def unassign(self, connectionName, streamId): destStreams = [] destConns = [] destPorts = [] # make sure that the connection exists if (self.outPorts[connectionName] != None): if (not connectionName in self.connectionToStream): destStreams = [] self.connectionToStream[connectionName] = destStreams else: raise BULKIO.invalidConnectionName() # make sure that the streamId exists if (self.defaultSRIList[streamId] == None): raise BULKIO.invalidStreamID() if (destStreams != None): destStreams.remove(streamId) if (streamId in self.streamToConnection): destConns = self.streamToConnection[streamId] destConns.remove(connectionName) if (streamId in self.streamToPorts): destPorts = self.streamToPorts.get[streamId] destPorts.remove(self.outPorts[connectionName])
def assign(self, connectionName, streamId): destStreams = [] destConns = [] destPorts = [] self.outPorts = self.parent.virtual_port.outPorts # make sure that the connection exists if (self.outPorts[connectionName] != None): if (not connectionName in self.connectionToStream): destStreams = [] self.connectionToStream[connectionName] = destStreams else: raise BULKIO.invalidConnectionName() # make sure that the streamId exists if (self.defaultSRIList[streamId] == None): raise BULKIO.invalidStreamID() else: if (not streamId in self.streamToConnection): destConns = [] self.streamToConnection[streamId] = destConns if (not streamId in self.streamToPorts): destPorts = [] self.streamToPorts[streamId] = destPorts destStreams.append(streamId) destConns.append(connectionName) destPorts.append(self.outPorts[connectionName]) self.refreshSRIList[streamId] = True
def testChangeBlockWithNonEmptyQueue(self): self.utility() numPackets = 6 #set the queueDepth to the number of packets intending to be sent - 1 self.comp.mqd = numPackets - 1 #set the port to not block (this is default behavior s2_sri = BULKIO.StreamSRI(1, 0.0, 0.001, 1, 300, 0.0, 0.001, 1, 1, 's2', False, []) self.dataShortInput.pushSRI(s2_sri) #fill the queue half way self.dataShortInput.pushPacket([1], bulkio_helpers.createCPUTimestamp(), False, 's2') self.dataShortInput.pushPacket([1], bulkio_helpers.createCPUTimestamp(), False, 's2') self.dataShortInput.pushPacket([1], bulkio_helpers.createCPUTimestamp(), False, 's2') #now set the port the be blocking s1_sri = BULKIO.StreamSRI(1, 0.0, 0.001, 1, 300, 0.0, 0.001, 1, 1, 's1', True, []) self.dataShortInput.pushSRI(s1_sri) #should still be able to push 2 more before the queue is full self.dataShortInput.pushPacket([1], bulkio_helpers.createCPUTimestamp(), False, 's2') self.dataShortInput.pushPacket([1], bulkio_helpers.createCPUTimestamp(), False, 's2') #send the last packet in a separate thread #this call should block, not flush t2 = threading.Thread(None, self.pushOnePacketThread, 't2', ('s2', ), {}) t2.setDaemon(True) t2.start() #start the 'quasi' component thread, tell him to receive numPackets t1 = threading.Thread(None, self.getPacketThread, 't1', (numPackets, ), {}) t1.setDaemon(True) t1.start() self.comp.start() t2.join() t1.join() self.comp.stop() #should not have flushed self.assertTrue(not self.queueFlushed) self.assertTrue(self.packetsReceived == numPackets) self.comp.releaseObject()
def _retrieveStats(self, connectionId, connection): stats = connection.stats.retrieve() stats.streamIDs = [ stream_id for stream_id in self._streamQueues.keys() if self._isStreamRoutedToConnection(stream_id, connectionId) ] return BULKIO.UsesPortStatistics(connectionId, stats)
def pushPacket(self, data, T, EOS, streamID): self.port_lock.acquire() if self.queue.maxsize == 0: self.port_lock.release() return packet = None try: sri = BULKIO.StreamSRI(1, 0.0, 1.0, 1, 0, 0.0, 0.0, 0, 0, streamID, False, []) sriChanged = False if self.sriDict.has_key(streamID): sri, sriChanged = self.sriDict[streamID] self.sriDict[streamID] = (sri, False) if self.blocking: packet = (data, T, EOS, streamID, copy.deepcopy(sri), sriChanged, False) self.stats.update(len(data), float(self.queue.qsize()) / float(self.queue.maxsize), streamID, False) self.queue.put(packet) else: if self.queue.full(): try: self.queue.mutex.acquire() self.queue.queue.clear() self.queue.mutex.release() except Queue.Empty: pass packet = (data, T, EOS, streamID, copy.deepcopy(sri), sriChanged, True) self.stats.update(len(data), float(self.queue.qsize()) / float(self.queue.maxsize), streamID, True) else: packet = (data, T, EOS, streamID, copy.deepcopy(sri), sriChanged, False) self.stats.update(len(data), float(self.queue.qsize()) / float(self.queue.maxsize), streamID, False) self.queue.put(packet) finally: self.port_lock.release()
def queryStreamSRI(self, streamId): node = self.defaultSRIList[streamId] if (node == None): raise BULKIO.invalidStreamID() return node
def testUnicastAttachFail(self): # Get ports compDataSddsIn = self.comp.getPort('dataSddsIn') compDataShortOut_out = self.comp.getPort('dataShortOut') # Set properties self.comp.interface = 'lo' self.comp.advanced_optimizations.buffer_size = 200000 streamDef = BULKIO.SDDSStreamDefinition('id', BULKIO.SDDS_SI, self.uni_ip, 0, self.port, 8000, True, 'testing') attachId = '' # Try to attach try: attachId = compDataSddsIn.attach(streamDef, 'test') except: attachId = '' # Start component self.comp.start() # Wait for the attach time.sleep(1) # Double attach try: attachId = compDataSddsIn.attach(streamDef, 'test') except: attachId = 'shouldFail' self.assertTrue(attachId == 'shouldFail', "Second attach on port should cause a failure!")
def testMergeBulkIOSRI(self): # Get ports compDataShortOut_out = self.comp.getPort('dataShortOut') # Connect components self.comp.connect(self.sink, providesPortName='shortIn') # Here we are using the BULKIO SRI with a modified xdelta and complex flag but the sdds xdelta and cx should merge in sri = BULKIO.StreamSRI(hversion=1, xstart=0.0, xdelta=1.234e-9, xunits=1, subsize=0, ystart=0.0, ydelta=0.0, yunits=0, mode=0, streamID='StreamID1234', blocking=False, keywords=[]) self.setupComponent(sri=sri) # Start components self.comp.start() # Create data fakeData = [x for x in range(0, 512)] h = Sdds.SddsHeader(0, CX=1) p = Sdds.SddsShortPacket(h.header, fakeData) p.encode() # Defaults to big endian encoding self.userver.send(p.encodedPacket) time.sleep(0.05) data,stream = self.getData() sri_rx = stream.sri self.assertNotEqual(sri_rx.mode, sri.mode, "SDDS Packet Mode should have overridden the supplied SRI") self.assertNotEqual(sri_rx.xdelta, sri.xdelta, "SDDS Packet xdelta should have overridden the supplied SRI") self.assertEqual(sri_rx.streamID, sri.streamID, "Output SRI StreamID should have been inherited from the SRI")
def testSRI(self): request = fe_types.frontend_tuner_allocation() upstream_sri = BULKIO.StreamSRI(hversion=1, xstart=0.0, xdelta=1 / 2e6, xunits=BULKIO.UNITS_TIME, subsize=0, ystart=0.0, ydelta=0.0, yunits=BULKIO.UNITS_NONE, mode=0, streamID="", blocking=False, keywords=[]) request.center_frequency = 100e6 request.bandwidth = 1e6 request.sample_rate = 2e6 cf = 100e6 bw = 1e6 _keywords = [ CF.DataType(id="CHAN_RF", value=_any.to_any(cf)), CF.DataType(id="FRONTEND::BANDWIDTH", value=_any.to_any(bw)) ] upstream_sri.keywords = _keywords self.assertTrue( tuner_device.validateRequestVsSRI(request, upstream_sri, False)) cf = 100.49e6 _keywords = [ CF.DataType(id="CHAN_RF", value=_any.to_any(cf)), CF.DataType(id="FRONTEND::BANDWIDTH", value=_any.to_any(bw)) ] upstream_sri.keywords = _keywords self.assertTrue( tuner_device.validateRequestVsSRI(request, upstream_sri, False)) cf = 99.51e6 _keywords = [ CF.DataType(id="CHAN_RF", value=_any.to_any(cf)), CF.DataType(id="FRONTEND::BANDWIDTH", value=_any.to_any(bw)) ] upstream_sri.keywords = _keywords self.assertTrue( tuner_device.validateRequestVsSRI(request, upstream_sri, False)) cf = 100.51e6 _keywords = [ CF.DataType(id="CHAN_RF", value=_any.to_any(cf)), CF.DataType(id="FRONTEND::BANDWIDTH", value=_any.to_any(bw)) ] upstream_sri.keywords = _keywords self.assertRaises(FRONTEND.BadParameterException, tuner_device.validateRequestVsSRI, request, upstream_sri, False) cf = 99.49e6 _keywords = [ CF.DataType(id="CHAN_RF", value=_any.to_any(cf)), CF.DataType(id="FRONTEND::BANDWIDTH", value=_any.to_any(bw)) ] upstream_sri.keywords = _keywords self.assertRaises(FRONTEND.BadParameterException, tuner_device.validateRequestVsSRI, request, upstream_sri, False)
def queryConnection(self, connectionName): streams = self.connectionToStream.get[connectionName] # make sure that the connection exists if (streams == None): raise BULKIO.invalidConnectionName() return streams
def queryStreamConnections(self, streamId): connections = self.streamToConnection[streamId] # make sure that the streamId exists if (connections == None): raise BULKIO.invalidStreamID() return connections
def notSet(): """ Generates a BULKIO.PrecisionUTCTime object with zero time and an invalid flag. This is used by the automatic EOS """ return BULKIO.PrecisionUTCTime(BULKIO.TCM_OFF, BULKIO.TCS_INVALID, 0.0, 0.0, 0.0)
def createCPUTimestamp(): """ Generates a BULKIO.PrecisionUTCTime object using the current CPU time that you can use in the pushPacket call """ ts = time.time() return BULKIO.PrecisionUTCTime(BULKIO.TCM_CPU, BULKIO.TCS_VALID, 0.0, int(ts), ts - int(ts))
def testNavSetter(self): input_parent = self.nav_port_sample() input_parent_2 = self.nav_port_sample() input_port_1 = InNavDataPort("input_1", input_parent) output_port = OutNavDataPort("output") self.assertEquals(input_parent.get_source_id(), "original") _time = BULKIO.PrecisionUTCTime(1, 1, 1.0, 1.0, 1.0) _positioninfo = FRONTEND.PositionInfo(False, 'DATUM_WGS84', 0.0, 0.0, 0.0) _cartesianpos = FRONTEND.CartesianPositionInfo(False, 'DATUM_WGS84', 0.0, 0.0, 0.0) _velocityinfo = FRONTEND.VelocityInfo(False, 'DATUM_WGS84', '', 0.0, 0.0, 0.0) _accelerationinfo = FRONTEND.AccelerationInfo(False, 'DATUM_WGS84', '', 0.0, 0.0, 0.0) _attitudeinfo = FRONTEND.AttitudeInfo(False, 0.0, 0.0, 0.0) navpacket = FRONTEND.NavigationPacket('', '', _positioninfo, _cartesianpos, _velocityinfo, _accelerationinfo, _attitudeinfo, _time, []) navpacket.source_id = "newvalue" output_port._set_nav_packet(navpacket) self.assertEquals(input_parent.get_source_id(), "original") self.assertRaises(PortCallError, output_port._set_nav_packet, navpacket, "hello") output_port.connectPort(input_port_1._this(), "hello") output_port._set_nav_packet(navpacket) self.assertEquals(input_parent.get_source_id(), "newvalue") navpacket.source_id = "newvalue_2" output_port._set_nav_packet(navpacket, "hello") self.assertEquals(input_parent.get_source_id(), "newvalue_2") self.assertRaises(PortCallError, output_port._set_nav_packet, navpacket, "foo") navpacket.source_id = "newvalue_3" input_port_2 = InNavDataPort("input_2", input_parent_2) output_port.connectPort(input_port_2._this(), "foo") output_port._set_nav_packet(navpacket) self.assertEquals(input_parent.get_source_id(), "newvalue_3") self.assertEquals(input_parent_2.get_source_id(), "newvalue_3") navpacket.source_id = "newvalue_4" output_port._set_nav_packet(navpacket, "hello") self.assertEquals(input_parent.get_source_id(), "newvalue_4") self.assertEquals(input_parent_2.get_source_id(), "newvalue_3") self.assertRaises(PortCallError, output_port._set_nav_packet, navpacket, "something") output_port.disconnectPort("hello")
def _pushData(self, connection, dataString, numBytes, currentSampleTime): # Gather information about the connection arraySrcInst = connection['arraySrcInst'] bytesPerSample = 1 srcPortType = connection['srcPortType'] for i in self.supportedPorts.values(): if i['portType'] == srcPortType: bytesPerSample = i['bytesPerSample'] break outputSize = numBytes / bytesPerSample # Set the byte swap to use if self.byte_swap == 1: byte_swap = bytesPerSample else: byte_swap = self.byte_swap # Perform the byte swap if byte_swap > 1: if byte_swap != bytesPerSample: log.warn("Data size " + str(bytesPerSample) + " is not equal to byte swap size " + str(byte_swap)) output = self._flip(dataString[:numBytes], byte_swap) else: output = dataString[:numBytes] # Convert from a string to a list of # the type expected for the port outputList = self._stringToList(output, bytesPerSample, srcPortType) formattedOutput = _bulkio_helpers.formatData( outputList, BULKIOtype=eval(srcPortType)) EOS = False if len(formattedOutput) == 0: EOS = True T = _BULKIO.PrecisionUTCTime( _BULKIO.TCM_CPU, _BULKIO.TCS_VALID, 0.0, int(currentSampleTime), currentSampleTime - int(currentSampleTime)) if srcPortType != "_BULKIO__POA.dataXML": _bulkio_data_helpers.ArraySource.pushPacket(arraySrcInst, data=formattedOutput, T=T, EOS=EOS, streamID='testing') else: _bulkio_data_helpers.XmlArraySource.pushPacket( arraySrcInst, data=formattedOutput, EOS=EOS, streamID='testing')
def __init__(self, porttype): """ Instantiates a new object and generates a default StreamSRI. The porttype parameter corresponds to the type of data contained in the array of data being sent. The porttype is also used in the connectPort() method to narrow the connection """ self.file_d = None self.pkts_sent = 0 self.port_type = porttype self.byte_per_sample = 1 self.structFormat = "B" if (porttype == BULKIO__POA.dataShort): self.byte_per_sample = 2 self.structFormat = "h" elif (porttype == BULKIO__POA.dataFloat): self.byte_per_sample = 4 self.structFormat = "f" elif (porttype == BULKIO__POA.dataDouble): self.byte_per_sample = 8 self.structFormat = "d" elif (porttype == BULKIO__POA.dataChar): self.byte_per_sample = 1 self.structFormat = "b" elif (porttype == BULKIO__POA.dataOctet): self.byte_per_sample = 1 self.structFormat = "B" elif (porttype == BULKIO__POA.dataUlong): self.byte_per_sample = 4 self.structFormat = "L" elif (porttype == BULKIO__POA.dataUshort): self.byte_per_sample = 2 self.structFormat = "H" elif (porttype == BULKIO__POA.dataLong): self.byte_per_sample = 4 self.structFormat = "l" elif (porttype == BULKIO__POA.dataLongLong): self.byte_per_sample = 8 self.structFormat = "q" elif (porttype == BULKIO__POA.dataUlongLong): self.byte_per_sample = 8 self.structFormat = "Q" elif (porttype == BULKIO__POA.dataXML): self.byte_per_sample = 1 self.structFormat = "c" self.outPorts = {} self.refreshSRI = False # Create default SRI self.sri = BULKIO.StreamSRI(1, 0.0, 0.001, 1, 200, 0.0, 0.001, 1, 1, "defaultStreamID", True, []) self.port_lock = threading.Lock() self.EOS = False
def testUseBulkIOSRI(self): # Get ports compDataShortOut_out = self.comp.getPort('dataShortOut') sink = sb.DataSink() # Connect components self.comp.connect(sink, providesPortName='shortIn') # Here we are using the BULKIO SRI with a modified xdelta and complex flag. kw = [ CF.DataType("BULKIO_SRI_PRIORITY", ossie.properties.to_tc_value(1, 'long')) ] sri = BULKIO.StreamSRI(hversion=1, xstart=0.0, xdelta=1.234e-9, xunits=1, subsize=0, ystart=0.0, ydelta=0.0, yunits=0, mode=0, streamID='TestStreamID', blocking=False, keywords=kw) self.setupComponent(sri=sri) # Start components self.comp.start() sink.start() # Create data fakeData = [x for x in range(0, 512)] h = Sdds.SddsHeader(0, CX=1) p = Sdds.SddsShortPacket(h.header, fakeData) p.encode() # Defaults to big endian encoding self.userver.send(p.encodedPacket) time.sleep(0.05) data = sink.getData() sri_rx = sink.sri() # compareSRI does not work for CF.DataType with keywords so we check those first then zero them out self.assertEqual(sri.keywords[0].id, sri_rx.keywords[0].id, "SRI Keyword ID do not match") self.assertEqual(sri.keywords[0].value.value(), sri_rx.keywords[0].value.value(), "SRI Keyword Value do not match") self.assertEqual(sri.keywords[0].value.typecode(), sri_rx.keywords[0].value.typecode(), "SRI Keyword Type codes do not match") sri.keywords = [] sri_rx.keywords = [] self.assertTrue(compareSRI(sri, sri_rx), "Attach SRI does not match received SRI")
def retrieve(self): if not self.enabled: return retVal = [] for entry in self.receivedStatistics: runningStats = BULKIO.PortStatistics(portName=self.port_ref.name,averageQueueDepth=-1,elementsPerSecond=-1,bitsPerSecond=-1,callsPerSecond=-1,streamIDs=[],timeSinceLastCall=-1,keywords=[]) listPtr = (self.receivedStatistics_idx[entry] + 1) % self.historyWindow # don't count the first set of data, since we're looking at change in time rather than absolute time frontTime = self.receivedStatistics[entry][(self.receivedStatistics_idx[entry] - 1) % self.historyWindow].secs backTime = self.receivedStatistics[entry][self.receivedStatistics_idx[entry]].secs totalData = 0.0 queueSize = 0.0 streamIDs = [] while (listPtr != self.receivedStatistics_idx[entry]): totalData += self.receivedStatistics[entry][listPtr].elements queueSize += self.receivedStatistics[entry][listPtr].queueSize streamIDptr = 0 foundstreamID = False while (streamIDptr != len(streamIDs)): if (streamIDs[streamIDptr] == self.receivedStatistics[entry][listPtr].streamID): foundstreamID = True break streamIDptr += 1 if (not foundstreamID): streamIDs.append(self.receivedStatistics[entry][listPtr].streamID) listPtr += 1 listPtr = listPtr % self.historyWindow currentTime = time.time() totalTime = currentTime - backTime if totalTime == 0: totalTime = 1e6 receivedSize = len(self.receivedStatistics[entry]) runningStats.bitsPerSecond = (totalData * self.bitSize) / totalTime runningStats.elementsPerSecond = totalData/totalTime runningStats.averageQueueDepth = queueSize / receivedSize runningStats.callsPerSecond = float((receivedSize - 1)) / totalTime runningStats.streamIDs = streamIDs runningStats.timeSinceLastCall = currentTime - frontTime usesPortStat = BULKIO.UsesPortStatistics(connectionId=entry, statistics=runningStats) retVal.append(usesPortStat) return retVal
def getSddsStreamDef(self, streamId): ndef = BULKIO.SDDSStreamDefinition(id=streamId, dataFormat=BULKIO.SDDS_SB, multicastAddress='0.0.0.0', vlan=0, port=0, sampleRate=0, timeTagValid=False, privateInfo='privateInfo') return ndef
def create_cputime_stamp(): """ Generates a PrecisionUTCTime object using the current CPU time. Output: Returns a BULKIO.PrecisionUTCTime object """ ts = time.time() return BULKIO.PrecisionUTCTime(BULKIO.TCM_CPU, BULKIO.TCS_VALID, 0.0, int(ts), ts - int(ts))
def setupComponent(self, endianness=BIG_ENDIAN, pkts_per_push=1, sri=None): # Set properties self.comp.interface = 'lo' compDataSddsIn = self.comp.getPort('dataSddsIn') self.comp.advanced_optimizations.sdds_pkts_per_bulkio_push = pkts_per_push if sri is None: kw = [ CF.DataType("dataRef", ossie.properties.to_tc_value(endianness, 'long')) ] sri = BULKIO.StreamSRI(hversion=1, xstart=0.0, xdelta=1.0, xunits=1, subsize=0, ystart=0.0, ydelta=0.0, yunits=0, mode=0, streamID='TestStreamID', blocking=False, keywords=kw) compDataSddsIn.pushSRI(sri, timestamp.now()) streamDef = BULKIO.SDDSStreamDefinition('id', BULKIO.SDDS_SI, self.uni_ip, 0, self.port, 8000, True, 'testing') # Try to attach self.attachId = '' try: self.attachId = compDataSddsIn.attach(streamDef, 'test') except: print "ATTACH FAILED" attachId = '' self.assertTrue(self.attachId != '', "Failed to attach to SourceSDDS component")
def create(sid='defStream', srate=1.0, xunits=1): return BULKIO.StreamSRI(hversion=1, xstart=0.0, xdelta=1.0 / srate, xunits=xunits, subsize=0, ystart=0.0, ydelta=0.0, yunits=0, mode=0, streamID=sid, blocking=False, keywords=[])
def pushPacket(self, *args): """ This function is called whenever the pushPacket call is made on the connected output port. This attempts to place a new CORBA packet on the date queue. To pull packets off of the queue use the getPacket call """ data = args[0] #the dataXML port and dataFile port don't #have time tags so check the number of args if len(args) == 4: T = args[1] EOS = args[2] streamID = args[3] else: T = None EOS = args[1] streamID = args[2] self.port_lock.acquire() packet = None try: sri = BULKIO.StreamSRI(1, 0.0, 1.0, 1, 0, 0.0, 0.0, 0, 0, streamID, False, []) sriChanged = False if self.sriDict.has_key(streamID): sri, sriChanged = self.sriDict[streamID] self.sriDict[streamID] = (sri, False) else: self.sriDict[streamID] = (sri, False) sriChanged = True if self.blocking: packet = (data, T, EOS, streamID, copy.deepcopy(sri), sriChanged, False) self.queue.put(packet) else: if self.queue.full(): try: self.queue.mutex.acquire() self.queue.queue.clear() self.queue.mutex.release() except Queue.Empty: pass packet = (data, T, EOS, streamID, copy.deepcopy(sri), sriChanged, True) else: packet = (data, T, EOS, streamID, copy.deepcopy(sri), sriChanged, False) self.queue.put(packet) finally: self.port_lock.release()
def pushSRI(self, xdelta=1, streamID='TestStreamID', mode=0, kw=[]): sri = BULKIO.StreamSRI(hversion=1, xstart=0.0, xdelta=xdelta, xunits=1, subsize=0, ystart=0.0, ydelta=0.0, yunits=0, mode=mode, streamID=streamID, blocking=False, keywords=kw) self.input_vita49_port.pushSRI(sri, timestamp.now())
def retrieve(self): totals = {} for stat in self._statistics: for key, value in stat.iteritems(): totals[key] = totals.get(key, 0) + value if totals: first = self._statistics[0] current_time = time.time() totals['elapsed'] = current_time - first['timestamp'] totals['count'] = len(self._statistics) elements_per_second = totals['elements'] / totals['elapsed'] bits_per_second = elements_per_second * self._bitsPerElement avg_queue_depth = totals['queueDepth'] / totals['count'] calls_per_sec = totals['count'] / totals['elapsed'] time_since_last_call = current_time - self._statistics[-1][ 'timestamp'] bursts_per_second = totals['bursts'] / totals['elapsed'] bursts_per_push = totals['bursts'] / float(totals['count']) elements_per_burst = totals['elements'] / float(totals['bursts']) average_latency = totals['delay'] / totals['count'] else: elements_per_second = 0.0 bits_per_second = 0.0 calls_per_sec = 0.0 avg_queue_depth = 0.0 time_since_last_call = 0.0 bursts_per_second = 0.0 bursts_per_push = 0.0 elements_per_burst = 0.0 average_latency = 0.0 # To be filled in by caller stream_ids = [] # Add burst-specific stats to keywords burst_stats = [('BURSTS_PER_SECOND', bursts_per_second), ('BURSTS_PER_PUSH', bursts_per_push), ('ELEMENTS_PER_BURST', elements_per_burst), ('AVERAGE_LATENCY', average_latency)] self._addKeywords(burst_stats, totals) keywords = [CF.DataType(k, any.to_any(v)) for k, v in burst_stats] return BULKIO.PortStatistics(self._name, elements_per_second, bits_per_second, calls_per_sec, stream_ids, avg_queue_depth, time_since_last_call, keywords)
def callAttach(self, valid_data_format=True, mode=0): # Mode 0 = RealShort , 1 = ComplexShort, 2 = RealFloat, 3 = ComplexFloat payloadFormat_RealShort = BULKIO.VITA49DataPacketPayloadFormat( True, BULKIO.VITA49_REAL, BULKIO.VITA49_16T, False, 0, 0, 16, 16, 1, 1) payloadFormat_ComplexShort = BULKIO.VITA49DataPacketPayloadFormat( True, BULKIO.VITA49_COMPLEX_CARTESIAN, BULKIO.VITA49_16T, False, 0, 0, 16, 16, 1, 1) payloadFormat_RealFloat = BULKIO.VITA49DataPacketPayloadFormat( True, BULKIO.VITA49_REAL, BULKIO.VITA49_32F, False, 0, 0, 32, 32, 1, 1) payloadFormat_ComplexFloat = BULKIO.VITA49DataPacketPayloadFormat( True, BULKIO.VITA49_COMPLEX_CARTESIAN, BULKIO.VITA49_32F, False, 0, 0, 32, 32, 1, 1) payloadFormat_RealLong = BULKIO.VITA49DataPacketPayloadFormat( True, BULKIO.VITA49_REAL, BULKIO.VITA49_32T, False, 0, 0, 32, 32, 1, 1) payloadFormat_RealOctet = BULKIO.VITA49DataPacketPayloadFormat( True, BULKIO.VITA49_REAL, BULKIO.VITA49_8T, False, 0, 0, 8, 8, 1, 1) if mode == 0: payloadFormat = payloadFormat_RealShort elif mode == 1: payloadFormat = payloadFormat_ComplexShort elif mode == 2: payloadFormat = payloadFormat_RealFloat elif mode == 3: payloadFormat = payloadFormat_ComplexFloat elif mode == 4: payloadFormat = payloadFormat_RealLong elif mode == 5: payloadFormat = payloadFormat_RealOctet else: payloadFormat = None streamDef = BULKIO.VITA49StreamDefinition(self.uni_ip, 0, self.port, BULKIO.VITA49_UDP_TRANSPORT, "id", valid_data_format, payloadFormat) # Try to attach attachId = '' try: attachId = self.input_vita49_port.attach(streamDef, 'test') except Exception, e: print str(e) print "ATTACH FAILED" attachId = ''
def create( whole_secs=-1.0, fractional_secs=-1.0, tsrc=BULKIO.TCM_CPU ): """ Generates a BULKIO.PrecisionUTCTime object using the current CPU time that you can use in the pushPacket call """ wsec = whole_secs; fsec = fractional_secs; if wsec < 0.0 and fsec < 0.0 : ts=time.time() wsec=int(ts) fsec = ts-int(ts) return BULKIO.PrecisionUTCTime(tsrc, BULKIO.TCS_VALID, 0.0, wsec, fsec )
def __init__(self, parent, vars={}, **extras): self.parent = parent self.vars = dict(vars) self.vars.update(extras) self.port_lock = threading.Lock() self.refreshSRI = False self.defaultStreamSRI = BULKIO.StreamSRI(1, 0.0, 0.001, 1, 200, 0.0, 0.001, 1, 1, "sampleStream", []) self.active = True self.refreshSRIList = {} self.connectionToStream = {} self.streamToConnection = {} self.streamToPorts = {} self.defaultSRIList = {} self.outPorts = {}
def __init__(self, porttype, pushSRI, pushPacket): """ Inputs: :porttype The BULKIO__POA data type """ self.port_type = porttype self.last_sri = BULKIO.StreamSRI(1, 0.0, 0.001, 1, 200, 0.0, 0.001, 1, 1, "defaultStreamID", True, []) self.last_packet = [] self.eos = False self._pushSRI_callback = pushSRI self._pushPacket_callback = pushPacket self._logger = logging.getLogger(self.__class__.__name__)
def get_nav_packet(self, port_name): _time = BULKIO.PrecisionUTCTime(1, 1, 1.0, 1.0, 1.0) _positioninfo = FRONTEND.PositionInfo(False, 'DATUM_WGS84', 0.0, 0.0, 0.0) _cartesianpos = FRONTEND.CartesianPositionInfo(False, 'DATUM_WGS84', 0.0, 0.0, 0.0) _velocityinfo = FRONTEND.VelocityInfo(False, 'DATUM_WGS84', '', 0.0, 0.0, 0.0) _accelerationinfo = FRONTEND.AccelerationInfo(False, 'DATUM_WGS84', '', 0.0, 0.0, 0.0) _attitudeinfo = FRONTEND.AttitudeInfo(False, 0.0, 0.0, 0.0) _navpacket = FRONTEND.NavigationPacket('', '', _positioninfo, _cartesianpos, _velocityinfo, _accelerationinfo, _attitudeinfo, _time, []) return _navpacket
def unassignAllStreams(self, connectionName): for streamId in self.defaultSRIList: try: self.unassign(connectionName, streamId) except: raise BULKIO.invalidStreamID()