|
|
@ -207,17 +207,27 @@ void DisinfectionApp::initialize() { |
|
|
|
} |
|
|
|
|
|
|
|
if (io0enable || io1enable || io2enable) { |
|
|
|
REG_LAMADA_FN(kfn_liquid_level_read_io_state, [&](ProcessContext* cxt) { |
|
|
|
REG_LAMADA_FN(kfn_disinfectant_bucket_level_sensor_read_level, [&](ProcessContext* cxt) { |
|
|
|
int32_t liquid_level_state = 0; |
|
|
|
if (io0enable) { |
|
|
|
liquid_level_state |= (io0.read() ? 0 : 1) << 0; // bit0:低液位置
|
|
|
|
} |
|
|
|
if (io1enable) { |
|
|
|
liquid_level_state |= (io1.read() ? 0 : 1) << 1; // bit1:中液位
|
|
|
|
} |
|
|
|
if (io2enable) { |
|
|
|
liquid_level_state |= (io2.read() ? 0 : 1) << 2; // bit2:高液位
|
|
|
|
|
|
|
|
bool io0state = false; |
|
|
|
bool io1state = false; |
|
|
|
bool io2state = false; |
|
|
|
|
|
|
|
if (io0enable) io0state = io0.read(); |
|
|
|
if (io1enable) io1state = io1.read(); |
|
|
|
if (io2enable) io2state = io2.read(); |
|
|
|
|
|
|
|
if (io2state) { |
|
|
|
liquid_level_state = 3; // 液位最高
|
|
|
|
} else if (io1state) { |
|
|
|
liquid_level_state = 2; // 液位中等
|
|
|
|
} else if (io0state) { |
|
|
|
liquid_level_state = 1; // 液位最低
|
|
|
|
} else { |
|
|
|
liquid_level_state = 0; // 无液位
|
|
|
|
} |
|
|
|
|
|
|
|
zcanbus_send_ack(cxt->packet, liquid_level_state); |
|
|
|
}); |
|
|
|
} |
|
|
|