mainserver module

Module defining the server to be run on the VEGA radio-telescope computer for monitoring remote users connexion to the antenna backend. If executed as main, simply instanciates and runs the server.

Notice that in addition to enabling remote connexions and ergonomic operation of VEGA, the proposed server-client architecture adds a layer of security by only allowing indirect user access to the APM features.

Format of exchanged messages :

Client -> Server : &{cmd} {*args, separated by spaces}

Server -> Client : &{Status}|{feedback}

with Status in (PRINT, OK, WARNING, ERROR)

Notice hence forbidden characters & and | in the body of exchanged messages

class SRTThread(*args: Any, **kwargs: Any)

Bases: QThread

Thread that handles communication with SRT object, including tracking. Internal class instantiated by ServerGUI. The self.msg is updated when a command is received from the client.

Constructor of the thread.

Parameters:

msg (str) – Motion command sent from client, to be processed and executed. Continuously updated

endMotion

alias of str

measurementDone()
pausePositionLogging()
receiveCommand(str)

Slot triggered when ServerGui receives a command to be executed by the SRT class

run()

Loop of the thread. Processes the command contained in self.msg, then resets it waiting for the next

send2log

alias of str

send2socket

alias of str

sendClient(msgSend)

Method that emits a signal with a non-formatted message to send to the server as argument. The signal triggers the ServerGUI.sendClient slot which in turns formats and sends the message to the client

Parameters:

msgSend (str) – non-formatted message to send to the client

sendError(msg)

Adds prefix ERROR to message passed to sendClient. See self.sendClient for more

sendOK(msg)

Adds prefix OK to message passed to sendClient. See self.sendClient for more

sendPos()

Method that sends to the client the current coordinates of the mount in all coordinate systems.

sendWarning(msg)

Adds prefix WARNING to message passed to sendClient. See self.sendClient for more

tracking()
unpausePositionLogging()
class ServerGUI(*args: Any, **kwargs: Any)

Bases: QMainWindow

Class that operates the server by handshaking clients, receiving and sending messages and modifying the GUI display in consequence.

Owner of the SRTthread that operates the mount

addToLog(strInput)

Adds statement to the GUI log console

Parameters:

strInput (str) – Message to be logged

closeEvent(event)

Triggered when the server GUI is closed manually

disconnectClient()

Method triggered when the client disconnects from the server A safety SRT disconnect is called in order to set the antenna to standby mode

handleConnection()

Method triggered when a new client connects the server If a client is already connected, rejects the connection Otherwise, executes the handshake (sends CONNECTED to client)

portChanged()

Handles manual port changing

processMsg(msg, verbose)

Method that processes the command sent from client. Note that several messages might be received simultaneously, hence the recursive approach taking advantage of the format of messages : &{command} {*args}

receiveLog(log)

Slot activated when a thread adds a message to log window

receiveMessage(verbose=True)

Method that handles receiving a message from the client via TCP socket

redirect_stdout()

Operates the redirection of stdout to both the server console and to the client via a msg with PRINT status

restore_stdout()

Method triggered when the client disconnects. Print statements are no longer redirected to a client

sendClient(msg, verbose=True)

Send message to client via TCP socket

sendEndMotion(cmd, feedback)

Sends message to client when motion is ended. See mainclient script for more detail

This is a slot connected to signal self.motionThread.endMotion

sendError(msg)

Adds prefix ERROR to message passed to sendClient. See self.sendClient for more

sendOK(msg)

Adds prefix OK to message passed to sendClient. See self.sendClient for more

sendToSRTSignal

alias of str

sendWarning(msg)

Adds prefix WARNING to message passed to sendClient. See self.sendClient for more

setIPAddress(stringIn)

Sets the IP address displayed in the GUI

Parameters:

stringIn (str) – IP address to update

class StdoutRedirector(target, parent=None)

Bases: StringIO

Handles the redirection of print statements to both the server-side console and to the client via messages with PRINT status

write(message)

Write string to file.

Returns the number of characters written, which is always equal to the length of the string.

get_ipv4_address()

Method that gets the ipv4 address of host to initialize the server

class sigEmettor(*args: Any, **kwargs: Any)

Bases: QObject

QObject that handles sending a signal from a non-Q thread. Used by StdoutRedirector to pass the Server a print statement to send to the client

printMsg

alias of str