def testAttr(output=True): if output: printHeader("Testing read/write operations construction") scpitree = BuildComponent() voltageObj = AttrTest() currentObj = AttrTest() source = BuildComponent('source', scpitree) voltageComp = BuildComponent('voltage', source) UpperVoltage = BuildAttribute('upper', voltageComp, readcb=voltageObj.upperLimit, writecb=voltageObj.upperLimit) LowerVoltage = BuildAttribute('lower', voltageComp, readcb=voltageObj.lowerLimit, writecb=voltageObj.lowerLimit) ReadVoltage = BuildAttribute('value', voltageComp, readcb=voltageObj.readTest, default=True) currentComp = BuildComponent('current', source) UpperCurrent = BuildAttribute('upper', currentComp, readcb=currentObj.upperLimit, writecb=currentObj.upperLimit) LowerCurrent = BuildAttribute('lower', currentComp, readcb=currentObj.lowerLimit, writecb=currentObj.lowerLimit) ReadCurrent = BuildAttribute('value', currentComp, readcb=currentObj.readTest, default=True) if output: print("%r" % (scpitree)) return scpitree
def testChannelsWithSubchannels(output=True): if output: printHeader("Testing the nested channels commands construction") scpiChannels = BuildComponent() voltageObj = SubchannelTest(nChannels, nSubchannels) currentObj = SubchannelTest(nChannels, nSubchannels) channels = BuildChannel("channel", nChannels, scpiChannels) measures = BuildComponent('measures', channels) functions = BuildChannel("function", nSubchannels, measures) voltageComp = BuildComponent('voltage', functions) UpperVoltage = BuildAttribute('upper', voltageComp, readcb=voltageObj.upperLimit, writecb=voltageObj.upperLimit) LowerVoltage = BuildAttribute('lower', voltageComp, readcb=voltageObj.lowerLimit, writecb=voltageObj.lowerLimit) ReadVoltage = BuildAttribute('value', voltageComp, readcb=voltageObj.readTest, default=True) currentComp = BuildComponent('current', functions) UpperCurrent = BuildAttribute('upper', currentComp, readcb=currentObj.upperLimit, writecb=currentObj.upperLimit) LowerCurrent = BuildAttribute('lower', currentComp, readcb=currentObj.lowerLimit, writecb=currentObj.lowerLimit) ReadCurrent = BuildAttribute('value', currentComp, readcb=currentObj.readTest, default=True) if output: print("%r" % (scpiChannels)) return scpiChannels
def testSpeciaCommands(output=True): if output: printHeader("Testing the special commands construction") scpiSpecials = BuildComponent() idnCmd = BuildSpecialCmd("IDN", scpiSpecials, idn) if output: print("IDN answer: %s" % (scpiSpecials["IDN"].read())) return scpiSpecials
def testArrayAnswers(output=True): if output: printHeader("Testing the array conversion answers") scpiArrays = BuildComponent() reading = ArrayTest() arrayreader = BuildAttribute('readarray', scpiArrays, readcb=reading.readTest) if output: print("%r" % (scpiArrays)) return scpiArrays
def testDictKey(output=True): if output: printHeader("Tests for the DictKey object construction") sampleKey = 'qwerty' dictKey = DictKey(sampleKey) if output: print("Compare the key and it's reduced versions") while dictKey == sampleKey: if output: print("\t%s == %s" % (dictKey, sampleKey)) sampleKey = sampleKey[:-1] if output: print("\tFinally %s != %s" % (dictKey, sampleKey)) return dictKey
def testComponent(output=True): # TODO: test channel like Components if output: printHeader("Tests for the Component dictionary construction") scpitree = BuildComponent() if output: print("Build a root component: %r" % (scpitree)) rootNode = BuildComponent('rootnode', scpitree) nestedA = BuildComponent('nesteda', rootNode) leafA = BuildAttribute('leafa', nestedA) if output: print("Assign a nested component:%r" % (scpitree)) nestedB = BuildComponent('nestedb', rootNode) leafB = BuildAttribute('leafb', nestedB) if output: print("Assign another nested component:%r" % (scpitree)) nestedC = BuildComponent('nestedc', rootNode) subnestedC = BuildComponent('subnestedc', nestedC) leafC = BuildAttribute('leafc', subnestedC) if output: print("Assign a double nested component:%r" % (scpitree)) return scpitree
def testChannels(output=True): if output: printHeader("Testing the channels commands construction") scpiChannels = BuildComponent() voltageObj = ChannelTest(nChannels) currentObj = ChannelTest(nChannels) channels = BuildChannel("channel", nChannels, scpiChannels) voltageComp = BuildComponent('voltage', channels) UpperVoltage = BuildAttribute('upper', voltageComp, readcb=voltageObj.upperLimit, writecb=voltageObj.upperLimit) LowerVoltage = BuildAttribute('lower', voltageComp, readcb=voltageObj.lowerLimit, writecb=voltageObj.lowerLimit) ReadVoltage = BuildAttribute('value', voltageComp, readcb=voltageObj.readTest, default=True) currentComp = BuildComponent('current', channels) UpperCurrent = BuildAttribute('upper', currentComp, readcb=currentObj.upperLimit, writecb=currentObj.upperLimit) LowerCurrent = BuildAttribute('lower', currentComp, readcb=currentObj.lowerLimit, writecb=currentObj.lowerLimit) ReadCurrent = BuildAttribute('value', currentComp, readcb=currentObj.readTest, default=True) if output: print("%r" % (scpiChannels)) return scpiChannels
def testAttr(output=True): if output: printHeader("Testing read/write operations construction") scpitree = build_component() voltageObj = AttrTest() currentObj = AttrTest() source = build_component('source', scpitree) voltageComp = build_component('voltage', source) UpperVoltage = build_attribute('upper', voltageComp, read_cb=voltageObj.upperLimit, write_cb=voltageObj.upperLimit) LowerVoltage = build_attribute('lower', voltageComp, read_cb=voltageObj.lowerLimit, write_cb=voltageObj.lowerLimit) ReadVoltage = build_attribute('value', voltageComp, read_cb=voltageObj.readTest, default=True) currentComp = build_component('current', source) UpperCurrent = build_attribute('upper', currentComp, read_cb=currentObj.upperLimit, write_cb=currentObj.upperLimit) LowerCurrent = build_attribute('lower', currentComp, read_cb=currentObj.lowerLimit, write_cb=currentObj.lowerLimit) ReadCurrent = build_attribute('value', currentComp, read_cb=currentObj.readTest, default=True) if output: print("%r" % (scpitree)) return scpitree