You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
196 lines
9.0 KiB
196 lines
9.0 KiB
#include "internationalization.hpp"
|
|
|
|
#include "app_protocols/apperrorcode/apperrorcode.hpp"
|
|
using namespace iflytop;
|
|
using namespace std;
|
|
using namespace transmit_disfection_protocol;
|
|
using namespace iflytop::err;
|
|
class EcodeInfo {
|
|
public:
|
|
int code;
|
|
string info;
|
|
EcodeInfo(int code, const string& info) : code(code), info(info) {}
|
|
};
|
|
|
|
class CmdInfo {
|
|
public:
|
|
int cmdid;
|
|
string info;
|
|
CmdInfo(int cmdid, const string& info) : cmdid(cmdid), info(info) {}
|
|
};
|
|
|
|
static EcodeInfo chEcodeInfo[] = {
|
|
{kerr_overtime, "通信超时"},
|
|
{kerr_invalid_param, "非法参数"},
|
|
{kerr_invalid_param_num, "参数数量错误"},
|
|
{kerr_subdevice_offline, "485总线设备异常"},
|
|
{kerr_function_not_support, "代码错误方法不支持"},
|
|
{kerr_subdevice_overtime, "485总线设备通信超时"},
|
|
{kerr_motor_reset_error, "电机复位错误"},
|
|
{kerr_motor_subdevice_offline, "电机子设备离线"},
|
|
{kerr_motor_driver_error, "电机驱动器错误"},
|
|
{kerr_motor_undervoltage_error, "电机欠压错误"},
|
|
{kerr_motor_unkown_error, "电机未知错误"},
|
|
{kerr_motor_overtemperature_flag, "电机过温"},
|
|
{kerr_motor_overtemperature_pre_warning_flag, "电机过温预警"},
|
|
{kerr_motor_short_to_ground_indicator_phase_A, "电机A相短接"},
|
|
{kerr_motor_short_to_ground_indicator_phase_B, "电机B相短接"},
|
|
{kerr_motor_open_load_indicator_phase_A, "电机A相过载"},
|
|
{kerr_motor_open_load_indicator_phase_B, "电机B相过载"},
|
|
{kerr_motor_standstill_indicator, "电机异常停止"},
|
|
{kerr_AirBlowerError, "空压机异常"},
|
|
{kerr_HeaterError, "加热片异常"},
|
|
{kerr_BlowerError, "鼓风机异常"},
|
|
{kerr_ProportionalValveError, "气密性测试专用空压机异常"},
|
|
|
|
{kappe_code_error, "代码错误"},
|
|
{kappe_component_cfg_not_find, "组件配置未找到"},
|
|
{kappe_cmd_not_support, "命令不支持"},
|
|
{kappe_parse_json_err, "解析json错误"},
|
|
{kappe_std_exception, "标准库异常"},
|
|
{kappe_db_operate_error, "数据库操作错误"},
|
|
{kappe_missing_param, "缺少参数"},
|
|
{kappe_param_num_err, "参数个数错误"},
|
|
{kappe_param_value_err, "参数值错误"},
|
|
{kappe_user_not_exist, "用户不存在"},
|
|
{kappe_passwd_error, "密码错误"},
|
|
{kappe_user_exist, "用户已存在"},
|
|
{kappe_login_fail_device_islogined, "登陆失败,设备已登录"},
|
|
{kappe_disinfectant_insufficient, "消毒液不足"},
|
|
{kappe_the_bottom_of_the_device_has_water, "硬件仓内有液体"},
|
|
{kappe_the_evaporation_bin_has_water, "蒸发仓内有液体"},
|
|
{kappe_the_sensor_is_prehearting, "传感器正在预热"},
|
|
{kappe_not_detect_udisk, "未检测到U盘"},
|
|
{kappe_udisk_wr_fail, "U盘读写错误"},
|
|
{kappe_open_file_error, "文件操作错误"},
|
|
{kappe_adding_liquid_is_already_in_place, "液体已加到位"},
|
|
{kappe_adding_liquid_is_greater_than_the_maximum_capacity_of_the_device, "加液大于设备最大容量"},
|
|
{kappe_sensor_is_pre_hearting, "传感器正在预热"},
|
|
{kappe_state_is_busy, "设备忙"},
|
|
{kappe_is_adding_liquid, "加液中"},
|
|
{kappe_is_draining_liquid, "排液中"},
|
|
{kappe_is_disinfecting, "消毒中"},
|
|
{kappe_is_air_leak_detect_testing, "气密性测试中"},
|
|
{kappe_setting_id_outof_range, "设置ID超出范围"},
|
|
{kappe_exception_flag_is_setted, "设备硬件异常"},
|
|
{kappe_disinfection_state_is_wrong, "消毒状态错误"},
|
|
{kappe_liquid_ctrl_reboot, "液路板复位"},
|
|
{kappe_power_control_reboot, "功率板复位"},
|
|
{kappe_device_type_not_init, "设备未初始化"},
|
|
|
|
};
|
|
|
|
static CmdInfo cmdInfo[] = {
|
|
{kfn_read_board_info, "读取子板信息"},
|
|
{kfn_force_report, "强制上报"},
|
|
{kfn_read_sysinfo, "读取子板系统信息"},
|
|
{kfn_read_taskinfo, "读取子板任务信息"},
|
|
{kfn_heart_ping, "心跳PING"},
|
|
{kfn_clear_reset_flag, "清除复位标志"},
|
|
{kfn_enable_report, "启用上报"},
|
|
{kfn_reset_board, "复位子板"},
|
|
{kreport_heatpacket_pong, "心跳PONG"},
|
|
{kreport_exception_error, "异常错误上报"},
|
|
{kreport_device_reset, "设备复位上报"},
|
|
{kfn_pump_rotate, "泵机控制"},
|
|
{kfn_pump_stop, "泵机控制"},
|
|
{kfn_pump_set_ihold_irun_idelay, "泵机设置IHOLD参数"},
|
|
{kfn_pump_set_acc, "泵机设置加速参数"},
|
|
{kfn_pump_ping, "泵机PING"},
|
|
{kfn_pump_set_ramp, "泵机设置RAMP"},
|
|
{kfn_pump_set_tzw, "泵机设置TZW"},
|
|
{kfn_pump_set_subic_reg, "泵机设置子IC寄存器"},
|
|
{kfn_pump_get_subic_reg, "泵机获取子IC寄存器"},
|
|
{kfn_pump_is_run, "泵机是否在运行"},
|
|
{kfn_heater_ctrl, "加热片控制"},
|
|
{kfn_heater_ctrl_safe_valve, "加热片安全阀控制"},
|
|
{kfn_heater_read_ei, "读取加热片电流"},
|
|
{kfn_heater_read_temperature_data, "读取加热片温度数据"},
|
|
{kfn_heater_read_ei_adc_raw, "读取加热片电流ADC原始数据"},
|
|
{kfn_heater_read_temperature_data_adc_raw, "读取加热片温度数据ADC原始数据"},
|
|
{kfn_heater_is_open, "加热片是否开启"},
|
|
{kfn_h2o2_sensor_read_calibration_date, "读取H2O2传感器校准日期"},
|
|
{kfn_h2o2_sensor_read_sub_ic_errorcode, "读取H2O2传感器子IC错误码"},
|
|
{kfn_h2o2_sensor_read_sub_ic_reg, "读取H2O2传感器子IC寄存器"},
|
|
{kreport_h2o2_sensor_data, "H2O2传感器数据上报"},
|
|
{kfn_triple_warning_light_ctl, "三色警示灯控制"},
|
|
{kfn_triple_warning_light_read_state, "三色警示灯读取状态"},
|
|
{kfn_evaporation_tank_water_sensor_read_state, "读取蒸发仓水位传感器状态"},
|
|
{kfn_device_bottom_water_sensor_read_state, "读取设备底部水位传感器状态"},
|
|
{kreport_evaporation_bin_water_sensor, "蒸发仓水位传感器上报"},
|
|
{kreport_device_bottom_water_sensor, "设备底部水位传感器上报"},
|
|
{kfn_blower_ctrl, "风机控制"},
|
|
{kfn_blower_ctrl_safe_valve, "风机安全阀控制"},
|
|
{kfn_blower_read_ei, "读取风机电流"},
|
|
{kfn_blower_is_error, "读取风机电气异常状态"},
|
|
{kfn_blower_read_ei_adc_raw, "读取风机电流ADC原始数据"},
|
|
{kfn_blower_is_open, "读取风机是否开启"},
|
|
{kfn_air_compressor_ctrl, "空压机控制"},
|
|
{kfn_air_compressor_ctrl_safe_valve, "空压机安全阀控制"},
|
|
{kfn_air_compressor_read_ei, "读取空压机电流"},
|
|
{kfn_air_compressor_read_ei_adc_raw, "读取空压机电流ADC原始数据"},
|
|
{kfn_air_compressor_is_open, "读取空压机是否开启"},
|
|
{kfn_air_leak_detect_ac_ctrl, "空压机气密性测试控制"},
|
|
{kfn_air_leak_detect_ac_is_open, "空压机气密性测试是否开启"},
|
|
{kfn_psbus_read_data, "读取PSBUS数据"},
|
|
{kfn_psbus_scan, "扫描PSBUS设备"},
|
|
{kfn_psbus_start_report, "开始PSBUS设备上报"},
|
|
{kfn_psbus_stop_report, "停止PSBUS设备上报"},
|
|
{kreport_pressure_data, "压力数据上报"},
|
|
{kfn_proportional_set_valve, "设置比例阀"},
|
|
{kfn_proportional_read_pos, "读取比例阀位置"},
|
|
{kfn_proportional_is_busy, "比例阀是否忙碌"},
|
|
{kfn_air_leak_test_set_mode, "设置气密性测试模式"},
|
|
{kfn_air_leak_test_get_mode, "读取气密性测试模式"},
|
|
{kfn_ext_ch_selector_set_ch, "设置外部通道选择器通道"},
|
|
{kfn_ext_ch_selector_get_ch, "获取外部通道选择器通道"},
|
|
{kfn_set_add_fluid_channel_selector_valve, "设置加液通道选择阀"},
|
|
{kfn_disinfectant_bucket_level_sensor_read_level, "读取消毒液桶液位传感器"},
|
|
{kappe_no_online_h2o2_sensor_dectected, "未检测到在线H2O2传感器"},
|
|
|
|
};
|
|
|
|
string Internationalization::ecode2description(int ecode) {
|
|
for (const auto& e : chEcodeInfo) {
|
|
if (e.code == ecode) {
|
|
return fmt::format("{}({})", e.info, e.code);
|
|
}
|
|
}
|
|
return fmt::format("错误码{}", ecode);
|
|
}
|
|
|
|
string Internationalization::cmdid2str(int cmdid) {
|
|
for (const auto& c : cmdInfo) {
|
|
if (c.cmdid == cmdid) {
|
|
return fmt::format("{}({})", c.info, c.cmdid);
|
|
}
|
|
}
|
|
return fmt::format("命令ID{}", cmdid);
|
|
}
|
|
|
|
string Internationalization::ecode2description(int ecode, int32_t toboard, int32_t cmdid, uint8_t* param, int32_t paramLen) { //
|
|
if (cmdid == kfn_proportional_set_valve) {
|
|
int32_t subid = ((int32_t*)param)[0];
|
|
return fmt::format("{},设置比例阀{}异常", ecode, subid);
|
|
}
|
|
return fmt::format("{},执行{}错误", ecode, cmdid2str(cmdid));
|
|
}
|
|
string Internationalization::deviceBusyError2description(int ecode, DeviceState deviceState) {
|
|
if (ecode == kappe_state_is_busy) {
|
|
switch (deviceState) {
|
|
case DeviceState::kIdle:
|
|
return "设备空闲";
|
|
case DeviceState::kAddingLiquid:
|
|
return "操作不允许, 设备正在加液";
|
|
case DeviceState::kDrainingLiquid:
|
|
return "操作不允许, 设备正在排液";
|
|
case DeviceState::kDisinfection:
|
|
return "操作不允许, 设备正在消毒";
|
|
case DeviceState::kAirLeakDetectTesting:
|
|
return "操作不允许, 设备正在气密性测试";
|
|
default:
|
|
return "设备状态未知";
|
|
}
|
|
}
|
|
return ecode2description(ecode);
|
|
}
|