Logo
Telescience Resource Kit
TReK Python  5.4.0 ART
TelemetryApi Class Reference

Provides access to telemetry features of TReK. More...

Inherits ApiClient.

Public Member Functions

Initialize / Finalize

Functions handling class initialization and destruction.

def TelemetryApi ( -> None ) -> def 
 Class initializer. More...
 
Packet Handling

Functions for retrieving packets.

def get_packet_definition (packet_key: str, packet: Packet -> None ) -> def 
 Retrieve the Packet definition for the specified key. More...
 
def get_newest_packet (packet_key: str, buffer: bytearray -> Tuple[int, int] ) -> def 
 Gets a copy of the newest packet available from the data store. More...
 
def get_next_packet (packet_key: str, token: int, buffer: bytearray -> Tuple[int, int, int] ) -> def 
 Gets a copy of the next packet available from the data store. More...
 
def get_this_packet (packet_key: str, token: int, buffer: bytearray -> int ) -> def 
 Gets a copy of the specified packet from the data store. More...
 
def get_source_list ( -> List[str] ) -> def 
 Gets the list of packet keys currently being processed. More...
 
def register_packet_semaphore (packet_key: str -> None ) -> def 
 Registers a semaphore to be signaled when a packet arrives. More...
 
def unregister_packet_semaphore (packet_key: str -> None ) -> def 
 Unregisters the packet arrival semaphore. More...
 
def wait_for_packet (packet_key: str, timeout: int=0 -> bool ) -> def 
 Waits for the specified packet to arrive. More...
 
Logging

Functions handling TReK logging.

def set_monitor_log_file (filename: str -> None ) -> def 
 Sets the filename prefix and path used for writing monitor messages if monitor logging is on. More...
 
def start_monitor_logging ( -> None ) -> def 
 Starts the logging of monitor messages. More...
 
def stop_monitor_logging ( -> None ) -> def 
 Stops the logging of monitor messages. More...
 
- Public Member Functions inherited from ApiClient
def cleanse ( -> None ) -> def 
 Cleans up any resources from crashed TReK user programs. More...
 
def connect ( str destination="DefaultDataStore" -> None ) -> def 
 Connects this instance of the API to TReK for the specified destination. More...
 
def is_connected ( -> bool ) -> def 
 Indicates if the API is connected. More...
 
def disconnect ( -> None ) -> def 
 Disconnects from the destination. More...
 
def get_wait_timeout ( -> int ) -> def 
 Returns the current timeout value for API calls. More...
 
def set_wait_timeout (timeout: int -> None ) -> def 
 Sets the timeout value for API calls that require communicating with TReK. More...
 

Detailed Description

Provides access to telemetry features of TReK.

This class provides access to the telemetry feature of TReK. Users of the class can get packets, convert and calibrate parameters.

Constructor & Destructor Documentation

◆ TelemetryApi()

() -> None

Class initializer.

TelemetryApi creation:

my_telemetry_api = TelemetryApi()

Reimplemented from ApiClient.

Member Function Documentation

◆ get_newest_packet()

(packet_key : str 
buffer : bytearray 
) -> Tuple[int, int]

Gets a copy of the newest packet available from the data store.

The returned packet can be processed with a Packet instance.

Parameters
[in]packet_keyThe packet key.
[in,out]bufferThe buffer to contain the back byte data.
Returns
Tuple[token, used_length] Returns a tuple containing the token value used to determine which packet was returned and the number of bytes of the buffer filled.
Exceptions
TrekError28010 - TLM_API_NULL_POINTER,

31123 - TCA_API_NOT_CONNECTED,

28026 - TLM_API_PKT_NAME_LEN_ERR,

31020 - TCA_WAIT_TIMEOUT,

28017 - TLM_API_DATA_STORE_WAIT_ERR,

28020 - TLM_API_LENGTH_ERR

◆ get_next_packet()

(packet_key : str 
token : int 
buffer : bytearray  
) -> Tuple[int, int, int]

Gets a copy of the next packet available from the data store.

Next is determined by the token provided. If this is the first request, the token should be 0. If the next packet is not availible anymore, the oldest packet will be returned and the return 'status' of the method will be TLM_API_MISSING_DATA. If additional data is available, the return 'status' TLM_API_MORE_DATA_AVAILABLE will be returned. A status of TLM_API_MISSING_DATA or TLM_API_MORE_DATA_AVAILABLE is not considered an error. The returned packet can be processed with a Packet instance.

Parameters
[in]packet_keyThe packet key.
[in]tokenToken used to determine the previous packet returned.
[in,out]bufferThe bytearray buffer holding the byte data of the packet, if successful.
Returns
Tuple[token, used_length, status] Returns a tuple containing the token value used to determine which packet was returned and the number of bytes of the buffer filled and a status code of SUCCESS = 0, TLM_API_MORE_DATA_AVAILABLE (28031) or TLM_API_MISSING_DATA (28030).
Exceptions
TrekError28010 - TLM_API_NULL_POINTER,

31123 - TCA_API_NOT_CONNECTED,

28026 - TLM_API_PKT_NAME_LEN_ERR,

31020 - TCA_WAIT_TIMEOUT,

