Commit bfc8f329 authored by Pavel Vainerman's avatar Pavel Vainerman

Написал небольшую документацию по использованию python-module-uniset

parent 6a4cdcb0
/*!
\page PythonPage Интерфейс на python
В проект входит два простых интерфейса для python:
- \ref pgPython_secUniSet
- \ref pgPython_secModbus
\section pgPython_secUniSet Простой python-интерфейс для работы с uniset
В данном интерфейсе реализован только самые просты функции \b getValue и \b setValue.
\sa UConnector
Пример использования:
\code
#!/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())
\endcode
\section pgPython_secModbus Простой python-интерфейс для работы с modbus
В данном интерфейсе реализованы функции Modbus master на основе использования libuniset.
Он имеет ряд простых функций getWord(), getByte(), getBit(), а так же универсальная функция
UModbus::mbread() позволяющая более тонко определять параметры запроса.
Для записи одного регистра (!) реализована UModbus::mbwrite()
\sa UModbus
Пример использования:
\code
#!/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())
\endcode
*/
......@@ -31,7 +31,7 @@ ddir = $(docdir)/html
d_DATA = html/*
# examples
exampledir = $(docdir)/examples
example_DATA = examples/*
# exampledir = $(docdir)/examples
# example_DATA = examples/*
endif
......@@ -653,7 +653,8 @@ INPUT = DocPages/ \
../src/ \
../conf \
../Utilities \
../extensions
../extensions \
../python
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
......@@ -674,7 +675,8 @@ INPUT_ENCODING = UTF-8
FILE_PATTERNS = *.dox \
*.cc \
*.h \
*.idl
*.idl \
*.py
# The RECURSIVE tag can be used to turn specify whether or not subdirectories
# should be searched for input files as well. Possible values are YES and NO.
......@@ -724,7 +726,7 @@ EXAMPLE_PATH =
# and *.h) to filter out the source-files in the directories. If left
# blank all files are included.
EXAMPLE_PATTERNS = DocPages/exmaples
EXAMPLE_PATTERNS =
# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
# searched for input files to be used with the \include or \dontinclude
......
......@@ -647,13 +647,14 @@ WARN_LOGFILE =
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
INPUT = ../include/ \
INPUT = DocPages/ \
../include/ \
../IDL/ \
../src/ \
DocPages/ \
../conf \
../Utilities \
../extensions
../extensions \
../python
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
......@@ -671,11 +672,11 @@ INPUT_ENCODING = UTF-8
# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py
# *.f90 *.f *.for *.vhd *.vhdl
FILE_PATTERNS = *.cc \
FILE_PATTERNS = *.dox \
*.cc \
*.h \
*.idl \
*.dox \
*.hh
*.py
# The RECURSIVE tag can be used to turn specify whether or not subdirectories
# should be searched for input files as well. Possible values are YES and NO.
......@@ -689,7 +690,7 @@ RECURSIVE = YES
# Note that relative paths are relative to the directory from which doxygen is
# run.
EXCLUDE = ../include/gtkmm
EXCLUDE =
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
# directories that are symbolic links (a Unix file system feature) are excluded
......@@ -724,7 +725,7 @@ EXAMPLE_PATH =
# and *.h) to filter out the source-files in the directories. If left
# blank all files are included.
EXAMPLE_PATTERNS = DocPages/Exmaples
EXAMPLE_PATTERNS =
# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
# searched for input files to be used with the \include or \dontinclude
......
......@@ -32,9 +32,10 @@ class UModbus
inline void setTimeout( int msec ){ tout_msec = msec; }
/* Если не указывать ip и порт, будут использованы, те
* чтобы были заданы в connect(). Если заданы другие ip и port,
* будет сделана переподключение..
/*! Универсальная функция для чтения регистров.
* Если не указывать ip и порт, будут использованы, те
* чтобы были заданы в UModbus::connect(). Если заданы другие ip и port,
* будет сделано переподключение..
*/
long mbread( int addr, int mbreg, int mbfunc,
const char* vtype, int nbit=-1,
......@@ -44,6 +45,11 @@ class UModbus
long getByte( int addr, int mbreg, int mbfunc=0x4 )throw(UException);
bool getBit( int addr, int mbreg, int mbfunc=0x2 )throw(UException);
/*! Функция записи регистров 0x06 или 0x10 задаётся параметром \a mbfunc.
* Если не указывать ip и порт, будут использованы, те
* чтобы были заданы в UModbus::connect(). Если заданы другие ip и port,
* будет сделана переподключение..
*/
void mbwrite( int addr, int mbreg, int val, int mbfunc, const char* ip=0, int port=-1 )throw(UException);
protected:
......
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