Commit b978ca67 authored by Pavel Vainerman's avatar Pavel Vainerman

Добавил тесты для python

parent 4a046564
#!/bin/sh
START=./uniset-start.sh
export LD_LIBRARY_PATH="../../lib/.libs;../../lib/pyUniSet/.libs"
${START} -f ./testUC.py --unideb-add-levels info,warn,crit
../../../conf/test.xml
\ No newline at end of file
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
sys.path.append('./.libs/')
sys.path.append('../../lib/pyUniSet/.libs/')
sys.path.append('../../lib/pyUniSet/')
#from pyUniSet import *
from pyUConnector import *
from pyUExceptions import *
if __name__ == "__main__":
lst = Params_inst()
for i in range(0, len(sys.argv)):
if i >= Params.max:
break;
lst.add( sys.argv[i] )
p = []
print "lst: class: " + str(p.__class__.__name__)
try:
uc1 = UConnector( lst, "test.xml" )
# print "(0)UIType: %s" % uc1.getUIType()
print "(1)getShortName: id=%d name=%s" % (1, uc1.getShortName(1))
# print " getName: id=%d name=%s" % (1, uc1.getName(101))
# print " getTextName: id=%d name=%s" % (1, uc1.getTextName(101))
# print "\n"
# print "getShortName: id=%d name=%s" % (2, uc1.getShortName(109))
# print " getName: id=%d name=%s" % (2, uc1.getName(109))
# print " getTextName: id=%d name=%s" % (2, uc1.getTextName(109))
try:
print "(1)setValue: %d=%d" % (3,22)
uc1.setValue(3,22,DefaultID)
except UException, e:
print "(1)setValue exception: " + str(e.getError())
try:
print "(1)getValue: %d=%d" % ( 3, uc1.getValue(3,DefaultID) )
except UException, e:
print "(1)getValue exception: " + str(e.getError())
except UException, e:
print "(testUI): catch exception: " + str(e.getError())
/home/pv/Projects/uniset/Utilities/scripts/uniset-start.sh
\ No newline at end of file
#!/bin/sh
START=./uniset-start.sh
${START} -f ./testUI.py --unideb-add-levels info,warn,crit
../../../conf/test.xml
\ No newline at end of file
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
sys.path.append('./.libs/')
sys.path.append('../../lib/pyUniSet/.libs/')
sys.path.append('../../lib/pyUniSet/')
from pyUniSet import *
if __name__ == "__main__":
lst = Params_inst()
for i in range(0, len(sys.argv)):
if i >= Params.max:
break;
lst.add( sys.argv[i] )
try:
uniset_init_params( lst, str("test.xml") )
print "getShortName: id=%d name=%s" % (1, getShortName(1))
print " getName: id=%d name=%s" % (1, getName(1))
print " getTextName: id=%d name=%s" % (1, getTextName(1))
print "\n"
print "getShortName: id=%d name=%s" % (2, getShortName(2))
print " getName: id=%d name=%s" % (2, getName(2))
print " getTextName: id=%d name=%s" % (2, getTextName(2))
try:
print "getValue: %d=%d" % ( 1, getValue(1) )
except UException, e:
print "getValue exception: " + str(e.getError())
try:
print "setValue: %d=%d" % (14,setValue(14,22))
except UException, e:
print "setValue exception: " + str(e.getError())
except UException, e:
print "(testUI): catch exception: " + str(e.getError())
\ No newline at end of file
/home/pv/Projects/uniset/Utilities/scripts/uniset-start.sh
\ No newline at end of file
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
sys.path.append('./.libs/')
sys.path.append('../../lib/pyUniSet/.libs/')
sys.path.append('../../lib/pyUniSet/')
from pyUModbus import *
if __name__ == "__main__":
try:
mb = UModbus()
print "UIType: %s" % mb.getUIType()
mb.connect("localhost",2048)
try:
print "Test READ functions..."
for f in range(1,5):
print "func=%d reg=%d" % (f,22)
val = mb.mbread(0x01,22,f,"unsigned",-1)
# val = mb.mbread(0x01,22)
print "val=%d"%val
print "getWord: %d" % mb.getWord(0x01,22)
print "getByte: %d" % mb.getByte(0x01,22)
print "getBit: %d" % mb.getBit(0x01,22,3)
# print ""
# print "Test WRITE functions..."
# for f in range(1,6):
# print "func=%d reg=%d" % (f,22)
# val = mb.getValue(f,0x01,22,"unsigned",-1)
except UException, e:
print "exception: " + str(e.getError())
except UException, e:
print "(testUModbus): catch exception: " + str(e.getError())
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment