面板显示更新,json配置增加语言显示配置

main
HwangKC 2025-03-17 09:58:54 +08:00
parent 33ab44bd08
commit 542c170fe5
4 changed files with 15 additions and 7 deletions

View File

@ -158,14 +158,15 @@ void CustomDisplayPanel::UpdateData(OpenJson& json)
int panel_type = json["panel_type"].i32(); int panel_type = json["panel_type"].i32();
qDebug() << panel_type; qDebug() << panel_type;
if (panel_type == CustomDisplayPanel::PANEL_TEMPERATURE) if (panel_type == CustomDisplayPanel::PANEL_ALARM)
{
UpdateTemperature(json);
}
else if (panel_type == CustomDisplayPanel::PANEL_ALARM)
{ {
UpdateAlarm(json); UpdateAlarm(json);
} }
else //(panel_type == CustomDisplayPanel::PANEL_TEMPERATURE)
{
UpdateTemperature(json);
}
} }
void CustomDisplayPanel::UpdateTemperature(OpenJson &json) void CustomDisplayPanel::UpdateTemperature(OpenJson &json)

View File

@ -19,6 +19,7 @@
"start_addr":40000, "start_addr":40000,
"quantity":9, "quantity":9,
"bytes_per_register":2, "bytes_per_register":2,
"language":"en",
"device_name_chn":"温湿度", "device_name_chn":"温湿度",
"device_name_eng":"Temperature", "device_name_eng":"Temperature",
"device_type":1, "device_type":1,
@ -119,6 +120,7 @@
"start_addr":40009, "start_addr":40009,
"quantity":6, "quantity":6,
"bytes_per_register":2, "bytes_per_register":2,
"language":"en",
"device_name_chn":"温湿度告警", "device_name_chn":"温湿度告警",
"device_name_eng":"Alarm", "device_name_eng":"Alarm",
"device_type":6, "device_type":6,
@ -180,7 +182,7 @@
"unit":"", "unit":"",
"title_chn":"低温告警", "title_chn":"低温告警",
"title_eng":"Low Temp.", "title_eng":"Low Temp.",
"display":0, "display":1,
"skip":0 "skip":0
} }
] ]

View File

@ -261,6 +261,7 @@ void MainWindow::ReadConfiguration(QString jsonFilePath)
address_item.start_addr = nodeAddrItem["start_addr"].i32(); address_item.start_addr = nodeAddrItem["start_addr"].i32();
address_item.quantity = nodeAddrItem["quantity"].i32(); address_item.quantity = nodeAddrItem["quantity"].i32();
address_item.bytes_per_register = nodeAddrItem["bytes_per_register"].i32(); address_item.bytes_per_register = nodeAddrItem["bytes_per_register"].i32();
address_item.lang = nodeAddrItem["language"].s();
address_item.device_name_chn = nodeAddrItem["device_name_chn"].s(); address_item.device_name_chn = nodeAddrItem["device_name_chn"].s();
address_item.device_name_eng = nodeAddrItem["device_name_eng"].s(); address_item.device_name_eng = nodeAddrItem["device_name_eng"].s();
address_item.device_type = nodeAddrItem["device_type"].i32(); address_item.device_type = nodeAddrItem["device_type"].i32();
@ -724,6 +725,9 @@ void MainWindow::DecodeSync(const QVector<uint16_t>& array,const slaveAddress& s
ddi.display_location = iter->second.display; ddi.display_location = iter->second.display;
ddi.order = iter->second.order; ddi.order = iter->second.order;
ddi.precision = iter->second.precision; ddi.precision = iter->second.precision;
if (QString::fromStdString(sa.lang.c_str()).toLower() == "chn")
ddi.title = iter->second.title_chn;
else
ddi.title = iter->second.title_en; ddi.title = iter->second.title_en;
ddi.unit = iter->second.unit; ddi.unit = iter->second.unit;
ddi.value = array[idx]; ddi.value = array[idx];

View File

@ -126,6 +126,7 @@ typedef struct __slaveAddress
int start_addr; // ":40000, 寄存器地址 int start_addr; // ":40000, 寄存器地址
unsigned short quantity; // " : 9, 连续读取多少个寄存器 unsigned short quantity; // " : 9, 连续读取多少个寄存器
unsigned short bytes_per_register; // " : 2, 每个寄存器的字节数缺省是uint16,两个字节 unsigned short bytes_per_register; // " : 2, 每个寄存器的字节数缺省是uint16,两个字节
std::string lang; // 使用语言,"chn": 中文 "en":English
std::string device_name_chn; // " : "温湿度", 该寄存器数组代表的设备名称 std::string device_name_chn; // " : "温湿度", 该寄存器数组代表的设备名称
std::string device_name_eng; // " : "温湿度", 该寄存器数组代表的设备名称,英文 std::string device_name_eng; // " : "温湿度", 该寄存器数组代表的设备名称,英文