def create_packets_from_results(self, packet_name, result_set):
        ''' Generate AIT Packets from a InfluxDB query ResultSet

        Extract Influx DB query results into one packet per result entry. This
        assumes that telemetry data was inserted in the format generated by
        :func:`InfluxDBBackend.insert`. Complex types such as CMD16 and EVR16 are
        evaluated if they can be properly encoded from the raw value in the
        query result. If there is no opcode / EVR-code for a particular raw
        value the value is skipped (and thus defaulted to 0).

        Arguments
            packet_name (string)
                The name of the AIT Packet to create from each result entry

            result_set (influxdb.resultset.ResultSet)
                The query ResultSet object to convert into packets

        Returns
            A list of packets extracted from the ResultSet object or None if
            an invalid packet name is supplied.
                
        '''
        try:
            pkt_defn = tlm.getDefaultDict()[packet_name]
        except KeyError:
            log.error('Unknown packet name {} Unable to unpack ResultSet'.format(packet_name))
            return None

        pkt = tlm.Packet(pkt_defn)

        pkts = []
        for r in result_set.get_points():
            new_pkt = tlm.Packet(pkt_defn)

            for f, f_defn in pkt_defn.fieldmap.iteritems():
                field_type_name = f_defn.type.name
                if field_type_name == 'CMD16':
                    if cmd.getDefaultDict().opcodes.get(r[f], None):
                        setattr(new_pkt, f, cmd_def.name)
                elif field_type_name == 'EVR16':
                    if evr.getDefaultDict().codes.get(r[f], None):
                        setattr(new_pkt, f, r[f])
                elif field_type_name == 'TIME8':
                    setattr(new_pkt, f, r[f] / 256.0)
                elif field_type_name == 'TIME32':
                    new_val = dmc.GPS_Epoch + dt.timedelta(seconds=r[f])
                    setattr(new_pkt, f, new_val)
                elif field_type_name == 'TIME40':
                    sec = int(r[f])
                    microsec = r[f] * 1e6
                    new_val = dmc.GPS_Epoch + dt.timedelta(seconds=sec, microseconds=microsec)
                    setattr(new_pkt, f, new_val)
                elif field_type_name == 'TIME64':
                    sec = int(r[f])
                    microsec = r[f] % 1 * 1e6
                    new_val = dmc.GPS_Epoch + dt.timedelta(seconds=sec, microseconds=microsec)
                    setattr(new_pkt, f, new_val)
                else:
                    try:
                        setattr(new_pkt, f, r[f])
                    except KeyError:
                        log.info('Field not found in query results {} Skipping ...'.format(f))

            pkts.append(new_pkt)
        return pkts
def create_packets_from_results ( self , packet_name , result_set ) : try : pkt_defn = tlm . getDefaultDict ( ) [ packet_name ] except KeyError : log . error ( 'Unknown packet name {} Unable to unpack ResultSet' . format ( packet_name ) ) return None pkt = tlm . Packet ( pkt_defn ) pkts = [ ] for r in result_set . get_points ( ) : new_pkt = tlm . Packet ( pkt_defn ) for f , f_defn in pkt_defn . fieldmap . iteritems ( ) : field_type_name = f_defn . type . name if field_type_name == 'CMD16' : if cmd . getDefaultDict ( ) . opcodes . get ( r [ f ] , None ) : setattr ( new_pkt , f , cmd_def . name ) elif field_type_name == 'EVR16' : if evr . getDefaultDict ( ) . codes . get ( r [ f ] , None ) : setattr ( new_pkt , f , r [ f ] ) elif field_type_name == 'TIME8' : setattr ( new_pkt , f , r [ f ] / 256.0 ) elif field_type_name == 'TIME32' : new_val = dmc . GPS_Epoch + dt . timedelta ( seconds = r [ f ] ) setattr ( new_pkt , f , new_val ) elif field_type_name == 'TIME40' : sec = int ( r [ f ] ) microsec = r [ f ] * 1e6 new_val = dmc . GPS_Epoch + dt . timedelta ( seconds = sec , microseconds = microsec ) setattr ( new_pkt , f , new_val ) elif field_type_name == 'TIME64' : sec = int ( r [ f ] ) microsec = r [ f ] % 1 * 1e6 new_val = dmc . GPS_Epoch + dt . timedelta ( seconds = sec , microseconds = microsec ) setattr ( new_pkt , f , new_val ) else : try : setattr ( new_pkt , f , r [ f ] ) except KeyError : log . info ( 'Field not found in query results {} Skipping ...' . format ( f ) ) pkts . append ( new_pkt ) return pkts
Generate AIT Packets from a InfluxDB query ResultSet

        Extract Influx DB query results into one packet per result entry. This
        assumes that telemetry data was inserted in the format generated by
        :func:`InfluxDBBackend.insert`. Complex types such as CMD16 and EVR16 are
        evaluated if they can be properly encoded from the raw value in the
        query result. If there is no opcode / EVR-code for a particular raw
        value the value is skipped (and thus defaulted to 0).

        Arguments
            packet_name (string)
                The name of the AIT Packet to create from each result entry

            result_set (influxdb.resultset.ResultSet)
                The query ResultSet object to convert into packets

        Returns
            A list of packets extracted from the ResultSet object or None if
            an invalid packet name is supplied.