Nix (Dev) 3.5.10
dev - 3.5.10 - 1af9301
Loading...
Searching...
No Matches
ValveManager.hpp
Go to the documentation of this file.
1#ifndef IV_SRC_MODEL_CONTROLS_VALVEMANAGER_HPP_
2#define IV_SRC_MODEL_CONTROLS_VALVEMANAGER_HPP_
3
4#include "core/types.hpp"
8
9#include <list>
10#include <map>
11#include <memory>
12#include <optional>
13#include <set>
14
15namespace iv::model::control
16{
17
19{
20public:
21 ValveManager() = default;
22 ~ValveManager() = default;
23
24 void update(const ValveManager &other);
25 bool load(const iv::file::xml::node &nodeValves);
26 bool save(iv::file::xml::node &nodeValves) const;
27
28 bool insertValve(const std::shared_ptr<iv::model::control::Valve> &valve);
29
32 const iv::model::control::valve::AllValveChannels &allValveChannels);
33
37
38 bool removeValve(const types::control::valve::valveId &valveId, bool resetWiredChannels,
39 bool removeSoftwareChannels);
40
50 valve::eValveType &defaultValveType, iv::types::unitId &defaultLomId);
51
57 [[nodiscard]]
58 static std::set<iv::types::unitId> getAvailableLomIds(iv::model::control::valve::eValveType valveType);
59
66 [[nodiscard]]
67 static std::optional<std::shared_ptr<iv::channels::AbstractChannel>>
69
76 [[nodiscard]]
77 static std::optional<std::shared_ptr<iv::channels::AbstractChannel>>
79
86 [[nodiscard]]
88 getLomAvailability(const std::shared_ptr<iv::units::Unit> &unit, iv::model::control::valve::eValveType valveType);
89
90 [[nodiscard]] std::map<iv::types::control::valve::valveId, std::shared_ptr<iv::model::control::Valve>> &valves();
91
92private:
98 [[nodiscard]]
99 static bool isDefaultChannel(const std::shared_ptr<iv::channels::AbstractChannel> &channel);
100
106 [[nodiscard]]
107 static uint16_t getNumAvailableDigitalOutputChannels(const std::shared_ptr<iv::units::Unit> &unit);
108
115 static std::list<iv::types::channelOrder>
116 getNumAvailableCmdChannelOrders(const std::shared_ptr<iv::units::Unit> &unit);
117
124 static std::list<iv::types::channelOrder>
125 getNumAvailableTripChannelOrders(const std::shared_ptr<iv::units::Unit> &unit);
126
134 [[nodiscard]]
135 static bool linkAndConfigureValveChannels(const std::shared_ptr<iv::model::control::Valve> &valve);
136
137 static void reconfigureValveChannels(const std::shared_ptr<iv::model::control::Valve> &valve);
138
144 static void resetValveWiredChannels(const std::shared_ptr<iv::model::control::Valve> &valve);
145
151 static void removeValveSoftwareChannels(const std::shared_ptr<iv::model::control::Valve> &valve);
152
153 static bool configureChFeedbackOP(const std::shared_ptr<iv::channels::AbstractChannel> &channel,
155 static bool configureChFeedbackCL(const std::shared_ptr<iv::channels::AbstractChannel> &channel,
157 static bool configureChOutputOP(const std::shared_ptr<iv::channels::AbstractChannel> &channel,
159 static bool configureChOutputCL(const std::shared_ptr<iv::channels::AbstractChannel> &channel,
161 static bool configureChCmdOP(const std::shared_ptr<iv::channels::AbstractChannel> &channel,
163 iv::types::channelOrder channelOrder, iv::types::unitId unitId,
164 bool isConfiguringFromController);
165 static bool configureChCmdCL(const std::shared_ptr<iv::channels::AbstractChannel> &channel,
167 iv::types::channelOrder channelOrder, iv::types::unitId unitId,
168 bool isConfiguringFromController);
169 static bool configureChCmdReset(const std::shared_ptr<iv::channels::AbstractChannel> &channel,
171 iv::types::channelOrder channelOrder, iv::types::unitId unitId,
172 bool isConfiguringFromController);
173 static bool configureChTrip(const std::shared_ptr<iv::channels::AbstractChannel> &channel,
175 iv::types::unitId unitId, bool isConfiguringFromController);
176
177 std::map<iv::types::control::valve::valveId, std::shared_ptr<iv::model::control::Valve>> m_valves;
178
179 struct Sections
180 {
181 static constexpr std::string_view valve {"Valve"};
182 };
184 {
185 static constexpr uint16_t maxValveOrderValue {999};
186 static constexpr uint16_t numCmdChannels {3};
187 static constexpr uint16_t numTripChannels {1};
188 static constexpr std::pair<iv::types::channelOrder, iv::types::channelOrder> valveCmdChannelOrderRange {400,
189 499};
190 static constexpr std::pair<iv::types::channelOrder, iv::types::channelOrder> valveTripChannelOrderRange {300,
191 363};
192 };
193};
194
195}// namespace iv::model::control
196
197#endif//IV_SRC_MODEL_CONTROLS_VALVEMANAGER_HPP_
Definition xmlFile.hpp:15
Definition ValveManager.hpp:19
static bool configureChFeedbackCL(const std::shared_ptr< iv::channels::AbstractChannel > &channel, iv::types::control::valve::valveId valveId)
Definition ValveManager.cpp:614
void update(const ValveManager &other)
Definition ValveManager.cpp:962
static uint16_t getNumAvailableDigitalOutputChannels(const std::shared_ptr< iv::units::Unit > &unit)
Get the number of available digital output channels for a given unit.
Definition ValveManager.cpp:324
std::map< iv::types::control::valve::valveId, std::shared_ptr< iv::model::control::Valve > > m_valves
Definition ValveManager.hpp:177
static bool configureChCmdCL(const std::shared_ptr< iv::channels::AbstractChannel > &channel, const iv::types::control::valve::valveId &valveId, iv::types::channelOrder channelOrder, iv::types::unitId unitId, bool isConfiguringFromController)
Definition ValveManager.cpp:800
static std::list< iv::types::channelOrder > getNumAvailableCmdChannelOrders(const std::shared_ptr< iv::units::Unit > &unit)
Get the available command channel orders for a given unit.
Definition ValveManager.cpp:342
bool load(const iv::file::xml::node &nodeValves)
Definition ValveManager.cpp:14
bool insertValve(const std::shared_ptr< iv::model::control::Valve > &valve)
Definition ValveManager.cpp:41
bool changeValveSystemAndOrder(const iv::types::control::valve::valveId &oldValveId, iv::model::control::valve::eValveSystem newValveSystem, iv::types::control::valve::valveOrder newValveOrder)
Definition ValveManager.cpp:91
static std::list< iv::types::channelOrder > getNumAvailableTripChannelOrders(const std::shared_ptr< iv::units::Unit > &unit)
Get the available trip channel orders for a given unit.
Definition ValveManager.cpp:359
std::map< iv::types::control::valve::valveId, std::shared_ptr< iv::model::control::Valve > > & valves()
Definition ValveManager.cpp:146
static void removeValveSoftwareChannels(const std::shared_ptr< iv::model::control::Valve > &valve)
Remove the software channels of a valve.
Definition ValveManager.cpp:559
static bool isDefaultChannel(const std::shared_ptr< iv::channels::AbstractChannel > &channel)
Check if the channel is a default channel from the point of view of Valves.
Definition ValveManager.cpp:281
static bool configureChCmdOP(const std::shared_ptr< iv::channels::AbstractChannel > &channel, const iv::types::control::valve::valveId &valveId, iv::types::channelOrder channelOrder, iv::types::unitId unitId, bool isConfiguringFromController)
Definition ValveManager.cpp:749
static bool configureChTrip(const std::shared_ptr< iv::channels::AbstractChannel > &channel, const iv::types::control::valve::valveId &valveId, iv::types::channelOrder channelOrder, iv::types::unitId unitId, bool isConfiguringFromController)
Definition ValveManager.cpp:904
static bool configureChOutputOP(const std::shared_ptr< iv::channels::AbstractChannel > &channel, iv::types::control::valve::valveId valveId)
Definition ValveManager.cpp:659
static std::optional< std::shared_ptr< iv::channels::AbstractChannel > > getTheNAvailableValveFeedbackChannel(iv::types::unitId lomId, uint16_t n)
Get the Nth available valve feedback channel for a given LOM ID.
Definition ValveManager.cpp:222
static bool configureChOutputCL(const std::shared_ptr< iv::channels::AbstractChannel > &channel, iv::types::control::valve::valveId valveId)
Definition ValveManager.cpp:704
bool removeValve(const types::control::valve::valveId &valveId, bool resetWiredChannels, bool removeSoftwareChannels)
Definition ValveManager.cpp:121
static void reconfigureValveChannels(const std::shared_ptr< iv::model::control::Valve > &valve)
Definition ValveManager.cpp:469
bool createValve(valve::eValveSystem valveSystem, iv::types::control::valve::valveOrder valveOrder, iv::model::control::valve::eValveType valveType, iv::types::unitId lomId, const iv::model::control::valve::AllValveChannels &allValveChannels)
Definition ValveManager.cpp:59
bool save(iv::file::xml::node &nodeValves) const
Definition ValveManager.cpp:28
static std::optional< std::shared_ptr< iv::channels::AbstractChannel > > getTheNAvailableValveOrderChannel(iv::types::unitId lomId, uint16_t n)
Get the Nth available valve order channel for a given LOM ID.
Definition ValveManager.cpp:252
static bool configureChFeedbackOP(const std::shared_ptr< iv::channels::AbstractChannel > &channel, iv::types::control::valve::valveId valveId)
Definition ValveManager.cpp:569
static iv::model::control::valve::eLomAvailability getLomAvailability(const std::shared_ptr< iv::units::Unit > &unit, iv::model::control::valve::eValveType valveType)
Get the availability of LOMs for a given valve type.
Definition ValveManager.cpp:289
static bool linkAndConfigureValveChannels(const std::shared_ptr< iv::model::control::Valve > &valve)
Link and configure the channels of a valve.
Definition ValveManager.cpp:375
void getValveValidDefaultParameters(iv::model::control::valve::eValveSystem &defaultValveSystem, iv::types::control::valve::valveOrder &defaultValveOrder, valve::eValveType &defaultValveType, iv::types::unitId &defaultLomId)
Gets a valid combination of default parameters for a valve.
Definition ValveManager.cpp:151
static void resetValveWiredChannels(const std::shared_ptr< iv::model::control::Valve > &valve)
Reset the wired channels of a valve.
Definition ValveManager.cpp:533
static bool configureChCmdReset(const std::shared_ptr< iv::channels::AbstractChannel > &channel, const iv::types::control::valve::valveId &valveId, iv::types::channelOrder channelOrder, iv::types::unitId unitId, bool isConfiguringFromController)
Definition ValveManager.cpp:851
static std::set< iv::types::unitId > getAvailableLomIds(iv::model::control::valve::eValveType valveType)
Get the LOM IDs of the LOMs capable of managing a valve of a given type.
Definition ValveManager.cpp:191
eValveType
Definition enums.hpp:71
eValveSystem
Definition enums.hpp:21
eLomAvailability
Definition enums.hpp:77
Definition ControlManager.cpp:4
uint16_t valveOrder
Definition types.hpp:107
std::string valveId
Definition types.hpp:106
uint16_t unitId
Definition types.hpp:77
uint16_t channelOrder
Definition types.hpp:68
Definition ValveManager.hpp:184
static constexpr uint16_t numCmdChannels
Definition ValveManager.hpp:186
static constexpr std::pair< iv::types::channelOrder, iv::types::channelOrder > valveTripChannelOrderRange
Definition ValveManager.hpp:190
static constexpr uint16_t numTripChannels
Definition ValveManager.hpp:187
static constexpr std::pair< iv::types::channelOrder, iv::types::channelOrder > valveCmdChannelOrderRange
Definition ValveManager.hpp:188
static constexpr uint16_t maxValveOrderValue
Definition ValveManager.hpp:185
Definition ValveManager.hpp:180
static constexpr std::string_view valve
Definition ValveManager.hpp:181