Nix (Dev) 3.5.10
dev - 3.5.10 - 1af9301
Loading...
Searching...
No Matches
Station.hpp
Go to the documentation of this file.
1#ifndef IV_SRC_MODEL_DIAMAR_STATION_HPP_
2#define IV_SRC_MODEL_DIAMAR_STATION_HPP_
3
5#include "core/defines.hpp"
6#include "core/enums.hpp"
7#include "core/structs.hpp"
8#include "core/system.hpp"
10#include "model/enums.hpp"
11#include "model/structs.hpp"
12
13#include <memory>
14#include <set>
15#include <vector>
16
17namespace iv::diamar
18{
19
21{
22 std::vector<std::shared_ptr<iv::model::comms::NetworkData>> readNetworkDatas;
24 bool hasRetrofitNetwork {false};
25};
26
28{
29 struct Settings
30 {
31 bool canBlockAck {false};
32 bool localSoundOff {false};
33
34 bool canConfigureVolume {true};
36
39
40 bool load(const iv::file::xml::node &nodeSettings);
41 bool save(iv::file::xml::node &nodeSetings) const;
42 };
43
44public:
45 bool load(const iv::file::xml::node &nodeStation, iv::diamar::StationNetworksLoadData &readNetworksInfo);
46 bool save(iv::file::xml::node &nodeStation,
47 const std::vector<std::shared_ptr<iv::model::comms::NetworkData>> &stationNetworks) const;
48 [[nodiscard]] std::shared_ptr<Station> clone() const;
49 void update(const Station &other);
50
52
60
61 [[nodiscard]] std::set<iv::types::ipAddress> getIps() const;
62 std::set<iv::types::ipAddress> &getIpsRef();
63 void setIps(std::set<iv::types::ipAddress> ipAddresses);
64
65 [[nodiscard]] std::weak_ptr<iv::channels::AbstractChannel> getStationHeartbeatChannel() const;
66 [[nodiscard]] std::weak_ptr<iv::channels::AbstractChannel> getStationFailureChannel() const;
67
68 void setStationHeartbeatChannel(const std::shared_ptr<iv::channels::AbstractChannel> &channel);
69 void setStationFailureChannel(const std::shared_ptr<iv::channels::AbstractChannel> &channel);
70
71 [[nodiscard]] bool isOn() const;
72
75 // Getter and setter for the unit's last heartbeat
77 const std::map<iv::types::unitId, std::map<iv::comms::eLomLine, iv::types::timestamp>> &lastHeartbeats);
78 [[nodiscard]] std::map<iv::types::unitId, std::map<iv::comms::eLomLine, iv::types::timestamp>>
80
81private:
82 bool loadIp(const iv::file::xml::node &nodeStation);
83 bool saveIp(iv::file::xml::node &nodeStation) const;
84
85 bool loadNetworks(const iv::file::xml::node &nodeStation,
86 iv::diamar::StationNetworksLoadData &readNetworksInfo) const;
87 bool saveNetworks(iv::file::xml::node &nodeStation,
88 const std::vector<std::shared_ptr<iv::model::comms::NetworkData>> &stationNetworks) const;
89
90 std::weak_ptr<iv::channels::AbstractChannel> m_stationHeartbeatChannel;
91 std::weak_ptr<iv::channels::AbstractChannel>
99 std::set<iv::types::ipAddress> m_ip;
100
103
104 std::map<iv::types::unitId, std::map<iv::comms::eLomLine, iv::types::timestamp>>
107
108 struct Keys
109 {
110 static constexpr std::string_view stationId {"Id"};
111 static constexpr std::string_view shipArea {"ShipArea"};
112
113 static constexpr std::string_view canBlockACK {"CanBlockACK"};
114 static constexpr std::string_view localSoundOFF {"LocalSoundOFF"};
115 static constexpr std::string_view hideWatchCallPanel {"HideWatchCallPanel"};
116 static constexpr std::string_view canConfigureVolume {"CanConfigureVolume"};
117 static constexpr std::string_view canConfigureBrightness {"CanConfigureBrightness"};
118
119 static constexpr std::string_view heartbeatChannel {"HeartbeatChannel"};
120 static constexpr std::string_view failureChannel {"FailureChannel"};
121
122 static constexpr std::string_view ip {"Ip"};
123 };
124
125 struct Sections
126 {
127 static constexpr std::string_view settings {"Settings"};
128 static constexpr std::string_view ipAddresses {"IpAddresses"};
129 static constexpr std::string_view ipAddress {"IpAddress"};
130 static constexpr std::string_view networks {"Networks"};
131 static constexpr std::string_view network {"Network"};
132 static constexpr std::string_view networkCommInterfaceSettings {"Interface"};
133 static constexpr std::string_view networkCommProtocolSettings {"Protocol"};
134 static constexpr std::string_view alarmPrinter {"AlarmPrinter"};
135 static constexpr std::string_view printer {"Printer"};
136
137 struct Network
138 {
139 static constexpr std::string_view httpSetting {"HttpSetting"};
140 };
141 };
142
144 {
145 static constexpr std::string string {};
146 static constexpr bool isEnabled {};
147 static constexpr std::string shipArea {"Ecr"};
148 };
149};
150
152{
153public:
154 bool load(const iv::file::xml::File &xml);
155 [[nodiscard]] bool save(const std::shared_ptr<iv::file::xml::File> &xml) const;
156 void update(const iv::diamar::Stations &other);
157
158 bool insertNetworkData(const iv::types::stationId &stationId,
159 const std::shared_ptr<iv::model::comms::NetworkData> &networkData);
160 void changeNetworkId(const iv::types::networkId &previousNetworkID, const iv::types::networkId &newNetworkID);
162 bool removeNetworkData(const iv::types::networkId &networkId);
163
164 void changeStationId(const iv::types::stationId &previousStationID, const iv::types::stationId &newStationID);
166 void addStationDefaultNetworks(iv::types::stationId stationId, bool addLoggers = true, bool addRedundancy = true);
167
168 [[nodiscard]] std::shared_ptr<Station>
170 [[nodiscard]] const std::map<iv::types::stationId, std::shared_ptr<iv::diamar::Station>> &getAll() const;
171 [[nodiscard]] const std::map<iv::types::stationId, std::set<iv::types::networkId>> &getStationWithNetworks() const;
172
173 void addStation(const std::shared_ptr<Station> &station);
174 void clearStations();
175 void eraseStation(const iv::types::stationId &stationId);
176
177 void deleteNetwork(const iv::types::networkId &networkId);
178
179 [[nodiscard]] std::vector<std::shared_ptr<iv::model::comms::NetworkData>>
181
182 std::weak_ptr<iv::model::comms::NetworkData> getNetworkData(const iv::types::networkId &networkId);
183
184 [[nodiscard]] const std::map<iv::types::networkId, std::shared_ptr<iv::model::comms::NetworkData>> &
185 getNetworksData() const;
186
187 [[nodiscard]] std::shared_ptr<Stations> clone() const;
188 void updateNetworks(const std::shared_ptr<Stations> &newStations);
189
190 // Processed gets
191 [[nodiscard]] std::weak_ptr<Station> getStationAt(uint32_t index) const;
192
193 [[nodiscard]] std::weak_ptr<iv::model::comms::NetworkData> getNetworkDataAt(uint32_t index);
194
195 [[nodiscard]] std::vector<iv::comms::api::ApiCommunicationInfo>
196 getAPICommInfoOfType(iv::comms::eNetworkType networkType, bool onlyEnabled,
197 const iv::types::stationId &stationId = iv::system::retrieveHostName()) const;
198
199 [[nodiscard]] bool isMaster(const iv::types::stationId &stationId = iv::system::retrieveHostName()) const;
200 [[nodiscard]] bool isWatchcallMaster(const iv::types::stationId &stationId = iv::system::retrieveHostName()) const;
201
202 [[nodiscard]] std::shared_ptr<Station> getMaster() const;
203
204private:
205 std::map<iv::types::networkId, std::shared_ptr<iv::model::comms::NetworkData>> m_networksData;
206
207 std::map<iv::types::stationId, std::set<iv::types::networkId>> m_stationsNetworks;
208 std::map<iv::types::stationId, std::shared_ptr<iv::diamar::Station>> m_stations;
209
210 [[nodiscard]] std::vector<std::weak_ptr<iv::model::comms::NetworkData>>
211 getNetworksRefOfType(iv::comms::eNetworkType networkType, bool onlyEnabled,
212 const iv::types::stationId &stationId) const;
213
214public:
215 struct Sections
216 {
217 static constexpr std::string_view stations {"Stations"};
218 static constexpr std::string_view station {"Station"};
219 };
220};
221
222}// namespace iv::diamar
223
224#endif//IV_SRC_MODEL_DIAMAR_STATION_HPP_
Definition Station.hpp:28
iv::types::stationId & stationId()
Definition Station.cpp:81
std::map< iv::types::unitId, std::map< iv::comms::eLomLine, iv::types::timestamp > > unitsLastHeartbeats
Definition Station.hpp:105
std::set< iv::types::ipAddress > getIps() const
Definition Station.cpp:169
std::map< iv::types::unitId, std::map< iv::comms::eLomLine, iv::types::timestamp > > getUnitsLastHeartbeats()
Definition Station.cpp:459
bool load(const iv::file::xml::node &nodeStation, iv::diamar::StationNetworksLoadData &readNetworksInfo)
Definition Station.cpp:12
std::set< iv::types::ipAddress > m_ip
Definition Station.hpp:99
iv::model::eShipArea & shipArea()
Definition Station.cpp:86
bool loadIp(const iv::file::xml::node &nodeStation)
Definition Station.cpp:96
std::mutex m_unitsLastHeartbeatsMutex
Definition Station.hpp:106
iv::types::timestamp lastHeartbeat
Definition Station.hpp:73
bool isOn() const
Definition Station.cpp:444
void setUnitLastHeartbeats(const std::map< iv::types::unitId, std::map< iv::comms::eLomLine, iv::types::timestamp > > &lastHeartbeats)
Definition Station.cpp:452
std::weak_ptr< iv::channels::AbstractChannel > getStationHeartbeatChannel() const
Definition Station.cpp:956
std::shared_ptr< Station > clone() const
Definition Station.cpp:61
iv::types::stationId m_idStation
Definition Station.hpp:94
std::weak_ptr< iv::channels::AbstractChannel > getStationFailureChannel() const
Definition Station.cpp:951
std::weak_ptr< iv::channels::AbstractChannel > m_stationHeartbeatChannel
Definition Station.hpp:90
iv::model::eShipArea m_shipArea
Definition Station.hpp:101
iv::diamar::Station::Settings m_stationSettings
Definition Station.hpp:102
void setStationFailureChannel(const std::shared_ptr< iv::channels::AbstractChannel > &channel)
Definition Station.cpp:961
void update(const Station &other)
Definition Station.cpp:73
bool loadNetworks(const iv::file::xml::node &nodeStation, iv::diamar::StationNetworksLoadData &readNetworksInfo) const
Definition Station.cpp:129
std::weak_ptr< iv::channels::AbstractChannel > m_stationCommFailureChannel
Definition Station.hpp:92
bool save(iv::file::xml::node &nodeStation, const std::vector< std::shared_ptr< iv::model::comms::NetworkData > > &stationNetworks) const
Definition Station.cpp:39
void setIps(std::set< iv::types::ipAddress > ipAddresses)
Definition Station.cpp:179
bool saveIp(iv::file::xml::node &nodeStation) const
Definition Station.cpp:108
std::set< iv::types::ipAddress > & getIpsRef()
Definition Station.cpp:174
iv::types::unitId & stationUnitId()
Definition Station.cpp:465
void setStationHeartbeatChannel(const std::shared_ptr< iv::channels::AbstractChannel > &channel)
Definition Station.cpp:966
bool saveNetworks(iv::file::xml::node &nodeStation, const std::vector< std::shared_ptr< iv::model::comms::NetworkData > > &stationNetworks) const
Definition Station.cpp:153
iv::types::unitId m_stationUnitId
This field is used to mantain compatibilty with slim, please do NOT use for anything other than LOMs ...
Definition Station.hpp:98
iv::diamar::Station::Settings & stationSettings()
Definition Station.cpp:91
Definition Station.hpp:152
std::map< iv::types::networkId, std::shared_ptr< iv::model::comms::NetworkData > > m_networksData
Definition Station.hpp:205
std::weak_ptr< iv::model::comms::NetworkData > getNetworkDataAt(uint32_t index)
Definition Station.cpp:616
std::vector< std::shared_ptr< iv::model::comms::NetworkData > > getStationNetworksData(const iv::types::stationId &stationId=iv::system::retrieveHostName()) const
Definition Station.cpp:489
void changeStationId(const iv::types::stationId &previousStationID, const iv::types::stationId &newStationID)
Definition Station.cpp:369
std::weak_ptr< Station > getStationAt(uint32_t index) const
Definition Station.cpp:607
void addStation(const std::shared_ptr< Station > &station)
Definition Station.cpp:664
std::vector< iv::comms::api::ApiCommunicationInfo > getAPICommInfoOfType(iv::comms::eNetworkType networkType, bool onlyEnabled, const iv::types::stationId &stationId=iv::system::retrieveHostName()) const
Definition Station.cpp:626
bool addDefaultStation(iv::types::stationId stationId)
Definition Station.cpp:806
bool save(const std::shared_ptr< iv::file::xml::File > &xml) const
Definition Station.cpp:236
std::shared_ptr< Station > getMaster() const
Definition Station.cpp:791
bool insertNetworkData(const iv::types::stationId &stationId, const std::shared_ptr< iv::model::comms::NetworkData > &networkData)
Definition Station.cpp:287
std::map< iv::types::stationId, std::set< iv::types::networkId > > m_stationsNetworks
Definition Station.hpp:207
const std::map< iv::types::networkId, std::shared_ptr< iv::model::comms::NetworkData > > & getNetworksData() const
Definition Station.cpp:513
const std::map< iv::types::stationId, std::set< iv::types::networkId > > & getStationWithNetworks() const
Definition Station.cpp:678
void updateNetworkHeartbeatAndFailureChannelsTagsAndDescriptions(const types::networkId &networkId)
Definition Station.cpp:331
std::shared_ptr< Station > getStation(const iv::types::stationId &stationId=iv::system::retrieveHostName()) const
Gets the station that matches with the system host name.
Definition Station.cpp:476
std::vector< std::weak_ptr< iv::model::comms::NetworkData > > getNetworksRefOfType(iv::comms::eNetworkType networkType, bool onlyEnabled, const iv::types::stationId &stationId) const
Definition Station.cpp:648
std::map< iv::types::stationId, std::shared_ptr< iv::diamar::Station > > m_stations
Definition Station.hpp:208
void update(const iv::diamar::Stations &other)
Definition Station.cpp:254
bool removeNetworkData(const iv::types::networkId &networkId)
Definition Station.cpp:355
std::weak_ptr< iv::model::comms::NetworkData > getNetworkData(const iv::types::networkId &networkId)
Definition Station.cpp:504
void updateNetworks(const std::shared_ptr< Stations > &newStations)
Definition Station.cpp:537
bool load(const iv::file::xml::File &xml)
Definition Station.cpp:184
void changeNetworkId(const iv::types::networkId &previousNetworkID, const iv::types::networkId &newNetworkID)
Definition Station.cpp:302
void addStationDefaultNetworks(iv::types::stationId stationId, bool addLoggers=true, bool addRedundancy=true)
Definition Station.cpp:837
bool isMaster(const iv::types::stationId &stationId=iv::system::retrieveHostName()) const
Definition Station.cpp:775
void eraseStation(const iv::types::stationId &stationId)
Definition Station.cpp:696
std::shared_ptr< Stations > clone() const
Definition Station.cpp:518
void clearStations()
Definition Station.cpp:683
bool isWatchcallMaster(const iv::types::stationId &stationId=iv::system::retrieveHostName()) const
Definition Station.cpp:891
const std::map< iv::types::stationId, std::shared_ptr< iv::diamar::Station > > & getAll() const
Definition Station.cpp:673
void deleteNetwork(const iv::types::networkId &networkId)
Deletes a network.
Definition Station.cpp:738
Definition xmlFile.hpp:128
Definition xmlFile.hpp:15
eNetworkType
Definition enums.hpp:250
Definition DataLoggerManager.cpp:10
eShipArea
Definition enums.hpp:11
std::string retrieveHostName()
Retrieve the hostname.
Definition system.cpp:178
uint64_t timestamp
Definition types.hpp:21
uint16_t unitId
Definition types.hpp:77
std::string stationId
Definition types.hpp:75
std::string networkId
Definition types.hpp:43
Definition structs.hpp:44
Definition Station.hpp:21
bool hasRetrofitNetwork
Definition Station.hpp:24
std::vector< std::shared_ptr< iv::model::comms::NetworkData > > readNetworkDatas
Definition Station.hpp:22
bool requiresGenerateLoggersDefaultNetwork
Definition Station.hpp:23
Definition Station.hpp:144
static constexpr std::string shipArea
Definition Station.hpp:147
static constexpr bool isEnabled
Definition Station.hpp:146
Definition Station.hpp:109
static constexpr std::string_view heartbeatChannel
Definition Station.hpp:119
static constexpr std::string_view canConfigureBrightness
Definition Station.hpp:117
static constexpr std::string_view canBlockACK
Definition Station.hpp:113
static constexpr std::string_view localSoundOFF
Definition Station.hpp:114
static constexpr std::string_view canConfigureVolume
Definition Station.hpp:116
static constexpr std::string_view failureChannel
Definition Station.hpp:120
static constexpr std::string_view hideWatchCallPanel
Definition Station.hpp:115
static constexpr std::string_view shipArea
Definition Station.hpp:111
static constexpr std::string_view stationId
Definition Station.hpp:110
static constexpr std::string_view ip
Definition Station.hpp:122
Definition Station.hpp:138
static constexpr std::string_view httpSetting
Definition Station.hpp:139
Definition Station.hpp:126
static constexpr std::string_view settings
Definition Station.hpp:127
static constexpr std::string_view network
Definition Station.hpp:131
static constexpr std::string_view networkCommInterfaceSettings
Definition Station.hpp:132
static constexpr std::string_view ipAddress
Definition Station.hpp:129
static constexpr std::string_view ipAddresses
Definition Station.hpp:128
static constexpr std::string_view networkCommProtocolSettings
Definition Station.hpp:133
static constexpr std::string_view alarmPrinter
Definition Station.hpp:134
static constexpr std::string_view networks
Definition Station.hpp:130
static constexpr std::string_view printer
Definition Station.hpp:135
Definition Station.hpp:30
iv::PrinterDevice printer
Definition Station.hpp:38
bool canBlockAck
Definition Station.hpp:31
bool canConfigureVolume
Definition Station.hpp:34
bool load(const iv::file::xml::node &nodeSettings)
Definition Station.cpp:921
bool localSoundOff
Definition Station.hpp:32
bool canConfigureBrightness
Definition Station.hpp:35
bool save(iv::file::xml::node &nodeSetings) const
Definition Station.cpp:935
iv::PrinterDevice alarmPrinter
Definition Station.hpp:37
Definition Station.hpp:216
static constexpr std::string_view station
Definition Station.hpp:218
static constexpr std::string_view stations
Definition Station.hpp:217