Commit d763dfeb authored by Pavel Vainerman's avatar Pavel Vainerman

(SM): сделал возможность указывать conf-секцию.

parent c125ff4b
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include "NCRestorer.h" #include "NCRestorer.h"
#include "SharedMemory.h" #include "SharedMemory.h"
#include "Extensions.h" #include "Extensions.h"
#include "ORepHelpers.h"
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
using namespace std; using namespace std;
using namespace UniSetTypes; using namespace UniSetTypes;
...@@ -32,7 +31,6 @@ void SharedMemory::help_print( int argc, const char* const* argv ) ...@@ -32,7 +31,6 @@ void SharedMemory::help_print( int argc, const char* const* argv )
cout << "--pulsar-id - датчик 'мигания'" << endl; cout << "--pulsar-id - датчик 'мигания'" << endl;
cout << "--pulsar-msec - период 'мигания'. По умолчанию: 5000." << endl; cout << "--pulsar-msec - период 'мигания'. По умолчанию: 5000." << endl;
cout << "--pulsar-iotype - [DI|DO]тип датчика для 'мигания'. По умолчанию DI." << endl; cout << "--pulsar-iotype - [DI|DO]тип датчика для 'мигания'. По умолчанию DI." << endl;
cout << "--db-logging [1,0] - Включение логирования в DBServer. По умолчанию 0 (выключено)" << endl;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
SharedMemory::SharedMemory( ObjectId id, string datafile, std::string confname ): SharedMemory::SharedMemory( ObjectId id, string datafile, std::string confname ):
...@@ -52,15 +50,13 @@ SharedMemory::SharedMemory( ObjectId id, string datafile, std::string confname ) ...@@ -52,15 +50,13 @@ SharedMemory::SharedMemory( ObjectId id, string datafile, std::string confname )
xmlNode* cnode = conf->getNode(cname); xmlNode* cnode = conf->getNode(cname);
if( cnode == NULL ) if( cnode == NULL )
throw SystemError("Not found conf-node for " + cname ); throw SystemError("Not find conf-node for SharedMemory");
UniXML_iterator it(cnode); UniXML_iterator it(cnode);
// ---------------------- // ----------------------
buildHistoryList(cnode); buildHistoryList(cnode);
signal_change_state().connect(sigc::mem_fun(*this, &SharedMemory::updateHistory)); signal_change_state().connect(sigc::mem_fun(*this, &SharedMemory::updateHistory));
for( History::iterator i=hist.begin(); i!=hist.end(); ++i )
histmap[i->fuse_id].push_back(i);
// ---------------------- // ----------------------
restorer = NULL; restorer = NULL;
NCRestorer_XML* rxml = new NCRestorer_XML(datafile); NCRestorer_XML* rxml = new NCRestorer_XML(datafile);
...@@ -133,11 +129,10 @@ SharedMemory::SharedMemory( ObjectId id, string datafile, std::string confname ) ...@@ -133,11 +129,10 @@ SharedMemory::SharedMemory( ObjectId id, string datafile, std::string confname )
if( !t.empty() ) if( !t.empty() )
{ {
iotypePulsar = UniSetTypes::getIOType(t); iotypePulsar = UniSetTypes::getIOType(t);
if( iotypePulsar == UniversalIO::UnknownIOType || if( iotypePulsar == UniversalIO::UnknownIOType )
iotypePulsar == UniversalIO::AnalogInput || iotypePulsar == UniversalIO::AnalogOutput )
{ {
ostringstream err; ostringstream err;
err << myname << ": Invalid iotype '" << t << "' for pulsar. Must be 'DI' or 'DO'"; err << myname << ": Unknown iotype '" << t << "' for pulsar. Must be 'DI' or 'DO'";
dlog[Debug::CRIT] << myname << "(init): " << err.str() << endl; dlog[Debug::CRIT] << myname << "(init): " << err.str() << endl;
throw SystemError(err.str()); throw SystemError(err.str());
} }
...@@ -529,6 +524,59 @@ bool SharedMemory::readItem( UniXML& xml, UniXML_iterator& it, xmlNode* sec ) ...@@ -529,6 +524,59 @@ bool SharedMemory::readItem( UniXML& xml, UniXML_iterator& it, xmlNode* sec )
return true; return true;
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void SharedMemory::localSaveValue( AIOStateList::iterator& it, const IOController_i::SensorInfo& si,
CORBA::Long newvalue, UniSetTypes::ObjectId sup_id )
{
if( hist.empty() )
{
IONotifyController_LT::localSaveValue( it, si, newvalue, sup_id );
return;
}
uniset_mutex_lock l(hbmutex);
IONotifyController_LT::localSaveValue( it, si, newvalue, sup_id );
}
// ------------------------------------------------------------------------------------------
void SharedMemory::localSaveState( DIOStateList::iterator& it, const IOController_i::SensorInfo& si,
CORBA::Boolean newstate, UniSetTypes::ObjectId sup_id )
{
if( hist.empty() )
{
IONotifyController_LT::localSaveState( it, si, newstate, sup_id );
return;
}
uniset_mutex_lock l(hbmutex);
IONotifyController_LT::localSaveState( it, si, newstate, sup_id );
}
// ------------------------------------------------------------------------------------------
void SharedMemory::localSetState( DIOStateList::iterator& it, const IOController_i::SensorInfo& si,
CORBA::Boolean newstate, UniSetTypes::ObjectId sup_id )
{
if( hist.empty() )
{
IONotifyController_LT::localSetState( it, si, newstate, sup_id );
return;
}
uniset_mutex_lock l(hbmutex);
IONotifyController_LT::localSetState( it, si, newstate, sup_id );
}
// ------------------------------------------------------------------------------------------
void SharedMemory::localSetValue( AIOStateList::iterator& it, const IOController_i::SensorInfo& si,
CORBA::Long value, UniSetTypes::ObjectId sup_id )
{
if( hist.empty() )
{
IONotifyController_LT::localSetValue( it, si, value, sup_id );
return;
}
uniset_mutex_lock l(hbmutex);
IONotifyController_LT::localSetValue( it, si, value, sup_id );
}
// ------------------------------------------------------------------------------------------
SharedMemory* SharedMemory::init_smemory( int argc, const char* const* argv ) SharedMemory* SharedMemory::init_smemory( int argc, const char* const* argv )
{ {
string dfile = conf->getArgParam("--datfile", conf->getConfFileName()); string dfile = conf->getArgParam("--datfile", conf->getConfFileName());
...@@ -798,14 +846,10 @@ void SharedMemory::updateHistory( UniSetTypes::SensorMessage* sm ) ...@@ -798,14 +846,10 @@ void SharedMemory::updateHistory( UniSetTypes::SensorMessage* sm )
<< endl; << endl;
} }
HistoryFuseMap::iterator i = histmap.find(sm->id); for( History::iterator it=hist.begin(); it!=hist.end(); ++it )
if( i == histmap.end() ) {
return; if( sm->id == it->fuse_id )
for( HistoryItList::iterator it1=i->second.begin(); it1!=i->second.end(); ++it1 )
{ {
History::iterator it( (*it1) );
if( sm->sensor_type == UniversalIO::DigitalInput || if( sm->sensor_type == UniversalIO::DigitalInput ||
sm->sensor_type == UniversalIO::DigitalOutput ) sm->sensor_type == UniversalIO::DigitalOutput )
{ {
...@@ -815,8 +859,7 @@ void SharedMemory::updateHistory( UniSetTypes::SensorMessage* sm ) ...@@ -815,8 +859,7 @@ void SharedMemory::updateHistory( UniSetTypes::SensorMessage* sm )
if( dlog.debugging(Debug::INFO) ) if( dlog.debugging(Debug::INFO) )
dlog[Debug::INFO] << myname << "(updateHistory): HISTORY EVENT for " << (*it) << endl; dlog[Debug::INFO] << myname << "(updateHistory): HISTORY EVENT for " << (*it) << endl;
it->fuse_sec = sm->sm_tv_sec; it->fuse_tm = sm->tm;
it->fuse_usec = sm->sm_tv_usec;
m_historySignal.emit( &(*it) ); m_historySignal.emit( &(*it) );
} }
} }
...@@ -831,8 +874,7 @@ void SharedMemory::updateHistory( UniSetTypes::SensorMessage* sm ) ...@@ -831,8 +874,7 @@ void SharedMemory::updateHistory( UniSetTypes::SensorMessage* sm )
if( dlog.debugging(Debug::INFO) ) if( dlog.debugging(Debug::INFO) )
dlog[Debug::INFO] << myname << "(updateHistory): HISTORY EVENT for " << (*it) << endl; dlog[Debug::INFO] << myname << "(updateHistory): HISTORY EVENT for " << (*it) << endl;
it->fuse_sec = sm->sm_tv_sec; it->fuse_tm = sm->tm;
it->fuse_usec = sm->sm_tv_usec;
m_historySignal.emit( &(*it) ); m_historySignal.emit( &(*it) );
} }
} }
...@@ -843,13 +885,13 @@ void SharedMemory::updateHistory( UniSetTypes::SensorMessage* sm ) ...@@ -843,13 +885,13 @@ void SharedMemory::updateHistory( UniSetTypes::SensorMessage* sm )
if( dlog.debugging(Debug::INFO) ) if( dlog.debugging(Debug::INFO) )
dlog[Debug::INFO] << myname << "(updateHistory): HISTORY EVENT for " << (*it) << endl; dlog[Debug::INFO] << myname << "(updateHistory): HISTORY EVENT for " << (*it) << endl;
it->fuse_sec = sm->sm_tv_sec; it->fuse_tm = sm->tm;
it->fuse_usec = sm->sm_tv_usec;
m_historySignal.emit( &(*it) ); m_historySignal.emit( &(*it) );
} }
} }
} }
} }
}
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
std::ostream& operator<<( std::ostream& os, const SharedMemory::HistoryInfo& h ) std::ostream& operator<<( std::ostream& os, const SharedMemory::HistoryInfo& h )
......
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