#ifndef TOOLFUNC_H
#define TOOLFUNC_H
#include "define.h"
#include <QString>
#include <QByteArray>
#include <QString>
#include <QLabel>
#include <QWidget>
#include <QPushButton>
#include <QToolButton>
#ifdef  TOOLFUNC_C
#define TOOLFUNC_TEMP
#else
#define TOOLFUNC_TEMP extern
#endif

class ToolFunc
{
public:
    typedef union noneTYPE32DATABYTE
    {
      struct{
         INT32U onebyte0:8;
         INT32U onebyte1:8;
         INT32U onebyte2:8;
         INT32U onebyte3:8;
         }onebyte;
      struct{
         INT8U onebyte_4_0:4;
         INT8U onebyte_4_1:4;
         INT8U onebyte_4_2:4;
         INT8U onebyte_4_3:4;
         INT8U onebyte_4_4:4;
         INT8U onebyte_4_5:4;
         INT8U onebyte_4_6:4;
         INT8U onebyte_4_7:4;
         }fourBit;
        INT32U One32data;
        FP32   FP32data;
        INT8U  arrdata[4];
      }TYPE32DATABYTE;
    typedef union noneTYPE2BYTE
    {
      struct{
         INT8U onebyte0; //低位
         INT8U onebyte1;   //高位
         }TwoByte;
        INT16U OneINT;
      }TYPE2BYTE;
public:
   static void shutDown(void);//退出程序
   static INT16U crc16(INT8U *puchMsg, INT16U usDataLen);
   static void charArrCopy(INT8S *des, INT8S *src, INT32U length);
   static void charArrCopy(INT8U* des ,INT8U* src,INT32U length );
   static void ByteArrayTocharArrCopy(INT8S *des, QByteArray src, INT32S length);
   static void ByteArrayTocharArrCopy(INT8U *des, QByteArray src, INT32S length);
   static void charArrToByteArrayCopy(QByteArray& des ,INT8S* src,INT32S length );
   static void charArrToByteArrayCopy(QByteArray& des ,INT8U* src,INT32S length );
   static QString hexToString(INT8U *in, INT32S len);
   static QString hexToStringDIS(INT8S *in, INT32S len);
   static QString charArrToByteArrayCopy(QByteArray& des);
   static void charArrdataInit(INT8U *RamDataSE,INT8U setData, INT32U length);
   static INT32S QStringToGB2312Chars(QString str,INT8U *GB2312Chars,INT32S MaxLen);
   static void GB2312CharsToQString(INT8U *GB2312Chars,QString &str);
   static void GB2312Chars_ConstToQString(const INT8U *GB2312Chars,QString &str);
   static INT32U CharsLength(INT8U *charsdata);
   static INT32U QStringToGB2312Length(QString str);
   static void Numtochars(INT32U Uldata,INT8U *Datachars,INT8U length);
   static void longdataTochars(INT32U Uldata,INT8U *Datas);
   static void CharsMoveRight(INT8U *Datas,INT8U Length);
   static INT8U CharacterStringLength(INT8U *charsdata);
   static void CharsMoveLeft(INT8U *Datas);
   static INT32S fdata_to_SLdata(FP32 F_data);
   static void DatasToPointDatas(INT8U *Datas,INT8U point);
   static void DatasToClrPointDatas(INT8U *Datas,INT8U point);
   static void SLData_to_chars(INT32S SLdata,INT8U *Datas,INT8U length,INT8U point);
   static void SLData_to_charsPoint(INT32S SLdata,INT8U *Datas,INT8U length,INT8U point);
   static void SLData_to_chars_0(INT32S SLdata,INT8U *Datas,INT8U length,INT8U point);
   static void longdataTocharsLength(INT32U Uldata,unsigned char *Datas,INT8U length);
   static void longdataTocharsLengthWithSpace(INT32U Uldata,unsigned char *Datas,INT8U length);
   static FP32 absoluteDataTurn(FP32 F_data);
   static INT8U percentData(INT32U total,INT32U dataTemp);
   static INT32S floatToSlongWithDiag(FP32 F_data,INT8U diag);
   static void charSTurnCharsWithLength(INT8U *Datas,INT8U length);
   static INT8U AddCheckValue(INT8U *temps,INT8U length);

};


#endif // TOOLFUNC_H
