From a709a8a0fba1e49545eb2693853f92fa6cac0b64 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 3 Apr 2023 13:03:38 +0000 Subject: [PATCH] iec60870: fix coding style Signed-off-by: Steffen Vogel --- lib/nodes/iec60870.cpp | 82 +++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/lib/nodes/iec60870.cpp b/lib/nodes/iec60870.cpp index 65be0d701..a0af9ee6a 100644 --- a/lib/nodes/iec60870.cpp +++ b/lib/nodes/iec60870.cpp @@ -22,8 +22,8 @@ using namespace std::literals::chrono_literals; static CP56Time2a timespec_to_cp56time2a(timespec time) { time_t time_ms = - static_cast (time.tv_sec) * 1000 - + static_cast (time.tv_nsec) / 1000000; + static_cast(time.tv_sec) * 1000 + + static_cast(time.tv_nsec) / 1000000; return CP56Time2a_createFromMsTimestamp(NULL, time_ms); } @@ -148,7 +148,7 @@ SignalType ASDUData::signalType() const std::optional ASDUData::checkASDU(CS101_ASDU const &asdu) const { - if (CS101_ASDU_getTypeID(asdu) != static_cast (descriptor->type)) + if (CS101_ASDU_getTypeID(asdu) != static_cast(descriptor->type)) return std::nullopt; for (int i = 0; i < CS101_ASDU_getNumberOfElements(asdu); i++) { @@ -163,41 +163,41 @@ std::optional ASDUData::checkASDU(CS101_ASDU const &asdu) cons QualityDescriptor quality; switch (typeWithoutTimestamp()) { case ASDUData::SCALED_INT: { - auto scaled_int = reinterpret_cast (io); + auto scaled_int = reinterpret_cast(io); int scaled_int_value = MeasuredValueScaled_getValue(scaled_int); - signal_data.i = static_cast (scaled_int_value); + signal_data.i = static_cast(scaled_int_value); quality = MeasuredValueScaled_getQuality(scaled_int); break; } case ASDUData::NORMALIZED_FLOAT: { - auto normalized_float = reinterpret_cast (io); + auto normalized_float = reinterpret_cast(io); float normalized_float_value = MeasuredValueNormalized_getValue(normalized_float); - signal_data.f = static_cast (normalized_float_value); + signal_data.f = static_cast(normalized_float_value); quality = MeasuredValueNormalized_getQuality(normalized_float); break; } case ASDUData::DOUBLE_POINT: { - auto double_point = reinterpret_cast (io); + auto double_point = reinterpret_cast(io); DoublePointValue double_point_value = DoublePointInformation_getValue(double_point); - signal_data.i = static_cast (double_point_value); + signal_data.i = static_cast(double_point_value); quality = DoublePointInformation_getQuality(double_point); break; } case ASDUData::SINGLE_POINT: { - auto single_point = reinterpret_cast (io); + auto single_point = reinterpret_cast(io); bool single_point_value = SinglePointInformation_getValue(single_point); - signal_data.b = static_cast (single_point_value); + signal_data.b = static_cast(single_point_value); quality = SinglePointInformation_getQuality(single_point); break; } case ASDUData::SHORT_FLOAT: { - auto short_float = reinterpret_cast (io); + auto short_float = reinterpret_cast(io); float short_float_value = MeasuredValueShort_getValue(short_float); - signal_data.f = static_cast (short_float_value); + signal_data.f = static_cast(short_float_value); quality = MeasuredValueShort_getQuality(short_float); break; } @@ -209,31 +209,31 @@ std::optional ASDUData::checkASDU(CS101_ASDU const &asdu) cons std::optional time_cp56; switch (type()) { case ASDUData::SCALED_INT_WITH_TIMESTAMP: { - auto scaled_int = reinterpret_cast (io); + auto scaled_int = reinterpret_cast(io); time_cp56 = MeasuredValueScaledWithCP56Time2a_getTimestamp(scaled_int); break; } case ASDUData::NORMALIZED_FLOAT_WITH_TIMESTAMP: { - auto normalized_float = reinterpret_cast (io); + auto normalized_float = reinterpret_cast(io); time_cp56 = MeasuredValueNormalizedWithCP56Time2a_getTimestamp(normalized_float); break; } case ASDUData::DOUBLE_POINT_WITH_TIMESTAMP: { - auto double_point = reinterpret_cast (io); + auto double_point = reinterpret_cast(io); time_cp56 = DoublePointWithCP56Time2a_getTimestamp(double_point); break; } case ASDUData::SINGLE_POINT_WITH_TIMESTAMP: { - auto single_point = reinterpret_cast (io); + auto single_point = reinterpret_cast(io); time_cp56 = SinglePointWithCP56Time2a_getTimestamp(single_point); break; } case ASDUData::SHORT_FLOAT_WITH_TIMESTAMP: { - auto short_float = reinterpret_cast (io); + auto short_float = reinterpret_cast(io); time_cp56 = MeasuredValueShortWithCP56Time2a_getTimestamp(short_float); break; } @@ -263,72 +263,72 @@ bool ASDUData::addSampleToASDU(CS101_ASDU &asdu, ASDUData::Sample sample) const InformationObject io; switch (descriptor->type) { case ASDUData::SCALED_INT: { - auto scaled_int_value = static_cast (sample.signal_data.i & 0xFFFF); + auto scaled_int_value = static_cast(sample.signal_data.i & 0xFFFF); auto scaled_int = MeasuredValueScaled_create(NULL, ioa, scaled_int_value, sample.quality); - io = reinterpret_cast (scaled_int); + io = reinterpret_cast(scaled_int); break; } case ASDUData::NORMALIZED_FLOAT: { - auto normalized_float_value = static_cast (sample.signal_data.f); + auto normalized_float_value = static_cast(sample.signal_data.f); auto normalized_float = MeasuredValueNormalized_create(NULL, ioa, normalized_float_value, sample.quality); - io = reinterpret_cast (normalized_float); + io = reinterpret_cast(normalized_float); break; } case ASDUData::DOUBLE_POINT: { - auto double_point_value = static_cast (sample.signal_data.i & 0x3); + auto double_point_value = static_cast(sample.signal_data.i & 0x3); auto double_point = DoublePointInformation_create(NULL, ioa, double_point_value, sample.quality); - io = reinterpret_cast (double_point); + io = reinterpret_cast(double_point); break; } case ASDUData::SINGLE_POINT: { auto single_point_value = sample.signal_data.b; auto single_point = SinglePointInformation_create(NULL, ioa, single_point_value, sample.quality); - io = reinterpret_cast (single_point); + io = reinterpret_cast(single_point); break; } case ASDUData::SHORT_FLOAT: { - auto short_float_value = static_cast (sample.signal_data.f); + auto short_float_value = static_cast(sample.signal_data.f); auto short_float = MeasuredValueShort_create(NULL, ioa, short_float_value, sample.quality); - io = reinterpret_cast (short_float); + io = reinterpret_cast(short_float); break; } case ASDUData::SCALED_INT_WITH_TIMESTAMP: { - auto scaled_int_value = static_cast (sample.signal_data.i & 0xFFFF); + auto scaled_int_value = static_cast(sample.signal_data.i & 0xFFFF); auto scaled_int = MeasuredValueScaledWithCP56Time2a_create(NULL, ioa, scaled_int_value, sample.quality, timestamp.value()); - io = reinterpret_cast (scaled_int); + io = reinterpret_cast(scaled_int); break; } case ASDUData::NORMALIZED_FLOAT_WITH_TIMESTAMP: { - auto normalized_float_value = static_cast (sample.signal_data.f); + auto normalized_float_value = static_cast(sample.signal_data.f); auto normalized_float = MeasuredValueNormalizedWithCP56Time2a_create(NULL, ioa, normalized_float_value, sample.quality, timestamp.value()); - io = reinterpret_cast (normalized_float); + io = reinterpret_cast(normalized_float); break; } case ASDUData::DOUBLE_POINT_WITH_TIMESTAMP: { - auto double_point_value = static_cast (sample.signal_data.i & 0x3); + auto double_point_value = static_cast(sample.signal_data.i & 0x3); auto double_point = DoublePointWithCP56Time2a_create(NULL, ioa, double_point_value, sample.quality, timestamp.value()); - io = reinterpret_cast (double_point); + io = reinterpret_cast(double_point); break; } case ASDUData::SINGLE_POINT_WITH_TIMESTAMP: { auto single_point_value = sample.signal_data.b; auto single_point = SinglePointWithCP56Time2a_create(NULL, ioa, single_point_value, sample.quality, timestamp.value()); - io = reinterpret_cast (single_point); + io = reinterpret_cast(single_point); break; } case ASDUData::SHORT_FLOAT_WITH_TIMESTAMP: { - auto short_float_value = static_cast (sample.signal_data.f); + auto short_float_value = static_cast(sample.signal_data.f); auto short_float = MeasuredValueShortWithCP56Time2a_create(NULL, ioa, short_float_value, sample.quality, timestamp.value()); - io = reinterpret_cast (short_float); + io = reinterpret_cast(short_float); break; } @@ -383,27 +383,27 @@ void SlaveNode::createSlave() noexcept // Setup callbacks into the class CS104_Slave_setClockSyncHandler(server.slave, [] (void *tcp_node, IMasterConnection connection, CS101_ASDU asdu, CP56Time2a new_time) { - auto self = static_cast (tcp_node); + auto self = static_cast(tcp_node); return self->onClockSync(connection, asdu, new_time); }, this); CS104_Slave_setInterrogationHandler(server.slave, [] (void *tcp_node, IMasterConnection connection, CS101_ASDU asdu, QualifierOfInterrogation qoi) { - auto self = static_cast (tcp_node); + auto self = static_cast(tcp_node); return self->onInterrogation(connection, asdu, qoi); }, this); CS104_Slave_setASDUHandler(server.slave, [] (void *tcp_node, IMasterConnection connection, CS101_ASDU asdu) { - auto self = static_cast (tcp_node); + auto self = static_cast(tcp_node); return self->onASDU(connection, asdu); }, this); CS104_Slave_setConnectionEventHandler(server.slave, [](void *tcp_node, IMasterConnection connection, CS104_PeerConnectionEvent event){ - auto self = static_cast (tcp_node); + auto self = static_cast(tcp_node); self->debugPrintConnection(connection, event); }, this); CS104_Slave_setRawMessageHandler(server.slave, [](void *tcp_node, IMasterConnection connection, uint8_t *message, int message_size, bool sent){ - auto self = static_cast (tcp_node); + auto self = static_cast(tcp_node); self->debugPrintMessage(connection, message, message_size, sent); }, this);