Commit bad1f281 authored by Pavel Vainerman's avatar Pavel Vainerman

Предварительно добавил реализацию python-модуля (перенос из uniset-testsuite)

parent dacbcca3
%def_enable doc
%def_enable mysql
%def_enable sqlite
%def_enable python
%define oname uniset
Name: libuniset
Version: 1.5
Release: alt10
Version: 1.6
Release: alt0.1
Summary: UniSet - library for building distributed industrial control systems
......@@ -32,6 +33,10 @@ BuildRequires: libMySQL-devel
BuildRequires: libsqlite3-devel
%endif
%if_enabled python
BuildRequires: python-devel swig
%endif
%if_enabled doc
BuildRequires: doxygen
%endif
......@@ -107,6 +112,16 @@ Obsoletes: %oname-sqlite-devel
Libraries needed to develop for uniset SQLite
%endif
%if_enabled python
%package python-modules-uniset
Group: Development/Python
Summary: python interface for libuniset
Requires: %name = %version-%release
%description python-modules-uniset
Python interface for %name
%endif
%package utils
Summary: UniSet utilities
Group: Development/Tools
......@@ -221,6 +236,14 @@ rm -f %buildroot%_libdir/*.la
%_pkgconfigdir/libUniSetSQLite.pc
%endif
%if_enabled python
%files python-modules-uniset
%dir %python_sitelibdir/%name
%python_sitelibdir/*
%python_sitelibdir/%name/*
%endif
%if_enabled doc
%files doc
%_docdir/%oname
......
......@@ -102,6 +102,26 @@ fi
AM_CONDITIONAL(HAVE_EXTENTIONS, test ${ext} = true)
#check python support
AC_MSG_CHECKING([python support])
buildpython=true
AC_ARG_ENABLE(python, AC_HELP_STRING([--disable-python], [disable Python support]),
[ if test $enableval = yes; then buildpython=true; else buildpython=false; fi],[ buildpython=true; ])
if test ${buildpython} = true; then
AC_MSG_RESULT([enabled])
dnl Python
AM_PATH_PYTHON(,,)
PKG_CHECK_MODULES(PYTHON,python,,exit)
AC_CHECK_PROG(SWIG, swig, yes, exit)
else
AC_MSG_RESULT([disabled])
fi
AM_CONDITIONAL(DISABLE_PYTHON, test ${buildpython} = false)
# check Doxygen
DOXYGEN=""
doc=true
......@@ -213,7 +233,10 @@ AC_CONFIG_FILES([Makefile
extensions/SharedMemory/Makefile
extensions/SharedMemory/libUniSetSharedMemory.pc
extensions/SharedMemoryPlus/Makefile
extensions/tests/Makefile])
extensions/tests/Makefile
python/lib/Makefile
python/lib/pyUniSet/Makefile
python/Makefile])
AC_OUTPUT
......
if DISABLE_PYTHON
else
SUBDIRS=lib
endif
if DISABLE_PYTHON
else
SUBDIRS=pyUniSet
#lib_LTLIBRARIES = libUniSetPython.la
#libUniSetPython_la_SOURCES =
#libUniSetPython_la_LIBADD = pyUniSet/_pyUniSet.la
python_SCRIPTS = *.py
endif
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
sys.path.append('./.libs/')
sys.path.append('pyUniSet/.libs/')
sys.path.append('pyUniSet/')
from pyUExceptions import *
from pyUConnector import *
from pyUModbus import *
from TestSuiteGlobal import *
class UInterface():
def __init__(self):
self.utype = ""
self.i = None
self.ignore_nodes = False
def set_ignore_nodes(self, state):
self.ignore_nodes = state
def getSupportedInterfaceList(self):
return ["uniset","modbus"]
def create_uniset_interface(self, xmlfile, params):
self.i = UConnector(params,xmlfile)
self.itype = "uniset"
def create_modbus_interface(self):
self.i = UModbus()
self.itype = "modbus"
# return [id,node,name]
def getIDinfo(self, s_id):
if self.itype == "uniset":
return to_sid(s_id,self.i)
if self.itype == "modbus":
mbaddr,mbreg,mbfunc,nbit,vtype = get_mbquery_param(s_id,"0x04")
return [str(mbreg),str(mbaddr),s_id]
return ["","",""]
def getValue(self, s_id):
try:
if self.itype == "uniset":
s = to_sid(s_id,self.i)
if self.ignore_nodes == True:
s[1] = DefaultID
return self.i.getValue(s[0],s[1])
if self.itype == "modbus":
mbaddr,mbreg,mbfunc,nbit,vtype = get_mbquery_param(s_id,"0x04")
if mbaddr == None or mbreg == None or mbfunc == None:
raise UException( "(modbus:getValue): parse id='%s' failed. Must be 'mbreg@mbaddr:mbfunc:nbit:vtype'"%s_id )
if self.i.isWriteFunction(mbfunc) == True:
raise UException( "(modbus:getValue): for id='%s' mbfunc=%d is WriteFunction. Must be 'read'."%(s_id,mbfunc) )
return self.i.mbread(mbaddr,mbreg,mbfunc,vtype,nbit)
except UException, e:
raise e
raise UException("(getValue): Unknown interface %s"%self.utype)
def setValue(self, s_id, s_val):
try:
if self.itype == "uniset":
s = to_sid(s_id,self.i)
if self.ignore_nodes == True:
s[1] = DefaultID
self.i.setValue(s[0],s_val,s[1])
return
if self.itype == "modbus":
# ip,port,mbaddr,mbreg,mbfunc,vtype,nbit = ui.get_modbus_param(s_id)
mbaddr,mbreg,mbfunc,nbit,vtype = get_mbquery_param(s_id,"0x06")
if mbaddr == None or mbreg == None or mbfunc == None:
raise UException( "(modbus:setValue): parse id='%s' failed. Must be 'mbreg@mbaddr:mbfunc'"%s_id )
#print "MODBUS SET VALUE: s_id=%s"%s_id
if self.i.isWriteFunction(mbfunc) == False:
raise UException( "(modbus:setValue): for id='%s' mbfunc=%d is NOT WriteFunction."%(s_id,mbfunc) )
self.i.mbwrite(mbaddr,mbreg,to_int(s_val),mbfunc)
return
except UException, e:
raise e
raise UException("(setValue): Unknown interface %s"%self.utype)
def getConfFileName(self):
if self.itype == "uniset":
return self.i.getConfFileName()
if self.itype == "modbus":
return ""
raise UException("(setValue): Unknown interface %s"%self.utype)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import libxml2
import xml.dom.minidom as md
import re
import os
# -----------------------------
class EmptyNode():
def __init__(self):
self.proplist = dict()
def prop(self,name):
if name in self.proplist:
return self.proplist[name]
return ""
def setProp(self,name,val):
self.proplist[name] = val
def reset(self):
self.proplist = dict()
# -----------------------------
class UniXMLException(Exception):
def __init__(self,e=""):
self.err = e
def getError(self):
return self.err
# -----------------------------
class UniXML():
def __init__(self, xfile):
try:
self.doc = None
self.fname = xfile
self.doc = libxml2.parseFile(xfile)
except libxml2.parserError:
raise UniXMLException("(UniXML): Can`t open file " + xfile)
libxml2.registerErrorHandler(self.callback, "-->")
def __del__(self):
if self.doc != None:
self.doc.freeDoc()
libxml2.cleanupParser()
if libxml2.debugMemory(1) != 0:
print "Memory leak %d bytes" % (libxml2.debugMemory(1))
libxml2.dumpMemory()
def callback(ctx, str):
print "%s %s" % (ctx, str)
def getDoc(self):
return self.doc
def getFileName(self):
return self.fname
def findNode(self, node, nodestr="", propstr=""):
while node != None:
if node.name == nodestr:
return [node, node.name, node.prop(propstr)]
ret = self.findNode(node.children, nodestr, propstr)
if ret[0] != None:
return ret
node = node.next
return [None, None, None]
def findMyLevel(self, node, nodestr="", propstr=""):
while node != None:
if node.name == nodestr:
return [node, node.name, node.prop(propstr)]
node = node.next
return [None, None, None]
def findNode_byProp(self, node, propstr, valuestr):
while node != None:
if node.prop(propstr) == valuestr:
return [node, node.name, node.prop(propstr)]
ret = self.findNode_byProp (node.children, propstr, valuestr)
if ret[0] != None:
return ret
node = node.next
return [None, None, None]
def nextNode(self, node):
while node != None:
node = node.next
if node == None:
return node
if node.name != "text" and node.name != "comment":
return node
return None
def getNode(self, node):
if node == None:
return None
if node.name != "text" and node.name != "comment":
return node
return self.nextNode(node)
def firstNode(self, node):
while node != None:
prev = node
node = node.prev
if node == None:
node = prev
break
return self.getNode(node)
def lastNode(self, node):
prev = node
while node != None:
prev = node
node = self.nextNode(node)
return prev
def getProp(self, node, str):
prop = node.prop(str)
if prop != None:
return prop
else:
return ""
def save(self, filename=None, pretty_format=True, backup=False):
if filename == None:
filename = self.fname
if backup:
# чтобы "ссылки" не бились, делаем копирование не через rename
#os.rename(self.fname,str(self.fname+".bak"))
f_in = file(self.fname,'rb')
f_out = file(str(self.fname+".bak"),'wb')
f_in.seek(0)
f_out.write(f_in.read())
f_in.close()
f_out.close()
if pretty_format == True:
return self.pretty_save(filename)
return self.doc.saveFile(filename)
def reopen(self, filename):
try:
self.doc.freeDoc()
self.fname = filename
self.doc = libxml2.parseFile(filename)
except libxml2.parserError:
sys.exit(-1)
def pretty_save(self, filename):
context = self.doc.serialize(encoding="utf-8")
mdoc = md.parseString(context)
s = mdoc.toprettyxml(encoding="utf-8").split("\n")
out = open(filename,"w")
p = re.compile(r'\ [^\s]{1,}=""')
for l in s:
if l.strip():
# удаяем пустые свойства prop=""
l = p.sub('', l)
out.write(l+"\n")
out.close()
if DISABLE_PYTHON
else
pyexec_LTLIBRARIES = _pyUniSet.la _pyUConnector.la _pyUModbus.la _pyUExceptions.la
_pyUniSet_la_SOURCES = UInterface.cc UInterface_wrap.cxx
_pyUniSet_la_CXXFLAGS = $(UNISET_CFLAGS) $(PYTHON_CFLAGS)
_pyUniSet_la_LDFLAGS = -module -avoid-version
_pyUniSet_la_LIBADD = $(UNISET_LIBS) $(PYTHON_LIBS)
UInterface_wrap.cxx: UInterface.i UInterface.h
swig -python -c++ -classic UInterface.i
_pyUConnector_la_SOURCES = UConnector.cc UConnector_wrap.cxx
_pyUConnector_la_CXXFLAGS = $(UNISET_CFLAGS) $(PYTHON_CFLAGS)
_pyUConnector_la_LDFLAGS = -module -avoid-version
_pyUConnector_la_LIBADD = $(UNISET_LIBS) $(PYTHON_LIBS)
UConnector_wrap.cxx: UConnector.i UConnector.h
swig -python -c++ -classic UConnector.i
_pyUModbus_la_SOURCES = UModbus.cc UModbus_wrap.cxx
_pyUModbus_la_CXXFLAGS = $(UNISET_CFLAGS) $(UNISET_EXT_CFLAGS) $(PYTHON_CFLAGS)
_pyUModbus_la_LDFLAGS = -module -avoid-version
_pyUModbus_la_LIBADD = $(UNISET_LIBS) $(UNISET_EXT_LIBS) $(PYTHON_LIBS)
UModbus_wrap.cxx: UInterface.i UModbus.h
swig -python -c++ -classic UModbus.i
_pyUExceptions_la_SOURCES = UExceptions_wrap.cxx
_pyUExceptions_la_CXXFLAGS = $(UNISET_CFLAGS) $(UNISET_EXT_CFLAGS) $(PYTHON_CFLAGS)
_pyUExceptions_la_LDFLAGS = -module -avoid-version
_pyUExceptions_la_LIBADD = $(UNISET_LIBS) $(UNISET_EXT_LIBS) $(PYTHON_LIBS)
UExceptions_wrap.cxx: UExceptions.i UExceptions.h
swig -python -c++ -classic UExceptions.i
pyexec_SCRIPTS = pyUniSet.py pyUConnector.py pyUModbus.py pyUExceptions.py
clean-local:
rm -rf *.py* *_wrap.cxx
endif
#include "UConnector.h"
#include "ORepHelpers.h"
// --------------------------------------------------------------------------
using namespace std;
// --------------------------------------------------------------------------
UConnector::UConnector( UTypes::Params* p, const char* xfile )throw(UException):
conf(0),
ui(0),
xmlfile(xfile)
{
try
{
conf = new UniSetTypes::Configuration(p->argc,p->argv,xmlfile);
ui = new UniversalInterface(conf);
}
catch( UniSetTypes::Exception& ex )
{
throw UException(ex.what());
}
catch( ... )
{
throw UException();
}
}
//---------------------------------------------------------------------------
UConnector::UConnector( int argc, char** argv, const char* xfile )throw(UException):
conf(0),
ui(0),
xmlfile(xfile)
{
try
{
conf = new UniSetTypes::Configuration(argc,argv,xmlfile);
ui = new UniversalInterface(conf);
}
catch( UniSetTypes::Exception& ex )
{
throw UException(ex.what());
}
catch( ... )
{
throw UException();
}
}
// --------------------------------------------------------------------------
UConnector::~UConnector()
{
delete ui;
delete conf;
}
// --------------------------------------------------------------------------
const char* UConnector::getConfFileName()
{
// return xmlfile;
if( conf )
return conf->getConfFileName().c_str();
return "";
}
// --------------------------------------------------------------------------
long UConnector::getValue( long id, long node )throw(UException)
{
if( !conf || !ui )
throw USysError();
if( node == UTypes::DefaultID )
node = conf->getLocalNode();
UniversalIO::IOTypes t = conf->getIOType(id);
try
{
switch(t)
{
case UniversalIO::DigitalInput:
case UniversalIO::DigitalOutput:
return (ui->getState(id,node) ? 1 : 0);
break;
case UniversalIO::AnalogInput:
case UniversalIO::AnalogOutput:
return ui->getValue(id,node);
break;
default:
{
ostringstream e;
e << "(getValue): Unknown iotype for id=" << id;
throw UException(e.str());
}
}
}
catch( UException& ex )
{
throw ex;
}
catch( UniSetTypes::Exception& ex )
{
throw UException(ex.what());
}
catch( ... )
{
throw UException("(getValue): catch...");
}
throw UException("(getValue): unknown error");
}
//---------------------------------------------------------------------------
void UConnector::setValue( long id, long val, long node )throw(UException)
{
if( !conf || !ui )
throw USysError();
if( node == UTypes::DefaultID )
node = conf->getLocalNode();
UniversalIO::IOTypes t = conf->getIOType(id);
try
{
switch(t)
{
case UniversalIO::DigitalInput:
ui->saveState(id,val,t,node);
break;
case UniversalIO::DigitalOutput:
ui->setState(id,val,node);
break;
case UniversalIO::AnalogInput:
ui->saveValue(id,val,t,node);
break;
case UniversalIO::AnalogOutput:
ui->setValue(id,val,node);
break;
default:
{
ostringstream e;
e << "(setValue): Unknown iotype for id=" << id;
throw UException(e.str());
}
}
}
catch( UException& ex )
{
throw ex;
}
catch( UniSetTypes::Exception& ex )
{
throw UException(ex.what());
}
catch( ... )
{
throw UException("(setValue): catch...");
}
}
//---------------------------------------------------------------------------
long UConnector::getSensorID( const char* name )
{
if( conf )
return conf->getSensorID(name);
return UTypes::DefaultID;
}
//---------------------------------------------------------------------------
long UConnector::getNodeID( const char* name )
{
if( conf )
return conf->getNodeID(name);
return UTypes::DefaultID;
}
//---------------------------------------------------------------------------
const char* UConnector::getName( long id )
{
if( conf )
return conf->oind->getMapName(id).c_str();
return "";
}
//---------------------------------------------------------------------------
const char* UConnector::getShortName( long id )
{
if( conf )
return ORepHelpers::getShortName(conf->oind->getMapName(id)).c_str();
return "";
}
//---------------------------------------------------------------------------
const char* UConnector::getTextName( long id )
{
if( conf )
return conf->oind->getTextName(id).c_str();
return "";
}
//---------------------------------------------------------------------------
#ifndef UConnector_H_
#define UConnector_H_
// --------------------------------------------------------------------------
#include <string>
#include <Configuration.h>
#include <UniversalInterface.h>
#include "UTypes.h"
#include "UExceptions.h"
// --------------------------------------------------------------------------
class UConnector
{
public:
UConnector( int argc, char** argv, const char* xmlfile )throw(UException);
UConnector( UTypes::Params* p, const char* xmlfile )throw(UException);
~UConnector();
inline const char* getUIType(){ return "uniset"; }
const char* getConfFileName();
long getValue( long id, long node )throw(UException);
void setValue( long id, long val, long node )throw(UException);
long getSensorID( const char* );
long getNodeID( const char* );
const char* getShortName( long id );
const char* getName( long id );
const char* getTextName( long id );
private:
UniSetTypes::Configuration* conf;
UniversalInterface* ui;
const char* xmlfile;
};
//---------------------------------------------------------------------------
#endif
//---------------------------------------------------------------------------
/***********************************************************
* Interface file for wrapping test
* to regenerate the wrappers run:
* swig -python UInterface.i
***********************************************************/
%module pyUConnector
%{
#include "UConnector.h"
%}
/* Для генерации классов и констант в Питоне */
%include "UTypes.h"
//%include "UExceptions.h"
%include "UConnector.h"
This source diff could not be displayed because it is too large. You can view the blob instead.
#ifndef UExceptions_H_
#define UExceptions_H_
// --------------------------------------------------------------------------
struct UException
{
UException(){}
UException( const std::string e ):err(e){}
UException( const char* e ):err( std::string(e)){}
~UException(){}
const char* getError(){ return err.c_str(); }
std::string err;
};
//---------------------------------------------------------------------------
struct UTimeOut:
public UException
{
UTimeOut():UException("UTimeOut"){}
UTimeOut( const std::string e ):UException(e){}
~UTimeOut(){}
};
//---------------------------------------------------------------------------
struct USysError:
public UException
{
USysError():UException("UTimeOut"){}
USysError( const std::string e ):UException(e){}
~USysError(){}
};
//---------------------------------------------------------------------------
#endif
//---------------------------------------------------------------------------
/***********************************************************
* Interface file for wrapping test
* to regenerate the wrappers run:
* swig -python UException.i
***********************************************************/
%module pyUExceptions
%{
#include "UExceptions.h"
%}
%include "UExceptions.h"
This source diff could not be displayed because it is too large. You can view the blob instead.
#include <ostream>
#include <Exceptions.h>
#include <ORepHelpers.h>
#include <UniversalInterface.h>
#include <Configuration.h>
#include <UniSetTypes.h>
#include "UInterface.h"
//---------------------------------------------------------------------------
using namespace std;
//---------------------------------------------------------------------------
static UniversalInterface* ui=0;
//---------------------------------------------------------------------------
void UInterface::uniset_init_params( UTypes::Params* p, const char* xmlfile )throw(UException)
{
UInterface::uniset_init(p->argc,p->argv,xmlfile);
}
//---------------------------------------------------------------------------
void UInterface::uniset_init( int argc, char* argv[], const char* xmlfile )throw(UException)
{
try
{
UniSetTypes::uniset_init(argc,argv,xmlfile);
ui = new UniversalInterface();
return;
}
catch( UniSetTypes::Exception& ex )
{
throw UException(ex.what());
}
catch( ... )
{
throw UException();
}
}
//---------------------------------------------------------------------------
long UInterface::getValue( long id )throw(UException)
{
if( !UniSetTypes::conf || !ui )
throw USysError();
UniversalIO::IOTypes t = UniSetTypes::conf->getIOType(id);
try
{
switch(t)
{
case UniversalIO::DigitalInput:
case UniversalIO::DigitalOutput:
return (ui->getState(id) ? 1 : 0);
break;
case UniversalIO::AnalogInput:
case UniversalIO::AnalogOutput:
return ui->getValue(id);
break;
default:
{
ostringstream e;
e << "(getValue): Unknown iotype for id=" << id;
throw UException(e.str());
}
}
}
catch( UException& ex )
{
throw ex;
}
catch( UniSetTypes::Exception& ex )
{
throw UException(ex.what());
}
catch( ... )
{
throw UException("(getValue): catch...");
}
throw UException("(getValue): unknown error");
}
//---------------------------------------------------------------------------
void UInterface::setValue( long id, long val )throw(UException)
{
if( !UniSetTypes::conf || !ui )
throw USysError();
UniversalIO::IOTypes t = UniSetTypes::conf->getIOType(id);
try
{
switch(t)
{
case UniversalIO::DigitalInput:
ui->saveState(id,val,t);
break;
case UniversalIO::DigitalOutput:
ui->setState(id,val);
break;
case UniversalIO::AnalogInput:
ui->saveValue(id,val,t);
break;
case UniversalIO::AnalogOutput:
ui->setValue(id,val);
break;
default:
{
ostringstream e;
e << "(setValue): Unknown iotype for id=" << id;
throw UException(e.str());
}
}
}
catch( UException& ex )
{
throw ex;
}
catch( UniSetTypes::Exception& ex )
{
throw UException(ex.what());
}
catch( ... )
{
throw UException("(setValue): catch...");
}
}
//---------------------------------------------------------------------------
long UInterface::getSensorID( const char* name )
{
if( UniSetTypes::conf )
return UniSetTypes::conf->getSensorID(name);
return -1;
}
//---------------------------------------------------------------------------
const char* UInterface::getName( long id )
{
if( UniSetTypes::conf )
return UniSetTypes::conf->oind->getMapName(id).c_str();
return "";
}
//---------------------------------------------------------------------------
const char* UInterface::getShortName( long id )
{
if( UniSetTypes::conf )
return ORepHelpers::getShortName(UniSetTypes::conf->oind->getMapName(id)).c_str();
return "";
}
//---------------------------------------------------------------------------
const char* UInterface::getTextName( long id )
{
if( UniSetTypes::conf )
return UniSetTypes::conf->oind->getTextName(id).c_str();
return "";
}
//---------------------------------------------------------------------------
const char* getConfFileName()
{
if( UniSetTypes::conf )
return UniSetTypes::conf->getConfFileName().c_str();
return "";
}
//---------------------------------------------------------------------------
#ifndef UInterface_H_
#define UInterface_H_
// --------------------------------------------------------------------------
#include <string>
#include "UTypes.h"
#include "UExceptions.h"
// --------------------------------------------------------------------------
namespace UInterface
{
void uniset_init_params( UTypes::Params* p, const char* xmlfile )throw(UException);
void uniset_init( int argc, char** argv, const char* xmlfile )throw(UException);
//---------------------------------------------------------------------------
long getValue( long id )throw(UException);
void setValue( long id, long val )throw(UException);
long getSensorID( const char* );
const char* getShortName( long id );
const char* getName( long id );
const char* getTextName( long id );
const char* getConfFileName();
};
//---------------------------------------------------------------------------
#endif
//---------------------------------------------------------------------------
/***********************************************************
* Interface file for wrapping test
* to regenerate the wrappers run:
* swig -python UInterface.i
***********************************************************/
%module pyUniSet
%{
#include "UInterface.h"
%}
/* Для генерации классов и констант в Питоне */
%include "UInterface.h"
%include "UTypes.h"
%include "UExceptions.h"
This source diff could not be displayed because it is too large. You can view the blob instead.
#include <ostream>
#include <cmath>
#include "UModbus.h"
// --------------------------------------------------------------------------
using namespace std;
// --------------------------------------------------------------------------
#if 0
UModbus::UModbus( UTypes::Params* p )throw(UException):
mb(0),
ip(""),
port(512),
tout_msec(5000)
{
try
{
mb = new ModbusTCPMaster();
}
catch(...)
{
throw UException();
}
}
//---------------------------------------------------------------------------
UModbus::UModbus( int argc, char** argv )throw(UException):
mb(0),
ip(""),
port(512),
tout_msec(5000)
{
try
{
mb = new ModbusTCPMaster();
}
catch(...)
{
throw UException();
}
}
#endif
// --------------------------------------------------------------------------
UModbus::UModbus():
mb(0),
ip(""),
port(512),
tout_msec(5000)
{
mb = new ModbusTCPMaster();
}
// --------------------------------------------------------------------------
UModbus::~UModbus()
{
delete mb;
}
// --------------------------------------------------------------------------
void UModbus::prepare( const char* _ip, int _port )throw(UException)
{
if( !mb )
throw UException("(connect): mb=NULL?!");
string s(_ip);
if( mb->isConnection() )
{
if( _port == port && s==ip )
return;
mb->disconnect();
}
//cerr << "************** Prepare: " << string(_ip) << ":" << port << endl;
// strncpy(char *dest, const char *src, size_t n);
ip = s;
port = _port;
}
// --------------------------------------------------------------------------
void UModbus::connect( const char* _ip, int _port )throw(UException)
{
if( !mb )
throw UException("(connect): mb=NULL?!");
string s(_ip);
if( mb->isConnection() )
{
if( _port == port && s==ip )
return;
mb->disconnect();
}
ip = s;
port = _port;
ost::InetAddress ia(_ip);
try
{
// cerr << "************** Connect: " << ia << ":" << port << " ip:" << ip << endl;
mb->connect(ia,port);
}
catch( ModbusRTU::mbException& ex )
{
std::ostringstream err;
err << ex;
throw UException(err.str());
}
catch(...)
{
std::ostringstream err;
err << "Connection failed: ip=" << ip << " port=" << port;
throw UException(err.str());
}
}
// --------------------------------------------------------------------------
long UModbus::getWord( int addr, int mbreg, int mbfunc )throw(UException)
{
return mbread(addr,mbreg,mbfunc,"signed");
}
// --------------------------------------------------------------------------
long UModbus::getByte( int addr, int mbreg, int mbfunc )throw(UException)
{
return mbread(addr,mbreg,mbfunc,"byte");
}
// --------------------------------------------------------------------------
bool UModbus::getBit( int addr, int mbreg, int mbfunc )throw(UException)
{
return mbread(addr,mbreg,mbfunc,"unsigned");
}
// --------------------------------------------------------------------------
long UModbus::mbread( int mbaddr, int mbreg, int mbfunc, const char* s_vtype, int nbit,
const char* new_ip, int new_port )throw(UException)
{
using namespace VTypes;
// const char* n_ip = strcmp(new_ip,"") ? new_ip : ip;
const char* n_ip = (new_ip != 0) ? new_ip : ip.c_str();
int n_port = ( new_port > 0 ) ? new_port : port;
connect(n_ip,n_port);
VType vt = str2type(s_vtype);
if( vt == vtUnknown )
{
std::ostringstream err;
err << "(mbread): Unknown vtype='" << string(s_vtype) << "'";
throw UException(err.str());
}
if( nbit >= 16 )
{
std::ostringstream err;
err << "(mbread): BAD nbit='%d' (nbit must be <16)" << nbit;
throw UException(err.str());
}
int b_count = wsize(vt);
try
{
switch( mbfunc )
{
case ModbusRTU::fnReadInputRegisters:
{
ModbusRTU::ReadInputRetMessage ret = mb->read04(mbaddr,mbreg,b_count);
if( nbit < 0 )
return data2value(vt,ret.data);
ModbusRTU::DataBits16 b(ret.data[0]);
return b[nbit];
}
break;
case ModbusRTU::fnReadOutputRegisters:
{
ModbusRTU::ReadOutputRetMessage ret = mb->read03(mbaddr,mbreg,b_count);
if( nbit < 0 )
return data2value(vt,ret.data);
ModbusRTU::DataBits16 b(ret.data[0]);
return b[nbit];
}
break;
case ModbusRTU::fnReadInputStatus:
{
ModbusRTU::ReadInputStatusRetMessage ret = mb->read02(mbaddr,mbreg,1);
ModbusRTU::DataBits b(ret.data[0]);
return b[0];
}
break;
case ModbusRTU::fnReadCoilStatus:
{
ModbusRTU::ReadCoilRetMessage ret = mb->read01(mbaddr,mbreg,1);
ModbusRTU::DataBits b(ret.data[0]);
return b[0];
}
break;
default:
{
std::ostringstream err;
err << "(mbread): Unsupported function = '" << mbfunc << "'";
throw UException(err.str());
}
break;
}
}
catch( ModbusRTU::mbException& ex )
{
if( ex.err != ModbusRTU::erTimeOut )
throw UTimeOut();
std::ostringstream err;
err << ex;
throw UException(err.str());
}
catch(...)
{
throw UException("(mbread): catch...");
}
}
//---------------------------------------------------------------------------
long UModbus::data2value( VTypes::VType vtype, ModbusRTU::ModbusData* data )
{
#if 0
if( vt == VTypes::vtUnknown )
{
ModbusRTU::DataBits16 b(data[0]);
if( nbit >= 0 )
return b[p->nbit] ? 1 : 0;
if( p->rnum <= 1 )
{
if( p->stype == UniversalIO::DigitalInput ||
p->stype == UniversalIO::DigitalOutput )
{
IOBase::processingAsDI( p, data[0], shm, force );
}
else
IOBase::processingAsAI( p, (signed short)(data[0]), shm, force );
return true;
}
dlog[Debug::CRIT] << myname << "(initSMValue): IGNORE item: rnum=" << p->rnum
<< " > 1 ?!! for id=" << p->si.id << endl;
return false;
}
#endif
if( vtype == VTypes::vtSigned )
return (signed short)(data[0]);
else if( vtype == VTypes::vtUnsigned )
return (unsigned short)data[0];
else if( vtype == VTypes::vtByte )
{
VTypes::Byte b(data[0]);
return (long)(b.raw.b[0]);
}
else if( vtype == VTypes::vtF2 )
{
VTypes::F2 f(data,VTypes::F2::wsize());
return lroundf( (float)f );
}
else if( vtype == VTypes::vtF4 )
{
VTypes::F4 f(data,VTypes::F4::wsize());
return lroundf( (float)f );
}
else if( vtype == VTypes::vtI2 )
{
VTypes::I2 i2(data,VTypes::I2::wsize());
return (int)i2;
}
else if( vtype == VTypes::vtU2 )
{
VTypes::U2 u2(data,VTypes::U2::wsize());
return (unsigned int)u2;
}
return 0;
}
//---------------------------------------------------------------------------
void UModbus::mbwrite( int mbaddr, int mbreg, int val, int mbfunc, const char* new_ip, int new_port )throw(UException)
{
const char* n_ip = (new_ip != 0) ? new_ip : ip.c_str();
int n_port = ( new_port > 0 ) ? new_port : port;
connect(n_ip,n_port);
try
{
switch( mbfunc )
{
case ModbusRTU::fnWriteOutputSingleRegister:
{
ModbusRTU::WriteSingleOutputRetMessage ret = mb->write06(mbaddr,mbreg,val);
}
break;
case ModbusRTU::fnWriteOutputRegisters:
{
ModbusRTU::WriteOutputMessage msg(mbaddr,mbreg);
msg.addData(val);
ModbusRTU::WriteOutputRetMessage ret = mb->write10(msg);
}
break;
case ModbusRTU::fnForceSingleCoil:
{
ModbusRTU::ForceSingleCoilRetMessage ret = mb->write05(mbaddr,mbreg,val);
}
break;
case ModbusRTU::fnForceMultipleCoils:
{
ModbusRTU::ForceCoilsMessage msg(mbaddr,mbreg);
msg.addBit( (val ? true : false) );
ModbusRTU::ForceCoilsRetMessage ret = mb->write0F(msg);
}
break;
default:
{
std::ostringstream err;
err << "(mbwrite): Unsupported function = '" << mbfunc << "'";
throw UException(err.str());
}
break;
}
}
catch( ModbusRTU::mbException& ex )
{
if( ex.err != ModbusRTU::erTimeOut )
throw UTimeOut();
std::ostringstream err;
err << ex;
throw UException(err.str());
}
catch(...)
{
throw UException("(mbwrite): catch...");
}
}
//---------------------------------------------------------------------------
#ifndef UModbus_H_
#define UModbus_H_
// --------------------------------------------------------------------------
#include <Configuration.h>
#include <UniversalInterface.h>
#include <modbus/ModbusTCPMaster.h>
#include <modbus/ModbusTypes.h>
#include <extensions/VTypes.h>
#include <Debug.h>
#include "UTypes.h"
#include "UExceptions.h"
// --------------------------------------------------------------------------
class UModbus
{
public:
// UModbus( int argc, char** argv )throw(UException);
// UModbus( UTypes::Params* p )throw(UException);
UModbus();
~UModbus();
inline const char* getUIType(){ return "modbus"; }
inline bool isWriteFunction( int mbfunc ){ return ModbusRTU::isWriteFunction((ModbusRTU::SlaveFunctionCode)mbfunc); }
// выставление паметров связи, без установления соединения (!)
void prepare( const char* ip, int port )throw(UException);
void connect( const char* ip, int port )throw(UException);
inline int conn_port(){ return port; }
inline std::string conn_ip(){ return ip; }
inline bool isConnection(){ return (mb && mb->isConnection()); }
inline void setTimeout( int msec ){ tout_msec = msec; }
/* Если не указывать ip и порт, будут использованы, те
* чтобы были заданы в connect(). Если заданы другие ip и port,
* будет сделана переподключение..
*/
long mbread( int addr, int mbreg, int mbfunc,
const char* vtype, int nbit=-1,
const char* ip=0, int port=-1 )throw(UException);
long getWord( int addr, int mbreg, int mbfunc=0x4 )throw(UException);
long getByte( int addr, int mbreg, int mbfunc=0x4 )throw(UException);
bool getBit( int addr, int mbreg, int mbfunc=0x2 )throw(UException);
void mbwrite( int addr, int mbreg, int val, int mbfunc, const char* ip=0, int port=-1 )throw(UException);
protected:
long data2value( VTypes::VType vt, ModbusRTU::ModbusData* data );
private:
// DebugStream dlog;
ModbusTCPMaster* mb;
int port;
string ip;
int tout_msec;
};
//---------------------------------------------------------------------------
#endif
//---------------------------------------------------------------------------
/***********************************************************
* Interface file for wrapping test
* to regenerate the wrappers run:
* swig -python UInterface.i
***********************************************************/
%module pyUModbus
%{
#include "UModbus.h"
%}
/* Для генерации классов и констант в Питоне */
%include "UModbus.h"
%include "UTypes.h"
//%include "UExceptions.h"
This source diff could not be displayed because it is too large. You can view the blob instead.
#ifndef UTypes_H_
#define UTypes_H_
// --------------------------------------------------------------------------
#include <UniSetTypes.h>
// --------------------------------------------------------------------------
namespace UTypes
{
const long DefaultID = UniSetTypes::DefaultObjectId;
struct Params
{
static const int max = 20;
Params():argc(0){}
bool add( char* s )
{
if( argc < Params::max )
{
argv[argc++] = s;
return true;
}
return false;
}
int argc;
char* argv[max];
static Params inst(){ return Params(); }
};
};
//---------------------------------------------------------------------------
#endif
//---------------------------------------------------------------------------
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 2.0.8
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
from sys import version_info
if version_info >= (2,6,0):
def swig_import_helper():
from os.path import dirname
import imp
fp = None
try:
fp, pathname, description = imp.find_module('_pyUConnector', [dirname(__file__)])
except ImportError:
import _pyUConnector
return _pyUConnector
if fp is not None:
try:
_mod = imp.load_module('_pyUConnector', fp, pathname, description)
finally:
fp.close()
return _mod
_pyUConnector = swig_import_helper()
del swig_import_helper
else:
import _pyUConnector
del version_info
def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
if (name == "thisown"): return self.this.own(value)
if (name == "this"):
if type(value).__name__ == 'SwigPyObject':
self.__dict__[name] = value
return
method = class_type.__swig_setmethods__.get(name,None)
if method: return method(self,value)
if (not static):
self.__dict__[name] = value
else:
raise AttributeError("You cannot add attributes to %s" % self)
def _swig_setattr(self,class_type,name,value):
return _swig_setattr_nondynamic(self,class_type,name,value,0)
def _swig_getattr(self,class_type,name):
if (name == "thisown"): return self.this.own()
method = class_type.__swig_getmethods__.get(name,None)
if method: return method(self)
raise AttributeError(name)
def _swig_repr(self):
try: strthis = "proxy of " + self.this.__repr__()
except: strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
class Params:
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, Params, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, Params, name)
__repr__ = _swig_repr
max = _pyUConnector.Params_max
def __init__(self):
this = _pyUConnector.new_Params()
try: self.this.append(this)
except: self.this = this
def add(self, *args): return _pyUConnector.Params_add(self, *args)
__swig_setmethods__["argc"] = _pyUConnector.Params_argc_set
__swig_getmethods__["argc"] = _pyUConnector.Params_argc_get
__swig_setmethods__["argv"] = _pyUConnector.Params_argv_set
__swig_getmethods__["argv"] = _pyUConnector.Params_argv_get
__swig_getmethods__["inst"] = lambda x: _pyUConnector.Params_inst
__swig_destroy__ = _pyUConnector.delete_Params
__del__ = lambda self : None;
Params_swigregister = _pyUConnector.Params_swigregister
Params_swigregister(Params)
cvar = _pyUConnector.cvar
DefaultID = cvar.DefaultID
def Params_inst():
return _pyUConnector.Params_inst()
Params_inst = _pyUConnector.Params_inst
class UConnector:
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, UConnector, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, UConnector, name)
__repr__ = _swig_repr
def __init__(self, *args):
this = _pyUConnector.new_UConnector(*args)
try: self.this.append(this)
except: self.this = this
__swig_destroy__ = _pyUConnector.delete_UConnector
__del__ = lambda self : None;
def getUIType(self): return _pyUConnector.UConnector_getUIType(self)
def getConfFileName(self): return _pyUConnector.UConnector_getConfFileName(self)
def getValue(self, *args): return _pyUConnector.UConnector_getValue(self, *args)
def setValue(self, *args): return _pyUConnector.UConnector_setValue(self, *args)
def getSensorID(self, *args): return _pyUConnector.UConnector_getSensorID(self, *args)
def getNodeID(self, *args): return _pyUConnector.UConnector_getNodeID(self, *args)
def getShortName(self, *args): return _pyUConnector.UConnector_getShortName(self, *args)
def getName(self, *args): return _pyUConnector.UConnector_getName(self, *args)
def getTextName(self, *args): return _pyUConnector.UConnector_getTextName(self, *args)
UConnector_swigregister = _pyUConnector.UConnector_swigregister
UConnector_swigregister(UConnector)
# This file is compatible with both classic and new-style classes.
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 2.0.4
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
from sys import version_info
if version_info >= (2,6,0):
def swig_import_helper():
from os.path import dirname
import imp
fp = None
try:
fp, pathname, description = imp.find_module('_pyUExceptions', [dirname(__file__)])
except ImportError:
import _pyUExceptions
return _pyUExceptions
if fp is not None:
try:
_mod = imp.load_module('_pyUExceptions', fp, pathname, description)
finally:
fp.close()
return _mod
_pyUExceptions = swig_import_helper()
del swig_import_helper
else:
import _pyUExceptions
del version_info
def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
if (name == "thisown"): return self.this.own(value)
if (name == "this"):
if type(value).__name__ == 'SwigPyObject':
self.__dict__[name] = value
return
method = class_type.__swig_setmethods__.get(name,None)
if method: return method(self,value)
if (not static):
self.__dict__[name] = value
else:
raise AttributeError("You cannot add attributes to %s" % self)
def _swig_setattr(self,class_type,name,value):
return _swig_setattr_nondynamic(self,class_type,name,value,0)
def _swig_getattr(self,class_type,name):
if (name == "thisown"): return self.this.own()
method = class_type.__swig_getmethods__.get(name,None)
if method: return method(self)
raise AttributeError(name)
def _swig_repr(self):
try: strthis = "proxy of " + self.this.__repr__()
except: strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
class UException:
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, UException, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, UException, name)
__repr__ = _swig_repr
def __init__(self, *args):
this = _pyUExceptions.new_UException(*args)
try: self.this.append(this)
except: self.this = this
__swig_destroy__ = _pyUExceptions.delete_UException
__del__ = lambda self : None;
def getError(self): return _pyUExceptions.UException_getError(self)
__swig_setmethods__["err"] = _pyUExceptions.UException_err_set
__swig_getmethods__["err"] = _pyUExceptions.UException_err_get
UException_swigregister = _pyUExceptions.UException_swigregister
UException_swigregister(UException)
class UTimeOut(UException):
__swig_setmethods__ = {}
for _s in [UException]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, UTimeOut, name, value)
__swig_getmethods__ = {}
for _s in [UException]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, UTimeOut, name)
__repr__ = _swig_repr
def __init__(self, *args):
this = _pyUExceptions.new_UTimeOut(*args)
try: self.this.append(this)
except: self.this = this
__swig_destroy__ = _pyUExceptions.delete_UTimeOut
__del__ = lambda self : None;
UTimeOut_swigregister = _pyUExceptions.UTimeOut_swigregister
UTimeOut_swigregister(UTimeOut)
class USysError(UException):
__swig_setmethods__ = {}
for _s in [UException]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, USysError, name, value)
__swig_getmethods__ = {}
for _s in [UException]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, USysError, name)
__repr__ = _swig_repr
def __init__(self, *args):
this = _pyUExceptions.new_USysError(*args)
try: self.this.append(this)
except: self.this = this
__swig_destroy__ = _pyUExceptions.delete_USysError
__del__ = lambda self : None;
USysError_swigregister = _pyUExceptions.USysError_swigregister
USysError_swigregister(USysError)
# This file is compatible with both classic and new-style classes.
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 2.0.4
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
from sys import version_info
if version_info >= (2,6,0):
def swig_import_helper():
from os.path import dirname
import imp
fp = None
try:
fp, pathname, description = imp.find_module('_pyUModbus', [dirname(__file__)])
except ImportError:
import _pyUModbus
return _pyUModbus
if fp is not None:
try:
_mod = imp.load_module('_pyUModbus', fp, pathname, description)
finally:
fp.close()
return _mod
_pyUModbus = swig_import_helper()
del swig_import_helper
else:
import _pyUModbus
del version_info
def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
if (name == "thisown"): return self.this.own(value)
if (name == "this"):
if type(value).__name__ == 'SwigPyObject':
self.__dict__[name] = value
return
method = class_type.__swig_setmethods__.get(name,None)
if method: return method(self,value)
if (not static):
self.__dict__[name] = value
else:
raise AttributeError("You cannot add attributes to %s" % self)
def _swig_setattr(self,class_type,name,value):
return _swig_setattr_nondynamic(self,class_type,name,value,0)
def _swig_getattr(self,class_type,name):
if (name == "thisown"): return self.this.own()
method = class_type.__swig_getmethods__.get(name,None)
if method: return method(self)
raise AttributeError(name)
def _swig_repr(self):
try: strthis = "proxy of " + self.this.__repr__()
except: strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
class UModbus:
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, UModbus, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, UModbus, name)
__repr__ = _swig_repr
def __init__(self):
this = _pyUModbus.new_UModbus()
try: self.this.append(this)
except: self.this = this
__swig_destroy__ = _pyUModbus.delete_UModbus
__del__ = lambda self : None;
def getUIType(self): return _pyUModbus.UModbus_getUIType(self)
def isWriteFunction(self, *args): return _pyUModbus.UModbus_isWriteFunction(self, *args)
def prepare(self, *args): return _pyUModbus.UModbus_prepare(self, *args)
def connect(self, *args): return _pyUModbus.UModbus_connect(self, *args)
def conn_port(self): return _pyUModbus.UModbus_conn_port(self)
def conn_ip(self): return _pyUModbus.UModbus_conn_ip(self)
def isConnection(self): return _pyUModbus.UModbus_isConnection(self)
def setTimeout(self, *args): return _pyUModbus.UModbus_setTimeout(self, *args)
def mbread(self, *args): return _pyUModbus.UModbus_mbread(self, *args)
def getWord(self, *args): return _pyUModbus.UModbus_getWord(self, *args)
def getByte(self, *args): return _pyUModbus.UModbus_getByte(self, *args)
def getBit(self, *args): return _pyUModbus.UModbus_getBit(self, *args)
def mbwrite(self, *args): return _pyUModbus.UModbus_mbwrite(self, *args)
UModbus_swigregister = _pyUModbus.UModbus_swigregister
UModbus_swigregister(UModbus)
class Params:
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, Params, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, Params, name)
__repr__ = _swig_repr
max = _pyUModbus.Params_max
def __init__(self):
this = _pyUModbus.new_Params()
try: self.this.append(this)
except: self.this = this
def add(self, *args): return _pyUModbus.Params_add(self, *args)
__swig_setmethods__["argc"] = _pyUModbus.Params_argc_set
__swig_getmethods__["argc"] = _pyUModbus.Params_argc_get
__swig_setmethods__["argv"] = _pyUModbus.Params_argv_set
__swig_getmethods__["argv"] = _pyUModbus.Params_argv_get
__swig_getmethods__["inst"] = lambda x: _pyUModbus.Params_inst
__swig_destroy__ = _pyUModbus.delete_Params
__del__ = lambda self : None;
Params_swigregister = _pyUModbus.Params_swigregister
Params_swigregister(Params)
cvar = _pyUModbus.cvar
DefaultID = cvar.DefaultID
def Params_inst():
return _pyUModbus.Params_inst()
Params_inst = _pyUModbus.Params_inst
# This file is compatible with both classic and new-style classes.
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 2.0.4
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
from sys import version_info
if version_info >= (2,6,0):
def swig_import_helper():
from os.path import dirname
import imp
fp = None
try:
fp, pathname, description = imp.find_module('_pyUniSet', [dirname(__file__)])
except ImportError:
import _pyUniSet
return _pyUniSet
if fp is not None:
try:
_mod = imp.load_module('_pyUniSet', fp, pathname, description)
finally:
fp.close()
return _mod
_pyUniSet = swig_import_helper()
del swig_import_helper
else:
import _pyUniSet
del version_info
def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
if (name == "thisown"): return self.this.own(value)
if (name == "this"):
if type(value).__name__ == 'SwigPyObject':
self.__dict__[name] = value
return
method = class_type.__swig_setmethods__.get(name,None)
if method: return method(self,value)
if (not static):
self.__dict__[name] = value
else:
raise AttributeError("You cannot add attributes to %s" % self)
def _swig_setattr(self,class_type,name,value):
return _swig_setattr_nondynamic(self,class_type,name,value,0)
def _swig_getattr(self,class_type,name):
if (name == "thisown"): return self.this.own()
method = class_type.__swig_getmethods__.get(name,None)
if method: return method(self)
raise AttributeError(name)
def _swig_repr(self):
try: strthis = "proxy of " + self.this.__repr__()
except: strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
def uniset_init_params(*args):
return _pyUniSet.uniset_init_params(*args)
uniset_init_params = _pyUniSet.uniset_init_params
def uniset_init(*args):
return _pyUniSet.uniset_init(*args)
uniset_init = _pyUniSet.uniset_init
def getValue(*args):
return _pyUniSet.getValue(*args)
getValue = _pyUniSet.getValue
def setValue(*args):
return _pyUniSet.setValue(*args)
setValue = _pyUniSet.setValue
def getSensorID(*args):
return _pyUniSet.getSensorID(*args)
getSensorID = _pyUniSet.getSensorID
def getShortName(*args):
return _pyUniSet.getShortName(*args)
getShortName = _pyUniSet.getShortName
def getName(*args):
return _pyUniSet.getName(*args)
getName = _pyUniSet.getName
def getTextName(*args):
return _pyUniSet.getTextName(*args)
getTextName = _pyUniSet.getTextName
def getConfFileName():
return _pyUniSet.getConfFileName()
getConfFileName = _pyUniSet.getConfFileName
class Params:
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, Params, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, Params, name)
__repr__ = _swig_repr
max = _pyUniSet.Params_max
def __init__(self):
this = _pyUniSet.new_Params()
try: self.this.append(this)
except: self.this = this
def add(self, *args): return _pyUniSet.Params_add(self, *args)
__swig_setmethods__["argc"] = _pyUniSet.Params_argc_set
__swig_getmethods__["argc"] = _pyUniSet.Params_argc_get
__swig_setmethods__["argv"] = _pyUniSet.Params_argv_set
__swig_getmethods__["argv"] = _pyUniSet.Params_argv_get
__swig_getmethods__["inst"] = lambda x: _pyUniSet.Params_inst
__swig_destroy__ = _pyUniSet.delete_Params
__del__ = lambda self : None;
Params_swigregister = _pyUniSet.Params_swigregister
Params_swigregister(Params)
cvar = _pyUniSet.cvar
DefaultID = cvar.DefaultID
def Params_inst():
return _pyUniSet.Params_inst()
Params_inst = _pyUniSet.Params_inst
class UException(Exception):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, UException, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, UException, name)
__repr__ = _swig_repr
def __init__(self, *args):
this = _pyUniSet.new_UException(*args)
try: self.this.append(this)
except: self.this = this
__swig_destroy__ = _pyUniSet.delete_UException
__del__ = lambda self : None;
def getError(self): return _pyUniSet.UException_getError(self)
__swig_setmethods__["err"] = _pyUniSet.UException_err_set
__swig_getmethods__["err"] = _pyUniSet.UException_err_get
UException_swigregister = _pyUniSet.UException_swigregister
UException_swigregister(UException)
class UTimeOut(UException):
__swig_setmethods__ = {}
for _s in [UException]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, UTimeOut, name, value)
__swig_getmethods__ = {}
for _s in [UException]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, UTimeOut, name)
__repr__ = _swig_repr
def __init__(self, *args):
this = _pyUniSet.new_UTimeOut(*args)
try: self.this.append(this)
except: self.this = this
__swig_destroy__ = _pyUniSet.delete_UTimeOut
__del__ = lambda self : None;
UTimeOut_swigregister = _pyUniSet.UTimeOut_swigregister
UTimeOut_swigregister(UTimeOut)
class USysError(UException):
__swig_setmethods__ = {}
for _s in [UException]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, USysError, name, value)
__swig_getmethods__ = {}
for _s in [UException]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, USysError, name)
__repr__ = _swig_repr
def __init__(self, *args):
this = _pyUniSet.new_USysError(*args)
try: self.this.append(this)
except: self.this = this
__swig_destroy__ = _pyUniSet.delete_USysError
__del__ = lambda self : None;
USysError_swigregister = _pyUniSet.USysError_swigregister
USysError_swigregister(USysError)
# This file is compatible with both classic and new-style classes.
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