|
@@ -38,7 +38,7 @@ impl GoldBms {
|
|
|
})?;
|
|
|
info!("成功加载BMS协议配置,共{}个寄存器", config.len());
|
|
|
let ctx = connect_modbus_tcp().await?;
|
|
|
- info!("BMS[{}]初始化成功!", id);
|
|
|
+ info!("{}初始化成功!", id);
|
|
|
Ok(GoldBms {
|
|
|
id,
|
|
|
_producer: producer,
|
|
@@ -73,7 +73,7 @@ impl GoldBms {
|
|
|
publish_data!(client, vec, "/pds/bms/0/yx", RegisterType::DiscreteInput);
|
|
|
// 发布遥调数据 (YT)
|
|
|
publish_data!(client, vec, "/pds/bms/0/yt", RegisterType::HoldingRegister);
|
|
|
- info!("数据上行成功, 耗时 {:?}", time.elapsed());
|
|
|
+ info!("MQTT ↑↑↑, took {:?}", time.elapsed());
|
|
|
Ok(())
|
|
|
}
|
|
|
}
|
|
@@ -124,7 +124,7 @@ impl Service for GoldBms {
|
|
|
handle_modbus_error(&e, &self.ctx, "读取保持寄存器失败").await;
|
|
|
}
|
|
|
if let Err(e) = &self.push(modbus_guard.as_slice(), time).await {
|
|
|
- error!("推送消息失败: {}", e);
|
|
|
+ error!("MQTT ↑↑↑ error: {}", e);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -136,16 +136,16 @@ impl Service for GoldBms {
|
|
|
let modbus_code_clone = self.modbus_code.clone();
|
|
|
if let Ok(msg) = consumer.lock().await.recv().await {
|
|
|
if msg.id == self.id {
|
|
|
- info!("[BMS]接收到指令: {}", msg);
|
|
|
+ info!("MQTT ↓↓↓: {}", msg);
|
|
|
let instant = Instant::now();
|
|
|
let modbus_code = modbus_code_clone.lock().await;
|
|
|
let mut req_code = ModbusReqCode::build(modbus_code.as_slice(), &msg);
|
|
|
let vec = slice_sequential(req_code.as_mut_slice(), MAX_WORD_CNT);
|
|
|
let context_guard = ctx.lock().await;
|
|
|
match down_link(vec, context_guard).await {
|
|
|
- Ok(()) => info!("数据下行成功, 耗时 {:?}", instant.elapsed()),
|
|
|
+ Ok(()) => info!("modbus ↓↓↓, took {:?}", instant.elapsed()),
|
|
|
Err(e) => {
|
|
|
- error!("数据下行失败:{}", e)
|
|
|
+ error!("modbus ↓↓↓ error:{}", e)
|
|
|
}
|
|
|
}
|
|
|
}
|