def testGetRTReturnValue01(self):
     s = sat.Satellite()
     s.addRemoteTerminal(rt=remT.RemoteTerminal(address=1))
     s.addRemoteTerminal(rt=remT.RemoteTerminal(address=2))
     retVal = s.getRemoteTerminal()
     self.assertEqual(retVal.__len__(), 2,
                      'getRemoteTerminal does not get remote terminal')
 def testAddRTInvalidRTErrorType03(self):
     s = sat.Satellite()
     for i in range(1, 31):
         rt = remT.RemoteTerminal(address=i)
         s.addRemoteTerminal(rt)
     rtfinal = remT.RemoteTerminal(address=2)
     self.assertRaises(ValueError, s.addRemoteTerminal, (rtfinal))
 def testAddRTSecondReturnType02(self):
     s = sat.Satellite()
     rt = remT.RemoteTerminal(address=1)
     s.addRemoteTerminal(rt)
     rt1 = remT.RemoteTerminal(address=2)
     self.assertEqual(s.addRemoteTerminal(rt1), 2,
                      'addRemoteTerminal does not set remote terminal')
Example #4
0
 def testSetPollFrameTwortListReturnValue02(self):
     s = sat.Satellite()
     bc = busC.BusController()
     s.setBusController(bc)
     s.addRemoteTerminal(rt=remT.RemoteTerminal(address=15))
     s.addRemoteTerminal(rt=remT.RemoteTerminal(address=29))
     rtList = [15, 29]
     self.assertEqual(bc.setPollFrame(rtList), 2)
 def testAddRTInvalidRTErrorMessage03(self):
     s = sat.Satellite()
     for i in range(1, 31):
         rt = remT.RemoteTerminal(address=i)
         s.addRemoteTerminal(rt)
     rtfinal = remT.RemoteTerminal(address=2)
     self.assertRaisesRegexp(Exception, "^Satellite.addRemoteTerminal:\s\s",
                             s.addRemoteTerminal, (rtfinal))
Example #6
0
 def setUp(self):
     self.sat = sat.Satellite()
     self.rt1 = remT.RemoteTerminal(1)
     self.rt2 = remT.RemoteTerminal(2)
     self.rt3 = remT.RemoteTerminal(3)
     self.rt4 = remT.RemoteTerminal(4)
     self.sat.addRemoteTerminal(self.rt1)
     self.sat.addRemoteTerminal(self.rt2)
     self.sat.addRemoteTerminal(self.rt3)
Example #7
0
 def testSetPollFrameWithNonExistingRTErrorType03(self):
     s = sat.Satellite()
     bc = busC.BusController()
     s.setBusController(bc)
     s.addRemoteTerminal(rt=remT.RemoteTerminal(address=1))
     s.addRemoteTerminal(rt=remT.RemoteTerminal(address=4))
     s.addRemoteTerminal(rt=remT.RemoteTerminal(address=8))
     rtList = [1, 4, 6, 6, 8]
     self.assertRaises(ValueError, bc.setPollFrame, (rtList))
Example #8
0
 def testSetPollFrameWithNonExistingRTErrorMessage03(self):
     s = sat.Satellite()
     bc = busC.BusController()
     s.setBusController(bc)
     s.addRemoteTerminal(rt=remT.RemoteTerminal(address=1))
     s.addRemoteTerminal(rt=remT.RemoteTerminal(address=4))
     s.addRemoteTerminal(rt=remT.RemoteTerminal(address=8))
     rtList = [1, 4, 6, 6, 8]
     self.assertRaisesRegexp(Exception, "^BusController.setPollFrame:\s\s",
                             bc.setPollFrame, (rtList))
Example #9
0
 def testSetPollFrameFourrtListReturnValue(self):
     s = sat.Satellite()
     bc = busC.BusController()
     s.setBusController(bc)
     s.addRemoteTerminal(rt=remT.RemoteTerminal(address=1))
     s.addRemoteTerminal(rt=remT.RemoteTerminal(address=6))
     s.addRemoteTerminal(rt=remT.RemoteTerminal(address=27))
     s.addRemoteTerminal(rt=remT.RemoteTerminal(address=29))
     rtList = [1, 6, 27, 29]
     self.assertEqual(bc.setPollFrame(rtList), 4)
