コード例 #1
0
    def testTriacs(self):
        # need better test rig for this. 
        # e.g. temp sensors on mains lamps.

        # first read temp sensors
        savedTemps = list()
        sts = self.loadWbStatus(underTestAddress)
        sts2 = self.loadWbStatus(controlWbAddress)
       
        for idx in range(0,5):
            savedTemps.append( sts2.getTemp( idx ) )

        for idx in range(0,4):
            wb6.DigOn( underTestAddress, idx )
            time.sleep(10)
            #sts = self.loadWbStatus(underTestAddress)
            sts2 = self.loadWbStatus(controlWbAddress)
            tv = sts2.getTemp( idx+1 )
            if ( savedTemps[idx+1] + 3 ) > tv:
                time.sleep(10)
                sts2 = self.loadWbStatus(controlWbAddress)
                tv = sts2.getTemp( idx+1 )
                if ( savedTemps[idx+1] + 3 ) > tv:
                    self.error( 'Not seeing temperature rise for Triac/Lamp: %i Old Temp %s new Temp %s' % (idx, savedTemps[idx],tv) )
                
            wb6.DigOff( underTestAddress, idx )

        self.assertEqual( self.ErrorCount, 0 )
コード例 #2
0
ファイル: wbFactoryTest.py プロジェクト: skyfire1983/webbrick
    def testMimicVolts(self):
        # default should be five volts
        h = wb6.SendHTTP(
            underTestAddress, "SM0;63;1;0"
        )  # make sure Mimics full off or full on and fade fast & 5V
        self.assertEqual(h, True)

        h = wb6.DigOn(underTestAddress, 0)
        print "Return from DigOn is %s" % h
        self.assertEqual(h, True)

        print "----  In 30 second wait ----"
        time.sleep(30)

        self.expectMimicVolts(20, 40)

        wb6.SendHTTP(
            underTestAddress, "SM0;63;1;1"
        )  # make sure Mimics full off or full on and fade fast & 12V
        self.expectMimicVolts(
            55, 90)  # 55 in case running off 12V instead of 13.8V

        wb6.SendHTTP(
            underTestAddress, "SM0;63;1;0"
        )  # make sure Mimics full off or full on and fade fast & 5V
        wb6.DigOff(underTestAddress, 0)

        self.assertEqual(self.ErrorCount, 0)
コード例 #3
0
    def setConfiguration(self):
        logging.info( "setConfiguration" )
        wb6.SendHTTP( underTestAddress,"SM0;63;1;0" )    # make sure Mimics full off or full on and fade fast
        self.disableWebBrickActions(underTestAddress)

        wb6.ConfigFadeRate(underTestAddress, 1 )
        for idx in range(0,8):
            wb6.DigOff( underTestAddress, idx )
        # force a change that Wb will see.
        wb6.DigOn( underTestAddress, 1 )
        wb6.DigOff( underTestAddress, 1 )
        self.assertEqual( self.ErrorCount, 0 )
コード例 #4
0
    def testMimicVolts(self):
        # default should be five volts
        wb6.SendHTTP( underTestAddress,"SM0;63;1;0" )    # make sure Mimics full off or full on and fade fast & 5V

        wb6.DigOn( underTestAddress, 0 )
        self.expectMimicVolts(20, 40)
        
        wb6.SendHTTP( underTestAddress,"SM0;63;1;1" )    # make sure Mimics full off or full on and fade fast & 12V
        self.expectMimicVolts(55, 90)   # 55 in case running off 12V instead of 13.8V

        wb6.SendHTTP( underTestAddress,"SM0;63;1;0" )    # make sure Mimics full off or full on and fade fast & 5V
        wb6.DigOff( underTestAddress, 0 )

        self.assertEqual( self.ErrorCount, 0 )
コード例 #5
0
ファイル: wbFactoryTest.py プロジェクト: skyfire1983/webbrick
    def testDigitals(self):
        # Combine digital and mimic tests
        # include triac tests

        # get current temps  for main lamps.
        triacMap = (1, 2, 3, 4)  # maps triac index to temp index.

        savedTemps = list()
        sts2 = self.loadWbStatus(controlWbAddress)
        owSts = sts2.getOneWireBus()
        for idx in range(0, 4):
            tidx = triacMap[idx]
            if (owSts & (0x01 << tidx)) == 0:
                self.error('Not seeing temperature Triac/Lamp: %i (%i)' %
                           (idx, tidx))
                savedTemps.append(0)
            else:
                savedTemps.append(sts2.getTemp(tidx))

        wb6.SendHTTP(
            underTestAddress,
            "SM0;63;1;0")  # make sure Mimics full off or full on and fade fast
        # tests digital in 0-7 and digital out 0-7/mimics 0-7. The later depends on the conenction to the inputs
        for idx in range(0, 8):
            self.testADigitalChannel(idx)

        # leave all on for soak test
        for idx in range(0, 8):
            wb6.DigOn(underTestAddress, idx)

        # get current temps.
        # see whether mains lamps switched on during this test run.
        # they should of generated enough of a temperature rise to be detected.
        sts2 = self.loadWbStatus(controlWbAddress)
        owSts = sts2.getOneWireBus()

        for idx in range(0, 4):
            tidx = triacMap[idx]
            if (owSts & (0x01 << tidx)) != 0:
                # check we had a sensor.
                tv = sts2.getTemp(tidx)
                if (savedTemps[idx] + 3) > tv:
                    self.error(
                        'Not seeing temperature rise for Triac/Lamp: %i Old Temp %s new Temp %s'
                        % (idx, savedTemps[idx], tv))

        self.assertEqual(self.DigitalErrorCount, 0)
        self.assertEqual(self.MimicErrorCount, 0)
        self.assertEqual(self.ErrorCount, 0)
