Exemplo n.º 1
0
    def __init__(self, time_base=0, time_context=0, seconds=0, useconds=0):
        '''
        Constructor

        Args
            time_base (int): Time base index for the time tag. Must be a valid
                             integer for a TimeBase Enum value.
            time_context (int): Time context for the time tag
            seconds (int): Seconds elapsed since specified time base
            useconds (int): Microseconds since start of current second. Must
                            be in range [0, 999999] inclusive

        Returns:
            An initialized TimeType object
        '''
        # Layout of time tag:
        #
        # START (LSB)
        # |  2 bytes  |    1 byte    | 4 bytes |   4 bytes    |
        # |-----------|--------------|---------|--------------|
        # | Time Base | Time Context | Seconds | Microseconds |

        self._check_time_base(time_base)
        self._check_useconds(useconds)

        self.__timeBase = u16_type.U16Type(time_base)
        self.__timeContext = u8_type.U8Type(time_context)
        self.__secs = u32_type.U32Type(seconds)
        self.__usecs = u32_type.U32Type(useconds)
Exemplo n.º 2
0
    def decode_ch_api(self, msg):
        """
        Decode channel telemetry item using Channel object dictionary.
        """
        #type_base.showBytes(msg)
        #
        ptr = 0

        # Decode log channel ID here...
        u32_obj = u32_type.U32Type()
        u32_obj.deserialize(msg, ptr)
        ptr += u32_obj.getSize()
        tlm_id = u32_obj.val
        #print "ID: %d" % i

        # Decode time...
        # Time base
        u32_obj = u16_type.U16Type()
        u32_obj.deserialize(msg, ptr)
        ptr += u32_obj.getSize()
        time_base = u32_obj.val
        #print "Time Base: %d" % time_base

        # Time context
        u8_obj = u8_type.U8Type()
        u8_obj.deserialize(msg, ptr)
        ptr += u8_obj.getSize()
        time_context = u8_obj.val

        # Seconds
        u32_obj = u32_type.U32Type()
        u32_obj.deserialize(msg, ptr)
        ptr += u32_obj.getSize()
        time_secs = u32_obj.val
        #print "Time Seconds: %d" % time_secs
        # Micro-seconds
        u32_obj = u32_type.U32Type()
        u32_obj.deserialize(msg, ptr)
        ptr += u32_obj.getSize()
        time_usecs = u32_obj.val
        #print "Time MicroSeconds: %d" % time_usecs

        # Decode value here...
        # Look up correct Channel channel telemetry instance object for decoding
        if tlm_id in self.__ch_obj_dict:
            ch_obj = self.__ch_obj_dict[tlm_id]
            # Deserialize to a tuple to stringify
            ch_value = ch_obj.deserialize(msg, ptr)
            return (tlm_id, ch_value)
        else:
            return None
Exemplo n.º 3
0
    def decode_event_api(self, msg):
        """
        Decode event log message using Event object dictionary.
        @return (Event ID, Event Arguments)
        """

        ptr = 0

        # Decode log event ID here...
        u32_obj = u32_type.U32Type()
        u32_obj.deserialize(msg, ptr)
        ptr += u32_obj.getSize()
        event_id = u32_obj.val
        #print "ID: %d" % i

        # Decode time...
        # Base
        u32_obj = u16_type.U16Type()
        u32_obj.deserialize(msg, ptr)
        ptr += u32_obj.getSize()
        time_base = u32_obj.val
        #print "Time Base: %d" % time_base

        # Time context
        u8_obj = u8_type.U8Type()
        u8_obj.deserialize(msg, ptr)
        ptr += u8_obj.getSize()
        time_context = u8_obj.val

        # Seconds
        u32_obj = u32_type.U32Type()
        u32_obj.deserialize(msg, ptr)
        ptr += u32_obj.getSize()
        time_secs = u32_obj.val
        #print "Time Seconds: %d" % time_secs
        # Micro-seconds
        u32_obj = u32_type.U32Type()
        u32_obj.deserialize(msg, ptr)
        ptr += u32_obj.getSize()
        time_usecs = u32_obj.val
        #print "Time MicroSeconds: %d" % time_usecs

        if event_id in self.__event_obj_dict:
            event_obj = self.__event_obj_dict[event_id]
            event_args = event_obj.deserialize(msg[ptr:])[1:]
            return (event_id, event_args)
        else:
            return None
