From ed7ed0ba8061163fb904d3736f93e67263700b7f Mon Sep 17 00:00:00 2001 From: bowang888 Date: Tue, 17 Dec 2024 14:50:22 +0800 Subject: [PATCH] first commit --- CableTool.pro | 44 + CableTool.pro.user | 322 ++ common.cpp | 109 + common.h | 521 +++ form.ui | 8962 ++++++++++++++++++++++++++++++++++++++++++++ images/AppIcon.ico | Bin 0 -> 10776 bytes main.cpp | 11 + widget.cpp | 2373 ++++++++++++ widget.h | 227 ++ 9 files changed, 12569 insertions(+) create mode 100644 CableTool.pro create mode 100644 CableTool.pro.user create mode 100644 common.cpp create mode 100644 common.h create mode 100644 form.ui create mode 100644 images/AppIcon.ico create mode 100644 main.cpp create mode 100644 widget.cpp create mode 100644 widget.h diff --git a/CableTool.pro b/CableTool.pro new file mode 100644 index 0000000..7f66aa5 --- /dev/null +++ b/CableTool.pro @@ -0,0 +1,44 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2024-09-19T10:32:24 +# +#------------------------------------------------- + +QT += core gui +QT += serialport + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = CableTool +TEMPLATE = app +RC_ICONS = images/AppIcon.ico + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +CONFIG += c++11 + +SOURCES += \ + main.cpp \ + widget.cpp \ + common.cpp + +HEADERS += \ + widget.h \ + common.h + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target + +FORMS += \ + form.ui diff --git a/CableTool.pro.user b/CableTool.pro.user new file mode 100644 index 0000000..48f8ec9 --- /dev/null +++ b/CableTool.pro.user @@ -0,0 +1,322 @@ + + + + + + EnvironmentId + {a69b2536-8d4a-4969-8b95-1e79af475b44} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + -fno-delayed-template-parsing + + true + + + + ProjectExplorer.Project.Target.0 + + Desktop Qt 5.11.3 MinGW 32bit + Desktop Qt 5.11.3 MinGW 32bit + qt.qt5.5113.win32_mingw53_kit + 2 + 0 + 0 + + D:/work/QtProject/CableTool/build-CableTool-Desktop_Qt_5_11_3_MinGW_32bit-Debug + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + true + + + D:/work/QtProject/CableTool/build-CableTool-Desktop_Qt_5_11_3_MinGW_32bit-Release + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + + false + false + true + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + + D:/work/QtProject/CableTool/build-CableTool-Desktop_Qt_5_11_3_MinGW_32bit-Profile + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + true + true + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + 3 + + + 0 + 部署 + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy Configuration + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + CableTool + + Qt4ProjectManager.Qt4RunConfiguration:D:/work/QtProject/CableTool/CableTool/CableTool.pro + true + + CableTool.pro + + D:/work/QtProject/CableTool/build-CableTool-Desktop_Qt_5_11_3_MinGW_32bit-Profile + 3768 + false + true + false + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 18 + + + Version + 18 + + diff --git a/common.cpp b/common.cpp new file mode 100644 index 0000000..b5b0405 --- /dev/null +++ b/common.cpp @@ -0,0 +1,109 @@ +#include "common.h" +#include +#include + +#define CRC32_CHAR_BIT 8 +static uint32_t crc32Table[256]; + + +uint32_t crc32_reflect(uint32_t value, uint8_t bits) +{ + uint32_t reflection = 0; + + for(uint8_t i = 0; i < bits ; i++) + { + if (value & (1u << i)) + reflection |= 1 << (bits - 1 - i); + } + + return reflection; +} + +/* crc32 初始化. */ +void crc32_table_init(void) +{ + uint32_t int1 = 1; + uint32_t const value_high_bit = int1 << 31u; + uint8_t dividend = 0; + + do + { + uint32_t remainder = 0; + for(uint8_t mask = 1u << (CRC32_CHAR_BIT - 1u); mask; mask >>= 1) + { + if (dividend & mask) + remainder ^= value_high_bit; + + if (remainder & value_high_bit) + { + remainder <<= 1; + remainder ^= 0x04C11DB7u; + } + else + remainder <<= 1; + } + + crc32Table[crc32_reflect(dividend, CRC32_CHAR_BIT)] = crc32_reflect(remainder, 32); + } + while(++dividend); +} + + +uint32_t crc32(void const *buf, uint32_t byte_count) +{ + uint32_t rem = 0xFFFFFFFF; + uint8_t const * const b_begin = (uint8_t*)buf; + uint8_t const * const b_end = b_begin + byte_count; + + for(uint8_t const *p = b_begin; p < b_end; p++) + { + uint8_t const byte_index = *p ^ rem; + rem >>= CRC32_CHAR_BIT; + rem ^= crc32Table[ byte_index ]; + //char *nptr = (char *)&rem; + //printHexArray(nptr, 4); + } + return ~rem; +} + +int32_t stringToChar(QString str, char *buf, uint32_t len) +{ + if (nullptr == buf) + { + return -1; + } + + QByteArray ba = str.toLatin1(); + + if (ba.length() <= 0 + || ba.length() >= len) + { + return -2; + } + + memset(buf, 0, len); + memcpy(buf, ba.data(), ba.length()); + return 0; +} + + +void printHexArray(const char *msg, const char *array, int length) +{ + QTextStream out(stdout); + out << msg << "###printHexArray" << "(len:" << length << ")\n"; + for (int i = 0; i < length; ++i) + { + out << QString::number(static_cast(array[i]), 16) + .toUpper().rightJustified(2, '0'); // 转换为16进制并且前面补0 + if (i < length - 1) + { + out << " "; // 每个元素之间加空格 + } + + if ((i+1) % 16 == 0) + out << "\n"; // 换行 + } + out << "\n"; // 换行 +} + + diff --git a/common.h b/common.h new file mode 100644 index 0000000..54b1bfb --- /dev/null +++ b/common.h @@ -0,0 +1,521 @@ +/***************************************************************************** + * file Inc/common.h + * author YuLiang + * version 1.0.0 + * date 10-Jun-2022 + * brief This file provides all the headers of common function. + ****************************************************************************** + * Attention + * + *

© COPYRIGHT(c) 2022 LandPower

+ * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of WTOE nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ******************************************************************************/ + +#ifndef __COMMON_H__ +#define __COMMON_H__ + +/* Includes ------------------------------------------------------------------*/ +#include +//#include "cmsis_os.h" +//#include "task.h" +#include +#include +#include + +/* Define --------------------------------------------------------------------*/ + + +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef short int16_t; +typedef unsigned short uint16_t; +typedef int int32_t; +typedef unsigned uint32_t; + +#define TRUE 1 +#define FALSE 0 +#define OTHER 2 + +/* int16_t无效时的数据. */ +#define INVALID_DATE_8 0x7F +/* uint16_t无效数据.*/ +#define INVALID_DATA_U8 0xFF +/* int16_t无效时的数据. */ +#define INVALID_DATE_16 0x7FFF +/* uint16_t无效数据.*/ +#define INVALID_DATA_U16 0xFFFF +/* int32_t无效时的数据. */ +#define INVALID_DATE_32 0x7FFFFFFF +/* uint32_t无效数据.*/ +#define INVALID_DATA_U32 0xFFFFFFFF + +/* DAU 工频通道数. */ +#define DAU_PORT_POWER_CNT 8 +#define DAU_PORT_DEFECT_MAX 4 +#define DAU_PORT_FAULT_MAX 4 +/* ADC 校准点. */ +#define DAU_POWER_ADJ_CNT 5 + +/* ADC 通道数. */ +#define CFG_ADC_CH_CNT 8 +#define SENSOR_SUM 8 +/* ADC 校准点. */ +#define ADC_COLLECT_CNT 2000 // ADC 每个通道采样次数. + +/* RS485 传感器数量. */ +#define SENSOR_SUM 8 +#define WAVE_SUM 4 +#define POSITION_SUM 3 + +#define USART_BUF_SIZE 1088 +#define DEBUG_DATA_SIZE 1024 +#define UPDATE_DATA_SIZE DEBUG_DATA_SIZE + +#define FLASH_LOG_BUF_LEN 256 + +#define FD_BUF_LEN 256 +#define FLASH_LOG_DATA_LEN 248 + +#define MONITOR_ADCi_NOTIFY_OK 0x101 +#define MONITOR_ADC_NOTIFY_OK 0x102 +#define MONITOR_SEN_NOTIFY_OK 0x201 + +#define COM_WDG_COM 0x0001 +#define COM_WDG_ADC 0x0002 +#define COM_WDG_CLI 0x0004 +#define COM_WDG_WIR 0x0008 +#define COM_WDG_DAU 0x0010 +#define COM_WDG_GPS 0x0020 + +#define CSG_CIPHERTEXT_LEN 4 +#define CSG_PASSWD_LEN 4 + +#define BIT00 (0x01) +#define BIT01 (0x02) +#define BIT02 (0x04) +#define BIT03 (0x08) +#define BIT04 (0x10) +#define BIT05 (0x20) +#define BIT06 (0x40) +#define BIT07 (0x80) + +#define BIT08 (0x0100) +#define BIT09 (0x0200) +#define BIT10 (0x0400) +#define BIT11 (0x0800) +#define BIT12 (0x1000) +#define BIT13 (0x2000) +#define BIT14 (0x4000) +#define BIT15 (0x8000) + +#define BIT16 (0x00010000) +#define BIT17 (0x00020000) +#define BIT18 (0x00040000) +#define BIT19 (0x00080000) +#define BIT20 (0x00100000) +#define BIT21 (0x00200000) +#define BIT22 (0x00400000) +#define BIT23 (0x00800000) + +#define BIT24 (0x01000000) +#define BIT25 (0x02000000) +#define BIT26 (0x04000000) +#define BIT27 (0x08000000) +#define BIT28 (0x10000000) +#define BIT29 (0x20000000) +#define BIT30 (0x40000000) +#define BIT31 (0x80000000) + +#define DEV_CAPABILITY_LEN 16 +#define DEV_CAPABILITY_BIT_LEN 128 +#define DEV_PASSWORD_LEN 16 +#define DEV_COMPILE_TIME_LEN 32 +#define DEV_VERSION_STR_LEN 32 +#define DEV_NAME_LEN 128 +#define DEV_RESET_INFO_NUM 10 +#define DEV_APN_LEN 16 +#define DEV_APN_LEN_LONG 64 + +#define DEV_CONFIG_SIZE 1024 +#define DEV_RECORD_SIZE 512 + + +/* Exported types ------------------------------------------------------------*/ +/* debug模块号. */ +typedef enum +{ + DBG_M_ADC = 0, + DBG_M_4G, + DBG_M_RS485_SEN, + DBG_M_RS485_DEBUG, + DBG_M_DAU, + DBG_M_DAU_TXRX, + DBG_M_GPS, + DBG_M_COUNT +} DBG_MODULE_E; + +/* debug命令字. */ +typedef enum +{ + DBG_CMD_ON = 0, + DBG_CMD_OFF, + DBG_CMD_OFF_ALL, +} DBG_CMD_E; + +/* 公共监控任务标志. */ +typedef enum +{ + COM_SYS_SAVE_CONFIG = 0, + COM_SYS_SAVE_RECORD, + COM_SYS_SAVE_INFO, + COM_SYS_RESET, + COM_SYS_SHUTDOWN, +} COM_SYS_FLAG_E; + +/* 命令类型. */ +enum DEBUG_CMD_TYPE +{ + DEBUG_CT_REQUEST = 1, + DEBUG_CT_REPLY = 2, + DEBUG_CT_PRV_REQUEST = 121, + DEBUG_CT_PRV_REPLY = 122, +}; + +/* 共有命令字. */ +enum DEBUG_CMD +{ + DEBUG_C_CONTACT = 1, + DEBUG_C_DEV_INFO_SET = 2, + DEBUG_C_RESET = 3, + DEBUG_C_DEFAULT = 4, + DEBUG_C_UPDATE_APP = 5, + DEBUG_C_UPDATE_IAP = 6, + DEBUG_C_DEV_CONFIG = 7, + DEBUG_C_DEV_CONFIG_SET = 8, + DEBUG_C_UPDATE_APP_RT = 9, + DEBUG_C_KEEPALIVE = 10, + DEBUG_C_TIME = 11 +}; + +/* 私有命令字. */ +enum DEBUG_CM_CMD +{ + DEBUG_PRV_REALDATA = 1, + DEBUG_PRV_POWER = 2, + DEBUG_PRV_DEFECT = 3, + DEBUG_PRV_REALDATA_FUALT = 4, + DEBUG_PRV_POWER_FAULT = 5, + DEBUG_PRV_FAULT = 6, + DEBUG_PRV_ADJ_INFO = 7, + DEBUG_PRV_ADJ_INFO_SET = 8, + DEBUG_PRV_ADJ_AUTO = 9, + DEBUG_PRV_DEV_STATE = 10, + DEBUG_PRV_WAVE_COL = 11, + DEBUG_PRV_WAVE_CAL = 12, + DEBUG_PRV_WAVE_MAX = 13, + DEBUG_PRV_LOG = 14, + DEBUG_PRV_HISTORY_DATA = 15, + DEBUG_PRV_ADJ_MANUAL = 16, + DEBUG_PRV_CSG_CONFIG = 17, + DEBUG_PRV_CSG_CONFIG_SET = 18, + DEBUG_PRV_POSITION_WAVE = 19, + DEBUG_PRV_POSITION = 20 +}; + +/* . */ +typedef enum +{ + ADC_ENERGY_AUTO = 0, + ADC_ENERGY_NORMAL, + ADC_ENERGY_SLEEP, + ADC_ENERGY_SLEEP_FORCE, + ADC_ENERGY_CNT +} ADC_ENERGY_E; + +enum WaveStateE +{ + WAVE_STATE_IDLE = 0, + WAVE_STATE_START, + WAVE_STATE_WAIT, + WAVE_STATE_READ, + WAVE_STATE_STOP, + WAVE_STATE_ADC_ERROR, + WAVE_STATE_TIMEOUT, + WAVE_STATE_COMPLETION = 255 +}; +//Q_ENUM(WaveStateE); + +/* 状态机状态. */ +enum WlStateE +{ + WL_STATE_SOFT = 0, + WL_STATE_AT_ATE, + WL_STATE_AT_QICSGP, + WL_STATE_AT_QIACT, + WL_STATE_AT_CSQ, + WL_STATE_AT_QICFGTS, + WL_STATE_AT_QICFGWT, + WL_STATE_AT_QIOPEN, + WL_STATE_WAKEUP = 128, + WL_STATE_REALDATA, + WL_STATE_PWR_FRE, + WL_STATE_UPDATE, + WL_STATE_UPDATE_RT, + WL_STATE_WAVE, + WL_STATE_WAVE_MAX, + WL_STATE_KEEPALIVE, + WL_STATE_END = 255 +}; +//Q_ENUM(WlStateE); + + +typedef struct +{ + uint16_t len; + uint8_t dev_type_m; + uint8_t dev_type_s; + uint32_t dev_id; + uint8_t cmd_type; + uint8_t cmd; + uint16_t pkt_id; + uint8_t reserve[8]; +} proto_head_t; + +typedef struct +{ + uint32_t index; + uint32_t len; +} mul_head_t; + +typedef struct +{ + /* 设备信息. 36byte */ + uint8_t typeM; + uint8_t typeS; + uint8_t mac[6]; + uint32_t id; + uint8_t ip[4]; + uint8_t ipMask[4]; + uint8_t ipGw[4]; + uint8_t serverIp[4]; + uint8_t wirelessServerIp[4]; + uint16_t serverPort; + uint16_t wirelessServerPort; + /* 版本信息. 224byte */ + uint8_t bootVersion[DEV_VERSION_STR_LEN]; + uint8_t bootCompile_time[DEV_COMPILE_TIME_LEN]; + uint8_t imgVersion[DEV_VERSION_STR_LEN]; + uint8_t imgCompile_time[DEV_VERSION_STR_LEN]; + uint8_t hardwareVersion[DEV_VERSION_STR_LEN]; + uint8_t fpgaVersion[DEV_COMPILE_TIME_LEN]; + uint8_t factoryTime[DEV_COMPILE_TIME_LEN]; + /* 设备其他信息. 128byte */ + uint8_t name[DEV_NAME_LEN]; + uint8_t csgId[8]; + uint16_t csgVersion; + uint8_t csgCard[6]; +} devInfo; + +/* RS485 调试通讯协议配置信息. */ +typedef struct +{ + /* 设备配置. 12byte */ + uint16_t flag; + uint8_t energyMode; + uint8_t isVoltageCol; + uint8_t sensor_id[SENSOR_SUM]; + uint16_t collectInterval; + uint16_t waveInterval; + uint16_t collectThreshold; + uint16_t waveThreshold; + uint8_t mainCable; + uint8_t normalSleep; + uint8_t isTempCol; + uint8_t isWaveCol; + uint8_t APN[DEV_APN_LEN]; + //uint8_t APN_long[DEV_APN_LEN_LONG]; +} devConfig; + +/* 南网配置信息. */ +typedef struct +{ + uint8_t passwd[CSG_PASSWD_LEN]; + uint8_t beatInterval; + uint8_t resetTime[3]; + uint16_t collectInterval; + uint16_t sleepTime; + uint16_t onlineTime; + uint8_t reserve[2]; + uint8_t ciphertext[CSG_CIPHERTEXT_LEN]; // 实时数据认证密文. +} csgConfig_t; + +/* 实时数据信息. */ +typedef struct +{ + int16_t temperature; // 设备温度, 单位: 0.1℃. + uint16_t vbat; // 电池电压, 单位: mv. + int16_t CSQ; // 4G 信号质量 > -51dBm 统一显示 -51dBm, < -113 dBm 为无信号. + uint16_t vin; // 工作电压, 单位: mv. + uint32_t elec[CFG_ADC_CH_CNT]; // 通道电流有效值 mA. + uint16_t vsc; // 超级电容电压, 单位: mv. + int16_t sen_temp[SENSOR_SUM]; // 传感器温度: 单位: 0.1℃. + uint16_t senX[SENSOR_SUM]; // 传感器震动 x 轴. + uint16_t senY[SENSOR_SUM]; // 传感器震动 y 轴. + uint16_t senZ[SENSOR_SUM]; // 传感器震动 z 轴. + uint8_t energyMode; // 节能模式. + uint8_t senShort; // 传感器是否短路, 0 – 没有短路, 1 – 短路. + uint8_t senValid[SENSOR_SUM]; // 传感器数据是否有效, 0 - 无效, 1 - 有效. +} realData_t; + +/* 设备状态信息. */ +typedef struct +{ + uint8_t energyMode; // 节能模式. + uint8_t isAdcCollect; // ADC 采集完成. + uint8_t isAdcUp; // ADC 上传完成. + uint8_t AdciCnt; // ADCi 错误计数. + uint8_t AdciState; // ADCi 状态. + uint8_t AdcCnt; // ADC 错误计数. + uint8_t AdcState; // ADC 状态. + uint8_t waveState; // 高频录波状态. + uint32_t waveTime; // 高频录波开始时间. + uint8_t waveStart; // 高频录波完成. + uint8_t waveUpStart; // 高频录波上传完成. + uint16_t waveIdx; // 高频录波续传索引. + uint8_t waveRt; // 高频录波结果. + uint8_t waveForce; // 是否强制录波. + uint8_t wlState; // 4G 状态. + uint8_t wlCnt; // 4G 错误计数. + uint16_t wlWaveIdx; // 4G 上传录波文件索引. + uint8_t isWlUpdate; // 4G 升级. + uint8_t isAdcthr; // 是否超过工频阈值. + uint8_t forceSleepUp; // 强制睡眠报文是否上传. + uint8_t isBatCharge; // 电池充电状态. + uint16_t waveAdj; // 高频校准系数. + int16_t waveMin; // 高频采样最大值. + int16_t waveMax; // 高频采样最小值. + uint32_t sysTime; // 系统运行时间. + uint16_t scMax; // 超级电容最大值. + uint16_t scMin; // 超级电容最小值. + uint32_t scMaxTime; // 超级电容最大值时间. + uint32_t scMinTime; // 超级电容最小值时间. + uint32_t scUpTime; // 超级电容充电时间. + uint32_t scDownTime; // 超级电容放电时间. +} devState; + +/* 校准参数信息. */ +typedef struct +{ + uint16_t ADCRatio[DAU_PORT_POWER_CNT]; // 变比 + uint32_t ADCBase_elec[DAU_PORT_POWER_CNT][DAU_POWER_ADJ_CNT]; // 分段点(1A/2A/5A/10A/30A) + uint16_t ADCAdj[DAU_PORT_POWER_CNT][DAU_POWER_ADJ_CNT]; // 斜率(校准系数) + float ADCBase[DAU_PORT_POWER_CNT][DAU_POWER_ADJ_CNT]; // 采样值(对应分段点的1/2/5/10/30) + uint16_t vin; + uint16_t vin_adj; + uint8_t ADC_turns[DAU_PORT_POWER_CNT]; // 匝数 +} dev_adj_t; + +/* 校准命令信息. */ +typedef struct +{ + uint8_t chSelecet; + uint8_t isVoltageSel; + uint8_t manualIndex; + uint8_t reserve[1]; +} adjSet; + + +/* 高频校准信息. */ +typedef struct +{ + /* 高频校准. 4 */ + uint16_t param; + uint8_t reserve[2]; +} waveParam_t; + +/* Note: 必须保证这个结构体的大小是可以被flash扇区大小整除的,比如128,256... */ +typedef struct +{ + uint64_t id; + uint8_t data[FLASH_LOG_DATA_LEN]; +} falsh_log_t; + +/* Note: 必须保证这个结构体的大小是可以被flash扇区大小整除的,比如128,256... */ +typedef struct +{ + uint64_t id; + uint32_t run_time; // 时间, 单位 s + int16_t temperature; // 设备温度, 单位: 0.1℃ + uint16_t vin; // 工作电压, 单位: mv + uint16_t vbat; // 电池电压, 单位: mv + uint16_t vsc; // 超级电容电压, 单位: mv + uint16_t defect[4]; // 缺陷电流最大值 mA + uint32_t elec[DAU_PORT_POWER_CNT]; // 通道电流有效值 mA + uint8_t col_flag; // DAU 采集标志位 + uint8_t reserve[3]; // Reserve +} fd_data_t; + + +/* Exported macro ------------------------------------------------------------*/ + +/* dev_config flag 类型号. */ +enum DevConfigFlag +{ + DEV_FLAG_CLI = 0, // 是否开启命令行模式. + DEV_FLAG_ADJ, // 是否开启校准模式. + DEV_FLAG_FACTORY // 工厂持续采样模式. +}; + +/* bitmap操作. */ +#define MONITOR_BITMAP_SET(t, b) ((t) |= 1 << (b)) +#define MONITOR_BITMAP_RESET(t, b) ((t) &= ~(1 << (b))) +#define IS_MONITOR_BIT_SET(t, b) ((t) & (1 << b)) + + +//QByteArray data +#define HexPrint(func, packet, len) \ +do{\ + QByteArray data((const char *)packet, len); \ + QString hexString; \ + qDebug() << func << ":\n"; \ + for (int i = 0; i < data.size(); i++) { \ + hexString += QString("%1 ").arg((quint8)data.at(i), 2, 16, QChar('0')); \ + } \ + qDebug() << hexString; \ +}while (0); + + +/* Extern global variables ---------------------------------------------------*/ + +/* Extern functions ----------------------------------------------------------*/ +extern uint32_t crc32_update(uint32_t crc, char* buf, uint32_t len); +extern void crc32_table_init(void); +extern uint32_t crc32(void const *buf, uint32_t byte_count); +extern uint32_t crc32_update(uint32_t crc, char* buf, uint32_t len); +extern uint16_t crc16(uint8_t *data, uint16_t size); +int32_t stringToChar(QString str, char *buf, uint32_t len); +void printHexArray(const char *msg, const char *array, int length); +#endif +/******************* (C) COPYRIGHT LandPower ***** END OF FILE ****************/ diff --git a/form.ui b/form.ui new file mode 100644 index 0000000..a39ec6b --- /dev/null +++ b/form.ui @@ -0,0 +1,8962 @@ + + + form + + + + 0 + 0 + 1430 + 705 + + + + + 1430 + 700 + + + + CableTool + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + 100 + 0 + + + + + 200 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 11 + + + + 110 + + + + + 300 + + + + + 600 + + + + + 1200 + + + + + 2400 + + + + + 4800 + + + + + 9600 + + + + + 14400 + + + + + 19200 + + + + + 38400 + + + + + 57600 + + + + + 115200 + + + + + 230400 + + + + + 380400 + + + + + 460800 + + + + + 921600 + + + + + + + + + 0 + 0 + + + + + 微软雅黑 Light + 12 + + + + 刷新 + + + + + + + + 0 + 0 + + + + + 微软雅黑 Light + 12 + + + + 连接 + + + + + + + Qt::Vertical + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + false + + + + 100 + 0 + + + + + 100 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + + APP + + + + + IAP + + + + + + + + + 300 + 0 + + + + + 微软雅黑 Light + 12 + + + + + + + + false + + + + 0 + 0 + + + + + 微软雅黑 Light + 12 + + + + 文件 + + + + + + + false + + + + 0 + 0 + + + + + 微软雅黑 Light + 12 + + + + 升级 + + + + + + + + 130 + 27 + + + + + 16777215 + 27 + + + + + 微软雅黑 Light + 12 + + + + 0 / 0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Vertical + + + + + + + false + + + + 0 + 0 + + + + + 微软雅黑 Light + 12 + + + + 默认配置 + + + + + + + false + + + + 0 + 0 + + + + + 微软雅黑 Light + 12 + + + + 重启 + + + + + + + + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + + 微软雅黑 Light + 12 + + + + 5 + + + + 信息 + + + + + + + + + 16777215 + 16777215 + + + + + CT 供电 + + + + + 电池供电 + + + + + AC/DC 供电 + + + + + 未使用 + + + + + 电容供电 + + + + + CT 供电 + 定位 + + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + APP版本: + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 设备id: + + + + + + + + 微软雅黑 Light + 12 + + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 设备型号: + + + + + + + + 200 + 0 + + + + + 16777215 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + QFrame::Plain + + + + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 设备名称: + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 出厂日期: + + + + + + + + 200 + 0 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + QFrame::Plain + + + + + + + + + + + 微软雅黑 Light + 12 + + + + false + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + QFrame::Plain + + + + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 供电方式: + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 硬件版本: + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 编译时间: + + + + + + + + 200 + 0 + + + + + 16777215 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + QFrame::Plain + + + + + + + + + + + 200 + 0 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + QFrame::Plain + + + + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + IAP版本: + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + FPGA版本: + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 编译时间: + + + + + + + + 微软雅黑 Light + 12 + + + + + + + + + 微软雅黑 Light + 12 + + + + + + + + + 200 + 0 + + + + + 16777215 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + false + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + QFrame::Plain + + + + + + + + + + + 微软雅黑 Light + 12 + + + + + + + + + 16777215 + 16777215 + + + + + 朗德协议 + + + + + 南网协议 + + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 通讯协议: + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 南网id: + + + + + + + + 微软雅黑 Light + 12 + + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 南网协议版本: + + + + + + + + 微软雅黑 Light + 12 + + + + + + + + + + Qt::Horizontal + + + + + + + + + + 微软雅黑 Light + 12 + + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 服务器IP: + + + + + + + + 微软雅黑 Light + 12 + + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 无线服务器IP: + + + + + + + + 微软雅黑 Light + 12 + + + + + + + + + 微软雅黑 Light + 12 + + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 子网掩码: + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 端口号: + + + + + + + + 微软雅黑 Light + 12 + + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 端口号: + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + MAC地址: + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + IP地址: + + + + + + + + 微软雅黑 Light + 12 + + + + + + + + + 微软雅黑 Light + 12 + + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 网关: + + + + + + + + 微软雅黑 Light + 12 + + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 南网主站卡号: + + + + + + + + 微软雅黑 Light + 12 + + + + + + + + + + Qt::Horizontal + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + false + + + + 0 + 0 + + + + + 微软雅黑 Light + 12 + + + + 配置 + + + + + + + + + Qt::Vertical + + + + 20 + 93 + + + + + + + + + 配置 + + + + + + + + 通用配置 + + + + + + + 130 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 电源模式: + + + + + + + + 130 + 0 + + + + + 130 + 16777215 + + + + + 智能模式 + + + + + 正常模式 + + + + + 节能模式 + + + + + + + + + 130 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + Debug 方式: + + + + + + + + 130 + 0 + + + + + 130 + 16777215 + + + + + CLI + + + + + 可视化工具 + + + + + + + + + 130 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 工作模式: + + + + + + + + 130 + 0 + + + + + 130 + 16777215 + + + + + 正常模式 + + + + + 校准模式 + + + + + 工厂模式 + + + + + + + + + 130 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 正常状态休眠: + + + + + + + + 130 + 0 + + + + + 130 + 16777215 + + + + + + + + + + + + + + + + + + + 130 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + APN: + + + + + + + + 130 + 0 + + + + + 130 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + + + + + + + + 设备配置 + + + + + + + 170 + 27 + + + + + 170 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 上传间隔(m): + + + + + + + + 20 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + + + + + + 170 + 27 + + + + + 170 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 工频录波阈值(A): + + + + + + + + 20 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + + + + + + 170 + 27 + + + + + 170 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 高频录波间隔(h): + + + + + + + + 20 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + + + + + + 170 + 27 + + + + + 170 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 高频录波阈值(mv): + + + + + + + + 20 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + + + + + + 170 + 27 + + + + + 170 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 主缆 ID: + + + + + + + + 20 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + + + + + 开启电流采集 + + + + + + + 开启温度震动 + + + + + + + 开启高频录波 + + + + + + + + + + + + 温度/震动传感器ID设置 + + + + + + + 90 + 27 + + + + + 90 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 接头温度: + + + + + + + + 90 + 27 + + + + + 90 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + B相 + + + + + + + + 90 + 27 + + + + + 90 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 表面温度: + + + + + + + + 90 + 27 + + + + + 90 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 环境温度: + + + + + + + + 20 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + + + + + + 20 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 20 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + + + + + + 90 + 27 + + + + + 90 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + A相 + + + + + + + + 90 + 27 + + + + + 90 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + C相 + + + + + + + + 20 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + + + + + + 20 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + + + + + + 20 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + + + + + + 20 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + + + + + + + + + + + + Qt::Horizontal + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + false + + + + 0 + 0 + + + + + 微软雅黑 Light + 12 + + + + 刷新 + + + + + + + false + + + + 0 + 0 + + + + + 微软雅黑 Light + 12 + + + + 配置 + + + + + + + + + Qt::Vertical + + + + 20 + 191 + + + + + + + + + 南网配置 + + + + + + + + + 130 + 27 + + + + + 130 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 密码: + + + + + + + + 20 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + + + + + + 130 + 27 + + + + + 130 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 心跳间隔(m): + + + + + + + + 20 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + + + + + + 20 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + + + + + + 130 + 27 + + + + + 130 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 采集间隔(m): + + + + + + + + 20 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + + + + + + 130 + 27 + + + + + 130 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 休眠时间(m): + + + + + + + + 130 + 27 + + + + + 130 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 认证密文: + + + + + + + + 130 + 27 + + + + + 130 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 重启时间: + + + + + + + + 20 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + + + + + + 20 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + + + + + + 20 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + + + + + + 130 + 27 + + + + + 130 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 在线时长(m): + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Horizontal + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + false + + + + 0 + 0 + + + + + 微软雅黑 Light + 12 + + + + 刷新 + + + + + + + false + + + + 0 + 0 + + + + + 微软雅黑 Light + 12 + + + + 配置 + + + + + + + + + Qt::Vertical + + + + 20 + 168 + + + + + + + + + true + + + 实时数据 + + + + + + + + 设备实时数据 + + + + + + + 135 + 0 + + + + + 135 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 设备温度(℃): + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 135 + 0 + + + + + 135 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 输入电压(V): + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 135 + 0 + + + + + 135 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 电容电压(V): + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 135 + 0 + + + + + 135 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 电池电压(V): + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 170 + 0 + + + + + 170 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 4G信号强度(dBm): + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 135 + 0 + + + + + 135 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 传感器短路: + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + 电流实时数据(A) + + + + + + + 120 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 总接地(CH4): + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 运行(CH5): + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 预留(CH6): + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 170 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + A相接地电流(CH1): + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 170 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + B相接地电流(CH2): + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 170 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + C相接地电流(CH3): + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + 温度震动实时数据 + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + C相 + + + + + + + + 125 + 0 + + + + + 115 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + Z轴姿态(mg): + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + B相 + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 125 + 0 + + + + + 115 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + Y轴姿态(mg): + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 125 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 环境温度(℃): + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + A相 + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 125 + 0 + + + + + 115 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 表面温度(℃): + + + + + + + + 125 + 0 + + + + + 115 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 接头温度(℃): + + + + + + + + 125 + 0 + + + + + 115 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + X轴姿态(mg): + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + + + + + Qt::Horizontal + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 查看高频波形 + + + + + + + false + + + + 0 + 0 + + + + + 微软雅黑 Light + 12 + + + + 下载高频数据 + + + + + + + + 120 + 13 + + + + + 120 + 27 + + + + + 微软雅黑 Light + 12 + + + + 0 / 8000 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + false + + + + 0 + 0 + + + + + 微软雅黑 Light + 12 + + + + 手动刷新 + + + + + + + Qt::Vertical + + + + + + + false + + + + 0 + 0 + + + + + 微软雅黑 Light + 12 + + + + 自动刷新 + + + + + + + + + Qt::Vertical + + + + 20 + 183 + + + + + + + + + 状态 + + + + + + + + ADC + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 节能模式: + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 充电状态: + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 睡眠上传: + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 采集完成: + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 上传完成: + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 超过阈值: + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + ADCi CNT: + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + ADCi STATE: + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + ADC CNT: + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + ADC STATE: + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + + + 录波 + + + + + + + 110 + 27 + + + + + 110 + 27 + + + + + 微软雅黑 Light + 12 + + + + 强制录波: + + + + + + + + 180 + 27 + + + + + 150 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 27 + + + + + 110 + 27 + + + + + 微软雅黑 Light + 12 + + + + 录波时间: + + + + + + + + 180 + 27 + + + + + 150 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 27 + + + + + 110 + 27 + + + + + 微软雅黑 Light + 12 + + + + 录波完成: + + + + + + + + 180 + 27 + + + + + 150 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 27 + + + + + 110 + 27 + + + + + 微软雅黑 Light + 12 + + + + 上传完成: + + + + + + + + 180 + 27 + + + + + 150 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 27 + + + + + 110 + 27 + + + + + 微软雅黑 Light + 12 + + + + 续传索引: + + + + + + + + 180 + 27 + + + + + 150 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 27 + + + + + 110 + 27 + + + + + 微软雅黑 Light + 12 + + + + 状态: + + + + + + + + 180 + 27 + + + + + 150 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 27 + + + + + 110 + 27 + + + + + 微软雅黑 Light + 12 + + + + 结果: + + + + + + + + 180 + 27 + + + + + 150 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + + + 4G + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 状态: + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + CNT: + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 录波索引: + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 是否升级: + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + + + + + 超级电容滞回周期: + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 最高电压(V): + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 最低电压(V): + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 放电时间: + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 充电时间: + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + + + 其他 + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 运行时间: + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + + + + + Qt::Vertical + + + + + + + + + Qt::Horizontal + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + false + + + + 0 + 0 + + + + + 微软雅黑 Light + 12 + + + + 刷新 + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 工频数据 + + + + + + + 0 + 0 + + + + + 0 + 800 + + + + + 0 + 800 + + + + + 微软雅黑 Light + 9 + + + + 50 + + + + P01 + + + + + P02 + + + + + P03 + + + + + P04 + + + + + P05 + + + + + P06 + + + + + P07 + + + + + P08 + + + + + P09 + + + + + P10 + + + + + P11 + + + + + P12 + + + + + P13 + + + + + P14 + + + + + P15 + + + + + P16 + + + + + P17 + + + + + P18 + + + + + P19 + + + + + P20 + + + + + P21 + + + + + P22 + + + + + P23 + + + + + P24 + + + + + P25 + + + + + P26 + + + + + P27 + + + + + P28 + + + + + P29 + + + + + P30 + + + + + P31 + + + + + P32 + + + + + P33 + + + + + P34 + + + + + P35 + + + + + P36 + + + + + P37 + + + + + P38 + + + + + P39 + + + + + P40 + + + + + P41 + + + + + P42 + + + + + P43 + + + + + P44 + + + + + P45 + + + + + P46 + + + + + P47 + + + + + P48 + + + + + P49 + + + + + P50 + + + + + 1 + + + AlignLeading|AlignVCenter + + + + + 2 + + + AlignLeading|AlignVCenter + + + + + 3 + + + AlignLeading|AlignVCenter + + + + + 4 + + + AlignLeading|AlignVCenter + + + + + 5 + + + AlignLeading|AlignVCenter + + + + + 6 + + + AlignLeading|AlignVCenter + + + + + 7 + + + AlignLeading|AlignVCenter + + + + + 8 + + + AlignLeading|AlignVCenter + + + + + 9 + + + AlignLeading|AlignVCenter + + + + + 10 + + + AlignLeading|AlignVCenter + + + + + 11 + + + AlignLeading|AlignVCenter + + + + + 12 + + + AlignLeading|AlignVCenter + + + + + 13 + + + AlignLeading|AlignVCenter + + + + + 14 + + + AlignLeading|AlignVCenter + + + + + 15 + + + AlignLeading|AlignVCenter + + + + + 16 + + + AlignLeading|AlignVCenter + + + + + 17 + + + AlignLeading|AlignVCenter + + + + + 18 + + + AlignLeading|AlignVCenter + + + + + 19 + + + AlignLeading|AlignVCenter + + + + + 20 + + + AlignLeading|AlignVCenter + + + + + 21 + + + + + 22 + + + + + 23 + + + + + 24 + + + + + 25 + + + + + 26 + + + + + 27 + + + + + 28 + + + + + 29 + + + + + 30 + + + + + 31 + + + + + 32 + + + + + 33 + + + + + 34 + + + + + 35 + + + + + 36 + + + + + 37 + + + + + 38 + + + + + 39 + + + + + 40 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 40 + 0 + + + + + 50 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 通道: + + + + + + + false + + + + 10 + 0 + + + + + 40 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + + 1 + + + + + 2 + + + + + 3 + + + + + 4 + + + + + 5 + + + + + 6 + + + + + 7 + + + + + 8 + + + + + + + + false + + + + 0 + 0 + + + + + 微软雅黑 Light + 12 + + + + 刷新 + + + + + + + + 65 + 27 + + + + + 65 + 27 + + + + + 微软雅黑 Light + 12 + + + + 0 / 10 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + 校准参数 + + + + + + + 0 + 280 + + + + + 微软雅黑 Light + 9 + + + + 8 + + + 19 + + + false + + + false + + + 75 + + + true + + + 50 + + + true + + + false + + + false + + + 28 + + + + + + + AlignCenter + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 通道 + + + + 微软雅黑 Light + + + + AlignLeading|AlignVCenter + + + + + 变比 + + + + 微软雅黑 Light + + + + AlignLeading|AlignVCenter + + + + + 匝数 + + + + 微软雅黑 Light + + + + AlignLeading|AlignVCenter + + + + + 校准点1 + + + + 微软雅黑 Light + + + + AlignLeading|AlignVCenter + + + + + 采样值1 + + + + 微软雅黑 Light + + + + AlignLeading|AlignVCenter + + + + + 斜率1 + + + + 微软雅黑 Light + + + + AlignLeading|AlignVCenter + + + + + 校准点2 + + + + 微软雅黑 Light + + + + AlignLeading|AlignVCenter + + + + + 采样值2 + + + + 微软雅黑 Light + + + + AlignLeading|AlignVCenter + + + + + 斜率2 + + + + 微软雅黑 Light + + + + AlignLeading|AlignVCenter + + + + + 校准点3 + + + + 微软雅黑 Light + + + + AlignLeading|AlignVCenter + + + + + 采样值3 + + + + 微软雅黑 Light + + + + AlignLeading|AlignVCenter + + + + + 斜率3 + + + + 微软雅黑 Light + + + + AlignLeading|AlignVCenter + + + + + 校准点4 + + + + 微软雅黑 Light + + + + AlignLeading|AlignVCenter + + + + + 采样值4 + + + + 微软雅黑 Light + + + + AlignLeading|AlignVCenter + + + + + 斜率4 + + + + 微软雅黑 Light + + + + AlignLeading|AlignVCenter + + + + + 校准点5 + + + + 微软雅黑 Light + + + + AlignLeading|AlignVCenter + + + + + 采样值5 + + + + 微软雅黑 Light + + + + AlignLeading|AlignVCenter + + + + + 斜率5 + + + + 微软雅黑 Light + + + + AlignLeading|AlignVCenter + + + + + + + + + 微软雅黑 Light + + + + AlignCenter + + + + + 1 + + + + 微软雅黑 Light + 50 + false + + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 2 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 3 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 4 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 5 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 6 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 7 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 8 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 0 + + + + + + + + + + false + + + + 0 + 0 + + + + + 微软雅黑 Light + 12 + + + + 手动下发 + + + + + + + + 80 + 0 + + + + + 130 + 16777215 + + + + + 分段点1 + + + + + 分段点2 + + + + + 分段点3 + + + + + 分段点4 + + + + + 分段点5 + + + + + + + + + 130 + 27 + + + + + 16777215 + 27 + + + + + 微软雅黑 Light + 12 + 50 + false + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + false + + + + 0 + 0 + + + + + 微软雅黑 Light + 12 + + + + 手动校准段1 + + + + + + + Qt::Vertical + + + + + + + false + + + + 0 + 0 + + + + + 微软雅黑 Light + 12 + + + + 参数导出 + + + + + + + false + + + + 0 + 0 + + + + + 微软雅黑 Light + 12 + + + + 参数导入 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Vertical + + + + + + + + + + true + + + + + + + + 80 + 27 + + + + + 16777215 + 27 + + + + 输入电压(mV): + + + + + + + + 80 + 16777215 + + + + 4000 + + + + + + + + 80 + 27 + + + + + 16777215 + 27 + + + + 电压系数: + + + + + + + + 80 + 16777215 + + + + 4000 + + + + + + + false + + + + 0 + 0 + + + + + 微软雅黑 Light + 12 + + + + 自动下发 + + + + + + + false + + + + 0 + 0 + + + + + 微软雅黑 Light + 12 + + + + 自动校准 + + + + + + + + + Qt::Vertical + + + + 20 + 193 + + + + + + + + + 高频系数 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 110 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 高频系数: + + + + + + + + 110 + 27 + + + + + 110 + 27 + + + + + 微软雅黑 Light + 12 + + + + 录波完成: + + + + + + + + 110 + 27 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + QLabel{background:#f0f0f0;} + + + QFrame::Box + + + + + + + + + + + 110 + 27 + + + + + 110 + 27 + + + + + 微软雅黑 Light + 12 + + + + 最大值: + + + + + + + + 20 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + + + + + + 110 + 27 + + + + + 110 + 27 + + + + + 微软雅黑 Light + 12 + + + + 最小值: + + + + + + + + 20 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + + + + + + 20 + 0 + + + + + 110 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + + + + + + + Qt::Horizontal + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + false + + + + 0 + 0 + + + + + 微软雅黑 Light + 12 + + + + 高频录波 + + + + + + + false + + + + 0 + 0 + + + + + 微软雅黑 Light + 12 + + + + 刷新 + + + + + + + false + + + + 0 + 0 + + + + + 微软雅黑 Light + 12 + + + + 计算 + + + + + + + + + Qt::Vertical + + + + 20 + 270 + + + + + + + + + LOG + + + + + + true + + + + + + + Qt::Horizontal + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 70 + 27 + + + + + 70 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 数量(条): + + + + + + + + 70 + 0 + + + + + 70 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + + + + + false + + + + 0 + 0 + + + + + 微软雅黑 Light + 12 + + + + 下载 Log + + + + + + + + 90 + 13 + + + + + 90 + 27 + + + + + 微软雅黑 Light + 12 + + + + 0 / 0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + 历史数据 + + + + + + + 0 + 400 + + + + + 0 + 800 + + + + + 0 + 800 + + + + + 微软雅黑 Light + 9 + + + + 0 + + + + ID + + + AlignLeading|AlignVCenter + + + + + 时间 + + + AlignLeading|AlignVCenter + + + + + 设备温度 + + + AlignLeading|AlignVCenter + + + + + 输入电压 + + + AlignLeading|AlignVCenter + + + + + 电池电压 + + + AlignLeading|AlignVCenter + + + + + 电容电压 + + + AlignLeading|AlignVCenter + + + + + A相接地电流(CH1) + + + AlignLeading|AlignVCenter + + + + + B相接地电流(CH2) + + + AlignLeading|AlignVCenter + + + + + C相接地电流(CH3) + + + AlignLeading|AlignVCenter + + + + + 总接地(CH4) + + + AlignLeading|AlignVCenter + + + + + 运行(CH5) + + + AlignLeading|AlignVCenter + + + + + 预留(CH6) + + + AlignLeading|AlignVCenter + + + + + + + + Qt::Horizontal + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 70 + 27 + + + + + 70 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + 数量(条): + + + + + + + + 70 + 0 + + + + + 70 + 16777215 + + + + + 微软雅黑 Light + 12 + + + + + + + + false + + + + 0 + 0 + + + + + 微软雅黑 Light + 12 + + + + 下载数据 + + + + + + + + 90 + 13 + + + + + 90 + 27 + + + + + 微软雅黑 Light + 12 + + + + 0 / 0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + diff --git a/images/AppIcon.ico b/images/AppIcon.ico new file mode 100644 index 0000000000000000000000000000000000000000..553ae3be5d0dade8adf8a14430d538d1fb7ac6f2 GIT binary patch literal 10776 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 + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + Widget w; + w.show(); + + return a.exec(); +} diff --git a/widget.cpp b/widget.cpp new file mode 100644 index 0000000..853068a --- /dev/null +++ b/widget.cpp @@ -0,0 +1,2373 @@ +#include "widget.h" +#include "ui_form.h" +#include "common.h" +#include +#include +#include +#include +#include +#include + +QWidget *ReadOnlyDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + Q_UNUSED(parent) + Q_UNUSED(option) + Q_UNUSED(index) + return nullptr; +} + + +Widget::Widget(QWidget *parent) + : QWidget(parent),ui(new Ui::form) +{ + ui->setupUi(this); + + on_btnRefresh_clicked(); + + memset(rxbuf, 0, sizeof(rxbuf)); + rxbufLen = 0; + + memset(&clientDevInfo, 0, sizeof(clientDevInfo)); + + memset(&csgConfig, 0, sizeof(csgConfig_t)); + + memset(&clientRealData, 0, sizeof(realData_t)); + + memset(powerFre, 0, sizeof(powerFre)); + + memset(&clientDevState, 0, sizeof(devState)); + + memset(&clientAdjInfo, 0, sizeof(dev_adj_t)); + + memset(&clientAdjSet, 0, sizeof(adjSet)); + + isConnected = 0; + upFileRecvSize = 0; + upFileSize = 0; + isDataRefresh = false; + waveParam = 0; + is_log_up = 0; + logIndex = 0; + waveIndex = 0; + is_wave_up = 0; + dataIndex = 0; + is_data_up = false; + historyDataSum = 0; + logSum = 0; + + energyMode[0] = "未知"; + energyMode[1] = "正常模式"; + energyMode[2] = "节能模式"; + energyMode[3] = "休眠模式"; + + crc32_table_init(); + + /* 配置校准页面表格 */ + ui->adjustTable->horizontalHeader()->setVisible(true); + ui->adjustTable->horizontalHeader()->resizeSection(0,20); + ui->adjustTable->horizontalHeader()->resizeSection(1,50); + + //如下代码设置横向表格头的间隔线,有四个方向的间隔线,不需要间隔线的可以设置为0px + ui->adjustTable->horizontalHeader()->setStyleSheet( + "QHeaderView::section{" + "border-top:0px solid #E5E5E5;" + "border-left:0px solid #E5E5E5;" + "border-right:0.5px solid #E5E5E5;" + "border-bottom: 0.5px solid #E5E5E5;" + "background-color:white;" + "padding:4px;" + "}" + ); + /* 只可以配置变比. */ + readOnlyDelegate = new ReadOnlyDelegate(this); + for(int i = 0; i < ui->adjustTable->columnCount(); i++) + { + if (0 == i || 2 == i || 3 == i || 4 == i || 7 == i || 10 == i || 13 == i || 16 == i) + { + continue; + } + ui->adjustTable->setItemDelegateForColumn(i, readOnlyDelegate); + } + + for(int i = 0; i < ui->adjustTable->rowCount(); i++) + { + QCheckBox *checkBox = new QCheckBox(); + ui->adjustTable->setCellWidget(i, 0, checkBox); + } + + + /* 配置历史数据页面表格 */ + //如下代码设置横向表格头的间隔线,有四个方向的间隔线,不需要间隔线的可以设置为0px + ui->historyDataTable->horizontalHeader()->setStyleSheet( + "QHeaderView::section{" + "border-top:0px solid #E5E5E5;" + "border-left:0px solid #E5E5E5;" + "border-right:0.5px solid #E5E5E5;" + "border-bottom: 0.5px solid #E5E5E5;" + "background-color:red;" + "padding:4px;" + "}" + ); + + for(int i = 0; i < ui->historyDataTable->columnCount(); i++) + { + ui->historyDataTable->setItemDelegateForColumn(i, readOnlyDelegate); + } + ui->historyDataTable->horizontalHeader()->resizeSection(0, 50); + ui->historyDataTable->horizontalHeader()->resizeSection(1, 130); + ui->historyDataTable->horizontalHeader()->resizeSection(2, 60); + ui->historyDataTable->horizontalHeader()->resizeSection(3, 60); + ui->historyDataTable->horizontalHeader()->resizeSection(4, 60); + ui->historyDataTable->horizontalHeader()->resizeSection(5, 60); + ui->historyDataTable->horizontalHeader()->resizeSection(6, 110); + ui->historyDataTable->horizontalHeader()->resizeSection(7, 110); + ui->historyDataTable->horizontalHeader()->resizeSection(8, 110); + ui->historyDataTable->horizontalHeader()->resizeSection(9, 110); + ui->historyDataTable->horizontalHeader()->resizeSection(10, 110); + ui->historyDataTable->horizontalHeader()->resizeSection(11, 110); + + /* 打开配置文件, 恢复关闭前的状态. */ + QString file = QCoreApplication::applicationDirPath()+"/CableTool.ini"; + settings = new QSettings(file, QSettings::IniFormat, this); +#if 0 + for(int i = 0; i < ui->comboPort->count(); i++) + { + if (!QString::compare(ui->comboPort->itemText(i), settings->value("usartBoxName", "COM1").toString(), Qt::CaseSensitive)) + { + ui->comboPort->setCurrentIndex(i); + } + } +#endif + ui->comboBaud->setCurrentIndex(settings->value("baudBoxIndex", 6).toInt()); + filePath = settings->value("updateFile", "").toString(); + adjFilePath = settings->value("adjFile", "").toString(); + waveFilePath = settings->value("waveFile", "").toString(); + QFileInfo fileinfo = QFileInfo(filePath); + ui->fileNameEdit->setText(fileinfo.fileName()); + ui->fileNameEdit->setReadOnly(true); + ui->fileTypeBox->setCurrentIndex(settings->value("updateFileType", 0).toInt()); + ui->freChBox->setCurrentIndex(settings->value("freChIndex", 0).toInt()); + +} + +Widget::~Widget() +{ + for(int i = 0; i < ui->frequencyTable->columnCount(); i++) + { + for(int j = 0; j < ui->frequencyTable->rowCount(); j++) + { + delete ui->frequencyTable->item(j, i); + } + } + + for(int i = 0; i < ui->adjustTable->rowCount(); i++) + { + delete ui->adjustTable->cellWidget(i, 0); + } + //delete usartProtocol; + deinitSerial(); + delete settings; + + delete ui; +} + +QString Widget::toHexadecimal(const QByteArray &byteArray) +{ + QString str; + for(int i = 0; i< byteArray.length(); i++) + { + QString byteStr = QString::number(static_cast(byteArray[i]), 16); + if(byteStr.length() == 1) str += "0" + byteStr; + else str += byteStr; + } + return str; +} + +int Widget::searchUsablePort() +{ + foreach(const QSerialPortInfo &info, QSerialPortInfo::availablePorts()) + { + QSerialPort serial; + serial.setPort(info); + if(serial.open(QIODevice::ReadWrite)) + { + ui->comboPort->addItem(serial.portName()); + QString portName = serial.portName(); + qDebug() << "usable port" << portName; + serial.close(); + return 1; + } + } + qDebug() << "无法打开串口"; + return 0; +} + +/* 串口错误处理槽. */ +void Widget::serialErrHandle(QSerialPort::SerialPortError error) +{ + if (error == QSerialPort::ResourceError) + { + QMessageBox::critical(this, tr("Critical Error"), serialPort->errorString()); + //workStop(CM_usart::RV_USART); + } +} + +void Widget::serialDisconnect() +{ + deinitSerial(); + isConnected = 0; + ui->btnConn->setText("连接"); + buttonEnable(FALSE); +} + + +int Widget::initSerial() +{ + serialPort = new QSerialPort; + serialPort->setPortName(ui->comboPort->currentText()); + serialPort->setBaudRate(ui->comboBaud->currentText().toInt()); + serialPort->setDataBits(QSerialPort::Data8); + serialPort->setParity(QSerialPort::NoParity); + serialPort->setStopBits(QSerialPort::OneStop); + serialPort->setFlowControl(QSerialPort::NoFlowControl); + if (serialPort->open(QIODevice::ReadWrite)) + { // open success + connect(serialPort, &QSerialPort::errorOccurred, this, &Widget::serialErrHandle); + connect(serialPort, &QSerialPort::readyRead, this, &Widget::readData); + } + else + { // open failed + QMessageBox::critical(this, tr("Error"), serialPort->errorString()); + } + //serialPort->setBaudRate(ui->comboBaud->currentText().toInt()); + qDebug() << "baudrate:" << serialPort->baudRate(); + + //newTask = new QThread; + //usartProtocol = new Protocol; + //usartProtocol->moveToThread(newTask); + //newTask->Start(); + + //connect(worker, &WorkerThread::finished, this, &MainWindow::updateGUI); + //connect(this, &Widget::workStart, task, &CM_usart::run); + + + return 0; +} + +int Widget::deinitSerial() +{ + if (serialPort->isOpen()) + { + //disconnect(&serialPort, &QSerialPort::readyRead, this, &Widget::readData); + serialPort->waitForReadyRead(500); // Wait 0.5 second to read all the data. + serialPort->close(); + delete serialPort; + } + return 0; +} + + +int Widget::readData() +{ + QByteArray qarry; + qarry = serialPort->readAll(); + + if (!qarry.isEmpty()) + { + char *buf = qarry.data(); + int len = qarry.size(); + + qDebug() << __FUNCTION__ << "LEN=" << len << "rxbufLen:" << rxbufLen << endl; + HexPrint(__FUNCTION__, buf, len); + + if (len < 0 || len > USART_BUF_SIZE) + { + rxbufLen = 0; + qDebug() << __FUNCTION__ << ":" << __LINE__ << "data is error.\n"; + return -1; + } + + if (len + rxbufLen > USART_BUF_SIZE) + { + rxbufLen = 0; + qDebug() << __FUNCTION__ << ":" << __LINE__ << "data is error.\n"; + return -1; + } + + memcpy(rxbuf + rxbufLen, buf, len); + rxbufLen += len; + + if (rxbufLen < sizeof(proto_head_t)) + { + qDebug() << __FUNCTION__ << ":" << __LINE__ << "data is error.\n"; + return -1; + } + + proto_head_t *header = reinterpret_cast(rxbuf); + //qDebug() << "header->len:" << header->len << " " << "rxbufLen:" << rxbufLen << endl; + if (rxbufLen != header->len + 4) + { + qDebug() << __FUNCTION__ << ":" << __LINE__ << "data is error.\n"; + return -1; + } + + /* CRC32 校验. */ + if (crc32(rxbuf, header->len) != (*reinterpret_cast(rxbuf + header->len))) + { + qDebug() << "Bad data,throw it away.\n"; + rxbufLen = 0; + return -1; + } + rxbufLen = 0; + + //printHexArray(__FUNCTION__, buf, len); + //HexPrint(__FUNCTION__, rxbuf, (header->len + 4)); + paraseProtocols(rxbuf); + + //qDebug() << "end rxbufLen = " << rxbufLen << endl; + + } + qarry.clear(); + return 0; +} + +int Widget::writeData(char *buf, int len) +{ + serialPort->write(buf, len); + serialPort->flush(); + return 0; +} + +int Widget::protoHeaderInit(proto_head_t * header, uint16_t len, uint32_t id, uint8_t cmd_type, uint8_t cmd) +{ + header->len = len; + header->dev_type_m = clientDevInfo.typeM; + header->dev_type_s = clientDevInfo.typeS; + header->dev_id = id; + header->cmd_type = cmd_type; + header->cmd = cmd; + header->pkt_id++; + if (0 == header->pkt_id) + { + header->pkt_id = 0x8000; + } + return 0; +} + +/* 按钮使能操作. */ +void Widget::buttonEnable(bool flag) +{ + ui->configButton->setEnabled(flag); + ui->waveButton->setEnabled(flag); + ui->dataRefreshButton->setEnabled(flag); + ui->freChBox->setEnabled(flag); + ui->freRefreshButton->setEnabled(flag); + ui->updateButton->setEnabled(flag); + ui->defaultButton->setEnabled(flag); + ui->btnReset->setEnabled(flag); + ui->fileTypeBox->setEnabled(flag); + ui->fileButton->setEnabled(flag); + ui->adjButton->setEnabled(flag); + ui->configSetButton->setEnabled(flag); + ui->stateRefreshButton->setEnabled(flag); + ui->waveCalButton->setEnabled(flag); + ui->waveColButton->setEnabled(flag); + ui->waveRefreshButton->setEnabled(flag); + ui->ratioSetButton->setEnabled(flag); + ui->configGetButton->setEnabled(flag); + ui->dataRefreshAutoButton->setEnabled(flag); + ui->stateLogButton->setEnabled(flag); + ui->historyDataButton->setEnabled(flag); + ui->logTextEdit->setEnabled(flag); + ui->manualRatioSetButton->setEnabled(flag); + ui->manualAdjButton->setEnabled(flag); + ui->csgConfigGetButton->setEnabled(flag); + ui->csgConfigSetButton->setEnabled(flag); + ui->RatioParamSetButton->setEnabled(flag); + ui->RatioParamGetButton->setEnabled(flag); +} + +QString Widget::devStateWaveStateGet(uint8_t state) +{ + switch(state) + { + case WAVE_STATE_IDLE: + return "空闲"; + case WAVE_STATE_START: + return "准备"; + case WAVE_STATE_WAIT: + return "等待"; + case WAVE_STATE_READ: + return "读取"; + case WAVE_STATE_STOP: + return "结束"; + case WAVE_STATE_ADC_ERROR: + case WAVE_STATE_TIMEOUT: + return "错误"; + case WAVE_STATE_COMPLETION: + return "完成"; + default: + return "未知"; + } +} + + +QString Widget::devStateWlStateGet(uint8_t state) +{ + switch(state) + { + case WL_STATE_SOFT: + case WL_STATE_AT_ATE: + case WL_STATE_AT_QICSGP: + case WL_STATE_AT_QIACT: + case WL_STATE_AT_CSQ: + case WL_STATE_AT_QIOPEN: + return "AT"; + case WL_STATE_WAKEUP: + return "联络"; + case WL_STATE_REALDATA: + return "数据"; + case WL_STATE_PWR_FRE: + return "工频"; + case WL_STATE_WAVE: + return "高频"; + case WL_STATE_UPDATE: + return "升级"; + case WL_STATE_UPDATE_RT: + return "升级回复"; + case WL_STATE_END: + return "完成"; + default: + return "未知"; + } +} + +void Widget::uiDevInfoRefresh() +{ + ui->devTypeNameLabel->setText("LowPowerCable"); + ui->devNameEdit->setText(QString(reinterpret_cast(clientDevInfo.name))); + if (clientDevInfo.typeS != 4) + { + ui->devTypeBox->setCurrentIndex(clientDevInfo.typeS - 1); + ui->communicationTypeBox->setCurrentIndex(0); + } + else + { + ui->devTypeBox->setCurrentIndex(0); + ui->communicationTypeBox->setCurrentIndex(1); + } + + ui->idEdit->setText(QString().sprintf("%08x", clientDevInfo.id)); + ui->csgIdEdit->setText(reinterpret_cast(clientDevInfo.csgId)); + ui->csgVersionEdit->setText(QString().sprintf("%04x", clientDevInfo.csgVersion)); + ui->factoryDateEdit->setText(reinterpret_cast(clientDevInfo.factoryTime)); + ui->hwVersionEdit->setText(QString(reinterpret_cast(clientDevInfo.hardwareVersion))); + ui->fpgaVersionLabel->setText(QString(reinterpret_cast(clientDevInfo.fpgaVersion))); + QString temp; + QStringList list; + temp = QString(reinterpret_cast(clientDevInfo.bootVersion)); + list = temp.split("."); + if (4 == list.length()) + { + ui->IAPVersionLabel->setText("V" + list[2] + "." + list[3]); + } + ui->IAPDateLabel->setText(QString(reinterpret_cast(clientDevInfo.bootCompile_time))); + temp = QString(reinterpret_cast(clientDevInfo.imgVersion)); + list = temp.split("."); + if (4 == list.length()) + { + ui->APPVersionLabel->setText("V" + list[2] + "." + list[3]); + } + ui->APPDateLabel->setText(QString(reinterpret_cast(clientDevInfo.imgCompile_time))); + ui->macEdit->setText(QString().sprintf("%02x:%02x:%02x:%02x:%02x:%02x", clientDevInfo.mac[0], clientDevInfo.mac[1], clientDevInfo.mac[2], + clientDevInfo.mac[3], clientDevInfo.mac[4], clientDevInfo.mac[5])); + ui->ipEdit->setText(QString().sprintf("%d.%d.%d.%d", clientDevInfo.ip[0], clientDevInfo.ip[1], clientDevInfo.ip[2], clientDevInfo.ip[3])); + ui->maskEdit->setText(QString().sprintf("%d.%d.%d.%d", clientDevInfo.ipMask[0], clientDevInfo.ipMask[1], clientDevInfo.ipMask[2], clientDevInfo.ipMask[3])); + ui->gwEdit->setText(QString().sprintf("%d.%d.%d.%d", clientDevInfo.ipGw[0], clientDevInfo.ipGw[1], clientDevInfo.ipGw[2], clientDevInfo.ipGw[3])); + ui->serverEdit->setText(QString().sprintf("%d.%d.%d.%d", clientDevInfo.serverIp[0], clientDevInfo.serverIp[1], clientDevInfo.serverIp[2], + clientDevInfo.serverIp[3])); + ui->serverWIEdit->setText(QString().sprintf("%d.%d.%d.%d", clientDevInfo.wirelessServerIp[0], clientDevInfo.wirelessServerIp[1], + clientDevInfo.wirelessServerIp[2], clientDevInfo.wirelessServerIp[3])); + ui->serverPortEdit->setText(QString().sprintf("%d", clientDevInfo.serverPort)); + ui->serverWIPortEdit->setText(QString().sprintf("%d", clientDevInfo.wirelessServerPort)); + ui->cardEdit->setText(QString().sprintf("%01x%02x%02x%02x%02x%02x", clientDevInfo.csgCard[0] & 0x0f, clientDevInfo.csgCard[1], + clientDevInfo.csgCard[2], clientDevInfo.csgCard[3], clientDevInfo.csgCard[4], clientDevInfo.csgCard[5])); +} + +void Widget::uiDevConfigRefresh() +{ + qDebug() << __FUNCTION__ << "flag:" << clientDevConfig.flag << endl; + if (IS_MONITOR_BIT_SET(clientDevConfig.flag, DEV_FLAG_CLI)) + { + ui->debugModeBox->setCurrentIndex(0); + } + else + { + ui->debugModeBox->setCurrentIndex(1); + } + + if (IS_MONITOR_BIT_SET(clientDevConfig.flag, DEV_FLAG_ADJ)) + { + ui->workModeBox->setCurrentIndex(1); + } + else if(IS_MONITOR_BIT_SET(clientDevConfig.flag, DEV_FLAG_FACTORY)) + { + ui->workModeBox->setCurrentIndex(2); + } + else + { + ui->workModeBox->setCurrentIndex(0); + } + + if (clientDevConfig.energyMode < 3) + { + ui->energyModeBox->setCurrentIndex(clientDevConfig.energyMode); + } + + if (clientDevConfig.normalSleep) + { + ui->normalSleepBox->setCurrentIndex(1); + } + else + { + ui->normalSleepBox->setCurrentIndex(0); + } + + //ui->APNEdit->setText(QString(reinterpret_cast(clientDevConfig.APN_long))); + + ui->colIntervalEdit->setText(QString::number(clientDevConfig.collectInterval)); + ui->waveIntervalEdit->setText(QString::number(clientDevConfig.waveInterval)); + ui->colThresholdEdit->setText(QString::number(clientDevConfig.collectThreshold)); + ui->waveThresholdEdit->setText(QString::number(clientDevConfig.waveThreshold)); + ui->waveThresholdEdit->setText(QString::number(clientDevConfig.waveThreshold)); + ui->mainCableIdEdit->setText(QString::number(clientDevConfig.mainCable)); + ui->voltageColBox->setChecked(clientDevConfig.isVoltageCol); + ui->tempColBox->setChecked(clientDevConfig.isTempCol); + ui->waveColBox->setChecked(clientDevConfig.isWaveCol); + + ui->sensor1IdEdit->setText(QString::number(clientDevConfig.sensor_id[0])); + ui->sensor2IdEdit->setText(QString::number(clientDevConfig.sensor_id[1])); + ui->sensor3IdEdit->setText(QString::number(clientDevConfig.sensor_id[2])); + ui->sensor4IdEdit->setText(QString::number(clientDevConfig.sensor_id[3])); + ui->sensor5IdEdit->setText(QString::number(clientDevConfig.sensor_id[4])); + ui->sensor6IdEdit->setText(QString::number(clientDevConfig.sensor_id[5])); + ui->sensor7IdEdit->setText(QString::number(clientDevConfig.sensor_id[6])); +} + +void Widget::uiDevCsgConfigRefresh() +{ + ui->passwdEdit->setText(QString(reinterpret_cast(csgConfig.passwd))); + ui->beatIntervalEdit->setText(QString::number(csgConfig.beatInterval)); + ui->csgColIntervalEdit->setText(QString::number(csgConfig.collectInterval)); + ui->sleepTimeEdit->setText(QString::number(csgConfig.sleepTime)); + ui->onlineTimeEdit->setText(QString::number(csgConfig.onlineTime)); + ui->resetTimeEdit->setText(QString().sprintf("%d:%d:%d", csgConfig.resetTime[0], csgConfig.resetTime[1], csgConfig.resetTime[2])); + ui->ciphertextEdit->setText(QString(reinterpret_cast(csgConfig.ciphertext))); +} + +void Widget::uiDevRealDataRefresh() +{ + QString temp; + + temp.sprintf("%.2f", clientRealData.temperature / 10.0); + ui->tempLabel->setText(temp); + temp.sprintf("%.2f", clientRealData.vin / 1000.0); + ui->vinLabel->setText(temp); + temp.sprintf("%.2f", clientRealData.vsc / 1000.0); + ui->vscLabel->setText(temp); + temp.sprintf("%.2f", clientRealData.vbat / 1000.0); + ui->vbatLabel->setText(temp); + ui->signalLabel->setText(QString::number(clientRealData.CSQ)); + + temp.sprintf("%.2f", clientRealData.sen_temp[0] / 10.0); + ui->senTemp1Label->setText(temp); + temp.sprintf("%.2f", clientRealData.sen_temp[1] / 10.0); + ui->senTemp2Label->setText(temp); + temp.sprintf("%.2f", clientRealData.sen_temp[2] / 10.0); + ui->senTemp3Label->setText(temp); + temp.sprintf("%.2f", clientRealData.sen_temp[3] / 10.0); + ui->senTemp4Label->setText(temp); + temp.sprintf("%.2f", clientRealData.sen_temp[4] / 10.0); + ui->senTemp5Label->setText(temp); + temp.sprintf("%.2f", clientRealData.sen_temp[5] / 10.0); + ui->senTemp6Label->setText(temp); + temp.sprintf("%.2f", clientRealData.sen_temp[6] / 10.0); + ui->senTemp7Label->setText(temp); + + ui->senShortLabel->setText(clientRealData.senShort ? "是" : "否"); + + ui->senX1Label->setText(QString::number(clientRealData.senX[0] - 16000)); + ui->senX3Label->setText(QString::number(clientRealData.senX[2] - 16000)); + ui->senX5Label->setText(QString::number(clientRealData.senX[4] - 16000)); + + ui->senY1Label->setText(QString::number(clientRealData.senY[0] - 16000)); + ui->senY3Label->setText(QString::number(clientRealData.senY[2] - 16000)); + ui->senY5Label->setText(QString::number(clientRealData.senY[4] - 16000)); + + ui->senZ1Label->setText(QString::number(clientRealData.senZ[0] - 16000)); + ui->senZ3Label->setText(QString::number(clientRealData.senZ[2] - 16000)); + ui->senZ5Label->setText(QString::number(clientRealData.senZ[4] - 16000)); + + temp.sprintf("%.2f", clientRealData.elec[0] / 1000.0); + ui->elec1Label->setText(temp); + temp.sprintf("%.2f", clientRealData.elec[1] / 1000.0); + ui->elec2Label->setText(temp); + temp.sprintf("%.2f", clientRealData.elec[2] / 1000.0); + ui->elec3Label->setText(temp); + temp.sprintf("%.2f", clientRealData.elec[3] / 1000.0); + ui->elec4Label->setText(temp); + temp.sprintf("%.2f", clientRealData.elec[4] / 1000.0); + ui->elec5Label->setText(temp); + temp.sprintf("%.2f", clientRealData.elec[5] / 1000.0); + ui->elec6Label->setText(temp); +} + +void Widget::uiDevStateRefresh() +{ + QString temp; + + if (clientDevState.energyMode < 4) + { + ui->stateEnergyLabel->setText(energyMode[clientDevState.energyMode]); + } + else + { + ui->stateEnergyLabel->setText(energyMode[0]); + } + ui->stateBatChargeLabel->setText(clientDevState.isBatCharge ? "未充电" : "充电"); + ui->stateForceSleepUpLabel->setText(clientDevState.forceSleepUp ? "是" : "否"); + ui->stateAdcColLabel->setText(clientDevState.isAdcCollect ? "完成" : "未完成"); + ui->stateAdcUpLabel->setText(clientDevState.isAdcUp ? "完成" : "未完成"); + ui->stateAdcThrLabel->setText(clientDevState.isAdcthr ? "是" : "否"); + ui->stateAdciCntLabel->setText(QString::number(clientDevState.AdciCnt)); + ui->stateAdciStLabel->setText(QString::number(clientDevState.AdciState)); + ui->stateAdcCntLabel->setText(QString::number(clientDevState.AdcCnt)); + ui->stateAdcStLabel->setText(QString::number(clientDevState.AdcState)); + + /*得到系统时间*/ + time_t cur = static_cast(clientDevState.waveTime); + tm *day; + day = localtime(&cur); + temp.sprintf("%d/%d/%d %d:%d:%d", day->tm_year + 1900, day->tm_mon+1, day->tm_mday, + day->tm_hour, day->tm_min, day->tm_sec); + ui->stateWaveTmLabel->setText(temp); + ui->stateWaveFinLabel->setText(clientDevState.waveStart ? "未完成" : "完成"); + ui->stateWaveUpLabel->setText(clientDevState.waveUpStart ? "未完成" : "完成"); + ui->stateWaveIdxLabel->setText(QString::number(clientDevState.waveIdx)); + ui->stateWaveStLabel->setText(devStateWaveStateGet(clientDevState.waveState)); + ui->stateWaveRtLabel->setText(QString::number(clientDevState.waveRt)); + ui->stateWaveForceLabel->setText(clientDevState.waveForce ? "是" : "否"); + + ui->stateWlStLabel->setText(devStateWlStateGet(clientDevState.wlState)); + ui->stateWlCntLabel->setText(QString::number(clientDevState.wlCnt)); + ui->stateWlUpLabel->setText(clientDevState.isWlUpdate ? "升级" : "未升级"); + ui->stateWlIdxLabel->setText(QString::number(clientDevState.wlWaveIdx)); + + ui->waveParamEdit->setText(QString::number(clientDevState.waveAdj)); + ui->waveFinLabel->setText(clientDevState.waveStart ? "未完成" : "完成"); + ui->waveMinEdit->setText(QString::number(clientDevState.waveMin)); + ui->waveMaxEdit->setText(QString::number(clientDevState.waveMax)); + + temp.sprintf("%dh:%dm:%ds", clientDevState.sysTime / 3600, (clientDevState.sysTime / 60) % 60, clientDevState.sysTime % 60); + ui->stateRunTimeLabel->setText(temp); + double tempSc; + tempSc = clientDevState.scMax / 1000.00; + ui->stateScMaxLabel->setText(QString::number(tempSc, 'g', 3)); + tempSc = clientDevState.scMin / 1000.00; + ui->stateScMinLabel->setText(QString::number(tempSc, 'g', 3)); + ui->stateUpTimeLabel->setText(QString::number(clientDevState.scUpTime)); + ui->stateDownTimeLabel->setText(QString::number(clientDevState.scDownTime)); +} + +void Widget::uiPowerFrequencyRefresh() +{ + int row = ui->frequencyTable->rowCount(); + int column = ui->frequencyTable->columnCount(); + + for(int32_t i = 0; i < row; i++) + { + for(int32_t j = 0; j < column; j++) + { + QString temp; + temp.sprintf("%d", powerFre[ui->freChBox->currentText().toInt() - 1][column * i + j]); + ui->frequencyTable->item(i, j)->setText(temp); + } + } +} + +/* 手动校准界面刷新. */ +void Widget::uiManualAdjustRefresh() +{ + uint8_t ch = 0; + int index = 0; + + /* 获取校准通道. */ + for(uint8_t i = 0; i < ui->adjustTable->rowCount(); i++) + { + QCheckBox *checkBox = reinterpret_cast(ui->adjustTable->cellWidget(i, 0)); + if (checkBox->isChecked()) + { + ch = i; + break; + } + } + + if (ch >= ui->adjustTable->rowCount()) + { + ch = 0; + } + + index = ui->manualAdjBox->currentIndex(); + ui->manualAdjLabel->setText("输入电流" + QString::number(clientAdjInfo.ADCBase_elec[ch][index] / 1000) + "A"); + ui->manualAdjButton->setText("手动校准段" + QString::number(index + 1)); +} + +void Widget::uiAdjustInfoRefresh() +{ + QString temp; + + for(int i = 0; i < ui->adjustTable->rowCount(); i++) + { + ui->adjustTable->item(i, 2)->setText(QString::number(clientAdjInfo.ADCRatio[i])); + ui->adjustTable->item(i, 3)->setText(QString::number(clientAdjInfo.ADC_turns[i])); + for(int j = 0; j < DAU_POWER_ADJ_CNT; j++) + { + ui->adjustTable->item(i, j * 3 + 4)->setText(QString::number(clientAdjInfo.ADCBase_elec[i][j])); + temp.sprintf("%.1f", static_cast(clientAdjInfo.ADCBase[i][j])); + ui->adjustTable->item(i, j * 3 + 5)->setText(temp); + ui->adjustTable->item(i, j * 3 + 6)->setText(QString::number(clientAdjInfo.ADCAdj[i][j])); + } + } + + ui->vinEdit->setText(QString::number(clientAdjInfo.vin_adj)); + ui->vinAdjEdit->setText(QString::number(clientAdjInfo.vin)); + + uiManualAdjustRefresh(); +} + + + +void Widget::protoContact(char *data) +{ + char *pbody = data + sizeof(proto_head_t); + memcpy(&clientDevInfo, pbody, sizeof(devInfo)); + uiDevInfoRefresh(); + buttonEnable(true); +} + +void Widget::protoConfig(char *data) +{ + char *pbody = data + sizeof(proto_head_t); + memcpy(&clientDevConfig, pbody, sizeof(devConfig)); + uiDevConfigRefresh(); +} + +void Widget::protoCsgConfig(char *data) +{ + char *pbody = data + sizeof(proto_head_t); + memcpy(&csgConfig, pbody, sizeof(csgConfig_t)); + uiDevCsgConfigRefresh(); +} + +void Widget::protoRealdata(char *data) +{ + char *pbody = data + sizeof(proto_head_t); + memcpy(&clientRealData, pbody, sizeof(realData_t)); + uiDevRealDataRefresh(); + + if (isDataRefresh) + { + sendMsgDeviceRealDataGet(); + } +} + +int Widget::protoUpdateReply(char *data, int fileType) +{ + mul_head_t *header = reinterpret_cast(data + sizeof(proto_head_t)); + + /* 数据头验证. */ + qDebug() << "recv:index:" << header->index << "upPackIndex:" << upPackIndex << "len:" << header->len << endl; + if (header->index != upPackIndex + || header->len > UPDATE_DATA_SIZE) + { + return -1; + } + + /* 发送报文. */ + /* 小于 CM_U_RX_M_PKT_MAX, 表示发送完成进入下个状态, 否则继续发送. */ + if (header->len < UPDATE_DATA_SIZE) + { + upPackIndex = 0; + ui->upFileSizeLabel->setText("升级完成"); + QMessageBox::information(this, "SUCCEED", "文件" + filePath + "升级完成.", QMessageBox::Ok); + } + else + { + upPackIndex++; + sendMsgDeviceUpdate(fileType); + QString temp; + upFileRecvSize += header->len; + temp.sprintf("%d / %lld", upFileRecvSize, upFileSize); + ui->upFileSizeLabel->setText(temp); + } + return 0; +} + +int Widget::protoWaveDataUploadReply(char *data) +{ + mul_head_t *header = reinterpret_cast(data + sizeof(proto_head_t)); + + /* 数据头校验. */ + qDebug() << "recv:index:" << header->index << "waveIndex:" << waveIndex << "len:" << header->len << endl; + if (header->index != waveIndex + || header->len > UPDATE_DATA_SIZE) + { + return -1; + } + + /* 获取文件. */ + QFile file(waveFilePath); + if (0 == header->index) + { + file.remove(); + } + + if (file.open(QIODevice::WriteOnly | QIODevice::Append)) + { + file.write(data + sizeof(proto_head_t) + sizeof(mul_head_t), header->len); + file.close(); + qDebug() << "file " << header->index << header->len; + } + else + { + qDebug() << "file ERROR"; + return -1; + } + + /* 通知发包线程进入下个状态. */ + if (header->len < UPDATE_DATA_SIZE) + { + waveIndex = 0; + buttonEnable(true); + is_wave_up = false; + ui->upWaveIndexLabel->setText("下载完成"); + QMessageBox::information(this, "SUCCEED", "高频录波文件下载完成.", QMessageBox::Ok); + } + else + { + waveIndex = header->index + 1; + sendMsgDeviceWaveDataGet(); + ui->upWaveIndexLabel->setText(QString("%1 / 8000").arg(waveIndex)); + } + + return 0; +} + +/* 工频录波文件请求处理. */ +int Widget::protoPowerFrequency(char *data) +{ + mul_head_t *header = reinterpret_cast(data + sizeof(proto_head_t)); + + /* 数据头校验. */ + qDebug() << "recv:index:" << header->index << "freIndex:" << freIndex << "len:" << header->len << endl; + if (header->index != freIndex + || header->len > UPDATE_DATA_SIZE) + { + return -1; + } + + /* 获取文件. */ + memcpy(reinterpret_cast(powerFre) + header->index * UPDATE_DATA_SIZE, data + sizeof(proto_head_t) + sizeof(mul_head_t), header->len); + + /* 通知发包线程进入下个状态. */ + if (header->len < UPDATE_DATA_SIZE) + { + freIndex = 0; + ui->upFreIndexLabel->setText("下载完成"); + QMessageBox::information(this, "SUCCEED", "工频录波文件下载完成.", QMessageBox::Ok); + buttonEnable(true); + uiPowerFrequencyRefresh(); + } + else + { + freIndex = header->index + 1; + sendMsgDevicePowerFrequencyGet(); + QString temp; + temp.sprintf("%d / 10", freIndex + 1); + ui->upFreIndexLabel->setText(temp); + } + + return 0; +} + + +int Widget::protoState(char *data) +{ + char *pbody = data + sizeof(proto_head_t); + memcpy(&clientDevState, pbody, sizeof(devState)); + uiDevStateRefresh(); + return 0; +} + +int Widget::protoManualAdjust(char *data) +{ + int32_t rv = *reinterpret_cast(data + sizeof(proto_head_t)); + + sendMsgDeviceAdjustInfoGet(); + buttonEnable(true); + + /* 判断返回值. */ + if (0 == rv) + { + QMessageBox::information(this, "SUCCEED", "校准完成.", QMessageBox::Ok); + int index = ui->manualAdjBox->currentIndex(); + + index++; + if (index >= DAU_POWER_ADJ_CNT) + { + index = 0; + } + + ui->manualAdjBox->setCurrentIndex(index); + uiManualAdjustRefresh(); + } + else + { + QMessageBox::warning(this, "WARNING", "校准失败!", QMessageBox::Ok); + } + + return 0; +} + +int Widget::protoAdjustInfoGet(char *data) +{ + /* 获取参数. */ + memcpy(&clientAdjInfo, data + sizeof(proto_head_t), sizeof(dev_adj_t)); + + /* 更新界面. */ + uiAdjustInfoRefresh(); + return 0; +} + +int Widget::protoAutoAdjust(char *data) +{ + int32_t rv = *reinterpret_cast(data + sizeof(proto_head_t)); + + /* 跳转状态. */ + //if (work) + { + //work->stateSet(CM_usart::WS_ADJ_INFO_GET); + //work->mutexUnlock(); + } + + sendMsgDeviceAdjustInfoGet(); + buttonEnable(true); + + /* 判断返回值. */ + if (0 == rv) + { + QMessageBox::information(this, "SUCCEED", "校准完成.", QMessageBox::Ok); + } + else + { + QMessageBox::warning(this, "WARNING", "校准失败!", QMessageBox::Ok); + } + + return 0; +} + + +int Widget::protoLog(char * data) +{ + mul_head_t *header = reinterpret_cast(data + sizeof(proto_head_t)); + falsh_log_t *log; + uint32_t cnt = 0; + + qDebug() << "index:" << header->index << "len:" << header->len << endl; + + /* 数据头校验. */ + if (header->index != logIndex + || header->len > UPDATE_DATA_SIZE) + { + return -1; + } + + /* 获取文件. */ + QFile file("log.txt"); + if (0 == header->index) + { + file.remove(); + } + + if (file.open(QIODevice::WriteOnly | QIODevice::Append)) + { + cnt = header->len / FLASH_LOG_BUF_LEN; + for(uint32_t i = 0; i < cnt; i++) + { + log = reinterpret_cast(data + sizeof(proto_head_t) + sizeof(mul_head_t) + i * FLASH_LOG_BUF_LEN); + file.write((char *)log->data, strlen((char *)log->data)); + ui->logTextEdit->insertPlainText((char *)log->data); + } + file.close(); + } + else + { + qDebug() << "file ERROR"; + return -1; + } + + /* 通知发包线程进入下个状态. */ + if (header->len < UPDATE_DATA_SIZE) + { + //work->multipleIndexSet(0); + //work->stateSet(CM_usart::WS_IDLE); + logIndex = 0; + buttonEnable(true); + ui->logIndexLabel->setText("下载完成"); + QMessageBox::information(this, "SUCCEED", "Log 文件下载完成.", QMessageBox::Ok); + is_log_up = false; + ui->stateLogButton->setText("下载 Log"); + } + else + { + logIndex = header->index + 1;; + QString temp; + temp.sprintf("%d / %d", logIndex, ui->stateLogEdit->text().toInt()); + ui->logIndexLabel->setText(temp); + sendMsgLogGet(); + } + + return 0; +} + + +int Widget::protoHistoryData(char * data) +{ + mul_head_t *header = reinterpret_cast(data + sizeof(proto_head_t)); + fd_data_t *pHistoryData; + uint32_t cnt = 0; + qDebug() << "index:" << header->index << "len:" << header->len << endl; + + /* 数据头校验. */ + if (header->index != dataIndex + || header->len > UPDATE_DATA_SIZE) + { + return -1; + } + + /* 获取文件. */ + cnt = header->len / FD_BUF_LEN; + for(uint32_t i = 0; i < cnt; i++) + { + pHistoryData = reinterpret_cast(data + sizeof(proto_head_t) + sizeof(mul_head_t) + i * FD_BUF_LEN); + int32_t row = ui->historyDataTable->rowCount(); + ui->historyDataTable->insertRow(row); + + QTableWidgetItem *item = new QTableWidgetItem (QString::number(pHistoryData->id)); + ui->historyDataTable->setItem(row, 0, item); + + time_t cur = static_cast(pHistoryData->run_time); + tm *day; + day = localtime(&cur); + QString temp; + temp.sprintf("%d/%d/%d %d:%d:%d", day->tm_year + 1900, day->tm_mon+1, day->tm_mday, day->tm_hour, day->tm_min, day->tm_sec); + item = new QTableWidgetItem (temp); + ui->historyDataTable->setItem(row, 1, item); + + temp.sprintf("%.2f", pHistoryData->temperature / 10.0); + item = new QTableWidgetItem (temp); + ui->historyDataTable->setItem(row, 2, item); + temp.sprintf("%.2f", pHistoryData->vin / 1000.0); + item = new QTableWidgetItem (temp); + ui->historyDataTable->setItem(row, 3, item); + temp.sprintf("%.2f", pHistoryData->vbat / 1000.0); + item = new QTableWidgetItem (temp); + ui->historyDataTable->setItem(row, 4, item); + temp.sprintf("%.2f", pHistoryData->vsc / 1000.0); + item = new QTableWidgetItem (temp); + ui->historyDataTable->setItem(row, 5, item); + temp.sprintf("%.2f", pHistoryData->elec[0] / 1000.0); + item = new QTableWidgetItem (temp); + ui->historyDataTable->setItem(row, 6, item); + temp.sprintf("%.2f", pHistoryData->elec[1] / 1000.0); + item = new QTableWidgetItem (temp); + ui->historyDataTable->setItem(row, 7, item); + temp.sprintf("%.2f", pHistoryData->elec[2] / 1000.0); + item = new QTableWidgetItem (temp); + ui->historyDataTable->setItem(row, 8, item); + temp.sprintf("%.2f", pHistoryData->elec[3] / 1000.0); + item = new QTableWidgetItem (temp); + ui->historyDataTable->setItem(row, 9, item); + temp.sprintf("%.2f", pHistoryData->elec[4] / 1000.0); + item = new QTableWidgetItem (temp); + ui->historyDataTable->setItem(row, 10, item); + temp.sprintf("%.2f", pHistoryData->elec[5] / 1000.0); + item = new QTableWidgetItem (temp); + ui->historyDataTable->setItem(row, 11, item); + } + + if (header->len < UPDATE_DATA_SIZE) + { + //work->multipleIndexSet(0); + //work->stateSet(CM_usart::WS_IDLE); + dataIndex = 0; + buttonEnable(true); + ui->dataIndexLabel->setText("下载完成"); + QMessageBox::information(this, "SUCCEED", "历史数据下载完成.", QMessageBox::Ok); + ui->historyDataButton->setText("下载数据"); + is_data_up = false; + } + else + { + dataIndex = header->index + 1; + QString temp; + temp.sprintf("%d / %d", dataIndex, ui->historyDataEdit->text().toInt()); + ui->dataIndexLabel->setText(temp); + //work->multipleIndexSet(header->index + 1); + sendMsgHistoryDataGet(); + } + return 0; +} + +int Widget::paraseProtocols(char *data) +{ + proto_head_t *header = reinterpret_cast(data); + + qDebug() << "cmd_type:" << header->cmd_type << "cmd:" << header->cmd << endl; + qDebug() << "len:" << header->len << endl; + if (DEBUG_CT_REPLY == header->cmd_type) + { + /* 共有命令处理. */ + switch (header->cmd) + { + case DEBUG_C_CONTACT: // 获取配置成功后更新页面 + protoContact(data); + break; + + case DEBUG_C_DEV_INFO_SET: + break; + case DEBUG_C_RESET: + //_debug_pkt_reset(); + break; + case DEBUG_C_DEFAULT: + //_debug_pkt_default(); + break; + case DEBUG_C_UPDATE_APP: + case DEBUG_C_UPDATE_IAP: + protoUpdateReply(data, header->cmd); + break; + case DEBUG_C_DEV_CONFIG: // 获取配置成功后更新页面 + protoConfig(data); + break; + case DEBUG_C_DEV_CONFIG_SET: + //buttonEnable(false); + //snedMsgDeviceInfoGet(); + break; + default: + break; + } + } + else if (DEBUG_CT_PRV_REPLY == header->cmd_type) + { + /* 私有命令处理. */ + switch (header->cmd) + { + case DEBUG_PRV_REALDATA: + protoRealdata(data); + break; + case DEBUG_PRV_POWER: + //_debug_pkt_power_fre_get(); + break; + case DEBUG_PRV_DEFECT: + protoWaveDataUploadReply(data); + break; + case DEBUG_PRV_ADJ_INFO: + protoAdjustInfoGet(data); + break; + case DEBUG_PRV_ADJ_INFO_SET: + /* 更新界面. */ + QMessageBox::information(this, "SUCCEED", "操作完成.", QMessageBox::Ok); + break; + case DEBUG_PRV_ADJ_AUTO: + protoAutoAdjust(data); + break; + case DEBUG_PRV_DEV_STATE: + protoState(data); + break; + case DEBUG_PRV_WAVE_COL: + //_debug_pkt_wave_col(); + break; + case DEBUG_PRV_WAVE_CAL: + //_debug_pkt_wave_cal(); + break; + case DEBUG_PRV_LOG: + protoLog(data); + break; + case DEBUG_PRV_HISTORY_DATA: + protoHistoryData(data); + break; + case DEBUG_PRV_ADJ_MANUAL: + protoManualAdjust(data); + break; + case DEBUG_PRV_CSG_CONFIG: // 获取配置成功后更新页面 + protoCsgConfig(data); + break; + case DEBUG_PRV_CSG_CONFIG_SET: + //_debug_pkt_csg_config_set(); + break; + default: + break; + } + } +} + +int Widget::snedMsgDeviceInfoGet() +{ + char buf[2048] = {0}; + uint32_t *crc = nullptr; + + proto_head_t *header = reinterpret_cast(buf); + protoHeaderInit(header, sizeof(proto_head_t), 0xFFFFFFFF, DEBUG_CT_REQUEST, DEBUG_C_CONTACT); + header->dev_type_m = 2; + header->dev_type_s = 255; + + /* 计算校验和. */ + crc = reinterpret_cast(buf + header->len); + *crc = crc32(buf, header->len); + + //printHexArray(__FUNCTION__, buf, header->len + 4); + HexPrint(__FUNCTION__, buf, header->len + 4); + writeData(buf, header->len + 4); + return 0; +} + +int Widget::sendMsgDeviceInfoSet() +{ + char buf[2048] = {0}; + uint32_t *crc = nullptr; + + proto_head_t *header = reinterpret_cast(buf); + devInfo *data = reinterpret_cast(buf + sizeof(proto_head_t)); + + /* 初始化报文头. */ + protoHeaderInit(header, sizeof(proto_head_t) + sizeof(devInfo), clientDevInfo.id, DEBUG_CT_REQUEST, DEBUG_C_DEV_INFO_SET); + + memcpy(data, &clientDevInfo, sizeof(devInfo)); + + /* 计算校验位. */ + crc = reinterpret_cast(buf + header->len); + *crc = crc32(buf, header->len); + + printHexArray(__FUNCTION__, buf, header->len + 4); + writeData(buf, header->len + 4); + return 0; +} + +int Widget::sendMsgDeviceReset() +{ + char buf[2048] = {0}; + uint32_t *crc = nullptr; + + proto_head_t *header = reinterpret_cast(buf); + + /* 初始化报文头. */ + protoHeaderInit(header, sizeof(proto_head_t), clientDevInfo.id, DEBUG_CT_REQUEST, DEBUG_C_RESET); + + /* 计算校验位. */ + crc = reinterpret_cast(buf + header->len); + *crc = crc32(buf, header->len); + + printHexArray(__FUNCTION__, buf, header->len + 4); + writeData(buf, header->len + 4); + return 0; +} + +int Widget::sendMsgDeviceCfgDefault() +{ + char buf[2048] = {0}; + uint32_t *crc = nullptr; + + proto_head_t *header = reinterpret_cast(buf); + + /* 初始化报文头. */ + protoHeaderInit(header, sizeof(proto_head_t), clientDevInfo.id, DEBUG_CT_REQUEST, DEBUG_C_DEFAULT); + + /* 计算校验位. */ + crc = reinterpret_cast(buf + header->len); + *crc = crc32(buf, header->len); + + printHexArray(__FUNCTION__, buf, header->len + 4); + writeData(buf, header->len + 4); + return 0; +} + +int Widget::sendMsgDeviceUpdate(int fileType) +{ + char buf[2048] = {0}; + uint32_t *crc = nullptr; + + proto_head_t *header = reinterpret_cast(buf); + mul_head_t *m_head = (mul_head_t*)(buf + sizeof(proto_head_t)); + uint8_t *data = (uint8_t*)(buf + sizeof(proto_head_t) + sizeof(mul_head_t)); + + /* 初始化报文头. */ + protoHeaderInit(header, sizeof(proto_head_t), clientDevInfo.id, DEBUG_CT_REQUEST, fileType); + m_head->index = upPackIndex; + + /* 读取文件 */ + QFile file_read(filePath); + int len; + if (!file_read.open(QIODevice::ReadOnly)) + { + return -1; + } + + QDataStream in(&file_read); + in.skipRawData(static_cast(upPackIndex * UPDATE_DATA_SIZE)); + len = in.readRawData((char *)data, UPDATE_DATA_SIZE); + file_read.close(); + m_head->len = static_cast(len); + header->len = static_cast(sizeof(proto_head_t) + sizeof(mul_head_t) + m_head->len); + + /* 计算校验位. */ + crc = reinterpret_cast(buf + header->len); + *crc = crc32(buf, header->len); + + qDebug() << "send:upPackIndex=" << upPackIndex << "packLen=" << header->len + 4 << endl; + //printHexArray(__FUNCTION__, buf, header->len + 4); + writeData(buf, header->len + 4); + return 0; +} + +int Widget::sendMsgDeviceConfigSet() +{ + char buf[2048] = {0}; + uint32_t *crc = nullptr; + + proto_head_t *header = reinterpret_cast(buf); + devConfig *data = reinterpret_cast(buf + sizeof(proto_head_t)); + + /* 初始化报文头. */ + protoHeaderInit(header, sizeof(proto_head_t) + sizeof(devConfig), clientDevInfo.id, DEBUG_CT_REQUEST, DEBUG_C_DEV_CONFIG_SET); + + memcpy(data, &clientDevConfig, sizeof(devConfig)); + + /* 计算校验位. */ + crc = reinterpret_cast(buf + header->len); + *crc = crc32(buf, header->len); + + //printHexArray(__FUNCTION__, buf, header->len + 4); + //HexPrint(__FUNCTION__, buf, header->len + 4); + writeData(buf, header->len + 4); + return 0; +} + +int Widget::sendMsgDeviceConfigGet() +{ + char buf[2048] = {0}; + uint32_t *crc = nullptr; + proto_head_t *header = reinterpret_cast(buf); + + /* 初始化报文头. */ + protoHeaderInit(header, sizeof(proto_head_t), clientDevInfo.id, DEBUG_CT_REQUEST, DEBUG_C_DEV_CONFIG); + + /* 计算校验位. */ + crc = reinterpret_cast(buf + header->len); + *crc = crc32(buf, header->len); + + HexPrint(__FUNCTION__, buf, header->len + 4); + writeData(buf, header->len + 4); + return 0; +} + +int Widget::sendMsgDeviceCsgConfigGet() +{ + char buf[2048] = {0}; + uint32_t *crc = nullptr; + proto_head_t *header = reinterpret_cast(buf); + + /* 初始化报文头. */ + protoHeaderInit(header, sizeof(proto_head_t), clientDevInfo.id, DEBUG_CT_PRV_REQUEST, DEBUG_PRV_CSG_CONFIG); + + /* 计算校验位. */ + crc = reinterpret_cast(buf + header->len); + *crc = crc32(buf, header->len); + + HexPrint(__FUNCTION__, buf, header->len + 4); + writeData(buf, header->len + 4); + return 0; +} + +int Widget::sendMsgDeviceCsgConfigSet() +{ + char buf[2048] = {0}; + uint32_t *crc = nullptr; + proto_head_t *header = reinterpret_cast(buf); + + /* 初始化报文头. */ + protoHeaderInit(header, sizeof(proto_head_t) + sizeof(csgConfig_t), clientDevInfo.id, DEBUG_CT_PRV_REQUEST, DEBUG_PRV_CSG_CONFIG_SET); + + memcpy(buf, &csgConfig, sizeof(csgConfig_t)); + + /* 计算校验位. */ + crc = reinterpret_cast(buf + header->len); + *crc = crc32(buf, header->len); + + HexPrint(__FUNCTION__, buf, header->len + 4); + writeData(buf, header->len + 4); + return 0; +} + +int Widget::sendMsgDeviceRealDataGet() +{ + char buf[2048] = {0}; + uint32_t *crc = nullptr; + proto_head_t *header = reinterpret_cast(buf); + + /* 初始化报文头. */ + protoHeaderInit(header, sizeof(proto_head_t), clientDevInfo.id, DEBUG_CT_PRV_REQUEST, DEBUG_PRV_REALDATA); + + /* 计算校验位. */ + crc = reinterpret_cast(buf + header->len); + *crc = crc32(buf, header->len); + + HexPrint(__FUNCTION__, buf, header->len + 4); + writeData(buf, header->len + 4); + return 0; +} + +int Widget::sendMsgDeviceWaveDataGet() +{ + char buf[2048] = {0}; + uint32_t *crc = nullptr; + proto_head_t *header = reinterpret_cast(buf); + mul_head_t *m_head = (mul_head_t*)(buf + sizeof(proto_head_t)); + + /* 初始化报文头. */ + protoHeaderInit(header, sizeof(proto_head_t) + sizeof(mul_head_t), clientDevInfo.id, DEBUG_CT_PRV_REQUEST, DEBUG_PRV_DEFECT); + m_head->index = waveIndex; + m_head->len = 0; + + /* 计算校验位. */ + crc = reinterpret_cast(buf + header->len); + *crc = crc32(buf, header->len); + + HexPrint(__FUNCTION__, buf, header->len + 4); + writeData(buf, header->len + 4); + return 0; +} + +int Widget::sendMsgDeviceStateGet() +{ + char buf[2048] = {0}; + uint32_t *crc = nullptr; + proto_head_t *header = reinterpret_cast(buf); + + /* 初始化报文头. */ + protoHeaderInit(header, sizeof(proto_head_t), clientDevInfo.id, DEBUG_CT_PRV_REQUEST, DEBUG_PRV_DEV_STATE); + + /* 计算校验位. */ + crc = reinterpret_cast(buf + header->len); + *crc = crc32(buf, header->len); + + HexPrint(__FUNCTION__, buf, header->len + 4); + writeData(buf, header->len + 4); + return 0; +} + +int Widget::sendMsgDevicePowerFrequencyGet() +{ + char buf[2048] = {0}; + uint32_t *crc = nullptr; + + proto_head_t *header = reinterpret_cast(buf); + mul_head_t *m_head = (mul_head_t*)(buf + sizeof(proto_head_t)); + + /* 初始化报文头. */ + protoHeaderInit(header, sizeof(proto_head_t) + sizeof(mul_head_t), clientDevInfo.id, DEBUG_CT_PRV_REQUEST, DEBUG_PRV_POWER); + + m_head->index = freIndex; + m_head->len = 0; + + /* 计算校验位. */ + crc = reinterpret_cast(buf + header->len); + *crc = crc32(buf, header->len); + + /* 计算校验位. */ + HexPrint(__FUNCTION__, buf, header->len + 4); + writeData(buf, header->len + 4); + + return 0; +} + +int Widget::sendMsgDeviceAdjustInfoSet() +{ + char buf[2048] = {0}; + uint32_t *crc = nullptr; + proto_head_t *header = reinterpret_cast(buf); + dev_adj_t *pdata = reinterpret_cast(buf + sizeof(proto_head_t)); + + /* 初始化报文头. */ + protoHeaderInit(header, sizeof(proto_head_t), clientDevInfo.id, DEBUG_CT_PRV_REQUEST, DEBUG_PRV_ADJ_INFO_SET); + memcpy(pdata, &clientAdjInfo, sizeof(dev_adj_t)); + + /* 计算校验位. */ + crc = reinterpret_cast(buf + header->len); + *crc = crc32(buf, header->len); + + HexPrint(__FUNCTION__, buf, header->len + 4); + writeData(buf, header->len + 4); + return 0; +} + +int Widget::sendMsgDeviceAdjustInfoGet() +{ + char buf[2048] = {0}; + uint32_t *crc = nullptr; + proto_head_t *header = reinterpret_cast(buf); + + /* 初始化报文头. */ + protoHeaderInit(header, sizeof(proto_head_t), clientDevInfo.id, DEBUG_CT_PRV_REQUEST, DEBUG_PRV_ADJ_INFO); + + /* 计算校验位. */ + crc = reinterpret_cast(buf + header->len); + *crc = crc32(buf, header->len); + + HexPrint(__FUNCTION__, buf, header->len + 4); + writeData(buf, header->len + 4); + return 0; +} + +int Widget::sendMsgDeviceAdjustMode(uint8_t cmd, adjSet *param) +{ + char buf[2048] = {0}; + uint32_t *crc = nullptr; + proto_head_t *header = reinterpret_cast(buf); + adjSet *pdata = reinterpret_cast(buf + sizeof(proto_head_t)); + + /* 初始化报文头. */ + protoHeaderInit(header, sizeof(proto_head_t) + sizeof(adjSet), clientDevInfo.id, DEBUG_CT_PRV_REQUEST, cmd); + + memcpy(pdata, param, sizeof(adjSet)); + + /* 计算校验位. */ + crc = reinterpret_cast(buf + header->len); + *crc = crc32(buf, header->len); + + HexPrint(__FUNCTION__, buf, header->len + 4); + writeData(buf, header->len + 4); + return 0; +} + +int Widget::sendMsgWaveCol() +{ + char buf[2048] = {0}; + uint32_t *crc = nullptr; + proto_head_t *header = reinterpret_cast(buf); + + /* 初始化报文头. */ + protoHeaderInit(header, sizeof(proto_head_t), clientDevInfo.id, DEBUG_CT_PRV_REQUEST, DEBUG_PRV_WAVE_COL); + + /* 计算校验位. */ + crc = reinterpret_cast(buf + header->len); + *crc = crc32(buf, header->len); + + //HexPrint(__FUNCTION__, buf, header->len + 4); + writeData(buf, header->len + 4); + return 0; +} + +int Widget::sendMsgWaveCal() +{ + char buf[2048] = {0}; + uint32_t *crc = nullptr; + proto_head_t *header = reinterpret_cast(buf); + waveParam_t *data = reinterpret_cast(buf + sizeof(proto_head_t)); + + /* 初始化报文头. */ + protoHeaderInit(header, sizeof(proto_head_t) + 4, clientDevInfo.id, DEBUG_CT_PRV_REQUEST, DEBUG_PRV_WAVE_CAL); + + data->param = waveParam; + + /* 计算校验位. */ + crc = reinterpret_cast(buf + header->len); + *crc = crc32(buf, header->len); + + //HexPrint(__FUNCTION__, buf, header->len + 4); + writeData(buf, header->len + 4); + return 0; +} + +int Widget::sendMsgLogGet() +{ + char buf[2048] = {0}; + uint32_t *crc = nullptr; + proto_head_t *header = reinterpret_cast(buf); + mul_head_t *m_head = reinterpret_cast(buf + sizeof(proto_head_t)); + int32_t *data = reinterpret_cast(buf + sizeof(proto_head_t) + sizeof(mul_head_t)); + + /* 初始化报文头. */ + protoHeaderInit(header, sizeof(proto_head_t) + sizeof(mul_head_t) + sizeof(uint32_t), clientDevInfo.id, DEBUG_CT_PRV_REQUEST, DEBUG_PRV_LOG); + + m_head->index = logIndex; + m_head->len = 0; + *data = logSum; + + /* 计算校验位. */ + crc = reinterpret_cast(buf + header->len); + *crc = crc32(buf, header->len); + + //HexPrint(__FUNCTION__, buf, header->len + 4); + writeData(buf, header->len + 4); + return 0; +} + + +int Widget::sendMsgHistoryDataGet() +{ + char buf[2048] = {0}; + uint32_t *crc = nullptr; + proto_head_t *header = reinterpret_cast(buf); + mul_head_t *m_head = reinterpret_cast(buf + sizeof(proto_head_t)); + int32_t *data = reinterpret_cast(buf + sizeof(proto_head_t) + sizeof(mul_head_t)); + + /* 初始化报文头. */ + protoHeaderInit(header, sizeof(proto_head_t) + sizeof(mul_head_t) + sizeof(uint32_t), clientDevInfo.id, DEBUG_CT_PRV_REQUEST, DEBUG_PRV_HISTORY_DATA); + + m_head->index = dataIndex; + m_head->len = 0; + *data = historyDataSum; + + /* 计算校验位. */ + crc = reinterpret_cast(buf + header->len); + *crc = crc32(buf, header->len); + + HexPrint(__FUNCTION__, buf, header->len + 4); + writeData(buf, header->len + 4); + return 0; +} + +void Widget::on_btnConn_clicked() +{ + if (!isConnected) + { + initSerial(); + /* 变更按钮文字. */ + ui->btnConn->setText("断开"); + snedMsgDeviceInfoGet(); + isConnected = 1; + } + else + { + serialDisconnect(); + } +} + +void Widget::on_btnReset_clicked() +{ + sendMsgDeviceReset(); + serialDisconnect(); +} + + +// 获取所有串口信息 +void Widget::on_btnRefresh_clicked() +{ + ui->comboPort->clear(); + const auto infos = QSerialPortInfo::availablePorts(); + for (const QSerialPortInfo &info : infos) + { + ui->comboPort->addItem(info.portName()); + } +} + +void Widget::on_configButton_clicked() +{ + /* 配置设备信息按钮 */ + QStringList list; + + /* 获取信息. */ + stringToChar(ui->devNameEdit->text(), reinterpret_cast(clientDevInfo.name), DEV_NAME_LEN); + clientDevInfo.typeM = 1; + if (ui->communicationTypeBox->currentIndex() == 0) + { + clientDevInfo.typeS = static_cast(ui->devTypeBox->currentIndex() + 1); + } + else + { + clientDevInfo.typeS = 4; + } + + clientDevInfo.id = ui->idEdit->text().toUInt(nullptr, 16); + stringToChar(ui->csgIdEdit->text(), reinterpret_cast(clientDevInfo.csgId), 8); + clientDevInfo.csgVersion = ui->csgVersionEdit->text().toUShort(nullptr, 16); + stringToChar(ui->factoryDateEdit->text(), reinterpret_cast(clientDevInfo.factoryTime), DEV_COMPILE_TIME_LEN); + stringToChar(ui->hwVersionEdit->text(), reinterpret_cast(clientDevInfo.hardwareVersion), DEV_VERSION_STR_LEN); + + list = ui->macEdit->text().split(":"); + for(int i = 0; i < list.size(); i++) + { + clientDevInfo.mac[i] = static_cast(list[i].toInt(nullptr, 16)); + } + + list = ui->ipEdit->text().split("."); + for(int i = 0; i < list.size(); i++) + { + clientDevInfo.ip[i] = static_cast(list[i].toInt()); + } + + list = ui->maskEdit->text().split("."); + for(int i = 0; i < list.size(); i++) + { + clientDevInfo.ipMask[i] = static_cast(list[i].toInt()); + } + + list = ui->gwEdit->text().split("."); + for(int i = 0; i < list.size(); i++) + { + clientDevInfo.ipGw[i] = static_cast(list[i].toInt()); + } + + list = ui->serverEdit->text().split("."); + for(int i = 0; i < list.size(); i++) + { + clientDevInfo.serverIp[i] = static_cast(list[i].toInt()); + } + + list = ui->serverWIEdit->text().split("."); + for(int i = 0; i < list.size(); i++) + { + clientDevInfo.wirelessServerIp[i] = static_cast(list[i].toInt()); + } + + clientDevInfo.serverPort = ui->serverPortEdit->text().toUShort(); + clientDevInfo.wirelessServerPort = ui->serverWIPortEdit->text().toUShort(); + + qulonglong temp = ui->cardEdit->text().toULongLong(nullptr, 16); + qulonglong divisor = 1; + for(int i = 5; i >= 0; i--) + { + clientDevInfo.csgCard[i] = (temp / divisor) & 0xff; + divisor = divisor * 0x100; + + if (0 == i) + { + clientDevInfo.csgCard[i] |= 0xf0; + } + } + + /* 下发配置. */ + sendMsgDeviceInfoSet(); +} + +void Widget::on_defaultButton_clicked() +{ + sendMsgDeviceCfgDefault(); +} + +void Widget::on_fileButton_clicked() +{ + /* 选择文件按钮. */ + QString Path; + QString curPath; + + /* 获取目录. */ + if (filePath.isEmpty()) + { + curPath = QCoreApplication::applicationDirPath(); + } + else + { + QFileInfo fileinfo = QFileInfo(filePath); + curPath = fileinfo.path(); + } + + /* 记录文件路径. */ + Path = QFileDialog::getOpenFileName(this, "Select Bin File", curPath, "*.bin"); + if (Path.isEmpty()) + { + return; + } + + /* 保存文件路径. */ + filePath = Path; + QFileInfo fileinfo = QFileInfo(filePath); + ui->fileNameEdit->setText(fileinfo.fileName()); + settings->setValue("updateFile", filePath); +} + +void Widget::on_updateButton_clicked() +{ + int fileType = DEBUG_C_UPDATE_APP; + /* 关闭按钮. */ + buttonEnable(false); + + /* 开始升级. */ + //work->fileNameSet(filePath); + qDebug() << "filePath:" << filePath << endl; + QFileInfo fileInfo(filePath); + QString temp; + upFileSize = fileInfo.size(); + upFileRecvSize = 0; + temp.sprintf("%d / %lld", upFileRecvSize, upFileSize); + ui->upFileSizeLabel->setText(temp); + + /* 保存文件类型索引. */ + settings->setValue("updateFileType", ui->fileTypeBox->currentIndex()); + + upPackIndex = 0; + if (ui->fileTypeBox->currentText() == "APP") + { + fileType = DEBUG_C_UPDATE_APP; + } + else + { + fileType = DEBUG_C_UPDATE_IAP; + } + + sendMsgDeviceUpdate(fileType); +} + + +void Widget::on_configSetButton_clicked() +{ + + if (0 == ui->debugModeBox->currentIndex()) + { + MONITOR_BITMAP_SET(clientDevConfig.flag, DEV_FLAG_CLI); + } + else + { + MONITOR_BITMAP_RESET(clientDevConfig.flag, DEV_FLAG_CLI); + } + + if (1 == ui->workModeBox->currentIndex()) + { + MONITOR_BITMAP_SET(clientDevConfig.flag, DEV_FLAG_ADJ); + MONITOR_BITMAP_RESET(clientDevConfig.flag, DEV_FLAG_FACTORY); + } + else if (2 == ui->workModeBox->currentIndex()) + { + MONITOR_BITMAP_RESET(clientDevConfig.flag, DEV_FLAG_ADJ); + MONITOR_BITMAP_SET(clientDevConfig.flag, DEV_FLAG_FACTORY); + } + else + { + MONITOR_BITMAP_RESET(clientDevConfig.flag, DEV_FLAG_ADJ); + MONITOR_BITMAP_RESET(clientDevConfig.flag, DEV_FLAG_FACTORY); + } + + clientDevConfig.energyMode = static_cast(ui->energyModeBox->currentIndex()); + clientDevConfig.normalSleep = static_cast(ui->normalSleepBox->currentIndex()); + memset(clientDevConfig.APN, 0, DEV_APN_LEN); + //stringToChar(ui->APNEdit->text(), reinterpret_cast(clientDevConfig.APN_long), DEV_APN_LEN_LONG); + + clientDevConfig.collectInterval = ui->colIntervalEdit->text().toUShort(); + clientDevConfig.waveInterval = ui->waveIntervalEdit->text().toUShort(); + clientDevConfig.collectThreshold = ui->colThresholdEdit ->text().toUShort(); + clientDevConfig.waveThreshold = ui->waveThresholdEdit->text().toUShort(); + clientDevConfig.mainCable = static_cast(ui->mainCableIdEdit->text().toUShort()); + + clientDevConfig.isVoltageCol = ui->voltageColBox->isChecked(); + clientDevConfig.isTempCol = ui->tempColBox->isChecked(); + clientDevConfig.isWaveCol = ui->waveColBox->isChecked(); + + clientDevConfig.sensor_id[0] = static_cast(ui->sensor1IdEdit->text().toUInt()); + clientDevConfig.sensor_id[1] = static_cast(ui->sensor2IdEdit->text().toUInt()); + clientDevConfig.sensor_id[2] = static_cast(ui->sensor3IdEdit->text().toUInt()); + clientDevConfig.sensor_id[3] = static_cast(ui->sensor4IdEdit->text().toUInt()); + clientDevConfig.sensor_id[4] = static_cast(ui->sensor5IdEdit->text().toUInt()); + clientDevConfig.sensor_id[5] = static_cast(ui->sensor6IdEdit->text().toUInt()); + clientDevConfig.sensor_id[6] = static_cast(ui->sensor7IdEdit->text().toUInt()); + clientDevConfig.sensor_id[7] = 0; + + /* 下发配置. */ + sendMsgDeviceConfigSet(); +} + + +void Widget::on_configGetButton_clicked() +{ + sendMsgDeviceConfigGet(); +} + +void Widget::on_csgConfigGetButton_clicked() +{ + sendMsgDeviceCsgConfigGet(); +} + +void Widget::on_csgConfigSetButton_clicked() +{ + stringToChar(ui->passwdEdit->text(), reinterpret_cast(csgConfig.passwd), CSG_PASSWD_LEN); + csgConfig.beatInterval = static_cast(ui->beatIntervalEdit->text().toUInt()); + csgConfig.collectInterval = static_cast(ui->csgColIntervalEdit->text().toUInt()); + csgConfig.sleepTime = static_cast(ui->sleepTimeEdit->text().toUInt()); + csgConfig.onlineTime = static_cast(ui->onlineTimeEdit->text().toUInt()); + QStringList list = ui->resetTimeEdit->text().split(":"); + for(int i = 0; i < list.size(); i++) + { + csgConfig.resetTime[i] = static_cast(list[i].toUInt()); + } + stringToChar(ui->ciphertextEdit->text(), reinterpret_cast(csgConfig.ciphertext), CSG_CIPHERTEXT_LEN); + qDebug() << "passwd:" << csgConfig.passwd << endl; + qDebug() << "beatInterval:" << csgConfig.beatInterval << endl; + qDebug() << "collectInterval:" << csgConfig.collectInterval << endl; + qDebug() << "sleepTime:" << csgConfig.sleepTime << endl; + qDebug() << "onlineTime:" << csgConfig.onlineTime << endl; + qDebug() << "resetTime:" << csgConfig.resetTime << endl; + qDebug() << "ciphertext:" << csgConfig.ciphertext << endl; + + /* 下发配置. */ + sendMsgDeviceCsgConfigSet(); +} + + +void Widget::on_dataRefreshButton_clicked() +{ + sendMsgDeviceRealDataGet(); +} + +void Widget::on_dataRefreshAutoButton_clicked() +{ + if (isDataRefresh) + { + isDataRefresh = false; + ui->dataRefreshAutoButton->setText("自动刷新"); + buttonEnable(true); + + } + else + { + buttonEnable(false); + ui->dataRefreshAutoButton->setEnabled(true); + ui->dataRefreshAutoButton->setText("停止刷新"); + isDataRefresh = true; + sendMsgDeviceRealDataGet(); + } +} + +void Widget::on_stateRefreshButton_clicked() +{ + sendMsgDeviceStateGet(); +} + +void Widget::on_freChBox_currentIndexChanged(int index) +{ + /* 工频数据通道选择按钮. */ + Q_UNUSED(index); + uiPowerFrequencyRefresh(); +} + +void Widget::on_freRefreshButton_clicked() +{ + /* 刷新工频数据. */ + freIndex = 0; + QString temp; + temp.sprintf("%d / 10", freIndex); + ui->upFreIndexLabel->setText(temp); + sendMsgDevicePowerFrequencyGet(); + + /* 关闭按钮. */ + buttonEnable(false); + + settings->setValue("freChIndex", ui->freChBox->currentIndex()); +} + + +void Widget::on_waveColButton_clicked() +{ + sendMsgWaveCol(); +} + +void Widget::on_waveRefreshButton_clicked() +{ + sendMsgDeviceStateGet(); +} + +void Widget::on_waveCalButton_clicked() +{ + uint16_t param = static_cast((ui->waveMaxEdit->text().toInt() - ui->waveMinEdit->text().toInt()) / 5) - 50; + ui->waveParamEdit->setText(QString::number(param)); + + /* 刷新实时数据按钮. */ + +} + + +void Widget::on_stateLogButton_clicked() +{ + if (is_log_up) + { + is_log_up = false; + ui->stateLogButton->setText("下载 Log"); + //work->stateSet(CM_usart::WS_IDLE); + buttonEnable(true); + } + else + { + logIndex = 0; + QString temp; + temp.sprintf("0 / %d", ui->stateLogEdit->text().toInt()); + logSum = ui->stateLogEdit->text().toInt(); + ui->logTextEdit->clear(); + ui->logIndexLabel->setText(temp); + //work->multipleIndexSet(0); + //work->stateSet(CM_usart::WS_LOG_GET); + sendMsgLogGet(); + + /* 关闭按钮. */ + buttonEnable(false); + ui->stateLogButton->setEnabled(true); + + is_log_up = true; + ui->stateLogButton->setText("暂停 Log"); + } +} + + +void Widget::on_historyDataButton_clicked() +{ + if (is_data_up) + { + is_data_up = false; + ui->historyDataButton->setText("下载数据"); + //work->stateSet(CM_usart::WS_IDLE); + buttonEnable(true); + } + else + { + dataIndex = 0; + QString temp; + temp.sprintf("0 / %d", ui->historyDataEdit->text().toInt()); + historyDataSum = ui->historyDataEdit->text().toInt(); + ui->dataIndexLabel->setText(temp); + sendMsgHistoryDataGet(); + + int row = ui->historyDataTable->rowCount(); + if (row > 0) + { + for(int i = 0; i < row; i++) + { + for(int j = 0; j < ui->historyDataTable->columnCount(); j++) + { + delete ui->historyDataTable->item(row - i - 1, j); + } + qDebug() << row - i - 1; + ui->historyDataTable->removeRow(row - i - 1); + } + } + + /* 关闭按钮. */ + buttonEnable(false); + ui->historyDataButton->setEnabled(true); + + is_data_up = true; + ui->historyDataButton->setText("暂停数据"); + } +} + + +void Widget::on_waveButton_clicked() +{ + if (is_wave_up) + { + is_wave_up = false; + ui->waveButton->setText("下载高频数据"); + buttonEnable(true); + } + else + { + QString curPath; + if (waveFilePath.isEmpty()) + { + curPath = QCoreApplication::applicationDirPath(); + } + else + { + QFileInfo info = QFileInfo(waveFilePath); + curPath = info.path(); + } + + curPath.append("/wavefile.wave"); + QString path = QFileDialog::getSaveFileName(this, tr("下载高频数据文件"), curPath, tr("data(*.*)")); + if (path.isNull() || path.isEmpty()) + { + QMessageBox::information(this, tr("提示"), tr("下载高频数据文件失败")); + return; + } + else + { + waveFilePath = path; + settings->setValue("waveFile", waveFilePath); + } + + QString temp; + temp.sprintf("%d / 8000", waveIndex); + ui->upWaveIndexLabel->setText(temp); + waveIndex = 0; + + /* 关闭按钮. */ + buttonEnable(false); + ui->waveButton->setEnabled(true); + + is_wave_up = true; + ui->waveButton->setText("暂停高频数据"); + } +} + + +void Widget::on_manualRatioSetButton_clicked() +{ + /* 获取参数. */ + for(int i = 0; i < ui->adjustTable->rowCount(); i++) + { + clientAdjInfo.ADCRatio[i] = ui->adjustTable->item(i, 2)->text().toUShort(); + clientAdjInfo.ADC_turns[i] = static_cast(ui->adjustTable->item(i, 3)->text().toUShort()); + for(int j = 0; j < DAU_POWER_ADJ_CNT ; j++) + { + clientAdjInfo.ADCBase_elec[i][j] = ui->adjustTable->item(i, 4 + j * 3)->text().toUInt(); + } + + } + clientAdjInfo.vin_adj = ui->vinEdit->text().toUShort(); + clientAdjInfo.vin = ui->vinAdjEdit->text().toUShort(); + + /* 下发配置. */ + sendMsgDeviceAdjustInfoSet(); + + uiManualAdjustRefresh(); +} + + +void Widget::on_manualAdjBox_activated(int index) +{ + if (index < 10) + { + uiManualAdjustRefresh(); + } +} + +void Widget::on_manualAdjButton_clicked() +{ + adjSet adj; + + memset(&adj, 0, sizeof(adjSet)); + + /* 获取校准通道. */ + for(int32_t i = 0; i < ui->adjustTable->rowCount(); i++) + { + QCheckBox *checkBox = reinterpret_cast(ui->adjustTable->cellWidget(i, 0)); + if (checkBox->isChecked()) + { + adj.chSelecet |= 1 << i; + } + } + + adj.manualIndex = static_cast(ui->manualAdjBox->currentIndex()); + + /* 下发配置. */ + buttonEnable(false); + sendMsgDeviceAdjustMode(DEBUG_PRV_ADJ_MANUAL, &adj); +} + + +void Widget::on_RatioParamGetButton_clicked() +{ + QString fileWritePath; + fileWritePath.append(QCoreApplication::applicationDirPath() + "/adjParam.bin"); + QFile file_write(fileWritePath); + if (!file_write.open(QIODevice::WriteOnly)) + { + QMessageBox::warning(this, "WARNING", "文件 " + fileWritePath + " 创建失败!", QMessageBox::Ok); + return; + } + + QDataStream out(&file_write); + + /* 获取参数. */ + for(int i = 0; i < ui->adjustTable->rowCount(); i++) + { + clientAdjInfo.ADCRatio[i] = ui->adjustTable->item(i, 2)->text().toUShort(); + clientAdjInfo.ADC_turns[i] = static_cast(ui->adjustTable->item(i, 3)->text().toUShort()); + for(int j = 0; j < DAU_POWER_ADJ_CNT ; j++) + { + clientAdjInfo.ADCBase_elec[i][j] = ui->adjustTable->item(i, 4 + j * 3)->text().toUInt(); + clientAdjInfo.ADCBase[i][j] = ui->adjustTable->item(i, 5 + j * 3)->text().toFloat(); + clientAdjInfo.ADCAdj[i][j] = ui->adjustTable->item(i, 6 + j * 3)->text().toUShort(); + } + } + clientAdjInfo.vin_adj = ui->vinEdit->text().toUShort(); + clientAdjInfo.vin = ui->vinAdjEdit->text().toUShort(); + + out.writeRawData(reinterpret_cast(&clientAdjInfo), sizeof(dev_adj_t)); + file_write.close(); + QMessageBox::information(this, "SUCCEED", "校准系数文件 " + fileWritePath + " 导出完成.", QMessageBox::Ok); +} + +void Widget::on_RatioParamSetButton_clicked() +{ + QString Path; + QString curPath = QCoreApplication::applicationDirPath(); + dev_adj_t tempAdj; + if (adjFilePath.isEmpty()) + { + curPath = QCoreApplication::applicationDirPath(); + } + else + { + QFileInfo fileinfo = QFileInfo(adjFilePath); + curPath = fileinfo.path(); + } + + Path = QFileDialog::getOpenFileName(this, "Select adj param File", curPath, "*.bin"); + if (Path.isEmpty()) + { + return; + } + + adjFilePath = Path; + settings->setValue("adjFile", adjFilePath); + + QFile file_read(adjFilePath); + if (!file_read.open(QIODevice::ReadOnly)) + { + QMessageBox::warning(this, "WARNING", "文件 " + adjFilePath +" 打开失败!", QMessageBox::Ok); + return; + } + + QDataStream in(&file_read); + + int len = in.readRawData(reinterpret_cast(&tempAdj), sizeof(dev_adj_t)); + if (len != sizeof(dev_adj_t)) + { + file_read.close(); + QMessageBox::warning(this, "WARNING", "文件 " + adjFilePath +" 读取失败!", QMessageBox::Ok); + return; + } + + file_read.close(); + + QString temp; + memcpy(&clientAdjInfo, &tempAdj, sizeof(dev_adj_t)); + for(int i = 0; i < ui->adjustTable->rowCount(); i++) + { + ui->adjustTable->item(i, 2)->setText(QString::number(clientAdjInfo.ADCRatio[i])); + ui->adjustTable->item(i, 3)->setText(QString::number(clientAdjInfo.ADC_turns[i])); + for(int j = 0; j < DAU_POWER_ADJ_CNT; j++) + { + ui->adjustTable->item(i, j * 3 + 4)->setText(QString::number(clientAdjInfo.ADCBase_elec[i][j])); + temp.sprintf("%.1f", static_cast(clientAdjInfo.ADCBase[i][j])); + ui->adjustTable->item(i, j * 3 + 5)->setText(temp); + ui->adjustTable->item(i, j * 3 + 6)->setText(QString::number(clientAdjInfo.ADCAdj[i][j])); + } + } + + ui->vinEdit->setText(QString::number(clientAdjInfo.vin_adj)); + ui->vinAdjEdit->setText(QString::number(clientAdjInfo.vin)); + + /* 下发配置. */ + sendMsgDeviceAdjustInfoSet(); +} + +void Widget::on_ratioSetButton_clicked() +{ + uint16_t ratio = 0; + + /* 获取参数. */ + for(int i = 0; i < ui->adjustTable->rowCount(); i++) + { + ratio = ui->adjustTable->item(i, 2)->text().toUShort(); + if (40 == ratio) + { + ui->adjustTable->item(i, 4)->setText(QString::number(1000)); + ui->adjustTable->item(i, 7)->setText(QString::number(2000)); + ui->adjustTable->item(i, 10)->setText(QString::number(5000)); + ui->adjustTable->item(i, 13)->setText(QString::number(10000)); + ui->adjustTable->item(i, 16)->setText(QString::number(30000)); + } + else if(60 == ratio) + { + ui->adjustTable->item(i, 4)->setText(QString::number(1000)); + ui->adjustTable->item(i, 7)->setText(QString::number(2000)); + ui->adjustTable->item(i, 10)->setText(QString::number(5000)); + ui->adjustTable->item(i, 13)->setText(QString::number(10000)); + ui->adjustTable->item(i, 16)->setText(QString::number(30000)); + } + else if(200 == ratio) + { + ui->adjustTable->item(i, 4)->setText(QString::number(1000)); + ui->adjustTable->item(i, 7)->setText(QString::number(3000)); + ui->adjustTable->item(i, 10)->setText(QString::number(10000)); + ui->adjustTable->item(i, 13)->setText(QString::number(30000)); + ui->adjustTable->item(i, 16)->setText(QString::number(100000)); + } + else if(400 == ratio) + { + ui->adjustTable->item(i, 4)->setText(QString::number(1000)); + ui->adjustTable->item(i, 7)->setText(QString::number(10000)); + ui->adjustTable->item(i, 10)->setText(QString::number(50000)); + ui->adjustTable->item(i, 13)->setText(QString::number(100000)); + ui->adjustTable->item(i, 16)->setText(QString::number(200000)); + } + else if(1000 == ratio) + { + ui->adjustTable->item(i, 4)->setText(QString::number(5000)); + ui->adjustTable->item(i, 7)->setText(QString::number(10000)); + ui->adjustTable->item(i, 10)->setText(QString::number(50000)); + ui->adjustTable->item(i, 13)->setText(QString::number(250000)); + ui->adjustTable->item(i, 16)->setText(QString::number(500000)); + } + } + + /* 获取参数. */ + for(int i = 0; i < ui->adjustTable->rowCount(); i++) + { + clientAdjInfo.ADCRatio[i] = ui->adjustTable->item(i, 2)->text().toUShort(); + clientAdjInfo.ADC_turns[i] = static_cast(ui->adjustTable->item(i, 3)->text().toUShort()); + for(int j = 0; j < DAU_POWER_ADJ_CNT ; j++) + { + clientAdjInfo.ADCBase_elec[i][j] = ui->adjustTable->item(i, 4 + j * 3)->text().toUInt(); + } + } + clientAdjInfo.vin_adj = ui->vinEdit->text().toUShort(); + clientAdjInfo.vin = ui->vinAdjEdit->text().toUShort(); + + /* 下发配置. */ + sendMsgDeviceAdjustInfoSet(); +} + +void Widget::on_adjButton_clicked() +{ + adjSet adj; + + memset(&adj, 0, sizeof(adjSet)); + + /* 获取校准通道. */ + for(int32_t i = 0; i < ui->adjustTable->rowCount(); i++) + { + QCheckBox *checkBox = reinterpret_cast(ui->adjustTable->cellWidget(i, 0)); + if (checkBox->isChecked()) + { + adj.chSelecet |= 1 << i; + + } + } + + if (ui->voltageAdjButtonBox->isChecked()) + { + adj.isVoltageSel = true; + } + + /* 下发配置. */ + buttonEnable(false); + sendMsgDeviceAdjustMode(DEBUG_PRV_ADJ_AUTO, &adj); +} + +void Widget::on_tabWidget_tabBarClicked(int index) +{ + qDebug() << "index" << index << endl; + if (index == 6) + { + uiAdjustInfoRefresh(); + } +} diff --git a/widget.h b/widget.h new file mode 100644 index 0000000..56373e8 --- /dev/null +++ b/widget.h @@ -0,0 +1,227 @@ +#ifndef WIDGET_H +#define WIDGET_H + +#include +#include +#include +#include +#include +#include "common.h" + +namespace Ui { //新增的 + class form; +} + + +#define USART_BUF_SIZE 1088 + +/* 设置tableview某行/列不可编辑. */ +class ReadOnlyDelegate: public QItemDelegate +{ + +public: + ReadOnlyDelegate(QWidget *parent = nullptr):QItemDelegate(parent) + {} + + QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,const QModelIndex &index) const override; +}; + +class Widget : public QWidget +{ + Q_OBJECT + +public: + Widget(QWidget *parent = nullptr); + ~Widget(); +private slots: + void on_btnConn_clicked(); + + void on_btnReset_clicked(); + + void on_btnRefresh_clicked(); + + void on_configButton_clicked(); + + void on_defaultButton_clicked(); + + void on_fileButton_clicked(); + + void on_updateButton_clicked(); + + void on_configSetButton_clicked(); + + void on_configGetButton_clicked(); + + void on_csgConfigGetButton_clicked(); + + void on_csgConfigSetButton_clicked(); + + void on_dataRefreshButton_clicked(); + + void on_dataRefreshAutoButton_clicked(); + + void on_stateRefreshButton_clicked(); + + void on_freChBox_currentIndexChanged(int index); + + void on_freRefreshButton_clicked(); + + void on_waveColButton_clicked(); + + void on_waveRefreshButton_clicked(); + + void on_waveCalButton_clicked(); + + void on_historyDataButton_clicked(); + + void on_stateLogButton_clicked(); + + void on_waveButton_clicked(); + + void on_manualRatioSetButton_clicked(); + + void on_manualAdjBox_activated(int index); + + void on_manualAdjButton_clicked(); + + void on_RatioParamGetButton_clicked(); + + void on_RatioParamSetButton_clicked(); + + void on_ratioSetButton_clicked(); + + void on_adjButton_clicked(); + + void on_tabWidget_tabBarClicked(int index); + +private: + + QString toHexadecimal(const QByteArray &byteArray); + int searchUsablePort(); + void serialErrHandle(QSerialPort::SerialPortError error); + void serialDisconnect(); + int initSerial(); + int deinitSerial(); + int readData(); + int writeData(char *buf, int len); + + int protoHeaderInit(proto_head_t * header, uint16_t len, uint32_t id, uint8_t cmd_type, uint8_t cmd); + + void buttonEnable(bool flag); + + QString devStateWaveStateGet(uint8_t state); + + QString devStateWlStateGet(uint8_t state); + void uiDevInfoRefresh(); + void uiDevConfigRefresh(); + void uiDevCsgConfigRefresh(); + void uiDevRealDataRefresh(); + + void uiDevStateRefresh(); + + void uiPowerFrequencyRefresh(); + + void uiManualAdjustRefresh(); + + void uiAdjustInfoRefresh(); + + void protoContact(char *data); + + void protoConfig(char *data); + + void protoCsgConfig(char *data); + + void protoRealdata(char *data); + + int protoUpdateReply(char *data, int fileType); + + int protoWaveDataUploadReply(char *data); + + int protoPowerFrequency(char *data); + + int protoState(char *data); + + int protoManualAdjust(char *data); + + int protoAutoAdjust(char *data); + + int protoAdjustInfoGet(char *data); + + int protoLog(char * data); + + int protoHistoryData(char *data); + + int paraseProtocols(char *data); + int snedMsgDeviceInfoGet(); + int sendMsgDeviceInfoSet(); + int sendMsgDeviceReset(); + int sendMsgDeviceCfgDefault(); + int sendMsgDeviceConfigSet(); + int sendMsgDeviceConfigGet(); + int sendMsgDeviceCsgConfigGet(); + int sendMsgDeviceCsgConfigSet(); + int sendMsgDeviceRealDataGet(); + int sendMsgDeviceUpdate(int fileType); + int sendMsgDeviceWaveDataGet(); + + int sendMsgDeviceStateGet(); + + int sendMsgDevicePowerFrequencyGet(); + + int sendMsgDeviceAdjustInfoGet(); + + int sendMsgDeviceAdjustInfoSet(); + + int sendMsgDeviceAdjustMode(uint8_t cmd, adjSet *param); + + int sendMsgWaveCol(); + + int sendMsgWaveCal(); + + int sendMsgLogGet(); + + int sendMsgHistoryDataGet(); + + Ui::form *ui; //新增的 + QSerialPort *serialPort; + QSettings *settings; + QString filePath; + QString adjFilePath; + QString waveFilePath; + //QThread *newTask; + //Protocol *usartProtocol; + + char rxbuf[USART_BUF_SIZE]; + int rxbufLen; + + devInfo clientDevInfo; + devConfig clientDevConfig; + csgConfig_t csgConfig; + realData_t clientRealData; + devState clientDevState; + dev_adj_t clientAdjInfo; + adjSet clientAdjSet; + QString energyMode[4]; + int isConnected; // serial connect state + int64_t upFileSize; + uint32_t upFileRecvSize; + uint32_t upPackIndex; + int isDataRefresh; + int16_t powerFre[CFG_ADC_CH_CNT][ADC_COLLECT_CNT]; + uint32_t freIndex; + uint32_t waveIndex; + uint16_t waveParam; + uint8_t is_wave_up; + uint8_t is_log_up; + uint32_t logIndex; + uint8_t is_data_up; + uint32_t dataIndex; + int32_t logSum; + int32_t historyDataSum; + + + ReadOnlyDelegate* readOnlyDelegate; +}; + + +#endif // WIDGET_H