28017 - TLM_API_DATA_STORE_WAIT_ERR,

28020 - TLM_API_LENGTH_ERR

◆ get_packet_definition()

(packet_key : str 
packet : Packet 
) -> None

Retrieve the Packet definition for the specified key.

The returned packet definition has all of the parameters available for this packet.

Parameters
[in]packet_keyThe packet key.
[in,out]packetThe Packet instance to hold the packet definition if successful.
Exceptions
TrekError28010 - TLM_API_NULL_POINTER,

31123 - TCA_API_NOT_CONNECTED,

28026 - TLM_API_PKT_NAME_LEN_ERR,

31020 - TCA_WAIT_TIMEOUT,

28017 - TLM_API_DATA_STORE_WAIT_ERR,

16008 - DATA_STORE_PACKET_DOES_NOT_EXIST,

28018 - TLM_API_COULD_NOT_LOAD_FILE

◆ get_source_list()

() -> List[str]

Gets the list of packet keys currently being processed.

This method returns a list[str] of the active packets in the corresponding TReK Data application.

Returns
list[str] of packet keys.
Exceptions
TrekError31123 - TCA_API_NOT_CONNECTED,

31020 - TCA_WAIT_TIMEOUT,

28017 - TLM_API_DATA_STORE_WAIT_ERR,

28022 - TLM_API_FILE_OPEN_ERR

◆ get_this_packet()

(packet_key : str 
token : int 
buffer : bytearray 
) -> int

Gets a copy of the specified packet from the data store.

If the packet still exists in the buffer with a matching token, it is returned.

Parameters
[in]packet_keyThe packey key.
[in]tokenA token value used to determine the packet to return.
[out]bufferA bytes array of sufficient size to hold the packet data.
Returns
The amount of space used in the provided buffer.

◆ register_packet_semaphore()

(packet_key : str ) -> None

Registers a semaphore to be signaled when a packet arrives.

If successful, wait_for_packet() can be called to be notified of the arrival of the next packet.

Parameters
[in]packet_keyThe packet key to register.
Exceptions
TrekError28010 - TLM_API_NULL_POINTER,

31123 - TCA_API_NOT_CONNECTED,

28026 - TLM_API_PKT_NAME_LEN_ERR,

31020 - TCA_WAIT_TIMEOUT,

28023 - TLM_API_ALREADY_EXISTS,

28017 - TLM_API_DATA_STORE_WAIT_ERR

◆ set_monitor_log_file()

(filename : str ) -> None

Sets the filename prefix and path used for writing monitor messages if monitor logging is on.

The filename should be the complete path to the file. The file is not created until start_monitor_logging() is called. When the file is created a timestamp is appended to the name and a ".log" extension is added after the timestamp.

Parameters
[in]filenameThe full path to a file prefix name for logging.
Exceptions
TrekError28010 - TLM_API_NULL_POINTER,

31123 - TCA_API_NOT_CONNECTED,

28019 - TLM_API_FILE_LEN_ERR,

31020 - TCA_WAIT_TIMEOUT

◆ start_monitor_logging()

() -> None

Starts the logging of monitor messages.

The filename prefix and path are set via set_monitor_log_file().

Exceptions
TrekError28010 - TLM_API_NULL_POINTER,

31123 - TCA_API_NOT_CONNECTED,

31020 - TCA_WAIT_TIMEOUT

◆ stop_monitor_logging()

() -> None

Stops the logging of monitor messages.

Closes current file in use for monitor messages. Starting logging again will create a new file.

Exceptions
TrekError28010 - TLM_API_NULL_POINTER,

31123 - TCA_API_NOT_CONNECTED,

31020 - TCA_WAIT_TIMEOUT

◆ unregister_packet_semaphore()

(packet_key : str ) -> None

Unregisters the packet arrival semaphore.

Removes the semaphore from the list of semaphores to be signalled when the specified packet arrives.

Parameters
[in]packet_keyThe packet key to unregister.
Exceptions
TrekError28010 - TLM_API_NULL_POINTER,

31123 - TCA_API_NOT_CONNECTED,

28026 - TLM_API_PKT_NAME_LEN_ERR,

31020 - TCA_WAIT_TIMEOUT,

28023 - TLM_API_ALREADY_EXISTS,

28017 - TLM_API_DATA_STORE_WAIT_ERR

◆ wait_for_packet()

(packet_key : str 
timeout : int  
) -> bool

Waits for the specified packet to arrive.

Will wait the specified time for a signal that a new packet has arrived. If the method returns SUCCESS, other API calls can be made to retrieve new data.

Note
If a packet arrives when the code has not blocked with a WaitForPacket call, wait_for_packet() will return immediately when called next to allow the program to retrieve data.
Parameters
[in]packet_keyThe awaited packet key.
[in]timeoutThe number of milliseconds to wait, 0 = infinite.
Returns
True, if packet arrived, else timeout occurred.
Exceptions
TrekError28010 - TLM_API_NULL_POINTER,

31123 - TCA_API_NOT_CONNECTED,

28026 - TLM_API_PKT_NAME_LEN_ERR,

31020 - TCA_WAIT_TIMEOUT,

28024 - TLM_API_DOES_NOT_EXIST