Commit b25663ab authored by Pavel Vainerman's avatar Pavel Vainerman

Добавил функцию getIOType..

parent 1cefdb27
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
Name: libuniset Name: libuniset
Version: 0.99 Version: 0.99
Release: eter7 Release: eter8
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++
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# See doc: http://www.gnu.org/software/hello/manual/autoconf/Generic-Programs.html # See doc: http://www.gnu.org/software/hello/manual/autoconf/Generic-Programs.html
# AC_PREREQ(2.59) # AC_PREREQ(2.59)
AC_INIT([uniset], [0.99.1], pv@etersoft.ru) AC_INIT([uniset], [0.99.2], pv@etersoft.ru)
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME,AC_PACKAGE_VERSION) AM_INIT_AUTOMAKE(AC_PACKAGE_NAME,AC_PACKAGE_VERSION)
# AC_CONFIG_MACRO_DIR([m4]) # AC_CONFIG_MACRO_DIR([m4])
...@@ -30,7 +30,7 @@ AC_ENABLE_SHARED(yes) ...@@ -30,7 +30,7 @@ AC_ENABLE_SHARED(yes)
AC_ENABLE_STATIC(no) AC_ENABLE_STATIC(no)
AM_PROG_LIBTOOL AM_PROG_LIBTOOL
LIBVER=0:9:0 LIBVER=0:9:2
AC_SUBST(LIBVER) AC_SUBST(LIBVER)
# Checks for libraries. # Checks for libraries.
......
...@@ -110,6 +110,8 @@ namespace UniSetTypes ...@@ -110,6 +110,8 @@ namespace UniSetTypes
xmlNode* getXMLServicesSection(); xmlNode* getXMLServicesSection();
xmlNode* getXMLNodesSection(); xmlNode* getXMLNodesSection();
xmlNode* getXMLObjectNode( UniSetTypes::ObjectId ); xmlNode* getXMLObjectNode( UniSetTypes::ObjectId );
UniversalIO::IOTypes getIOType( UniSetTypes::ObjectId );
UniversalIO::IOTypes getIOType( const std::string name );
// net // net
inline unsigned int getCountOfNet() const { return countOfNet; } inline unsigned int getCountOfNet() const { return countOfNet; }
......
...@@ -42,6 +42,7 @@ class ObjectIndex ...@@ -42,6 +42,7 @@ class ObjectIndex
// info // info
virtual const ObjectInfo* getObjectInfo( const ObjectId )=0; virtual const ObjectInfo* getObjectInfo( const ObjectId )=0;
virtual const ObjectInfo* getObjectInfo( const std::string name )=0;
// создание полного имени в репозитории по паре имя:узел // создание полного имени в репозитории по паре имя:узел
static std::string mkRepName( const std::string repname, const std::string nodename ); static std::string mkRepName( const std::string repname, const std::string nodename );
......
...@@ -48,6 +48,7 @@ class ObjectIndex_Array: ...@@ -48,6 +48,7 @@ class ObjectIndex_Array:
virtual const ObjectInfo* getObjectInfo(const ObjectId); virtual const ObjectInfo* getObjectInfo(const ObjectId);
virtual const ObjectInfo* getObjectInfo( const std::string name );
virtual ObjectId getIdByName(const std::string& name); virtual ObjectId getIdByName(const std::string& name);
virtual std::string getMapName(const ObjectId id); virtual std::string getMapName(const ObjectId id);
virtual std::string getTextName(const ObjectId id); virtual std::string getTextName(const ObjectId id);
......
...@@ -47,7 +47,8 @@ class ObjectIndex_XML: ...@@ -47,7 +47,8 @@ class ObjectIndex_XML:
ObjectIndex_XML(UniXML& xml, int minSize=1000 ); ObjectIndex_XML(UniXML& xml, int minSize=1000 );
virtual ~ObjectIndex_XML(); virtual ~ObjectIndex_XML();
virtual const ObjectInfo* getObjectInfo(const ObjectId); virtual const UniSetTypes::ObjectInfo* getObjectInfo(const ObjectId);
virtual const UniSetTypes::ObjectInfo* getObjectInfo( const std::string name );
virtual ObjectId getIdByName(const std::string& name); virtual ObjectId getIdByName(const std::string& name);
virtual std::string getMapName(const ObjectId id); virtual std::string getMapName(const ObjectId id);
virtual std::string getTextName(const ObjectId id); virtual std::string getTextName(const ObjectId id);
......
...@@ -17,6 +17,7 @@ class ObjectIndex_idXML: ...@@ -17,6 +17,7 @@ class ObjectIndex_idXML:
virtual ~ObjectIndex_idXML(); virtual ~ObjectIndex_idXML();
virtual const UniSetTypes::ObjectInfo* getObjectInfo( const UniSetTypes::ObjectId ); virtual const UniSetTypes::ObjectInfo* getObjectInfo( const UniSetTypes::ObjectId );
virtual const UniSetTypes::ObjectInfo* getObjectInfo( const std::string name );
virtual UniSetTypes::ObjectId getIdByName( const std::string& name ); virtual UniSetTypes::ObjectId getIdByName( const std::string& name );
virtual std::string getMapName( const UniSetTypes::ObjectId id ); virtual std::string getMapName( const UniSetTypes::ObjectId id );
virtual std::string getTextName( const UniSetTypes::ObjectId id ); virtual std::string getTextName( const UniSetTypes::ObjectId id );
......
...@@ -117,3 +117,12 @@ const ObjectInfo* ObjectIndex_Array::getObjectInfo( const ObjectId id ) ...@@ -117,3 +117,12 @@ const ObjectInfo* ObjectIndex_Array::getObjectInfo( const ObjectId id )
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
const ObjectInfo* ObjectIndex_Array::getObjectInfo( const std::string name )
{
MapObjectKey::iterator it = mok.find(name);
if( it != mok.end() )
return &(objectInfo[it->second]);
return NULL;
}
// ------------------------------------------------------------------------------------------
...@@ -285,3 +285,12 @@ const ObjectInfo* ObjectIndex_XML::getObjectInfo( const ObjectId id ) ...@@ -285,3 +285,12 @@ const ObjectInfo* ObjectIndex_XML::getObjectInfo( const ObjectId id )
return NULL; return NULL;
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
const ObjectInfo* ObjectIndex_XML::getObjectInfo( const std::string name )
{
MapObjectKey::iterator it = mok.find(name);
if( it != mok.end() )
return &(omap[it->second]);
return NULL;
}
// ------------------------------------------------------------------------------------------
...@@ -229,3 +229,15 @@ const ObjectInfo* ObjectIndex_idXML::getObjectInfo( const ObjectId id ) ...@@ -229,3 +229,15 @@ const ObjectInfo* ObjectIndex_idXML::getObjectInfo( const ObjectId id )
return NULL; return NULL;
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
const ObjectInfo* ObjectIndex_idXML::getObjectInfo( const std::string name )
{
const char* n = name.c_str();
for( MapObjects::iterator it=omap.begin(); it!=omap.end(); it++ )
{
if( !strcmp(it->second.repName,n) )
return &(it->second);
}
return NULL;
}
// ------------------------------------------------------------------------------------------
...@@ -1036,6 +1036,30 @@ xmlNode* Configuration::getXMLObjectNode( UniSetTypes::ObjectId id ) ...@@ -1036,6 +1036,30 @@ xmlNode* Configuration::getXMLObjectNode( UniSetTypes::ObjectId id )
return 0; return 0;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
UniversalIO::IOTypes Configuration::getIOType( UniSetTypes::ObjectId id )
{
const ObjectInfo* i = oind->getObjectInfo(id);
if( i && (xmlNode*)(i->data) )
{
UniXML_iterator it((xmlNode*)(i->data));
return UniSetTypes::getIOType( it.getProp("iotype") );
}
return UniversalIO::UnknownIOType;
}
// -------------------------------------------------------------------------
UniversalIO::IOTypes Configuration::getIOType( const std::string name )
{
const ObjectInfo* i = oind->getObjectInfo(name);
if( i && (xmlNode*)(i->data) )
{
UniXML_iterator it((xmlNode*)(i->data));
return UniSetTypes::getIOType( it.getProp("iotype") );
}
return UniversalIO::UnknownIOType;
}
// -------------------------------------------------------------------------
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 );
......
...@@ -20,8 +20,16 @@ int main(int argc, const char **argv) ...@@ -20,8 +20,16 @@ int main(int argc, const char **argv)
conf = new Configuration(argc, argv, confile); conf = new Configuration(argc, argv, confile);
string t(conf->oind->getTextName(1)); string t(conf->oind->getTextName(1));
cout << "**** check getTextName: " << ( t.empty() ? "FAILED" : "OK" ) << endl; cout << "**** check getTextName: " << ( t.empty() ? "FAILED" : "OK" ) << endl;
string mn(conf->oind->getMapName(1));
cout << "**** check getMapName: " << ( mn.empty() ? "FAILED" : "OK" ) << endl;
UniversalIO::IOTypes t1=conf->getIOType(1);
cout << "**** check getIOType(id): (" << t1 << ") " << ( t1 == UniversalIO::UnknownIOType ? "FAILED" : "OK" ) << endl;
UniversalIO::IOTypes t2=conf->getIOType(mn);
cout << "**** check getIOType(name): (" << t2 << ") " << ( t2 == UniversalIO::UnknownIOType ? "FAILED" : "OK" ) << endl;
return 0; return 0;
} }
catch(SystemError& err) catch(SystemError& err)
......
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