Commit 32852a64 authored by Aleksey Vinogradov's avatar Aleksey Vinogradov

еще правки в unet для возможности наследования

parent 6700fc00
......@@ -95,6 +95,7 @@ class UNetExchange:
/*! игнорировать запись датчика в SM */
void ignore_item(UniSetTypes::ObjectId id = UniSetTypes::DefaultObjectId, bool set = true);
protected:
UNetExchange();
xmlNode* cnode;
std::string s_field;
......@@ -129,7 +130,6 @@ class UNetExchange:
};
private:
UNetExchange();
bool initPause;
UniSetTypes::uniset_mutex mutex_start;
......
......@@ -366,7 +366,60 @@ void UNetReceiver::real_update()
}
}
}
// -----------------------------------------------------------------------------
void UNetReceiver::updateDItem( ItemInfo& ii, const long& id, bool val )
{
try
{
if( ii.iotype == UniversalIO::DigitalInput )
shm->localSaveState(ii.dit,id,val,shm->ID());
else if( ii.iotype == UniversalIO::AnalogInput )
shm->localSaveValue(ii.ait,id,val,shm->ID());
else if( ii.iotype == UniversalIO::AnalogOutput )
shm->localSetValue(ii.ait,id,val,shm->ID());
else if( ii.iotype == UniversalIO::DigitalOutput )
shm->localSetState(ii.dit,id,val,shm->ID());
else
dlog[Debug::CRIT] << myname << "(updateAItem): Unknown iotype for sid=" << id << endl;
}
catch( UniSetTypes::Exception& ex)
{
dlog[Debug::CRIT] << myname << "(updateAItem): " << ex << std::endl;
throw ex;
}
catch(...)
{
dlog[Debug::CRIT] << myname << "(updateAItem): catch ..." << std::endl;
throw;
}
}
// -----------------------------------------------------------------------------
void UNetReceiver::updateAItem( ItemInfo& ii, const UniSetUDP::UDPAData& d )
{
try
{
if( ii.iotype == UniversalIO::DigitalInput )
shm->localSaveState(ii.dit,d.id,d.val,shm->ID());
else if( ii.iotype == UniversalIO::AnalogInput )
shm->localSaveValue(ii.ait,d.id,d.val,shm->ID());
else if( ii.iotype == UniversalIO::AnalogOutput )
shm->localSetValue(ii.ait,d.id,d.val,shm->ID());
else if( ii.iotype == UniversalIO::DigitalOutput )
shm->localSetState(ii.dit,d.id,d.val,shm->ID());
else
dlog[Debug::CRIT] << myname << "(updateAItem): Unknown iotype for sid=" << d.id << endl;
}
catch( UniSetTypes::Exception& ex)
{
dlog[Debug::CRIT] << myname << "(updateAItem): " << ex << std::endl;
throw ex;
}
catch(...)
{
dlog[Debug::CRIT] << myname << "(updateAItem): catch ..." << std::endl;
throw;
}
}
// -----------------------------------------------------------------------------
void UNetReceiver::stop()
{
......
......@@ -97,6 +97,7 @@ class UNetReceiver
void ignore_item(UniSetTypes::ObjectId id = UniSetTypes::DefaultObjectId, bool set = true);
protected:
UNetReceiver();
SMInterface* shm;
......@@ -104,10 +105,33 @@ class UNetReceiver
void step();
virtual void real_update();
std::string myname;
struct ItemInfo
{
long id;
IOController::AIOStateList::iterator ait;
IOController::DIOStateList::iterator dit;
UniversalIO::IOTypes iotype;
bool ignore; /*!< флаг игнорирования сохранения в SM*/
ItemInfo():
id(UniSetTypes::DefaultObjectId),
iotype(UniversalIO::UnknownIOType),
ignore(false){}
};
virtual void updateDItem( ItemInfo& ii, const long& id, bool val );
virtual void updateAItem( ItemInfo& ii, const UniSetUDP::UDPAData& d );
void initIterators();
typedef std::vector<ItemInfo> ItemVec;
ItemVec d_icache; /*!< кэш итераторов для булевых */
ItemVec a_icache; /*!< кэш итераторов для аналоговых */
bool d_cache_init_ok;
bool a_cache_init_ok;
private:
UNetReceiver();
int recvpause; /*!< пауза меджду приёмами пакетов, [мсек] */
int updatepause; /*!< переодичность обновления данных в SM, [мсек] */
......@@ -115,7 +139,6 @@ class UNetReceiver
ost::UDPReceive* udp;
ost::IPV4Address addr;
ost::tpport_t port;
std::string myname;
UniSetTypes::uniset_mutex pollMutex;
PassiveTimer ptRecvTimeout;
......@@ -170,27 +193,6 @@ class UNetReceiver
Trigger trTimeout;
UniSetTypes::uniset_mutex tmMutex;
struct ItemInfo
{
long id;
IOController::AIOStateList::iterator ait;
IOController::DIOStateList::iterator dit;
UniversalIO::IOTypes iotype;
bool ignore; /*!< флаг игнорирования сохранения в SM*/
ItemInfo():
id(UniSetTypes::DefaultObjectId),
iotype(UniversalIO::UnknownIOType),
ignore(false){}
};
typedef std::vector<ItemInfo> ItemVec;
ItemVec d_icache; /*!< кэш итераторов для булевых */
ItemVec a_icache; /*!< кэш итераторов для аналоговых */
bool d_cache_init_ok;
bool a_cache_init_ok;
virtual void initDCache( UniSetUDP::UDPMessage& pack, bool force=false );
virtual void initACache( UniSetUDP::UDPMessage& pack, bool force=false );
};
......
......@@ -66,7 +66,13 @@ class UNetSender
void initIterators();
protected:
UNetSender();
std::string myname;
UniSetUDP::UDPMessage mypack;
DMap dlist;
int maxItem;
std::string s_field;
std::string s_fvalue;
......@@ -78,21 +84,16 @@ class UNetSender
virtual void readConfiguration();
private:
UNetSender();
ost::UDPBroadcast* udp;
ost::IPV4Address addr;
ost::tpport_t port;
std::string s_host;
std::string myname;
int sendpause;
bool activated;
UniSetTypes::uniset_mutex pack_mutex;
UniSetUDP::UDPMessage mypack;
DMap dlist;
int maxItem;
unsigned long packetnum;
UniSetUDP::UDPPacket s_msg;
......
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