Commit 89406a14 authored by Pavel Vainerman's avatar Pavel Vainerman

(tests): добавил тест UInterface, но функций которые можно проверить без

SharedMemory. C SM тесты будут в extensions/tests.
parent ecee5cb0
...@@ -121,6 +121,9 @@ long UInterface::getValue( const ObjectId id, const ObjectId node ) const ...@@ -121,6 +121,9 @@ long UInterface::getValue( const ObjectId id, const ObjectId node ) const
if ( id == DefaultObjectId ) if ( id == DefaultObjectId )
throw ORepFailed("UI(getValue): error id=UniSetTypes::DefaultObjectId"); throw ORepFailed("UI(getValue): error id=UniSetTypes::DefaultObjectId");
if ( node == DefaultObjectId )
throw ORepFailed("UI(getValue): error node=UniSetTypes::DefaultObjectId");
try try
{ {
CORBA::Object_var oref; CORBA::Object_var oref;
...@@ -279,6 +282,9 @@ void UInterface::setValue( const ObjectId id, long value, const ObjectId node ) ...@@ -279,6 +282,9 @@ void UInterface::setValue( const ObjectId id, long value, const ObjectId node )
if ( id == DefaultObjectId ) if ( id == DefaultObjectId )
throw ORepFailed("UI(setValue): попытка обратиться к объекту с id=UniSetTypes::DefaultObjectId"); throw ORepFailed("UI(setValue): попытка обратиться к объекту с id=UniSetTypes::DefaultObjectId");
if ( node == DefaultObjectId )
throw ORepFailed("UI(setValue): error node=UniSetTypes::DefaultObjectId");
try try
{ {
CORBA::Object_var oref; CORBA::Object_var oref;
...@@ -469,6 +475,9 @@ void UInterface::askRemoteSensor( const ObjectId id, UniversalIO::UIOCommand cmd ...@@ -469,6 +475,9 @@ void UInterface::askRemoteSensor( const ObjectId id, UniversalIO::UIOCommand cmd
if ( id == DefaultObjectId ) if ( id == DefaultObjectId )
throw ORepFailed("UI(askRemoteSensor): id=UniSetTypes::DefaultObjectId"); throw ORepFailed("UI(askRemoteSensor): id=UniSetTypes::DefaultObjectId");
if ( node == DefaultObjectId )
throw ORepFailed("UI(askRemoteSensor): error node=UniSetTypes::DefaultObjectId");
try try
{ {
CORBA::Object_var oref; CORBA::Object_var oref;
...@@ -557,6 +566,9 @@ IOType UInterface::getIOType( const ObjectId id, const ObjectId node ) const ...@@ -557,6 +566,9 @@ IOType UInterface::getIOType( const ObjectId id, const ObjectId node ) const
if ( id == DefaultObjectId ) if ( id == DefaultObjectId )
throw ORepFailed("UI(getIOType): попытка обратиться к объекту с id=UniSetTypes::DefaultObjectId"); throw ORepFailed("UI(getIOType): попытка обратиться к объекту с id=UniSetTypes::DefaultObjectId");
if ( node == DefaultObjectId )
throw ORepFailed("UI(getIOType): error node=UniSetTypes::DefaultObjectId");
try try
{ {
CORBA::Object_var oref; CORBA::Object_var oref;
...@@ -639,6 +651,9 @@ ObjectType UInterface::getType(const ObjectId name, const ObjectId node) const ...@@ -639,6 +651,9 @@ ObjectType UInterface::getType(const ObjectId name, const ObjectId node) const
if ( name == DefaultObjectId ) if ( name == DefaultObjectId )
throw ORepFailed("UI(getType): попытка обратиться к объекту с id=UniSetTypes::DefaultObjectId"); throw ORepFailed("UI(getType): попытка обратиться к объекту с id=UniSetTypes::DefaultObjectId");
if ( node == DefaultObjectId )
throw ORepFailed("UI(getType): error node=UniSetTypes::DefaultObjectId");
try try
{ {
CORBA::Object_var oref; CORBA::Object_var oref;
...@@ -762,6 +777,9 @@ ObjectPtr UInterface::resolve( const ObjectId rid , const ObjectId node, int tim ...@@ -762,6 +777,9 @@ ObjectPtr UInterface::resolve( const ObjectId rid , const ObjectId node, int tim
if ( rid == DefaultObjectId ) if ( rid == DefaultObjectId )
throw ResolveNameError("UI(resolve): ID=UniSetTypes::DefaultObjectId"); throw ResolveNameError("UI(resolve): ID=UniSetTypes::DefaultObjectId");
if ( node == DefaultObjectId )
throw ResolveNameError("UI(resolve): error node=UniSetTypes::DefaultObjectId");
CosNaming::NamingContext_var ctx; CosNaming::NamingContext_var ctx;
rcache.erase(rid, node); rcache.erase(rid, node);
try try
...@@ -890,6 +908,9 @@ void UInterface::send( const ObjectId name, const TransportMessage& msg, const O ...@@ -890,6 +908,9 @@ void UInterface::send( const ObjectId name, const TransportMessage& msg, const O
if ( name == DefaultObjectId ) if ( name == DefaultObjectId )
throw ORepFailed("UI(send): ERROR: id=UniSetTypes::DefaultObjectId"); throw ORepFailed("UI(send): ERROR: id=UniSetTypes::DefaultObjectId");
if ( node == DefaultObjectId )
throw ORepFailed("UI(send): error node=UniSetTypes::DefaultObjectId");
try try
{ {
CORBA::Object_var oref; CORBA::Object_var oref;
...@@ -958,6 +979,9 @@ IOController_i::ShortIOInfo UInterface::getChangedTime( const ObjectId id, const ...@@ -958,6 +979,9 @@ IOController_i::ShortIOInfo UInterface::getChangedTime( const ObjectId id, const
if( id == DefaultObjectId ) if( id == DefaultObjectId )
throw ORepFailed("UI(getChangedTime): Unknown id=UniSetTypes::DefaultObjectId"); throw ORepFailed("UI(getChangedTime): Unknown id=UniSetTypes::DefaultObjectId");
if ( node == DefaultObjectId )
throw ORepFailed("UI(getChangedTime): error node=UniSetTypes::DefaultObjectId");
try try
{ {
CORBA::Object_var oref; CORBA::Object_var oref;
...@@ -1183,6 +1207,9 @@ void UInterface::askRemoteThreshold( const ObjectId sid, const ObjectId node, ...@@ -1183,6 +1207,9 @@ void UInterface::askRemoteThreshold( const ObjectId sid, const ObjectId node,
if ( sid == DefaultObjectId ) if ( sid == DefaultObjectId )
throw ORepFailed("UI(askRemoteThreshold): попытка обратиться к объекту с id=UniSetTypes::DefaultObjectId"); throw ORepFailed("UI(askRemoteThreshold): попытка обратиться к объекту с id=UniSetTypes::DefaultObjectId");
if ( node == DefaultObjectId )
throw ORepFailed("UI(askRemoteThreshold): error node=UniSetTypes::DefaultObjectId");
try try
{ {
CORBA::Object_var oref; CORBA::Object_var oref;
...@@ -1341,6 +1368,9 @@ long UInterface::getRawValue( const IOController_i::SensorInfo& si ) ...@@ -1341,6 +1368,9 @@ long UInterface::getRawValue( const IOController_i::SensorInfo& si )
if ( si.id == DefaultObjectId ) if ( si.id == DefaultObjectId )
throw ORepFailed("UI(getRawValue): попытка обратиться к объекту с id=UniSetTypes::DefaultObjectId"); throw ORepFailed("UI(getRawValue): попытка обратиться к объекту с id=UniSetTypes::DefaultObjectId");
if ( si.node == DefaultObjectId )
throw ORepFailed("UI(cgetRawValue): error node=UniSetTypes::DefaultObjectId");
try try
{ {
CORBA::Object_var oref; CORBA::Object_var oref;
...@@ -1417,9 +1447,12 @@ void UInterface::calibrate(const IOController_i::SensorInfo& si, ...@@ -1417,9 +1447,12 @@ void UInterface::calibrate(const IOController_i::SensorInfo& si,
// if( admId==UniSetTypes::DefaultObjectId ) // if( admId==UniSetTypes::DefaultObjectId )
// throw UniSetTypes::IOBadParam("UI(askTreshold): неизвестен ID администратора"); // throw UniSetTypes::IOBadParam("UI(askTreshold): неизвестен ID администратора");
if ( si.id == DefaultObjectId ) if( si.id == DefaultObjectId )
throw ORepFailed("UI(calibrate): попытка обратиться к объекту с id=UniSetTypes::DefaultObjectId"); throw ORepFailed("UI(calibrate): попытка обратиться к объекту с id=UniSetTypes::DefaultObjectId");
if( si.node == DefaultObjectId )
throw ORepFailed("UI(calibrate): error node=UniSetTypes::DefaultObjectId");
try try
{ {
CORBA::Object_var oref; CORBA::Object_var oref;
...@@ -1492,6 +1525,9 @@ IOController_i::CalibrateInfo UInterface::getCalibrateInfo( const IOController_i ...@@ -1492,6 +1525,9 @@ IOController_i::CalibrateInfo UInterface::getCalibrateInfo( const IOController_i
if ( si.id == DefaultObjectId ) if ( si.id == DefaultObjectId )
throw ORepFailed("UI(getCalibrateInfo): попытка обратиться к объекту с id=UniSetTypes::DefaultObjectId"); throw ORepFailed("UI(getCalibrateInfo): попытка обратиться к объекту с id=UniSetTypes::DefaultObjectId");
if ( si.node == DefaultObjectId )
throw ORepFailed("UI(getCalibrateInfo): error node=UniSetTypes::DefaultObjectId");
try try
{ {
CORBA::Object_var oref; CORBA::Object_var oref;
...@@ -1803,6 +1839,12 @@ UniSetTypes::IDSeq_var UInterface::askSensorsSeq( UniSetTypes::IDList& lst, ...@@ -1803,6 +1839,12 @@ UniSetTypes::IDSeq_var UInterface::askSensorsSeq( UniSetTypes::IDList& lst,
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
IOController_i::ShortMapSeq* UInterface::getSensors( const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node ) IOController_i::ShortMapSeq* UInterface::getSensors( const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node )
{ {
if ( id == DefaultObjectId )
throw ORepFailed("UI(getSensors): error node=UniSetTypes::DefaultObjectId");
if ( node == DefaultObjectId )
throw ORepFailed("UI(getSensors): error node=UniSetTypes::DefaultObjectId");
try try
{ {
CORBA::Object_var oref; CORBA::Object_var oref;
...@@ -1871,6 +1913,12 @@ IOController_i::ShortMapSeq* UInterface::getSensors( const UniSetTypes::ObjectId ...@@ -1871,6 +1913,12 @@ IOController_i::ShortMapSeq* UInterface::getSensors( const UniSetTypes::ObjectId
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool UInterface::waitReady( const ObjectId id, int msec, int pmsec, const ObjectId node ) bool UInterface::waitReady( const ObjectId id, int msec, int pmsec, const ObjectId node )
{ {
if( msec < 0 )
msec = 0;
if( pmsec < 0 )
pmsec = 0;
PassiveTimer ptReady(msec); PassiveTimer ptReady(msec);
bool ready = false; bool ready = false;
while( !ptReady.checkTime() && !ready ) while( !ptReady.checkTime() && !ready )
...@@ -1891,6 +1939,12 @@ bool UInterface::waitReady( const ObjectId id, int msec, int pmsec, const Object ...@@ -1891,6 +1939,12 @@ bool UInterface::waitReady( const ObjectId id, int msec, int pmsec, const Object
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool UInterface::waitWorking( const ObjectId id, int msec, int pmsec, const ObjectId node ) bool UInterface::waitWorking( const ObjectId id, int msec, int pmsec, const ObjectId node )
{ {
if( msec < 0 )
msec = 0;
if( pmsec < 0 )
pmsec = 0;
PassiveTimer ptReady(msec); PassiveTimer ptReady(msec);
bool ready = false; bool ready = false;
......
...@@ -75,12 +75,12 @@ ostream& UniSetTypes::Configuration::help(ostream& os) ...@@ -75,12 +75,12 @@ ostream& UniSetTypes::Configuration::help(ostream& os)
namespace UniSetTypes namespace UniSetTypes
{ {
DebugStream ulog; DebugStream ulog;
Configuration *conf = 0; Configuration* conf = 0;
Configuration::Configuration(): Configuration::Configuration():
oind(NULL), oind(NULL),
NSName("NameService"), NSName("NameService"),
repeatCount(2),repeatTimeout(100), repeatCount(2),repeatTimeout(100),
localDBServer(UniSetTypes::DefaultObjectId), localDBServer(UniSetTypes::DefaultObjectId),
localNode(UniSetTypes::DefaultObjectId), localNode(UniSetTypes::DefaultObjectId),
localNodeName(""), localNodeName(""),
...@@ -173,10 +173,6 @@ void Configuration::initConfiguration( int argc, const char* const* argv ) ...@@ -173,10 +173,6 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
rootDir = string(curdir) + "/"; rootDir = string(curdir) + "/";
/*! \todo Надо избавляться от глобального conf (!) */
if( !UniSetTypes::conf )
UniSetTypes::conf = this;
{ {
ostringstream s; ostringstream s;
s << this << "NameService"; s << this << "NameService";
......
...@@ -3,24 +3,16 @@ ...@@ -3,24 +3,16 @@
############################################################################ ############################################################################
noinst_PROGRAMS = tests tests_with_conf noinst_PROGRAMS = tests tests_with_conf
#unixml ui umutex conftest iterator_test sscanf_hex calibration threadtst dlog #ui umutex sscanf_hexthreadtst dlog
tests_SOURCES = tests.cc passivetimer.cc hourglass.cc delaytimer.cc unixml.cc tests_SOURCES = tests.cc passivetimer.cc hourglass.cc delaytimer.cc unixml.cc
tests_LDADD = $(top_builddir)/lib/libUniSet2.la tests_LDADD = $(top_builddir)/lib/libUniSet2.la
tests_CPPFLAGS = -I$(top_builddir)/include -I$(includedir)/Catch tests_CPPFLAGS = -I$(top_builddir)/include -I$(includedir)/Catch
tests_with_conf_SOURCES = tests_with_conf.cc conftest.cc tests_with_conf_SOURCES = tests_with_conf.cc conftest.cc ui.cc
tests_with_conf_LDADD = $(top_builddir)/lib/libUniSet2.la tests_with_conf_LDADD = $(top_builddir)/lib/libUniSet2.la
tests_with_conf_CPPFLAGS = -I$(top_builddir)/include -I$(includedir)/Catch tests_with_conf_CPPFLAGS = -I$(top_builddir)/include -I$(includedir)/Catch
# unixml_SOURCES = unixml.cc
# unixml_LDADD = $(top_builddir)/lib/libUniSet2.la ${SIGC_LIBS}
# unixml_CPPFLAGS = -I$(top_builddir)/include ${SIGC_CFLAGS}
#
# iterator_test_SOURCES = iterator_test.cc
# iterator_test_LDADD = $(top_builddir)/lib/libUniSet2.la
# iterator_test_CPPFLAGS = -I$(top_builddir)/include
#
# ui_SOURCES = ui.cc # ui_SOURCES = ui.cc
# ui_LDADD = $(top_builddir)/lib/libUniSet2.la # ui_LDADD = $(top_builddir)/lib/libUniSet2.la
# ui_CPPFLAGS = -I$(top_builddir)/include # ui_CPPFLAGS = -I$(top_builddir)/include
...@@ -31,10 +23,6 @@ tests_with_conf_CPPFLAGS = -I$(top_builddir)/include -I$(includedir)/Catch ...@@ -31,10 +23,6 @@ tests_with_conf_CPPFLAGS = -I$(top_builddir)/include -I$(includedir)/Catch
# #
# sscanf_hex_SOURCES = sscanf_hex.cc # sscanf_hex_SOURCES = sscanf_hex.cc
# #
# calibration_SOURCES = calibration.cc
# calibration_LDADD = $(top_builddir)/lib/libUniSet2.la ${SIGC_LIBS}
# calibration_CPPFLAGS = -I$(top_builddir)/include ${SIGC_CFLAGS}
#
# threadtst_SOURCES = threadtst.cc # threadtst_SOURCES = threadtst.cc
# threadtst_LDADD = $(top_builddir)/lib/libUniSet2.la ${SIGC_LIBS} $(COMCPP_LIBS) # threadtst_LDADD = $(top_builddir)/lib/libUniSet2.la ${SIGC_LIBS} $(COMCPP_LIBS)
# threadtst_CPPFLAGS = -I$(top_builddir)/include ${SIGC_CFLAGS} $(COMCPP_CFLAGS) # threadtst_CPPFLAGS = -I$(top_builddir)/include ${SIGC_CFLAGS} $(COMCPP_CFLAGS)
......
...@@ -98,60 +98,3 @@ TEST_CASE( "Configuration", "[Configuration]" ) ...@@ -98,60 +98,3 @@ TEST_CASE( "Configuration", "[Configuration]" )
} }
} }
#if 0
try
{
int i1 = uni_atoi("-100");
cout << "**** check uni_atoi: '-100' " << ( ( i1 != -100 ) ? "FAILED" : "OK" ) << endl;
int i2 = uni_atoi("20");
cout << "**** check uni_atoi: '20' " << ( ( i2 != 20 ) ? "FAILED" : "OK" ) << endl;
xmlNode* cnode = conf->getNode("testnode");
if( cnode == NULL )
{
cerr << "<testnode name='testnode'> not found" << endl;
return 1;
}
cout << "**** check conf->getNode function [OK] " << endl;
UniXML_iterator it(cnode);
int prop2 = conf->getArgInt("--prop-id2",it.getProp("id2"));
cerr << "**** check conf->getArgInt(arg1,...): " << ( (prop2 == 0) ? "[FAILED]" : "OK" ) << endl;
int prop3 = conf->getArgInt("--prop-dummy",it.getProp("id2"));
cerr << "**** check conf->getArgInt(...,arg2): " << ( (prop3 != -100) ? "[FAILED]" : "OK" ) << endl;
int prop1 = conf->getArgPInt("--prop-id2",it.getProp("id2"),0);
cerr << "**** check conf->getArgPInt(...): " << ( (prop1 == 0) ? "[FAILED]" : "OK" ) << endl;
int prop4 = conf->getArgPInt("--prop-dummy",it.getProp("dummy"),20);
cerr << "**** check conf->getArgPInt(...,...,defval): " << ( (prop4 != 20) ? "[FAILED]" : "OK" ) << endl;
int prop5 = conf->getArgPInt("--prop-dummy",it.getProp("dummy"),0);
cerr << "**** check conf->getArgPInt(...,...,defval): " << ( (prop5 != 0) ? "[FAILED]" : "OK" ) << endl;
return 0;
}
catch(SystemError& err)
{
cerr << "(conftest): " << err << endl;
}
catch(Exception& ex)
{
cerr << "(conftest): " << ex << endl;
}
catch(...)
{
cerr << "(conftest): catch(...)" << endl;
}
return 1;
}
#endif
\ No newline at end of file
#define CATCH_CONFIG_RUNNER #define CATCH_CONFIG_RUNNER
#include <catch.hpp> #include <catch.hpp>
#include <iostream>
#include "Configuration.h" #include "Configuration.h"
int main( int argc, char* argv[] ) int main( int argc, char* argv[] )
{ {
Catch::Session session; Catch::Session session;
try
{
UniSetTypes::uniset_init(argc,argv);
UniSetTypes::uniset_init(argc,argv); int returnCode = session.applyCommandLine( argc, argv, Catch::Session::OnUnusedOptions::Ignore );
if( returnCode != 0 ) // Indicates a command line error
return returnCode;
return session.run();
}
catch( UniSetTypes::Exception& ex )
{
std::cerr << ex << std::endl;
}
int returnCode = session.applyCommandLine( argc, argv, Catch::Session::OnUnusedOptions::Ignore ); return 1;
if( returnCode != 0 ) // Indicates a command line error
return returnCode;
return session.run();
} }
#!/bin/sh #!/bin/sh
# '--' - нужен для отделения аоргументов catch, от наших.. # '--' - нужен для отделения аоргументов catch, от наших..
uniset-start.sh -f ./tests_with_conf -- --confile tests_with_conf.xml --prop-id2 -10 $* uniset-start.sh -f ./tests_with_conf $* -- --confile tests_with_conf.xml --prop-id2 -10
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<!-- Общие(стартовые) параметры по UniSet --> <!-- Общие(стартовые) параметры по UniSet -->
<UniSet> <UniSet>
<NameService host="localhost" port="2809"/> <NameService host="localhost" port="2809"/>
<LocalNode name="LocalhostNode"/> <LocalNode name="localhost"/>
<RootSection name="UNISET_PLC"/> <RootSection name="UNISET_PLC"/>
<CountOfNet name="1"/> <CountOfNet name="1"/>
...@@ -55,8 +55,8 @@ ...@@ -55,8 +55,8 @@
textname - текстовое имя датчика textname - текстовое имя датчика
--> -->
<nodes port="2809"> <nodes port="2809">
<item id="1000" name="LocalhostNode" alias="" textname="Локальный узел" ip="127.0.0.1"/> <item id="1000" name="localhost" alias="" textname="Локальный узел" ip="127.0.0.1"/>
<item id="1001" name="Node2" alias="" textname="Локальный узел" ip="127.0.0.1"/> <item id="1001" name="node2" alias="" textname="Локальный узел" ip="127.0.0.1"/>
</nodes> </nodes>
<!-- ************************ Датчики ********************** --> <!-- ************************ Датчики ********************** -->
......
#include <catch.hpp>
#include <time.h> #include <time.h>
#include "UInterface.h" #include "UInterface.h"
#include "UniSetTypes.h" #include "UniSetTypes.h"
...@@ -5,64 +7,63 @@ ...@@ -5,64 +7,63 @@
using namespace std; using namespace std;
using namespace UniSetTypes; using namespace UniSetTypes;
int main( int argc, const char **argv ) TEST_CASE("UInterface","[UInterface]")
{ {
try CHECK( conf!=0 );
{
uniset_init(argc,argv,"test.xml"); std::string sidName("Input1_S");
UInterface ui;
ObjectId testOID = conf->getObjectID("TestProc");
cout << "** check getSensorID function **" << endl; CHECK( testOID != DefaultObjectId );
ObjectId id1 = conf->getSensorID("Input1_S");
if( id1 != 1 ) ObjectId sid = conf->getSensorID(sidName);
{ CHECK( sid != DefaultObjectId );
cout << "** FAILED! check getSensorID function **" << endl;
return 1; UInterface ui;
}
CHECK( ui.getObjectIndex() != 0 );
cout << "** check getConfIOType function **" << endl; CHECK( ui.getConf() == UniSetTypes::conf );
UniversalIO::IOType t = ui.getConfIOType(id1);
cout << "sensor ID=" << id1 << " iotype=" << t << endl; CHECK( ui.getConfIOType(sid) != UniversalIO::UnknownIOType );
if( t != UniversalIO::DI )
{ REQUIRE_THROWS_AS( ui.getValue(DefaultObjectId), UniSetTypes::ORepFailed );
cout << "** FAILED! check getSensorID function **" << endl; REQUIRE_THROWS_AS( ui.getValue(sid), UniSetTypes::Exception );
return 1; REQUIRE_THROWS_AS( ui.getValue(sid, DefaultObjectId), UniSetTypes::Exception );
} REQUIRE_THROWS_AS( ui.getValue(sid, 100), UniSetTypes::Exception );
int id = conf->getArgInt("--sid"); REQUIRE_THROWS_AS( ui.resolve(sid), UniSetTypes::ORepFailed );
if( id <= 0 ) REQUIRE_THROWS_AS( ui.resolve(sid,10), UniSetTypes::ORepFailed );
{ REQUIRE_THROWS_AS( ui.resolve(sid,DefaultObjectId), UniSetTypes::ORepFailed );
cerr << "unknown sensor ID. Use --sid " << endl;
return 1; TransportMessage tm( SensorMessage(sid,10).transport_msg() );
}
REQUIRE_THROWS_AS( ui.send(testOID,tm), UniSetTypes::Exception );
cout << "** check getChangedTime for ID=" << id << ":" << endl; REQUIRE_THROWS_AS( ui.send(testOID,tm, -20), UniSetTypes::Exception );
REQUIRE_THROWS_AS( ui.send(testOID,tm, DefaultObjectId), UniSetTypes::Exception );
IOController_i::ShortIOInfo inf = ui.getChangedTime(id,conf->getLocalNode()); REQUIRE_THROWS_AS( ui.getChangedTime(sid,-20), UniSetTypes::Exception );
REQUIRE_THROWS_AS( ui.getChangedTime(sid,DefaultObjectId), UniSetTypes::Exception );
struct tm* tms = localtime(&inf.tv_sec); REQUIRE_THROWS_AS( ui.getChangedTime(sid,conf->getLocalNode()), UniSetTypes::Exception );
char t_str[ 150 ]; CHECK_FALSE( ui.isExist(sid) );
strftime( t_str, sizeof(t_str), "%d %b %Y %H:%M:%S", tms ); CHECK_FALSE( ui.isExist(sid,DefaultObjectId) );
CHECK_FALSE( ui.isExist(sid,100) );
cout << "id=" << id
<< " value=" << inf.value CHECK_FALSE( ui.waitReady(sid,100,50) );
<< " last changed: " << string(t_str) << endl; CHECK_FALSE( ui.waitReady(sid,300,50,DefaultObjectId) );
CHECK_FALSE( ui.waitReady(sid,300,50,-20) );
cout << "check getValue: " << ui.getValue(id1) << endl; CHECK_FALSE( ui.waitReady(sid,-1,50) );
cout << "check setValue: id='" << id1 << "' val=2 ..."; CHECK_FALSE( ui.waitReady(sid,300,-1) );
ui.setValue(id1,2);
cout << ( ui.getValue(id1) == 2 ? "OK" : "FAIL" ) << endl; CHECK_FALSE( ui.waitWorking(sid,100,50) );
} CHECK_FALSE( ui.waitWorking(sid,100,50,DefaultObjectId) );
catch( Exception& ex ) CHECK_FALSE( ui.waitWorking(sid,100,50,-20) );
{ CHECK_FALSE( ui.waitWorking(sid,-1,50) );
cout << "(uitest):" << ex << endl; CHECK_FALSE( ui.waitWorking(sid,100,-1) );
}
catch(...) std::string longName("UNISET_PLC/Sensors/" + sidName);
{ CHECK( ui.getIdByName(longName) == sid );
cout << "(uitest): catch ..."<< endl; CHECK( ui.getNameById(sid) == longName );
} CHECK( ui.getTextName(sid) == "Команда 1" );
CHECK( ui.getNodeId("localhost") == 1000 );
return 0;
} }
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