Commit 4139b7d7 authored by Pavel Vainerman's avatar Pavel Vainerman

add getConfIOType function to UniversalInterface.

parent ce4ba08d
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
Name: libuniset Name: libuniset
Version: 0.97 Version: 0.97
Release: eter58 Release: eter59
Summary: UniSet - library for building distributed industrial control systems Summary: UniSet - library for building distributed industrial control systems
License: GPL License: GPL
Group: Development/C++ Group: Development/C++
......
...@@ -107,6 +107,7 @@ namespace UniSetTypes ...@@ -107,6 +107,7 @@ namespace UniSetTypes
xmlNode* getXMLObjectsSection(); xmlNode* getXMLObjectsSection();
xmlNode* getXMLControllersSection(); xmlNode* getXMLControllersSection();
xmlNode* getXMLServicesSection(); xmlNode* getXMLServicesSection();
xmlNode* getObjectInfo( UniSetTypes::ObjectId );
// net // net
inline unsigned int getCountOfNet() const { return countOfNet; } inline unsigned int getCountOfNet() const { return countOfNet; }
......
...@@ -118,9 +118,14 @@ namespace UniSetTypes ...@@ -118,9 +118,14 @@ namespace UniSetTypes
/*! */ /*! */
struct ObjectInfo struct ObjectInfo
{ {
ObjectInfo():
id(DefaultObjectId),
repName(0),textName(0),data(0){}
ObjectId id; /*!< */ ObjectId id; /*!< */
char* repName; /*!< */ char* repName; /*!< */
char* textName; /*!< */ char* textName; /*!< */
void* data;
}; };
typedef std::list<NodeInfo> ListOfNode; typedef std::list<NodeInfo> ListOfNode;
......
...@@ -196,6 +196,9 @@ class UniversalInterface ...@@ -196,6 +196,9 @@ class UniversalInterface
UniSetTypes::ObjectType getType(UniSetTypes::ObjectId id, UniSetTypes::ObjectId node) throw(IO_THROW_EXCEPTIONS); UniSetTypes::ObjectType getType(UniSetTypes::ObjectId id, UniSetTypes::ObjectId node) throw(IO_THROW_EXCEPTIONS);
UniSetTypes::ObjectType getType(UniSetTypes::ObjectId id); UniSetTypes::ObjectType getType(UniSetTypes::ObjectId id);
// read from xml (only for xml!)
UniversalIO::IOTypes getConfIOType( UniSetTypes::ObjectId id );
IOController_i::ShortIOInfo getChangedTime( UniSetTypes::ObjectId id, UniSetTypes::ObjectId node ); IOController_i::ShortIOInfo getChangedTime( UniSetTypes::ObjectId id, UniSetTypes::ObjectId node );
IOController_i::ShortMapSeq* getSensors( UniSetTypes::ObjectId id, IOController_i::ShortMapSeq* getSensors( UniSetTypes::ObjectId id,
UniSetTypes::ObjectId node=UniSetTypes::conf->getLocalNode() ); UniSetTypes::ObjectId node=UniSetTypes::conf->getLocalNode() );
......
...@@ -3101,3 +3101,17 @@ bool UniversalInterface::waitWorking( UniSetTypes::ObjectId id, int msec, int pm ...@@ -3101,3 +3101,17 @@ bool UniversalInterface::waitWorking( UniSetTypes::ObjectId id, int msec, int pm
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
UniversalIO::IOTypes UniversalInterface::getConfIOType( UniSetTypes::ObjectId id )
{
if( !conf )
return UniversalIO::UnknownIOType;
xmlNode* x = conf->getObjectInfo(id);
if( !x )
return UniversalIO::UnknownIOType;
UniXML_iterator it(x);
return UniSetTypes::getIOType( it.getProp("iotype") );
}
// -----------------------------------------------------------------------------
...@@ -189,6 +189,8 @@ unsigned int ObjectIndex_XML::read_section( UniXML& xml, const std::string sec, ...@@ -189,6 +189,8 @@ unsigned int ObjectIndex_XML::read_section( UniXML& xml, const std::string sec,
omap[ind].textName = new char[textname.size()+1]; omap[ind].textName = new char[textname.size()+1];
strcpy( omap[ind].textName, textname.c_str() ); strcpy( omap[ind].textName, textname.c_str() );
omap[ind].data = (void*)(xmlNode*)it;
// cout << "read: " << "(" << ind << ") " << omap[ind].repName << "\t" << omap[ind].textName << endl; // cout << "read: " << "(" << ind << ") " << omap[ind].repName << "\t" << omap[ind].textName << endl;
ind++; ind++;
...@@ -257,6 +259,7 @@ unsigned int ObjectIndex_XML::read_nodes( UniXML& xml, const std::string sec, un ...@@ -257,6 +259,7 @@ unsigned int ObjectIndex_XML::read_nodes( UniXML& xml, const std::string sec, un
omap[ind].textName = new char[textname.size()+1]; omap[ind].textName = new char[textname.size()+1];
strcpy( omap[ind].textName, textname.c_str() ); strcpy( omap[ind].textName, textname.c_str() );
omap[ind].data = (void*)(xmlNode*)(it);
// //
mok[omap[ind].repName] = ind; mok[omap[ind].repName] = ind;
......
...@@ -157,6 +157,9 @@ void ObjectIndex_idXML::read_section( UniXML& xml, const std::string sec ) ...@@ -157,6 +157,9 @@ void ObjectIndex_idXML::read_section( UniXML& xml, const std::string sec )
inf.textName = new char[textname.size()+1]; inf.textName = new char[textname.size()+1];
strcpy( inf.textName, textname.c_str() ); strcpy( inf.textName, textname.c_str() );
inf.data = (void*)(xmlNode*)(it);
omap[inf.id] = inf; omap[inf.id] = inf;
} }
} }
...@@ -212,6 +215,8 @@ void ObjectIndex_idXML::read_nodes( UniXML& xml, const std::string sec ) ...@@ -212,6 +215,8 @@ void ObjectIndex_idXML::read_nodes( UniXML& xml, const std::string sec )
inf.textName = new char[textname.size()+1]; inf.textName = new char[textname.size()+1];
strcpy( inf.textName, textname.c_str() ); strcpy( inf.textName, textname.c_str() );
inf.data = (void*)(xmlNode*)(it);
omap[inf.id] = inf; omap[inf.id] = inf;
} }
} }
......
...@@ -1012,6 +1012,15 @@ xmlNode* Configuration::getXMLServicesSection() ...@@ -1012,6 +1012,15 @@ xmlNode* Configuration::getXMLServicesSection()
return xmlServicesSec; return xmlServicesSec;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
xmlNode* Configuration::getObjectInfo( UniSetTypes::ObjectId id )
{
const ObjectInfo* i = oind->getObjectInfo(id);
if( i )
return (xmlNode*)(i->data);
return 0;
}
// -------------------------------------------------------------------------
void uniset_init( int argc, const char* const* argv, const std::string xmlfile ) void uniset_init( int argc, const char* const* argv, const std::string xmlfile )
{ {
string confile = UniSetTypes::getArgParam( "--confile", argc, argv, xmlfile ); string confile = UniSetTypes::getArgParam( "--confile", argc, argv, xmlfile );
......
...@@ -11,6 +11,25 @@ int main( int argc, const char **argv ) ...@@ -11,6 +11,25 @@ int main( int argc, const char **argv )
{ {
uniset_init(argc,argv,"test.xml"); uniset_init(argc,argv,"test.xml");
UniversalInterface ui;
cout << "** check getSensorID function **" << endl;
ObjectId id1 = conf->getSensorID("Input1_S");
if( id1 != 1 )
{
cout << "** FAILED! check getSensorID function **" << endl;
return 1;
}
cout << "** check getConfIOType function **" << endl;
UniversalIO::IOTypes t = ui.getConfIOType(id1);
cout << "sensor ID=" << id1 << " iotype=" << t << endl;
if( t != UniversalIO::DigitalInput )
{
cout << "** FAILED! check getSensorID function **" << endl;
return 1;
}
int id = conf->getArgInt("--sid"); int id = conf->getArgInt("--sid");
if( id <= 0 ) if( id <= 0 )
...@@ -19,9 +38,8 @@ int main( int argc, const char **argv ) ...@@ -19,9 +38,8 @@ int main( int argc, const char **argv )
return 1; return 1;
} }
UniversalInterface ui;
cout << "getChangedTime for ID=" << id << ":" << endl; cout << "** check getChangedTime for ID=" << id << ":" << endl;
IOController_i::ShortIOInfo inf = ui.getChangedTime(id,conf->getLocalNode()); IOController_i::ShortIOInfo inf = ui.getChangedTime(id,conf->getLocalNode());
...@@ -33,6 +51,7 @@ int main( int argc, const char **argv ) ...@@ -33,6 +51,7 @@ int main( int argc, const char **argv )
cout << "id=" << id cout << "id=" << id
<< " value=" << inf.value << " value=" << inf.value
<< " last changed: " << string(t_str) << endl; << " last changed: " << string(t_str) << 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