#ifndef GDDCSTATEINFO_H #define GDDCSTATEINFO_H #include "basetsd.h" #include #include #include #include #include #include #include #include #include namespace Ui { class GDDCStateInfo; } class GDDCStateInfo : public QWidget { Q_OBJECT public: explicit GDDCStateInfo(QWidget *parent = nullptr); ~GDDCStateInfo(); private: Ui::GDDCStateInfo *ui; public: void initParam(); // 初始化参数 public: // 设置TableView的几何位置 void setTableViewGeometry(int ax, int ay, int aw, int ah); QStandardItemModel *m_tableModel; /*数据校验 * 数据 * 数据长度 * 校验方式 1亦或,2和校验 */ bool checkdata(QByteArray, int, int); void UDPMessageReceive(QByteArray &, int); // udp数据接收 typedef union { float float_value; UINT8 uint8[4]; } packet_uint32_to_float; float m_uint32_to_float(UINT8 value4, UINT8 value3, UINT8 value2, UINT8 value1) { packet_uint32_to_float packet; UINT8 buf[4]; memset(buf, 0x00, sizeof(buf)); buf[0] = (UINT8)((value1) & 0xFF); buf[1] = (UINT8)((value2) & 0xFF); buf[2] = (UINT8)((value3) & 0xFF); buf[3] = (UINT8)((value4) & 0xFF); UINT32 uint32 = ((buf[0] << 24) & 0XFFFFFFFF) + ((buf[1] << 16) & 0XFFFFFF) + ((buf[2] << 8) & 0XFFFF) + buf[3]; for (UINT8 i = 0; i < 4; i++) { packet.uint8[i] = (UINT8)(uint32 >> (i * 8)); } // print("modbus_uint32_to_float uint32=%d, value1=%d; value2=%d; // float_value = %f;",uint32,value1,value2,packet.float_value); return packet.float_value; } }; #endif // GDDCSTATEINFO_H