Commit 1b6f351e authored by Pavel Vainerman's avatar Pavel Vainerman

Merge commit 'origin/newRTUExchange' into eterbook

Conflicts: extentions/SharedMemory/SharedMemory.cc
parents f7b192be 9263e5a0
...@@ -98,6 +98,7 @@ ...@@ -98,6 +98,7 @@
*/ */
enum IOTypes enum IOTypes
{ {
UnknownIOType,
DigitalInput, DigitalInput,
DigitalOutput, DigitalOutput,
AnalogInput, AnalogInput,
......
...@@ -18,6 +18,11 @@ ...@@ -18,6 +18,11 @@
<DumpStateTime name="10"/><!-- [] --> <DumpStateTime name="10"/><!-- [] -->
<SleepTickMS name="500"/><!-- [] --> <SleepTickMS name="500"/><!-- [] -->
<ServicesSection name="Services"/>
<NameService host="localhost" port="2809"/>
<SizeOfMessageQueue name="2000"/>
<LocalIOR name="0"/>
<!-- Debug, logs --> <!-- Debug, logs -->
<UniSetDebug name="unideb" levels="crit,warn" file=""/> <UniSetDebug name="unideb" levels="crit,warn" file=""/>
...@@ -83,6 +88,8 @@ ...@@ -83,6 +88,8 @@
<HeartBeatTime time_msec="5000"/> <HeartBeatTime time_msec="5000"/>
<IOControl name="IOControl" />
<ObjectsMap idfromfile="0"> <ObjectsMap idfromfile="0">
<!-- <!--
'sensors' 'sensors'
...@@ -100,11 +107,38 @@ ...@@ -100,11 +107,38 @@
<!-- ************************ ********************** --> <!-- ************************ ********************** -->
<sensors name="Sensors"> <sensors name="Sensors">
<item name="Input1_S" textname=" 1" node="" iotype="DI" priority="Medium" default="1" /> <item name="Input1_S" textname=" 1" node="" iotype="DI" priority="Medium" default="1" />
<item name="Input2_S" textname=" 2" node="" iotype="DI" priority="Medium" mbtype="rtu" mbaddr="0x01" mbfunc="0x04" mbreg="0x02" rs="2" /> <item name="Input2_S" textname=" 2" node="" iotype="DI" priority="Medium" mbtype="rtu" mbaddr="0x01" mbfunc="0x04" mbreg="0x02" rs="1" />
<item name="Input3_S" textname=" 3" node="" iotype="DI" priority="Medium" mbtcp="1" mbaddr="0x02" mbfunc="0x04" mbreg="0x02"/> <item name="Input3_S" textname=" 3" node="" iotype="DI" priority="Medium" mbtcp="1" mbaddr="0x02" mbfunc="0x04" mbreg="0x02"/>
<item name="Input4_S" textname=" 4" node="" iotype="DI" priority="Medium" mbtype="rtu" mbaddr="0x02" mbfunc="0x04" mbreg="0x02" rs="2" /> <item name="Input4_S" textname=" 4" node="" iotype="DI" priority="Medium" mbtype="rtu" mbaddr="0x02" mbfunc="0x04" mbreg="0x05" rs="1" />
<item name="Input5_S" textname=" 5" node="" iotype="DI" priority="Medium" udp="2"/>
<item name="Input6_S" textname=" 6" node="" iotype="DI" priority="Medium" udp="2"> <item name="RS_Test1_S" textname=" 2" node="" iotype="DI" priority="Medium" mbtype="rtu" mbaddr="0x01" mbfunc="0x03" mbreg="0x02" nbit="1" rs="1" />
<item name="RS_Test2_S" textname=" 2" node="" iotype="DI" priority="Medium" mbtype="rtu" mbaddr="0x01" mbfunc="0x03" mbreg="0x02" nbit="2" rs="1" />
<item name="RS_Test3_S" textname=" 2" node="" iotype="DI" priority="Medium" mbtype="rtu" mbaddr="0x01" mbfunc="0x03" mbreg="0x02" nbit="3" rs="1" />
<item name="RS_Test4_S" textname=" 2" node="" iotype="DI" priority="Medium" mbtype="rtu" mbaddr="0x01" mbfunc="0x03" mbreg="0x02" nbit="4" rs="1" />
<item name="RS_Test5_S" textname=" 5" node="" iotype="DI" priority="Medium" mbtype="rtu188" mbaddr="0x03" jack="J1" channel="23" rs="1" />
<item name="RS_Test6_S" textname=" 5" node="" iotype="DI" priority="Medium" mbtype="rtu188" mbaddr="0x03" jack="J1" channel="23" rs="1" />
<item name="RS_Test7_S" textname=" 5" node="" iotype="DI" priority="Medium" mbtype="rtu188" mbaddr="0x04" jack="J1" channel="23" rs="1" />
<item name="RS_Test8_S" textname=" 2" node="" iotype="DI" priority="Medium" mbtype="rtu" mbaddr="0x01" mbfunc="0x03" mbreg="0x05" rs="1" />
<item name="RS_Test9_S" textname=" 2" node="" iotype="DI" priority="Medium" mbtype="rtu" mbaddr="0x01" mbfunc="0x03" mbreg="0x06" rs="1" />
<item name="RS_Test10_S" textname=" 2" node="" iotype="DI" priority="Medium" mbtype="rtu" mbaddr="0x01" mbfunc="0x03" mbreg="0x07" rs="1" />
<item name="RS_Test11_S" textname=" 2" node="" iotype="DI" priority="Medium" mbtype="rtu" vtype="F2" mbaddr="0x01" mbfunc="0x03" mbreg="0x08" rs="1" />
<item name="RS_Test12_S" textname=" 2" node="" iotype="DI" priority="Medium" mbtype="rtu" mbaddr="0x01" mbfunc="0x03" mbreg="0xA" rs="1" />
<item name="RS_Test13_S" textname=" 2" node="" iotype="DI" priority="Medium" mbtype="rtu" mbaddr="0x01" mbfunc="0x03" mbreg="0xB" rs="1" />
<item name="RS_Test14_S" textname=" 2" node="" iotype="DI" priority="Medium" mbtype="rtu" mbaddr="0x01" mbfunc="0x03" mbreg="0xC" rs="1" />
<item name="RS_Test15_S" textname=" 2" node="" iotype="DI" priority="Medium" mbtype="rtu" mbaddr="0x01" mbfunc="0x03" mbreg="0xD" rs="1" />
<item name="RS_Test16_S" textname=" 2" node="" iotype="DI" priority="Medium" mbtype="mtr" mtrtype="F1" mbaddr="0x05" mbfunc="0x03" mbreg="0x10" rs="1" />
<item name="RS_Test17_S" textname=" 2" node="" iotype="DI" priority="Medium" mbtype="rtu" mbaddr="0x01" mbfunc="0x03" mbreg="0x10" rs="1" />
<item name="IO_Test1_S" textname="io test" node="" iotype="DO" priority="Medium" io="1"/>
<item name="IO_Test2_S" textname="io test" node="" iotype="DI" priority="Medium" io="1"/>
<item name="IO_Test3_S" textname="io test" node="" iotype="AO" priority="Medium" io="1"/>
<item name="IO_Test4_S" textname="io test" node="" iotype="AI" priority="Medium" io="1"/>
<item name="W_Test2_S" textname="io test" node="" iotype="DI" priority="Medium" mbtype="rtu" mbaddr="0x02" mbfunc="0x03" mbreg="0x3001" rs="wago" />
<item name="W_Test3_S" textname="io test" node="" iotype="DI" priority="Medium" mbtype="rtu" mbaddr="0x02" mbfunc="0x03" mbreg="0x3002" rs="wago" />
<item name="W_Test4_S" textname="io test" node="" iotype="AI" priority="Medium" mbtype="rtu" mbaddr="0x02" mbfunc="0x06" mbreg="0x3008" rs="wago" default="4"/>
<item name="Input6_S" textname=" 6" node="" iotype="DI" priority="Medium">
<depends> <depends>
<depend name="Input4_S"/> <depend name="Input4_S"/>
</depends> </depends>
......
...@@ -2,7 +2,11 @@ ...@@ -2,7 +2,11 @@
Name: uniset Name: uniset
Version: 0.96 Version: 0.96
<<<<<<< HEAD:conf/uniset.spec
Release: eter6
=======
Release: eter9 Release: eter9
>>>>>>> 6eb79ccca4b348cddaa393aae9cb34b9fcf2a001:conf/uniset.spec
Summary: UniSet Summary: UniSet
License: GPL License: GPL
Group: Development/C++ Group: Development/C++
...@@ -180,10 +184,14 @@ Libraries needed to develop for uniset extentions ...@@ -180,10 +184,14 @@ Libraries needed to develop for uniset extentions
%_bindir/%name-smviewer %_bindir/%name-smviewer
%changelog %changelog
<<<<<<< HEAD:conf/uniset.spec
* Wed May 20 2009 Pavel Vainerman <pv@altlinux.ru> 0.96-eter5
=======
* Tue Apr 21 2009 Pavel Vainerman <pv@etersoft.ru> 0.96-eter6 * Tue Apr 21 2009 Pavel Vainerman <pv@etersoft.ru> 0.96-eter6
- new build - new build
* Tue Apr 21 2009 Pavel Vainerman <pv@etersoft.ru> 0.96-eter5 * Tue Apr 21 2009 Pavel Vainerman <pv@etersoft.ru> 0.96-eter5
>>>>>>> 6eb79ccca4b348cddaa393aae9cb34b9fcf2a001:conf/uniset.spec
- new build - new build
* Mon Apr 06 2009 Pavel Vainerman <pv@altlinux.ru> 0.96-eter4 * Mon Apr 06 2009 Pavel Vainerman <pv@altlinux.ru> 0.96-eter4
......
...@@ -56,7 +56,7 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID, ...@@ -56,7 +56,7 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID,
UniXML_iterator it(cnode); UniXML_iterator it(cnode);
noCards = true; noCards = true;
for( unsigned int i=0; i<cards.size(); i++ ) for( unsigned int i=0; i=<cards.size(); i++ )
{ {
stringstream s1; stringstream s1;
s1 << "--iodev" << i; s1 << "--iodev" << i;
......
...@@ -68,9 +68,9 @@ class IOControl: ...@@ -68,9 +68,9 @@ class IOControl:
{} {}
short subdev; /*!< (UNIO) (. comedi_test /) */ int subdev; /*!< (UNIO) (. comedi_test /) */
short channel; /*!< (UNIO) [0...23] */ int channel; /*!< (UNIO) [0...23] */
short ncard; /*!< [1|2]. 0 - */ int ncard; /*!< [1|2]. 0 - */
/*! /*!
0 - analog ref = analog ground 0 - analog ref = analog ground
......
#!/bin/sh
ln -s -f /usr/bin/uniset-stop.sh stop.sh
ln -s -f ../../conf/test.xml test.xml
...@@ -30,7 +30,7 @@ int main(int argc, char **argv) ...@@ -30,7 +30,7 @@ int main(int argc, char **argv)
string logfilename = conf->getArgParam("--io-logfile","iocontrol.log"); string logfilename = conf->getArgParam("--io-logfile","iocontrol.log");
string logname( conf->getLogDir() + logfilename ); string logname( conf->getLogDir() + logfilename );
dlog.logFile( logname.c_str() ); dlog.logFile( logname.c_str() );
unideb.logFile( logname.c_str() ); unideb.logFile( logname.c_str() );
ObjectId shmID = DefaultObjectId; ObjectId shmID = DefaultObjectId;
string sID = conf->getArgParam("--smemory-id"); string sID = conf->getArgParam("--smemory-id");
......
#!/bin/sh
#ulimit -Sc 1000000000000
uniset-start.sh -f ./uniset-iocontrol --smemory-id SharedMemory \
--confile test.xml \
--io-name IOControl \
--io-polltime 100 \
--io-s-filter-field io \
--io-s-filter-value 1 \
--iodev1 /dev/null \
--iodev2 /dev/null \
--io-test-lamp RS_Test9_S \
--io-heartbeat-id AI_AS \
--io-sm-ready-test-sid RS_Test9_S \
--unideb-add-levels info,crit,warn,level9,system \
...@@ -76,7 +76,7 @@ class Element ...@@ -76,7 +76,7 @@ class Element
ChildInfo():el(0),num(0){} ChildInfo():el(0),num(0){}
Element* el; Element* el;
int num; int num;
}; };
typedef std::list<ChildInfo> OutputList; typedef std::list<ChildInfo> OutputList;
......
...@@ -50,49 +50,116 @@ class RTUExchange: ...@@ -50,49 +50,116 @@ class RTUExchange:
dtMTR /*!< MTR (DEIF) */ dtMTR /*!< MTR (DEIF) */
}; };
static DeviceType getDeviceType( const std::string dtype );
friend std::ostream& operator<<( std::ostream& os, const DeviceType& dt ); friend std::ostream& operator<<( std::ostream& os, const DeviceType& dt );
// -------------------------------------------------------------------------------
struct RTUDevice;
struct RegInfo;
struct RSProperty: struct RSProperty:
public IOBase public IOBase
{ {
DeviceType devtype; /*!< */
ModbusRTU::ModbusAddr mbaddr; /*!< */
ModbusRTU::ModbusData mbreg; /*!< */
ModbusRTU::SlaveFunctionCode mbfunc; /*!< / */
// only for RTU // only for RTU
short nbit; /*!< bit number (for func=[0x01,0x02]) */ short nbit; /*!< bit number (for func=[0x01,0x02]) */
VTypes::VType vType; /*!< type of value */ VTypes::VType vType; /*!< type of value */
short rnum; /*!< count of registers */ short rnum; /*!< count of registers */
RSProperty():
nbit(-1),vType(VTypes::vtUnknown),
rnum(VTypes::wsize(VTypes::vtUnknown)),
reg(0)
{}
RegInfo* reg;
};
friend std::ostream& operator<<( std::ostream& os, const RSProperty& p );
typedef std::list<RSProperty> PList;
struct RegInfo
{
RegInfo():
mbval(0),mbreg(0),mbfunc(ModbusRTU::fnUnknown),
mtrType(MTR::mtUnknown),
rtuJack(RTUStorage::nUnknown),rtuChan(0),
dev(0),
q_num(0),q_count(1)
{}
ModbusRTU::ModbusData mbval;
ModbusRTU::ModbusData mbreg; /*!< */
ModbusRTU::SlaveFunctionCode mbfunc; /*!< / */
PList slst;
// only for MTR // only for MTR
MTR::MTRType mtrType; /*!< ( MTR) */ MTR::MTRType mtrType; /*!< ( MTR) */
// only for RTU188 // only for RTU188
RTUStorage* rtu;
RTUStorage::RTUJack rtuJack; RTUStorage::RTUJack rtuJack;
int rtuChan; int rtuChan;
RTUDevice* dev;
RSProperty(): // optimization
devtype(dtUnknown), int q_num; /*! number in query */
mbaddr(0),mbreg(0),mbfunc(ModbusRTU::fnUnknown), int q_count; /*! count registers for query */
nbit(-1),vType(VTypes::vtUnknown), };
rnum(VTypes::wsize(VTypes::vtUnknown)),
rtu(0),rtuJack(RTUStorage::nUnknown),rtuChan(0) friend std::ostream& operator<<( std::ostream& os, RegInfo& r );
typedef std::map<ModbusRTU::ModbusData,RegInfo*> RegMap;
struct RTUDevice
{
RTUDevice():
respnond(false),
mbaddr(0),
dtype(dtUnknown),
resp_id(UniSetTypes::DefaultObjectId),
resp_state(false),
resp_invert(false),
resp_real(false),
rtu(0)
{} {}
bool respnond;
ModbusRTU::ModbusAddr mbaddr; /*!< */
RegMap regmap;
DeviceType dtype; /*!< */
UniSetTypes::ObjectId resp_id;
IOController::DIOStateList::iterator resp_dit;
PassiveTimer resp_ptTimeout;
Trigger resp_trTimeout;
bool resp_state;
bool resp_invert;
bool resp_real;
RTUStorage* rtu;
// return TRUE if state changed
bool checkRespond();
friend std::ostream& operator<<( std::ostream& os, RSProperty& p );
}; };
protected: friend std::ostream& operator<<( std::ostream& os, RTUDevice& d );
typedef std::map<ModbusRTU::ModbusAddr,RTUDevice*> RTUDeviceMap;
typedef std::vector<RSProperty> RSMap; friend std::ostream& operator<<( std::ostream& os, RTUDeviceMap& d );
RSMap rsmap; /*!< / */ void printMap(RTUDeviceMap& d);
unsigned int maxItem; /*!< ( ) */ // ----------------------------------
protected:
RTUDeviceMap rmap;
ModbusRTUMaster* mb; ModbusRTUMaster* mb;
UniSetTypes::uniset_mutex mbMutex; UniSetTypes::uniset_mutex mbMutex;
std::string devname;
std::string speed;
int recv_timeout;
xmlNode* cnode; xmlNode* cnode;
std::string s_field; std::string s_field;
...@@ -102,10 +169,12 @@ class RTUExchange: ...@@ -102,10 +169,12 @@ class RTUExchange:
void step(); void step();
void poll(); void poll();
long pollRTU188( RSMap::iterator& p ); void pollRTU( RTUDevice* dev, RegMap::iterator& it );
long pollMTR( RSMap::iterator& p );
long pollRTU( RSMap::iterator& p ); void updateSM();
void setRespond(ModbusRTU::ModbusAddr addr, bool respond ); void updateRTU(RegMap::iterator& it);
void updateMTR(RegMap::iterator& it);
void updateRTU188(RegMap::iterator& it);
virtual void processingMessage( UniSetTypes::VoidMessage *msg ); virtual void processingMessage( UniSetTypes::VoidMessage *msg );
void sysCommand( UniSetTypes::SystemMessage *msg ); void sysCommand( UniSetTypes::SystemMessage *msg );
...@@ -119,30 +188,30 @@ class RTUExchange: ...@@ -119,30 +188,30 @@ class RTUExchange:
// //
virtual void sigterm( int signo ); virtual void sigterm( int signo );
void initMB();
void initIterators(); void initIterators();
bool initItem( UniXML_iterator& it ); bool initItem( UniXML_iterator& it );
bool readItem( UniXML& xml, UniXML_iterator& it, xmlNode* sec ); bool readItem( UniXML& xml, UniXML_iterator& it, xmlNode* sec );
bool initCommParam( UniXML_iterator& it, RSProperty& p );
bool initMTRitem( UniXML_iterator& it, RSProperty& p );
bool initRTU188item( UniXML_iterator& it, RSProperty& p ); RTUDevice* addDev( RTUDeviceMap& dmap, ModbusRTU::ModbusAddr a, UniXML_iterator& it );
bool initRTUitem( UniXML_iterator& it, RSProperty& p ); RegInfo* addReg( RegMap& rmap, ModbusRTU::ModbusData r, UniXML_iterator& it,
RTUDevice* dev, RegInfo* rcopy=0 );
RSProperty* addProp(PList& plist, RSProperty& p );
bool initMTRitem( UniXML_iterator& it, RegInfo* p );
bool initRTU188item( UniXML_iterator& it, RegInfo* p );
bool initRSProperty( RSProperty& p, UniXML_iterator& it );
bool initRegInfo( RegInfo* r, UniXML_iterator& it, RTUDevice* dev );
bool initRTUDevice( RTUDevice* d, UniXML_iterator& it );
bool initRespondInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniXML_iterator& it );
void rtuQueryOptimization( RTUDeviceMap& m );
void readConfiguration(); void readConfiguration();
bool check_item( UniXML_iterator& it ); bool check_item( UniXML_iterator& it );
/*
struct RTUInfo
{
RTUInfo():rtu(0),sid_conn(UniSetTypes::DefaultObjectId){}
RTUStorage* rtu;
UniSetTypes::ObjectId sid_conn;
};
*/
typedef std::map<int,RTUStorage*> RTUMap;
RTUMap rtulist;
private: private:
RTUExchange(); RTUExchange();
bool initPause; bool initPause;
...@@ -152,6 +221,7 @@ class RTUExchange: ...@@ -152,6 +221,7 @@ class RTUExchange:
bool force_out; /*!< , */ bool force_out; /*!< , */
bool mbregFromID; bool mbregFromID;
int polltime; /*!< , [] */ int polltime; /*!< , [] */
PassiveTimer ptHeartBeat; PassiveTimer ptHeartBeat;
UniSetTypes::ObjectId sidHeartBeat; UniSetTypes::ObjectId sidHeartBeat;
int maxHeartBeat; int maxHeartBeat;
...@@ -160,28 +230,6 @@ class RTUExchange: ...@@ -160,28 +230,6 @@ class RTUExchange:
UniSetTypes::uniset_mutex pollMutex; UniSetTypes::uniset_mutex pollMutex;
struct RespondInfo
{
RespondInfo():
id(UniSetTypes::DefaultObjectId),
state(false),
invert(false)
{}
UniSetTypes::ObjectId id;
IOController::DIOStateList::iterator dit;
PassiveTimer ptTimeout;
Trigger trTimeout;
bool state;
bool invert;
};
typedef std::map<ModbusRTU::ModbusAddr,RespondInfo> RespondMap;
RespondMap respMap;
PassiveTimer aiTimer;
int ai_polltime;
bool activated; bool activated;
int activateTimeout; int activateTimeout;
}; };
......
...@@ -267,6 +267,95 @@ bool RTUStorage::getState( RTUJack jack, unsigned short int chan, UniversalIO::I ...@@ -267,6 +267,95 @@ bool RTUStorage::getState( RTUJack jack, unsigned short int chan, UniversalIO::I
return false; return false;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
ModbusRTU::ModbusData RTUStorage::getRegister( RTUJack jack, unsigned short chan, UniversalIO::IOTypes t )
{
if( t == UniversalIO::AnalogInput )
{
switch( jack )
{
case nJ1:
return 1032+chan;
case nJ2:
return 1032+24+chan;
case nJ5:
return 1000+chan;
case nX1:
return 1016+chan;
case nX2:
return 1016+4+chan;
default:
break;
}
return -1;
}
if( t == UniversalIO::AnalogOutput )
{
switch( jack )
{
case nJ1:
return 1016+chan;
case nJ2:
return 1016+24+chan;
case nJ5:
return 1000+chan;
case nX1:
return 1016+chan;
case nX2:
return 1016+4+chan;
default:
break;
}
return -1;
}
if( t == UniversalIO::DigitalInput )
{
switch( jack )
{
case nJ1:
return 32+chan;
case nJ2:
return 32+24+chan;
case nJ5:
return 16+chan;
case nX4:
return chan;
case nX5:
return 8+chan;
default:
break;
}
return -1;
}
if( t == UniversalIO::DigitalOutput )
{
switch( jack )
{
case nJ1:
return 16+chan;
case nJ2:
return 16+24+chan;
case nJ5:
return chan;
default:
break;
}
return -1;
}
return -1;
}
// -----------------------------------------------------------------------------
std::ostream& operator<<(std::ostream& os, RTUStorage& m ) std::ostream& operator<<(std::ostream& os, RTUStorage& m )
{ {
os << "-------------------" << endl os << "-------------------" << endl
......
...@@ -46,6 +46,8 @@ class RTUStorage ...@@ -46,6 +46,8 @@ class RTUStorage
long getInt( RTUJack jack, unsigned short channel, UniversalIO::IOTypes t ); long getInt( RTUJack jack, unsigned short channel, UniversalIO::IOTypes t );
float getFloat( RTUJack jack, unsigned short channel, UniversalIO::IOTypes t ); float getFloat( RTUJack jack, unsigned short channel, UniversalIO::IOTypes t );
bool getState( RTUJack jack, unsigned short channel, UniversalIO::IOTypes t ); bool getState( RTUJack jack, unsigned short channel, UniversalIO::IOTypes t );
static ModbusRTU::ModbusData getRegister( RTUJack jack, unsigned short channel, UniversalIO::IOTypes t );
// : setState, setValue // : setState, setValue
void print(); void print();
......
#!/bin/sh #!/bin/sh
uniset-start.sh -f ./uniset-rtuexchange --rs-name RTUExchange --confile test.xml \ uniset-start.sh -f ./uniset-rtuexchange --rs-name RTUExchange --confile test.xml \
--rs-filter-field rs --rs-filter-value 1 \ --rs-filter-field rs --rs-filter-value wago \
--rs-dev /dev/cbsideA0 --rs-reg-from-id 1 \ --rs-dev /dev/ttyUSB0 \
--dlog-add-levels info,crit,warn --dlog-add-levels info,crit,warn
#level3 #,level3
...@@ -411,6 +411,7 @@ void SharedMemory::fastSaveValue(const IOController_i::SensorInfo& si, CORBA::Lo ...@@ -411,6 +411,7 @@ void SharedMemory::fastSaveValue(const IOController_i::SensorInfo& si, CORBA::Lo
SharedMemory* SharedMemory::init_smemory( int argc, char* argv[] ) SharedMemory* SharedMemory::init_smemory( int argc, char* argv[] )
{ {
string dfile = conf->getArgParam("--datfile",conf->getConfFileName()); string dfile = conf->getArgParam("--datfile",conf->getConfFileName());
if( dfile[0]!='.' && dfile[0]!='/' ) if( dfile[0]!='.' && dfile[0]!='/' )
dfile = conf->getConfDir() + dfile; dfile = conf->getConfDir() + dfile;
......
#!/bin/sh
ln -s -f /usr/bin/uniset-stop.sh stop.sh
ln -s -f ../../conf/test.xml test.xml
...@@ -4,22 +4,21 @@ ulimit -Sc 10000000 ...@@ -4,22 +4,21 @@ ulimit -Sc 10000000
START=uniset-start.sh START=uniset-start.sh
${START} -f ./uniset-smemory-plus --smemory-id SharedMemory --confile test.xml \ ${START} -f ./uniset-smemory-plus --smemory-id SharedMemory --confile test.xml \
--unideb-add-levels info,crit,warn,level9,system \ --unideb-add-levels info,crit,warn,level9,system,level3,level2,level1 \
--add-io \ --add-io \
--io-force 1 \ --io-name IOControl \
--io-name IOControl1 \
--io-polltime 100 \ --io-polltime 100 \
--io-s-filter-field io \ --io-s-filter-field io \
--io-s-filter-value ts \ --io-s-filter-value 1 \
--iodev1 /dev/null --iodev1 /dev/null \
--iodev2 /dev/null \ --iodev2 /dev/null \
--io-test-lamp TS_TestLamp_S \ --io-test-lamp RS_Test9_S \
--io-heartbeat-id _31_11_AS \ --io-heartbeat-id AI_AS \
--io-sm-ready-test-sid TestMode_S \ --io-sm-ready-test-sid RS_Test9_S
--add-rtu \ # --add-rtu \
--rtu-device /dev/cbsideA1 \ # --rs-dev /dev/cbsideA1 \
--rtu-id RTUExchange \ # --rs-id RTUExchange \
--add-mbslave \ # --add-mbslave \
#--skip-rtu1 --skip-rtu2 --skip-can --dlog-add-levels info,warn,crit #--skip-rtu1 --skip-rtu2 --skip-can --dlog-add-levels info,warn,crit
......
...@@ -85,6 +85,7 @@ static const int NoSafety = -1; ...@@ -85,6 +85,7 @@ static const int NoSafety = -1;
static void processingAsAI( IOBase* it, long new_val, SMInterface* shm, bool force ); static void processingAsAI( IOBase* it, long new_val, SMInterface* shm, bool force );
static void processingAsDI( IOBase* it, bool new_set, SMInterface* shm, bool force ); static void processingAsDI( IOBase* it, bool new_set, SMInterface* shm, bool force );
static long processingAsAO( IOBase* it, SMInterface* shm, bool force ); static long processingAsAO( IOBase* it, SMInterface* shm, bool force );
static float processingFasAO( IOBase* it, SMInterface* shm, bool force );
static bool processingAsDO( IOBase* it, SMInterface* shm, bool force ); static bool processingAsDO( IOBase* it, SMInterface* shm, bool force );
static bool initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm, static bool initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm,
DebugStream* dlog=0, std::string myname="", DebugStream* dlog=0, std::string myname="",
......
...@@ -81,7 +81,7 @@ namespace MTR ...@@ -81,7 +81,7 @@ namespace MTR
bool setDataBits( ModbusRTUMaster* mb, ModbusRTU::ModbusAddr addr, mtrDataBits d ); bool setDataBits( ModbusRTUMaster* mb, ModbusRTU::ModbusAddr addr, mtrDataBits d );
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
static const int u2size = 2*sizeof(unsigned short); static const int u2size = 2;
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
class T1 class T1
{ {
...@@ -128,6 +128,8 @@ namespace MTR ...@@ -128,6 +128,8 @@ namespace MTR
// ------------------------------------------ // ------------------------------------------
// ... // ...
T3(){ memset(raw.v,0,sizeof(raw.v)); } T3(){ memset(raw.v,0,sizeof(raw.v)); }
T3( signed int i ){ raw.val = i; }
T3( unsigned short v1, unsigned short v2 ) T3( unsigned short v1, unsigned short v2 )
{ {
...@@ -177,7 +179,7 @@ namespace MTR ...@@ -177,7 +179,7 @@ namespace MTR
memcpy(c,&(data[0]),sizeof(c)); memcpy(c,&(data[0]),sizeof(c));
sval = std::string(c); sval = std::string(c);
} }
~T4(){} ~T4(){}
// ------------------------------------------ // ------------------------------------------
/*! */ /*! */
...@@ -202,6 +204,7 @@ namespace MTR ...@@ -202,6 +204,7 @@ namespace MTR
unsigned int val:24; unsigned int val:24;
signed char exp; // :8 signed char exp; // :8
} __attribute__( ( packed ) ) u2; } __attribute__( ( packed ) ) u2;
long lval;
} T5mem; } T5mem;
// ------------------------------------------ // ------------------------------------------
// ... // ...
...@@ -213,6 +216,11 @@ namespace MTR ...@@ -213,6 +216,11 @@ namespace MTR
val = raw.u2.val * pow(10,raw.u2.exp); val = raw.u2.val * pow(10,raw.u2.exp);
} }
T5( long v )
{
raw.lval = v;
}
T5( const ModbusRTU::ModbusData* data ) T5( const ModbusRTU::ModbusData* data )
{ {
if( sizeof(data) >=u2size ) if( sizeof(data) >=u2size )
...@@ -247,6 +255,7 @@ namespace MTR ...@@ -247,6 +255,7 @@ namespace MTR
signed int val:24; signed int val:24;
signed char exp; // :8 signed char exp; // :8
} u2; } u2;
long lval;
} T6mem; } T6mem;
// ------------------------------------------ // ------------------------------------------
// ... // ...
...@@ -257,6 +266,11 @@ namespace MTR ...@@ -257,6 +266,11 @@ namespace MTR
raw.v[1] = v2; raw.v[1] = v2;
val = raw.u2.val * pow(10,raw.u2.exp); val = raw.u2.val * pow(10,raw.u2.exp);
} }
T6( long v )
{
raw.lval = v;
}
T6( const ModbusRTU::ModbusData* data ) T6( const ModbusRTU::ModbusData* data )
{ {
...@@ -293,6 +307,7 @@ namespace MTR ...@@ -293,6 +307,7 @@ namespace MTR
unsigned char ic; // :8 - Inductive/capacitive unsigned char ic; // :8 - Inductive/capacitive
unsigned char ie; // :8 - Import/export unsigned char ie; // :8 - Import/export
}__attribute__( ( packed ) ) u2; }__attribute__( ( packed ) ) u2;
long lval;
} T7mem; } T7mem;
// ------------------------------------------ // ------------------------------------------
// ... // ...
...@@ -303,6 +318,10 @@ namespace MTR ...@@ -303,6 +318,10 @@ namespace MTR
raw.v[1] = v2; raw.v[1] = v2;
val = raw.u2.val * pow(10,-4); val = raw.u2.val * pow(10,-4);
} }
T7( const long v )
{
raw.lval = v;
}
T7( const ModbusRTU::ModbusData* data ) T7( const ModbusRTU::ModbusData* data )
{ {
...@@ -442,6 +461,11 @@ namespace MTR ...@@ -442,6 +461,11 @@ namespace MTR
raw.v[1] = v2; raw.v[1] = v2;
} }
F1( float f )
{
raw.val = f;
}
F1( const ModbusRTU::ModbusData* data ) F1( const ModbusRTU::ModbusData* data )
{ {
if( sizeof(data) >=u2size ) if( sizeof(data) >=u2size )
......
...@@ -42,6 +42,7 @@ namespace VTypes ...@@ -42,6 +42,7 @@ namespace VTypes
// ... // ...
F2(){ memset(raw.v,0,sizeof(raw.v)); } F2(){ memset(raw.v,0,sizeof(raw.v)); }
F2( float f ){ raw.val = f; }
F2( const ModbusRTU::ModbusData* data, int size ) F2( const ModbusRTU::ModbusData* data, int size )
{ {
for( int i=0; i<wsize() && i<size; i++ ) for( int i=0; i<wsize() && i<size; i++ )
...@@ -76,6 +77,7 @@ namespace VTypes ...@@ -76,6 +77,7 @@ namespace VTypes
// ... // ...
F4(){ memset(raw.v,0,sizeof(raw.v)); } F4(){ memset(raw.v,0,sizeof(raw.v)); }
F4( float f ){ raw.val = f; }
F4( const ModbusRTU::ModbusData* data, int size ) F4( const ModbusRTU::ModbusData* data, int size )
{ {
for( int i=0; i<wsize() && i<size; i++ ) for( int i=0; i<wsize() && i<size; i++ )
......
...@@ -148,14 +148,23 @@ void IOBase::processingAsAI( IOBase* it, long val, SMInterface* shm, bool force ...@@ -148,14 +148,23 @@ void IOBase::processingAsAI( IOBase* it, long val, SMInterface* shm, bool force
shm->localSaveValue( it->ait,it->si.id,val,shm->ID() ); shm->localSaveValue( it->ait,it->si.id,val,shm->ID() );
else if( it->stype == UniversalIO::AnalogOutput ) else if( it->stype == UniversalIO::AnalogOutput )
shm->localSetValue( it->ait,it->si.id,val,shm->ID() ); shm->localSetValue( it->ait,it->si.id,val,shm->ID() );
else if( it->stype == UniversalIO::DigitalOutput )
shm->localSetState( it->dit,it->si.id,(bool)val,shm->ID() );
else if( it->stype == UniversalIO::DigitalInput )
shm->localSaveState( it->dit,it->si.id,(bool)val,shm->ID() );
it->value = val; it->value = val;
} }
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void IOBase::processingFasAI( IOBase* it, float val, SMInterface* shm, bool force ) void IOBase::processingFasAI( IOBase* it, float fval, SMInterface* shm, bool force )
{ {
long val = lroundf(fval);
if( it->cal.precision > 0 )
val = lroundf( fval * pow10(it->cal.precision) );
// //
if( it->check_channel_break(val) ) if( it->check_channel_break(val) )
{ {
...@@ -185,15 +194,16 @@ void IOBase::processingFasAI( IOBase* it, float val, SMInterface* shm, bool forc ...@@ -185,15 +194,16 @@ void IOBase::processingFasAI( IOBase* it, float val, SMInterface* shm, bool forc
if( it->value == ChannelBreakValue ) if( it->value == ChannelBreakValue )
shm->localSetUndefinedState(it->ait,false,it->si.id); shm->localSetUndefinedState(it->ait,false,it->si.id);
if( it->cal.precision > 0 )
val *= lroundf(pow10(it->cal.precision));
if( force || it->value != val ) if( force || it->value != val )
{ {
if( it->stype == UniversalIO::AnalogInput ) if( it->stype == UniversalIO::AnalogInput )
shm->localSaveValue( it->ait,it->si.id,val,shm->ID() ); shm->localSaveValue( it->ait,it->si.id,val,shm->ID() );
else if( it->stype == UniversalIO::AnalogOutput ) else if( it->stype == UniversalIO::AnalogOutput )
shm->localSetValue( it->ait,it->si.id,val,shm->ID() ); shm->localSetValue( it->ait,it->si.id,val,shm->ID() );
else if( it->stype == UniversalIO::DigitalOutput )
shm->localSetState( it->dit,it->si.id,(bool)val,shm->ID() );
else if( it->stype == UniversalIO::DigitalInput )
shm->localSaveState( it->dit,it->si.id,(bool)val,shm->ID() );
it->value = val; it->value = val;
} }
...@@ -223,6 +233,10 @@ void IOBase::processingAsDI( IOBase* it, bool set, SMInterface* shm, bool force ...@@ -223,6 +233,10 @@ void IOBase::processingAsDI( IOBase* it, bool set, SMInterface* shm, bool force
shm->localSaveState(it->dit,it->si.id,set,shm->ID()); shm->localSaveState(it->dit,it->si.id,set,shm->ID());
else if( it->stype == UniversalIO::DigitalOutput ) else if( it->stype == UniversalIO::DigitalOutput )
shm->localSetState(it->dit,it->si.id,set,shm->ID()); shm->localSetState(it->dit,it->si.id,set,shm->ID());
else if( it->stype == UniversalIO::AnalogInput )
shm->localSaveValue( it->ait,it->si.id,(set ? 1:0),shm->ID() );
else if( it->stype == UniversalIO::AnalogOutput )
shm->localSetValue( it->ait,it->si.id,(set ? 1:0),shm->ID() );
it->value = set ? 1 : 0; it->value = set ? 1 : 0;
} }
...@@ -292,6 +306,52 @@ bool IOBase::processingAsDO( IOBase* it, SMInterface* shm, bool force ) ...@@ -292,6 +306,52 @@ bool IOBase::processingAsDO( IOBase* it, SMInterface* shm, bool force )
return false; return false;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
float IOBase::processingFasAO( IOBase* it, SMInterface* shm, bool force )
{
uniset_spin_lock lock(it->val_lock);
long val = it->value;
if( force )
{
val = shm->localGetValue(it->ait,it->si.id);
it->value = val;
}
if( it->stype == UniversalIO::AnalogOutput ||
it->stype == UniversalIO::AnalogInput )
{
if( it->cdiagram ) //
{
if( it->cprev != it->value )
{
it->cprev = it->value;
val = it->cdiagram->getRawValue(val);
it->craw = val;
}
else
val = it->craw; //
}
else
{
float fval = val;
IOController_i::CalibrateInfo* cal( &(it->cal) );
if( cal->maxRaw!=0 && cal->maxRaw!=cal->minRaw ) //
{
// !!!
fval = UniSetTypes::fcalibrate(fval,
cal->minCal, cal->maxCal, cal->minRaw, cal->maxRaw, true );
}
if( it->cal.precision > 0 )
return ( fval / pow10(it->cal.precision) );
}
}
return val;
}
// -----------------------------------------------------------------------------
bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm, bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm,
DebugStream* dlog, std::string myname, DebugStream* dlog, std::string myname,
int def_filtersize, float def_filterT ) int def_filtersize, float def_filterT )
...@@ -347,20 +407,12 @@ bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm, ...@@ -347,20 +407,12 @@ bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm,
else else
b->safety = NoSafety; b->safety = NoSafety;
string stype( it.getProp("iotype") ); b->stype = UniSetTypes::getIOType(it.getProp("iotype"));
if( stype == "AI" ) if( b->stype == UniversalIO::UnknownIOType )
b->stype = UniversalIO::AnalogInput;
else if ( stype == "AO" )
b->stype = UniversalIO::AnalogOutput;
else if ( stype == "DO" )
b->stype = UniversalIO::DigitalOutput;
else if ( stype == "DI" )
b->stype = UniversalIO::DigitalInput;
else
{ {
if( dlog ) if( dlog )
dlog[Debug::CRIT] << myname << "(IOBase::readItem): iotype=: " dlog[Debug::CRIT] << myname << "(IOBase::readItem): iotype=: "
<< stype << " " << sname << endl; << it.getProp("iotype") << " " << sname << endl;
return false; return false;
} }
......
...@@ -41,7 +41,7 @@ int wsize( VType t ) ...@@ -41,7 +41,7 @@ int wsize( VType t )
if( t == vtF4 ) if( t == vtF4 )
return F4::wsize(); return F4::wsize();
return 0; return 1;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
} // end of namespace VTypes } // end of namespace VTypes
......
...@@ -130,8 +130,6 @@ namespace UniSetTypes ...@@ -130,8 +130,6 @@ namespace UniSetTypes
std::string getArgParam(const std::string name, const std::string defval=""); std::string getArgParam(const std::string name, const std::string defval="");
xmlNode* initDebug( DebugStream& deb, const std::string& nodename ); xmlNode* initDebug( DebugStream& deb, const std::string& nodename );
static bool file_exist( const std::string filename );
UniSetTypes::ListOfNode::const_iterator listNodesBegin() UniSetTypes::ListOfNode::const_iterator listNodesBegin()
{ {
return lnodes.begin(); return lnodes.begin();
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <string> #include <string>
#include <list> #include <list>
#include <limits> #include <limits>
#include <ostream>
#include <omniORB4/CORBA.h> #include <omniORB4/CORBA.h>
#include "UniSetTypes_i.hh" #include "UniSetTypes_i.hh"
...@@ -49,6 +50,9 @@ namespace UniSetTypes ...@@ -49,6 +50,9 @@ namespace UniSetTypes
typedef CORBA::Object_ptr ObjectPtr; /*!< ObjectRepository */ typedef CORBA::Object_ptr ObjectPtr; /*!< ObjectRepository */
typedef CORBA::Object_var ObjectVar; /*!< ObjectRepository */ typedef CORBA::Object_var ObjectVar; /*!< ObjectRepository */
UniversalIO::IOTypes getIOType( const std::string s );
std::ostream& operator<<( std::ostream& os, const UniversalIO::IOTypes t );
/*! */ /*! */
enum LampCommand enum LampCommand
{ {
...@@ -213,6 +217,8 @@ namespace UniSetTypes ...@@ -213,6 +217,8 @@ namespace UniSetTypes
std::sscanf(str,"%x",&n); std::sscanf(str,"%x",&n);
return n; return n;
} }
bool file_exist( const std::string filename );
IDList explode( const std::string str, char sep=',' ); IDList explode( const std::string str, char sep=',' );
} }
......
...@@ -139,7 +139,7 @@ namespace ModbusRTU ...@@ -139,7 +139,7 @@ namespace ModbusRTU
const DataBits& operator=(const ModbusByte& r); const DataBits& operator=(const ModbusByte& r);
operator ModbusByte(); operator ModbusByte();
ModbusByte mbyte(); ModbusByte mbyte();
bool operator[]( const int i ){ return b[i]; } bool operator[]( const int i ){ return b[i]; }
...@@ -158,9 +158,12 @@ namespace ModbusRTU ...@@ -158,9 +158,12 @@ namespace ModbusRTU
const DataBits16& operator=(const ModbusData& r); const DataBits16& operator=(const ModbusData& r);
operator ModbusData(); operator ModbusData();
ModbusData mdata(); ModbusData mdata();
bool operator[]( const int i ){ return b[i]; }
void set( int n, bool s ){ b.set(n,s); }
std::bitset<BitsPerData> b; std::bitset<BitsPerData> b;
}; };
......
...@@ -78,6 +78,7 @@ void UniversalInterface::init() ...@@ -78,6 +78,7 @@ void UniversalInterface::init()
// NameSerivice // NameSerivice
// . ޣ // . ޣ
// localIOR // localIOR
localctx=CosNaming::NamingContext::_nil();
try try
{ {
if( CORBA::is_nil(orb) ) if( CORBA::is_nil(orb) )
...@@ -88,13 +89,20 @@ void UniversalInterface::init() ...@@ -88,13 +89,20 @@ void UniversalInterface::init()
else else
localctx = ORepHelpers::getRootNamingContext( orb, oind->getRealNodeName(uconf->getLocalNode()) ); localctx = ORepHelpers::getRootNamingContext( orb, oind->getRealNodeName(uconf->getLocalNode()) );
} }
catch(Exception& ex ) catch( Exception& ex )
{ {
if( !uconf->isLocalIOR() ) if( !uconf->isLocalIOR() )
throw ex; throw ex;
localctx=CosNaming::NamingContext::_nil(); localctx=CosNaming::NamingContext::_nil();
} }
catch( ... )
{
if( !uconf->isLocalIOR() )
throw;
localctx=CosNaming::NamingContext::_nil();
}
} }
// ------------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------------
void UniversalInterface::initBackId( UniSetTypes::ObjectId backid ) void UniversalInterface::initBackId( UniSetTypes::ObjectId backid )
...@@ -1563,27 +1571,22 @@ void UniversalInterface::registered( UniSetTypes::ObjectId id, UniSetTypes::Obje ...@@ -1563,27 +1571,22 @@ void UniversalInterface::registered( UniSetTypes::ObjectId id, UniSetTypes::Obje
{ {
// ޣ // ޣ
// IOR // IOR
// ݣ
// NameService (omniNames)
if( uconf->isLocalIOR() ) if( uconf->isLocalIOR() )
{ {
if( CORBA::is_nil(orb) ) if( CORBA::is_nil(orb) )
orb = uconf->getORB(); orb = uconf->getORB();
string sior(orb->object_to_string(oRef)); uconf->iorfile.setIOR(id,node,orb->object_to_string(oRef));
uconf->iorfile.setIOR(id,node,sior);
return; return;
} }
try try
{ {
string nm=oind->getNameById(id, node); rep.registration(oind->getNameById(id, node),oRef,(bool)force);
rep.registration(nm,oRef,(bool)force);
} }
catch(Exception& ex ) catch(Exception& ex )
{ {
if( !uconf->isLocalIOR() ) throw;
throw;
} }
} }
...@@ -1591,17 +1594,18 @@ void UniversalInterface::registered( UniSetTypes::ObjectId id, UniSetTypes::Obje ...@@ -1591,17 +1594,18 @@ void UniversalInterface::registered( UniSetTypes::ObjectId id, UniSetTypes::Obje
void UniversalInterface::unregister(UniSetTypes::ObjectId id, UniSetTypes::ObjectId node)throw(ORepFailed) void UniversalInterface::unregister(UniSetTypes::ObjectId id, UniSetTypes::ObjectId node)throw(ORepFailed)
{ {
if( uconf->isLocalIOR() ) if( uconf->isLocalIOR() )
{
uconf->iorfile.unlinkIOR(id,node); uconf->iorfile.unlinkIOR(id,node);
return;
}
try try
{ {
string nm = oind->getNameById(id,node); rep.unregistration(oind->getNameById(id,node));
rep.unregistration(nm);
} }
catch(Exception& ex ) catch(Exception& ex )
{ {
if( !uconf->isLocalIOR() ) throw;
throw;
} }
} }
...@@ -1638,14 +1642,17 @@ ObjectPtr UniversalInterface::resolve( ObjectId rid , ObjectId node, int timeout ...@@ -1638,14 +1642,17 @@ ObjectPtr UniversalInterface::resolve( ObjectId rid , ObjectId node, int timeout
{ {
// NameService , // NameService ,
// //
if( CORBA::is_nil(localctx) ) // if( CORBA::is_nil(localctx) )
{ // {
unideb[Debug::WARN] << " IOR- " << uconf->oind->getNameById(rid,node) << endl; if( unideb.debugging(Debug::WARN) )
{
unideb[Debug::WARN] << " IOR- " << uconf->oind->getNameById(rid,node) << endl;
}
throw UniSetTypes::ResolveNameError(); throw UniSetTypes::ResolveNameError();
} // }
// NameService (omniNames) // NameService (omniNames)
unideb[Debug::WARN] << " IOR- " << uconf->oind->getNameById(rid,node) // unideb[Debug::WARN] << " IOR- " << uconf->oind->getNameById(rid,node)
<< " NameService \n"; // << " NameService \n";
} }
} }
...@@ -2314,17 +2321,21 @@ bool UniversalInterface::isExist( UniSetTypes::ObjectId id ) ...@@ -2314,17 +2321,21 @@ bool UniversalInterface::isExist( UniSetTypes::ObjectId id )
{ {
try try
{ {
/* if( uconf->isLocalIOR() )
try
{ {
oref = rcache.resolve(id, uconf->getLocalNode()); if( CORBA::is_nil(orb) )
} orb = uconf->getORB();
catch(NameNotFound){}
if(!oref) string sior(uconf->iorfile.getIOR(id,uconf->getLocalNode()));
oref = resolve(id, uconf->getLocalNode()); if( !sior.empty() )
return rep.isExist( oref ); {
*/ CORBA::Object_var oref = orb->string_to_object(sior.c_str());
return rep.isExist( oref );
}
return false;
}
string nm = oind->getNameById(id); string nm = oind->getNameById(id);
return rep.isExist(nm); return rep.isExist(nm);
} }
...@@ -2332,7 +2343,7 @@ bool UniversalInterface::isExist( UniSetTypes::ObjectId id ) ...@@ -2332,7 +2343,7 @@ bool UniversalInterface::isExist( UniSetTypes::ObjectId id )
{ {
// unideb[Debug::WARN] << "UI(isExist): " << ex << endl; // unideb[Debug::WARN] << "UI(isExist): " << ex << endl;
} }
catch(...){} catch(...){}
return false; return false;
} }
// ------------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------------
...@@ -2350,7 +2361,7 @@ bool UniversalInterface::isExist( UniSetTypes::ObjectId id, UniSetTypes::ObjectI ...@@ -2350,7 +2361,7 @@ bool UniversalInterface::isExist( UniSetTypes::ObjectId id, UniSetTypes::ObjectI
} }
catch(NameNotFound){} catch(NameNotFound){}
if( CORBA::is_nil(oref) ) if( CORBA::is_nil(oref) )
oref = resolve(id, node); oref = resolve(id, node);
return rep.isExist( oref ); return rep.isExist( oref );
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
*/ */
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#include <cmath> #include <cmath>
#include <fstream>
#include "UniSetTypes.h" #include "UniSetTypes.h"
#include "Configuration.h" #include "Configuration.h"
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -163,6 +164,23 @@ using namespace UniSetTypes; ...@@ -163,6 +164,23 @@ using namespace UniSetTypes;
return seq; return seq;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
bool UniSetTypes::file_exist( const std::string filename )
{
std::ifstream file;
#ifdef HAVE_IOS_NOCREATE
file.open( filename.c_str(), std::ios::in | std::ios::nocreate );
#else
file.open( filename.c_str(), std::ios::in );
#endif
bool result = false;
if( file )
result = true;
file.close();
return result;
}
// -------------------------------------------------------------------------
UniSetTypes::IDList UniSetTypes::explode( const string str, char sep ) UniSetTypes::IDList UniSetTypes::explode( const string str, char sep )
{ {
UniSetTypes::IDList l; UniSetTypes::IDList l;
...@@ -184,3 +202,34 @@ using namespace UniSetTypes; ...@@ -184,3 +202,34 @@ using namespace UniSetTypes;
return l; return l;
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
UniversalIO::IOTypes UniSetTypes::getIOType( const std::string stype )
{
if( stype == "AI" )
return UniversalIO::AnalogInput;
if ( stype == "AO" )
return UniversalIO::AnalogOutput;
if ( stype == "DO" )
return UniversalIO::DigitalOutput;
if ( stype == "DI" )
return UniversalIO::DigitalInput;
return UniversalIO::UnknownIOType;
}
// ------------------------------------------------------------------------------------------
std::ostream& UniSetTypes::operator<<( std::ostream& os, const UniversalIO::IOTypes t )
{
if( t == UniversalIO::AnalogInput )
return os << "AI";
if( t == UniversalIO::DigitalInput )
return os << "DI";
if( t == UniversalIO::AnalogOutput )
return os << "AO";
if( t == UniversalIO::DigitalOutput )
return os << "DO";
return os << "UnknownIOType";
}
// ------------------------------------------------------------------------------------------
...@@ -890,23 +890,6 @@ string Configuration::getPort() ...@@ -890,23 +890,6 @@ string Configuration::getPort()
return UniSetDefaultPort; return UniSetDefaultPort;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
bool Configuration::file_exist( const string filename )
{
std::ifstream file;
#ifdef HAVE_IOS_NOCREATE
file.open( filename.c_str(), std::ios::in | std::ios::nocreate );
#else
file.open( filename.c_str(), std::ios::in );
#endif
bool result(false);
if( file )
result = true;
file.close();
return result;
}
// -------------------------------------------------------------------------
ObjectId Configuration::getSensorID( const std::string name ) ObjectId Configuration::getSensorID( const std::string name )
{ {
return oind->getIdByName(conf->getSensorsSection()+"/"+name); return oind->getIdByName(conf->getSensorsSection()+"/"+name);
......
...@@ -147,6 +147,9 @@ void NCRestorer_XML::read_list( UniXML& xml, xmlNode* node, IONotifyController* ...@@ -147,6 +147,9 @@ void NCRestorer_XML::read_list( UniXML& xml, xmlNode* node, IONotifyController*
} }
} }
break; break;
default:
break;
} }
rslot(xml,it,node); rslot(xml,it,node);
...@@ -276,21 +279,12 @@ bool NCRestorer_XML::getSensorInfo( UniXML& xml, xmlNode* it, SInfo& inf ) ...@@ -276,21 +279,12 @@ bool NCRestorer_XML::getSensorInfo( UniXML& xml, xmlNode* it, SInfo& inf )
} }
} }
string iotype(xml.getProp(it,"iotype"));
if( iotype=="DI" ) inf.type = UniSetTypes::getIOType(xml.getProp(it,"iotype"));
inf.type=UniversalIO::DigitalInput; if( inf.type == UniversalIO::UnknownIOType )
else if( iotype=="AI" )
inf.type=UniversalIO::AnalogInput;
else if( iotype=="AO" )
inf.type=UniversalIO::AnalogOutput;
else if( iotype=="DO" )
inf.type=UniversalIO::DigitalOutput;
else
{ {
unideb[Debug::CRIT] << "(NCRestorer_XML:getSensorInfo): (" unideb[Debug::CRIT] << "(NCRestorer_XML:getSensorInfo): unknown iotype=" << xml.getProp(it,"iotype")
<< iotype << ") / " << " for " << xml.getProp(it,"name") << endl;
<< xml.getProp(it,"name") << endl;
return false; return false;
} }
......
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