Commit 49939803 authored by Pavel Vainerman's avatar Pavel Vainerman

(LogicProcessor): исправил баг с определением iotype датчика

parent ec61eb32
......@@ -3,7 +3,7 @@
Name: libuniset
Version: 1.0
Release: alt59
Release: alt60
Summary: UniSet - library for building distributed industrial control systems
License: GPL
Group: Development/C++
......@@ -213,6 +213,9 @@ rm -f %buildroot%_libdir/*.la
%changelog
* Wed Dec 21 2011 Pavel Vainerman <pv@altlinux.ru> 1.0-alt60
- fixed bug in LogicProcessor
* Mon Dec 19 2011 Pavel Vainerman <pv@altlinux.ru> 1.0-alt59
- add precision for output variables
......
#include <iostream>
#include "Configuration.h"
#include "Extensions.h"
#include "LProcessor.h"
// -------------------------------------------------------------------------
using namespace std;
using namespace UniSetTypes;
using namespace UniSetExtensions;
// -------------------------------------------------------------------------
LProcessor::LProcessor()
{
......@@ -26,15 +28,15 @@ void LProcessor::execute( const string lfile )
}
catch( LogicException& ex )
{
cerr << "(LProcessor::execute): " << ex << endl;
dlog[Debug::CRIT] << "(LProcessor::execute): " << ex << endl;
}
catch( Exception& ex )
{
cerr << "(LProcessor::execute): " << ex << endl;
dlog[Debug::CRIT] << "(LProcessor::execute): " << ex << endl;
}
catch(...)
{
cerr << "(LProcessor::execute): catch...\n";
dlog[Debug::CRIT] << "(LProcessor::execute): catch...\n";
}
msleep(sleepTime);
}
......@@ -58,7 +60,7 @@ void LProcessor::build( const string& lfile )
UniSetTypes::ObjectId sid = conf->getSensorID(it->name);
if( sid == DefaultObjectId )
{
cerr << "НЕ НАЙДЕН ИДЕНТИФИКАТОР ДАТЧИКА: " << it->name << endl;
dlog[Debug::CRIT] << "НЕ НАЙДЕН ИДЕНТИФИКАТОР ДАТЧИКА: " << it->name << endl;
continue;
}
......@@ -66,7 +68,12 @@ void LProcessor::build( const string& lfile )
ei.sid = sid;
ei.state = false;
ei.lnk = &(*it);
ei.iotype = UniversalIO::UnknownIOType;
ei.iotype = conf->getIOType(sid);
if( ei.iotype == UniversalIO::UnknownIOType )
{
dlog[Debug::CRIT] << "Unkown iotype for sid=" << sid << "(" << it->name << ")" << endl;
continue;
}
extInputs.push_front(ei);
}
......@@ -75,14 +82,19 @@ void LProcessor::build( const string& lfile )
UniSetTypes::ObjectId sid = conf->getSensorID(it->name);
if( sid == DefaultObjectId )
{
cerr << "НЕ НАЙДЕН ИДЕНТИФИКАТОР ВЫХОДА: " << it->name << endl;
dlog[Debug::CRIT] << "НЕ НАЙДЕН ИДЕНТИФИКАТОР ВЫХОДА: " << it->name << endl;
continue;
}
EXTOutInfo ei;
ei.sid = sid;
ei.lnk = &(*it);
ei.iotype = UniversalIO::UnknownIOType;
ei.iotype = conf->getIOType(sid);
if( ei.iotype == UniversalIO::UnknownIOType )
{
dlog[Debug::CRIT] << "Unkown iotype for sid=" << sid << "(" << it->name << ")" << endl;
continue;
}
extOuts.push_front(ei);
}
......@@ -135,17 +147,17 @@ void LProcessor::setOuts()
break;
default:
cerr << "(LProcessor::setOuts): неподдерживаемый тип iotype=" << it->iotype << endl;
dlog[Debug::CRIT] << "(LProcessor::setOuts): неподдерживаемый тип iotype=" << it->iotype << endl;
break;
}
}
catch( Exception& ex )
{
cerr << "(LProcessor::setOuts): " << ex << endl;
dlog[Debug::CRIT] << "(LProcessor::setOuts): " << ex << endl;
}
catch(...)
{
cerr << "(LProcessor::setOuts): catch...\n";
dlog[Debug::CRIT] << "(LProcessor::setOuts): catch...\n";
}
}
}
......
......@@ -90,7 +90,7 @@ void PassiveLProcessor::sysCommand( UniSetTypes::SystemMessage *sm )
{
if( !shm->waitSMready(10000) )
{
cerr << "(ERR): SM not ready. Terminated... " << endl;
dlog[Debug::CRIT] << "(ERR): SM not ready. Terminated... " << endl;
raise(SIGTERM);
return;
}
......@@ -163,17 +163,17 @@ void PassiveLProcessor::setOuts()
break;
default:
cerr << "(LProcessor::setOuts): неподдерживаемый тип iotype=" << it->iotype << endl;
dlog[Debug::CRIT] << "(LProcessor::setOuts): неподдерживаемый тип iotype=" << it->iotype << endl;
break;
}
}
catch( Exception& ex )
{
cerr << "(LProcessor::setOuts): " << ex << endl;
dlog[Debug::CRIT] << "(LProcessor::setOuts): " << ex << endl;
}
catch(...)
{
cerr << "(LProcessor::setOuts): catch...\n";
dlog[Debug::CRIT] << "(LProcessor::setOuts): catch...\n";
}
}
}
......@@ -195,17 +195,17 @@ void PassiveLProcessor::sigterm( int signo )
break;
default:
cerr << "(LProcessor::sigterm): неподдерживаемый тип iotype=" << it->iotype << endl;
dlog[Debug::CRIT] << "(LProcessor::sigterm): неподдерживаемый тип iotype=" << it->iotype << endl;
break;
}
}
catch( Exception& ex )
{
cerr << "(LProcessor::sigterm): " << ex << endl;
dlog[Debug::CRIT] << "(LProcessor::sigterm): " << ex << endl;
}
catch(...)
{
cerr << "(LProcessor::sigterm): catch...\n";
dlog[Debug::CRIT] << "(LProcessor::sigterm): catch...\n";
}
}
}
......@@ -243,7 +243,7 @@ void PassiveLProcessor::processingMessage( UniSetTypes::VoidMessage* msg )
}
catch(Exception& ex)
{
cout << myname << "(processingMessage): " << ex << endl;
dlog[Debug::CRIT] << myname << "(processingMessage): " << ex << endl;
}
}
// -----------------------------------------------------------------------------
#include <iostream>
#include "Extensions.h"
#include "Element.h"
// -------------------------------------------------------------------------
using namespace std;
using namespace UniSetExtensions;
// -------------------------------------------------------------------------
TAND::TAND(ElementID id, int num, bool st):
TOR(id,num,st)
......@@ -46,7 +47,9 @@ void TAND::setIn( int num, bool state )
if( !brk )
myout = true;
cout << this << ": myout " << myout << endl;
if( dlog.debugging(Debug::INFO) )
dlog[Debug::INFO] << this << ": myout " << myout << endl;
if( prev != myout )
Element::setChildOut();
}
......
#include <iostream>
#include "Extensions.h"
#include "TDelay.h"
// -------------------------------------------------------------------------
using namespace std;
using namespace UniSetExtensions;
// -------------------------------------------------------------------------
TDelay::TDelay( Element::ElementID id, int delayMS, int inCount):
Element(id),
......@@ -28,7 +30,8 @@ void TDelay::setIn( int num, bool state )
{
pt.setTiming(0); // reset timer
myout = false;
cout << this << ": set " << myout << endl;
if( dlog.debugging(Debug::INFO) )
dlog[Debug::INFO] << this << ": set " << myout << endl;
if( prev != myout )
Element::setChildOut();
return;
......@@ -41,7 +44,8 @@ void TDelay::setIn( int num, bool state )
{
pt.setTiming(0); // reset timer
myout = true;
cout << this << ": set " << myout << endl;
if( dlog.debugging(Debug::INFO) )
dlog[Debug::INFO] << this << ": set " << myout << endl;
if( prev != myout )
Element::setChildOut();
return;
......@@ -50,7 +54,8 @@ void TDelay::setIn( int num, bool state )
// засекаем, если ещё не установлен таймер
if( !myout && !prev ) // т.е. !myout && prev != myout
{
cout << this << ": set timer " << delay << " [msec]" << endl;
if( dlog.debugging(Debug::INFO) )
dlog[Debug::INFO] << this << ": set timer " << delay << " [msec]" << endl;
pt.setTiming(delay);
}
}
......@@ -61,7 +66,8 @@ void TDelay::tick()
{
myout = true;
pt.setTiming(0); // reset timer
cout << getType() << "(" << myid << "): TIMER!!!! myout=" << myout << endl;
if( dlog.debugging(Debug::INFO) )
dlog[Debug::INFO] << getType() << "(" << myid << "): TIMER!!!! myout=" << myout << endl;
Element::setChildOut();
}
}
......
#include <sstream>
#include <iostream>
#include "Extensions.h"
#include "Element.h"
// -------------------------------------------------------------------------
using namespace std;
using namespace UniSetExtensions;
// -------------------------------------------------------------------------
TNOT::TNOT( ElementID id, bool out_default ):
Element(id),
......@@ -21,7 +22,9 @@ void TNOT::setIn( int num, bool state )
bool prev = myout;
myout = !state;
cout << this << ": myout " << myout << endl;
if( dlog.debugging(Debug::INFO) )
dlog[Debug::INFO] << this << ": myout " << myout << endl;
if( prev != myout )
Element::setChildOut();
}
......
#include <sstream>
#include <iostream>
#include "Extensions.h"
#include "Element.h"
// -------------------------------------------------------------------------
using namespace std;
using namespace UniSetExtensions;
// -------------------------------------------------------------------------
TOR::TOR(ElementID id, int num, bool st):
Element(id),
......@@ -59,7 +60,8 @@ void TOR::setIn( int num, bool state )
if( !brk )
myout = false;
cout << this << ": myout " << myout << endl;
if( dlog.debugging(Debug::INFO) )
dlog[Debug::INFO] << this << ": myout " << myout << endl;
if( prev != myout )
Element::setChildOut();
}
......
#!/bin/sh
uniset-start.sh -f ./uniset-logicproc --confile test.xml --unideb-add-levels info,crit,warn,level9,system
uniset-start.sh -f ./uniset-logicproc --confile test.xml --schema schema.xml --unideb-add-levels any --dlog-add-levels any
#!/bin/sh
uniset-start.sh -f ./uniset-plogicproc --schema schema.xml \
uniset-start.sh -g ./uniset-plogicproc --schema schema.xml \
--smemory-id SharedMemory --name LProcessor \
--confile test.xml --unideb-add-levels info,crit,warn,level9,system
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