123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- #pragma once
- #include "LogicDevice.h"
- #include "commonDataStruct.h"
- #include "ScopeLock.h"
- #ifndef SYSTEMDEVICE_EXPORTS
- #ifdef _WIN64
- #ifdef _DEBUG
- #pragma comment(lib, "LogicDeviceX64D.lib")
- #else
- #pragma comment(lib, "LogicDeviceX64.lib")
- #endif
- #else
- #ifdef _DEBUG
- #pragma comment(lib, "LogicDeviceD.lib")
- #else
- #pragma comment(lib, "LogicDevice.lib")
- #endif
- #endif
- #endif
- #define CONNECTIONERROR 1
- #define UNCLEARERROR 2
- #define CLEARERROR 3
- #define AUTOCLEARERROR 4
- #ifdef SYSTEMDEVICE_EXPORTS
- #define SYSTEMDEVICE_API __declspec(dllexport)
- #else
- #define SYSTEMDEVICE_API __declspec(dllimport)
- #endif
- class SYSTEMDEVICE_API DeviceObject {
- public:
- DeviceObject();
- virtual ~DeviceObject();
- //打开设备
- int Open(string DeviceRootURI);
- int OpenDevice();
- //关闭设备
- int Close();
- int CloseDevice();
- RET_STATUS DeviceAction(const char* ActionName, ResDataObject& req, ResDataObject& res, DWORD timeout);
- const char* GetDeviceURI() { return m_strDeviceRoot.c_str(); }
- int GetAllDevice(ResDataObject& rdoAll);
- int GetDeviceUnitCount() { return m_nDeviceNum; }
- LogicClient* GetDeviceClient(int idx);
- LogicClient* GetDriverClient() { return m_pRootDriver; }
- protected:
- string m_strDeviceRoot;
- LogicClient *m_pRootDriver;
- ResDataObject m_DriverResource;
- ResDataObject m_DeviceList;
- int m_nDeviceNum;
- LogicClient* *m_pDevices;
- };
- /*
- * ROOT路径即设备的驱动URI,打开之后的设备URI是相对路径
- <DIOS_WS>
- <Default>
- <ServiceDevice>ServiceDefault</ServiceDevice>
- <OEMDevice>
- <ROOT>DIOS/DEVICE/DETECTOR/iRay/3543W/A876453</ROOT>
- <ROOT>DIOS/DEVICE/GENERATOR/Simens/Exs/B87632</ROOT>
- </OEMDevice>
- <SystemDevice>DRSystem</SystemDevice>
- </Default>
- <Demo>
- <ServiceDevice>ServiceDefault</ServiceDevice>
- <OEMDevice>
- <ROOT>DIOS/DEVICE/DETECTOR/ECOM/DEMO/DEMOFPD</ROOT>
- <ROOT>DIOS/DEVICE/GENERATOR/ECOM/DEMO/DEMOGEN</ROOT>
- </OEMDevice>
- <SystemDevice>DRSystem</SystemDevice>
- </Demo>
- </DIOS_WS>
- <ServiceDefault>
- <ROOT>DIOS/DEVICE/SERVICE/ImageSave/ECOM/1234</ROOT>
- <ROOT>DIOS/DEVICE/SERVICE/ImageView/ECOM/1234</ROOT>
- </ServiceDefault>
- <SystemDefault>
- <ROOT>DIOS/DEVICE/SYSTEM/DRSystem/ECOM/1234</ROOT>
- </SystemDefault>
- <DRSystem>
- <ROOT>DIOS/DEVICE/SYSTEM/DRSystem/ECOM/1234</ROOT>
- </DRSystem>
-
- */
- class SYSTEMDEVICE_API WorkStationDevice :
- public LogicDevice
- {
- protected:
- //ResDataObject* m_pResErrorList; //错误列表
- string m_strConfigFileName; //配置文件路径
- ResDataObject m_resAllConfig; //配置内容
- string m_strSetWS; //当前WorkStation名称
- BaseJsonDataObject<string> m_WorkSatition; //当前WorkStation对象
- int m_nAllOemDeviceNum;
- DeviceObject* m_pAllOemDevice; //工作位专用对象,如探测器+发生器
- int m_nServiceDeviceNum;
- DeviceObject* m_pServiceDevice; //服务设备
- int m_nSystemDeviceNum;
- DeviceObject* m_pSystemDevice; //系统设备
- vector<LogicClient*> m_pWSDriverClient;
- int m_nAllDeviceUnitNum;// 所有设备数量,包括服务设备和系统设备
- vector<LogicClient*> m_pWSDeviceClient; //所有的设备client事件句柄
- HANDLE* m_pHandleArray; // DeviceUnit通知事件数组,这里有漏洞,如果发生连续两个事件,会漏,使用者要两个都用:事件和轮询
- vector< string > m_vecWorksationDeviceUnitPath; //与Handle保持一致的事件对应的设备Path
- protected:
- bool RefreshUnitClientAttribute();
- RET_STATUS ResetFunc();
- void CloseUnit(const string& strPath);
- public: //对象对外接口
- //根据URI查找设备
- DeviceObject* FindDevice(string strDeviceURI);
- int GetAllDevice(ResDataObject& rdoAll);
- int OpenAll();
- int CloseAll();
- RET_STATUS RESET();
- RET_STATUS SetAction(const char* ActionName, ResDataObject& Req, ResDataObject& Resp, DWORD timeout = INFINITE);
- vector<string> GetAllDeviceDrivers(const char* ws = nullptr);
- void GetDriversNotifyHandle(HANDLE* pHandles, int nNum);
- vector<string> GetAllDeviceUnit();
- public:
- WorkStationDevice();
- virtual ~WorkStationDevice();
- //继承的接口实现
- virtual bool SYSTEM_CALL GetDeviceType(GUID& DevType) override;
- virtual RET_STATUS SYSTEM_CALL CmdToLogicDev(ResDataObject PARAM_IN* pCmd) override;
- RET_STATUS Request(ResDataObject PARAM_IN* pRequest, ResDataObject PARAM_OUT* pResponse) override;
- virtual RET_STATUS GetDeviceResource(ResDataObject PARAM_OUT* pDeviceResource) override;
- public: //模块对外接口
- //设置配置文件路径
- bool SetConfigFile(const char* pszFileName);
- bool SetConfigRes(ResDataObject &resConfig);
- //切换工作位
- RET_STATUS SetWorkStation(const char* pParam, int setWs = 1);
- //查询工作位
- RET_STATUS GetWorkStion(const char* pParam, ResDataObject &resWorkStation);
- RET_STATUS GetWorkStationList(ResDataObject& resWSList);
- //添加工作位
- RET_STATUS AddWorkStation(const char* pParam, ResDataObject &resWorkStation);
- //删除工作位
- RET_STATUS DelWorkStation(const char* pParam);
- //编辑工作位
- RET_STATUS EditWorkStation(const char* pParam, ResDataObject &resWorkStation);
- //检查工作位
- RET_STATUS CheckWorkStation(const char* pParam);
- //EBus版本WorkStation的Driver列表
- RET_STATUS GetDeviceDriver();
- RET_STATUS AddDriverList(const ResDataObject& pParam);
- RET_STATUS DelDriverList(const ResDataObject& pParam);
- RET_STATUS AddDeviceDriver(const ResDataObject& pParam);
- RET_STATUS DelDeviceDriver(const ResDataObject& pParam);
- RET_STATUS SetDeviceStatusAttr(const ResDataObject& pParam);
- bool CheckDriverDevice();
- RET_STATUS SetAS(const string& pParam);
- bool CheckASState(const char* ws = nullptr);
- // m_mapDeviceList有关的函数和定义,设备在线状态相关
- enum GetDevListOutType
- {
- otSaveXml,
- otGetDevDriver,
- };
- bool GetDeviceState() { return true; }
- vector<string> GetAllDevicesDemo();
- int GetAllDriversList(GetDevListOutType ot, ResDataObject& rdoOut);
- void ClearUnitClientList();
- void SetUnitClientToList(const char* pPath);
- bool UpdateUnitClientState(const char* pPath, int cmdtype);
- bool FindDeviceClient(const string& strDrv, LogicClient** ppClient);
- int InitDriverList();
- void IntUnitClientList(const string& strPath);
- bool CheckDevUnitErrorList();
- public:
- void CloseAllDeviceClient(); //关闭设备连接
- void CloseAllDriverClient(); //关闭驱动连接
- };
|