#include "csh.h"
#include "shell.h"
#include "dev_uart.h"
+#include "device_model.h"
+#include "user_mb.h"
#include "SWM341.h"
/* 输入环形缓冲大小 (须为 2 的幂) */
return 0;
}
CSH_SCMD_EXPORT_FULL(cmd_ledoff, "turn off LED (param 1~5)",
- "ledoff <1~5>\r\n - turn off the specified LED\r\n");
\ No newline at end of file
+ "ledoff <1~5>\r\n - turn off the specified LED\r\n");
+
+/* ======================== 遥测遥信区打印 ========================
+ * 打印"遥测遥信"数据区(寄存器 0~77, realtime_telemetry_t) 全部解析后的值。
+ * float 默认按 1 位小数; 电流/功率因数/参考电压等小数位较多字段单独多给几位。
+ */
+static int cmd_dump_realtime_telemetry(int argc, char **argv)
+{
+ realtime_telemetry_t t;
+ int i;
+
+ (void)argc;
+ (void)argv;
+
+ if (!user_mb_get_realtime_telemetry(&t)) {
+ csh_printf(&s_csh, "no telemetry data\r\n");
+ return -1;
+ }
+
+ csh_printf(&s_csh, "==== 遥测遥信 (reg 0~77) ====\r\n");
+ csh_printf(&s_csh, "开入状态 : 0x%04X\r\n", t.di);
+ csh_printf(&s_csh, "开出状态 : 0x%04X\r\n", t.do_);
+ csh_printf(&s_csh, "事件遥信 : 0x%08lX\r\n", (unsigned long)t.event);
+ csh_printf(&s_csh, "其它状态 : 0x%04X\r\n", t.other_state);
+ csh_printf(&s_csh, "自检信息 : 0x%04X\r\n", t.info);
+ csh_printf(&s_csh, "Ua : %.1f V\r\n", t.ua);
+ csh_printf(&s_csh, "Ub : %.1f V\r\n", t.ub);
+ csh_printf(&s_csh, "Uc : %.1f V\r\n", t.uc);
+ csh_printf(&s_csh, "Ia : %.4f A\r\n", t.ia);
+ csh_printf(&s_csh, "Ib : %.4f A\r\n", t.ib);
+ csh_printf(&s_csh, "Ic : %.4f A\r\n", t.ic);
+ csh_printf(&s_csh, "Il(漏电流) : %.4f A\r\n", t.il);
+ csh_printf(&s_csh, "I0(零序) : %.4f A\r\n", t.i0);
+ csh_printf(&s_csh, "U1(正序) : %.1f V\r\n", t.u1);
+ csh_printf(&s_csh, "U2(负序) : %.1f V\r\n", t.u2);
+ csh_printf(&s_csh, "I1(正序) : %.4f A\r\n", t.i1);
+ csh_printf(&s_csh, "I2(负序) : %.4f A\r\n", t.i2);
+ csh_printf(&s_csh, "功率因数cos : %.3f\r\n", t.cos);
+ csh_printf(&s_csh, "有功功率P : %d W\r\n", t.p);
+ csh_printf(&s_csh, "无功功率Q : %d Var\r\n", t.q);
+ csh_printf(&s_csh, "有功电度Ph : %lu 度\r\n", (unsigned long)t.ph);
+ csh_printf(&s_csh, "无功电度Qh : %lu 度\r\n", (unsigned long)t.qh);
+ csh_printf(&s_csh, "动作报告总数 : %u\r\n", t.act_report_total);
+ csh_printf(&s_csh, "动作报告指针 : %u\r\n", t.act_report_ptr);
+ csh_printf(&s_csh, "变位报告总数 : %u\r\n", t.chg_report_total);
+ csh_printf(&s_csh, "变位报告指针 : %u\r\n", t.chg_report_ptr);
+ csh_printf(&s_csh, "故障录波总数 : %u\r\n", t.fault_wave_total);
+ csh_printf(&s_csh, "故障录波指针 : %u\r\n", t.fault_wave_ptr);
+ csh_printf(&s_csh, "PT变比 : %.1f\r\n", t.pt_ratio);
+ csh_printf(&s_csh, "CT额定电流 : %u A\r\n", t.ct_ratio);
+ csh_printf(&s_csh, "累计运行时间 : %u h\r\n", t.run_hours);
+ csh_printf(&s_csh, "KM合闸次数 : %u\r\n", t.km_hz_cnt);
+ csh_printf(&s_csh, "KM分闸次数 : %u\r\n", t.km_fz_cnt);
+ csh_printf(&s_csh, "电机运行状态 : %u\r\n", t.motor_state);
+ csh_printf(&s_csh, "电机起动时间 : %.1f s\r\n", t.motor_start_time);
+ csh_printf(&s_csh, "起动最大电流 : %.4f A\r\n", t.iq);
+ csh_printf(&s_csh, "起动次数 : %u\r\n", t.st);
+ csh_printf(&s_csh, "电流不平衡度 : %.1f %%\r\n", t.i_unbalance);
+ csh_printf(&s_csh, "最大相频率 : %.2f Hz\r\n", t.max_freq);
+ csh_printf(&s_csh, "Ia相位 : %u°\r\n", t.ia_phase);
+ csh_printf(&s_csh, "Ib相位 : %u°\r\n", t.ib_phase);
+ csh_printf(&s_csh, "Ic相位 : %u°\r\n", t.ic_phase);
+ csh_printf(&s_csh, "Ua相位 : %u°\r\n", t.ua_phase);
+ csh_printf(&s_csh, "Ub相位 : %u°\r\n", t.ub_phase);
+ csh_printf(&s_csh, "Uc相位 : %u°\r\n", t.uc_phase);
+ csh_printf(&s_csh, "最大相滑差 : %.1f Hz/s\r\n", t.max_slip);
+ csh_printf(&s_csh, "CPU温度 : %.1f °\r\n", t.cpu_temp);
+ csh_printf(&s_csh, "参考电压 : %.2f V\r\n", t.vref);
+ csh_printf(&s_csh, "协议类型码 : %u\r\n", t.proto_type);
+ csh_printf(&s_csh, "热容量 : %.1f %%\r\n", t.thermal_cap);
+ csh_printf(&s_csh, "最大温度 : %.1f °\r\n", t.max_temp);
+ csh_printf(&s_csh, "Ua频率 : %.2f Hz\r\n", t.ua_freq);
+ csh_printf(&s_csh, "Ub频率 : %.2f Hz\r\n", t.ub_freq);
+ csh_printf(&s_csh, "Uc频率 : %.2f Hz\r\n", t.uc_freq);
+ csh_printf(&s_csh, "温度计数值 : %u\r\n", t.temp_cnt_val);
+ csh_printf(&s_csh, "选配功能 : 0x%08lX\r\n", (unsigned long)t.option.raw);
+ csh_printf(&s_csh, "起动模式 : %u\r\n", t.start_mode);
+ csh_printf(&s_csh, "密码 : %u\r\n", t.password);
+ csh_printf(&s_csh, "显示对比度 : %u\r\n", t.contrast);
+ csh_printf(&s_csh, "语言 : %u\r\n", t.language);
+ csh_printf(&s_csh, "电压输入方式 : %u\r\n", t.v_input_mode);
+ csh_printf(&s_csh, "USB状态 : 0x%08lX\r\n", (unsigned long)t.usb_state);
+ csh_printf(&s_csh, "重启次数 : %u\r\n", t.reboot_cnt);
+ for (i = 0; i < 9; i++)
+ csh_printf(&s_csh, "温度通道[%d] : %.1f °\r\n", i + 1, t.temp_ch[i]);
+ csh_printf(&s_csh, "最大温度通道数: %u\r\n", t.max_temp_channels);
+ return 0;
+}
+CSH_SCMD_EXPORT_ALIAS_FULL(cmd_dump_realtime_telemetry, teli, "dump telemetry data (reg 0~77)",
+ "teli\r\n - print realtime telemetry data (reg 0~77)\r\n");
\ No newline at end of file