Commit 0f5f6560 authored by Pavel Vainerman's avatar Pavel Vainerman

Добавил python/examples. Откорректировал ошибки сборки.

parent 021e94ee
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
Name: libuniset Name: libuniset
Version: 1.6 Version: 1.6
Release: alt0.3 Release: alt0.5
Summary: UniSet - library for building distributed industrial control systems Summary: UniSet - library for building distributed industrial control systems
...@@ -316,14 +316,20 @@ mv -f %buildroot%python_sitelibdir_noarch/%oname/%oname.py %buildroot%python_sit ...@@ -316,14 +316,20 @@ mv -f %buildroot%python_sitelibdir_noarch/%oname/%oname.py %buildroot%python_sit
%exclude %_pkgconfigdir/libUniSet.pc %exclude %_pkgconfigdir/libUniSet.pc
%changelog %changelog
* Tue Mar 05 2013 Pavel Vainerman <pv@altlinux.ru> 1.6-alt0.5
- python: test build
* Tue Mar 05 2013 Pavel Vainerman <pv@altlinux.ru> 1.6-alt0.4
- python: test build
* Tue Mar 05 2013 Pavel Vainerman <pv@altlinux.ru> 1.6-alt0.3 * Tue Mar 05 2013 Pavel Vainerman <pv@altlinux.ru> 1.6-alt0.3
- new build - python: test build
* Tue Mar 05 2013 Pavel Vainerman <pv@altlinux.ru> 1.6-alt0.2 * Tue Mar 05 2013 Pavel Vainerman <pv@altlinux.ru> 1.6-alt0.2
- test build (with python) - python: test build
* Mon Mar 04 2013 Pavel Vainerman <pv@altlinux.ru> 1.6-alt0.1 * Mon Mar 04 2013 Pavel Vainerman <pv@altlinux.ru> 1.6-alt0.1
- new build - add python interface
* Mon Jan 14 2013 Pavel Vainerman <pv@altlinux.ru> 1.5-alt10 * Mon Jan 14 2013 Pavel Vainerman <pv@altlinux.ru> 1.5-alt10
- add error code for MTR (eterbug #8659) - add error code for MTR (eterbug #8659)
......
#!/bin/sh
START=uniset-start.sh
${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
from uniset 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())
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from uniset 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())
...@@ -4,16 +4,6 @@ ...@@ -4,16 +4,6 @@
from pyUConnector import * from pyUConnector import *
import time import time
# различные глобальные вспомогательные функции
t_NONE=""
t_FAILED="FAILED"
t_PASSED="PASSED"
t_IGNORE="IGNORE"
t_BREAK="BREAK"
t_PAUSE="PAUSE"
t_WARNING = "WARNING"
t_UNKNOWN="UNKNOWN"
def is_id( str_id ): def is_id( str_id ):
if str_id.__class__.__name__ == "int": if str_id.__class__.__name__ == "int":
return True return True
...@@ -229,17 +219,3 @@ def fcalibrate( raw, rawMin, rawMax, calMin, calMax ): ...@@ -229,17 +219,3 @@ def fcalibrate( raw, rawMin, rawMax, calMin, calMax ):
return 0; # деление на 0!!! return 0; # деление на 0!!!
return 1.0 * (raw - rawMin) * (calMax - calMin) / ( rawMax - rawMin ) + calMin; return 1.0 * (raw - rawMin) * (calMax - calMin) / ( rawMax - rawMin ) + calMin;
class TestSuiteException(Exception):
def __init__(self,e="",test_time=-1):
self.err = e
self.ftime = test_time
if test_time == -1:
self.ftime = time.time()
def getError(self):
return self.err
def getFinishTime(self):
return self.ftime
if DISABLE_PYTHON if DISABLE_PYTHON
else else
pyexec_LTLIBRARIES = _pyUniSet.la _pyUConnector.la _pyUModbus.la _pyUExceptions.la pyexec_LTLIBRARIES = _pyUConnector.la _pyUModbus.la _pyUExceptions.la
#_pyUniSet.la
_pyUniSet_la_SOURCES = UInterface.cc UInterface_wrap.cxx # DEPRECATED (use UConnector)
_pyUniSet_la_CXXFLAGS = $(UNISET_CFLAGS) $(PYTHON_CFLAGS) #_pyUniSet_la_SOURCES = UInterface.cc UInterface_wrap.cxx
_pyUniSet_la_LDFLAGS = -module -avoid-version #_pyUniSet_la_CXXFLAGS = $(UNISET_CFLAGS) $(PYTHON_CFLAGS)
_pyUniSet_la_LIBADD = $(UNISET_LIBS) $(PYTHON_LIBS) #_pyUniSet_la_LDFLAGS = -module -avoid-version
#_pyUniSet_la_LIBADD = $(UNISET_LIBS) $(PYTHON_LIBS)
UInterface_wrap.cxx: UInterface.i UInterface.h UInterface_wrap.cxx: UInterface.i UInterface.h
swig -python -c++ -classic UInterface.i swig -python -c++ -classic UInterface.i
...@@ -34,7 +36,7 @@ _pyUExceptions_la_LIBADD = $(UNISET_LIBS) $(UNISET_EXT_LIBS) $(PYTHON_LIBS) ...@@ -34,7 +36,7 @@ _pyUExceptions_la_LIBADD = $(UNISET_LIBS) $(UNISET_EXT_LIBS) $(PYTHON_LIBS)
UExceptions_wrap.cxx: UExceptions.i UExceptions.h UExceptions_wrap.cxx: UExceptions.i UExceptions.h
swig -python -c++ -classic UExceptions.i swig -python -c++ -classic UExceptions.i
pyexec_SCRIPTS = pyUniSet.py pyUConnector.py pyUModbus.py pyUExceptions.py python_SCRIPTS = pyUniSet.py pyUConnector.py pyUModbus.py pyUExceptions.py
clean-local: clean-local:
rm -rf *.py* *_wrap.cxx rm -rf *.py* *_wrap.cxx
......
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