コード例 #1
0
ファイル: test_sri.py プロジェクト: spirit0801/core-framework
 def pushOnePlusPacketsThread(self, firstStreamID, restStreamID,
                              numPacketsToSend):
     self.dataShortInput.pushPacket([], bulkio_helpers.createCPUTimestamp(),
                                    False, firstStreamID)
     for x in range(numPacketsToSend):
         self.dataShortInput.pushPacket([],
                                        bulkio_helpers.createCPUTimestamp(),
                                        False, restStreamID)
コード例 #2
0
    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()
コード例 #3
0
ファイル: test_SinkSDDS.py プロジェクト: scottwedge/assets
    def testBulkIOTimeStamp(self):
        ts_start = bulkio_helpers.createCPUTimestamp()
        self.source = sb.DataSource(startTime=ts_start.twsec + ts_start.tfsec)
        self.octetConnect()
        sb.start()
        fakeData = 1024 * [1]
        self.source.push(fakeData,
                         EOS=False,
                         streamID=self.id(),
                         sampleRate=1.0,
                         complexData=False,
                         loop=False)
        rcv = self.getPacket()
        sdds_header = self.getHeader(rcv)
        frac_int = sdds_header.timeTag % 4000000000
        secs_int = sdds_header.timeTag - frac_int
        frac_flt = frac_int / 4e9
        secs_flt = secs_int / 4e9
        ext_flt = 250e-12 * sdds_header.timeTagExt / 4294967296.0
        frac_flt += ext_flt

        now = datetime.datetime.utcnow()
        first_of_year = datetime.datetime(now.year, 1, 1, tzinfo=UTC())
        begin_of_time = datetime.datetime(1970, 1, 1, tzinfo=UTC())
        startOfYear = timedelta_total_seconds(first_of_year - begin_of_time)

        bulkIO_twsec = secs_flt + startOfYear
        bulkIO_tfsec = frac_flt

        self.assertEqual(bulkIO_tfsec, ts_start.tfsec,
                         "Expected frac seconds do not match")
        self.assertEqual(bulkIO_twsec, ts_start.twsec,
                         "Expected whole seconds do not match")
コード例 #4
0
ファイル: test_sri.py プロジェクト: spirit0801/core-framework
 def pushOnePacketThread(self, streamID):
     self.dataShortInput.pushPacket([], bulkio_helpers.createCPUTimestamp(),
                                    False, streamID)
コード例 #5
0
ファイル: test_sri.py プロジェクト: spirit0801/core-framework
    def testEOSBlockReset(self):
        self.utility()
        numPackets = 4

        #set the queueDepth to the number of packets intending to be sent - 1
        self.comp.mqd = numPackets - 1

        #send two streamSRI, one for blocking and one to not block, should tell the port to block
        s1_sri = BULKIO.StreamSRI(1, 0.0, 0.001, 1, 300, 0.0, 0.001, 1, 1,
                                  's1', True, [])
        s2_sri = BULKIO.StreamSRI(1, 0.0, 0.001, 1, 300, 0.0, 0.001, 1, 1,
                                  's2', False, [])
        self.dataShortInput.pushSRI(s1_sri)
        self.dataShortInput.pushSRI(s2_sri)

        #start the 'quasi' component thread, tell him to receive numPackets*2
        t1 = threading.Thread(None, self.getPacketThread, 't1',
                              (numPackets * 2, ), {})
        t1.setDaemon(True)
        t1.start()

        #fill the queue
        for x in range(numPackets - 1):
            self.dataShortInput.pushPacket([],
                                           bulkio_helpers.createCPUTimestamp(),
                                           False, 's1')

        #send the last one and the rest of the packets in a separate thread
        t2 = threading.Thread(None, self.pushOnePlusPacketsThread, 't2',
                              ('s1', 's2', numPackets), {})
        t2.setDaemon(True)
        t2.start()

        #start the component and let the 'quasi' component thread complete
        self.comp.start()
        t2.join()
        t1.join()

        #should not have flushed, should have gotten all packets
        self.assertFalse(self.queueFlushed)
        self.assertEquals(self.packetsReceived, numPackets * 2)
        self.comp.stop()

        #reset packetsReceived to 0
        self.packetsReceived = 0

        #start another receiver thread
        t1 = threading.Thread(None, self.getPacketThread, 't1',
                              (numPackets * 2, ), {})
        t1.setDaemon(True)
        t1.start()

        #send 2 packets, the second one with an EOS which should lift the block
        #since s1 was calling for the block and s2 wasn't
        self.comp.start()
        self.dataShortInput.pushPacket([], bulkio_helpers.createCPUTimestamp(),
                                       False, 's1')
        self.dataShortInput.pushPacket([], bulkio_helpers.createCPUTimestamp(),
                                       True, 's1')

        #wait to see that the EOS has passed through the component
        #which should reset the block to false
        while not self.EOSReceived:
            pass

        self.comp.stop()

        #push enough packets in to cause a flush
        self.dataShortInput.pushPacket([], bulkio_helpers.createCPUTimestamp(),
                                       False, 's2')
        self.dataShortInput.pushPacket([], bulkio_helpers.createCPUTimestamp(),
                                       False, 's2')
        self.dataShortInput.pushPacket([], bulkio_helpers.createCPUTimestamp(),
                                       False, 's2')
        self.dataShortInput.pushPacket([], bulkio_helpers.createCPUTimestamp(),
                                       False, 's2')

        self.comp.start()
        t1.join()
        self.comp.stop()

        #should have received the 2 packets from s1, and the single packet from s2
        self.assertTrue(self.queueFlushed)
        self.assertTrue(self.packetsReceived == 3)