コード例 #6
0
    def testSerial485OutOfWebBrick(self):
        wb6.DigOn( controlWbAddress, CONTROL_SERIAL_RELAY )
        wb6.SendHTTP( underTestAddress,"CR4" ) # RS485
        wb6.SendHTTP( controlWbAddress,"CR4" ) # RS485
        wb6.SendHTTP( controlWbAddress,"RI" ) # RS485 input
        wb6.SendHTTP( underTestAddress,"RO" ) # RS485 output

        self.captureEvents()

        self.verifySerial(underTestAddress, self.getSerialControlWb)

        wb6.SendHTTP( underTestAddress,"RI" ) # RS485 input
        wb6.DigOff( controlWbAddress, CONTROL_SERIAL_RELAY )

        self.assertEqual( self.ErrorCount, 0 )
コード例 #7
0
    def testSerial485InToWebBrick(self):
        # ensure relay connected for RS232
        wb6.DigOn( controlWbAddress, CONTROL_SERIAL_RELAY )
        
        wb6.SendHTTP( underTestAddress,"CR4" ) # RS485
        wb6.SendHTTP( controlWbAddress,"CR4" ) # RS485
        wb6.SendHTTP( underTestAddress,"RI" ) # RS485 input
        wb6.SendHTTP( controlWbAddress,"RO" ) # RS485 output

        self.captureEvents()

        self.verifySerial(controlWbAddress, self.getSerialUnderTestWb)

        wb6.SendHTTP( controlWbAddress,"RI" ) # RS485 output
        wb6.DigOff( controlWbAddress, CONTROL_SERIAL_RELAY )

        self.assertEqual( self.ErrorCount, 0 )
コード例 #8
0
    def testMimicVolts(self):
        # default should be five volts
        self.sendTestCommand(
            "SM0;63;1;0"
        )  # make sure Mimics full off or full on and fade fast & 5V

        wb6.DigOn(underTestAddress, 0)
        self.expectMimicVolts(15, 30)

        self.sendTestCommand(
            "SM0;63;1;1"
        )  # make sure Mimics full off or full on and fade fast & 12V
        self.expectMimicVolts(50, 80)

        self.sendTestCommand(
            "SM0;63;1;0"
        )  # make sure Mimics full off or full on and fade fast & 5V
        wb6.DigOff(underTestAddress, 0)

        self.expectMimicVolts(-5, 5)  # now off

        self.assertEqual(self.ErrorCount, 0)
