RedRatProcess.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #pragma once
  2. #include "TCPClient.h"
  3. class CRedRatProcess: public CTCPClient
  4. {
  5. public:
  6. CRedRatProcess(void);
  7. ~CRedRatProcess(void);
  8. protected:
  9. bool checkEOM(std::string& data);
  10. private:
  11. // 只能运行一个红老鼠进程;
  12. static DWORD m_dwCurAppId;
  13. std::string m_strCurDevice;
  14. std::string m_strCurDataset;
  15. std::vector<std::string> m_vtDevices;
  16. std::vector<std::string> m_vtDataset;
  17. std::vector<std::string> m_vtSignals;
  18. // 外部程序接口;
  19. public:
  20. static bool StartApp(LPCTSTR lpAppDir, LPCTSTR lpSignalXml, DWORD dwPort = 40000);
  21. static DWORD IsAppRunning(LPCTSTR lpszAppDir);
  22. static bool CloseApp(DWORD dwAppId = 0);
  23. static DWORD GetProcessId(std::string strApp = "RedRatHubCmd.exe");
  24. // 红老鼠接口;
  25. public:
  26. // 获取设备列表;
  27. bool getDeviceNameList();
  28. bool getDeviceNameList(std::vector<std::string>& vtDevice);
  29. // 设置信号数据集;
  30. void SelectDataset(std::string dataset) { m_strCurDataset = dataset; }
  31. // 获取数据集列表;
  32. bool getDatasetNameList();
  33. bool getDatasetNameList(std::vector<std::string>& vtDataset);
  34. // 加载信号数据集xml文件,将会删除以前所有加载过的xml文件;
  35. bool loadSignalDataSet(std::string file);
  36. // 添加信号数据集xml文件, 相同数据集名称的将会被覆盖
  37. bool addSignalDataSet(std::string file);
  38. // 获取指定数据集信号名称;
  39. //bool getSignalsName(std::string dataset = "");
  40. bool getSignalsName(std::vector<std::string>& vtSignals, std::string dataset = "");
  41. std::string getSignalsName(std::string dataset = "");
  42. // 发送单个信号;
  43. bool sendSignal(std::string signal, int send_times = 1, int sleep_time = 1000);
  44. // 发送多个信号;
  45. bool sendSignals(const char(*signals)[10], int nCount, int sleep_time = 1000);
  46. bool sendSignals(std::string signals[], int nCount, int sleep_time = 1000);
  47. bool sendSignals(std::vector<std::string>& vtSignals, int sleep_time = 1000);
  48. // 重复发送;
  49. bool sendRepeatsSignal(std::string signal, int repeat_time = 2);
  50. bool sendDurationSignal(std::string signal, int duration_time = 1000);
  51. bool sendBothSignal(std::string signal, int repeat_time = 2, int duration_time = 1000);
  52. };