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)
Exemple #2
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 )
    def setUp(self):
        # Called before every test
        self.testStartAt = time.time()
        self.ErrorCount = 0
        self.ErrorMsgs = list()
        self.MimicErrorCount = 0
        self.DigitalErrorCount = 0
        self.testName = ""
        self.newTest = False
        # flush ARP cache, this does iot every test
        os.system("arp -d %s" % underTestAddress)
        #        os.system( "arp -d *" )

        self.doLogin(underTestAddress)
        self.doLogin(controlWbAddress)
        time.sleep(0.1)
        wb6.Send(underTestAddress,
                 'SO1;1')  # disable UDP events for analigue etc
        #        wb6.Send(underTestAddress,'SO2;1')   # Read continuous on analogue inputs.
        wb6.Send(controlWbAddress,
                 'SO1;1')  # disable UDP events for analigue etc
        wb6.Send(controlWbAddress,
                 'SO2;1')  # Read continuous on analogue inputs.

        # ensure relay connected for RS232
        wb6.DigOff(controlWbAddress, CONTROL_SERIAL_RELAY)

        wb6.SendHTTP(underTestAddress, "CR2")  # RS232
        wb6.SendHTTP(controlWbAddress, "CR2")  # RS232

        # we only need to reset all actions on first test of run.
        global FirstTest
        if FirstTest:
            wb6.Send(underTestAddress, 'RT')  # rescan temp bus
            self.disableWebBrickActions(underTestAddress)
            self.disableWebBrickActions(controlWbAddress)
            FirstTest = False

        self.tgt = None
        self.udp = None
        #        print( "Test Setup %f seconds" % (time.time() - self.testStartAt) )

        return
Exemple #4
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)
Exemple #5
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
Exemple #6
0
#! /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()
Exemple #7
0
#
#  wb6 Excercise
#
#   Trigger Digital and Analogue outputs a lot
#
import sys
sys.path.append('../API')
from time import sleep

import wb6
test_ip = "10.100.100.100";


for trig in range(0,8):
    wb6.DigOff(test_ip,trig)


while 1:
    for trig in range(0,8):
        wb6.DigTrigger(test_ip,trig)
        for ana in range(0,4):
            wb6.AnOutSp(test_ip,ana,trig)
        sleep(0.2)