IRControl.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // 下列 ifdef 块是创建使从 DLL 导出更简单的
  2. // 宏的标准方法。此 DLL 中的所有文件都是用命令行上定义的 {0}_EXPORTS
  3. // 符号编译的。在使用此 DLL 的
  4. // 任何项目上不应定义此符号。这样,源文件中包含此文件的任何其他项目都会将
  5. // {0}_API 函数视为是从 DLL 导入的,而此 DLL 则将用此宏定义的
  6. // 符号视为是被导出的。
  7. #ifdef IRCONTROL_EXPORTS
  8. #define IRCONTROL_API __declspec(dllexport)
  9. #else
  10. #define IRCONTROL_API __declspec(dllimport)
  11. #endif
  12. #include "TCPClient.h"
  13. // 此类是从 dll 导出的
  14. class IRCONTROL_API CIRControl : public CTCPClient
  15. {
  16. public:
  17. CIRControl();
  18. ~CIRControl();
  19. protected:
  20. bool checkEOM(std::string& data);
  21. private:
  22. // 只能运行一个红老鼠进程;
  23. static DWORD m_dwCurAppId;
  24. std::string m_strCurDevice;
  25. std::string m_strCurDataset;
  26. std::vector<std::string> m_vtDevices;
  27. std::vector<std::string> m_vtDataset;
  28. std::vector<std::string> m_vtSignals;
  29. // 外部程序接口;
  30. public:
  31. static bool StartApp(LPCTSTR lpAppDir, LPCTSTR lpSignalXml, DWORD dwPort = 40000);
  32. static DWORD IsAppRunning(LPCTSTR lpszAppDir);
  33. static bool CloseApp(DWORD dwAppId = 0);
  34. static DWORD GetProcessId(std::string strApp = "RedRatHubCmd.exe");
  35. // 红老鼠接口;
  36. public:
  37. // 获取设备列表;
  38. bool getDeviceNameList();
  39. bool getDeviceNameList(std::vector<std::string>& vtDevice);
  40. // 设置信号数据集;
  41. void SelectDataset(std::string dataset) { m_strCurDataset = dataset; }
  42. // 获取数据集列表;
  43. bool getDatasetNameList();
  44. bool getDatasetNameList(std::vector<std::string>& vtDataset);
  45. // 加载信号数据集xml文件,将会删除以前所有加载过的xml文件;
  46. bool loadSignalDataSet(std::string file);
  47. // 添加信号数据集xml文件, 相同数据集名称的将会被覆盖
  48. bool addSignalDataSet(std::string file);
  49. // 获取指定数据集信号名称;
  50. //bool getSignalsName(std::string dataset = "");
  51. bool getSignalsName(std::vector<std::string>& vtSignals, std::string dataset = "");
  52. std::string getSignalsName(std::string dataset = "");
  53. // 发送单个信号;
  54. bool sendSignal(std::string signal, int send_times = 1, int sleep_time = 1000);
  55. // 发送多个信号;
  56. bool sendSignals(const char(*signals)[10], int nCount, int sleep_time = 1000);
  57. bool sendSignals(std::string signals[], int nCount, int sleep_time = 1000);
  58. bool sendSignals(std::vector<std::string>& vtSignals, int sleep_time = 1000);
  59. // 重复发送;
  60. bool sendRepeatsSignal(std::string signal, int repeat_time = 2);
  61. bool sendDurationSignal(std::string signal, int duration_time = 1000);
  62. bool sendBothSignal(std::string signal, int repeat_time = 2, int duration_time = 1000);
  63. };