def test_ccsds_plugin_validate_cfs_ccsds_data(ccsds_plugin_instance, cfs_plugin_instance): """ Test CCSDS plugin validate_cfs_ccsds_data method: Validates the CCSDS data types by sending an empty instance of each command code found in the MID map to CFS. """ with patch('plugins.cfs.pycfs.cfs_controllers.LocalCfsInterface'): if Global.get_time_manager() is None: print("Global.get_time_manager() is None:") cfs_plugin_instance.initialize() Global.plugins_available = {"CFS Plugin": cfs_plugin_instance} cfs_plugin_instance.register_cfs('cfs') with patch('plugins.cfs.cfs_plugin.CfsPlugin.send_cfs_command', return_value=True), \ patch('lib.ctf_global.Global.time_manager.wait', return_value=True): ccsds_plugin_instance.validate_cfs_ccsds_data('cfs')
def on_packet_received(self, mid: int, payload: any) -> None: """ If this is the first time receiving a packet with the given mid then print the value of the mid. """ if not self.has_received_mid[mid]: log.info("Receiving Packet for Data Type: {} with MID: {}".format( type(payload), hex(mid))) # Update the array so that the message is not printed again self.has_received_mid[mid] = True payload_count = len(self.received_mid_packets_dic[mid]) + 1 # Add the received packet to the dictionary under the correct mid packet = Packet(mid, payload, payload_count, Global.get_time_manager().exec_time) self.received_mid_packets_dic[mid].append(packet) self.tlm_has_been_received = True self.unchecked_packet_mids.append(mid)
def write_tlm_log(self, payload, buf, mid): """ Write payload and mid to telemetry log file. if log file does not exist, create one. """ if self.tlm_log_file is None: tlm_log_file_path = os.path.join( Global.current_script_log_dir, self.config.name + "_tlm_msgs.log") self.tlm_log_file = open(tlm_log_file_path, "w+") self.tlm_log_file.write("Time: MID, Data\n") try: self.tlm_log_file.write("{}: {}\n\t{}\n".format( Global.get_time_manager().exec_time, hex(mid), str(payload).replace("\n", "\n\t"))) if self.config.telemetry_debug: self.tlm_log_file.write( " For mid {} Payload length: {} hex values: 0X{}\n". format(hex(mid), len(buf), buf.hex())) except IOError: log.error( "Failed to write telemetry packet received for {}".format( hex(mid))) traceback.format_exc()
def test_ctf_global_time_manager(): assert Global.get_time_manager() is None Global.set_time_manager(Mock()) assert Global.get_time_manager() == Global.time_manager