| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- /*************************************************
- /* Copyright (C), 2010-2011,StoneU. Co., Ltd.
- /* File name: leicai.h
- /* Author: Zero.t
- /* Version: Ver1.0.0.1
- /* Date: 2011-12-05
- /* Description: 镭彩科技带大显示屏温湿度;
- /* Others: RS232,2400/8/1,无校验;
- /* Function List: ###
- /* History:
- /* 特别说明: 该协议 项目:上海 捷明信息
- *************************************************/
- #ifndef _LEICAI_UPS_HEAD__
- #define _LEICAI_UPS_HEAD__
- #pragma once
- #include "CommInterface.h"
- class leicai:public CCommInterface
- {
- public:
- enum __ERRO_CODE_UPSSANTAK
- {
- ERR_CODE_LEICAI_COM_FAULT = 50201 , //设备串口通信故障
- ERR_CODE_LEICAI_COM_BUSY , //设备串口通信忙
- ERR_CODE_LEICAI_COM_READ_NO_DATA , //设备没有读到数据
- ERR_CODE_LEICAI_COM_READ_LEN_OVER , //设备读到数据长度超时限制
- ERR_CODE_LEICAI_COM_LRC_LOST , //设备lrc校验失败
- EER_CODE_LEICAI_COM_WRITE_DATA , //设备写串口错误
- EER_CODE_LEICAI_COM_REGNUM , //设备寄存器数
- ERR_CODE_LEICAI_COM_VARLEN , //设备变量长度非法
- ERR_CODE_LEICAI_COM_INVALIDRES , //设备无效应答
- };
- #define DEBUG_LEICAI 1
- public:
- leicai(char *szPath,char *szIniName,int nCommPort,int nAddr,int nRate,int nDataBit,int nStopBit,int nParity,int nInterval);
- ~leicai(void);
- BOOL leicaiOpenComm(int nCommPort, int nAddr, int nRate, int nDataBit, int nStopBit, int nParity, int nInterval);
- int SendReadRequest(
- char *szPath, // 程序所在路径
- char *szIniName, // 配置文件名称
- int nCommPort, // 串行端口
- int nAddr, // 设备地址
- char *szCmd, // 请求命令
- char *szMsg, // 响应的值
- int nReversed1, // 预留整形参数1接口
- int nReversed2, // 预留整形参数2接口
- int nReversed3, // 预留整形参数3接口
- int nReversed4, // 预留整形参数4接口
- int nReversed5, // 预留整形参数5接口
- float fReversed1, // 预留float参数1接口
- float fReversed2, // 预留float参数2接口
- float fReversed3, // 预留float参数3接口
- char *szReversed1, // 预留字符数组参数1接口
- char *szReversed2, // 预留字符数组参数2接口
- char *szReversed3, // 预留字符数组参数3接口
- char *szReversed4, // 预留字符数组参数4接口
- char *szReversed5 // 预留字符数组参数5接口
- );
- // 发送设置设备参数请求
- int SendSetReuest(
- char *szPath, // 程序所在路径
- char *szIniName, // 配置文件名称
- int nCommPort, // 串行端口
- int nAddr, // 设备地址
- char *szCmd, // 请求命令
- char *szSetMsg, // 设置的值
- int nReversed1, // 预留整形参数1接口
- int nReversed2, // 预留整形参数2接口
- int nReversed3, // 预留整形参数3接口
- int nReversed4, // 预留整形参数4接口
- int nReversed5, // 预留整形参数5接口
- float fReversed1, // 预留float参数1接口
- float fReversed2, // 预留float参数2接口
- float fReversed3, // 预留float参数3接口
- char *szReversed1, // 预留字符数组参数1接口
- char *szReversed2, // 预留字符数组参数2接口
- char *szReversed3, // 预留字符数组参数3接口
- char *szReversed4, // 预留字符数组参数4接口
- char *szReversed5 // 预留字符数组参数5接口
- );
- protected:
- int GetDeviceParam( int nAddr,CCommProcess *pComm,char *IniSendCMD,const int &IniSendlen);
- int Send_ReadDeviceData(int nAddr,CCommProcess *pComm, const char *IniSendCMD,const int &IniSendlen);
- int Recv_ReadDeviceData(int nAddr,CCommProcess *pComm,char *szSendCMD);
-
- int SetDeviceParam( int nAddr,CCommProcess *pComm,char *szCmd,char *szSetMsg,char *szRecvMsg,char *IniSendCMD, const int &IniSendlen);
- int Send_WriteDeviceData(int naddr, CCommProcess *pComm, char *szCmd, char *szSetMsg, char *IniSendCMD, const int &IniSendlen );
- int Recv_WriteDeviceData(int nAddr, CCommProcess *pComm, char *szCmd, char *szRecvMsg );
- private:
- int Getleicai_Msg( int nAddr,char *szSendCMD, char *szMsg,int &nIndex,int &nLen,char *szType,int startBit,int endBit );
- void Setleicai_Msg( int nAddr, char *szSendCMD, char *pBuffer);
- void GetSystemTime(BYTE *szSystemTime);
- void SimulationCommData();
- int StrLower(char *pSource, char *pDest);
- private:
- BOOL m_dwOnlineTick[MAX_ADDR];
- BOOL m_devOnline[MAX_ADDR];
- HANDLE m_hSemComm;
- CRITICAL_SECTION m_csReadMsg;
- char m_sz_Msg[MAX_ADDR][MAX_RECE_MSG];
- };
- #endif
|