Example #10
0
 def testScenario1And4(self):        
         rtAddress = 10
         r = rt.RemoteTerminal(address = rtAddress)
         c = com.Command(address = r.getAddress())
         c.setToModeCommand(mode = com.Command.transmitStatusWord)
         bus = bs.Bus()
         bus.writeBus(word = c)
         rtResponse = r.readBus(bus = bus)          
         
         rWord = rtResponse.readBus()
         assert isinstance(rWord, st.Status), 'Resulting word is not status word'
         try:
             self.assertEqual(rWord.isServiceRequested(), False, 'RT wants to communicate')
             print 'Test scenario 1 was tested'
         except Exception:
             print 'Test scenario 4 was tested'
             self.assertEqual(rWord.isServiceRequested(), True, 'RT does not want to communicate')
             c1 = com.Command(address = r.getAddress())
             c1.setToModeCommand(mode = com.Command.transmitVectorWord)
             bus = bs.Bus()
             bus.writeBus(word = c1)
             rtResponse = r.readBus(bus = bus)  
             
             rWord = rtResponse.readBus()
             assert isinstance(rWord, st.Status), 'Resulting word is not status word'
             cWord = rtResponse.readBus()
             assert isinstance(cWord, com.Command), 'Resulting word is not command word'     
Example #11
0
 def testSetPollFrameOnertListReturnValue03(self):
     s = sat.Satellite()
     bc = busC.BusController()
     s.setBusController(bc)
     s.addRemoteTerminal(rt=remT.RemoteTerminal(address=30))
     rtList = [30]
     self.assertEqual(bc.setPollFrame(rtList), 1)
 def testLaunchErrorType02(self):
     s = sat.Satellite()
     bc = busC.BusController()
     s.setBusController(bc)
     for i in range(1, 3):
         s.addRemoteTerminal(rt=remT.RemoteTerminal(address=i))
     bc.setPollFrame(rtList=[1, 2])
     self.assertRaises(ValueError, s.launch, (1.2))
 def testLaunchReturnValue03(self):
     s = sat.Satellite()
     bc = busC.BusController()
     s.setBusController(bc)
     for i in range(1, 6):
         s.addRemoteTerminal(rt=remT.RemoteTerminal(address=i))
     bc.setPollFrame(rtList=[1, 2, 3, 4, 5])
     self.assertEqual(s.launch(), 5, 'launch does not launch buscontroller')
Example #14
0
 def testSetPollFrameRepeatrtListReturnValue01(self):
     s = sat.Satellite()
     bc = busC.BusController()
     s.setBusController(bc)
     rt = remT.RemoteTerminal(address=1)
     s.addRemoteTerminal(rt)
     rtList = [1, 1]
     self.assertEqual(bc.setPollFrame(rtList), 2)
Example #15
0
 def testPollReturnValue06(self):
     s = sat.Satellite()
     bc = busC.BusController()
     s.setBusController(bc)
     for i in range(1, 6):
         s.addRemoteTerminal(rt=remT.RemoteTerminal(address=i))
     bc.setPollFrame(rtList=[1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3])
     self.assertEqual(bc.poll(), 3, 'Buscontroller does not poll properly')
 def testLaunchPolledNo05(self):
     s = sat.Satellite()
     bc = busC.BusController()
     s.setBusController(bc)
     for i in range(1, 3):
         s.addRemoteTerminal(rt=remT.RemoteTerminal(address=i))
     bc.setPollFrame(rtList=[1, 2])
     s.launch(frameCount=5)
     self.assertEqual(s.polled, 5, 'launch does not launch buscontroller')
 def testLaunchErrorMessage02(self):
     s = sat.Satellite()
     bc = busC.BusController()
     s.setBusController(bc)
     for i in range(1, 3):
         s.addRemoteTerminal(rt=remT.RemoteTerminal(address=i))
     bc.setPollFrame(rtList=[1, 2])
     s.launch(frameCount=5)
     self.assertRaisesRegexp(Exception, "^Satellite.launch:\s\s", s.launch,
                             (1.2))
