Global.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799
  1. #pragma once
  2. #include "stdafx.h"
  3. #include "struct.h"
  4. #include <windows.h>
  5. #include "ado.h"
  6. #include "BaseVar.h"
  7. #include "Device.h"
  8. #include "Client2SrvType.h"
  9. #include <list>
  10. #include "DevicesManager.h"
  11. using namespace std;
  12. extern int READ_VAR_ERROR_MAX;
  13. extern int g_nTryTimeLessToNotice;
  14. extern int g_nBlanceLessToNotice;
  15. extern char g_strDirectory[256];
  16. extern CStringArray g_strAllVideoFile;
  17. extern CString g_strVersion;
  18. extern float g_fBlance;
  19. //声光报警
  20. #define AWA_NUM_MAX 100
  21. extern int g_nDealAWAStatus;//处理声光报警状态 -1未初始化 0初始化 1在处理中 2处理完成 3新事件
  22. typedef struct
  23. {
  24. CString sDoSet;
  25. CString sDoStatus;
  26. int nAlarmData;
  27. int nResumeData;
  28. CStringArray SA;
  29. CString sPlanTime;
  30. int nStatus;//-1 没有初始化 0 没有声光报警 1 正在声光报警
  31. }AWA;
  32. extern AWA g_AWA[AWA_NUM_MAX];
  33. bool g_FunSetAWA();//触发/取消 声光报警
  34. int ProcessResWriteSingleVarData( CString sVarName,int iData );
  35. //结束 声光报警
  36. void g_FunReadAllIniName( CString strPath, CString strFileName, int nLayer );
  37. bool g_FunIniOK( CString sIniName );
  38. //DOG
  39. extern INT g_nUseTimeLimit; //是否超过使用期限
  40. extern INT g_nSlaveVersion; //版本子ID
  41. extern CString g_sPassDueInfo; //过期信息
  42. extern bool g_bSoftRegisterFileIsOfficial; //注册文件是正式版
  43. extern bool g_bGetBlanceReturn; //10086是否返回
  44. extern CRITICAL_SECTION g_csWrDataBase;//写日志和告警数据库操作
  45. #if 0
  46. extern CServerSocket* g_pTcpServer;
  47. #endif
  48. // 客户端在线Tick
  49. extern DWORD g_dwClientOnlineTick[MAX_CLIENT_NUM];
  50. //客户端数据
  51. extern INT g_nClientNum;
  52. //程序退出事件
  53. extern HANDLE g_hRunObject;
  54. extern CDevicesManager* g_pDevicesManager;
  55. //WatchServer
  56. extern CHAR g_strWatchServerIP[MAX_EQUIP_IP + 1];
  57. extern CHAR g_strWatchServerPort[MAX_PORT + 1];
  58. //Database
  59. extern CADODatabase* g_pADODatabase;
  60. extern CHAR g_strConnectString[MAX_PATH + 1];
  61. extern CHAR g_strDBType[MAX_SERVER_LENGTH + 1];
  62. extern CHAR g_strAccessFile[MAX_PATH_LENGTH + 1];
  63. extern CHAR g_strServerName[MAX_SERVER_LENGTH + 1];
  64. extern CHAR g_strDataBaseName[MAX_DATABASE_LENGTH + 1];
  65. extern CHAR g_strUserName[MAX_USER_LENGTH + 1];
  66. extern CHAR g_strPassword[MAX_PASSWORD_LENGTH + 1];
  67. //用户信息
  68. extern CHAR g_strLoginUserID[MAX_USER_LENGTH + 1];
  69. extern CHAR g_strLoginPwd[MAX_PASSWORD_LENGTH + 1];
  70. extern CHAR g_strDefaultUserID[MAX_USER_LENGTH + 1];
  71. extern CHAR g_strDefaultUserPwd[MAX_PASSWORD_LENGTH + 1];
  72. //操作提示
  73. extern CHAR g_strErrorDBDisConnection[MAX_ERROR_LEN + 1] ;
  74. extern CHAR g_strMsgDBConnectionSuccess[MAX_ERROR_LEN + 1];
  75. extern CHAR g_strErrorExecSql[MAX_ERROR_LEN + 1];
  76. //系统设置
  77. extern BOOL g_bEnableTimeLimited;
  78. extern INT g_iAutoRunSystem;
  79. //extern INT g_nSendSms;
  80. //extern INT g_nSendVoice;
  81. //extern INT g_nSendEmail;
  82. extern CHAR g_strLanguage[MAX_LANG_LENGTH + 1]; // 默认语言
  83. extern CHAR g_strNoticePre[MAX_SERVER_LENGTH + 1]; // 通知前辍
  84. extern INT g_nNoticeDelay; // 通知延时
  85. extern INT g_nEncryptionType; // 加密类型
  86. //日志
  87. //extern CHAR g_strDirectory[MAX_PATH_LENGTH + 1]; // 软件所在路径
  88. extern CHAR g_strAppName[MAX_PATH_LENGTH + 1]; // 软件名称
  89. extern CHAR g_strSummaryLogPath[MAX_PATH_LENGTH + 1]; // 日志存放目录
  90. extern INT g_nLogSaveTimes; // 日志保存月数
  91. //环境参数配置
  92. extern INT g_nLevelWav; // 语音通知级别
  93. extern INT g_nLevelSms; // 发送短信级别
  94. extern INT g_nLevelEmail; // 发送Email级别
  95. extern INT g_nLevelDevInterrupt; // 通讯中断级别
  96. extern INT g_nLevelDlg; // 本地报警提示框级别
  97. extern INT g_nLevelLocalWav; // 本地声音提示级别
  98. extern INT g_nDBRecordDate; // 数据库记录时间
  99. //Sms
  100. extern INT g_nSendSms; // 是否启动短信报警功能
  101. extern CHAR g_strSmsComPort[MAX_TEL_LENGTH + 1]; // 短信猫端口
  102. extern INT g_nSmsRate; // 串口波特率
  103. extern INT g_nSmsDataBit; // 数据位
  104. extern INT g_nSmsStopBit; // 停止位
  105. extern INT g_nSmsParity; // 检验位
  106. extern INT g_nSmsInterval; // 间隔时间
  107. extern INT g_nSmsLanguageTrans; // 是否需要繁简转换
  108. extern INT g_nSmsMaxChar; // 短信猫支持最大字符个数
  109. extern INT g_nSmsMakeCall; // 发送短信后,是否拔打电话提醒
  110. extern CHAR g_strSmsSMSC[MAX_TEL_LENGTH + 1]; // smsc号码
  111. extern INT g_nSmsTimOut; // 短信发送超时
  112. extern INT g_nSmsCallTimes; // 最大的短信发送次数
  113. //Email
  114. extern INT g_nSendEmail; // 是否启动Email报警功能
  115. extern CHAR g_strEmailSMTPSrv[MAX_MAILSERVER_LENGTH]; // SMTPServer地址
  116. extern INT g_nEmailSMTPPort; // SMTP端口
  117. extern INT g_nEmailIsNeed; // 是否需要身份验证
  118. extern CHAR g_strEmailUserAcc[MAX_USER_LENGTH]; // 用户名
  119. extern CHAR g_strEmailUserPwd[MAX_PASSWORD_LENGTH]; // 密码
  120. extern INT g_nEmailTimeOut; // 发送邮件超时
  121. extern CHAR g_strEmailFromAddr[MAX_MAILTO_LENGTH]; // 发信人Email地址
  122. extern CHAR g_strEmailSubject[MAX_EMAIL_LENGTH]; // Email标题
  123. extern INT g_nEmailCallTimes; // 最大的Email发送次数
  124. //语音通知
  125. extern INT g_nSendVoice; // 是否启动语音通知功能
  126. extern INT g_nNoticeCardType; // 板卡类型
  127. extern CHAR g_strNoticeTelPre[MAX_TEL_LENGTH + 1]; // 外线前缀
  128. extern INT g_nNoticeCallDelay; // 两次呼叫间隔时间
  129. extern INT g_nNoticeCallTimes; // 最大的呼叫次数
  130. //定时发送短信和电话参数配置
  131. extern INT g_nTimingEnable;
  132. extern INT g_nTimingWeeks;
  133. extern INT g_nTimingHours;
  134. extern INT g_nTimingMinutes;
  135. extern INT g_nTimingPreiods;
  136. //变量输出,特别为上海烟草局做的
  137. extern INT g_nOutputEnable;
  138. extern CHAR g_strOutputPath[MAX_PATH_LENGTH + 1]; // 输出内容存放路径
  139. extern CHAR g_strOutputFileName[MAX_PATH_LENGTH + 1]; // 输出内容存放路径
  140. extern CHAR g_strOutputClock[MAX_PATH_LENGTH + 1]; // 输出内容存放路径
  141. extern INT g_nOutputLineCount1;
  142. extern CHAR g_strOutputLine1[MAX_MSG_LENGTH + 1]; // 第一行
  143. extern INT g_nOutputLineCount2;
  144. extern CHAR g_strOutputLine2[MAX_MSG_LENGTH + 1]; // 第二行
  145. extern INT g_nOutputLineCount3;
  146. extern CHAR g_strOutputLine3[MAX_MSG_LENGTH + 1]; // 第三行
  147. extern INT g_nOutputLineCount4;
  148. extern CHAR g_strOutputLine4[MAX_MSG_LENGTH + 1]; // 第四行
  149. extern INT g_nOutputLineCount5;
  150. extern CHAR g_strOutputLine5[MAX_MSG_LENGTH + 1]; // 第五行
  151. extern INT g_nOutputLineCount6;
  152. extern CHAR g_strOutputLine6[MAX_MSG_LENGTH + 1]; // 第六行
  153. extern INT g_nOutputLineCount7;
  154. extern CHAR g_strOutputLine7[MAX_MSG_LENGTH + 1]; // 第七行
  155. extern INT g_nOutputLineCount8;
  156. extern CHAR g_strOutputLine8[MAX_MSG_LENGTH + 1]; // 第八行
  157. extern INT g_nOutputLineCount9;
  158. extern CHAR g_strOutputLine9[MAX_MSG_LENGTH + 1]; // 第九行
  159. extern INT g_nOutputLineCount10;
  160. extern CHAR g_strOutputLine10[MAX_MSG_LENGTH + 1]; // 第十行
  161. extern CHAR g_strOutputLineUid1[MAX_UID + 1];
  162. extern CHAR g_strOutputLineUid2[MAX_UID + 1];
  163. extern CHAR g_strOutputLineUid3[MAX_UID + 1];
  164. extern CHAR g_strOutputLineUid4[MAX_UID + 1];
  165. extern CHAR g_strOutputLineUid5[MAX_UID + 1];
  166. extern CHAR g_strOutputLineUid6[MAX_UID + 1];
  167. extern CHAR g_strOutputLineUid7[MAX_UID + 1];
  168. extern CHAR g_strOutputLineUid8[MAX_UID + 1];
  169. extern CHAR g_strOutputLineUid9[MAX_UID + 1];
  170. extern CHAR g_strOutputLineUid10[MAX_UID + 1];
  171. //是否启用Snmp参数配置
  172. extern INT g_nSnmpEnable;
  173. extern CHAR g_strSnmpOidRoot[MAX_OBJ_OID + 1];
  174. extern CHAR g_strSnmpIP[MAX_EQUIP_IP + 1];
  175. extern CHAR g_strSnmpField[MAX_EQUIP_DESC + 1];
  176. //资源字符串
  177. extern CString g_strServiceName;
  178. extern CString g_strHintSysRun;
  179. extern CString g_strHintAlarmWelcome;
  180. extern CString g_strHintVoiceEnd;
  181. extern CString g_strHintReturnNormal;
  182. extern CString g_strHintUpperLimit;
  183. extern CString g_strHintLowerLimit;
  184. extern CString g_strHintCurrValue;
  185. extern CString g_strHintBlance;
  186. extern CString g_strHintDateLimit;
  187. //服务
  188. extern TCHAR g_szServiceName[];
  189. // 用户角色信息
  190. typedef struct __USERINFO
  191. {
  192. char szTel[MAX_TEL_LENGTH + 1];
  193. char szMobileTel[MAX_TEL_LENGTH + 1];
  194. char szFax[MAX_TEL_LENGTH + 1];
  195. char szEmail[MAX_EMAIL_LENGTH + 1];
  196. }USERINFO, *PUSERINFO;
  197. typedef struct __USERROLEINFO
  198. {
  199. char szDevUID[20];
  200. vector<__USERINFO> vtUserInfo;
  201. }USERROLEINFO, *PUSERROLEINFO;
  202. extern vector<USERINFO> g_vtUserInfo;
  203. extern vector<USERROLEINFO> g_vtUserRoleInfo;
  204. //TTS参数配置
  205. extern INT g_nTTSType; // TTS格式类型
  206. extern INT g_nTTSRate; // TTS语速 (-10 - 10)
  207. extern INT g_nTTSVolume; // TTS音量 (0 - 100)
  208. // 报警参数设置
  209. extern INT g_nAlarmModeIsDlg; // 是否弹出报警提示框
  210. extern INT g_nAlarmModeShowDlgTimes; // 提示框显示次数
  211. extern INT g_nAlarmModeIsSound; // 是否本地播放报警提示音
  212. extern INT g_nAlarmModeSoundNum; // 声音播放次数,0:代表无限播放,直到报警被确认
  213. typedef list<CString> LIST_TEL;
  214. // 变量通知
  215. typedef struct _VAR_NOTICE
  216. {
  217. char szDevUID[20]; // 设备Uid
  218. int nVarID; // 变量ID
  219. int nResult; // 0: 未操作, 1:单个确认, 2:全部确认
  220. int nCallTime; // 拔打次数
  221. int nSmsTime; // 短信发送次数
  222. DWORD dwIdentityTick; // 辨识Tick
  223. DWORD dwReDetectTick; // 重新检测Tick
  224. DWORD dwIntervalTick; // 两次拔打之间的Tick
  225. bool bQueueExist; // true: 存在于语音队列且没有被取走 fasle: 不存在于语音队列或已被取走
  226. int nTelInex; // 电话list中的索引
  227. LIST_TEL listTel; // 有管理这个设备Uid的电话号码和手机号码列表
  228. int nLastStatus; // 前一次的报警状态,用于状态恢复正常的情况
  229. bool bFirstDeal; // 第一次处理这个变量
  230. int nReDetectTime; // 重新检测时间
  231. }VAR_NOTICE, *PVAR_NOTICE;
  232. typedef list<VAR_NOTICE> LIST_VAR_NOTICE;
  233. extern LIST_VAR_NOTICE g_listVarNotice;
  234. typedef int (WINAPI *PFCALLBACK)( int iType,float fData,CString sContent );//iType=0:
  235. // fData=1 恢复正常 fData=0 报警不打电话不发短信
  236. //iType=1:
  237. // fData=余额
  238. //软件加密
  239. typedef int (__stdcall *Reg_DLLInit)( char *pDirectory );
  240. typedef int (WINAPI *Reg_DLLGetDiskInof)( CString &sFilePath );
  241. typedef int (WINAPI *Reg_DLLCreateRegisterFile)( CString &sFilePath,CString &sMsg );
  242. typedef int (WINAPI *Reg_DLLJudgeIsRegister)( CString &sMsg );
  243. typedef int (WINAPI *Reg_DLLUnInit)();
  244. typedef int (WINAPI *Reg_DLLGetEcFileStr)( LPCTSTR fpath,CString &sGet,CString &sMsg );
  245. typedef int (WINAPI *Reg_DLLSetEcFileStr)( LPCTSTR fpath,CString sScrItem,CString sDes,CString &sMsg );
  246. typedef int (WINAPI *Reg_DLLGetHourToCount)( );
  247. typedef int (WINAPI *Reg_DLLIsValidTime)( CString &sMsg );
  248. typedef int (WINAPI *Reg_DLLAddUserDate)( );
  249. extern HINSTANCE g_hSoftRegisterLibModule;
  250. extern Reg_DLLInit pRegdllInit;
  251. extern Reg_DLLJudgeIsRegister pRegdllJudgeIsRegister;
  252. extern Reg_DLLUnInit pRegdllUnInit;
  253. extern Reg_DLLGetHourToCount pRegdllGetHourToCount;
  254. extern Reg_DLLIsValidTime pRegdllIsValidTime;
  255. extern Reg_DLLAddUserDate pRegdllAddUserDate;
  256. // TTS
  257. typedef BOOL (WINAPI *MySTONEU_DLLRegisterTTS)(void);
  258. typedef void (WINAPI *MySTONEU_DLLUnRegisterTTS)(void);
  259. typedef void (WINAPI *MySTONEU_DLLTxtToWav)( char *pText, char *pWavFileName, int nVoiceType, int nRate, int nVolume );
  260. extern HINSTANCE hTTSModule;
  261. extern MySTONEU_DLLRegisterTTS pStoneUDllRegisterTTS;
  262. extern MySTONEU_DLLUnRegisterTTS pStoneUDllUnRegisterTTS;
  263. extern MySTONEU_DLLTxtToWav pStoneUDLLTxtToWav;
  264. // 语音通知动态库输出函数
  265. typedef BOOL (WINAPI *STONEU_DLLRegisterVoice)(char *pDirectory, int nTTSType);
  266. typedef void (WINAPI *STONEU_DLLUnRegisterVoice)(void);
  267. typedef int (WINAPI *STONEU_DLLAllocateChannel)(char *pTel, char *pPreTel, char *pUid, int nVarID,int nAlarmIndex, char *pContent);
  268. extern HINSTANCE g_hVoiceLibModule;
  269. extern STONEU_DLLRegisterVoice pStoneUDllRegisterVoice;
  270. extern STONEU_DLLUnRegisterVoice pStoneUDllUnRegisterVoice;
  271. extern STONEU_DLLAllocateChannel pStoneUDllAllocateChannel;
  272. // Email输出函数
  273. typedef BOOL (WINAPI *EMAIL_DLLInit)( char *pDirectory, // 软件所在路径
  274. char *pSmtpServer, // Smtp服务器
  275. int nSmtpPort, // Smtp端口
  276. int nIsNeed, // 是否需要smtp身份验证
  277. char *pUserAcc, // Email帐号
  278. char *pUserPwd, // Email密码
  279. char *pFromEmailAddr, // 发送人Email地址
  280. int nTimeOut // 超时
  281. );
  282. typedef void (WINAPI *EMAIL_DLLUnInit)(void);
  283. typedef int (WINAPI *EMAIL_DLLSendEmail)(char *pEmail, // 收件人Email地址
  284. char *pSubject, // 邮件标题
  285. char *pContent, // 发送内容
  286. char *pTime, // 发生时间
  287. char *pErrorMsg // 错误消息
  288. );
  289. extern HINSTANCE g_hEmailLibModule;
  290. extern EMAIL_DLLInit pEmailDllInit;
  291. extern EMAIL_DLLUnInit pEmailDllUnInit;
  292. extern EMAIL_DLLSendEmail pEmailDllSendEmail;
  293. // Sms输出函数
  294. typedef BOOL (WINAPI *SMS_DLLInit)( char *pDirectory,
  295. int nAddr, // 保留,因为短信猫是串口232没有地址
  296. int nCommPort, // 串口号
  297. int nRate, // 波特率
  298. int nDataBit, // 数据位
  299. int nStopBit, // 停止位
  300. int nParity, // 校验位
  301. int nInterval, // 间隔时间
  302. int nNeedLanguageTrans, // 是否需要语言转换
  303. int nMaxChar, // 短信猫一条短信最大支持的字符个数
  304. int nMakeCall ); // 发送后是否先拔打电话提醒
  305. typedef void (WINAPI *SMS_DLLUnInit)(void);
  306. typedef int (WINAPI *SMS_DLLSendSms)(char *pTel, // 手机号码
  307. char *pContent, // 发送内容
  308. char *pSendResult); // 发送结果
  309. typedef bool (WINAPI *SMS_DLLGetCSQ)( int iMin,int iMax,int &iNowData ); // 得到短信猫信号
  310. typedef int (WINAPI *SMS_DLLSetCallBack)(PFCALLBACK Func);
  311. typedef int (WINAPI *SMS_DLLGetBalance)( char *pSendResult );
  312. extern HINSTANCE g_hSmsLibModule;
  313. extern SMS_DLLInit pSmsDllInit;
  314. extern SMS_DLLUnInit pSmsDllUnInit;
  315. extern SMS_DLLSendSms pSmsDllSendSms;
  316. extern SMS_DLLGetCSQ pSmsDllGetCSQ;
  317. extern SMS_DLLSetCallBack pSmsDllSetCallBack;
  318. extern SMS_DLLGetBalance pSmsGetBalance;
  319. extern bool g_bAlarmNoticeFlag;//报警通知开头,由短信控制
  320. // Snmp输出函数
  321. typedef BOOL (WINAPIV *SNMP_DLL_GetVale)(
  322. char *pDevIP, // snmp设备IP
  323. char *pSnmpField, // snmp Oid 域,一般为public, private
  324. char *pObjOid, // Obj Oid
  325. char *pValue // 得到的值
  326. );
  327. typedef int (WINAPIV *SNMP_DLL_SetValue)(
  328. char *pDevIP, // snmp设备IP
  329. char *pSnmpField, // snmp Oid 域,一般为public, private
  330. char *pObjOid, // Obj Oid
  331. char *pObjType, // Obj 对象类型
  332. int nRetries, // 可回收标志,暂时都为1
  333. int nTimeOut, // 请求超时
  334. char *pValue // 要设置的值
  335. );
  336. extern HINSTANCE g_hSnmpLibModule;
  337. extern SNMP_DLL_GetVale pSnmpDllGetValue;
  338. extern SNMP_DLL_SetValue pSnmpDllSetValue;
  339. //modbus tcp 动态库输出函数
  340. typedef int (WINAPI *TCP_DLLInit)( int nNetPort,
  341. int nAddr,
  342. char strIpAddr[32],
  343. WORD wRegNum,
  344. WORD wStartAddr,
  345. WORD wTranProcessID,
  346. WORD wProtocolID,
  347. int nFuncCode );
  348. typedef void (WINAPI *TCP_DLLUnInit)(void);
  349. typedef int (WINAPI *TCP_DLLRequestStatusData)(int nNetPort, int nAddr, char strIpAddr[32], char *pData);
  350. typedef BOOL (WINAPI *TCP_DLLInitNet)( int nAddr, int nNetPort, char strIpAddr[32]);
  351. typedef BOOL (WINAPI *TCP_DLLCloseNet)( int nAddr, int nNetPort, char strIpAddr[32]);
  352. typedef int (WINAPI *TCP_DLLWrite)( int nNetPort,
  353. int nAddr,
  354. char strIpAddr[32],
  355. WORD wRegNum,
  356. WORD wStartAddr,
  357. WORD wTranProcessID,
  358. WORD wProtocolID,
  359. int nFuncCode,
  360. int nRegValue);
  361. typedef int (WINAPI *TCP_DLLRequestWrStatusData)(int nNetPort, int nAddr, char strIpAddr[32], int &nWriteResult);
  362. extern HINSTANCE g_hTCPLibModule;
  363. extern TCP_DLLCloseNet pTCP_DllCloseNet;
  364. extern TCP_DLLInitNet pTCP_DLLInitNet;
  365. extern TCP_DLLInit pTCP_DLLInit;
  366. extern TCP_DLLUnInit pTCP_DLLUnInit;
  367. extern TCP_DLLRequestStatusData pTCP_DLLRequestStatusData;
  368. extern TCP_DLLWrite pTCP_DLLWrite;
  369. extern TCP_DLLRequestWrStatusData pTCP_DLLRequestWrStatusData;
  370. //modbus rtu 动态库输出函数
  371. typedef int (WINAPI *RTU_DLLInit)( int nCommPort, int nAddr, SETBASEPARAM SetBasePara, int nDataLen, char chMsg[80] );
  372. typedef void (WINAPI *RTU_DLLUnInit)(void);
  373. typedef BOOL (WINAPI *RTU_DLLInitCom)( int nAddr, int nCommPort, int nRate, int nDataBit, int nStopBit, int nParity, int nInterval);
  374. typedef BOOL (WINAPI *RTU_DLLWrite)( int nCommPort, int nAddr, SETBASEPARAM SetBasePara, double Data, int nDataLen );
  375. typedef BOOL (WINAPI *RTU_DLLRequestWrStatusData)( int nCommPort, int nAddr, char *pData );
  376. extern HINSTANCE g_hRTULibModule;
  377. extern RTU_DLLInitCom pRTU_DLLInitCom;
  378. extern RTU_DLLInit pRTU_DLLInit;
  379. extern RTU_DLLUnInit pRTU_DLLUnInit;
  380. extern RTU_DLLWrite pRTU_DLLWrite;
  381. extern RTU_DLLRequestWrStatusData pRTU_DLLRequestWrStatusData;
  382. //modbus asc 动态库输出函数
  383. typedef BOOL (WINAPI *ASC_DLLInitCom)(int nAdddr, int nCommPort, int nRate, int nDataBit, int nStopBit, int nParity, int nInterval);
  384. typedef int (WINAPI *ASC_DLLInit)(int nCommPort, int nAddr, SETBASEPARAM SetBasePara, int nDataLen, char chMsg[80]);
  385. typedef void (WINAPI *ASC_DLLUnInit)(void);
  386. typedef int (WINAPI *ASC_DLLRequestStatusData)(int nCommPort, int nAddr, int nByteNum, char *pData);
  387. //typedef void (WINAPI *ASC_DLLDetectOnlineCallBack)(void *pPara);
  388. typedef int ((WINAPI *ASC_DLLWrCom))(int nCommPort, int nAddr, SETBASEPARAM SetBasePara, double Data, int nDataLen);
  389. typedef int (WINAPI *ASC_DLLRequestWrStatusData)(int nCommPort, int iAddr, char *pData);
  390. extern HINSTANCE g_hASCLibModule;
  391. extern ASC_DLLInitCom pASCDLLInitCom;
  392. extern ASC_DLLInit pASCDLLInit;
  393. extern ASC_DLLUnInit pASCDLLUnInit;
  394. extern ASC_DLLRequestStatusData pASCDLLRequestStatusData;
  395. extern ASC_DLLWrCom pASC_DLLWrCom;
  396. extern ASC_DLLRequestWrStatusData pASC_DLLRequestWrStatusData;
  397. //extern ASC_DLLDetectOnlineCallBack pASCDLLDetectOnlineCallBack;
  398. //icpdas 动态库输出函数
  399. typedef int (WINAPI *ICPDAS_DLLInit)
  400. ( int nCommPort,
  401. int nAddr,
  402. BYTE Start,//起始位
  403. BYTE StartAddr[2],//起始地址
  404. int nRegNum,//读取的寄存器个数
  405. BYTE FuncCode[2],
  406. int nDataLen,
  407. BYTE byWithAddrFlag,
  408. char chMsg[80]);
  409. typedef int ((WINAPI *ICPDAS_DLLWrCom))
  410. (int nCommPort,
  411. int nAddr,
  412. char DataBuffer[80],
  413. int nDataLen);
  414. typedef void (WINAPI *ICPDAS_DLLUnInit)(void);
  415. typedef int (WINAPI *ICPDAS_DLLRequestStatusData)
  416. (int nCommPort,
  417. int nAddr,
  418. int nByteNum,
  419. char *pData,
  420. int iVarID);
  421. typedef BOOL (WINAPI *ICPDAS_DLLInitCom)( int nAddr,
  422. int nCommPort,
  423. int nRate,
  424. int nDataBit,
  425. int nStopBit,
  426. int nParity,
  427. int nInterval);
  428. extern HINSTANCE g_hICPDASLibModule;
  429. extern ICPDAS_DLLInitCom pICPDAS_DLLInitCom;
  430. extern ICPDAS_DLLInit pICPDAS_DLLInit;
  431. extern ICPDAS_DLLUnInit pICPDAS_DLLUnInit;
  432. extern ICPDAS_DLLRequestStatusData pICPDAS_DLLRequestStatusData;
  433. extern ICPDAS_DLLWrCom pICPDAS_DLLWrCom;
  434. //upskehua 动态库输出函数
  435. typedef int (WINAPI *UPSKEHUA_DLLInit)
  436. (int nCommPort,
  437. int nAddr,
  438. char szCmd[32],
  439. char chSendMsg[32],
  440. int nDataLen,
  441. char chMsg[UPS_KE_HUA_MAX_MSG]);
  442. typedef int ((WINAPI *UPSKEHUA_DLLWrCom))
  443. (int nCommPort,
  444. int nAddr,
  445. char DataBuffer[80],
  446. int nDataLen);
  447. typedef void (WINAPI *UPSKEHUA_DLLUnInit)(void);
  448. typedef BOOL (WINAPI *UPSKEHUA_DLLInitCom)( int nAddr,
  449. int nCommPort,
  450. int nRate,
  451. int nDataBit,
  452. int nStopBit,
  453. int nParity,
  454. int nInterval);
  455. extern HINSTANCE g_hUPSKEHUALibModule;
  456. extern UPSKEHUA_DLLInitCom pUPSKEHUA_DLLInitCom;
  457. extern UPSKEHUA_DLLInit pUPSKEHUA_DLLInit;
  458. extern UPSKEHUA_DLLUnInit pUPSKEHUA_DLLUnInit;
  459. extern UPSKEHUA_DLLWrCom pUPSKEHUA_DLLWrCom;
  460. //Separate 动态库输出函数
  461. typedef int (WINAPI *SEPARATE_DLLRead)
  462. (
  463. int nCommPort,
  464. int nAddr,
  465. char szPath[MAX_PATH],
  466. char szIniName[MAX_PATH],
  467. char szCmd[MAX_CMD],
  468. char szMsg[MAX_VAR_MSG]
  469. );
  470. typedef int ((WINAPI *SEPARATE_DLLWrite))
  471. (
  472. int nCommPort,
  473. int nAddr,
  474. char szPath[MAX_PATH],
  475. char szIniName[MAX_PATH],
  476. char szCmd[MAX_CMD],
  477. char szMsg[MAX_VAR_MSG]
  478. );
  479. typedef void (WINAPI *SEPARATE_DLLUnInit)(void);
  480. typedef BOOL (WINAPI *SEPARATE_DLLInit)( int nAddr,
  481. int nCommPort,
  482. int nRate,
  483. int nDataBit,
  484. int nStopBit,
  485. int nParity,
  486. int nInterval);
  487. extern HINSTANCE g_hSeparateLibModule;
  488. extern SEPARATE_DLLInit pSeparate_DLLInit;
  489. extern SEPARATE_DLLUnInit pSeparate_DLLUnInit;
  490. extern SEPARATE_DLLRead pSeparate_DLLRead;
  491. extern SEPARATE_DLLWrite pSeparate_DLLWrite;
  492. //Upsparadigm 动态库输出函数
  493. typedef int (WINAPI *PARADIGM_DLLInit)( int nCommPort,
  494. int nDevAddr,
  495. int nAddr, //设备地址描述
  496. int nVer, //版本
  497. int nCid1, //控制标识码
  498. int nCid2, //命令信息
  499. WORD wLenId,//INFO字节长度
  500. BYTE byCmdType,//命令类型
  501. int nCmdID, //命令ID
  502. int nDataLen,
  503. int nCmdPos,
  504. int nCmdLen,
  505. char chMsg[80],
  506. char *byDataFlag);
  507. typedef void (WINAPI *PARADIGM_DLLUnInit)(void);
  508. typedef BOOL (WINAPI *PARADIGM_DLLInitCom)( int nAddr, int nCommPort, int nRate,
  509. int nDataBit, int nStopBit, int nParity, int nInterval);
  510. extern HINSTANCE g_hPARADIGMLibModule;
  511. extern PARADIGM_DLLInitCom pPARADIGM_DLLInitCom;
  512. extern PARADIGM_DLLInit pPARADIGM_DLLInit;
  513. extern PARADIGM_DLLUnInit pPARADIGM_DLLUnInit;
  514. //stulz 动态库输出函数
  515. typedef int (WINAPI *STULZ_DLLInit)( int nCommPort,
  516. int nAddr,
  517. SETBASEPARAM SetBasePara,
  518. int nDataLen,
  519. int iCmdPos,
  520. int iCmdLen,
  521. char chMsg[10] );
  522. typedef void (WINAPI *STULZ_DLLUnInit)(void);
  523. typedef BOOL (WINAPI *STULZ_DLLInitCom)( int nAddr, int nCommPort, int nRate,
  524. int nDataBit, int nStopBit, int nParity, int nInterval);
  525. typedef int (WINAPI *STULZ_DLLWrCom)(int nCommPort, int nAddr, char DataBuffer[80], char ResDataBuffer[2]);
  526. extern HINSTANCE g_hSTULZLibModule;
  527. extern STULZ_DLLInitCom pSTULZ_DLLInitCom;
  528. extern STULZ_DLLInit pSTULZ_DLLInit;
  529. extern STULZ_DLLUnInit pSTULZ_DLLUnInit;
  530. extern STULZ_DLLWrCom pSTULZ_DLLWrCom;
  531. //Powerware 动态库输出函数
  532. typedef int (WINAPI *POWERWARE_DLLInit)( int nCommPort, //串口
  533. int nDevAddr, //设备地址
  534. int nRequestLen, //请求数据总长度
  535. int nResponseLen, //响应数据总长度
  536. int nCmd, //命令
  537. int nCmdPos, //变量索引
  538. int nCmdLen, //变量长度
  539. int nParam, //参数
  540. char chMsg[80]); //读到变量值
  541. typedef void (WINAPI *POWERWARE_DLLUnInit)(void);
  542. typedef BOOL (WINAPI *POWERWARE_DLLInitCom)( int nAddr, int nCommPort, int nRate,
  543. int nDataBit, int nStopBit, int nParity, int nInterval);
  544. extern HINSTANCE g_hPowerwareLibModule;
  545. extern POWERWARE_DLLInitCom pPOWERWARE_DLLInitCom;
  546. extern POWERWARE_DLLInit pPOWERWARE_DLLInit;
  547. extern POWERWARE_DLLUnInit pPOWERWARE_DLLUnInit;
  548. //gree 动态库输出函数
  549. typedef int (WINAPI *GREE_DLLInit)( int nCommPort, int nAddr,int nDataLen,int nReadPos, char chMsg[80] );
  550. typedef void (WINAPI *GREE_DLLUnInit)(void);
  551. typedef BOOL (WINAPI *GREE_DLLInitCom)( int nAddr, int nCommPort, int nRate, int nDataBit, int nStopBit, int nParity, int nInterval);
  552. typedef BOOL (WINAPI *GREE_DLLWrCom)( int nCommPort, int nAddr,
  553. int nWorkStatus, int nWorkMode, int nFanSpeed,
  554. int nPutWind, int nAirTrade, int nSleep, int nLight,
  555. int nTempSetPoint );
  556. extern HINSTANCE g_hGREELibModule;
  557. extern GREE_DLLInitCom pGREE_DLLInitCom;
  558. extern GREE_DLLInit pGREE_DLLInit;
  559. extern GREE_DLLUnInit pGREE_DLLUnInit;
  560. extern GREE_DLLWrCom pGREE_DLLWrCom;
  561. //Carel控制器
  562. typedef int (WINAPI *CAREL_DLLInit)( int nAddr, int nCommPort, int nRate,
  563. int nDataBit, int nStopBit, int nParity, int nInterval);
  564. typedef void (WINAPI *CAREL_DLLUnInit)(void);
  565. typedef BOOL (WINAPI *CAREL_DLLRequestData)(
  566. int nCommPort, //串口号
  567. int nAddr, //地址
  568. char chRs232cmd[32], //命令
  569. char szType[MAX_ID], //类型
  570. char szIndex[MAX_ID], //索引
  571. char szMsg[CAREL_MAX_MSG] //内容
  572. );
  573. typedef BOOL (WINAPI *CAREL_DLLControl)(
  574. int nCommPort, //串口号
  575. int nAddr, //地址
  576. char chRs232cmd[32], //命令
  577. char szType[MAX_ID], //类型
  578. char szIndex[MAX_ID], //索引
  579. char szMsg[CAREL_MAX_MSG] //内容
  580. );
  581. extern HINSTANCE g_hCarelLibModule;
  582. extern CAREL_DLLInit pCarel_DLLInit;
  583. extern CAREL_DLLUnInit pCarel_DLLUnInit;
  584. extern CAREL_DLLRequestData pCarelRequestData;
  585. extern CAREL_DLLControl pCarelControl;
  586. // MostDevice 以后大部分设备都集成到这个动态库里面
  587. typedef BOOL (WINAPI *DLL_MostDeviceInit)(
  588. char szPath[MAX_PATH], // 程序所在路径
  589. char szIniName[MAX_PATH], // 配置文件名称
  590. int nCommPort, // 串行端口
  591. int nAddr, // 设备地址
  592. int nRate, // 波特率
  593. int nDataBit, // 数据位
  594. int nStopBit, // 停止位
  595. int nParity, // 校验位
  596. int nInterval // 时间间隔
  597. );
  598. typedef void (WINAPI *DLL_MostDeviceUnInit)(
  599. char szPath[MAX_PATH], // 程序所在路径
  600. char szIniName[MAX_PATH], // 配置文件名称
  601. int nCommPort // 串行端口
  602. );
  603. typedef int (WINAPI *DLL_MostDeviceRead)(
  604. char szPath[MAX_PATH], // 程序所在路径
  605. char szIniName[MAX_PATH], // 配置文件名称
  606. int nCommPort, // 串行端口
  607. int nAddr, // 设备地址
  608. char szCmd[MAX_CMD], // 请求命令
  609. char szMsg[MAX_VAR_MSG], // 响应的值
  610. int nReversed1, // 预留整形参数1接口
  611. int nReversed2, // 预留整形参数2接口
  612. int nReversed3, // 预留整形参数3接口
  613. int nReversed4, // 预留整形参数4接口
  614. int nReversed5, // 预留整形参数5接口
  615. float fReversed1, // 预留float参数1接口
  616. float fReversed2, // 预留float参数2接口
  617. float fReversed3, // 预留float参数3接口
  618. char szReversed1[MAX_RESERVED1], // 预留字符数组参数1接口
  619. char szReversed2[MAX_RESERVED2], // 预留字符数组参数2接口
  620. char szReversed3[MAX_RESERVED3], // 预留字符数组参数3接口
  621. char szReversed4[MAX_RESERVED4], // 预留字符数组参数4接口
  622. char szReversed5[MAX_RESERVED5] // 预留字符数组参数5接口
  623. );
  624. typedef int (WINAPI *DLL_MostDeviceSet)(
  625. char szPath[MAX_PATH], // 程序所在路径
  626. char szIniName[MAX_PATH], // 配置文件名称
  627. int nCommPort, // 串行端口
  628. int nAddr, // 设备地址
  629. char szCmd[MAX_CMD], // 请求命令
  630. char szMsg[MAX_VAR_MSG], // 响应的值
  631. int nReversed1, // 预留整形参数1接口
  632. int nReversed2, // 预留整形参数2接口
  633. int nReversed3, // 预留整形参数3接口
  634. int nReversed4, // 预留整形参数4接口
  635. int nReversed5, // 预留整形参数5接口
  636. float fReversed1, // 预留float参数1接口
  637. float fReversed2, // 预留float参数2接口
  638. float fReversed3, // 预留float参数3接口
  639. char szReversed1[MAX_RESERVED1], // 预留字符数组参数1接口
  640. char szReversed2[MAX_RESERVED2], // 预留字符数组参数2接口
  641. char szReversed3[MAX_RESERVED3], // 预留字符数组参数3接口
  642. char szReversed4[MAX_RESERVED4], // 预留字符数组参数4接口
  643. char szReversed5[MAX_RESERVED5] // 预留字符数组参数5接口
  644. );
  645. extern HINSTANCE g_hMostDeviceLibModule;
  646. extern DLL_MostDeviceInit pDllMostDeviceInit;
  647. extern DLL_MostDeviceUnInit pDllMostDeviceUnInit;
  648. extern DLL_MostDeviceRead pDllMostDeviceRead;
  649. extern DLL_MostDeviceSet pDllMostDeviceSet;
  650. extern void WriteSummaryLog(CHAR *pdevname, CHAR *pHappenTime, CHAR* memo, int id,
  651. CHAR *ptypedesc, double currvalue, CHAR* varuid, CHAR *varname);
  652. extern WORD AsciiToBYTE(BYTE btSrc);
  653. extern char ByteToAscii(BYTE btSrc);
  654. char lowercase2uppercase(BYTE btSrc);
  655. extern int StrLower(char *pSource, char *pDest);
  656. extern int StrUpper(char *pSource, char *pDest);
  657. extern int DigitToBinary(WORD wdSource, char* pDes, int iBit);
  658. extern char Hex16(char WillChangeNum[]); //该函数把四位二进制转换成十六进制数
  659. extern BYTE TwoByteToByte(BYTE b1, BYTE b2); //两个字符转换为一个字符
  660. extern void ByteToTwoByte(BYTE b, BYTE b2[]); //一个字符转换为两个字符
  661. extern void ByteToUpper(char *szMsg);
  662. void g_GetAllLogFile();
  663. //md5全局变量
  664. #ifndef PROTOTYPES
  665. #define PROTOTYPES 1
  666. #endif
  667. /* POINTER defines a generic pointer type */
  668. typedef unsigned char *POINTER;
  669. /* UINT2 defines a two byte word */
  670. typedef unsigned short int UINT2;
  671. /* UINT4 defines a four byte word */
  672. typedef unsigned long int UINT4;
  673. /* PROTO_LIST is defined depending on how PROTOTYPES is defined above.
  674. If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
  675. returns an empty list.
  676. */
  677. #if PROTOTYPES
  678. #define PROTO_LIST(list) list
  679. #else
  680. #define PROTO_LIST(list) ()
  681. #endif