def tc_19_1_get_data(self, packet):
     """
     This function parses the st19 packet data field to json
     :param packet: The packet which data field we want to parse
     :return: A JSON object with all the parsed information
     """
     data = dict()
     packet_reduced = pb.pusPacketReduced_t()
     pb.pus_tc_19_1_getAction(packet_reduced, packet)
     data_packet = pb.pusPacket_t()
     pb.pus_packetReduced_createPacketFromPacketReduced(
         data_packet, packet_reduced)
     event_id = pb.pus_tc_19_X_getEventId(packet)
     data["event_id"] = event_id
     data["request"] = self.packet2json(data_packet)
     return data
 def tc_11_4_get_data(self, packet):
     """
     This function parses the st011-4 packet data field to json
     :param packet: The packet which data field we want to parse
     :return: A JSON object with all the parsed information
     """
     data = dict()
     ncount = pb.pus_tc_11_4_getNCount(packet)
     for i in range(ncount):
         data["activity" + str(i + 1)] = dict()
         data_packet = pb.pusPacket_t()
         pb.pus_tc_11_4_get_request(i, packet, data_packet, 10)
         t = pb.pus_tc_11_4_get_release_time(i, packet, 10)
         data["activity" +
              str(i + 1)]["packet"] = self.packet2json(data_packet)
         data["activity" + str(i + 1)]["time"] = t  # REVISAR, tiempo
     return data
    def show_packet_json(self, svc, msg):
        """
        This method writes the packet with the service id and message id
        specified in json format in the textbox of the window.
        :param svc: Service id of the packet
        :param msg: Message id of the packet
        :return: The packet in json format
        """
        packet = pb.pusPacket_t()
        packet_translator = PacketTranslator()

        apid_info = self.model.apid_info
        apid = pb.pus_getInfoApid(apid_info)
        seq = pb.pus_getNextPacketCount(apid_info)

        if (svc, msg) == (8, 1):
            pb.pus_tc_8_1_createPerformFuctionRequest(packet, apid, seq, 0)
        elif (svc, msg) == (9, 1):
            pb.pus_tc_9_1_createSetTimeReportRate(packet, apid, seq, 0)
        elif svc == 11:
            if msg == 1:
                pb.pus_tc_11_1_createEnableTimeBasedSchedule(packet, apid, seq)
            elif msg == 2:
                pb.pus_tc_11_2_createDisableTimeBasedSchedule(
                    packet, apid, seq)
            elif msg == 3:
                pb.pus_tc_11_3_createResetTimeBasedSchedule(packet, apid, seq)
        elif svc == 12:
            if msg == 1:
                pb.pus_tc_12_1_createEnableParameterMonitoringDefinitions(
                    packet, apid, seq, 0)
            elif msg == 2:
                pb.pus_tc_12_2_createDisableParameterMonitoringDefinitions(
                    packet, apid, seq, 0)
            elif msg == 15:
                pb.pus_tc_12_15_createEnableParameterMonitoring(
                    packet, apid, seq)
            elif msg == 16:
                pb.pus_tc_12_16_createDisableParameterMonitoring(
                    packet, apid, seq)
        elif (svc, msg) == (17, 1):
            pb.pus_tc_17_1_createConnectionTestRequest(packet, apid, seq)
        elif svc == 19:
            if msg == 2:
                pb.pus_tc_19_2_createDeleteEventActionDefinitionsRequest(
                    packet, apid, seq, 0)
            elif msg == 4:
                pb.pus_tc_19_4_createEnableEventActionDefinitions(
                    packet, apid, seq, 0)
            elif msg == 5:
                pb.pus_tc_19_5_createDisableEventActionDefinitions(
                    packet, apid, seq, 0)
        elif svc == 20:
            if msg == 1:
                pb.pus_tc_20_1_createParameterValueRequest(
                    packet, apid, seq, 0)
            elif msg == 3:
                pb.pus_tc_20_3_createSetParameterValueRequest(
                    packet, apid, seq, 0, 0)
        elif svc == 23:
            if msg == 1:
                pb.pus_tc_23_1_createCreateFileRequest(packet, apid, seq, "",
                                                       "", 0)
            elif msg == 2:
                pb.pus_tc_23_2_createDeleteFileRequest(packet, apid, seq, "",
                                                       "")
            elif msg == 3:
                pb.pus_tc_23_3_createReportFileAtributesRequest(
                    packet, apid, seq, "", "")
            elif msg == 14:
                pb.pus_tc_23_14_createCopyFileRequest(packet, apid, seq, "",
                                                      "", "", "")
        else:
            pass
        return packet_translator.packet2json(packet)
    def show_packet_json(self, svc, msg):
        """
        This method writes the packet with the service id and message id
        specified in json format in the textbox of the window.
        :param svc: Service id of the packet
        :param msg: Message id of the packet
        :return: The packet in json format
        """
        packet = pb.pusPacket_t()
        packet_translator = PacketTranslator()
        apid_info = self.model.apid_info
        apid = pb.pus_getInfoApid(apid_info)
        seq = pb.pus_getNextPacketCount(apid_info) # REVISAR parece que la secuencia no aumenta

        if (svc, msg) == (8, 1):
            pb.pus_tc_8_1_createPerformFuctionRequest(packet, apid, seq, 0)
        elif (svc, msg) == (9, 1):
            pb.pus_tc_9_1_createSetTimeReportRate(packet, apid, seq, 0)
        elif svc == 11:
            if msg == 1:
                print(pb.pus_tc_11_1_createEnableTimeBasedSchedule(packet, apid, seq))
            elif msg == 2:
                pb.pus_tc_11_2_createDisableTimeBasedSchedule(packet, apid, seq)
            elif msg == 3:
                pb.pus_tc_11_3_createResetTimeBasedSchedule(packet, apid, seq)
            elif msg == 4:
                self.view.window.addTcButton.show()
                pb.pus_tc_11_4_createInsertActivityIntoSchedule(packet, apid, seq)

                scndpacket, schedule = self.open_add_tc_window(True)
                packet_translator.packet2json(scndpacket)
                if scndpacket is None:
                    self.view.window.msgComboBox.setCurrentIndex(0)
                    return None, None
                elif schedule is None:
                    time_ = pb.pusTime_t()
                    pb.pus_now(time_)
                else:
                    time_ = pb.pus_posix2time(schedule)
                    pb.pus_tc_11_4_setActivity(packet, scndpacket, time_)
        elif svc == 12:
            if msg == 1:
                pb.pus_tc_12_1_createEnableParameterMonitoringDefinitions(packet, apid, seq, 0)
            elif msg == 2:
                pb.pus_tc_12_2_createDisableParameterMonitoringDefinitions(packet, apid, seq, 0)
            elif msg == 15:
                pb.pus_tc_12_15_createEnableParameterMonitoring(packet, apid, seq)
            elif msg == 16:
                pb.pus_tc_12_16_createDisableParameterMonitoring(packet, apid, seq)
        elif (svc, msg) == (17, 1):
            pb.pus_tc_17_1_createConnectionTestRequest(packet, apid, seq)
        elif (svc, msg) == (18, 1):
            obcpid, length, obcpcode = self.open_obcp_add_code_window()
            pb.pus_tc_18_1_createLoadObcpDirectRequest(packet, apid, seq, obcpid, obcpcode, length)
        elif (svc, msg) == (18, 2):
            pb.pus_tc_18_2_createUnloadObcpRequest(packet, apid, seq, "")
        elif (svc, msg) == (18, 3):
            pb.pus_tc_18_3_createActivateObcpRequest(packet, apid, seq, "", 0)
        elif (svc, msg) == (18, 4):
            pb.pus_tc_18_4_createStopObcpRequest(packet, apid, seq, "", 0)
        elif (svc, msg) == (18, 5):
            pb.pus_tc_18_5_createSuspendObcpRequest(packet, apid, seq, "", 0)
        elif (svc, msg) == (18, 6):
            pb.pus_tc_18_6_createResumeObcpRequest(packet, apid, seq, "")
        elif (svc, msg) == (18, 12):
            pb.pus_tc_18_12_createAbortObcpRequest(packet, apid, seq, "")
        elif (svc, msg) == (18, 13):
            pb.pus_tc_18_13_createLoadObcpReferenceRequest(packet, apid, seq, "", "", "")
        elif (svc, msg) == (18, 21):
            pb.pus_tc_18_21_createStartObcpEngineRequest(packet, apid, seq,)
        elif (svc, msg) == (18, 22):
            pb.pus_tc_18_22_createStopObcpEngineRequest(packet, apid, seq)
        elif svc == 19:
            if msg == 1:
                scndpacket, event = self.open_add_tc_window(False)
                if scndpacket is None:
                    self.view.window.msgComboBox.setCurrentIndex(0)
                    return None, None
                else:
                    pb.pus_tc_19_1_createAddEventActionDefinitionsRequest(packet, apid, seq, event, scndpacket)
            elif msg == 2:
                pb.pus_tc_19_2_createDeleteEventActionDefinitionsRequest(packet, apid, seq, 0)
            elif msg == 4:
                pb.pus_tc_19_4_createEnableEventActionDefinitions(packet, apid, seq, 0)
            elif msg == 5:
                pb.pus_tc_19_5_createDisableEventActionDefinitions(packet, apid, seq, 0)
        elif svc == 20:
            if msg == 1:
                pb.pus_tc_20_1_createParameterValueRequest(packet, apid, seq, 0)
            elif msg == 3:
                pb.pus_tc_20_3_createSetParameterValueRequest(packet, apid, seq, 0, 0)
        elif svc == 23:
            if msg == 1:
                pb.pus_tc_23_1_createCreateFileRequest(packet, apid, seq, "", "", 0)
            elif msg == 2:
                pb.pus_tc_23_2_createDeleteFileRequest(packet, apid, seq, "", "")
            elif msg == 3:
                pb.pus_tc_23_3_createReportFileAtributesRequest(packet, apid, seq, "", "")
            elif msg == 14:
                pb.pus_tc_23_14_createCopyFileRequest(packet, apid, seq, "", "", "", "")
        else:
            pass
        return packet_translator.packet2json(packet), packet
