Serveur OPCUA générique
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Définitions de type Macros
cta_ua_alarmmanager.h
Aller à la documentation de ce fichier.
1 #ifndef __CTAUAALARMMANAGER_H__
2 #define __CTAUAALARMMANAGER_H__
3 
4 #include "historymanagerbase.h"
5 #include "uabasenodes.h"
6 #include "servermanager.h"
7 
8 #include "nodemanagerbase.h"
9 
10 namespace CTA_Slc_Dict {
11 struct AlarmStruct;
12 }
13 
14 namespace CTA_UA {
15 class ControllerObject;
16 }
17 
18 namespace CTA_UA {
19 
20 class AlarmVariable: public IOVariableCallback {
21 
22  UA_DISABLE_COPY(AlarmVariable);
23 
24 public:
26  CTA_Slc_Dict::AlarmStruct *alarmStruct);
27  virtual ~AlarmVariable();
28  // Interface IOVariableCallback
29 
30  void dataChange(const UaDataValue& dataValue);
31  UaDataValue getLastValue();
32 
33  // Mutex for the data and settings
34  UaMutex m_mutex;
35 
36  // Variable to historize
37  UaVariable* m_pVariable;
38  // MonitoredItemId for internal monitoring
39  OpcUa_UInt32 m_monitoredItemId;
40 
41  // Flag indicating if the variable is valid
42  OpcUa_Boolean m_isValid;
43 
44  // Memory buffer for the changed values
45  std::list<UaDataValue> m_values;
48 };
49 
50 class AlarmManager: public HistoryManagerBase {
51  UA_DISABLE_COPY(AlarmManager);
52 
53 public:
54  AlarmManager();
55  virtual ~AlarmManager();
56  virtual UaStatus readRaw(const ServiceContext& serviceContext,
57  HistoryVariableHandle* pVariableHandle,
58  HistoryReadCPUserDataBase** ppContinuationPoint,
59  OpcUa_TimestampsToReturn timestampsToReturn, OpcUa_UInt32 maxValues,
60  OpcUa_DateTime& startTime, OpcUa_DateTime& endTime,
61  OpcUa_Boolean returnBounds, UaDataValues& dataValues);
62 
63  // Start up history manager for internal monitoring
64  void startUp(ServerManager* pServerManager);
65 
66  // Shut down history manager to stop internal monitoring
67  void shutDown();
68 
69  // Add a variable for historizing - must be called before startUp
70  void addVariableToAlarm(UaNode* pNode, CTA_UA::ControllerObject *pControler,
71  CTA_Slc_Dict::AlarmStruct *alarmStruct);
72 
73 private:
74  // List of variable to historize
75  std::map<UaNodeId, AlarmVariable*> m_mapVariables;
76 
77  // Internal session used for monitoring
78  Session* m_pSession;
79 
80  // Server manager used for internal monitoring
81  ServerManager* m_pServerManager;
82 };
83 
84 } // end namespace
85 #endif // __CTAUAALARMMANAGER_H__