Commit d9275876 authored by Pavel Vainerman's avatar Pavel Vainerman

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

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