You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PayloadAPP/Src/GDDC/gddcStateInfo.h

71 lines
1.7 KiB
C

#ifndef GDDCSTATEINFO_H
#define GDDCSTATEINFO_H
#include "basetsd.h"
#include <QByteArray>
#include <QHeaderView>
#include <QHostAddress>
#include <QMouseEvent>
#include <QNetworkDatagram>
#include <QStandardItemModel>
#include <QTimer>
#include <QUdpSocket>
#include <QWidget>
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;
/*数据校验
*
*
* 12
*/
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