Exemple #1
0
    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 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
Exemple #3
0
    def testUnicastAttachSuccess(self):
        """Attaches to the dataSddsIn port 10 times making sure that it occurs successfully each time"""
        
        compDataSddsIn = self.comp.getPort('dataSddsIn')
 
        streamDef = BULKIO.SDDSStreamDefinition('id', BULKIO.SDDS_SI, self.uni_ip, 0, self.port, 8000, True, 'testing')
        attachId = ''
        count = 0;
        valid = True
        while(valid):
            try:
                attachId = compDataSddsIn.attach(streamDef, 'test') 
            except Exception as e:
                attachId = ''
            time.sleep(1)
            self.assertNotEqual(attachId, '')
            compDataSddsIn.detach(attachId)
            count = count + 1
            if count == 10:
                valid = False
Exemple #4
0
    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")
# connect sig gen to an SDDS sender
siggen = sb.launch('rh.SigGen')
sdds_out = sb.launch('rh.SinkSDDS')
sdds_out.network_settings.interface = 'lo'
sdds_out.network_settings.ip_address = '127.0.0.1'
sdds_out.network_settings.port = 29000
siggen.connect(sdds_out, providesPortName="dataFloatIn")

# test to make sure sig gen is running
sgplot = sb.LinePlot()
siggen.connect(sgplot, providesPortName="floatIn")

sdds_in = sb.launch("rh.SourceSDDS")
sdds_in.interface = "lo"
sdds_port = sdds_in.getPort("dataSddsIn")
# Stream Definition:
# id, dataFormat, multicast address, vlan, port, sampleRate, timeTagValid, privateInfo
sd = BULKIO.SDDSStreamDefinition("big_stream", BULKIO.SDDS_CF, "127.0.0.1", 0,
                                 29000, siggen.sample_rate.__long__(), True,
                                 "testing")
attach_id = sdds_port.attach(sd, "username")

## connect SDDS sender (sink) to receiver (source) blocks
sdds_out.connect(sdds_in, providesPortName='dataSddsIn')

# see the data flowing through the source.
sddsplot = sb.LinePlot()
sdds_in.connect(sddsplot, providesPortName='floatIn')

sb.start()
Exemple #6
0
    def testRestartAfterDetach(self):
        """Checks that an Component will run after being detached and reattached without stopping """
        self.setupComponent()
        
        # Get ports
        compDataFloatOut_out = self.comp.getPort('dataShortOut')
 
        # Connect components
        self.comp.connect(self.sink, providesPortName='shortIn')

        # Start components
        self.comp.start()
        
        compDataSddsIn = self.comp.getPort('dataSddsIn')

        # Create data
        fakeData = [x for x in range(0, 512)]
        
        # Create packet and send
        h = Sdds.SddsHeader(0, DM = [0, 1, 0], TTV = 1, TT = 0)
        p = Sdds.SddsShortPacket(h.header, fakeData)
        p.encode()
        self.userver.send(p.encodedPacket)

        # Wait for data to be received
        time.sleep(1)
        
        # Get data
        data,stream = self.getData()
        
        # Validate correct amount of data was received
        self.assertEqual(len(data), 512)

        # Validate data is correct        
        self.assertEqual(fakeData, list(struct.unpack('>512H', struct.pack('>512H', *data))))
        
        
        #Send Detach
        compDataSddsIn.detach(self.attachId )
        time.sleep(1)
        
        # Get data
        data,stream = self.getData()
                
        self.assertTrue(stream.eos)
        
        #Re-Attach
        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")
        
        #Resend Data
        self.userver.send(p.encodedPacket)      
        
        # Wait for data to be received
        time.sleep(1)
        
        # Get data
        data,stream = self.getData()
        
        # Validate correct amount of data was received
        self.assertEqual(len(data), 512)

        # Validate data is correct        
        self.assertEqual(fakeData, list(struct.unpack('>512H', struct.pack('>512H', *data))))  
Exemple #7
0
    def testNonConformingConformingSwitch(self):
        self.setupComponent()
        
        # Get ports
        compDataShortOut_out = self.comp.getPort('dataShortOut')
        compDataSddsIn = self.comp.getPort('dataSddsIn')
        
        # Connect components
        self.comp.connect(self.sink, providesPortName='shortIn')
            
        # Start components
        self.comp.start()
        
        # Create data
        fakeData = [x for x in range(0, 512)]
        pktNum = 0
        
        sr=1e6
        xdelta_ns=int(1/(sr*2) * 1e9)
        time_ns=0
        
        recSRI = False
        # No time slips here
        while pktNum < 100:
            # Create data
            h = Sdds.SddsHeader(pktNum, FREQ=(sr*73786976294.838211), TT=(time_ns*4), CX=1)
            p = Sdds.SddsShortPacket(h.header, fakeData)
            p.encode()
            self.userver.send(p.encodedPacket)
            pktNum = pktNum + 1
            
            if pktNum != 0 and pktNum % 32 == 31:
                pktNum = pktNum + 1
                
            time_ns = time_ns + 512*xdelta_ns
            
        self.assertEqual(self.comp.status.time_slips, 0, "There should be no time slips!")
        
        # Stop the component, detach, then re-attach a new stream that is using the conforming sampleRate
        self.comp.stop()
        
        compDataSddsIn.detach(self.attachId)
        
        kw = [CF.DataType("dataRef", ossie.properties.to_tc_value(BIG_ENDIAN, '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='TestStreamID2', blocking=False, keywords=kw)
            
        compDataSddsIn.pushSRI(sri,timestamp.now())  
        
        streamDef = BULKIO.SDDSStreamDefinition('id2', BULKIO.SDDS_SI, self.uni_ip, 0, self.port, 8000, True, 'testing')
        self.attachId = compDataSddsIn.attach(streamDef, 'test') 

        self.comp.start()
        # Create data
        fakeData = [x for x in range(0, 512)]
        pktNum = 0
        
        sr=1e6
        xdelta_ns=int(1/(sr) * 1e9)
        time_ns=0
        
        recSRI = False
        # No time slips here
        while pktNum < 100:
            # Create data
            h = Sdds.SddsHeader(pktNum, FREQ=(sr*73786976294.838211), TT=(time_ns*4), CX=1)
            p = Sdds.SddsShortPacket(h.header, fakeData)
            p.encode()
            self.userver.send(p.encodedPacket)
            pktNum = pktNum + 1
            
            if pktNum != 0 and pktNum % 32 == 31:
                pktNum = pktNum + 1
                
            time_ns = time_ns + 512*xdelta_ns
            
        self.assertEqual(self.comp.status.time_slips, 0, "There should be no time slips!")