コード例 #6
0
ファイル: test_sri.py プロジェクト: spirit0801/core-framework
    def testSRIChanged(self):
        ossie.utils.testing.ScaComponentTestCase.setUp(self)
        #######################################################################
        # Launch the component with the default execparams
        execparams = self.getPropertySet(kinds=("execparam", ),
                                         modes=("readwrite", "writeonly"),
                                         includeNil=False)
        execparams = dict([(x.id, any.from_any(x.value)) for x in execparams])
        self.launch(execparams)
        self.comp_obj.initialize()
        self.comp_obj.start()

        self.helperShortInput = bulkio_helpers.createBULKIOInputPort(
            BULKIO__POA.dataShort)
        self.dataShortInput = self.comp_obj.getPort('dataShortIn')
        self.dataShortOutput = self.comp_obj.getPort('dataShortOut')
        self.dataShortOutput.connectPort(self.helperShortInput, 'dataShortOut')

        shortData = bulkio_helpers.genRandomDataSet(16, True, 1000)

        s1_sri = BULKIO.StreamSRI(1, 0.0, 0.001, 1, 300, 0.0, 0.001, 1, 1,
                                  "s1", False, [])
        s2_sri = BULKIO.StreamSRI(1, 0.0, 0.001, 1, 200, 0.0, 0.001, 1, 1,
                                  "s2", False, [])

        self.dataShortInput.pushPacket(shortData,
                                       bulkio_helpers.createCPUTimestamp(),
                                       False, "s1")
        self.dataShortInput.pushPacket(shortData,
                                       bulkio_helpers.createCPUTimestamp(),
                                       False, "s2")

        #pushPacket with no previous pushSRI, should have the correct streamIDs but the flags
        #should not be set in either getPacket call
        data, T, EOS, streamID, sri, sriChanged, flushed = self.helperShortInput.getPacket(
            -1)
        self.assertEquals(streamID, 's1')
        self.assertTrue(sriChanged)
        data, T, EOS, streamID, sri, sriChanged, flushed = self.helperShortInput.getPacket(
            -1)
        self.assertEquals(streamID, 's2')
        self.assertTrue(sriChanged)

        self.dataShortInput.pushSRI(s1_sri)
        self.dataShortInput.pushSRI(s2_sri)
        self.dataShortInput.pushPacket(shortData,
                                       bulkio_helpers.createCPUTimestamp(),
                                       False, "s1")
        self.dataShortInput.pushPacket(shortData,
                                       bulkio_helpers.createCPUTimestamp(),
                                       False, "s2")

        #pushSRIs followed by pushPackets.  The flag should be set in both getPacket
        #calls and the received SRIs should match the ones sent in
        data, T, EOS, streamID, sri, sriChanged, flushed = self.helperShortInput.getPacket(
            -1)
        self.assertEquals(streamID, 's1')
        self.assertTrue(bulkio_helpers.compareSRI(sri, s1_sri))
        self.assertTrue(sriChanged)
        data, T, EOS, streamID, sri, sriChanged, flushed = self.helperShortInput.getPacket(
            -1)
        self.assertEquals(streamID, 's2')
        self.assertTrue(bulkio_helpers.compareSRI(sri, s2_sri))
        self.assertTrue(sriChanged)

        s1_sri = BULKIO.StreamSRI(1, 0.0, 0.001, 1, 400, 0.0, 0.001, 1, 1,
                                  "s1", False, [])
        self.dataShortInput.pushSRI(s1_sri)
        self.dataShortInput.pushPacket(shortData,
                                       bulkio_helpers.createCPUTimestamp(),
                                       False, "s1")
        self.dataShortInput.pushPacket(shortData,
                                       bulkio_helpers.createCPUTimestamp(),
                                       False, "s2")

        #Changed the SRI for stream s1, and pushed it, did nothing for stream s2.  Should see the flag set
        #in the first getPacket call and the streamID should be s1, also the SRI should match the new one.
        #The second getPacket call should return streamID s2, flag not set, and the SRI should match the old one
        data, T, EOS, streamID, sri, sriChanged, flushed = self.helperShortInput.getPacket(
            -1)
        self.assertEquals(streamID, 's1')
        self.assertTrue(bulkio_helpers.compareSRI(sri, s1_sri))
        self.assertTrue(sriChanged)
        data, T, EOS, streamID, sri, sriChanged, flushed = self.helperShortInput.getPacket(
            -1)
        self.assertEquals(streamID, 's2')
        self.assertTrue(bulkio_helpers.compareSRI(sri, s2_sri))
        self.assertFalse(sriChanged)

        #Changed the SRI for stream s2, and pushed it, did nothing for stream s1.  Should see the flag set
        #in the second getPacket call and the streamID should be s2, also the SRI should match the new one.
        #The first getPacket call should return streamID s1, flag not set, and the SRI should match the old one
        s2_sri = BULKIO.StreamSRI(1, 0.0, 0.001, 1, 600, 0.0, 0.001, 1, 1,
                                  "s2", False, [])
        self.dataShortInput.pushSRI(s2_sri)
        self.dataShortInput.pushPacket(shortData,
                                       bulkio_helpers.createCPUTimestamp(),
                                       False, "s1")
        self.dataShortInput.pushPacket(shortData,
                                       bulkio_helpers.createCPUTimestamp(),
                                       False, "s2")

        data, T, EOS, streamID, sri, sriChanged, flushed = self.helperShortInput.getPacket(
            -1)
        self.assertEquals(streamID, 's1')
        self.assertTrue(bulkio_helpers.compareSRI(sri, s1_sri))
        self.assertFalse(sriChanged)
        data, T, EOS, streamID, sri, sriChanged, flushed = self.helperShortInput.getPacket(
            -1)
        self.assertEquals(streamID, 's2')
        self.assertTrue(bulkio_helpers.compareSRI(sri, s2_sri))
        self.assertTrue(sriChanged)

        #Did nothing to change either stream s1 or stream s2.  Should see no changes to SRI, and should not
        #see the flag set in either getPacket call.  The streamIDs should still come back in order
        self.dataShortInput.pushPacket(shortData,
                                       bulkio_helpers.createCPUTimestamp(),
                                       False, "s1")
        self.dataShortInput.pushPacket(shortData,
                                       bulkio_helpers.createCPUTimestamp(),
                                       False, "s2")

        data, T, EOS, streamID, sri, sriChanged, flushed = self.helperShortInput.getPacket(
            -1)
        self.assertEquals(streamID, 's1')
        self.assertTrue(bulkio_helpers.compareSRI(sri, s1_sri))
        self.assertFalse(sriChanged)
        data, T, EOS, streamID, sri, sriChanged, flushed = self.helperShortInput.getPacket(
            -1)
        self.assertEquals(streamID, 's2')
        self.assertTrue(bulkio_helpers.compareSRI(sri, s2_sri))
        self.assertFalse(sriChanged)

        #Changed the SRI for stream s2, and pushed it, Then repeated the operation changing the SRI again before
        #making a pushPacket call for either stream,  Should see the flag set in the getPacket call, also the SRI
        #should match the latest one pushed.
        s2_sri = BULKIO.StreamSRI(1, 0.0, 0.001, 1, 500, 0.0, 0.001, 1, 1,
                                  "s2", False, [])
        self.dataShortInput.pushSRI(s2_sri)
        s2_sri = BULKIO.StreamSRI(1, 0.0, 0.001, 1, 700, 0.0, 0.001, 1, 1,
                                  "s2", False, [])
        self.dataShortInput.pushSRI(s2_sri)
        self.dataShortInput.pushPacket(shortData,
                                       bulkio_helpers.createCPUTimestamp(),
                                       False, "s2")

        data, T, EOS, streamID, sri, sriChanged, flushed = self.helperShortInput.getPacket(
            -1)
        self.assertEquals(streamID, 's2')
        self.assertTrue(bulkio_helpers.compareSRI(sri, s2_sri))
        self.assertTrue(sriChanged)

        #Testing that a pushPacket with an EOS flag does not break anything with SRI.  The SRI is supposed
        #to be removed from the list that the port maintains if EOS was received for a particular streamID.
        #Flags should not be set and SRIs should still come back as the latest ones
        self.dataShortInput.pushPacket(shortData,
                                       bulkio_helpers.createCPUTimestamp(),
                                       True, "s1")
        self.dataShortInput.pushPacket(shortData,
                                       bulkio_helpers.createCPUTimestamp(),
                                       True, "s2")

        data, T, EOS, streamID, sri, sriChanged, flushed = self.helperShortInput.getPacket(
            -1)
        self.assertEquals(streamID, 's1')
        self.assertTrue(bulkio_helpers.compareSRI(sri, s1_sri))
        self.assertFalse(sriChanged)
        data, T, EOS, streamID, sri, sriChanged, flushed = self.helperShortInput.getPacket(
            -1)
        self.assertEquals(streamID, 's2')
        self.assertTrue(bulkio_helpers.compareSRI(sri, s2_sri))
        self.assertFalse(sriChanged)

        #This final test looks to see if the same SRI is pushed once before a pushPacket, then again after
        #the pushPacket, that the sriChanged flag won't be set for the next data set to be returned.  A
        #pushSRI with the exact same SRI that already exists should not cause the flag to be set. The first
        #getPacket should see new SRI and the flag set, the second one should see the same SRI, no flag set
        s1_sri = BULKIO.StreamSRI(1, 0.0, 0.001, 1, 300, 0.0, 0.001, 1, 1,
                                  "s1", False, [])
        self.dataShortInput.pushSRI(s1_sri)
        self.dataShortInput.pushPacket(shortData,
                                       bulkio_helpers.createCPUTimestamp(),
                                       False, "s1")
        self.dataShortInput.pushSRI(s1_sri)
        self.dataShortInput.pushPacket(shortData,
                                       bulkio_helpers.createCPUTimestamp(),
                                       False, "s1")

        data, T, EOS, streamID, sri, sriChanged, flushed = self.helperShortInput.getPacket(
            -1)
        self.assertEquals(streamID, 's1')
        self.assertTrue(bulkio_helpers.compareSRI(sri, s1_sri))
        self.assertTrue(sriChanged)
        data, T, EOS, streamID, sri, sriChanged, flushed = self.helperShortInput.getPacket(
            -1)
        self.assertEquals(streamID, 's1')
        self.assertTrue(bulkio_helpers.compareSRI(sri, s1_sri))
        self.assertFalse(sriChanged)

        self.comp_obj.stop()
        self.comp_obj.releaseObject()
