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

(SM): добавил процесс для попытки найти проблемму потери сообщений..

parent c8dde088
......@@ -39,6 +39,9 @@
<LogServer name="smplus" port="3333" host="localhost" />
<settings>
<LostTestProc name="TestProc1" sensor_s="Input4_S"/>
<TestProc name="TestProc1"
on_s="Input1_S"
lamp_c="Lamp58_C"
......
#include <iomanip>
#include "Exceptions.h"
#include "LostTestProc.h"
// -----------------------------------------------------------------------------
using namespace std;
using namespace UniSetTypes;
// -----------------------------------------------------------------------------
LostTestProc::LostTestProc( UniSetTypes::ObjectId id, xmlNode* confnode ):
LostTestProc_SK( id, confnode )
{
}
// -----------------------------------------------------------------------------
LostTestProc::~LostTestProc()
{
}
// -----------------------------------------------------------------------------
LostTestProc::LostTestProc()
{
cerr << ": init failed!!!!!!!!!!!!!!!" << endl;
throw UniSetTypes::Exception(myname+"(init): FAILED..");
}
// -----------------------------------------------------------------------------
void LostTestProc::sysCommand( const UniSetTypes::SystemMessage* sm )
{
LostTestProc_SK::sysCommand(sm);
if( sm->command == SystemMessage::StartUp || sm->command == SystemMessage::WatchDog )
{
askTimer(tmCheck, checkTime);
}
}
// -----------------------------------------------------------------------------
void LostTestProc::timerInfo( const TimerMessage* tm )
{
if( tm->id == tmCheck )
{
try
{
long smValue = ui->getValue(sensor_s);
if( smValue != in_sensor_s )
{
mycrit << myname << "(check): ERROR!! smValue=" << smValue << " != " << strval(sensor_s) << endl;
//std::terminate();
UniSetTypes::SimpleInfo_var i = getInfo();
mycrit << i->info << endl;
std::abort();
}
// cerr << "sm_value=" << smValue << " save " << (in_sensor_s+1) << endl;
// Выставляем новое значение
ui->setValue(sensor_s, in_sensor_s+1);
// проверяем что сохранилось
smValue = ui->getValue(sensor_s);
if(ui->getValue(sensor_s) != (in_sensor_s+1) )
{
mycrit << myname << "(check): SAVE TO SM ERROR!! smValue=" << smValue << strval(sensor_s) << endl;
std::abort();
}
}
catch( std::exception& ex )
{
mycrit << myname << "(check): " << ex.what() << endl;
}
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
#ifndef LostTestProc_H_
#define LostTestProc_H_
// -----------------------------------------------------------------------------
#include <vector>
#include "Debug.h"
#include "LostTestProc_SK.h"
// -----------------------------------------------------------------------------
/* Цель: поймать расхождение значения в SM и в in_-переменной в процессе.
* Тест: Каждые checkTime проверяем текущее значение в SM и в процессе, меняем в SM и опять проверяем.
*/
class LostTestProc:
public LostTestProc_SK
{
public:
LostTestProc( UniSetTypes::ObjectId id, xmlNode* confnode = UniSetTypes::uniset_conf()->getNode("LostTestProc") );
virtual ~LostTestProc();
protected:
LostTestProc();
enum Timers
{
tmCheck
};
virtual void timerInfo( const UniSetTypes::TimerMessage* tm ) override;
virtual void sysCommand( const UniSetTypes::SystemMessage* sm ) override;
private:
};
// -----------------------------------------------------------------------------
#endif // LostTestProc_H_
// -----------------------------------------------------------------------------
noinst_PROGRAMS = smemory-test
noinst_PROGRAMS = smemory-test sm-lostmessage-test
smemory_test_LDADD = $(top_builddir)/lib/libUniSet2.la \
$(top_builddir)/extensions/lib/libUniSet2Extensions.la \
$(top_builddir)/extensions/SharedMemory/libUniSet2SharedMemory.la \
......@@ -9,11 +9,25 @@ smemory_test_CPPFLAGS = -I$(top_builddir)/include \
$(SIGC_CFLAGS) $(POCO_CFLAGS)
smemory_test_SOURCES = TestProc_SK.cc TestProc.cc smemory-test.cc
BUILT_SOURCES=TestProc_SK.cc TestProc_SK.h
BUILT_SOURCES=TestProc_SK.cc TestProc_SK.h LostTestProc_SK.cc LostTestProc_SK.h
TestProc_SK.cc TestProc_SK.h: testproc.src.xml
$(SHELL) $(top_builddir)/Utilities/codegen/@PACKAGE@-codegen -l $(top_builddir)/Utilities/codegen --ask -n TestProc --local-include --topdir $(top_builddir)/ --no-main testproc.src.xml
LostTestProc_SK.cc LostTestProc_SK.h: losttestproc.src.xml
$(SHELL) $(top_builddir)/Utilities/codegen/@PACKAGE@-codegen -l $(top_builddir)/Utilities/codegen --ask -n LostTestProc --local-include --topdir $(top_builddir)/ --no-main losttestproc.src.xml
sm_lostmessage_test_LDADD = $(top_builddir)/lib/libUniSet2.la \
$(top_builddir)/extensions/lib/libUniSet2Extensions.la \
$(top_builddir)/extensions/SharedMemory/libUniSet2SharedMemory.la \
$(SIGC_LIBS) $(POCO_LIBS)
sm_lostmessage_test_CPPFLAGS = -I$(top_builddir)/include \
-I$(top_builddir)/extensions/include \
-I$(top_builddir)/extensions/SharedMemory \
$(SIGC_CFLAGS) $(POCO_CFLAGS)
sm_lostmessage_test_SOURCES = LostTestProc_SK.cc LostTestProc.cc sm-lostmessage-test.cc
clean-local:
rm -rf *_SK.cc *_SK.h
......
#include <string>
#include "Debug.h"
#include "UniSetActivator.h"
#include "SharedMemory.h"
#include "Extensions.h"
#include "LostTestProc.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
{
auto conf = uniset_init(argc, argv);
auto act = UniSetActivator::Instance();
int num = conf->getArgPInt("--numproc", 1);
for( int i = 1; i <= num; i++ )
{
ostringstream s;
s << "TestProc" << i;
cout << "..create " << s.str() << endl;
auto tp = make_shared<LostTestProc>( conf->getObjectID(s.str()));
// tp->init_dlog(dlog());
act->add(tp);
}
SystemMessage sm(SystemMessage::StartUp);
act->broadcast( sm.transport_msg() );
act->run(false);
return 0;
}
catch( const SystemError& err )
{
cerr << "(lostmessage-test): " << err << endl;
}
catch( const UniSetTypes::Exception& ex )
{
cerr << "(lostmessage-test): " << ex << endl;
}
catch( const std::exception& e )
{
cerr << "(lostmessage-test): " << e.what() << endl;
}
catch(...)
{
cerr << "(lostmessage-test): catch(...)" << endl;
}
return 1;
}
#!/bin/sh
START=uniset2-start.sh
${START} -f ./sm-lostmessage-test --confile ./test.xml --TestProc1-log-add-levels crit,warn --ulog-add-levels crit $*
# --uniset-abort-script ./abort-script-example.sh
#--ulog-add-levels crit,warn,info
#system,level2,level8,level9
......@@ -192,6 +192,10 @@ extensions/tests/SMemoryTest/test.xml
extensions/tests/SMemoryTest/TestProc.cc
extensions/tests/SMemoryTest/TestProc.h
extensions/tests/SMemoryTest/testproc.src.xml
extensions/tests/SMemoryTest/LostTestProc.cc
extensions/tests/SMemoryTest/LostTestProc.h
extensions/tests/SMemoryTest/losttestproc.src.xml
extensions/tests/SMemoryTest/sm-lostmessage-test.cc
extensions/tests/SMemoryTest/Makefile.am
extensions/tests/MBSlaveTest/mbslave-test.cc
extensions/tests/MBSlaveTest/test.xml
......
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