mainclient module

Graphical interface of the TCP client. A launcher first pops out and drives the first handshake with the server running on the antenna’s computer. Then the main window shows up (if connected to the server), allowing operation of VEGA in an ergonomic way. This GUI allows to slew the Antenna Pointing Mechanism, acquire radio-astronomic data and process it to plot Power Spectrum Diagram.

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

Bases: QWidget

Widget on which the camera stream is displayed

closeEvent(event)

Override of the closeEvent method inherited from the Widget class in order to properly handle the destruction of the QCameraThread object

show_image(cap)

Slot in charge of refreshing the camera stream frame.

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

Bases: QWidget

Widget showing at execution of the script. Manages the first handshake with the server. Allows to specify the server address and target port. If the server accepts the connexion, the Launcher hides and the main GUI shows.

Note the Launcher does not have direct access to the TCP socket used for communication to the server. Instead, the TCP socket is owned by the MainClient object. To attempt connexion, the Launcher emits a Qt signal (connectAttempt) which is connected to the MainClient slot connectServ. This happens for reasons of necessary unicity of the reference to a QTCPsocket object and should not be changed.

ConnectClicked()
updateStatus(msg)

Changes status displayed in the textbar. Allows to show error messages, or feedbacks from the server.

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

Bases: QWidget

Main class of the client GUI. It owns a Launcher object, and accesses its attributes to achieve connexion with the server via self.client_socket before showing.

The window has 3 tabs : Motion, Measurements and Plot.

  • MOTION tab serves to slew the antenna to any coordinates given by user (systems available are AzAlt, RaDec and Galactic). When the “Track” box is checked, the antenna shall track the input coordinates irrespective of the coord system.

  • MEASUREMENTS tab serves to acquire data with the SDR. All parameters of the acquisition are tunable. See the antenna documentation for frequency ranges and specs of the SDR.

  • PLOT allows to show the Power Spectrum Diagram of the processed data from any chosen observation and according calibration file.

Notice all 3 tabs are independent and methods from each can be triggered simultaneously, e.g. a measurement while slewing the antenna.

See the SRT class documentation for more about calibration and observation process

BrowseCalibClicked()

Opens the file browser for the user to choose the calibration data file

BrowseMeasureClicked()

Opens the file browser for the user to choose the observation data file

ConnectClicked()

Sends the command to connect the mount. This usually triggers the water evacuation process.

ConnectedToMount()
DisconnectClicked()

Sends the command to disconnect the mount. Usually triggers the untangling of cables and parking to standby (zenith) position.

DisconnectedFromMount()
GoHomeClicked()
GoToClicked()

Processes and sends the command to slew VEGA to input coordinates. Depending on the coordinate system and if tracking is enabled, the sent command varies. See class ServerGUI for more about commands formatting.

Note the signal MovementStarted has the effect to disable several buttons, waiting for the server to confirm the motion of the mount is over nefore allowing sending a new slew command.

LaunchMeasurementClicked()

Sends to server the command to begin a measurement with parameters indicated in appropriate widgets by user. The progression bar corresponds to the input observation time and is not related to actual activity of the SDR.

MeasureProgressBarUpdater(valueOverride=-1)
MeasurementDone()

Triggered when the server confirms the measurement is over.

MovementFinished()

Slot triggered when the server sends the message IDLE, meaning the mount has finished its slew and is ready for new slewing command.

MovementStarted()

Triggered when a slewing command is sent to server. Disables most button from Motion tab, waiting for the sever to send IDLE before re-enabling them.

PlotClicked()
StopTrackingClicked()

Triggered when the “Stop Tracking” button is pushed. Sends to the server the command to stop tracking the target.

TrackFirstCoordDegreeChanged(val)
TrackFirstCoordHMSChanged(val)
TrackSecondCoordDegreeChanged(val)
TrackSecondCoordHMSChanged(val)
TrackingComboBoxChanged(index)
addToLog(strInput)

Adds a string to the log text box with timestamp.

Parameters:

strInput – message to log

Returns:

str

cameraThreadFinished()

Triggered when the camera window is closed

connectServ()

Slot activated when the “Connect” button of the launcher is pressed. Tries to connect to indicated IP address via TCP

connexionError()

Triggered when self.socket_client returns error signal

initGUI()

Initializes the GUI appearance and features

onDisconnected()

Triggered when the server disconnects the client, e.g. when admin closes the server, or at reboot

openCameraClicked()

Triggered when the ‘Open Camera’ button is pushed by user. Opens/closes a window displaying the video stream of VEGA’s camera. Notice the text switches to Close Camera, but the button is still the same

processMsg(msg, verbose)

Processes messages received from the server on the TCP socket.

First checks for concatenated messages. If several initial ‘&’ characters are found in msg, processes them one-by-one by the means of a recursive call.

Second, triggers the correct signals/methods depending on the message. Possible actions can be : hide launcher and show main window ; enable grey buttons to allow sending a new slewing command ; update displayed coordinates ; print feedback from server to the log textbox.

Parameters:
  • msg (str) – string message received from server

  • verbose (bool) – Debugging flag, prints msg to console

receiveMessage(verbose=False)

Decodes bytes sent by server to a string object which is processed by self.processMsg

The need to process comes from concatenation of several server messages when received at too high frequency. To prevent this phenomenon, all messages in two-ways server-client communications begin with the character ‘&’.

See self.processMsg for more about messages processing

Parameters:

verbose – passed to processMsg for debugging, printing the received message to console

sendServ(message)

Formats and sends a message to the server.

Parameters:

message (str) – command to send to the server. See class Server for more about commands formatting

setCurrentCoords(*args)

Internal methods. Updates displayed coordinates of the mount.

Parameters:

args (tuple of str) – a tuple containing the current coordinates to display in all systems

standbyClicked()

Sends command to park the mount by elevation slew to zenith

untangleClicked()

Sends command to untangle the cables of the mount by azimuthal rotation back to parking position

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

Bases: QThread

Thread handling the display of the camera stream

run()
turnOff()
turnOn()