Exemplo n.º 4
0
    def decode_event(self, msg):
        """
        Decode event log message using Event object dictionary.
        """
        #type_base.showBytes(msg)
        #
        ptr = 0

        # Decode log event ID here...
        u32_obj = u32_type.U32Type()
        u32_obj.deserialize(msg, ptr)
        ptr += u32_obj.getSize()
        i = u32_obj.val
        #print "ID: %d" % i

        # Decode time...
        # Base
        u32_obj = u16_type.U16Type()
        u32_obj.deserialize(msg, ptr)
        ptr += u32_obj.getSize()
        time_base = u32_obj.val
        #print "Time Base: %d" % time_base

        # Time context
        u8_obj = u8_type.U8Type()
        u8_obj.deserialize(msg, ptr)
        ptr += u8_obj.getSize()
        time_context = u8_obj.val

        # Seconds
        u32_obj = u32_type.U32Type()
        u32_obj.deserialize(msg, ptr)
        ptr += u32_obj.getSize()
        time_secs = u32_obj.val
        #print "Time Seconds: %d" % time_secs
        # Micro-seconds
        u32_obj = u32_type.U32Type()
        u32_obj.deserialize(msg, ptr)
        ptr += u32_obj.getSize()
        time_usecs = u32_obj.val
        #print "Time MicroSeconds: %d" % time_usecs

        # Decode arguments here...
        # Look up correct Event event log message instance object for decoding
        if i in self.__event_obj_dict:
            event_obj = self.__event_obj_dict[i]
            #
            # Deserialize to a tuple to stringify
            event_args = event_obj.deserialize(msg[ptr:])
            # Stringify to formatted message string for GUI updates
            fmt = event_obj.stringify(event_args)
            #
            # Package NAME, ID, SEVERITY, and formatted string into tuple for views update.
            # 'Name (id) Severity : formatted string'
            name = event_obj.getName()
            event_id = event_obj.getId()
            severity = event_obj.getSeverity()

            # See if set to workstation time
            if (time_base == 2) or (time_base == 3):
                if self.__opt.log_time == "local":
                    event_time = time.strftime("%m/%d-%H:%M:%S",
                                               time.localtime(time_secs))
                else:
                    event_time = time.strftime("%m/%d-%H:%M:%S",
                                               time.gmtime(time_secs))

            else:
                event_time = "%f" % (float(time_secs) +
                                     (float(time_usecs) / 1000000))
                # Create tuple of log msg string and log msg object
            msg_tup = (event_time, name, event_id, severity, fmt)
            self.__current_event_log_msg = ("%s: %s (%d) %s : %s" % msg_tup,
                                            msg_tup)
            #print self.__current_event_log_msg
        else:
            self.__current_event_log_msg = "EVR ID Received but could not be decoded: %d" % i
Exemplo n.º 5
0
    def decode_ch(self, msg):
        """
        Decode channel telemetry item using Channel object dictionary.
        """
        #type_base.showBytes(msg)
        #
        ptr = 0

        # Decode channel ID here...
        u32_obj = u32_type.U32Type()
        u32_obj.deserialize(msg, ptr)
        ptr += u32_obj.getSize()
        i = u32_obj.val
        #print "ID: 0x%04X" % i

        # Decode time...
        # Base
        u32_obj = u16_type.U16Type()
        u32_obj.deserialize(msg, ptr)
        ptr += u32_obj.getSize()
        time_base = u32_obj.val
        #print "Time Base: %d" % time_base

        # Decode context
        u8_obj = u8_type.U8Type()
        u8_obj.deserialize(msg, ptr)
        ptr += u8_obj.getSize()
        time_context = u8_obj.val
        #print "Time Context: %d" % time_context

        # Seconds
        u32_obj = u32_type.U32Type()
        u32_obj.deserialize(msg, ptr)
        ptr += u32_obj.getSize()
        time_secs = u32_obj.val
        #print "Time Seconds: %d" % time_secs
        # Micro-seconds
        u32_obj = u32_type.U32Type()
        u32_obj.deserialize(msg, ptr)
        ptr += u32_obj.getSize()
        time_usecs = u32_obj.val
        #print "Time MicroSeconds: %d" % time_usecs

        # Decode value here...
        # Look up correct Channel channel telemetry instance object for decoding
        if i in self.__ch_obj_dict:
            ch_obj = self.__ch_obj_dict[i]
            #
            # Set time here...
            ch_obj.setTime(time_base, time_context, time_secs, time_usecs)
            #
            # Deserialize to a tuple to stringify
            ch_value = ch_obj.deserialize(msg, ptr)
            #print "Value: %s" % ch_value
            #
            # Package NAME, ID, CH. Desc., time, and Value into tuple for views update.
            # '(Name, id, ch. desc., time_sec, time_usec, value)'
            name = ch_obj.getName()
            i = ch_obj.getId()
            ch = ch_obj.getChDesc()
            t = ch_obj.getTime()
            f = ch_obj.getFormatString()
            lr = ch_obj.getLowRed()
            lo = ch_obj.getLowOrange()
            ly = ch_obj.getLowYellow()
            hy = ch_obj.getHighYellow()
            ho = ch_obj.getHighOrange()
            hr = ch_obj.getHighRed()

            self.__current_ch_msg = (name, i, ch, t, ch_value, f, lr, lo, ly,
                                     hy, ho, hr)

            #print self.__current_ch_msg
        else:
            self.__current_ch_msg = ("Not_Defined", i, "", ("", "", "",
                                                            ""), "Not_Defined",
                                     "Not_Defined", "NoLowRed", "NoLowOrange",
                                     "NoLowYellow", "NoHighYellow",
                                     "NoHighOrange", "NoHighRed")
Exemplo n.º 6
0
 def timeContext(self, val):
     self.__timeContext = u8_type.U8Type(val)