22#ifndef IOController_H_
23#define IOController_H_
25#include <unordered_map>
28#include <sigc++/sigc++.h>
29#include "IOController_i.hh"
30#include "UniSetTypes.h"
31#include "UniSetManager.h"
32#include "Configuration.h"
35#include "AccessMask.h"
36#include "AccessConfig.h"
51 public POA_IOController_i
55 IOController(
const std::string& name,
const std::string& section );
57 virtual ~IOController();
59 void setDBServer(
const std::shared_ptr<uniset::DBServer>& dbserver );
77 CORBA::Boolean undefined,
91 virtual IOController_i::SensorInfoSeq* getSensorsMap(
uniset::ObjectId sup_id )
override;
114 virtual IOController_i::ShortMapSeq* getSensors(
const uniset::ObjectId consumer_id )
override;
116#ifndef DISABLE_REST_API
118 virtual Poco::JSON::Object::Ptr httpHelp(
const Poco::URI::QueryParameters& p )
override;
126 typedef std::unordered_map<uniset::ObjectId, std::shared_ptr<USensorInfo>> IOStateList;
128 static const long not_specified_value = { std::numeric_limits<long>::max() };
136 typedef sigc::signal<void, std::shared_ptr<USensorInfo>&, IOController*>
ChangeSignal;
137 typedef sigc::signal<void, std::shared_ptr<USensorInfo>&, IOController*> ChangeUndefinedStateSignal;
146 ChangeUndefinedStateSignal signal_change_undefined_state(
uniset::ObjectId sid );
147 ChangeUndefinedStateSignal signal_change_undefined_state();
153 inline IOStateList::iterator ioBegin()
155 return ioList.begin();
157 inline IOStateList::iterator ioEnd()
163 return ioList.find(k);
166 inline int ioCount() const noexcept
168 return ioList.size();
175 virtual long localSetValueIt( IOStateList::iterator& it,
const uniset::ObjectId sid,
187 virtual void localFreezeValueIt( IOController::IOStateList::iterator& li,
193 virtual void localFreezeValue( std::shared_ptr<USensorInfo>& usi,
200 virtual long localSetValue( std::shared_ptr<USensorInfo>& usi, CORBA::Long value,
uniset::ObjectId sup_id );
201 long localGetValue( std::shared_ptr<USensorInfo>& usi,
const uniset::ObjectId consumer_id ) ;
203#ifndef DISABLE_REST_API
205 virtual Poco::JSON::Object::Ptr request_get(
const std::string& req,
const Poco::URI::QueryParameters& p );
206 virtual Poco::JSON::Object::Ptr request_set(
const std::string& req,
const Poco::URI::QueryParameters& p );
207 virtual Poco::JSON::Object::Ptr request_freeze(
const std::string& req,
const Poco::URI::QueryParameters& p,
bool set );
208 virtual Poco::JSON::Object::Ptr request_sensors(
const std::string& req,
const Poco::URI::QueryParameters& p );
209 void getSensorInfo( Poco::JSON::Array::Ptr& jdata, std::shared_ptr<USensorInfo>& s,
uniset::ObjectId consumer_id,
bool shortInfo =
false );
227 typedef sigc::signal<void, std::shared_ptr<USensorInfo>&,
IOController*> InitSignal;
230 InitSignal signal_init();
239 void reloadACLConfig( uniset::ACLMap& amap, uniset::ACLInfoMap& iomap );
244 uniset::Message::Priority p = uniset::Message::Medium,
254 ai.default_val = defval;
257 ai.supplier = sup_id;
258 ai.depend_sid = depend_sid;
275 virtual void logging( uniset::SensorMessage& sm );
283 IOStateList::iterator myioBegin();
284 IOStateList::iterator myioEnd();
287 void initIOList(
const IOStateList&& l );
289 typedef std::function<void(std::shared_ptr<USensorInfo>&)> UFunction;
291 void for_iolist( UFunction f );
293 void setDefaultAccessMask( uniset::AccessMask m );
296 friend class NCRestorer;
297 friend class SMInterface;
299 std::mutex siganyMutex;
302 std::mutex siganyundefMutex;
307 uniset::uniset_rwmutex ioMutex;
311 std::shared_ptr<uniset::DBServer> dbserver = {
nullptr };
313 std::mutex loggingMutex;
315 uniset::AccessMask defaultAccessMask = { uniset::AccessRW };
320 typedef std::list<std::shared_ptr<UThresholdInfo>> ThresholdExtList;
325 USensorInfo(
const USensorInfo& ) =
delete;
326 const USensorInfo& operator=(
const USensorInfo& ) =
delete;
327 USensorInfo( USensorInfo&& ) =
default;
328 USensorInfo& operator=(USensorInfo&& ) =
default;
331 virtual ~USensorInfo() {}
345 static const size_t MaxUserData = 4;
346 void*
userdata[MaxUserData] = {
nullptr,
nullptr,
nullptr,
nullptr };
349 void* getUserData(
size_t index );
350 void setUserData(
size_t index,
void* data );
358 ChangeUndefinedStateSignal sigUndefChange;
362 std::shared_ptr<USensorInfo> d_usi;
366 ThresholdExtList thresholds;
368 size_t nchanges = { 0 };
370 long undef_value = { not_specified_value };
371 long frozen_value = { 0 };
373 bool readonly = {
false };
375 std::string aclName = {
"" };
376 uniset::ACLPtr acl = {
nullptr };
377 uniset::AccessMask checkMask(
uniset::ObjectId,
const AccessMask& defaultMask)
const;
380 void checkDepend( std::shared_ptr<USensorInfo>& d_usi, IOController* );
382 void init(
const IOController_i::SensorIOInfo& s );
384 inline IOController_i::SensorIOInfo makeSensorIOInfo()
386 uniset::uniset_rwmutex_rlock lock(
val_lock);
387 IOController_i::SensorIOInfo s(*
this);
391 inline uniset::SensorMessage makeSensorMessage(
bool with_lock =
false )
393 uniset::SensorMessage sm;
396 sm.sensor_type =
type;
397 sm.priority = (uniset::Message::Priority)
priority;
402 uniset::uniset_rwmutex_rlock lock(
val_lock);
425 struct UThresholdInfo:
443 IOController::IOStateList::iterator
sit;
448 inline bool operator== (
const ThresholdInfo& r )
const
450 return ((
id == r.id) &&
Определения IOController.h:52
virtual void dumpToDB()
сохранение состояния всех датчиков в БД
Определения IOController.cc:598
virtual void sensorsUnregistration()
Определения IOController.cc:87
bool disabledHttpFreezeApi
Определения IOController.h:211
bool disabledHttpSetApi
Определения IOController.h:210
virtual void activateInit()
Определения IOController.cc:108
virtual bool deactivateObject() override
Определения IOController.cc:81
virtual void sensorsRegistration()
Определения IOController.h:223
virtual bool activateObject() override
Определения IOController.cc:70
void ioUnRegistration(const uniset::ObjectId sid)
Определения IOController.cc:552
virtual void localSetUndefinedState(IOStateList::iterator &it, bool undefined, const uniset::ObjectId sid)
Определения IOController.cc:201
bool disableHttpAccessControl
Определения IOController.h:212
void reloadACLConfig(uniset::ACLMap &amap, uniset::ACLInfoMap &iomap)
Определения IOController.cc:1049
void ioRegistration(std::shared_ptr< USensorInfo > &usi)
Определения IOController.cc:514
sigc::signal< void, std::shared_ptr< USensorInfo > &, IOController * > ChangeSignal
Определения IOController.h:136
virtual void logging(uniset::SensorMessage &sm)
сохранение информации об изменении состояния датчика
Определения IOController.cc:562
@ NormalThreshold
Определения IOController_i.idl:211
Определения Calibration.h:27
string< SizeOfObjectType > ObjectType
Определения UniSetTypes_i.idl:33
long ThresholdId
Определения UniSetTypes_i.idl:31
sequence< ObjectId > IDSeq
Определения UniSetTypes_i.idl:89
const ObjectId DefaultObjectId
Определения UniSetTypes.h:71
std::shared_ptr< Configuration > uniset_conf() noexcept
Определения Configuration.cc:106
long ObjectId
Определения UniSetTypes_i.idl:30
Определения IOController_i.idl:89
Определения IOController_i.idl:103
uniset::ObjectId supplier
Определения IOController_i.idl:116
unsigned long tv_sec
Определения IOController_i.idl:114
boolean undefined
Определения IOController_i.idl:105
CalibrateInfo ci
Определения IOController_i.idl:113
UniversalIO::IOType type
Определения IOController_i.idl:109
long priority
Определения IOController_i.idl:110
unsigned long tv_nsec
Определения IOController_i.idl:115
long value
Определения IOController_i.idl:104
Определения IOController_i.idl:64
uniset::ObjectId node
Определения IOController_i.idl:66
uniset::ObjectId id
Определения IOController_i.idl:65
Определения IOController_i.idl:150
Определения IOController_i.idl:216
long lowlimit
Определения IOController_i.idl:219
long hilimit
Определения IOController_i.idl:218
Определения IOController.h:324
void * userdata[MaxUserData]
Определения IOController.h:346
uniset::uniset_rwmutex userdata_lock
Определения IOController.h:347
long d_off_value
Определения IOController.h:361
long d_value
Определения IOController.h:360
uniset::uniset_rwmutex val_lock
Определения IOController.h:342
Определения IOController.h:427
IOController::IOStateList::iterator sit
Определения IOController.h:443
uniset::ObjectId sid
Определения IOController.h:440
bool invert
Определения IOController.h:446
Определения UniSetTypes_i.idl:65
Определения UHttpRequestHandler.h:87