Commit ae7c1dec authored by Pavel Vainerman's avatar Pavel Vainerman

Рефакторинг: getChangedTime() --> getTimeChange(),

а также добавил эту функцию в python интерфейс.
parent e921bab4
......@@ -144,7 +144,7 @@ interface IOController_i : UniSetManager_i
uniset::ObjectId supplier; /*!< идентификатор того, кто менял датчик (последний раз) */
};
ShortIOInfo getChangedTime( in uniset::ObjectId sid ) raises(NameNotFound);
ShortIOInfo getTimeChange( in uniset::ObjectId sid ) raises(NameNotFound);
/*! Информация о дискретном датчике */
......
......@@ -49,7 +49,7 @@ static struct option longopts[] =
{ "getValue", required_argument, 0, 'g' },
{ "getRawValue", required_argument, 0, 'w' },
{ "getCalibrate", required_argument, 0, 'y' },
{ "getChangedTime", required_argument, 0, 't' },
{ "getTimeChange", required_argument, 0, 't' },
{ "oinfo", required_argument, 0, 'p' },
{ "verbose", no_argument, 0, 'v' },
{ "quiet", no_argument, 0, 'q' },
......@@ -70,7 +70,7 @@ int logRotate( const string& args, UInterface& ui );
int setValue( const string& args, UInterface& ui );
int getValue( const string& args, UInterface& ui );
int getRawValue( const string& args, UInterface& ui );
int getChangedTime( const string& args, UInterface& ui );
int getTimeChange( const string& args, UInterface& ui );
int getState( const string& args, UInterface& ui );
int getCalibrate( const string& args, UInterface& ui );
int oinfo(const string& args, UInterface& ui , const string& userparam );
......@@ -116,7 +116,7 @@ static void usage()
cout << endl;
print_help(36, "-w|--getRawValue id1@node1,id2@node2,id3,.. ", "Получить 'сырое' значение.\n");
print_help(36, "-y|--getCalibrate id1@node1,id2@node2,id3,.. ", "Получить параметры калибровки.\n");
print_help(36, "-t|--getChangedTime id1@node1,id2@node2,id3,.. ", "Получить время последнего изменения.\n");
print_help(36, "-t|--getTimeChange id1@node1,id2@node2,id3,.. ", "Получить время последнего изменения.\n");
print_help(36, "-v|--verbose", "Подробный вывод логов.\n");
print_help(36, "-q|--quiet", "Выводит только результат.\n");
print_help(36, "-z|--csv", "Вывести результат (getValue) в виде val1,val2,val3...\n");
......@@ -218,13 +218,13 @@ int main(int argc, char** argv)
}
break;
case 't': //--getChangedTime
case 't': //--getTimeChange
{
auto conf = uniset_init(argc, argv, conffile);
UInterface ui(conf);
ui.initBackId(uniset::AdminID);
string name = ( optarg ) ? optarg : "";
return getChangedTime(name, ui);
return getTimeChange(name, ui);
}
break;
......@@ -843,7 +843,7 @@ int getRawValue( const std::string& args, UInterface& ui )
}
// --------------------------------------------------------------------------------------
int getChangedTime( const std::string& args, UInterface& ui )
int getTimeChange( const std::string& args, UInterface& ui )
{
int err = 0;
auto conf = ui.getConf();
......@@ -863,10 +863,10 @@ int getChangedTime( const std::string& args, UInterface& ui )
{
cout << " name: (" << it.si.id << ") " << it.fname << endl;
cout << " text: " << conf->oind->getTextName(it.si.id) << "\n\n";
cout << ui.getChangedTime(it.si.id, it.si.node) << endl;
cout << ui.getTimeChange(it.si.id, it.si.node) << endl;
}
else
cout << ui.getChangedTime(it.si.id, it.si.node);
cout << ui.getTimeChange(it.si.id, it.si.node);
}
catch( const uniset::Exception& ex )
{
......@@ -1016,7 +1016,7 @@ int oinfo(const string& args, UInterface& ui, const string& userparam )
try
{
cout << ui.getInfo(it.id, userparam,it.node) << endl;
cout << ui.getObjectInfo(it.id, userparam,it.node) << endl;
}
catch( const std::exception& ex )
{
......
......@@ -506,6 +506,8 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
%exclude %_pkgconfigdir/libUniSet2.pc
# history of current unpublished changes
- getChangedTime --> getTimeChange
- getInfo( long param ) --> getInfo( string param )
%changelog
* Tue Nov 22 2016 Pavel Vainerman <pv@altlinux.ru> 2.6-alt3.1
......
......@@ -66,8 +66,8 @@ TEST_CASE("UInterface", "[UInterface]")
si.node = -2;
REQUIRE_THROWS_AS( ui.setValue(si, 20, DefaultObjectId), uniset::Exception );
REQUIRE_THROWS_AS( ui.getChangedTime(sid, DefaultObjectId), uniset::ORepFailed );
REQUIRE_NOTHROW( ui.getChangedTime(sid, conf->getLocalNode()) );
REQUIRE_THROWS_AS( ui.getTimeChange(sid, DefaultObjectId), uniset::ORepFailed );
REQUIRE_NOTHROW( ui.getTimeChange(sid, conf->getLocalNode()) );
si.id = aid;
si.node = conf->getLocalNode();
......
......@@ -92,7 +92,7 @@ class IOController:
uniset::Message::Priority getPriority( const uniset::ObjectId id );
virtual IOController_i::ShortIOInfo getChangedTime( const uniset::ObjectId id ) override;
virtual IOController_i::ShortIOInfo getTimeChange( const uniset::ObjectId id ) override;
virtual IOController_i::ShortMapSeq* getSensors() override;
......
......@@ -139,10 +139,10 @@ class UInterface
uniset::ObjectType getType(const uniset::ObjectId id) const;
//! Время последнего изменения датчика
IOController_i::ShortIOInfo getChangedTime( const uniset::ObjectId id, const uniset::ObjectId node ) const;
IOController_i::ShortIOInfo getTimeChange( 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;
std::string getObjectInfo( const uniset::ObjectId id, const std::string& params, const uniset::ObjectId node ) const;
//! Получить список датчиков
IOController_i::ShortMapSeq* getSensors( const uniset::ObjectId id,
......
......@@ -175,9 +175,20 @@ class UInterface():
raise UValidateError("(getObjectID): Unknown interface %s"%self.itype)
def getObjectInfo( self, id, params = "", node = DefaultID ):
'''\param o_name - name, id, name@node, id@node'''
def getObjectInfo( self, o_name, params = "" ):
if self.itype != "uniset":
raise UException("(getObjectInfo): the interface does not support this feature..'getObjectInfo'")
raise UException("(getObjectInfo): the interface does not support this feature..")
return self.i.getObjectInfo( id, params, node )
s = to_sid(o_name,self.i)
return self.i.getObjectInfo( s[0], params, s[1] )
'''\param o_name - name, id, name@node, id@node '''
def getTimeChange( self, o_name ):
if self.itype != "uniset":
raise UException("(getTimeChange): the interface does not support this feature..")
s = to_sid(o_name,self.i)
return self.i.getTimeChange( s[0], s[1] )
\ No newline at end of file
......@@ -114,7 +114,37 @@ void UConnector::setValue( long id, long val, long node, long supplier )throw(UE
}
}
//---------------------------------------------------------------------------
long UConnector::getSensorID(const string& name )
static UTypes::ShortIOInfo toUTypes( IOController_i::ShortIOInfo i )
{
UTypes::ShortIOInfo ret;
ret.value = i.value;
ret.tv_sec = i.tv_sec;
ret.tv_nsec = i.tv_nsec;
ret.supplier = i.supplier;
return std::move(ret);
}
//---------------------------------------------------------------------------
UTypes::ShortIOInfo UConnector::getTimeChange( long id, long node )
{
if( !conf || !ui )
throw USysError();
if( node == UTypes::DefaultID )
node = conf->getLocalNode();
try
{
IOController_i::ShortIOInfo i = ui->getTimeChange(id,node);
return toUTypes(i);
}
catch( const std::exception& ex )
{
throw UException("(getChangedTime): catch " + std::string(ex.what()) );
}
}
//---------------------------------------------------------------------------
long UConnector::getSensorID( const string& name )
{
if( conf )
return conf->getSensorID(name);
......@@ -168,7 +198,7 @@ throw(UException)
try
{
return ui->getInfo(id,params,node);
return ui->getObjectInfo(id,params,node);
}
catch( std::exception& ex )
{
......
......@@ -40,6 +40,7 @@ class UConnector
std::string getConfFileName();
long getValue( long id, long node )throw(UException);
void setValue( long id, long val, long node, long supplier = UTypes::DefaultSupplerID )throw(UException);
UTypes::ShortIOInfo getTimeChange( long id, long node = UTypes::DefaultID );
long getSensorID( const std::string& name );
long getNodeID( const std::string& name );
......
......@@ -3010,10 +3010,11 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) {
#define SWIGTYPE_p_UConnector swig_types[0]
#define SWIGTYPE_p_UException swig_types[1]
#define SWIGTYPE_p_UTypes__Params swig_types[2]
#define SWIGTYPE_p_char swig_types[3]
#define SWIGTYPE_p_p_char swig_types[4]
static swig_type_info *swig_types[6];
static swig_module_info swig_module = {swig_types, 5, 0, 0, 0, 0};
#define SWIGTYPE_p_UTypes__ShortIOInfo swig_types[3]
#define SWIGTYPE_p_char swig_types[4]
#define SWIGTYPE_p_p_char swig_types[5]
static swig_type_info *swig_types[7];
static swig_module_info swig_module = {swig_types, 6, 0, 0, 0, 0};
#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
......@@ -3438,6 +3439,62 @@ SWIG_AsVal_int (PyObject * obj, int *val)
}
SWIGINTERN int
SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val)
{
#if PY_VERSION_HEX < 0x03000000
if (PyInt_Check(obj)) {
long v = PyInt_AsLong(obj);
if (v >= 0) {
if (val) *val = v;
return SWIG_OK;
} else {
return SWIG_OverflowError;
}
} else
#endif
if (PyLong_Check(obj)) {
unsigned long v = PyLong_AsUnsignedLong(obj);
if (!PyErr_Occurred()) {
if (val) *val = v;
return SWIG_OK;
} else {
PyErr_Clear();
return SWIG_OverflowError;
}
}
#ifdef SWIG_PYTHON_CAST_MODE
{
int dispatch = 0;
unsigned long v = PyLong_AsUnsignedLong(obj);
if (!PyErr_Occurred()) {
if (val) *val = v;
return SWIG_AddCast(SWIG_OK);
} else {
PyErr_Clear();
}
if (!dispatch) {
double d;
int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d));
if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) {
if (val) *val = (unsigned long)(d);
return res;
}
}
}
#endif
return SWIG_TypeError;
}
SWIGINTERNINLINE PyObject*
SWIG_From_unsigned_SS_long (unsigned long value)
{
return (value > LONG_MAX) ?
PyLong_FromUnsignedLong(value) : PyLong_FromLong(static_cast< long >(value));
}
SWIGINTERNINLINE PyObject *
SWIG_FromCharPtrAndSize(const char* carray, size_t size)
{
......@@ -3732,6 +3789,255 @@ SWIGINTERN PyObject *Params_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObjec
return SWIG_Py_Void();
}
SWIGINTERN PyObject *_wrap_ShortIOInfo_value_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
UTypes::ShortIOInfo *arg1 = (UTypes::ShortIOInfo *) 0 ;
long arg2 ;
void *argp1 = 0 ;
int res1 = 0 ;
long val2 ;
int ecode2 = 0 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
if (!PyArg_ParseTuple(args,(char *)"OO:ShortIOInfo_value_set",&obj0,&obj1)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_UTypes__ShortIOInfo, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ShortIOInfo_value_set" "', argument " "1"" of type '" "UTypes::ShortIOInfo *""'");
}
arg1 = reinterpret_cast< UTypes::ShortIOInfo * >(argp1);
ecode2 = SWIG_AsVal_long(obj1, &val2);
if (!SWIG_IsOK(ecode2)) {
SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ShortIOInfo_value_set" "', argument " "2"" of type '" "long""'");
}
arg2 = static_cast< long >(val2);
if (arg1) (arg1)->value = arg2;
resultobj = SWIG_Py_Void();
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *_wrap_ShortIOInfo_value_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
UTypes::ShortIOInfo *arg1 = (UTypes::ShortIOInfo *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
PyObject * obj0 = 0 ;
long result;
if (!PyArg_ParseTuple(args,(char *)"O:ShortIOInfo_value_get",&obj0)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_UTypes__ShortIOInfo, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ShortIOInfo_value_get" "', argument " "1"" of type '" "UTypes::ShortIOInfo *""'");
}
arg1 = reinterpret_cast< UTypes::ShortIOInfo * >(argp1);
result = (long) ((arg1)->value);
resultobj = SWIG_From_long(static_cast< long >(result));
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *_wrap_ShortIOInfo_tv_sec_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
UTypes::ShortIOInfo *arg1 = (UTypes::ShortIOInfo *) 0 ;
unsigned long arg2 ;
void *argp1 = 0 ;
int res1 = 0 ;
unsigned long val2 ;
int ecode2 = 0 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
if (!PyArg_ParseTuple(args,(char *)"OO:ShortIOInfo_tv_sec_set",&obj0,&obj1)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_UTypes__ShortIOInfo, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ShortIOInfo_tv_sec_set" "', argument " "1"" of type '" "UTypes::ShortIOInfo *""'");
}
arg1 = reinterpret_cast< UTypes::ShortIOInfo * >(argp1);
ecode2 = SWIG_AsVal_unsigned_SS_long(obj1, &val2);
if (!SWIG_IsOK(ecode2)) {
SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ShortIOInfo_tv_sec_set" "', argument " "2"" of type '" "unsigned long""'");
}
arg2 = static_cast< unsigned long >(val2);
if (arg1) (arg1)->tv_sec = arg2;
resultobj = SWIG_Py_Void();
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *_wrap_ShortIOInfo_tv_sec_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
UTypes::ShortIOInfo *arg1 = (UTypes::ShortIOInfo *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
PyObject * obj0 = 0 ;
unsigned long result;
if (!PyArg_ParseTuple(args,(char *)"O:ShortIOInfo_tv_sec_get",&obj0)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_UTypes__ShortIOInfo, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ShortIOInfo_tv_sec_get" "', argument " "1"" of type '" "UTypes::ShortIOInfo *""'");
}
arg1 = reinterpret_cast< UTypes::ShortIOInfo * >(argp1);
result = (unsigned long) ((arg1)->tv_sec);
resultobj = SWIG_From_unsigned_SS_long(static_cast< unsigned long >(result));
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *_wrap_ShortIOInfo_tv_nsec_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
UTypes::ShortIOInfo *arg1 = (UTypes::ShortIOInfo *) 0 ;
unsigned long arg2 ;
void *argp1 = 0 ;
int res1 = 0 ;
unsigned long val2 ;
int ecode2 = 0 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
if (!PyArg_ParseTuple(args,(char *)"OO:ShortIOInfo_tv_nsec_set",&obj0,&obj1)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_UTypes__ShortIOInfo, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ShortIOInfo_tv_nsec_set" "', argument " "1"" of type '" "UTypes::ShortIOInfo *""'");
}
arg1 = reinterpret_cast< UTypes::ShortIOInfo * >(argp1);
ecode2 = SWIG_AsVal_unsigned_SS_long(obj1, &val2);
if (!SWIG_IsOK(ecode2)) {
SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ShortIOInfo_tv_nsec_set" "', argument " "2"" of type '" "unsigned long""'");
}
arg2 = static_cast< unsigned long >(val2);
if (arg1) (arg1)->tv_nsec = arg2;
resultobj = SWIG_Py_Void();
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *_wrap_ShortIOInfo_tv_nsec_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
UTypes::ShortIOInfo *arg1 = (UTypes::ShortIOInfo *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
PyObject * obj0 = 0 ;
unsigned long result;
if (!PyArg_ParseTuple(args,(char *)"O:ShortIOInfo_tv_nsec_get",&obj0)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_UTypes__ShortIOInfo, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ShortIOInfo_tv_nsec_get" "', argument " "1"" of type '" "UTypes::ShortIOInfo *""'");
}
arg1 = reinterpret_cast< UTypes::ShortIOInfo * >(argp1);
result = (unsigned long) ((arg1)->tv_nsec);
resultobj = SWIG_From_unsigned_SS_long(static_cast< unsigned long >(result));
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *_wrap_ShortIOInfo_supplier_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
UTypes::ShortIOInfo *arg1 = (UTypes::ShortIOInfo *) 0 ;
long arg2 ;
void *argp1 = 0 ;
int res1 = 0 ;
long val2 ;
int ecode2 = 0 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
if (!PyArg_ParseTuple(args,(char *)"OO:ShortIOInfo_supplier_set",&obj0,&obj1)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_UTypes__ShortIOInfo, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ShortIOInfo_supplier_set" "', argument " "1"" of type '" "UTypes::ShortIOInfo *""'");
}
arg1 = reinterpret_cast< UTypes::ShortIOInfo * >(argp1);
ecode2 = SWIG_AsVal_long(obj1, &val2);
if (!SWIG_IsOK(ecode2)) {
SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ShortIOInfo_supplier_set" "', argument " "2"" of type '" "long""'");
}
arg2 = static_cast< long >(val2);
if (arg1) (arg1)->supplier = arg2;
resultobj = SWIG_Py_Void();
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *_wrap_ShortIOInfo_supplier_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
UTypes::ShortIOInfo *arg1 = (UTypes::ShortIOInfo *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
PyObject * obj0 = 0 ;
long result;
if (!PyArg_ParseTuple(args,(char *)"O:ShortIOInfo_supplier_get",&obj0)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_UTypes__ShortIOInfo, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ShortIOInfo_supplier_get" "', argument " "1"" of type '" "UTypes::ShortIOInfo *""'");
}
arg1 = reinterpret_cast< UTypes::ShortIOInfo * >(argp1);
result = (long) ((arg1)->supplier);
resultobj = SWIG_From_long(static_cast< long >(result));
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *_wrap_new_ShortIOInfo(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
UTypes::ShortIOInfo *result = 0 ;
if (!PyArg_ParseTuple(args,(char *)":new_ShortIOInfo")) SWIG_fail;
result = (UTypes::ShortIOInfo *)new UTypes::ShortIOInfo();
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_UTypes__ShortIOInfo, SWIG_POINTER_NEW | 0 );
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *_wrap_delete_ShortIOInfo(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
UTypes::ShortIOInfo *arg1 = (UTypes::ShortIOInfo *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
PyObject * obj0 = 0 ;
if (!PyArg_ParseTuple(args,(char *)"O:delete_ShortIOInfo",&obj0)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_UTypes__ShortIOInfo, SWIG_POINTER_DISOWN | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_ShortIOInfo" "', argument " "1"" of type '" "UTypes::ShortIOInfo *""'");
}
arg1 = reinterpret_cast< UTypes::ShortIOInfo * >(argp1);
delete arg1;
resultobj = SWIG_Py_Void();
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *ShortIOInfo_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *obj;
if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
SWIG_TypeNewClientData(SWIGTYPE_p_UTypes__ShortIOInfo, SWIG_NewClientData(obj));
return SWIG_Py_Void();
}
SWIGINTERN PyObject *_wrap_new_UConnector__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
int arg1 ;
......@@ -4193,6 +4499,135 @@ fail:
}
SWIGINTERN PyObject *_wrap_UConnector_getTimeChange__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
UConnector *arg1 = (UConnector *) 0 ;
long arg2 ;
long arg3 ;
void *argp1 = 0 ;
int res1 = 0 ;
long val2 ;
int ecode2 = 0 ;
long val3 ;
int ecode3 = 0 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
UTypes::ShortIOInfo result;
if (!PyArg_ParseTuple(args,(char *)"OOO:UConnector_getTimeChange",&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_getTimeChange" "', 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_getTimeChange" "', argument " "2"" of type '" "long""'");
}
arg2 = static_cast< long >(val2);
ecode3 = SWIG_AsVal_long(obj2, &val3);
if (!SWIG_IsOK(ecode3)) {
SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "UConnector_getTimeChange" "', argument " "3"" of type '" "long""'");
}
arg3 = static_cast< long >(val3);
result = (arg1)->getTimeChange(arg2,arg3);
resultobj = SWIG_NewPointerObj((new UTypes::ShortIOInfo(static_cast< const UTypes::ShortIOInfo& >(result))), SWIGTYPE_p_UTypes__ShortIOInfo, SWIG_POINTER_OWN | 0 );
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *_wrap_UConnector_getTimeChange__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
UConnector *arg1 = (UConnector *) 0 ;
long arg2 ;
void *argp1 = 0 ;
int res1 = 0 ;
long val2 ;
int ecode2 = 0 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
UTypes::ShortIOInfo result;
if (!PyArg_ParseTuple(args,(char *)"OO:UConnector_getTimeChange",&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_getTimeChange" "', 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_getTimeChange" "', argument " "2"" of type '" "long""'");
}
arg2 = static_cast< long >(val2);
result = (arg1)->getTimeChange(arg2);
resultobj = SWIG_NewPointerObj((new UTypes::ShortIOInfo(static_cast< const UTypes::ShortIOInfo& >(result))), SWIGTYPE_p_UTypes__ShortIOInfo, SWIG_POINTER_OWN | 0 );
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *_wrap_UConnector_getTimeChange(PyObject *self, PyObject *args) {
Py_ssize_t argc;
PyObject *argv[4] = {
0
};
Py_ssize_t ii;
if (!PyTuple_Check(args)) SWIG_fail;
argc = args ? PyObject_Length(args) : 0;
for (ii = 0; (ii < 3) && (ii < argc); ii++) {
argv[ii] = PyTuple_GET_ITEM(args,ii);
}
if (argc == 2) {
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) {
return _wrap_UConnector_getTimeChange__SWIG_1(self, args);
}
}
}
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_AsVal_long(argv[2], NULL);
_v = SWIG_CheckState(res);
}
if (_v) {
return _wrap_UConnector_getTimeChange__SWIG_0(self, args);
}
}
}
}
fail:
SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'UConnector_getTimeChange'.\n"
" Possible C/C++ prototypes are:\n"
" UConnector::getTimeChange(long,long)\n"
" UConnector::getTimeChange(long)\n");
return 0;
}
SWIGINTERN PyObject *_wrap_UConnector_getSensorID(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
UConnector *arg1 = (UConnector *) 0 ;
......@@ -4627,12 +5062,24 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"Params_inst", _wrap_Params_inst, METH_VARARGS, NULL},
{ (char *)"delete_Params", _wrap_delete_Params, METH_VARARGS, NULL},
{ (char *)"Params_swigregister", Params_swigregister, METH_VARARGS, NULL},
{ (char *)"ShortIOInfo_value_set", _wrap_ShortIOInfo_value_set, METH_VARARGS, NULL},
{ (char *)"ShortIOInfo_value_get", _wrap_ShortIOInfo_value_get, METH_VARARGS, NULL},
{ (char *)"ShortIOInfo_tv_sec_set", _wrap_ShortIOInfo_tv_sec_set, METH_VARARGS, NULL},
{ (char *)"ShortIOInfo_tv_sec_get", _wrap_ShortIOInfo_tv_sec_get, METH_VARARGS, NULL},
{ (char *)"ShortIOInfo_tv_nsec_set", _wrap_ShortIOInfo_tv_nsec_set, METH_VARARGS, NULL},
{ (char *)"ShortIOInfo_tv_nsec_get", _wrap_ShortIOInfo_tv_nsec_get, METH_VARARGS, NULL},
{ (char *)"ShortIOInfo_supplier_set", _wrap_ShortIOInfo_supplier_set, METH_VARARGS, NULL},
{ (char *)"ShortIOInfo_supplier_get", _wrap_ShortIOInfo_supplier_get, METH_VARARGS, NULL},
{ (char *)"new_ShortIOInfo", _wrap_new_ShortIOInfo, METH_VARARGS, NULL},
{ (char *)"delete_ShortIOInfo", _wrap_delete_ShortIOInfo, METH_VARARGS, NULL},
{ (char *)"ShortIOInfo_swigregister", ShortIOInfo_swigregister, METH_VARARGS, NULL},
{ (char *)"new_UConnector", _wrap_new_UConnector, METH_VARARGS, NULL},
{ (char *)"delete_UConnector", _wrap_delete_UConnector, METH_VARARGS, NULL},
{ (char *)"UConnector_getUIType", _wrap_UConnector_getUIType, METH_VARARGS, NULL},
{ (char *)"UConnector_getConfFileName", _wrap_UConnector_getConfFileName, METH_VARARGS, NULL},
{ (char *)"UConnector_getValue", _wrap_UConnector_getValue, METH_VARARGS, NULL},
{ (char *)"UConnector_setValue", _wrap_UConnector_setValue, METH_VARARGS, NULL},
{ (char *)"UConnector_getTimeChange", _wrap_UConnector_getTimeChange, 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},
......@@ -4651,6 +5098,7 @@ static PyMethodDef SwigMethods[] = {
static swig_type_info _swigt__p_UConnector = {"_p_UConnector", "UConnector *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_UException = {"_p_UException", "UException *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_UTypes__Params = {"_p_UTypes__Params", "UTypes::Params *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_UTypes__ShortIOInfo = {"_p_UTypes__ShortIOInfo", "UTypes::ShortIOInfo *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_p_char = {"_p_p_char", "char **", 0, 0, (void*)0, 0};
......@@ -4658,6 +5106,7 @@ static swig_type_info *swig_type_initial[] = {
&_swigt__p_UConnector,
&_swigt__p_UException,
&_swigt__p_UTypes__Params,
&_swigt__p_UTypes__ShortIOInfo,
&_swigt__p_char,
&_swigt__p_p_char,
};
......@@ -4665,6 +5114,7 @@ static swig_type_info *swig_type_initial[] = {
static swig_cast_info _swigc__p_UConnector[] = { {&_swigt__p_UConnector, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_UException[] = { {&_swigt__p_UException, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_UTypes__Params[] = { {&_swigt__p_UTypes__Params, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_UTypes__ShortIOInfo[] = { {&_swigt__p_UTypes__ShortIOInfo, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_p_char[] = { {&_swigt__p_p_char, 0, 0, 0},{0, 0, 0, 0}};
......@@ -4672,6 +5122,7 @@ static swig_cast_info *swig_cast_initial[] = {
_swigc__p_UConnector,
_swigc__p_UException,
_swigc__p_UTypes__Params,
_swigc__p_UTypes__ShortIOInfo,
_swigc__p_char,
_swigc__p_p_char,
};
......
......@@ -65,7 +65,16 @@ namespace UTypes
return Params();
}
};
struct ShortIOInfo
{
long value;
unsigned long tv_sec;
unsigned long tv_nsec;
long supplier;
};
}
//---------------------------------------------------------------------------
#endif
//---------------------------------------------------------------------------
......@@ -110,6 +110,32 @@ def Params_inst():
return _pyUConnector.Params_inst()
Params_inst = _pyUConnector.Params_inst
class ShortIOInfo:
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, ShortIOInfo, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, ShortIOInfo, name)
__repr__ = _swig_repr
__swig_setmethods__["value"] = _pyUConnector.ShortIOInfo_value_set
__swig_getmethods__["value"] = _pyUConnector.ShortIOInfo_value_get
__swig_setmethods__["tv_sec"] = _pyUConnector.ShortIOInfo_tv_sec_set
__swig_getmethods__["tv_sec"] = _pyUConnector.ShortIOInfo_tv_sec_get
__swig_setmethods__["tv_nsec"] = _pyUConnector.ShortIOInfo_tv_nsec_set
__swig_getmethods__["tv_nsec"] = _pyUConnector.ShortIOInfo_tv_nsec_get
__swig_setmethods__["supplier"] = _pyUConnector.ShortIOInfo_supplier_set
__swig_getmethods__["supplier"] = _pyUConnector.ShortIOInfo_supplier_get
def __init__(self):
this = _pyUConnector.new_ShortIOInfo()
try:
self.this.append(this)
except Exception:
self.this = this
__swig_destroy__ = _pyUConnector.delete_ShortIOInfo
__del__ = lambda self: None
ShortIOInfo_swigregister = _pyUConnector.ShortIOInfo_swigregister
ShortIOInfo_swigregister(ShortIOInfo)
class UConnector:
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, UConnector, name, value)
......@@ -138,6 +164,9 @@ class UConnector:
def setValue(self, *args):
return _pyUConnector.UConnector_setValue(self, *args)
def getTimeChange(self, *args):
return _pyUConnector.UConnector_getTimeChange(self, *args)
def getSensorID(self, name):
return _pyUConnector.UConnector_getSensorID(self, name)
......
......@@ -48,6 +48,9 @@ if __name__ == "__main__":
#obj2 = UProxyObject("TestProc1")
print "Info: %s"%uc1.getObjectInfo( uc1.getObjectID("TestProc1"),"")
# tc = uc1.getTimeChange(2)
# print "TimeChange: %s sup=%d"%(tc.value,tc.supplier)
# print "(0)UIType: %s" % uc1.getUIType()
print "(1)getShortName: id=%d name=%s" % (1, uc1.getShortName(1))
......
......@@ -1027,15 +1027,15 @@ void UInterface::send( const uniset::ObjectId name, const uniset::TransportMessa
}
// ------------------------------------------------------------------------------------------------------------
IOController_i::ShortIOInfo UInterface::getChangedTime( const uniset::ObjectId id, const uniset::ObjectId node ) const
IOController_i::ShortIOInfo UInterface::getTimeChange( const uniset::ObjectId id, const uniset::ObjectId node ) const
{
if( id == uniset::DefaultObjectId )
throw uniset::ORepFailed("UI(getChangedTime): Unknown id=uniset::DefaultObjectId");
throw uniset::ORepFailed("UI(getTimeChange): Unknown id=uniset::DefaultObjectId");
if( node == uniset::DefaultObjectId )
{
ostringstream err;
err << "UI(getChangedTime): id='" << id << "' error: node=uniset::DefaultObjectId";
err << "UI(getTimeChange): id='" << id << "' error: node=uniset::DefaultObjectId";
throw uniset::ORepFailed(err.str());
}
......@@ -1057,7 +1057,7 @@ IOController_i::ShortIOInfo UInterface::getChangedTime( const uniset::ObjectId i
oref = resolve( id, node );
IOController_i_var iom = IOController_i::_narrow(oref);
return iom->getChangedTime(id);
return iom->getTimeChange(id);
}
catch( const CORBA::TRANSIENT& ) {}
catch( const CORBA::OBJECT_NOT_EXIST& ) {}
......@@ -1071,27 +1071,27 @@ IOController_i::ShortIOInfo UInterface::getChangedTime( const uniset::ObjectId i
catch( const IOController_i::NameNotFound& ex)
{
rcache.erase(id, node);
uwarn << "UI(getChangedTime): " << ex.err << endl;
uwarn << "UI(getTimeChange): " << ex.err << endl;
}
catch( const IOController_i::IOBadParam& ex )
{
rcache.erase(id, node);
throw uniset::IOBadParam("UI(getChangedTime): " + string(ex.err));
throw uniset::IOBadParam("UI(getTimeChange): " + string(ex.err));
}
catch( const uniset::ORepFailed& )
{
rcache.erase(id, node);
uwarn << set_err("UI(getChangedTime): resolve failed ", id, node) << endl;
uwarn << set_err("UI(getTimeChange): resolve failed ", id, node) << endl;
}
catch( const CORBA::NO_IMPLEMENT& )
{
rcache.erase(id, node);
uwarn << set_err("UI(getChangedTime): method no implement", id, node) << endl;
uwarn << set_err("UI(getTimeChange): method no implement", id, node) << endl;
}
catch( const CORBA::OBJECT_NOT_EXIST& e )
{
rcache.erase(id, node);
uwarn << set_err("UI(getChangedTime): object not exist", id, node) << endl;
uwarn << set_err("UI(getTimeChange): object not exist", id, node) << endl;
}
catch( const CORBA::COMM_FAILURE& e )
{
......@@ -1105,10 +1105,10 @@ IOController_i::ShortIOInfo UInterface::getChangedTime( const uniset::ObjectId i
}
rcache.erase(id, node);
throw uniset::TimeOut(set_err("UI(getChangedTime): Timeout", id, node));
throw uniset::TimeOut(set_err("UI(getTimeChange): Timeout", id, node));
}
// ------------------------------------------------------------------------------------------------------------
std::string UInterface::getInfo( const ObjectId id, const std::string& params, const ObjectId node ) const
std::string UInterface::getObjectInfo( const ObjectId id, const std::string& params, const ObjectId node ) const
{
if( id == uniset::DefaultObjectId )
throw uniset::ORepFailed("UI(getInfo): Unknown id=uniset::DefaultObjectId");
......
......@@ -707,7 +707,7 @@ IDSeq* IOController::setOutputSeq(const IOController_i::OutSeq& lst, ObjectId su
return badlist.getIDSeq();
}
// -----------------------------------------------------------------------------
IOController_i::ShortIOInfo IOController::getChangedTime( uniset::ObjectId sid )
IOController_i::ShortIOInfo IOController::getTimeChange( uniset::ObjectId sid )
{
auto ait = ioList.find(sid);
......
......@@ -41,9 +41,9 @@ TEST_CASE("UInterface", "[UInterface]")
REQUIRE_THROWS_AS( ui.send(testOID, tm), uniset::Exception );
REQUIRE_THROWS_AS( ui.send(testOID, tm, -20), uniset::Exception );
REQUIRE_THROWS_AS( ui.send(testOID, tm, DefaultObjectId), uniset::Exception );
REQUIRE_THROWS_AS( ui.getChangedTime(sid, -20), uniset::Exception );
REQUIRE_THROWS_AS( ui.getChangedTime(sid, DefaultObjectId), uniset::Exception );
REQUIRE_THROWS_AS( ui.getChangedTime(sid, conf->getLocalNode()), uniset::Exception );
REQUIRE_THROWS_AS( ui.getTimeChange(sid, -20), uniset::Exception );
REQUIRE_THROWS_AS( ui.getTimeChange(sid, DefaultObjectId), uniset::Exception );
REQUIRE_THROWS_AS( ui.getTimeChange(sid, conf->getLocalNode()), uniset::Exception );
CHECK_FALSE( ui.isExist(sid) );
CHECK_FALSE( ui.isExist(sid, DefaultObjectId) );
......
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