libgs.protocols.protocolbase.ProtocolBase¶
-
class
libgs.protocols.protocolbase.
ProtocolBase
[source]¶ Base class for protocols. Defines the primary interface that is used by the scheduler. Any protocol used by the library must implement the following methods:
send_bytes()
: Send a sequence of bytes to the satellitedo_action()
: Ask the protocol to do something. The do_action should take different actions, depending on the arguments, but there are no further requirements on what those arguments should be.set_handler()
: Set callback for when data is received back from satellite, this is invoked by the ground-station class upon creation. The groundstation will expect the callback function to be called every time data is received from the satellite. It is the responsibility of the Protocol to ensure that happens.
The following class attribute shall also be overloaded:
name
: The name of the protocol
Additionally a protocol may implement the following methods:
init_rx()
: This method will be called by the scheduler before starting a listening pass. It should contain any initialisation routines required.init_rxtx()
: This method will be called by the scheduler before starting a transmitting pass. It should contain any initialisation routines required (power on amplifiers etc…)terminate()
: This method will be called by the scheduler as soon as a pass has finished. It should contain any clean-up routines required (power off amplifiers etc…), and most importantly ensure that any threads or loops initiated by the Protocolclass are immediately terminated in a clean and controlled manner.
When the scheduler starts a pass it will also set an attribute on the protocol class called sch_metadata. This attribute contains all the metadata stored in the currently scheduled
CommsPass
, and is available to the Protocol class to refer to as needed.Warning
Warning 1
This class should avoid blocking functions at all cost, and need to respond to the global abort_all event to allow libgs to shut down cleanly. A method is provided in libgs.utils called wait_loop that can be used as a replacement for time.sleep and/or waiting for events to occur. wait_loop will automatically handle the global abort_all event.
Warning
Warning 2
It is imperative that the terminate() method immediately stops any and all running processes or threads spawned by the Protocol class.
Methods
do_action
(*args, **kwargs)Request an action to be performed init_rx
()Interface method that is called by the scheduler before starting a listening pass. init_rxtx
()Interface method that is called by the scheduler before starting a transmitting pass. send_bytes
(data[, wait])Send a sequence of bytes to the satellite. set_handler
(func)Set a callback message handler for received data. terminate
()Interface method that is called by the scheduler as soon as a pass has finished. Attributes
name
The name of the protocol. sch_metadata
The scheduler will update this property with any metadata the operator has attached to the schedule, thereby allowing him/her to pass information to the protocol class Inherited from base class