1#ifndef IV_SRC_UNITS_MODEL_UNIT_HPP_
2#define IV_SRC_UNITS_MODEL_UNIT_HPP_
24 bool save(
const std::shared_ptr<iv::file::xml::File> &xml)
const;
26 [[nodiscard]] std::shared_ptr<Unit>
clone()
const;
29 [[nodiscard]] std::optional<iv::units::eUnitType>
getType()
const;
47 std::weak_ptr<iv::channels::AbstractChannel>
49 std::optional<iv::types::channelOrder> channelOrder = std::nullopt,
50 const std::optional<iv::types::channelId> &channelId = std::nullopt);
52 bool insertChannel(std::shared_ptr<iv::channels::AbstractChannel> channel);
56 [[nodiscard]] std::weak_ptr<iv::channels::AbstractChannel>
getChannelByShipyardTag(
const std::string &channelTag);
58 [[nodiscard]]
const std::unordered_map<iv::types::channelId, std::shared_ptr<iv::channels::AbstractChannel>> &
60 const std::map<iv::types::channelOrder, std::shared_ptr<iv::channels::AbstractChannel>> &
62 [[nodiscard]]
const std::map<iv::types::channelOrder, std::shared_ptr<iv::channels::AbstractChannel>> &
64 [[nodiscard]] std::shared_ptr<std::vector<std::weak_ptr<iv::channels::AbstractChannel>>>
66 [[nodiscard]] std::map<iv::types::indexChannel, std::shared_ptr<iv::channels::AbstractChannel>> &
70 std::optional<iv::channels::eChannelSpecificType> channelType = std::nullopt,
75 void setOfflineChannel(
const std::weak_ptr<iv::channels::AbstractChannel> &offlineChannel);
76 void setCanAFailChannel(
const std::weak_ptr<iv::channels::AbstractChannel> &canAFailChannel);
77 void setCanBFailChannel(
const std::weak_ptr<iv::channels::AbstractChannel> &canBFailChannel);
78 void setCanCFailChannel(
const std::weak_ptr<iv::channels::AbstractChannel> &canCFailChannel);
79 void setHeartbeatChannel(
const std::weak_ptr<iv::channels::AbstractChannel> &heartbeatChannel);
91 [[nodiscard]]
bool isLIM()
const;
92 [[nodiscard]]
bool isLOM()
const;
93 [[nodiscard]] std::string
getName(
bool isNotInProjectUnit =
false)
const;
95 [[nodiscard]]
bool isOn()
const;
119 std::unordered_map<iv::types::channelId, std::shared_ptr<iv::channels::AbstractChannel>>
m_channels;
124 std::map<iv::types::channelOrder, std::shared_ptr<iv::channels::AbstractChannel>>
m_channelsByOrder;
125 std::map<iv::types::indexChannel, std::shared_ptr<iv::channels::AbstractChannel>>
m_channelsByIndex;
130 mutable std::optional<std::map<iv::types::channelOrder, std::shared_ptr<iv::channels::AbstractChannel>>>
132 mutable std::map<iv::types::groupId, std::shared_ptr<std::vector<std::weak_ptr<iv::channels::AbstractChannel>>>>
146 static constexpr std::string_view
unit {
"Unit"};
148 static constexpr std::string_view
channels {
"Channels"};
149 static constexpr std::string_view
channel {
"Channel"};
150 static constexpr std::string_view
unitData {
"Data"};
154 static constexpr std::string_view
unitId {
"Id"};
155 static constexpr std::string_view
unitType {
"Type"};
156 static constexpr std::string_view
isEnabled {
"Enabled"};
158 static constexpr std::string_view
cabinetId {
"CabinetId"};
167 static constexpr std::string
string {};
168 static constexpr std::string_view
unitType {
"Aim18"};
Definition xmlFile.hpp:128
Definition UnitInfo.hpp:12
std::pair< iv::alarms::eAlarmState, iv::alarms::eAlarmPriority > calculateUnitAlarmStatePriority() const
Definition Unit.cpp:797
iv::types::cabinetId m_cabinetId
Definition Unit.hpp:108
std::optional< iv::comms::eHeartbeatState > m_lastHeartbeatState
Definition Unit.hpp:105
const std::map< iv::types::channelOrder, std::shared_ptr< iv::channels::AbstractChannel > > & getChannelsByOrder() const
Definition Unit.cpp:720
std::weak_ptr< iv::channels::AbstractChannel > m_canCFailChannel
Definition Unit.hpp:138
void setOfflineChannel(const std::weak_ptr< iv::channels::AbstractChannel > &offlineChannel)
Definition Unit.cpp:831
std::weak_ptr< iv::channels::AbstractChannel > getChannel(iv::types::channelOrder channelOrder) const
Definition Unit.cpp:652
std::string getName(bool isNotInProjectUnit=false) const
Definition Unit.cpp:957
std::weak_ptr< iv::channels::AbstractChannel > m_canAFailChannel
Definition Unit.hpp:136
void setCanBFailChannel(const std::weak_ptr< iv::channels::AbstractChannel > &canBFailChannel)
Definition Unit.cpp:840
std::weak_ptr< iv::channels::AbstractChannel > getHeartbeatChannel()
Definition Unit.cpp:1137
bool m_isEnabled
Definition Unit.hpp:103
std::map< iv::types::indexChannel, std::shared_ptr< iv::channels::AbstractChannel > > m_channelsByIndex
Definition Unit.hpp:125
bool changeChannelOrder(iv::types::channelOrder channelOrder, iv::types::channelOrder newChannelOrder)
Definition Unit.cpp:547
std::optional< iv::types::channelOrder > getFirstFreeChannelOrder(std::optional< iv::channels::eChannelSpecificType > channelType=std::nullopt, const std::optional< std::function< bool(iv::types::channelOrder)> > &addedCondition=std::nullopt) const
Definition Unit.cpp:763
std::map< iv::types::channelOrder, std::shared_ptr< iv::channels::AbstractChannel > > m_channelsByOrder
Definition Unit.hpp:124
void setCanAFailChannel(const std::weak_ptr< iv::channels::AbstractChannel > &canAFailChannel)
Definition Unit.cpp:835
std::weak_ptr< iv::channels::AbstractChannel > m_canBFailChannel
Definition Unit.hpp:137
const std::unordered_map< iv::types::channelId, std::shared_ptr< iv::channels::AbstractChannel > > & getChannels() const
Definition Unit.cpp:688
const std::map< iv::types::channelOrder, std::shared_ptr< iv::channels::AbstractChannel > > & getActiveChannels(bool refreshCache=false) const
Definition Unit.cpp:694
bool isLOM() const
Definition Unit.cpp:923
std::shared_ptr< std::vector< std::weak_ptr< iv::channels::AbstractChannel > > > getActiveChannelsByGroupId(const iv::types::groupId &groupId, bool refreshCache=false) const
Get all channels in the unit that belong to the group.
Definition Unit.cpp:732
bool isLIM() const
Definition Unit.cpp:889
bool hasChannels() const
Definition Unit.cpp:462
bool deleteChannel(iv::types::channelOrder channelOrder)
Definition Unit.cpp:561
std::weak_ptr< iv::channels::AbstractChannel > createChannel(iv::channels::eChannelSpecificType channelType, std::optional< iv::types::channelOrder > channelOrder=std::nullopt, const std::optional< iv::types::channelId > &channelId=std::nullopt)
Definition Unit.cpp:589
iv::units::UnitInfo & getUnitInfo()
Definition Unit.cpp:457
void setLasHeartbeat(iv::comms::eLomLine line, iv::types::timestamp timestamp)
Definition Unit.cpp:1147
std::optional< std::map< iv::types::channelOrder, std::shared_ptr< iv::channels::AbstractChannel > > > m_activeChannelsByOrder
Definition Unit.hpp:131
std::shared_ptr< Unit > clone() const
Definition Unit.cpp:426
std::map< iv::types::indexChannel, std::shared_ptr< iv::channels::AbstractChannel > > & getChannelsByIndex()
Definition Unit.cpp:757
bool changeChannelId(const iv::types::channelId &channelId, const iv::types::channelId &newChannelId)
Definition Unit.cpp:531
std::weak_ptr< iv::channels::AbstractChannel > getChannelByShipyardTag(const std::string &channelTag)
Definition Unit.cpp:671
void initializeChannels(const std::shared_ptr< AbstractProgress > &progress)
Definition Unit.cpp:488
iv::types::unitId m_id
Definition Unit.hpp:106
std::optional< iv::units::eUnitType > m_unitType
Definition Unit.hpp:109
std::map< iv::types::groupId, std::shared_ptr< std::vector< std::weak_ptr< iv::channels::AbstractChannel > > > > m_channelsByGroupId
Definition Unit.hpp:133
void setHeartbeatChannel(const std::weak_ptr< iv::channels::AbstractChannel > &heartbeatChannel)
Definition Unit.cpp:850
void prvCreateKLimSystemChannels()
Definition Unit.cpp:1017
Unit()
Definition Unit.cpp:243
iv::types::unitId getId() const
Definition Unit.cpp:447
void updateChannelsUnitId()
Definition Unit.cpp:1103
std::mutex m_lomCommunicationMutex
Definition Unit.hpp:113
bool isOn() const
Definition Unit.cpp:972
std::weak_ptr< iv::channels::AbstractChannel > getOfflineChannel()
Definition Unit.cpp:1117
bool changeChannelsDefaultId(const iv::types::unitId &newUnitId)
esto ahora debe funcionar diferente
Definition Unit.cpp:1047
bool insertChannel(std::shared_ptr< iv::channels::AbstractChannel > channel)
Definition Unit.cpp:637
std::weak_ptr< iv::channels::AbstractChannel > m_offlineChannel
Definition Unit.hpp:135
iv::units::UnitInfo m_unitInfo
Definition Unit.hpp:111
void update(const iv::units::Unit &other)
Definition Unit.cpp:292
std::weak_ptr< iv::channels::AbstractChannel > getCanCFailChannel()
Definition Unit.cpp:1132
std::optional< iv::units::eUnitType > getType() const
Definition Unit.cpp:452
bool load(const iv::file::xml::File &xml)
Definition Unit.cpp:315
std::weak_ptr< iv::channels::AbstractChannel > getCanAFailChannel()
Definition Unit.cpp:1122
std::unordered_map< iv::types::channelId, std::shared_ptr< iv::channels::AbstractChannel > > m_channels
Definition Unit.hpp:119
std::string m_internalDescription
Definition Unit.hpp:107
bool save(const std::shared_ptr< iv::file::xml::File > &xml) const
Definition Unit.cpp:384
void createSystemChannels()
Definition Unit.cpp:467
std::shared_ptr< iv::channels::AbstractChannel > extractChannel(iv::types::channelOrder channelOrder)
Definition Unit.cpp:506
bool existsChannel(const iv::types::channelId &channelId) const
Definition Unit.cpp:994
void setCanCFailChannel(const std::weak_ptr< iv::channels::AbstractChannel > &canCFailChannel)
Definition Unit.cpp:845
bool isOnOnCanLine(comms::eLomLine line) const
Definition Unit.cpp:985
bool isStation() const
Definition Unit.cpp:855
std::map< iv::comms::eLomLine, iv::types::timestamp > m_lastHeartbeat
Definition Unit.hpp:141
iv::types::timestamp getLastHeartbeat() const
Definition Unit.cpp:1111
std::weak_ptr< iv::channels::AbstractChannel > m_heartbeatChannel
Definition Unit.hpp:139
std::weak_ptr< iv::channels::AbstractChannel > getCanBFailChannel()
Definition Unit.cpp:1127
void prvCreateLomSystemChannels()
Definition Unit.cpp:999
eChannelSpecificType
Definition enums.hpp:72
eLomLine
Definition enums.hpp:231
uint64_t timestamp
Definition types.hpp:21
uint16_t unitId
Definition types.hpp:77
uint16_t channelOrder
Definition types.hpp:68
std::string cabinetId
Definition types.hpp:65
std::string channelId
Definition types.hpp:66
std::string groupId
Definition types.hpp:70
Definition AbstractChannel.hpp:16
eUnitType
Definition enums.hpp:8
static constexpr std::string_view unitType
Definition Unit.hpp:168
static constexpr bool isEnabled
Definition Unit.hpp:170
static constexpr iv::types::unitId unitId
Definition Unit.hpp:169
static constexpr std::string_view canAFailChannel
Definition Unit.hpp:160
static constexpr std::string_view offlineChannel
Definition Unit.hpp:159
static constexpr std::string_view unitId
Definition Unit.hpp:154
static constexpr std::string_view isEnabled
Definition Unit.hpp:156
static constexpr std::string_view cabinetId
Definition Unit.hpp:158
static constexpr std::string_view internalDescription
Definition Unit.hpp:157
static constexpr std::string_view canCFailChannel
Definition Unit.hpp:162
static constexpr std::string_view canBFailChannel
Definition Unit.hpp:161
static constexpr std::string_view heartbeatChannel
Definition Unit.hpp:163
static constexpr std::string_view unitType
Definition Unit.hpp:155
static constexpr std::string_view systemChannels
Definition Unit.hpp:147
static constexpr std::string_view unitData
Definition Unit.hpp:150
static constexpr std::string_view channel
Definition Unit.hpp:149
static constexpr std::string_view channels
Definition Unit.hpp:148
static constexpr std::string_view unit
Definition Unit.hpp:146