コード例 #9
0
    def testADigitalChannel( self, chn ):
        # switch all off
        for idx in range(0,8):
            if ( idx == chn ):
                wb6.DigOn( underTestAddress, chn )
            else:
                wb6.DigOff( underTestAddress, idx )

        self.setTest( 'On test Digital channel ' + str(chn) + ' ip address ' + underTestAddress )

        time.sleep(0.1)
        # first read the status XMl until we get what we expect
        # both the control and under test webbrick
        repeat = 0
        while repeat < 3:
            sts = self.loadWbStatus(underTestAddress)
            sts2 = self.loadWbStatus(controlWbAddress)
            if sts2.getDigIn(chn):
                # mimic correct
                if ( chn <= 3 ) and not sts.getDigIn(idx):
                    # OC correct
                    break
                if ( chn > 3 ) and sts.getDigIn(idx):
                    # DigOut correct
                    break
            repeat = repeat + 1
            time.sleep(0.5)

        # verify only channel under test on
        for idx in range(0,8):
            # if the same
            if ( idx > 3 ):
                if ( idx == chn ):
                    if not sts.getDigIn(idx):
                        self.error( 'channel ' + str(chn) + ' Should be On' )
                        self.DigitalErrorCount = self.DigitalErrorCount + 1
                else:
                    if sts.getDigIn(idx):
                        self.error( 'channel ' + str(idx) + ' Should be Off' )
                        self.DigitalErrorCount = self.DigitalErrorCount + 1
            else:
                if ( idx == chn ):
                    if sts.getDigIn(idx):
                        self.error( 'channel ' + str(chn) + ' Should be On' )
                        self.DigitalErrorCount = self.DigitalErrorCount + 1
                else:
                    if not sts.getDigIn(idx):
                        self.error( 'channel ' + str(idx) + ' Should be Off' )
                        self.DigitalErrorCount = self.DigitalErrorCount + 1

            if ( idx == chn ):
                if not sts2.getDigIn(idx):
                    self.error( 'channel ' + str(chn) + ' Mimic Should be On' )
                    self.MimicErrorCount = self.MimicErrorCount + 1
            else:
                if sts2.getDigIn(idx):
                    self.error( 'channel ' + str(idx) + ' Mimic Should be Off' )
                    self.MimicErrorCount = self.MimicErrorCount + 1

        # verify relays
        firstRelay = 8
        if doTestWb7:
            firstRelay = 9
        for idx in range(firstRelay,12):
            if (idx/2) == chn :
                if not sts.getDigIn(idx):
                    self.error( 'test Relay channel ' + str(chn) + 'Monitor ' + str(idx) + ' High' )
                    self.DigitalErrorCount = self.DigitalErrorCount + 1
            else:
                if sts.getDigIn(idx):
                    self.error( 'test Relay channel ' + str(chn) + 'Monitor ' + str(idx) +  ' Low' )
                    self.DigitalErrorCount = self.DigitalErrorCount + 1

        # switch all on
        self.setTest( 'Off test Digital channel ' + str(chn) + ' ip address ' + underTestAddress )

        for idx in range(0,8):
            if ( idx == chn ):
                wb6.DigOff( underTestAddress, chn )
            else:
                wb6.DigOn( underTestAddress, idx )
        time.sleep(0.1)

        # read the status XMl until we get what we expect
        # both the control and under test webbrick
        repeat = 0
        while repeat < 3:
            sts = self.loadWbStatus(underTestAddress)
            sts2 = self.loadWbStatus(controlWbAddress)
            if not sts2.getDigIn(chn):
                # mimic correct
                if ( chn <= 3 ) and sts.getDigIn(idx):
                    # OC correct
                    break
                if ( chn > 3 ) and not sts.getDigIn(idx):
                    # DigOut correct
                    break
            repeat = repeat + 1
            time.sleep(0.5)

        # verify only channel under test off
        for idx in range(0,8):
            # if the same
            if ( idx > 3 ):
                if ( idx == chn ):
                    if sts.getDigIn(idx):
                        self.error( 'channel ' + str(chn) +' Should be Off' )
                        self.DigitalErrorCount = self.DigitalErrorCount + 1
                else:
                    if not sts.getDigIn(idx):
                        self.error( 'channel ' + str(idx) + ' Should be On' )
                        self.DigitalErrorCount = self.DigitalErrorCount + 1
            else:
                if ( idx == chn ):
                    if not sts.getDigIn(idx):
                        self.error( 'channel ' + str(chn) +' Should be Off' )
                        self.DigitalErrorCount = self.DigitalErrorCount + 1
                else:
                    if sts.getDigIn(idx):
                        self.error( 'channel ' + str(idx) + ' Should be On' )
                        self.MimicErrorCount = self.DigitalErrorCount + 1
            if ( idx == chn ):
                if sts2.getDigIn(idx):
                    self.error( 'channel ' + str(chn) + ' Mimic Should be Off' )
                    self.MimicErrorCount = self.MimicErrorCount + 1
            else:
                if not sts2.getDigIn(idx):
                    self.error( 'channel ' + str(idx) + ' Mimic Should be On' )
                    self.MimicErrorCount = self.MimicErrorCount + 1

        # verify relays again
        for idx in range(firstRelay,12):
            if (idx/2) == chn :
                if sts.getDigIn(idx):
                    self.error( 'test Relay channel ' + str(chn) + 'Monitor ' + str(idx) + ' High' )
                    self.DigitalErrorCount = self.DigitalErrorCount + 1
            else:
                if not sts.getDigIn(idx):
                    self.error( 'test Relay channel ' + str(chn) + 'Monitor ' + str(idx) +  ' Low' )
                    self.DigitalErrorCount = self.DigitalErrorCount + 1
コード例 #10
0
ファイル: WbDigOut.py プロジェクト: skyfire1983/webbrick
#! /usr/local/bin/python
import sys, getopt, string
import wb6

def help_message():
    print '''WbDigOut.py   Direct control of a WebBrick output channel
operands are On,OfF,Toggle
Usage :  WbDigOut.py <Wb-IP-addr> chn operand'''
    sys.exit(0)

if (sys.argv[1] and sys.argv[2] and sys.argv[3]):
    if sys.argv[3] = "On":
        wb6.DigOn( sys.argv[1], sys.argv[2] )
    elif sys.argv[3] = "Off":
        wb6.DigOff( sys.argv[1], sys.argv[2] )
    elif sys.argv[3] = "Toggle":
        wb6.DigToggle( sys.argv[1], sys.argv[2] )
    else:
        print 'Bad action'
        help_message()
else:
    print 'Insufficient arguments'
    help_message()