/// @brief Structure to hold a monitoring signal
///
/// @param id The ID of the signal.
/// @param name The name of the signal. For ROS topics, the format is '/topicName>subtopic1>subtopic...'. eg: '/imu>angular_velocity>x'
/// @param unit The unit of the signal. enum value (eg: 1 -> METER_PER_SECOND, 2 -> METER, 3 -> KILOMETER, etc.)
/// @param rosTopicType The ROS topic type of the signal. Only used for ROS topics, eg 'sensor_msgs/msg/NavSatFix'
/// @param datasourceId The ID of the datasource this signal is associated to.
/// @param datasourceName The name of the datasource this signal is associated to.
/// @param signalType The type of the signal. enum value (eg: 1 -> INTEGER, 2 -> NUMBER, 7 -> STRING, 6 -> BOOLEAN...)
/// @param signalOperator The operator of the signal. enum value (eg: 1 -> IN, 2 -> OUT, 10 -> LESS_THAN, etc.)
/// @param valueType The type of the monitored value. (eg: "double", "string", "bool", "array", "zone"...)
/// @param value The stringified triggering value. (eg: "1.23", "true", "['a', 'b', 'c']", "zone1", "zone2"...)
struct MonitoringSignal
{
std::string id{}; ///< The ID of the signal.
std::string name{}; ///< The name of the signal. For ROS topics, the format is '/topicName>subtopic1>subtopic...'. eg: '/imu>angular_velocity>x'
int unit{static_cast<int>(apiinterface::Unit::UNIT_UNSPECIFIED)}; ///< The unit of the signal. enum value (eg: 1 -> METER_PER_SECOND, 2 -> METER, 3 -> KILOMETER, etc.)
std::string rosTopicType{}; ///< The ROS topic type of the signal. Only used for ROS topics, eg 'sensor_msgs/msg/NavSatFix'
std::string datasourceId{}; ///< The ID of the datasource this signal is associated to.
std::string datasourceName{}; ///< The name of the datasource this signal is associated to.
int signalType{static_cast<int>(apiinterface::SignalType::ST_UNSPECIFIED)}; ///< The type of the signal enum value (eg: 1 -> INTEGER, 2 -> NUMBER, 7 -> STRING, 6 -> BOOLEAN...)
int signalOperator{static_cast<int>(apiinterface::Operator::OP_UNSPECIFIED)}; ///< The operator of the signal enum value (eg: 1 -> IN, 2 -> OUT, 10 -> LESS_THAN, etc.)
std::string valueType{}; ///< The type of the monitored value. (eg: "double", "string", "bool", "array", "zone"...)
std::string value{}; ///< The stringified triggering value. (eg: "1.23", "true", "['a', 'b', 'c']", "some text", <zone>...)
// Copy assignment operator
MonitoringSignal& operator=(const MonitoringSignal& other) = default;
bool operator==(const MonitoringSignal& other) const
{
return (
id == other.id && name == other.name && unit == other.unit && rosTopicType == other.rosTopicType && datasourceId == other.datasourceId &&
datasourceName == other.datasourceName && signalType == other.signalType && signalOperator == other.signalOperator && valueType == other.valueType && value == other.value);
}
/// @brief Convert the unit to a stringified enum value for human readability (ie: 0 -> UNIT_UNSPECIFIED, 1 -> METER_PER_SECOND, etc.)
/// @return the stringified enum value
std::string unitToString() const
{
auto u = static_cast<apiinterface::Unit>(unit);
return apiinterface::Unit_Name(u);
}
/// @brief Convert the signal type to a stringified enum value for human readability (ie: 0 -> ST_UNSPECIFIED, 1 -> INTEGER, etc.)
/// @return the stringified enum value
std::string signalTypeToString() const
{
auto t = static_cast<apiinterface::SignalType>(signalType);
return apiinterface::SignalType_Name(t);
}
/// @brief Convert the signal operator to a stringified enum value for human readability (ie: 0 -> OP_UNSPECIFIED, 1 -> IN, 2 -> OUT, etc.)
/// @return the stringified enum value
std::string signalOperatorToString() const
{
auto o = static_cast<apiinterface::Operator>(signalOperator);
return apiinterface::Operator_Name(o);
}
};