Commit d9275876 authored by Pavel Vainerman's avatar Pavel Vainerman

(python): добавил возможность в setValue() указать ID от имени

которого сохраняется датчик. По умолчанию UniSetTypes::AdminID. Перегенерировал cxx файлы (swig)
parent 229b2ff1
......@@ -14,7 +14,7 @@
Name: libuniset2
Version: 2.5
Release: alt3
Release: alt4
Summary: UniSet - library for building distributed industrial control systems
License: LGPL
......@@ -486,6 +486,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
# ..
%changelog
* Mon Aug 29 2016 Pavel Vainerman <pv@altlinux.ru> 2.5-alt4
- (python): add supplier ID for setValue function
* Fri Aug 26 2016 Pavel Vainerman <pv@altlinux.ru> 2.5-alt3
- update requires
......
......@@ -67,14 +67,14 @@ class UInterface():
raise UException("(getValue): Unknown interface %s"%self.utype)
def setValue(self, s_id, s_val):
def setValue(self, s_id, s_val, supplier = DefaultSupplerID ):
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])
self.i.setValue(s[0],s_val,s[1], supplier)
return
if self.itype == "modbus":
......
......@@ -92,7 +92,7 @@ long pyUInterface::getValue( long id )throw(UException)
}
}
//---------------------------------------------------------------------------
void pyUInterface::setValue( long id, long val )throw(UException)
void pyUInterface::setValue( long id, long val, long supplier )throw(UException)
{
auto conf = UniSetTypes::uniset_conf();
......@@ -109,7 +109,7 @@ void pyUInterface::setValue( long id, long val )throw(UException)
case UniversalIO::DO:
case UniversalIO::AI:
case UniversalIO::AO:
ui->setValue(id, val);
ui->setValue(id, val, supplier);
break;
default:
......
......@@ -28,7 +28,7 @@ namespace pyUInterface
//---------------------------------------------------------------------------
long getValue( long id )throw(UException);
void setValue( long id, long val )throw(UException);
void setValue( long id, long val, long supplier = UTypes::DefaultSupplerID )throw(UException);
long getSensorID( const std::string& name );
......@@ -37,7 +37,6 @@ namespace pyUInterface
std::string getTextName( long id );
std::string getConfFileName();
}
//---------------------------------------------------------------------------
#endif
......
......@@ -95,7 +95,7 @@ long UConnector::getValue( long id, long node )throw(UException)
}
}
//---------------------------------------------------------------------------
void UConnector::setValue( long id, long val, long node )throw(UException)
void UConnector::setValue( long id, long val, long node, long supplier )throw(UException)
{
if( !conf || !ui )
throw USysError();
......@@ -106,7 +106,7 @@ void UConnector::setValue( long id, long val, long node )throw(UException)
try
{
ui->setValue(id, val, node);
ui->setValue(id, val, node, supplier);
}
catch( UniSetTypes::Exception& ex )
{
......
......@@ -38,7 +38,7 @@ class UConnector
std::string getConfFileName();
long getValue( long id, long node )throw(UException);
void setValue( long id, long val, long node )throw(UException);
void setValue( long id, long val, long node, long supplier = UTypes::DefaultSupplerID )throw(UException);
long getSensorID( const std::string& name );
long getNodeID( const std::string& name );
......
......@@ -5,6 +5,9 @@
***********************************************************/
%module pyUniSet
%include "std_string.i"
%{
#include "PyUInterface.h"
%}
......
......@@ -22,6 +22,7 @@
namespace UTypes
{
const long DefaultID = UniSetTypes::DefaultObjectId;
const long DefaultSupplerID = UniSetTypes::AdminID;
struct Params
{
......
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 3.0.7
# Version 3.0.8
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
......@@ -69,7 +69,7 @@ def _swig_getattr(self, class_type, name):
def _swig_repr(self):
try:
strthis = "proxy of " + self.this.__repr__()
except:
except Exception:
strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
......@@ -85,7 +85,7 @@ class Params:
this = _pyUConnector.new_Params()
try:
self.this.append(this)
except:
except Exception:
self.this = this
def add(self, s):
......@@ -101,6 +101,7 @@ Params_swigregister = _pyUConnector.Params_swigregister
Params_swigregister(Params)
cvar = _pyUConnector.cvar
DefaultID = cvar.DefaultID
DefaultSupplerID = cvar.DefaultSupplerID
def Params_inst():
return _pyUConnector.Params_inst()
......@@ -117,7 +118,7 @@ class UConnector:
this = _pyUConnector.new_UConnector(*args)
try:
self.this.append(this)
except:
except Exception:
self.this = this
__swig_destroy__ = _pyUConnector.delete_UConnector
__del__ = lambda self: None
......@@ -131,8 +132,8 @@ class UConnector:
def getValue(self, id, node):
return _pyUConnector.UConnector_getValue(self, id, node)
def setValue(self, id, val, node):
return _pyUConnector.UConnector_setValue(self, id, val, node)
def setValue(self, *args):
return _pyUConnector.UConnector_setValue(self, *args)
def getSensorID(self, name):
return _pyUConnector.UConnector_getSensorID(self, name)
......
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 3.0.7
# Version 3.0.8
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
......@@ -69,7 +69,7 @@ def _swig_getattr(self, class_type, name):
def _swig_repr(self):
try:
strthis = "proxy of " + self.this.__repr__()
except:
except Exception:
strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
......@@ -84,7 +84,7 @@ class UException:
this = _pyUExceptions.new_UException(*args)
try:
self.this.append(this)
except:
except Exception:
self.this = this
__swig_destroy__ = _pyUExceptions.delete_UException
__del__ = lambda self: None
......@@ -111,7 +111,7 @@ class UTimeOut(UException):
this = _pyUExceptions.new_UTimeOut(*args)
try:
self.this.append(this)
except:
except Exception:
self.this = this
__swig_destroy__ = _pyUExceptions.delete_UTimeOut
__del__ = lambda self: None
......@@ -133,7 +133,7 @@ class USysError(UException):
this = _pyUExceptions.new_USysError(*args)
try:
self.this.append(this)
except:
except Exception:
self.this = this
__swig_destroy__ = _pyUExceptions.delete_USysError
__del__ = lambda self: None
......
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 3.0.7
# Version 3.0.8
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
......@@ -69,7 +69,7 @@ def _swig_getattr(self, class_type, name):
def _swig_repr(self):
try:
strthis = "proxy of " + self.this.__repr__()
except:
except Exception:
strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
......@@ -84,7 +84,7 @@ class UModbus:
this = _pyUModbus.new_UModbus()
try:
self.this.append(this)
except:
except Exception:
self.this = this
__swig_destroy__ = _pyUModbus.delete_UModbus
__del__ = lambda self: None
......@@ -142,7 +142,7 @@ class Params:
this = _pyUModbus.new_Params()
try:
self.this.append(this)
except:
except Exception:
self.this = this
def add(self, s):
......@@ -158,6 +158,7 @@ Params_swigregister = _pyUModbus.Params_swigregister
Params_swigregister(Params)
cvar = _pyUModbus.cvar
DefaultID = cvar.DefaultID
DefaultSupplerID = cvar.DefaultSupplerID
def Params_inst():
return _pyUModbus.Params_inst()
......@@ -174,7 +175,7 @@ class UException(Exception):
this = _pyUModbus.new_UException(*args)
try:
self.this.append(this)
except:
except Exception:
self.this = this
__swig_destroy__ = _pyUModbus.delete_UException
__del__ = lambda self: None
......@@ -201,7 +202,7 @@ class UTimeOut(UException):
this = _pyUModbus.new_UTimeOut(*args)
try:
self.this.append(this)
except:
except Exception:
self.this = this
__swig_destroy__ = _pyUModbus.delete_UTimeOut
__del__ = lambda self: None
......@@ -223,7 +224,7 @@ class USysError(UException):
this = _pyUModbus.new_USysError(*args)
try:
self.this.append(this)
except:
except Exception:
self.this = this
__swig_destroy__ = _pyUModbus.delete_USysError
__del__ = lambda self: None
......
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 3.0.7
# Version 3.0.8
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
......@@ -69,7 +69,7 @@ def _swig_getattr(self, class_type, name):
def _swig_repr(self):
try:
strthis = "proxy of " + self.this.__repr__()
except:
except Exception:
strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
......@@ -86,8 +86,8 @@ def getValue(id):
return _pyUniSet.getValue(id)
getValue = _pyUniSet.getValue
def setValue(id, val):
return _pyUniSet.setValue(id, val)
def setValue(*args):
return _pyUniSet.setValue(*args)
setValue = _pyUniSet.setValue
def getSensorID(name):
......@@ -121,7 +121,7 @@ class Params:
this = _pyUniSet.new_Params()
try:
self.this.append(this)
except:
except Exception:
self.this = this
def add(self, s):
......@@ -137,6 +137,7 @@ Params_swigregister = _pyUniSet.Params_swigregister
Params_swigregister(Params)
cvar = _pyUniSet.cvar
DefaultID = cvar.DefaultID
DefaultSupplerID = cvar.DefaultSupplerID
def Params_inst():
return _pyUniSet.Params_inst()
......@@ -153,7 +154,7 @@ class UException(Exception):
this = _pyUniSet.new_UException(*args)
try:
self.this.append(this)
except:
except Exception:
self.this = this
__swig_destroy__ = _pyUniSet.delete_UException
__del__ = lambda self: None
......@@ -180,7 +181,7 @@ class UTimeOut(UException):
this = _pyUniSet.new_UTimeOut(*args)
try:
self.this.append(this)
except:
except Exception:
self.this = this
__swig_destroy__ = _pyUniSet.delete_UTimeOut
__del__ = lambda self: None
......@@ -202,7 +203,7 @@ class USysError(UException):
this = _pyUniSet.new_USysError(*args)
try:
self.this.append(this)
except:
except Exception:
self.this = this
__swig_destroy__ = _pyUniSet.delete_USysError
__del__ = lambda self: None
......
......@@ -20,7 +20,7 @@ if __name__ == "__main__":
lst.add( sys.argv[i] )
try:
uniset_init_params( lst, str("test.xml") )
uniset_init_params( lst, "test.xml");
print "getShortName: id=%d name=%s" % (1, getShortName(1))
......
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