47 if (data.size() < MODBUS_REGISTER_COUNT[this->protocol_version_] * 2)
50 auto publish_1_reg_sensor_state = [&](
sensor::Sensor *sensor,
size_t i,
float unit) ->
void {
51 if (sensor ==
nullptr)
53 float value =
encode_uint16(data[i * 2], data[i * 2 + 1]) * unit;
57 auto publish_2_reg_sensor_state = [&](
sensor::Sensor *sensor,
size_t reg1,
size_t reg2,
float unit) ->
void {
58 float value = ((
encode_uint16(data[reg1 * 2], data[reg1 * 2 + 1]) << 16) +
61 if (sensor !=
nullptr)
71 publish_1_reg_sensor_state(this->
pvs_[0].voltage_sensor_, 3, ONE_DEC_UNIT);
72 publish_1_reg_sensor_state(this->
pvs_[0].current_sensor_, 4, ONE_DEC_UNIT);
73 publish_2_reg_sensor_state(this->
pvs_[0].active_power_sensor_, 5, 6, ONE_DEC_UNIT);
75 publish_1_reg_sensor_state(this->
pvs_[1].voltage_sensor_, 7, ONE_DEC_UNIT);
76 publish_1_reg_sensor_state(this->
pvs_[1].current_sensor_, 8, ONE_DEC_UNIT);
77 publish_2_reg_sensor_state(this->
pvs_[1].active_power_sensor_, 9, 10, ONE_DEC_UNIT);
82 publish_1_reg_sensor_state(this->
phases_[0].voltage_sensor_, 14, ONE_DEC_UNIT);
83 publish_1_reg_sensor_state(this->
phases_[0].current_sensor_, 15, ONE_DEC_UNIT);
84 publish_2_reg_sensor_state(this->
phases_[0].active_power_sensor_, 16, 17, ONE_DEC_UNIT);
86 publish_1_reg_sensor_state(this->
phases_[1].voltage_sensor_, 18, ONE_DEC_UNIT);
87 publish_1_reg_sensor_state(this->
phases_[1].current_sensor_, 19, ONE_DEC_UNIT);
88 publish_2_reg_sensor_state(this->
phases_[1].active_power_sensor_, 20, 21, ONE_DEC_UNIT);
90 publish_1_reg_sensor_state(this->
phases_[2].voltage_sensor_, 22, ONE_DEC_UNIT);
91 publish_1_reg_sensor_state(this->
phases_[2].current_sensor_, 23, ONE_DEC_UNIT);
92 publish_2_reg_sensor_state(this->
phases_[2].active_power_sensor_, 24, 25, ONE_DEC_UNIT);
105 publish_1_reg_sensor_state(this->
pvs_[0].voltage_sensor_, 3, ONE_DEC_UNIT);
106 publish_1_reg_sensor_state(this->
pvs_[0].current_sensor_, 4, ONE_DEC_UNIT);
107 publish_2_reg_sensor_state(this->
pvs_[0].active_power_sensor_, 5, 6, ONE_DEC_UNIT);
109 publish_1_reg_sensor_state(this->
pvs_[1].voltage_sensor_, 7, ONE_DEC_UNIT);
110 publish_1_reg_sensor_state(this->
pvs_[1].current_sensor_, 8, ONE_DEC_UNIT);
111 publish_2_reg_sensor_state(this->
pvs_[1].active_power_sensor_, 9, 10, ONE_DEC_UNIT);
116 publish_1_reg_sensor_state(this->
phases_[0].voltage_sensor_, 38, ONE_DEC_UNIT);
117 publish_1_reg_sensor_state(this->
phases_[0].current_sensor_, 39, ONE_DEC_UNIT);
118 publish_2_reg_sensor_state(this->
phases_[0].active_power_sensor_, 40, 41, ONE_DEC_UNIT);
120 publish_1_reg_sensor_state(this->
phases_[1].voltage_sensor_, 42, ONE_DEC_UNIT);
121 publish_1_reg_sensor_state(this->
phases_[1].current_sensor_, 43, ONE_DEC_UNIT);
122 publish_2_reg_sensor_state(this->
phases_[1].active_power_sensor_, 44, 45, ONE_DEC_UNIT);
124 publish_1_reg_sensor_state(this->
phases_[2].voltage_sensor_, 46, ONE_DEC_UNIT);
125 publish_1_reg_sensor_state(this->
phases_[2].current_sensor_, 47, ONE_DEC_UNIT);
126 publish_2_reg_sensor_state(this->
phases_[2].active_power_sensor_, 48, 49, ONE_DEC_UNIT);