Commit a7486f85 authored by Pavel Vainerman's avatar Pavel Vainerman

(SM): добавил test-lost.xml для тестирования SM с большим количеством датчиков

parent 26590d30
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -244,7 +244,7 @@ void SharedMemory::sysCommand( const SystemMessage* sm )
if( !activated )
{
smcrit << myname << "(sysCommand): Don`t activate! TERMINATE.." << endl;
smcrit << myname << "(sysCommand): Don`t activate [timeout=" << activateTimeout << " msec]! TERMINATE.." << endl;
std::terminate();
}
......
#!/bin/sh
export LD_LIBRARY_PATH="../../lib/.libs;../lib/.libs"
ulimit -Sc 10000000000
./uniset2-start.sh -f ./uniset2-smemory --smemory-id SharedMemory \
--confile test-lost.xml --datfile test-lost.xml --ulog-add-levels system,level1 \
--sm-log-add-levels any $* --sm-run-logserver --activate-timeout 320000
#--pulsar-id DO_C --pulsar-iotype DO --pulsar-msec 100
#--ulog-add-levels info,crit,warn,level9,system \
#--dlog-add-levels info,crit,warn \
../../conf/test-lost.xml
\ No newline at end of file
......@@ -8,6 +8,36 @@ using namespace UniSetTypes;
LostTestProc::LostTestProc( UniSetTypes::ObjectId id, xmlNode* confnode ):
LostTestProc_SK( id, confnode )
{
auto conf = uniset_conf();
UniXML::iterator cit(confnode);
string f_field = conf->getArgParam("--" + argprefix + "filter-field", cit.getProp("filterField"));
string f_value = conf->getArgParam("--" + argprefix + "filter-value", cit.getProp("filterValue"));
xmlNode* snode = conf->getXMLSensorsSection();
if( !snode )
throw SystemError(myname + "(init): Not found <sensors> section?!");
UniXML::iterator it(snode);
if( !it.goChildren() )
throw SystemError(myname + "(init): Section <sensors> empty?!");
for( ; it; it++ )
{
if( !UniSetTypes::check_filter(it, f_field, f_value) )
continue;
if( it.getProp("iotype") != "AI" )
continue;
slist.emplace(it.getIntProp("id"),0);
}
setMaxSizeOfMessageQueue(slist.size()+500);
vmonit(ncycle);
vmonit(waitEmpty);
}
// -----------------------------------------------------------------------------
LostTestProc::~LostTestProc()
......@@ -27,43 +57,99 @@ void LostTestProc::sysCommand( const UniSetTypes::SystemMessage* sm )
if( sm->command == SystemMessage::StartUp || sm->command == SystemMessage::WatchDog )
{
askTimer(tmCheck, checkTime);
// начальная инициализация значений в SM
for( auto&& s: slist )
{
try
{
ui->setValue(s.first,s.second);
}
catch( std::exception& ex )
{
mycrit << myname << "(startUp): " << ex.what() << endl;
}
}
}
}
// -----------------------------------------------------------------------------
void LostTestProc::askSensors(UniversalIO::UIOCommand cmd)
{
for( const auto& s: slist )
askSensor(s.first,cmd);
}
// -----------------------------------------------------------------------------
void LostTestProc::sensorInfo(const SensorMessage* sm)
{
auto s = slist.find(sm->id);
if( s == slist.end() )
{
mycrit << myname << "(sensorInfo): ERROR: message from UNKNOWN SENSOR sm->id=" << sm->id << endl;
UniSetTypes::SimpleInfo_var i = getInfo();
mycrit << i->info << endl;
std::abort();
}
s->second = sm->value;
}
// -----------------------------------------------------------------------------
string LostTestProc::getMonitInfo()
{
ostringstream inf;
inf << "COUNT SENSORS: " << slist.size() << endl;
return std::move(inf.str());
}
// -----------------------------------------------------------------------------
void LostTestProc::timerInfo( const TimerMessage* tm )
{
if( tm->id == tmCheck )
{
try
if( countMessages() > 0 )
{
long smValue = ui->getValue(sensor_s);
if( smValue != in_sensor_s )
mylog1 << myname << ": [WAIT]: count of messages " << countMessages() << endl;
waitEmpty = true;
return;
}
waitEmpty = false;
myinfo << myname << ": [OK]: empty queue. UPDATE VALUE... " << endl;
for( auto&& s: slist )
{
try
{
mycrit << myname << "(check): ERROR!! smValue=" << smValue << " != " << strval(sensor_s) << endl;
//std::terminate();
UniSetTypes::SimpleInfo_var i = getInfo();
mycrit << i->info << endl;
std::abort();
}
long smValue = ui->getValue(s.first);
if( smValue != s.second )
{
cerr << myname << "(check): ERROR!! smValue=" << smValue << " != " << s.second << endl;
UniSetTypes::SimpleInfo_var i = getInfo();
cerr << i->info << endl;
std::abort();
}
// cerr << "sm_value=" << smValue << " save " << (in_sensor_s+1) << endl;
// cerr << "sm_value=" << smValue << " save " << (in_sensor_s+1) << endl;
// Выставляем новое значение
ui->setValue(sensor_s, in_sensor_s+1);
// Выставляем новое значение
ui->setValue(s.first, s.second+1);
// проверяем что сохранилось
smValue = ui->getValue(sensor_s);
// проверяем что сохранилось
smValue = ui->getValue(s.first);
if(ui->getValue(sensor_s) != (in_sensor_s+1) )
if(ui->getValue(s.first) != (s.second+1) )
{
cerr << myname << "(check): SAVE TO SM ERROR!! smValue=" << smValue << endl;
UniSetTypes::SimpleInfo_var i = getInfo();
cerr << i->info << endl;
std::abort();
}
}
catch( std::exception& ex )
{
mycrit << myname << "(check): SAVE TO SM ERROR!! smValue=" << smValue << strval(sensor_s) << endl;
std::abort();
mycrit << myname << "(check): " << ex.what() << endl;
}
}
catch( std::exception& ex )
{
mycrit << myname << "(check): " << ex.what() << endl;
}
myinfo << myname << ": [OK]: UPDATE FINISHED: cycle=" << ++ncycle << endl;
}
}
// -----------------------------------------------------------------------------
......@@ -2,7 +2,7 @@
#ifndef LostTestProc_H_
#define LostTestProc_H_
// -----------------------------------------------------------------------------
#include <vector>
#include <unordered_map>
#include "Debug.h"
#include "LostTestProc_SK.h"
// -----------------------------------------------------------------------------
......@@ -26,6 +26,13 @@ class LostTestProc:
virtual void timerInfo( const UniSetTypes::TimerMessage* tm ) override;
virtual void sysCommand( const UniSetTypes::SystemMessage* sm ) override;
virtual void askSensors( UniversalIO::UIOCommand cmd ) override;
virtual void sensorInfo( const UniSetTypes::SensorMessage* sm ) override;
virtual std::string getMonitInfo() override;
std::unordered_map<UniSetTypes::ObjectId,long> slist;
size_t ncycle = { 0 };
bool waitEmpty = { false };
private:
};
......
......@@ -2,7 +2,23 @@
START=uniset2-start.sh
${START} -f ./sm-lostmessage-test --confile ./test.xml --TestProc1-log-add-levels crit,warn --ulog-add-levels crit $*
LOGS="crit,warn,info"
${START} -f ./sm-lostmessage-test --confile ./test-lost.xml \
--numproc 3 \
--TestProc1-filter-field losttest \
--TestProc1-filter-value 1 \
--TestProc1-sleep-msec 50 \
--TestProc1-log-add-levels $LOGLEVEL \
--TestProc2-filter-field losttest \
--TestProc2-filter-value 2 \
--TestProc2-sleep-msec 50 \
--TestProc2-log-add-levels $LOGLEVEL \
--TestProc3-filter-field losttest \
--TestProc3-filter-value 3 \
--TestProc3-sleep-msec 50 \
--TestProc3-log-add-levels $LOGLEVEL \
--ulog-add-levels crit $*
# --uniset-abort-script ./abort-script-example.sh
#--ulog-add-levels crit,warn,info
......
../../../conf/test-lost.xml
\ No newline at end of file
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