コード例 #7
0
    def testMaxQueueDepth(self):
        shortData = bulkio_helpers.genRandomDataSet(16, True, 100)
        oldFlushTime = None

        #try changing it to 10
        newmqd = 10
        self.comp_obj.configure([
            ossie.cf.CF.DataType(id='mqd',
                                 value=CORBA.Any(CORBA.TC_short, newmqd))
        ])
        currmqd = self.comp_obj.query(
            [ossie.cf.CF.DataType(id=str('mqd'),
                                  value=any.to_any(None))])[0].value.value()
        self.assertEquals(currmqd, newmqd)

        #push the max + 1 packets, should see a flush on the last packet but not on any other
        #the reason the packets will be queuing up is because the component has not been started up.
        for x in range(newmqd + 1):
            stats = self.dataShortInput._get_statistics()
            for x in stats.keywords:
                if x.id == 'timeSinceLastFlush':
                    self.fail("Flush happened before it should have")
            self.dataShortInput.pushPacket(shortData,
                                           bulkio_helpers.createCPUTimestamp(),
                                           False, 'stream1')
        stats = self.dataShortInput._get_statistics()
        if 'timeSinceLastFlush' not in [y.id for y in stats.keywords]:
            self.fail("Should have flushed at the max+1 pushPacket")
        else:
            for x in stats.keywords:
                if x.id == 'timeSinceLastFlush':
                    oldFlushTime = x.value.value()
                    break

        #try setting it again
        newmqd = 250
        self.comp_obj.configure([
            ossie.cf.CF.DataType(id='mqd',
                                 value=CORBA.Any(CORBA.TC_short, newmqd))
        ])
        currmqd = self.comp_obj.query(
            [ossie.cf.CF.DataType(id=str('mqd'),
                                  value=any.to_any(None))])[0].value.value()
        self.assertEquals(int(currmqd), newmqd)

        #push the max packets (THERE IS ALREADY ONE PACKET IN THE QUEUE
        #should see a flush on the last packet but not on any other
        newFlushTime = None
        for x in range(newmqd):
            stats = self.dataShortInput._get_statistics()
            for y in stats.keywords:
                if y.id == 'timeSinceLastFlush':
                    newFlushTime = y.value.value()
                    self.assertTrue(oldFlushTime <= newFlushTime)
                    oldFlushTime = newFlushTime
                    break
            self.dataShortInput.pushPacket(shortData,
                                           bulkio_helpers.createCPUTimestamp(),
                                           False, 'stream1')
        stats = self.dataShortInput._get_statistics()
        for x in stats.keywords:
            if x.id == 'timeSinceLastFlush':
                newFlushTime = x.value.value()
                break
        self.assertTrue(newFlushTime <= oldFlushTime)
        oldFlushTime = newFlushTime

        #try making it infinite
        newmqd = -1
        self.comp_obj.configure([
            ossie.cf.CF.DataType(id='mqd',
                                 value=CORBA.Any(CORBA.TC_short, newmqd))
        ])
        currmqd = self.comp_obj.query(
            [ossie.cf.CF.DataType(id=str('mqd'),
                                  value=any.to_any(None))])[0].value.value()
        self.assertEquals(int(currmqd), newmqd)

        #push 1000 packets, should not see a flush at all
        newFlushTime = None
        for x in range(1000):
            stats = self.dataShortInput._get_statistics()
            for y in stats.keywords:
                if y.id == 'timeSinceLastFlush':
                    newFlushTime = y.value.value()
                    self.assertTrue(oldFlushTime <= newFlushTime)
                    oldFlushTime = newFlushTime
                    break
            self.dataShortInput.pushPacket(shortData,
                                           bulkio_helpers.createCPUTimestamp(),
                                           False, 'stream1')
        stats = self.dataShortInput._get_statistics()

        #set it to blocking, make sure it doesn't break
        newmqd = 0
        self.comp_obj.configure([
            ossie.cf.CF.DataType(id='mqd',
                                 value=CORBA.Any(CORBA.TC_short, newmqd))
        ])
        currmqd = self.comp_obj.query(
            [ossie.cf.CF.DataType(id=str('mqd'),
                                  value=any.to_any(None))])[0].value.value()
        self.assertEquals(int(currmqd), newmqd)

        #push 100 packets, the pushPacket returns immediately, the queueShould not grow
        firstaqd = self.dataShortInput._get_statistics().averageQueueDepth
        nextaqd = None
        newFlushTime = None
        for x in range(5):
            self.dataShortInput.pushPacket(shortData,
                                           bulkio_helpers.createCPUTimestamp(),
                                           False, 'stream1')
            nextaqd = self.dataShortInput._get_statistics().averageQueueDepth
            self.assertEquals(firstaqd, nextaqd)