Esempio n. 5
0
 def update_packets(self):
     for _ in range(10):
         packet = pb.pusPacket_t()
         if pb.pusError_t.PUS_NO_ERROR == pb.pus_notify_readTm(
                 packet):  # Comprobar si null
             self.add_table_signal.throw(packet)
    def create_default_packet(jsn):
        """
        This method creates a default packet for the packet specified
        in the json passed as an argument
        :param jsn: The packet in json format
        :return: A packet object
        """
        packet = pb.pusPacket_t()
        svc = jsn["data"]["pck_sec_head"]["msg_type_id"]["service_type_id"]
        msg = jsn["data"]["pck_sec_head"]["msg_type_id"]["msg_subtype_id"]

        if (svc, msg) == (8, 1):
            pb.pus_tc_8_1_createPerformFuctionRequest(packet, 0, 0, 0)
        elif (svc, msg) == (9, 1):
            pb.pus_tc_9_1_createSetTimeReportRate(packet, 0, 0, 0)
        elif (svc, msg) == (11, 1):
            pb.pus_tc_11_1_createEnableTimeBasedSchedule(packet, 0, 0)
        elif (svc, msg) == (11, 2):
            pb.pus_tc_11_2_createDisableTimeBasedSchedule(packet, 0, 0)
        elif (svc, msg) == (11, 3):
            pb.pus_tc_11_3_createResetTimeBasedSchedule(packet, 0, 0)
        elif (svc, msg) == (11, 4):
            pb.pus_tc_11_4_createInsertActivityIntoSchedule(packet, 0, 0)
        elif (svc, msg) == (12, 1):
            pb.pus_tc_12_1_createEnableParameterMonitoringDefinitions(
                packet, 0, 0, 0)
        elif (svc, msg) == (12, 2):
            pb.pus_tc_12_2_createDisableParameterMonitoringDefinitions(
                packet, 0, 0, 0)
        elif (svc, msg) == (12, 15):
            pb.pus_tc_12_15_createEnableParameterMonitoring(packet, 0, 0)
        elif (svc, msg) == (12, 16):
            pb.pus_tc_12_16_createDisableParameterMonitoring(packet, 0, 0)
        elif (svc, msg) == (17, 1):
            pb.pus_tc_17_1_createConnectionTestRequest(packet, 0, 0)
        elif (svc, msg) == (18, 1):
            pb.pus_tc_18_1_createLoadObcpDirectRequest(packet, 0, 0, "", [1],
                                                       1)
        elif (svc, msg) == (18, 2):
            pb.pus_tc_18_2_createUnloadObcpRequest(packet, 0, 0, "")
        elif (svc, msg) == (18, 3):
            pb.pus_tc_18_3_createActivateObcpRequest(packet, 0, 0, "", 0)
        elif (svc, msg) == (18, 4):
            pb.pus_tc_18_4_createStopObcpRequest(packet, 0, 0, "", 0)
        elif (svc, msg) == (18, 5):
            pb.pus_tc_18_5_createSuspendObcpRequest(packet, 0, 0, "", 0)
        elif (svc, msg) == (18, 6):
            pb.pus_tc_18_6_createResumeObcpRequest(packet, 0, 0, "")
        elif (svc, msg) == (18, 12):
            pb.pus_tc_18_12_createAbortObcpRequest(packet, 0, 0, "")
        elif (svc, msg) == (18, 13):
            pb.pus_tc_18_13_createLoadObcpReferenceRequest(
                packet, 0, 0, "", "", "")
        elif (svc, msg) == (18, 21):
            pb.pus_tc_18_21_createStartObcpEngineRequest(packet, 0, 0)
        elif (svc, msg) == (18, 22):
            pb.pus_tc_18_22_createStopObcpEngineRequest(packet, 0, 0)
        elif (svc, msg) == (19, 1):
            pb.pus_tc_19_1_createAddEventActionDefinitionsRequest(
                packet, 0, 0, 0, pb.pusPacket_t())
        elif (svc, msg) == (19, 2):
            pb.pus_tc_19_2_createDeleteEventActionDefinitionsRequest(
                packet, 0, 0, 0)
        elif (svc, msg) == (19, 4):
            pb.pus_tc_19_4_createEnableEventActionDefinitions(packet, 0, 0, 0)
        elif (svc, msg) == (19, 5):
            pb.pus_tc_19_5_createDisableEventActionDefinitions(packet, 0, 0, 0)
        elif (svc, msg) == (20, 1):
            pb.pus_tc_20_1_createParameterValueRequest(packet, 0, 0, 0)
        elif (svc, msg) == (20, 3):
            pb.pus_tc_20_3_createSetParameterValueRequest(packet, 0, 0, 0, 0)
        elif (svc, msg) == (23, 1):
            pb.pus_tc_23_1_createCreateFileRequest(packet, 0, 0, "", "", 0)
        elif (svc, msg) == (23, 2):
            pb.pus_tc_23_2_createDeleteFileRequest(packet, 0, 0, "", "")
        elif (svc, msg) == (23, 3):
            pb.pus_tc_23_3_createReportFileAtributesRequest(
                packet, 0, 0, "", "")
        elif (svc, msg) == (23, 14):
            pb.pus_tc_23_14_createCopyFileRequest(packet, 0, 0, "", "", "", "")
        else:
            pass
        """
            REVISAR Haria falta meter el 11 ??? y las telemetrias???
        """
        return packet