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

72 lines
1.7 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#ifndef GDDCSTATEINFO_H
#define GDDCSTATEINFO_H
#include <QWidget>
#include <QUdpSocket>
#include <QHostAddress>
#include <QNetworkDatagram>
#include <QByteArray>
#include <QTimer>
#include <QMouseEvent>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <QHeaderView>
#include <QStandardItemModel>
#include "basetsd.h"
namespace Ui {
class GDDCStateInfo;
}
class GDDCStateInfo : public QWidget
{
Q_OBJECT
public:
explicit GDDCStateInfo(QWidget *parent = nullptr);
~GDDCStateInfo();
public:
Ui::GDDCStateInfo *ui;
public:
void initParam(); //初始化参数
public:
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