コード例 #8
0
    def testEmptyDataPush(self):
        self.comp_obj.start()

        #####################################
        # Send empty data on each input port
        self.dataCharInput.pushPacket('', bulkio_helpers.createCPUTimestamp(),
                                      False, "s1")
        self.dataDoubleInput.pushPacket([],
                                        bulkio_helpers.createCPUTimestamp(),
                                        False, "s2")
        self.dataFloatInput.pushPacket([], bulkio_helpers.createCPUTimestamp(),
                                       False, "s3")
        self.dataLongInput.pushPacket([], bulkio_helpers.createCPUTimestamp(),
                                      False, "s4")
        self.dataOctetInput.pushPacket('', bulkio_helpers.createCPUTimestamp(),
                                       False, "s5")
        self.dataShortInput.pushPacket([], bulkio_helpers.createCPUTimestamp(),
                                       False, "s6")
        self.dataUlongInput.pushPacket([], bulkio_helpers.createCPUTimestamp(),
                                       False, "s7")
        self.dataUshortInput.pushPacket([],
                                        bulkio_helpers.createCPUTimestamp(),
                                        False, "s8")
        self.dataXMLInput.pushPacket('', False, "s9")
        self.dataFileInput.pushPacket('', bulkio_helpers.createCPUTimestamp(),
                                      False, 's10')
        self.dataLongLongInput.pushPacket([],
                                          bulkio_helpers.createCPUTimestamp(),
                                          False, "s11")
        self.dataUlongLongInput.pushPacket([],
                                           bulkio_helpers.createCPUTimestamp(),
                                           False, "s12")

        ##########################################
        # Receive data from each output port
        # *** THESE GET PACKETS ARE BLOCKING! ***
        _charData, T, EOS, streamID, sri, sriChanged, flushed = self.helperCharInput.getPacket(
            2)
        _doubleData, T, EOS, streamID, sri, sriChanged, flushed = self.helperDoubleInput.getPacket(
            2)
        _floatData, T, EOS, streamID, sri, sriChanged, flushed = self.helperFloatInput.getPacket(
            2)
        _longData, T, EOS, streamID, sri, sriChanged, flushed = self.helperLongInput.getPacket(
            2)
        _octetData, T, EOS, streamID, sri, sriChanged, flushed = self.helperOctetInput.getPacket(
            2)
        _shortData, T, EOS, streamID, sri, sriChanged, flushed = self.helperShortInput.getPacket(
            2)
        _uLongData, T, EOS, streamID, sri, sriChanged, flushed = self.helperUlongInput.getPacket(
            2)
        _uShortData, T, EOS, streamID, sri, sriChanged, flushed = self.helperUshortInput.getPacket(
            2)
        _xmlData, T, EOS, streamID, sri, sriChanged, flushed = self.helperXMLInput.getPacket(
            2)
        _fileData, T, EOS, streamID, sri, sriChanged, flushed = self.helperFileInput.getPacket(
            2)
        _longLongData, T, EOS, streamID, sri, sriChanged, flushed = self.helperLongLongInput.getPacket(
            2)
        _uLongLongData, T, EOS, streamID, sri, sriChanged, flushed = self.helperUlongLongInput.getPacket(
            2)

        sentData = ['', [], [], [], '', [], [], [], '', '', [], []]
        types = [
            'char', 'double', 'float', 'long', 'octet', 'short', 'uLong',
            'uLongLong', 'longLong', 'uShort', 'xml', 'file'
        ]

        sentData = {
            'char': '',
            'double': [],
            'float': [],
            'long': [],
            'octet': '',
            'short': [],
            'uLong': [],
            'uShort': [],
            'xml': '',
            'file': '',
            'longLong': [],
            'uLongLong': []
        }
        recData = {'char':_charData, 'double':_doubleData, 'float':_floatData, 'long':_longData, 'octet':_octetData, 'short':_shortData,\
                       'uLong':_uLongData, 'uShort':_uShortData, 'xml':_xmlData, 'file':_fileData, 'longLong':_longLongData, 'uLongLong':_uLongLongData}

        for x in types:
            self.assertNotEquals(
                None,
                recData[x],
                msg="No empty set was recieved for dataType (" + str(x) + ")")

        #############################################
        # Check that data received matches data sent
        for x in types:
            self.assertEqual(recData[x], sentData[x])

        self.comp_obj.stop()
