Nix (Dev) 3.5.10
dev - 3.5.10 - 1af9301
Loading...
Searching...
No Matches
utils.hpp
Go to the documentation of this file.
1#ifndef IV_SRC_CHANNELS_UTILS_HPP_
2#define IV_SRC_CHANNELS_UTILS_HPP_
3
5#include "core/strings.hpp"
6#include "core/utils.hpp"
7#include "model/constants.hpp"
9
10namespace iv::channels::utils
11{
12
18
19inline std::string formatValue(const iv::types::channelValue &value, const iv::channels::eChannelBaseType type,
20 const std::optional<uint8_t> numberOfDecimals = 0,
21 const std::optional<iv::eMeasurementUnit> measurementUnit = std::nullopt)
22{
23 switch (type)
24 {
27 {
28 return fmt::format("{:.{}f} {}", value, numberOfDecimals.value_or(0),
30 }
33 {
34 return value == 0 ? "OP" : "CL";
35 }
36 default:
37 {
38 return "";
39 }
40 }
41}
42
44{
45 return {.min = static_cast<iv::types::channelOrder>(1), .max = static_cast<iv::types::channelOrder>(100)};
46}
47
49{
50 return {.min = static_cast<iv::types::channelOrder>(128 * 100),
51 .max = static_cast<iv::types::channelOrder>(129 * 100)};
52}
55{
56 return {.min = static_cast<iv::types::channelOrder>(unitId * 100),
57 .max = static_cast<iv::types::channelOrder>(unitId * 100 + 99)};
58}
59
65
67{
68 return fmt::format("U{:03}_{:03}", unitId, channelOrder);
69}
70
72{
73 return fmt::format("U{:03}_HB", unitId);
74}
75
77{
78 return fmt::format("{}_HB", stationId);
79}
80
82{
83 return fmt::format("{}_FAIL", stationId);
84}
85
87{
88 return fmt::format("{}_RFAIL", repeaterId);
89}
90
92{
93 return fmt::format("{}_RHB", repeaterId);
94}
95
97{
98 return fmt::format("U{:03}_CANA", unitId);
99}
100
102{
103 return fmt::format("U{:03}_CANB", unitId);
104}
105
107{
108 return fmt::format("U{:03}_CANC", unitId);
109}
110
112{
113 return fmt::format("U{:03}_OFFLINE", unitId);
114}
115
116uint32_t getGlobalId(iv::types::channelOrder channelOrder, iv::types::unitId unitId,
117 iv::channels::eChannelSpecificType channelSpecificType);
118
120
121std::pair<iv::alarms::eAlarmState, iv::alarms::eAlarmType> unpackedStateAlarmAndTypeAlarm(unsigned char stateAndType);
122
124
126
127std::vector<iv::channels::eAnalogSensorType> sensorTypeByUnitTypeAndChOrder(const iv::units::eUnitType &unitType,
128 const iv::types::channelOrder &chOrder);
129
131
133
134}// namespace iv::channels::utils
135
136#endif//IV_SRC_CHANNELS_UTILS_HPP_
Definition utils.cpp:9
iv::types::channelOrder networkHeartbeatAndFailureChannelOrder(const iv::types::channelOrder stationOrder, const iv::types::channelOrder commOrder)
Definition utils.hpp:60
std::string generateDefaultStationHeartbeatChannelId(const iv::types::stationId &stationId)
Definition utils.hpp:76
std::string formatValue(const iv::types::channelValue &value, const iv::channels::eChannelBaseType type, const std::optional< uint8_t > numberOfDecimals=0, const std::optional< iv::eMeasurementUnit > measurementUnit=std::nullopt)
Definition utils.hpp:19
std::string generateDefaultStationFailChannelId(const iv::types::stationId &stationId)
Definition utils.hpp:81
bool isSerialLine(const iv::channels::eChannelSpecificType type)
Definition utils.cpp:291
std::string generateDefaultCanBFailChannelId(iv::types::unitId unitId)
Definition utils.hpp:101
std::vector< iv::channels::eAnalogSensorType > sensorTypeByUnitTypeAndChOrder(const iv::units::eUnitType &unitType, const iv::types::channelOrder &chOrder)
Definition utils.cpp:323
std::string generateDefaultLomOfflineChannelId(iv::types::unitId unitId)
Definition utils.hpp:111
std::string generateDefaultChannelId(iv::types::unitId unitId, iv::types::channelOrder channelOrder)
Definition utils.hpp:66
iv::types::Range< uint16_t > watchcallNodeHearbeatAndFailureChannelOrderRange()
Definition utils.hpp:48
std::string generateDefaultCanCFailChannelId(iv::types::unitId unitId)
Definition utils.hpp:106
iv::types::Range< iv::types::channelOrder > unitHeartbeatAndCanFailureChannelOrderRange(const iv::types::unitId unitId)
Definition utils.hpp:54
bool hasToShowRawValue(const iv::channels::eChannelBaseType baseType)
Definition utils.cpp:268
std::string generateDefaultWatchcallNodeHearbeatChannelId(const iv::types::repeaterId &repeaterId)
Definition utils.hpp:91
std::string generateDefaultWatchcallNodeFailChannelId(const iv::types::repeaterId &repeaterId)
Definition utils.hpp:86
std::string generateDefaultLomHeartbeatChannelId(iv::types::unitId unitId)
Definition utils.hpp:71
bool isChannelWithoutAlarm(iv::channels::eChannelSpecificType channelType)
Definition utils.cpp:418
iv::types::Range< uint16_t > stationHeartbeatAndFailureChannelOrderRange()
Definition utils.hpp:43
std::pair< iv::alarms::eAlarmState, iv::alarms::eAlarmType > unpackedStateAlarmAndTypeAlarm(unsigned char stateAndType)
Definition utils.cpp:251
bool isDefaultChannelId(const types::channelId &chId)
Definition utils.cpp:411
void formatTag(iv::types::channelId &id)
Definition utils.hpp:13
iv::types::indexChannel generateIndexChannel(uint16_t id, iv::channels::eChannelSpecificType type)
Definition utils.cpp:123
uint32_t getGlobalId(iv::types::channelOrder channelOrder, iv::types::unitId unitId, iv::channels::eChannelSpecificType channelSpecificType)
Definition utils.cpp:11
std::string generateDefaultCanAFailChannelId(iv::types::unitId unitId)
Definition utils.hpp:96
eChannelSpecificType
Definition enums.hpp:72
eChannelBaseType
Definition enums.hpp:63
static constexpr iv::types::channelOrder commFailureChannelsOffset
Definition defines.hpp:73
void toUpper(StringType &str)
Convert the given text's characters into uppercase ones.
Definition strings.hpp:24
void trim(std::string &str)
Trims left and right whites.
Definition strings.cpp:37
uint32_t indexChannel
Definition types.hpp:87
uint16_t unitId
Definition types.hpp:77
uint16_t channelOrder
Definition types.hpp:68
double channelValue
Definition types.hpp:67
std::string stationId
Definition types.hpp:75
std::string channelId
Definition types.hpp:66
std::string repeaterId
Definition types.hpp:79
eUnitType
Definition enums.hpp:8
static MeasurementUnit get(const iv::eMeasurementUnit &unit)
Definition structs.cpp:102
std::string symbol
Definition structs.hpp:36
Definition types.hpp:30