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
e921bab4
Commit
e921bab4
authored
Nov 24, 2016
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(UInterface): добавил функцию getObjectInfo(params) и в python интерфейс.
parent
3f788adc
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
340 additions
and
87 deletions
+340
-87
admin.cc
Utilities/Admin/admin.cc
+3
-39
UInterface.h
include/UInterface.h
+3
-0
testUC.py
python/examples/testUC.py
+2
-0
UInterface.py
python/lib/UInterface.py
+22
-16
UConnector.cc
python/lib/pyUniSet/UConnector.cc
+22
-0
UConnector.h
python/lib/pyUniSet/UConnector.h
+2
-0
UConnector_wrap.cxx
python/lib/pyUniSet/UConnector_wrap.cxx
+182
-0
pyUConnector.py
python/lib/pyUniSet/pyUConnector.py
+3
-0
testUC.py
python/tests/UConnector/testUC.py
+3
-11
UInterface.cc
src/Interfaces/UInterface.cc
+98
-21
No files found.
Utilities/Admin/admin.cc
View file @
e921bab4
...
...
@@ -14,6 +14,7 @@
#include "UniSetTypes.h"
#include "UniSetManager.h"
#include "MessageType.h"
#include "UInterface.h"
#include "Configuration.h"
#include "ObjectIndex_XML.h"
#include "Debug.h"
...
...
@@ -1008,51 +1009,14 @@ int oinfo(const string& args, UInterface& ui, const string& userparam )
auto
conf
=
uniset_conf
();
auto
sl
=
uniset
::
getObjectsList
(
args
,
conf
);
for
(
auto
&&
it
:
sl
)
for
(
auto
&&
it
:
sl
)
{
if
(
it
.
node
==
DefaultObjectId
)
it
.
node
=
conf
->
getLocalNode
();
try
{
uniset
::
ObjectVar
o
=
ui
.
resolve
(
it
.
id
,
it
.
node
);
UniSetObject_i_var
obj
=
UniSetObject_i
::
_narrow
(
o
);
if
(
CORBA
::
is_nil
(
obj
))
{
if
(
!
quiet
)
cout
<<
"(oinfo): объект '"
<<
it
.
id
<<
"' недоступен"
<<
endl
;
}
else
{
SimpleInfo_var
inf
=
obj
->
getInfo
(
userparam
.
c_str
());
cout
<<
inf
->
info
<<
endl
;
}
}
catch
(
const
uniset
::
Exception
&
ex
)
{
if
(
!
quiet
)
cout
<<
"ID='"
<<
it
.
id
<<
"' ERROR: "
<<
ex
<<
endl
;
}
catch
(
const
CORBA
::
SystemException
&
ex
)
{
if
(
!
quiet
)
cerr
<<
"CORBA::SystemException: "
<<
ex
.
NP_minorString
()
<<
endl
;
}
catch
(
const
CORBA
::
Exception
&
)
{
if
(
!
quiet
)
cerr
<<
"CORBA::Exception."
<<
endl
;
}
catch
(
const
omniORB
::
fatalException
&
fe
)
{
if
(
!
quiet
)
{
cerr
<<
"omniORB::fatalException:"
<<
endl
;
cerr
<<
" file: "
<<
fe
.
file
()
<<
endl
;
cerr
<<
" line: "
<<
fe
.
line
()
<<
endl
;
cerr
<<
" mesg: "
<<
fe
.
errmsg
()
<<
endl
;
}
cout
<<
ui
.
getInfo
(
it
.
id
,
userparam
,
it
.
node
)
<<
endl
;
}
catch
(
const
std
::
exception
&
ex
)
{
...
...
include/UInterface.h
View file @
e921bab4
...
...
@@ -141,6 +141,9 @@ class UInterface
//! Время последнего изменения датчика
IOController_i
::
ShortIOInfo
getChangedTime
(
const
uniset
::
ObjectId
id
,
const
uniset
::
ObjectId
node
)
const
;
//! Информация об объекте
std
::
string
getInfo
(
const
uniset
::
ObjectId
id
,
const
std
::
string
&
params
,
const
uniset
::
ObjectId
node
)
const
;
//! Получить список датчиков
IOController_i
::
ShortMapSeq
*
getSensors
(
const
uniset
::
ObjectId
id
,
const
uniset
::
ObjectId
node
=
uniset
::
uniset_conf
()
->
getLocalNode
()
);
...
...
python/examples/testUC.py
View file @
e921bab4
...
...
@@ -27,6 +27,8 @@ if __name__ == "__main__":
# 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))
...
...
python/lib/UInterface.py
View file @
e921bab4
...
...
@@ -38,7 +38,7 @@ class UInterface():
def
getIDinfo
(
self
,
s_id
):
if
self
.
itype
==
"uniset"
:
return
to_sid
(
s_id
,
self
.
i
)
return
to_sid
(
s_id
,
self
.
i
)
if
self
.
itype
==
"modbus"
:
mbaddr
,
mbreg
,
mbfunc
,
nbit
,
vtype
=
get_mbquery_param
(
s_id
,
"0x04"
)
...
...
@@ -53,7 +53,7 @@ class UInterface():
if
self
.
itype
==
"uniset"
:
s
=
to_sid
(
s_id
,
self
.
i
)
if
s
[
0
]
==
DefaultID
:
return
[
False
,
"Unknown ID for '
%
s'"
%
str
(
s_id
)]
return
[
False
,
"Unknown ID for '
%
s'"
%
str
(
s_id
)]
return
[
True
,
""
]
...
...
@@ -73,7 +73,7 @@ class UInterface():
return
[
True
,
""
]
except
UException
,
e
:
return
[
False
,
"
%
s"
%
e
.
getError
()]
return
[
False
,
"
%
s"
%
e
.
getError
()]
return
[
False
,
"Unknown interface
%
s"
%
self
.
itype
]
...
...
@@ -81,21 +81,21 @@ class UInterface():
try
:
if
self
.
itype
==
"uniset"
:
s
=
to_sid
(
s_id
,
self
.
i
)
s
=
to_sid
(
s_id
,
self
.
i
)
if
self
.
ignore_nodes
==
True
:
s
[
1
]
=
DefaultID
return
self
.
i
.
getValue
(
s
[
0
],
s
[
1
]
)
return
self
.
i
.
getValue
(
s
[
0
],
s
[
1
]
)
if
self
.
itype
==
"modbus"
:
mbaddr
,
mbreg
,
mbfunc
,
nbit
,
vtype
=
get_mbquery_param
(
s_id
,
"0x04"
)
mbaddr
,
mbreg
,
mbfunc
,
nbit
,
vtype
=
get_mbquery_param
(
s_id
,
"0x04"
)
if
mbaddr
==
None
or
mbreg
==
None
or
mbfunc
==
None
:
raise
UValidateError
(
"(modbus:getValue): parse id='
%
s' failed. Must be 'mbreg@mbaddr:mbfunc:nbit:vtype'"
%
s_id
)
if
self
.
i
.
isWriteFunction
(
mbfunc
)
==
True
:
raise
UValidateError
(
"(modbus:getValue): for id='
%
s' mbfunc=
%
d is WriteFunction. Must be 'read'."
%
(
s_id
,
mbfunc
)
)
raise
UValidateError
(
"(modbus:getValue): for id='
%
s' mbfunc=
%
d is WriteFunction. Must be 'read'."
%
(
s_id
,
mbfunc
)
)
return
self
.
i
.
mbread
(
mbaddr
,
mbreg
,
mbfunc
,
vtype
,
nbit
)
return
self
.
i
.
mbread
(
mbaddr
,
mbreg
,
mbfunc
,
vtype
,
nbit
)
except
UException
,
e
:
raise
e
...
...
@@ -109,20 +109,20 @@ class UInterface():
if
self
.
ignore_nodes
==
True
:
s
[
1
]
=
DefaultID
self
.
i
.
setValue
(
s
[
0
],
s_val
,
s
[
1
],
supplier
)
self
.
i
.
setValue
(
s
[
0
],
s_val
,
s
[
1
],
supplier
)
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"
)
mbaddr
,
mbreg
,
mbfunc
,
nbit
,
vtype
=
get_mbquery_param
(
s_id
,
"0x06"
)
if
mbaddr
==
None
or
mbreg
==
None
or
mbfunc
==
None
:
raise
UValidateError
(
"(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
UValidateError
(
"(modbus:setValue): for id='
%
s' mbfunc=
%
d is NOT WriteFunction."
%
(
s_id
,
mbfunc
)
)
raise
UValidateError
(
"(modbus:setValue): for id='
%
s' mbfunc=
%
d is NOT WriteFunction."
%
(
s_id
,
mbfunc
)
)
self
.
i
.
mbwrite
(
mbaddr
,
mbreg
,
to_int
(
s_val
),
mbfunc
)
self
.
i
.
mbwrite
(
mbaddr
,
mbreg
,
to_int
(
s_val
),
mbfunc
)
return
except
UException
,
e
:
...
...
@@ -139,7 +139,7 @@ class UInterface():
raise
UValidateError
(
"(setValue): Unknown interface
%
s"
%
self
.
itype
)
def
getShortName
(
self
,
s_node
):
def
getShortName
(
self
,
s_node
):
if
self
.
itype
==
"uniset"
:
return
self
.
i
.
getShortName
(
s_node
)
...
...
@@ -148,7 +148,7 @@ class UInterface():
raise
UValidateError
(
"(getShortName): Unknown interface
%
s"
%
self
.
itype
)
def
getNodeID
(
self
,
s_node
):
def
getNodeID
(
self
,
s_node
):
if
self
.
itype
==
"uniset"
:
return
self
.
i
.
getNodeID
(
s_node
)
...
...
@@ -157,7 +157,7 @@ class UInterface():
raise
UValidateError
(
"(getNodeID): Unknown interface
%
s"
%
self
.
itype
)
def
getSensorID
(
self
,
s_name
):
def
getSensorID
(
self
,
s_name
):
if
self
.
itype
==
"uniset"
:
return
self
.
i
.
getSensorID
(
s_name
)
...
...
@@ -166,7 +166,7 @@ class UInterface():
raise
UValidateError
(
"(getSensorID): Unknown interface
%
s"
%
self
.
itype
)
def
getObjectID
(
self
,
o_name
):
def
getObjectID
(
self
,
o_name
):
if
self
.
itype
==
"uniset"
:
return
self
.
i
.
getObjectID
(
o_name
)
...
...
@@ -175,3 +175,9 @@ class UInterface():
raise
UValidateError
(
"(getObjectID): Unknown interface
%
s"
%
self
.
itype
)
def
getObjectInfo
(
self
,
id
,
params
=
""
,
node
=
DefaultID
):
if
self
.
itype
!=
"uniset"
:
raise
UException
(
"(getObjectInfo): the interface does not support this feature..'getObjectInfo'"
)
return
self
.
i
.
getObjectInfo
(
id
,
params
,
node
)
python/lib/pyUniSet/UConnector.cc
View file @
e921bab4
...
...
@@ -154,6 +154,28 @@ string UConnector::getTextName( long id )
return
""
;
}
//---------------------------------------------------------------------------
string
UConnector
::
getObjectInfo
(
long
id
,
const
std
::
string
&
params
,
long
node
)
throw
(
UException
)
{
if
(
!
conf
||
!
ui
)
throw
USysError
();
if
(
id
==
UTypes
::
DefaultID
)
throw
UException
(
"(getObjectInfo): Unknown ID.."
);
if
(
node
==
UTypes
::
DefaultID
)
node
=
conf
->
getLocalNode
();
try
{
return
ui
->
getInfo
(
id
,
params
,
node
);
}
catch
(
std
::
exception
&
ex
)
{
throw
UException
(
"(getObjectInfo): error: "
+
std
::
string
(
ex
.
what
())
);
}
}
//---------------------------------------------------------------------------
void
UConnector
::
activate_objects
()
throw
(
UException
)
{
try
...
...
python/lib/pyUniSet/UConnector.h
View file @
e921bab4
...
...
@@ -49,6 +49,8 @@ class UConnector
std
::
string
getName
(
long
id
);
std
::
string
getTextName
(
long
id
);
std
::
string
getObjectInfo
(
long
id
,
const
std
::
string
&
params
,
long
node
=
UTypes
::
DefaultID
)
throw
(
UException
);
void
activate_objects
()
throw
(
UException
);
private
:
...
...
python/lib/pyUniSet/UConnector_wrap.cxx
View file @
e921bab4
...
...
@@ -4400,6 +4400,187 @@ fail:
}
SWIGINTERN
PyObject
*
_wrap_UConnector_getObjectInfo__SWIG_0
(
PyObject
*
SWIGUNUSEDPARM
(
self
),
PyObject
*
args
)
{
PyObject
*
resultobj
=
0
;
UConnector
*
arg1
=
(
UConnector
*
)
0
;
long
arg2
;
std
::
string
*
arg3
=
0
;
long
arg4
;
void
*
argp1
=
0
;
int
res1
=
0
;
long
val2
;
int
ecode2
=
0
;
int
res3
=
SWIG_OLDOBJ
;
long
val4
;
int
ecode4
=
0
;
PyObject
*
obj0
=
0
;
PyObject
*
obj1
=
0
;
PyObject
*
obj2
=
0
;
PyObject
*
obj3
=
0
;
std
::
string
result
;
if
(
!
PyArg_ParseTuple
(
args
,(
char
*
)
"OOOO:UConnector_getObjectInfo"
,
&
obj0
,
&
obj1
,
&
obj2
,
&
obj3
))
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_getObjectInfo"
"', argument "
"1"" of type '"
"UConnector *""'"
);
}
arg1
=
reinterpret_cast
<
UConnector
*
>
(
argp1
);
ecode2
=
SWIG_AsVal_long
(
obj1
,
&
val2
);
if
(
!
SWIG_IsOK
(
ecode2
))
{
SWIG_exception_fail
(
SWIG_ArgError
(
ecode2
),
"in method '"
"UConnector_getObjectInfo"
"', argument "
"2"" of type '"
"long""'"
);
}
arg2
=
static_cast
<
long
>
(
val2
);
{
std
::
string
*
ptr
=
(
std
::
string
*
)
0
;
res3
=
SWIG_AsPtr_std_string
(
obj2
,
&
ptr
);
if
(
!
SWIG_IsOK
(
res3
))
{
SWIG_exception_fail
(
SWIG_ArgError
(
res3
),
"in method '"
"UConnector_getObjectInfo"
"', argument "
"3"" of type '"
"std::string const &""'"
);
}
if
(
!
ptr
)
{
SWIG_exception_fail
(
SWIG_ValueError
,
"invalid null reference "
"in method '"
"UConnector_getObjectInfo"
"', argument "
"3"" of type '"
"std::string const &""'"
);
}
arg3
=
ptr
;
}
ecode4
=
SWIG_AsVal_long
(
obj3
,
&
val4
);
if
(
!
SWIG_IsOK
(
ecode4
))
{
SWIG_exception_fail
(
SWIG_ArgError
(
ecode4
),
"in method '"
"UConnector_getObjectInfo"
"', argument "
"4"" of type '"
"long""'"
);
}
arg4
=
static_cast
<
long
>
(
val4
);
try
{
result
=
(
arg1
)
->
getObjectInfo
(
arg2
,(
std
::
string
const
&
)
*
arg3
,
arg4
);
}
catch
(
UException
&
_e
)
{
SWIG_Python_Raise
(
SWIG_NewPointerObj
((
new
UException
(
static_cast
<
const
UException
&
>
(
_e
))),
SWIGTYPE_p_UException
,
SWIG_POINTER_OWN
),
"UException"
,
SWIGTYPE_p_UException
);
SWIG_fail
;
}
resultobj
=
SWIG_From_std_string
(
static_cast
<
std
::
string
>
(
result
));
if
(
SWIG_IsNewObj
(
res3
))
delete
arg3
;
return
resultobj
;
fail
:
if
(
SWIG_IsNewObj
(
res3
))
delete
arg3
;
return
NULL
;
}
SWIGINTERN
PyObject
*
_wrap_UConnector_getObjectInfo__SWIG_1
(
PyObject
*
SWIGUNUSEDPARM
(
self
),
PyObject
*
args
)
{
PyObject
*
resultobj
=
0
;
UConnector
*
arg1
=
(
UConnector
*
)
0
;
long
arg2
;
std
::
string
*
arg3
=
0
;
void
*
argp1
=
0
;
int
res1
=
0
;
long
val2
;
int
ecode2
=
0
;
int
res3
=
SWIG_OLDOBJ
;
PyObject
*
obj0
=
0
;
PyObject
*
obj1
=
0
;
PyObject
*
obj2
=
0
;
std
::
string
result
;
if
(
!
PyArg_ParseTuple
(
args
,(
char
*
)
"OOO:UConnector_getObjectInfo"
,
&
obj0
,
&
obj1
,
&
obj2
))
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_getObjectInfo"
"', argument "
"1"" of type '"
"UConnector *""'"
);
}
arg1
=
reinterpret_cast
<
UConnector
*
>
(
argp1
);
ecode2
=
SWIG_AsVal_long
(
obj1
,
&
val2
);
if
(
!
SWIG_IsOK
(
ecode2
))
{
SWIG_exception_fail
(
SWIG_ArgError
(
ecode2
),
"in method '"
"UConnector_getObjectInfo"
"', argument "
"2"" of type '"
"long""'"
);
}
arg2
=
static_cast
<
long
>
(
val2
);
{
std
::
string
*
ptr
=
(
std
::
string
*
)
0
;
res3
=
SWIG_AsPtr_std_string
(
obj2
,
&
ptr
);
if
(
!
SWIG_IsOK
(
res3
))
{
SWIG_exception_fail
(
SWIG_ArgError
(
res3
),
"in method '"
"UConnector_getObjectInfo"
"', argument "
"3"" of type '"
"std::string const &""'"
);
}
if
(
!
ptr
)
{
SWIG_exception_fail
(
SWIG_ValueError
,
"invalid null reference "
"in method '"
"UConnector_getObjectInfo"
"', argument "
"3"" of type '"
"std::string const &""'"
);
}
arg3
=
ptr
;
}
try
{
result
=
(
arg1
)
->
getObjectInfo
(
arg2
,(
std
::
string
const
&
)
*
arg3
);
}
catch
(
UException
&
_e
)
{
SWIG_Python_Raise
(
SWIG_NewPointerObj
((
new
UException
(
static_cast
<
const
UException
&
>
(
_e
))),
SWIGTYPE_p_UException
,
SWIG_POINTER_OWN
),
"UException"
,
SWIGTYPE_p_UException
);
SWIG_fail
;
}
resultobj
=
SWIG_From_std_string
(
static_cast
<
std
::
string
>
(
result
));
if
(
SWIG_IsNewObj
(
res3
))
delete
arg3
;
return
resultobj
;
fail
:
if
(
SWIG_IsNewObj
(
res3
))
delete
arg3
;
return
NULL
;
}
SWIGINTERN
PyObject
*
_wrap_UConnector_getObjectInfo
(
PyObject
*
self
,
PyObject
*
args
)
{
Py_ssize_t
argc
;
PyObject
*
argv
[
5
]
=
{
0
};
Py_ssize_t
ii
;
if
(
!
PyTuple_Check
(
args
))
SWIG_fail
;
argc
=
args
?
PyObject_Length
(
args
)
:
0
;
for
(
ii
=
0
;
(
ii
<
4
)
&&
(
ii
<
argc
);
ii
++
)
{
argv
[
ii
]
=
PyTuple_GET_ITEM
(
args
,
ii
);
}
if
(
argc
==
3
)
{
int
_v
;
void
*
vptr
=
0
;
int
res
=
SWIG_ConvertPtr
(
argv
[
0
],
&
vptr
,
SWIGTYPE_p_UConnector
,
0
);
_v
=
SWIG_CheckState
(
res
);
if
(
_v
)
{
{
int
res
=
SWIG_AsVal_long
(
argv
[
1
],
NULL
);
_v
=
SWIG_CheckState
(
res
);
}
if
(
_v
)
{
int
res
=
SWIG_AsPtr_std_string
(
argv
[
2
],
(
std
::
string
**
)(
0
));
_v
=
SWIG_CheckState
(
res
);
if
(
_v
)
{
return
_wrap_UConnector_getObjectInfo__SWIG_1
(
self
,
args
);
}
}
}
}
if
(
argc
==
4
)
{
int
_v
;
void
*
vptr
=
0
;
int
res
=
SWIG_ConvertPtr
(
argv
[
0
],
&
vptr
,
SWIGTYPE_p_UConnector
,
0
);
_v
=
SWIG_CheckState
(
res
);
if
(
_v
)
{
{
int
res
=
SWIG_AsVal_long
(
argv
[
1
],
NULL
);
_v
=
SWIG_CheckState
(
res
);
}
if
(
_v
)
{
int
res
=
SWIG_AsPtr_std_string
(
argv
[
2
],
(
std
::
string
**
)(
0
));
_v
=
SWIG_CheckState
(
res
);
if
(
_v
)
{
{
int
res
=
SWIG_AsVal_long
(
argv
[
3
],
NULL
);
_v
=
SWIG_CheckState
(
res
);
}
if
(
_v
)
{
return
_wrap_UConnector_getObjectInfo__SWIG_0
(
self
,
args
);
}
}
}
}
}
fail
:
SWIG_SetErrorMsg
(
PyExc_NotImplementedError
,
"Wrong number or type of arguments for overloaded function 'UConnector_getObjectInfo'.
\n
"
" Possible C/C++ prototypes are:
\n
"
" UConnector::getObjectInfo(long,std::string const &,long)
\n
"
" UConnector::getObjectInfo(long,std::string const &)
\n
"
);
return
0
;
}
SWIGINTERN
PyObject
*
_wrap_UConnector_activate_objects
(
PyObject
*
SWIGUNUSEDPARM
(
self
),
PyObject
*
args
)
{
PyObject
*
resultobj
=
0
;
UConnector
*
arg1
=
(
UConnector
*
)
0
;
...
...
@@ -4458,6 +4639,7 @@ static PyMethodDef SwigMethods[] = {
{
(
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
},
{
(
char
*
)
"UConnector_getObjectInfo"
,
_wrap_UConnector_getObjectInfo
,
METH_VARARGS
,
NULL
},
{
(
char
*
)
"UConnector_activate_objects"
,
_wrap_UConnector_activate_objects
,
METH_VARARGS
,
NULL
},
{
(
char
*
)
"UConnector_swigregister"
,
UConnector_swigregister
,
METH_VARARGS
,
NULL
},
{
NULL
,
NULL
,
0
,
NULL
}
...
...
python/lib/pyUniSet/pyUConnector.py
View file @
e921bab4
...
...
@@ -156,6 +156,9 @@ class UConnector:
def
getTextName
(
self
,
id
):
return
_pyUConnector
.
UConnector_getTextName
(
self
,
id
)
def
getObjectInfo
(
self
,
*
args
):
return
_pyUConnector
.
UConnector_getObjectInfo
(
self
,
*
args
)
def
activate_objects
(
self
):
return
_pyUConnector
.
UConnector_activate_objects
(
self
)
UConnector_swigregister
=
_pyUConnector
.
UConnector_swigregister
...
...
python/tests/UConnector/testUC.py
View file @
e921bab4
...
...
@@ -17,15 +17,6 @@ def myfunc( act ):
if
__name__
==
"__main__"
:
act
=
dict
()
act
[
'type'
]
=
'type'
myfunc
(
act
)
print
act
exit
(
0
)
lst
=
Params_inst
()
lst2
=
Params_inst
()
...
...
@@ -53,9 +44,10 @@ if __name__ == "__main__":
uc1
=
UConnector
(
lst
,
"test.xml"
)
uc2
=
UConnector
(
lst2
,
"test.xml"
)
obj1
=
UProxyObject
(
"TestProc"
)
obj2
=
UProxyObject
(
"TestProc1"
)
#
obj1 = UProxyObject("TestProc")
#
obj2 = UProxyObject("TestProc1")
print
"Info:
%
s"
%
uc1
.
getObjectInfo
(
uc1
.
getObjectID
(
"TestProc1"
),
""
)
# print "(0)UIType: %s" % uc1.getUIType()
print
"(1)getShortName: id=
%
d name=
%
s"
%
(
1
,
uc1
.
getShortName
(
1
))
...
...
src/Interfaces/UInterface.cc
View file @
e921bab4
...
...
@@ -137,7 +137,7 @@ throw(UI_THROW_EXCEPTIONS)
}
catch
(
const
uniset
::
NameNotFound
&
)
{}
for
(
unsigned
in
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
for
(
size_
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
{
try
{
...
...
@@ -224,7 +224,7 @@ void UInterface::setUndefinedState( const IOController_i::SensorInfo& si, bool u
}
catch
(
const
uniset
::
NameNotFound
&
)
{}
for
(
unsigned
in
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
for
(
size_
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
{
try
{
...
...
@@ -315,7 +315,7 @@ throw(UI_THROW_EXCEPTIONS)
}
catch
(
const
uniset
::
NameNotFound
&
)
{}
for
(
unsigned
in
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
for
(
size_
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
{
try
{
...
...
@@ -407,7 +407,7 @@ void UInterface::fastSetValue( const IOController_i::SensorInfo& si, long value,
}
catch
(
const
uniset
::
NameNotFound
&
)
{}
for
(
unsigned
in
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
for
(
size_
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
{
try
{
...
...
@@ -506,7 +506,7 @@ void UInterface::askRemoteSensor( const uniset::ObjectId id, UniversalIO::UIOCom
}
catch
(
const
uniset
::
NameNotFound
&
)
{}
for
(
unsigned
in
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
for
(
size_
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
{
try
{
...
...
@@ -603,7 +603,7 @@ throw(UI_THROW_EXCEPTIONS)
}
catch
(
const
uniset
::
NameNotFound
&
)
{}
for
(
unsigned
in
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
for
(
size_
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
{
try
{
...
...
@@ -694,7 +694,7 @@ throw(UI_THROW_EXCEPTIONS)
}
catch
(
const
uniset
::
NameNotFound
&
)
{}
for
(
unsigned
in
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
for
(
size_
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
{
try
{
...
...
@@ -901,7 +901,7 @@ throw(uniset::ResolveNameError, uniset::TimeOut )
CosNaming
::
Name_var
oname
=
omniURI
::
stringToName
(
oind
->
getNameById
(
rid
).
c_str
()
);
for
(
unsigned
in
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
for
(
size_
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
{
try
{
...
...
@@ -972,7 +972,7 @@ throw(UI_THROW_EXCEPTIONS)
}
catch
(
const
uniset
::
NameNotFound
&
)
{}
for
(
unsigned
in
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
for
(
size_
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
{
try
{
...
...
@@ -1049,7 +1049,7 @@ IOController_i::ShortIOInfo UInterface::getChangedTime( const uniset::ObjectId i
}
catch
(
const
uniset
::
NameNotFound
&
)
{}
for
(
unsigned
in
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
for
(
size_
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
{
try
{
...
...
@@ -1108,7 +1108,84 @@ IOController_i::ShortIOInfo UInterface::getChangedTime( const uniset::ObjectId i
throw
uniset
::
TimeOut
(
set_err
(
"UI(getChangedTime): Timeout"
,
id
,
node
));
}
// ------------------------------------------------------------------------------------------------------------
std
::
string
UInterface
::
getInfo
(
const
ObjectId
id
,
const
std
::
string
&
params
,
const
ObjectId
node
)
const
{
if
(
id
==
uniset
::
DefaultObjectId
)
throw
uniset
::
ORepFailed
(
"UI(getInfo): Unknown id=uniset::DefaultObjectId"
);
if
(
node
==
uniset
::
DefaultObjectId
)
{
ostringstream
err
;
err
<<
"UI(getInfo): id='"
<<
id
<<
"' error: node=uniset::DefaultObjectId"
;
throw
uniset
::
ORepFailed
(
err
.
str
());
}
try
{
CORBA
::
Object_var
oref
;
try
{
oref
=
rcache
.
resolve
(
id
,
node
);
}
catch
(
const
uniset
::
NameNotFound
&
)
{}
for
(
size_t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
{
try
{
if
(
CORBA
::
is_nil
(
oref
)
)
oref
=
resolve
(
id
,
node
);
UniSetObject_i_var
u
=
UniSetObject_i
::
_narrow
(
oref
);
SimpleInfo_var
i
=
u
->
getInfo
(
params
.
c_str
()
);
return
std
::
string
(
i
->
info
);
}
catch
(
const
CORBA
::
TRANSIENT
&
)
{}
catch
(
const
CORBA
::
OBJECT_NOT_EXIST
&
)
{}
catch
(
const
CORBA
::
SystemException
&
ex
)
{}
msleep
(
uconf
->
getRepeatTimeout
());
oref
=
CORBA
::
Object
::
_nil
();
}
}
catch
(
const
uniset
::
TimeOut
&
)
{}
catch
(
const
IOController_i
::
NameNotFound
&
ex
)
{
rcache
.
erase
(
id
,
node
);
uwarn
<<
"UI(getInfo): "
<<
ex
.
err
<<
endl
;
}
catch
(
const
IOController_i
::
IOBadParam
&
ex
)
{
rcache
.
erase
(
id
,
node
);
throw
uniset
::
IOBadParam
(
"UI(getInfo): "
+
string
(
ex
.
err
));
}
catch
(
const
uniset
::
ORepFailed
&
)
{
rcache
.
erase
(
id
,
node
);
uwarn
<<
set_err
(
"UI(getInfo): resolve failed "
,
id
,
node
)
<<
endl
;
}
catch
(
const
CORBA
::
NO_IMPLEMENT
&
)
{
rcache
.
erase
(
id
,
node
);
uwarn
<<
set_err
(
"UI(getInfo): method no implement"
,
id
,
node
)
<<
endl
;
}
catch
(
const
CORBA
::
OBJECT_NOT_EXIST
&
e
)
{
rcache
.
erase
(
id
,
node
);
uwarn
<<
set_err
(
"UI(getInfo): object not exist"
,
id
,
node
)
<<
endl
;
}
catch
(
const
CORBA
::
COMM_FAILURE
&
e
)
{
}
catch
(
const
CORBA
::
SystemException
&
ex
)
{
}
rcache
.
erase
(
id
,
node
);
throw
uniset
::
TimeOut
(
set_err
(
"UI(getInfo): Timeout"
,
id
,
node
));
}
// ------------------------------------------------------------------------------------------------------------
uniset
::
ObjectPtr
UInterface
::
CacheOfResolve
::
resolve
(
const
uniset
::
ObjectId
id
,
const
uniset
::
ObjectId
node
)
const
throw
(
uniset
::
NameNotFound
)
{
...
...
@@ -1300,7 +1377,7 @@ void UInterface::askRemoteThreshold( const uniset::ObjectId sid, const uniset::O
}
catch
(
const
uniset
::
NameNotFound
&
)
{}
for
(
unsigned
in
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
for
(
size_
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
{
try
{
...
...
@@ -1397,7 +1474,7 @@ UInterface::getThresholdInfo( const IOController_i::SensorInfo& si, const uniset
}
catch
(
const
uniset
::
NameNotFound
&
)
{}
for
(
unsigned
in
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
for
(
size_
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
{
try
{
...
...
@@ -1478,7 +1555,7 @@ long UInterface::getRawValue( const IOController_i::SensorInfo& si )
}
catch
(
const
uniset
::
NameNotFound
&
)
{}
for
(
unsigned
in
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
for
(
size_
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
{
try
{
...
...
@@ -1567,7 +1644,7 @@ void UInterface::calibrate(const IOController_i::SensorInfo& si,
}
catch
(
const
uniset
::
NameNotFound
&
)
{}
for
(
unsigned
in
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
for
(
size_
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
{
try
{
...
...
@@ -1649,7 +1726,7 @@ IOController_i::CalibrateInfo UInterface::getCalibrateInfo( const IOController_i
}
catch
(
const
uniset
::
NameNotFound
&
)
{}
for
(
unsigned
in
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
for
(
size_
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
{
try
{
...
...
@@ -1728,7 +1805,7 @@ IOController_i::SensorInfoSeq_var UInterface::getSensorSeq( const uniset::IDList
}
catch
(
const
uniset
::
NameNotFound
&
)
{}
for
(
unsigned
in
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
for
(
size_
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
{
try
{
...
...
@@ -1809,7 +1886,7 @@ uniset::IDSeq_var UInterface::setOutputSeq( const IOController_i::OutSeq& lst, u
}
catch
(
const
uniset
::
NameNotFound
&
)
{}
for
(
unsigned
in
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
for
(
size_
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
{
try
{
...
...
@@ -1895,7 +1972,7 @@ uniset::IDSeq_var UInterface::askSensorsSeq( const uniset::IDList& lst,
}
catch
(
const
uniset
::
NameNotFound
&
)
{}
for
(
unsigned
in
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
for
(
size_
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
{
try
{
...
...
@@ -1982,7 +2059,7 @@ IOController_i::ShortMapSeq* UInterface::getSensors( const uniset::ObjectId id,
}
catch
(
const
uniset
::
NameNotFound
&
)
{}
for
(
unsigned
in
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
for
(
size_
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
{
try
{
...
...
@@ -2063,7 +2140,7 @@ IOController_i::SensorInfoSeq* UInterface::getSensorsMap( const uniset::ObjectId
}
catch
(
const
uniset
::
NameNotFound
&
)
{}
for
(
unsigned
in
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
for
(
size_
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
{
try
{
...
...
@@ -2143,7 +2220,7 @@ IONotifyController_i::ThresholdsListSeq* UInterface::getThresholdsList( const un
}
catch
(
const
uniset
::
NameNotFound
&
)
{}
for
(
unsigned
in
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
for
(
size_
t
i
=
0
;
i
<
uconf
->
getRepeatCount
();
i
++
)
{
try
{
...
...
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