Example #18
0
 def testPollAscOrder02(self):
     s = sat.Satellite()
     bc = busC.BusController()
     s.setBusController(bc)
     for i in range(0, 30, -1):
         s.addRemoteTerminal(rt=remT.RemoteTerminal(address=i))
     bc.setPollFrame(rtList=[])
     bc.poll()
     self.assertEqual(sorted(bc.remoteTerminals), bc.polledTerminals,
                      'Buscontroller does not poll properly')
    def testScenario(self):
        # Create some remote terminals
        rt1 = remT.RemoteTerminal(1)
        rt2 = remT.RemoteTerminal(2)
        rt3 = remT.RemoteTerminal(3)

        # Create a bus controller
        bc = busC.BusController()

        # Create a satellite and install the subsystems
        s = sat.Satellite()
        s.setBusController(bc)
        s.addRemoteTerminal(rt1)
        s.addRemoteTerminal(rt2)
        s.addRemoteTerminal(rt3)

        # Tell the bus controller the order in which to poll remote terminals
        pollFrame = [1, 2, 2, 3]
        bc.setPollFrame(pollFrame)

        # Start the subsystems
        s.launch()
Example #20
0
 def testScenario2(self):
     rtAddress = 5
     rtSubAddress = 10
     r = rt.RemoteTerminal(address = rtAddress)
     wordCount = r.getAddress()
     c = com.Command(address = r.getAddress())
     c.setToCommandWord(address = rtSubAddress)
     c.setReceiveCommand()
     c.setWordCount(count = wordCount)
     bus = bs.Bus()
     bus.writeBus(word = c)
     for index in range(wordCount):
         bus.writeBus(word = dt.Data(payload = index))  
     rtResponse = r.readBus(bus = bus)   
     
     rWord = rtResponse.readBus()
     assert isinstance(rWord, st.Status), 'Resulting word is not status word'
Example #21
0
 def testScenario3(self):
     rtAddress = 8
     rtSubAddress = 14
     r = rt.RemoteTerminal(address = rtAddress)
     wordCount = r.getAddress() 
     c = com.Command(address = r.getAddress())
     c.setToCommandWord(address = rtSubAddress)
     c.setTransmitCommand()
     c.setWordCount(count = wordCount)
     bus = bs.Bus()
     bus.writeBus(word = c)
     rtResponse = r.readBus(bus = bus)  
     
     rWord = rtResponse.readBus()
     assert isinstance(rWord, st.Status), 'Resulting word is not status word'
     self.assertEqual(rWord.isServiceRequested(), False, 'RT wants to communicate')
     
     for i in range(r.getAddress()):
         dWord = rtResponse.readBus()
         assert isinstance(dWord, dt.Data), 'Resulting word is not data word'
         self.assertEqual(dWord.getContent(), i, 'Data word not delivered in proper order')
     self.assertRaises(ValueError, rtResponse.readBus)
Example #22
0
 def testReadBusExists(self):
     r = rt.RemoteTerminal(address = 2)
     assert "readBus" in dir(r), 'Method by name readBus does not exists'
 def testAddRTFirstReturnType01(self):
     s = sat.Satellite()
     rt = remT.RemoteTerminal(address=1)
     s.addRemoteTerminal(rt)
     self.assertEqual(s.remoteTerminals.__contains__(rt), True,
                      'addRemoteTerminal does not set remote terminal')
Example #24
0
 def testInitExists(self):
     r = rt.RemoteTerminal(address = 2)
     assert "__init__" in dir(r), 'Method by name __init__ does not exists'
Example #25
0
 def testRTInstantiationValidHAddress(self):
     r = rt.RemoteTerminal(address = 30)
     self.assertEqual(r.address, 30, 'Remote terminal not instantiated properly')
Example #26
0
 def testRTInstantiationValidHReturnType(self):
     r = rt.RemoteTerminal(address = 30)
     assert isinstance(r, rt.RemoteTerminal), 'Remote terminal not instantiated properly'
Example #27
0
 def testRTInstantiationValidLReturnAddress(self):
     r = rt.RemoteTerminal(address = 1)
     self.assertEqual(r.address, 1, 'Remote terminal not instantiated properly')
Example #28
0
 def testGetAddressExists(self):
     r = rt.RemoteTerminal(address = 2)
     assert "getAddress" in dir(r), 'Method by name getAddress does not exists'
Example #29
0
 def testGetAddressReturnType(self):
     r = rt.RemoteTerminal(address = 4)
     assert isinstance(r.getAddress(), int),'getTerminalAddress does not work properly'
Example #30
0
 def testGetAddressReturnValue(self):
     r = rt.RemoteTerminal(address = 4)
     self.assertEqual(r.getAddress(), 4, 'getTerminalAddress does not work properly')