コード例 #9
0
    def testDataPush(self):
        charData = bulkio_helpers.genRandomDataSet(8, True, 1000)
        doubleData = bulkio_helpers.genRandomDataSet(64, True, 1000)
        floatData = bulkio_helpers.genRandomDataSet(32, True, 1000)
        longData = bulkio_helpers.genRandomDataSet(32, True, 1000)
        octetData = bulkio_helpers.genRandomDataSet(8, False, 1000)
        shortData = bulkio_helpers.genRandomDataSet(16, True, 1000)
        uLongData = bulkio_helpers.genRandomDataSet(32, False, 1000)
        uLongLongData = bulkio_helpers.genRandomDataSet(32, False, 1000)
        longLongData = bulkio_helpers.genRandomDataSet(64, True, 1000)
        uShortData = bulkio_helpers.genRandomDataSet(16, False, 1000)
        xmlData = '<?xml version="1.0" encoding="ISO-8859-1"?>'
        fileData = 'SCA:/data/redhawk/myfile'

        #Format the data sets to be sure they can be used in the pushPacket call
        formCharData = bulkio_helpers.formatData(charData, self.dataCharInput)
        formDoubleData = bulkio_helpers.formatData(doubleData,
                                                   self.dataDoubleInput)
        formFloatData = bulkio_helpers.formatData(floatData,
                                                  self.dataFloatInput)
        formLongData = bulkio_helpers.formatData(longData, self.dataLongInput)
        formOctetData = bulkio_helpers.formatData(octetData,
                                                  self.dataOctetInput)
        formShortData = bulkio_helpers.formatData(shortData,
                                                  self.dataShortInput)
        formULongData = bulkio_helpers.formatData(uLongData,
                                                  self.dataUlongInput)
        formULongLongData = bulkio_helpers.formatData(uLongLongData,
                                                      self.dataUlongLongInput)
        formLongLongData = bulkio_helpers.formatData(longLongData,
                                                     self.dataLongLongInput)
        formUShortData = bulkio_helpers.formatData(uShortData,
                                                   self.dataUshortInput)
        formXmlData = bulkio_helpers.formatData(xmlData, self.dataXMLInput)
        formFileData = bulkio_helpers.formatData(fileData, self.dataFileInput)

        self.comp_obj.start()

        num_test_runs = 10
        for i in range(num_test_runs):
            ################################
            # Send Data on each output port
            self.dataCharInput.pushPacket(formCharData,
                                          bulkio_helpers.createCPUTimestamp(),
                                          False, "s1")
            self.dataDoubleInput.pushPacket(
                formDoubleData, bulkio_helpers.createCPUTimestamp(), False,
                "s2")
            self.dataFloatInput.pushPacket(formFloatData,
                                           bulkio_helpers.createCPUTimestamp(),
                                           False, "s3")
            self.dataLongInput.pushPacket(formLongData,
                                          bulkio_helpers.createCPUTimestamp(),
                                          False, "s4")
            self.dataOctetInput.pushPacket(formOctetData,
                                           bulkio_helpers.createCPUTimestamp(),
                                           False, "s5")
            self.dataShortInput.pushPacket(formShortData,
                                           bulkio_helpers.createCPUTimestamp(),
                                           False, "s6")
            self.dataUlongInput.pushPacket(formULongData,
                                           bulkio_helpers.createCPUTimestamp(),
                                           False, "s7")
            self.dataUlongLongInput.pushPacket(
                formULongLongData, bulkio_helpers.createCPUTimestamp(), False,
                "s8")
            self.dataLongLongInput.pushPacket(
                formLongLongData, bulkio_helpers.createCPUTimestamp(), False,
                "s9")
            self.dataUshortInput.pushPacket(
                formUShortData, bulkio_helpers.createCPUTimestamp(), False,
                "s10")
            self.dataXMLInput.pushPacket(formXmlData, False, "s11")
            self.dataFileInput.pushPacket(formFileData,
                                          bulkio_helpers.createCPUTimestamp(),
                                          False, "s12")

            ##########################################################
            # Receive data from each output port
            # *** THESE GET PACKETS CAN BE SET TO BLOCK OR TIMEOUT ***
            _charData, T, EOS, streamID, sri, sriChanged, flushed = self.helperCharInput.getPacket(
                2)
            _doubleData, T, EOS, streamID, sri, sriChanged, flushed = self.helperDoubleInput.getPacket(
                2)
            _floatData, T, EOS, streamID, sri, sriChanged, flushed = self.helperFloatInput.getPacket(
                2)
            _longData, T, EOS, streamID, sri, sriChanged, flushed = self.helperLongInput.getPacket(
                2)
            _octetData, T, EOS, streamID, sri, sriChanged, flushed = self.helperOctetInput.getPacket(
                2)
            _shortData, T, EOS, streamID, sri, sriChanged, flushed = self.helperShortInput.getPacket(
                2)
            _uLongData, T, EOS, streamID, sri, sriChanged, flushed = self.helperUlongInput.getPacket(
                2)
            _uLongLongData, T, EOS, streamID, sri, sriChanged, flushed = self.helperUlongLongInput.getPacket(
                2)
            _longLongData, T, EOS, streamID, sri, sriChanged, flushed = self.helperLongLongInput.getPacket(
                2)
            _uShortData, T, EOS, streamID, sri, sriChanged, flushed = self.helperUshortInput.getPacket(
                2)
            _xmlData, T, EOS, streamID, sri, sriChanged, flushed = self.helperXMLInput.getPacket(
                2)
            _fileData, T, EOS, streamID, sri, sriChanged, flushed = self.helperFileInput.getPacket(
                2)

            types = [
                'char', 'double', 'float', 'long', 'octet', 'short', 'uLong',
                'uLongLong', 'longLong', 'uShort', 'xml', 'file'
            ]

            sentData = {'char':formCharData, 'double':formDoubleData, 'float':formFloatData, 'long':formLongData, 'octet':formOctetData,\
                        'short':formShortData, 'uLong':formULongData, 'uShort':formUShortData, 'xml':formXmlData, 'file':formFileData,\
                        'longLong':formLongLongData, 'uLongLong':formULongLongData}
            recData = {'char':_charData, 'double':_doubleData, 'float':_floatData, 'long':_longData, 'octet':_octetData, 'short':_shortData,\
                       'uLong':_uLongData, 'uShort':_uShortData, 'xml':_xmlData, 'file':_fileData, 'longLong':_longLongData, 'uLongLong':_uLongLongData}

            for x in types:
                self.assertNotEquals(
                    None,
                    recData[x],
                    msg="No data was recieved for dataType (" + str(x) + ")")

            #############################################
            # Check that data received matches data sent
            for x in types:
                self.assertEqual(recData[x], sentData[x])

            #########################################
            # Check restoring the 8 bit data to its
            # original yields the same results
            restCharData = bulkio_helpers.restoreData(_charData, '8bit')
            restOctetData = bulkio_helpers.restoreData(_octetData, 'u8bit')
            self.assertEquals(restCharData, charData)
            self.assertEquals(restOctetData, octetData)

        self.comp_obj.stop()