Commit 4a473ce4 authored by Pavel Vainerman's avatar Pavel Vainerman

Добавил простой тест для проверки работы SMemory и TestProc

parent daa36794
...@@ -33,6 +33,11 @@ ...@@ -33,6 +33,11 @@
</UniSet> </UniSet>
<dlog name="dlog"/> <dlog name="dlog"/>
<settings> <settings>
<TestProc name="TestProc"
on_s="Input1_S"
lamp_c="Lamp58_C"
/>
<IOControl name="IOControl"/> <IOControl name="IOControl"/>
<testnode id="1000" id2="-100" name="testnode"/> <testnode id="1000" id2="-100" name="testnode"/>
<SharedMemory name="SharedMemory" shmID="SharedMemory"> <SharedMemory name="SharedMemory" shmID="SharedMemory">
...@@ -207,6 +212,7 @@ ...@@ -207,6 +212,7 @@
<item id="55" iotype="AI" name="AI55_S" textname="AI sensor 55" rrd="1" rrd1_ds="GAUGE:20:U:U"/> <item id="55" iotype="AI" name="AI55_S" textname="AI sensor 55" rrd="1" rrd1_ds="GAUGE:20:U:U"/>
<item id="56" iotype="AI" name="AI56_S" textname="AI sensor 56" rrd="2" rrd2_ds="COUNTER:20:U:U"/> <item id="56" iotype="AI" name="AI56_S" textname="AI sensor 56" rrd="2" rrd2_ds="COUNTER:20:U:U"/>
<item id="57" iotype="AI" name="AI57_S" textname="AI sensor 57" rrd="2" rrd2_ds="DERIVE:20:U:U"/> <item id="57" iotype="AI" name="AI57_S" textname="AI sensor 57" rrd="2" rrd2_ds="DERIVE:20:U:U"/>
<item id="58" iotype="AO" name="Lamp58_C" textname="Lamp 58" rrd="1" rrd1_ds="GAUGE:20:U:U"/>
</sensors> </sensors>
<thresholds name="thresholds"> <thresholds name="thresholds">
<sensor iotype="AI" name="AI_AS"> <sensor iotype="AI" name="AI_AS">
...@@ -244,6 +250,7 @@ ...@@ -244,6 +250,7 @@
<item id="6009" name="MBMaster2"/> <item id="6009" name="MBMaster2"/>
<item id="6010" name="MBMultiMaster1"/> <item id="6010" name="MBMultiMaster1"/>
<item id="6011" name="RRDServer1"/> <item id="6011" name="RRDServer1"/>
<item id="6012" name="TestProc"/>
</objects> </objects>
</ObjectsMap> </ObjectsMap>
<messages idfromfile="1" name="messages"> <messages idfromfile="1" name="messages">
......
...@@ -260,6 +260,7 @@ AC_CONFIG_FILES([Makefile ...@@ -260,6 +260,7 @@ AC_CONFIG_FILES([Makefile
extensions/RRDServer/Makefile extensions/RRDServer/Makefile
extensions/RRDServer/libUniSetRRDServer.pc extensions/RRDServer/libUniSetRRDServer.pc
extensions/tests/Makefile extensions/tests/Makefile
extensions/tests/SMemoryTest/Makefile
python/lib/Makefile python/lib/Makefile
python/lib/pyUniSet/Makefile python/lib/pyUniSet/Makefile
python/Makefile]) python/Makefile])
......
SUBDIR=SMemoryTest
noinst_PROGRAMS = calibration noinst_PROGRAMS = calibration
calibration_SOURCES = calibration.cc calibration_SOURCES = calibration.cc
......
noinst_PROGRAMS = smemory-test
smemory_test_LDADD = $(top_builddir)/lib/libUniSet.la \
$(top_builddir)/extensions/lib/libUniSetExtensions.la \
$(top_builddir)/extensions/SharedMemory/libUniSetSharedMemory.la \
$(SIGC_LIBS)
smemory_test_CPPFLAGS = -I$(top_builddir)/include \
-I$(top_builddir)/extensions/include \
-I$(top_builddir)/extensions/SharedMemory \
$(SIGC_CFLAGS)
smemory_test_SOURCES = TestProc_SK.cc TestProc.cc smemory-test.cc
TestProc_SK.cc: testproc.src.xml
# ./uniset-codegen --ask -n TestProc --local-include --topdir $(top_builddir)/ --no-main testproc.src.xml
$(top_builddir)/Utilities/codegen/@PACKAGE@-codegen -l $(top_builddir)/Utilities/codegen --ask -n TestProc --local-include --topdir $(top_builddir)/ --no-main testproc.src.xml
clean-local:
rm -rf *_SK.cc *_SK.h
#include "Exceptions.h"
#include "TestProc.h"
// -----------------------------------------------------------------------------
using namespace std;
using namespace UniSetTypes;
// -----------------------------------------------------------------------------
TestProc::TestProc( UniSetTypes::ObjectId id, xmlNode* confnode ):
TestProc_SK( id, confnode ),
state(false)
{
}
// -----------------------------------------------------------------------------
TestProc::~TestProc()
{
}
// -----------------------------------------------------------------------------
TestProc::TestProc():
state(false)
{
cerr << ": init failed!!!!!!!!!!!!!!!"<< endl;
throw Exception();
}
// -----------------------------------------------------------------------------
void TestProc::step()
{
}
// -----------------------------------------------------------------------------
void TestProc::sensorInfo( SensorMessage *sm )
{
if( sm->id == on_s )
{
if( sm->value )
askTimer(tmChange,changeTime);
}
}
// -----------------------------------------------------------------------------
void TestProc::timerInfo( TimerMessage *tm )
{
if( tm->id == tmChange )
{
state^=true;
out_lamp_c = ( state ? lmpBLINK : lmpOFF );
dlog[Debug::INFO] << myname << "(timerInfo): state=" << state << " lmp=" << out_lamp_c << endl;
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
#ifndef TestProc_H_
#define TestProc_H_
// -----------------------------------------------------------------------------
#include "TestProc_SK.h"
// -----------------------------------------------------------------------------
class TestProc:
public TestProc_SK
{
public:
TestProc( UniSetTypes::ObjectId id, xmlNode* confnode = UniSetTypes::conf->getNode("TestProc") );
virtual ~TestProc();
protected:
TestProc();
enum Timers
{
tmChange
};
virtual void step();
void sensorInfo( UniSetTypes::SensorMessage *sm );
void timerInfo( UniSetTypes::TimerMessage *tm );
private:
bool state;
};
// -----------------------------------------------------------------------------
#endif // TestProc_H_
// -----------------------------------------------------------------------------
#include <string>
#include "Debug.h"
#include "ObjectsActivator.h"
#include "SharedMemory.h"
#include "Extensions.h"
#include "TestProc.h"
// --------------------------------------------------------------------------
using namespace std;
using namespace UniSetTypes;
using namespace UniSetExtensions;
// --------------------------------------------------------------------------
int main(int argc, const char **argv)
{
if( argc>1 && ( strcmp(argv[1],"--help")==0 || strcmp(argv[1],"-h")==0 ) )
{
cout << "--confile - Использовать указанный конф. файл. По умолчанию configure.xml" << endl;
SharedMemory::help_print(argc, argv);
return 0;
}
try
{
string confile = UniSetTypes::getArgParam( "--confile", argc, argv, "configure.xml" );
conf = new Configuration(argc, argv, confile);
conf->initDebug(dlog,"dlog");
string logfilename = conf->getArgParam("--logfile", "smemory.log");
string logname( conf->getLogDir() + logfilename );
unideb.logFile( logname );
dlog.logFile( logname );
SharedMemory* shm = SharedMemory::init_smemory(argc, argv);
if( !shm )
return 1;
TestProc tp(conf->getObjectID("TestProc"));
tp.init_dlog(dlog);
ObjectsActivator act;
act.addObject(static_cast<class UniSetObject*>(shm));
act.addObject(static_cast<class UniSetObject*>(&tp));
SystemMessage sm(SystemMessage::StartUp);
act.broadcast( sm.transport_msg() );
act.run(false);
return 0;
}
catch( SystemError& err )
{
unideb[Debug::CRIT] << "(smemory): " << err << endl;
}
catch( Exception& ex )
{
unideb[Debug::CRIT] << "(smemory): " << ex << endl;
}
catch( std::exception& e )
{
unideb[Debug::CRIT] << "(smemory): " << e.what() << endl;
}
catch(...)
{
unideb[Debug::CRIT] << "(smemory): catch(...)" << endl;
}
return 1;
}
#!/bin/sh
START=uniset-start.sh
${START} -f ./smemory-test --confile test.xml --dlog-add-levels any --unideb-add-levels system --localNode LocalhostNode
../../../conf/test.xml
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!--
name - название класса
msgcount - сколько сообщений обрабатывается за один раз
sleep_msec - пауза между итерациями в работе процесса
type
====
in - входные регистры (только для чтения)
out - выходные регистры (запись)
-->
<TestProc>
<settings>
<set name="class-name" val="TestProc"/>
<set name="msg-count" val="30"/>
<set name="sleep-msec" val="150"/>
</settings>
<variables>
<item name="changeTime" type="int" default="2000" min="0" comment="change state time" const="1" public="1" />
</variables>
<smap>
<!-- name - название переменной в конф. файле -->
<item name="on_s" vartype="in" comment="Тестовый вход" smTestID="1"/>
<item name="lamp_c" vartype="out" comment="Лампочка (тестовый выход)"/>
</smap>
<msgmap>
</msgmap>
</TestProc>
...@@ -87,8 +87,6 @@ class UniversalInterface ...@@ -87,8 +87,6 @@ class UniversalInterface
//! Заказ по списку //! Заказ по списку
UniSetTypes::IDSeq_var askSensorsSeq( UniSetTypes::IDList& lst, UniversalIO::UIOCommand cmd, UniSetTypes::IDSeq_var askSensorsSeq( UniSetTypes::IDList& lst, UniversalIO::UIOCommand cmd,
UniSetTypes::ObjectId backid = UniSetTypes::DefaultObjectId ); UniSetTypes::ObjectId backid = UniSetTypes::DefaultObjectId );
// ------------------------------------------------------ // ------------------------------------------------------
//! Получение состояния датчика //! Получение состояния датчика
long getValue ( UniSetTypes::ObjectId id, UniSetTypes::ObjectId node )throw(IO_THROW_EXCEPTIONS); long getValue ( UniSetTypes::ObjectId id, UniSetTypes::ObjectId node )throw(IO_THROW_EXCEPTIONS);
...@@ -98,13 +96,11 @@ class UniversalInterface ...@@ -98,13 +96,11 @@ class UniversalInterface
void setValue ( UniSetTypes::ObjectId id, long value, UniSetTypes::ObjectId node ) throw(IO_THROW_EXCEPTIONS); void setValue ( UniSetTypes::ObjectId id, long value, UniSetTypes::ObjectId node ) throw(IO_THROW_EXCEPTIONS);
void setValue ( UniSetTypes::ObjectId id, long value); void setValue ( UniSetTypes::ObjectId id, long value);
void setValue ( IOController_i::SensorInfo& si, long value, UniSetTypes::ObjectId supplier ); void setValue ( IOController_i::SensorInfo& si, long value, UniSetTypes::ObjectId supplier );
void fastSetValue( IOController_i::SensorInfo& si, long value, UniSetTypes::ObjectId supplier ); void fastSetValue( IOController_i::SensorInfo& si, long value, UniSetTypes::ObjectId supplier );
// установка неопределённого состояния // установка неопределённого состояния
void setUndefinedState( IOController_i::SensorInfo& si, bool undefined, UniSetTypes::ObjectId supplier ); void setUndefinedState( IOController_i::SensorInfo& si, bool undefined, UniSetTypes::ObjectId supplier );
CORBA::Long getRawValue( const IOController_i::SensorInfo& si ); CORBA::Long getRawValue( const IOController_i::SensorInfo& si );
//! калибровка //! калибровка
......
...@@ -50,11 +50,10 @@ int main( int argc, const char **argv ) ...@@ -50,11 +50,10 @@ int main( int argc, const char **argv )
<< " value=" << inf.value << " value=" << inf.value
<< " last changed: " << string(t_str) << endl; << " last changed: " << string(t_str) << endl;
cout << "check getValue: " << ui.getValue(id1) << endl; cout << "check getValue: " << ui.getValue(id1) << endl;
cout << "check setValue: id='" << id1 << "' val=2" << endl; cout << "check setValue: id='" << id1 << "' val=2 ...";
ui.setValue(id1,2,DefaultObjectId); ui.setValue(id1,2);
cout << "OK" << endl; cout << ( ui.getValue(id1) == 2 ? "OK" : "FAIL" ) << endl;
} }
catch( Exception& ex ) catch( Exception& ex )
{ {
......
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