123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- // 下列 ifdef 块是创建使从 DLL 导出更简单的
- // 宏的标准方法。此 DLL 中的所有文件都是用命令行上定义的 {0}_EXPORTS
- // 符号编译的。在使用此 DLL 的
- // 任何项目上不应定义此符号。这样,源文件中包含此文件的任何其他项目都会将
- // {0}_API 函数视为是从 DLL 导入的,而此 DLL 则将用此宏定义的
- // 符号视为是被导出的。
- #ifdef IRCONTROL_EXPORTS
- #define IRCONTROL_API __declspec(dllexport)
- #else
- #define IRCONTROL_API __declspec(dllimport)
- #endif
- #include "TCPClient.h"
- // 此类是从 dll 导出的
- class IRCONTROL_API CIRControl : public CTCPClient
- {
- public:
- CIRControl();
- ~CIRControl();
- protected:
- bool checkEOM(std::string& data);
- private:
- // 只能运行一个红老鼠进程;
- static DWORD m_dwCurAppId;
- std::string m_strCurDevice;
- std::string m_strCurDataset;
- std::vector<std::string> m_vtDevices;
- std::vector<std::string> m_vtDataset;
- std::vector<std::string> m_vtSignals;
- // 外部程序接口;
- public:
- static bool StartApp(LPCTSTR lpAppDir, LPCTSTR lpSignalXml, DWORD dwPort = 40000);
- static DWORD IsAppRunning(LPCTSTR lpszAppDir);
- static bool CloseApp(DWORD dwAppId = 0);
- static DWORD GetProcessId(std::string strApp = "RedRatHubCmd.exe");
- // 红老鼠接口;
- public:
- // 获取设备列表;
- bool getDeviceNameList();
- bool getDeviceNameList(std::vector<std::string>& vtDevice);
- // 设置信号数据集;
- void SelectDataset(std::string dataset) { m_strCurDataset = dataset; }
- // 获取数据集列表;
- bool getDatasetNameList();
- bool getDatasetNameList(std::vector<std::string>& vtDataset);
- // 加载信号数据集xml文件,将会删除以前所有加载过的xml文件;
- bool loadSignalDataSet(std::string file);
- // 添加信号数据集xml文件, 相同数据集名称的将会被覆盖
- bool addSignalDataSet(std::string file);
- // 获取指定数据集信号名称;
- //bool getSignalsName(std::string dataset = "");
- bool getSignalsName(std::vector<std::string>& vtSignals, std::string dataset = "");
- std::string getSignalsName(std::string dataset = "");
- // 发送单个信号;
- bool sendSignal(std::string signal, int send_times = 1, int sleep_time = 1000);
- // 发送多个信号;
- bool sendSignals(const char(*signals)[10], int nCount, int sleep_time = 1000);
- bool sendSignals(std::string signals[], int nCount, int sleep_time = 1000);
- bool sendSignals(std::vector<std::string>& vtSignals, int sleep_time = 1000);
- // 重复发送;
- bool sendRepeatsSignal(std::string signal, int repeat_time = 2);
- bool sendDurationSignal(std::string signal, int duration_time = 1000);
- bool sendBothSignal(std::string signal, int repeat_time = 2, int duration_time = 1000);
- };
|