Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
4e998d57
Commit
4e998d57
authored
Sep 01, 2016
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(python): добавил функцию getObjectID() в UInterface
parent
e893e817
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
113 additions
and
2 deletions
+113
-2
libuniset2.spec
conf/libuniset2.spec
+4
-1
UInterface.py
python/lib/UInterface.py
+10
-0
PyUInterface.cc
python/lib/pyUniSet/PyUInterface.cc
+10
-0
PyUInterface.h
python/lib/pyUniSet/PyUInterface.h
+1
-0
UConnector.cc
python/lib/pyUniSet/UConnector.cc
+8
-0
UConnector.h
python/lib/pyUniSet/UConnector.h
+2
-1
UConnector_wrap.cxx
python/lib/pyUniSet/UConnector_wrap.cxx
+39
-0
UInterface_wrap.cxx
python/lib/pyUniSet/UInterface_wrap.cxx
+30
-0
pyUConnector.py
python/lib/pyUniSet/pyUConnector.py
+3
-0
pyUniSet.py
python/lib/pyUniSet/pyUniSet.py
+4
-0
testUC.py
python/tests/UConnector/testUC.py
+1
-0
testUI.py
python/tests/UInterface/testUI.py
+1
-0
No files found.
conf/libuniset2.spec
View file @
4e998d57
...
...
@@ -14,7 +14,7 @@
Name: libuniset2
Version: 2.5
Release: alt
5
Release: alt
6
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
* Thu Sep 01 2016 Pavel Vainerman <pv@altlinux.ru> 2.5-alt6
- (python): add getObjectID() for python UInterface
* Thu Sep 01 2016 Pavel Vainerman <pv@altlinux.ru> 2.5-alt5
- up build
...
...
python/lib/UInterface.py
View file @
4e998d57
...
...
@@ -130,3 +130,13 @@ class UInterface():
return
None
raise
UException
(
"(getSensorID): Unknown interface
%
s"
%
self
.
utype
)
def
getObjectID
(
self
,
o_name
):
if
self
.
itype
==
"uniset"
:
return
self
.
i
.
getObjectID
(
o_name
)
if
self
.
itype
==
"modbus"
:
return
None
raise
UException
(
"(getObjectID): Unknown interface
%
s"
%
self
.
utype
)
python/lib/pyUniSet/PyUInterface.cc
View file @
4e998d57
...
...
@@ -144,6 +144,16 @@ long pyUInterface::getSensorID(const string& name )
return
UniSetTypes
::
DefaultObjectId
;
}
//---------------------------------------------------------------------------
long
pyUInterface
::
getObjectID
(
const
string
&
name
)
{
auto
conf
=
UniSetTypes
::
uniset_conf
();
if
(
conf
)
return
conf
->
getObjectID
(
name
);
return
UniSetTypes
::
DefaultObjectId
;
}
//---------------------------------------------------------------------------
std
::
string
pyUInterface
::
getName
(
long
id
)
{
auto
conf
=
UniSetTypes
::
uniset_conf
();
...
...
python/lib/pyUniSet/PyUInterface.h
View file @
4e998d57
...
...
@@ -31,6 +31,7 @@ namespace pyUInterface
void
setValue
(
long
id
,
long
val
,
long
supplier
=
UTypes
::
DefaultSupplerID
)
throw
(
UException
);
long
getSensorID
(
const
std
::
string
&
name
);
long
getObjectID
(
const
std
::
string
&
name
);
std
::
string
getShortName
(
long
id
);
std
::
string
getName
(
long
id
);
...
...
python/lib/pyUniSet/UConnector.cc
View file @
4e998d57
...
...
@@ -158,3 +158,11 @@ string UConnector::getTextName( long id )
return
""
;
}
//---------------------------------------------------------------------------
long
UConnector
::
getObjectID
(
const
string
&
name
)
{
if
(
conf
)
return
conf
->
getObjectID
(
name
);
return
UTypes
::
DefaultID
;
}
//---------------------------------------------------------------------------
python/lib/pyUniSet/UConnector.h
View file @
4e998d57
...
...
@@ -41,7 +41,8 @@ class UConnector
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
);
long
getNodeID
(
const
std
::
string
&
name
);
long
getObjectID
(
const
std
::
string
&
name
);
std
::
string
getShortName
(
long
id
);
std
::
string
getName
(
long
id
);
...
...
python/lib/pyUniSet/UConnector_wrap.cxx
View file @
4e998d57
...
...
@@ -4236,6 +4236,44 @@ fail:
}
SWIGINTERN
PyObject
*
_wrap_UConnector_getObjectID
(
PyObject
*
SWIGUNUSEDPARM
(
self
),
PyObject
*
args
)
{
PyObject
*
resultobj
=
0
;
UConnector
*
arg1
=
(
UConnector
*
)
0
;
std
::
string
*
arg2
=
0
;
void
*
argp1
=
0
;
int
res1
=
0
;
int
res2
=
SWIG_OLDOBJ
;
PyObject
*
obj0
=
0
;
PyObject
*
obj1
=
0
;
long
result
;
if
(
!
PyArg_ParseTuple
(
args
,(
char
*
)
"OO:UConnector_getObjectID"
,
&
obj0
,
&
obj1
))
SWIG_fail
;
res1
=
SWIG_ConvertPtr
(
obj0
,
&
argp1
,
SWIGTYPE_p_UConnector
,
0
|
0
);
if
(
!
SWIG_IsOK
(
res1
))
{
SWIG_exception_fail
(
SWIG_ArgError
(
res1
),
"in method '"
"UConnector_getObjectID"
"', argument "
"1"" of type '"
"UConnector *""'"
);
}
arg1
=
reinterpret_cast
<
UConnector
*
>
(
argp1
);
{
std
::
string
*
ptr
=
(
std
::
string
*
)
0
;
res2
=
SWIG_AsPtr_std_string
(
obj1
,
&
ptr
);
if
(
!
SWIG_IsOK
(
res2
))
{
SWIG_exception_fail
(
SWIG_ArgError
(
res2
),
"in method '"
"UConnector_getObjectID"
"', argument "
"2"" of type '"
"std::string const &""'"
);
}
if
(
!
ptr
)
{
SWIG_exception_fail
(
SWIG_ValueError
,
"invalid null reference "
"in method '"
"UConnector_getObjectID"
"', argument "
"2"" of type '"
"std::string const &""'"
);
}
arg2
=
ptr
;
}
result
=
(
long
)(
arg1
)
->
getObjectID
((
std
::
string
const
&
)
*
arg2
);
resultobj
=
SWIG_From_long
(
static_cast
<
long
>
(
result
));
if
(
SWIG_IsNewObj
(
res2
))
delete
arg2
;
return
resultobj
;
fail
:
if
(
SWIG_IsNewObj
(
res2
))
delete
arg2
;
return
NULL
;
}
SWIGINTERN
PyObject
*
_wrap_UConnector_getShortName
(
PyObject
*
SWIGUNUSEDPARM
(
self
),
PyObject
*
args
)
{
PyObject
*
resultobj
=
0
;
UConnector
*
arg1
=
(
UConnector
*
)
0
;
...
...
@@ -4355,6 +4393,7 @@ static PyMethodDef SwigMethods[] = {
{
(
char
*
)
"UConnector_setValue"
,
_wrap_UConnector_setValue
,
METH_VARARGS
,
NULL
},
{
(
char
*
)
"UConnector_getSensorID"
,
_wrap_UConnector_getSensorID
,
METH_VARARGS
,
NULL
},
{
(
char
*
)
"UConnector_getNodeID"
,
_wrap_UConnector_getNodeID
,
METH_VARARGS
,
NULL
},
{
(
char
*
)
"UConnector_getObjectID"
,
_wrap_UConnector_getObjectID
,
METH_VARARGS
,
NULL
},
{
(
char
*
)
"UConnector_getShortName"
,
_wrap_UConnector_getShortName
,
METH_VARARGS
,
NULL
},
{
(
char
*
)
"UConnector_getName"
,
_wrap_UConnector_getName
,
METH_VARARGS
,
NULL
},
{
(
char
*
)
"UConnector_getTextName"
,
_wrap_UConnector_getTextName
,
METH_VARARGS
,
NULL
},
...
...
python/lib/pyUniSet/UInterface_wrap.cxx
View file @
4e998d57
...
...
@@ -3766,6 +3766,35 @@ fail:
}
SWIGINTERN
PyObject
*
_wrap_getObjectID
(
PyObject
*
SWIGUNUSEDPARM
(
self
),
PyObject
*
args
)
{
PyObject
*
resultobj
=
0
;
std
::
string
*
arg1
=
0
;
int
res1
=
SWIG_OLDOBJ
;
PyObject
*
obj0
=
0
;
long
result
;
if
(
!
PyArg_ParseTuple
(
args
,(
char
*
)
"O:getObjectID"
,
&
obj0
))
SWIG_fail
;
{
std
::
string
*
ptr
=
(
std
::
string
*
)
0
;
res1
=
SWIG_AsPtr_std_string
(
obj0
,
&
ptr
);
if
(
!
SWIG_IsOK
(
res1
))
{
SWIG_exception_fail
(
SWIG_ArgError
(
res1
),
"in method '"
"getObjectID"
"', argument "
"1"" of type '"
"std::string const &""'"
);
}
if
(
!
ptr
)
{
SWIG_exception_fail
(
SWIG_ValueError
,
"invalid null reference "
"in method '"
"getObjectID"
"', argument "
"1"" of type '"
"std::string const &""'"
);
}
arg1
=
ptr
;
}
result
=
(
long
)
pyUInterface
::
getObjectID
((
std
::
string
const
&
)
*
arg1
);
resultobj
=
SWIG_From_long
(
static_cast
<
long
>
(
result
));
if
(
SWIG_IsNewObj
(
res1
))
delete
arg1
;
return
resultobj
;
fail
:
if
(
SWIG_IsNewObj
(
res1
))
delete
arg1
;
return
NULL
;
}
SWIGINTERN
PyObject
*
_wrap_getShortName
(
PyObject
*
SWIGUNUSEDPARM
(
self
),
PyObject
*
args
)
{
PyObject
*
resultobj
=
0
;
long
arg1
;
...
...
@@ -4503,6 +4532,7 @@ static PyMethodDef SwigMethods[] = {
{
(
char
*
)
"getValue"
,
_wrap_getValue
,
METH_VARARGS
,
NULL
},
{
(
char
*
)
"setValue"
,
_wrap_setValue
,
METH_VARARGS
,
NULL
},
{
(
char
*
)
"getSensorID"
,
_wrap_getSensorID
,
METH_VARARGS
,
NULL
},
{
(
char
*
)
"getObjectID"
,
_wrap_getObjectID
,
METH_VARARGS
,
NULL
},
{
(
char
*
)
"getShortName"
,
_wrap_getShortName
,
METH_VARARGS
,
NULL
},
{
(
char
*
)
"getName"
,
_wrap_getName
,
METH_VARARGS
,
NULL
},
{
(
char
*
)
"getTextName"
,
_wrap_getTextName
,
METH_VARARGS
,
NULL
},
...
...
python/lib/pyUniSet/pyUConnector.py
View file @
4e998d57
...
...
@@ -141,6 +141,9 @@ class UConnector:
def
getNodeID
(
self
,
name
):
return
_pyUConnector
.
UConnector_getNodeID
(
self
,
name
)
def
getObjectID
(
self
,
name
):
return
_pyUConnector
.
UConnector_getObjectID
(
self
,
name
)
def
getShortName
(
self
,
id
):
return
_pyUConnector
.
UConnector_getShortName
(
self
,
id
)
...
...
python/lib/pyUniSet/pyUniSet.py
View file @
4e998d57
...
...
@@ -94,6 +94,10 @@ def getSensorID(name):
return
_pyUniSet
.
getSensorID
(
name
)
getSensorID
=
_pyUniSet
.
getSensorID
def
getObjectID
(
name
):
return
_pyUniSet
.
getObjectID
(
name
)
getObjectID
=
_pyUniSet
.
getObjectID
def
getShortName
(
id
):
return
_pyUniSet
.
getShortName
(
id
)
getShortName
=
_pyUniSet
.
getShortName
...
...
python/tests/UConnector/testUC.py
View file @
4e998d57
...
...
@@ -28,6 +28,7 @@ if __name__ == "__main__":
# print "(0)UIType: %s" % uc1.getUIType()
print
"(1)getShortName: id=
%
d name=
%
s"
%
(
1
,
uc1
.
getShortName
(
1
))
print
"(2)getObjectID('TestProc'):
%
d"
%
uc1
.
getObjectID
(
"TestProc"
)
# print " getName: id=%d name=%s" % (1, uc1.getName(101))
# print " getTextName: id=%d name=%s" % (1, uc1.getTextName(101))
...
...
python/tests/UInterface/testUI.py
View file @
4e998d57
...
...
@@ -30,6 +30,7 @@ if __name__ == "__main__":
print
"getShortName: id=
%
d name=
%
s"
%
(
2
,
getShortName
(
2
))
print
" getName: id=
%
d name=
%
s"
%
(
2
,
getName
(
2
))
print
" getTextName: id=
%
d name=
%
s"
%
(
2
,
getTextName
(
2
))
print
" getObjectID: id=
%
d name=
%
s"
%
(
getObjectID
(
"TestProc"
),
"TestProc"
)
try
:
print
"getValue:
%
d=
%
d"
%
(
1
,
getValue
(
1
)
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment