Commit 0cd82222 authored by Ivan Donchevskiy's avatar Ivan Donchevskiy

Merge branch 'master' of git.eter:/projects/uniset

parents 6e74886d 8f32358b
...@@ -182,6 +182,18 @@ interface IOController_i : ObjectsManager_i ...@@ -182,6 +182,18 @@ interface IOController_i : ObjectsManager_i
ӣ . ӣ .
*/ */
UniSetTypes::IDSeq setOutputSeq( in OutSeq lst, in UniSetTypes::ObjectId sup_id ); UniSetTypes::IDSeq setOutputSeq( in OutSeq lst, in UniSetTypes::ObjectId sup_id );
/*! */
struct ShortIOInfo
{
long value;
long tv_sec; /*!< , (gettimeofday) */
long tv_usec; /*!< , (gettimeofday) */
};
ShortIOInfo getChangedTime(in SensorInfo si) raises(NameNotFound);
}; };
// -------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
Name: libuniset Name: libuniset
Version: 0.96 Version: 0.96
Release: eter39 Release: eter45
Summary: UniSet - library for building distributed industrial control systems Summary: UniSet - library for building distributed industrial control systems
...@@ -177,6 +177,18 @@ rm -f %buildroot%_libdir/*.la ...@@ -177,6 +177,18 @@ rm -f %buildroot%_libdir/*.la
%exclude %_pkgconfigdir/libUniSet.pc %exclude %_pkgconfigdir/libUniSet.pc
%changelog %changelog
* Fri Aug 14 2009 Pavel Vainerman <pv@altlinux.ru> 0.96-eter44
- new build
* Thu Aug 13 2009 Pavel Vainerman <pv@altlinux.ru> 0.96-eter41
- new build
* Wed Aug 12 2009 Pavel Vainerman <pv@altlinux.ru> 0.96-eter40
- new build
* Wed Aug 12 2009 Pavel Vainerman <pv@altlinux.ru> 0.96-eter39
- new build
* Thu Aug 06 2009 Pavel Vainerman <pv@altlinux.ru> 0.96-eter38 * Thu Aug 06 2009 Pavel Vainerman <pv@altlinux.ru> 0.96-eter38
- new build - new build
......
...@@ -122,6 +122,8 @@ class IOController: ...@@ -122,6 +122,8 @@ class IOController:
UniSetTypes::Message::Priority getPriority(const IOController_i::SensorInfo& si, UniSetTypes::Message::Priority getPriority(const IOController_i::SensorInfo& si,
UniversalIO::IOTypes type); UniversalIO::IOTypes type);
virtual IOController_i::ShortIOInfo getChangedTime(const IOController_i::SensorInfo& si);
public: public:
struct DependsInfo; struct DependsInfo;
......
...@@ -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);
IOController_i::ShortIOInfo getChangedTime( UniSetTypes::ObjectId id, UniSetTypes::ObjectId node );
// /*! */ // /*! */
void registered(UniSetTypes::ObjectId id, const UniSetTypes::ObjectPtr oRef, bool force=false)throw(UniSetTypes::ORepFailed); void registered(UniSetTypes::ObjectId id, const UniSetTypes::ObjectPtr oRef, bool force=false)throw(UniSetTypes::ORepFailed);
void registered(UniSetTypes::ObjectId id, UniSetTypes::ObjectId node, const UniSetTypes::ObjectPtr oRef, bool force=false)throw(UniSetTypes::ORepFailed); void registered(UniSetTypes::ObjectId id, UniSetTypes::ObjectId node, const UniSetTypes::ObjectPtr oRef, bool force=false)throw(UniSetTypes::ORepFailed);
......
...@@ -2188,6 +2188,78 @@ void UniversalInterface::fastSaveState( IOController_i::SensorInfo& si, bool sta ...@@ -2188,6 +2188,78 @@ void UniversalInterface::fastSaveState( IOController_i::SensorInfo& si, bool sta
} }
// ------------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------------
IOController_i::ShortIOInfo UniversalInterface::getChangedTime( UniSetTypes::ObjectId id, UniSetTypes::ObjectId node )
{
if( id == DefaultObjectId )
throw ORepFailed("UI(getChangedTime): Unknown id=UniSetTypes::DefaultObjectId");
IOController_i::SensorInfo si;
si.id = id;
si.node = node;
try
{
CORBA::Object_var oref;
try
{
oref = rcache.resolve(si.id, si.node);
}
catch( NameNotFound ){}
for (unsigned int i=0; i<uconf->getRepeatCount(); i++)
{
try
{
if( CORBA::is_nil(oref) )
oref = resolve( si.id, si.node );
IOController_i_var iom = IOController_i::_narrow(oref);
return iom->getChangedTime(si);
}
catch(CORBA::TRANSIENT){}
catch(CORBA::OBJECT_NOT_EXIST){}
catch(CORBA::SystemException& ex){}
msleep(uconf->getRepeatTimeout());
oref = CORBA::Object::_nil();
}
}
catch(UniSetTypes::TimeOut){}
catch(IOController_i::NameNotFound &ex)
{
rcache.erase(si.id, si.node);
unideb[Debug::WARN] << "UI(getChangedTime): " << ex.err << endl;
}
catch(ORepFailed)
{
rcache.erase(si.id, si.node);
unideb[Debug::WARN] << set_err("UI(getChangedTime): ",si.id,si.node) << endl;
}
catch(CORBA::NO_IMPLEMENT)
{
rcache.erase(si.id, si.node);
unideb[Debug::WARN] << set_err("UI(getChangedTime): ",si.id,si.node) << endl;
}
catch(CORBA::OBJECT_NOT_EXIST)
{
rcache.erase(si.id, si.node);
unideb[Debug::WARN] << set_err("UI(getChangedTime): ",si.id,si.node) << endl;
}
catch(CORBA::COMM_FAILURE)
{
//
// unideb[Debug::WARN] << "UI(saveState): CORBA::COMM_FAILURE " << endl;
}
catch(CORBA::SystemException& ex)
{
//
// unideb[Debug::WARN] << "UI(saveState): CORBA::SystemException" << endl;
}
catch(...){}
rcache.erase(si.id, si.node);
throw UniSetTypes::TimeOut(set_err("UI(getChangedTime): TimeOut ",si.id, si.node));
}
// ------------------------------------------------------------------------------------------------------------
ObjectPtr UniversalInterface::CacheOfResolve::resolve( ObjectId id, ObjectId node ) ObjectPtr UniversalInterface::CacheOfResolve::resolve( ObjectId id, ObjectId node )
throw(NameNotFound) throw(NameNotFound)
......
...@@ -304,7 +304,9 @@ void ObjectsManager::objects(OManagerCommand cmd) ...@@ -304,7 +304,9 @@ void ObjectsManager::objects(OManagerCommand cmd)
} }
catch( CORBA::Exception& ex ) catch( CORBA::Exception& ex )
{ {
unideb[Debug::CRIT] << myname << "(objects): Caught CORBA::Exception." << endl; unideb[Debug::CRIT] << myname << "(objects): Caught CORBA::Exception. "
<< ex._name()
<< " (" << (*li)->getName() << ")" << endl;
} }
catch( omniORB::fatalException& fe ) catch( omniORB::fatalException& fe )
{ {
......
...@@ -913,7 +913,10 @@ IOController_i::DigitalIOInfo IOController::getDInfo(const IOController_i::Senso ...@@ -913,7 +913,10 @@ IOController_i::DigitalIOInfo IOController::getDInfo(const IOController_i::Senso
{ {
DIOStateList::iterator it = dioList.find( key(si.id, si.node) ); DIOStateList::iterator it = dioList.find( key(si.id, si.node) );
if( it!=dioList.end() ) if( it!=dioList.end() )
{
uniset_spin_lock lock(it->second.val_lock,checkLockValuePause);
return it->second; return it->second;
}
// ------------- // -------------
ostringstream err; ostringstream err;
...@@ -926,7 +929,10 @@ IOController_i::AnalogIOInfo IOController::getAInfo(const IOController_i::Sensor ...@@ -926,7 +929,10 @@ IOController_i::AnalogIOInfo IOController::getAInfo(const IOController_i::Sensor
{ {
AIOStateList::iterator it = aioList.find( key(si.id, si.node) ); AIOStateList::iterator it = aioList.find( key(si.id, si.node) );
if( it!=aioList.end() ) if( it!=aioList.end() )
{
uniset_spin_lock lock(it->second.val_lock,checkLockValuePause);
return it->second; return it->second;
}
// ------------- // -------------
ostringstream err; ostringstream err;
...@@ -1362,3 +1368,35 @@ IDSeq* IOController::setOutputSeq(const IOController_i::OutSeq& lst, ObjectId su ...@@ -1362,3 +1368,35 @@ IDSeq* IOController::setOutputSeq(const IOController_i::OutSeq& lst, ObjectId su
return badlist.getIDSeq(); return badlist.getIDSeq();
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
IOController_i::ShortIOInfo IOController::getChangedTime( const IOController_i::SensorInfo& si )
{
DIOStateList::iterator dit = dioList.find( key(si.id, si.node) );
if( dit!=dioList.end() )
{
IOController_i::ShortIOInfo i;
uniset_spin_lock lock(dit->second.val_lock,checkLockValuePause);
i.value = dit->second.state ? 1 : 0;
i.tv_sec = dit->second.tv_sec;
i.tv_usec = dit->second.tv_usec;
return i;
}
AIOStateList::iterator ait = aioList.find( key(si.id, si.node) );
if( ait!=aioList.end() )
{
IOController_i::ShortIOInfo i;
uniset_spin_lock lock(ait->second.val_lock,checkLockValuePause);
i.value = ait->second.value;
i.tv_sec = ait->second.tv_sec;
i.tv_usec = ait->second.tv_usec;
return i;
}
// -------------
ostringstream err;
err << myname << "(getChangedTime): () "
<< conf->oind->getNameById(si.id) << " ";
unideb[Debug::INFO] << err.str() << endl;
throw IOController_i::NameNotFound(err.str().c_str());
}
// -----------------------------------------------------------------------------
...@@ -2,10 +2,16 @@ ...@@ -2,10 +2,16 @@
# This file is part of the UniSet library # # This file is part of the UniSet library #
############################################################################ ############################################################################
noinst_PROGRAMS = passivetimer noinst_PROGRAMS = passivetimer ui
passivetimer_SOURCES = passivetimer.cc passivetimer_SOURCES = passivetimer.cc
passivetimer_LDADD = $(top_builddir)/lib/libUniSet.la passivetimer_LDADD = $(top_builddir)/lib/libUniSet.la
passivetimer_CPPFLAGS = -I$(top_builddir)/include passivetimer_CPPFLAGS = -I$(top_builddir)/include
ui_SOURCES = ui.cc
ui_LDADD = $(top_builddir)/lib/libUniSet.la
ui_CPPFLAGS = -I$(top_builddir)/include
include $(top_builddir)/conf/setting.mk include $(top_builddir)/conf/setting.mk
#!/bin/sh
ln -s -f /usr/bin/uniset-stop.sh stop.sh
ln -s -f ../conf/test.xml test.xml
#include <time.h>
#include "UniversalInterface.h"
#include "UniSetTypes.h"
using namespace std;
using namespace UniSetTypes;
int main( int argc, const char **argv )
{
try
{
uniset_init(argc,argv,"test.xml");
int id = conf->getArgInt("--sid");
if( id <=0 )
{
cerr << "unknown sensor ID. Use --sid " << endl;
return 1;
}
UniversalInterface ui;
cout << "getChangedTime for ID=" << id << ":" << endl;
IOController_i::ShortIOInfo inf = ui.getChangedTime(id,conf->getLocalNode());
struct tm* tms = localtime(&inf.tv_sec);
char t_str[ 150 ];
strftime( t_str, sizeof(t_str), "%d %b %Y %H:%M:%S", tms );
cout << "id=" << id
<< " value=" << inf.value
<< " last changed: " << string(t_str) << endl;
}
catch( Exception& ex )
{
cout << "(uitest):" << ex << endl;
}
catch(...)
{
cout << "(uitest): catch ..."<< endl;
}
return 0;
}
#!/bin/sh
SID=$1
[ -z "$SID" ] && SID=1
uniset-start.sh -f ./ui --confile test.xml --sid $SID
#--unideb-add-levels system,info,level9
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