123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- #pragma once
- #include <string>
- #include <deque>
- #include "DIOS.Dev.IODevice.Detail.hpp"
- //#include "DiosDevThread.h"
- #include "DiosThread.h"
- #include "IODeviceWithSCF.tlh"
- #include "IODeviceWithSCF.tli"
- #include "DIOS.Dev.MSGMould.hpp"
- #include "DIOS.Dev.MECH.Mould.hpp"
- //#include "ATLComTime.h"
- #include "DeliverModule.h"
- #define Dios_V3 0
- #if Dios_V3
- #include "LogicClient.h"
- #endif // Dios_V3
- #ifdef DIOSDEVMECHOTCSTITCH_EXPORTS
- #define _DIOSDEVMECHOTCSTITCH_API __declspec(dllexport)
- #else
- #define _DIOSDEVMECHOTCSTITCH_API __declspec(dllimport)
- #endif
- namespace nsSerialGPM = DIOS::Dev::MODLE::SerialGPM;
- enum OTC_MG_REGULATION_LEVEL { //故障等级
- REG_ERRO,
- REG_WARN
- };
- typedef enum _HAND_SWITCH {
- HAND_OFF,
- HAND_DWON1,
- HAND_DWON2,
- HAND_MAX
- }HAND_SWITCH;
- struct Axis
- {
- enum AxisState {
- AXIS_STOP,
- AXIS_MOVE
- };
- Axis(string name = "", AxisState state = AXIS_STOP) : m_strAxisName(name), m_nAxisState(state){};
- string GetName() { return m_strAxisName; };
- AxisState GetState() { return m_nAxisState; };
- void SetState(AxisState state) { m_nAxisState = state; };
- void SetState(int state) { m_nAxisState = (AxisState)state; };
- int GetPosition() { return m_nPosition; };
- void SetPosition(int pos) { m_nPosition = pos; };
- private:
- string m_strAxisName;
- AxisState m_nAxisState{ AXIS_STOP };
- int m_nPosition{ 0 };
- };
- #define AxisCount 4
- namespace DIOS::Dev::Detail::MECH
- {
- using cbFun = std::function <void(char*, int)>;
- struct tFrameMapItem
- {
- cbFun m_fFun; //处理函数
- tFrameMapItem();
- tFrameMapItem(cbFun f);
- tFrameMapItem& operator =(const tFrameMapItem& value);
- };
- static const int TIMEOUTVALUE = 100;
- struct tTomoResult
- {
- float nAngle{ 0 };
- float nHeight{ 0 };
- tTomoResult() :nAngle(0), nHeight(0) {}
- tTomoResult(float angle, float height) :nAngle(angle), nHeight(height){}
- };
- //-----------------------------------------------------------------------------
- // HanQing3DDevice
- //-----------------------------------------------------------------------------
- class _DIOSDEVMECHOTCSTITCH_API HanQing3DDevice : public IODeviceWithSCF <IODeviceDetail>, public MECHMould
- {
- using super = IODeviceWithSCF <IODeviceDetail>;
- using superMech = MECHMould;
- public:
- HanQing3DDevice(std::shared_ptr <IOEventCenter> center, nsSCF::SCF SCF,string configfile="");
- ~HanQing3DDevice();
- //上层继承
- virtual std::string GetGUID() const override;
- RET_STATUS RefreshData();
- //串口处理层
- static nsSerialGPM::CDeliverModule m_tDelivermodule;
- int m_nCMDType_WaitTime{ 0 };
- int m_nCMDType_HB{ 0 };
- int m_nCMDType_WaitACK{ 0 };
- static void __stdcall ProcessClientData(const char* pData, unsigned long DataLength, void* lparam);
- static void __stdcall WriteLog(const char* pData, nsSerialGPM::LOG_V2_LEVEL level);
- RET_STATUS HWSendWaittimeCMD(char* strCommand, int lengh, int headLengh = 3);
- RET_STATUS HWSendHBCMD(char* strCommand, int lengh, int headLengh = 3);
- RET_STATUS HWSendWaitACKCMD(char* strCommand, int lengh, int headLengh = 3);
- //检查信息接口
- virtual RET_STATUS SetStudyInfo(ResDataObject& pParam) override;
- virtual RET_STATUS SetViewInfo(ResDataObject& pParam)override;
- virtual RET_STATUS SetPatientInfo(ResDataObject& pParam) override;
- //系统指令
- virtual RET_STATUS Reset()override; //重置错误
- virtual RET_STATUS SetTechParamsInfo(ResDataObject& pParam) override;
- virtual RET_STATUS SetPositionNumber(int pn) override;
- virtual RET_STATUS SetSID(float value) override;
- virtual RET_STATUS SetSOD(float value) override;
- virtual RET_STATUS MoveToHome(string& value) override;
- virtual RET_STATUS MoveMech(string& value) override;
- virtual RET_STATUS StopMech(string& value) override;
- virtual RET_STATUS SetGrid(AttrKey::MECH_GRIDSTATE GridState) override;
- virtual RET_STATUS SetAutoTracking(int nAutoTracking) override;
- //3D运动基本接口
- virtual RET_STATUS SetTomoEnable(bool enable) override;
- virtual RET_STATUS SetTomoExpMode(string& value) override;
- virtual RET_STATUS SetTomoTechnical(string& value) override;
- virtual RET_STATUS GetTomoResults(std::string& result) override;
- //拼接相应接口
- virtual RET_STATUS BeginStitching() override;
- virtual RET_STATUS InitStitching() override;
- virtual RET_STATUS EndStitching() override;
- virtual RET_STATUS SetupStitching(string& value) override;
- virtual RET_STATUS AcceptStitchingImage() override;
- virtual RET_STATUS RejectStitchingImage() override;
- virtual RET_STATUS CancelStitching() override;
- virtual RET_STATUS CompleteStitching() override;
- virtual RET_STATUS NewExtraView() override;
- virtual RET_STATUS RepeatStitching() override;
- virtual RET_STATUS SetAutoPosiitonNo(int nPN) override;
- //牛头
- virtual RET_STATUS SetExpEnable(bool nExpEnabled) override;
- virtual RET_STATUS SetWS(int nWS) override;
- virtual RET_STATUS SetKV(int nKV) override;
- virtual RET_STATUS SetMA(float fMA) override;
- virtual RET_STATUS SetMS(float fMS) override;
- virtual RET_STATUS SetMAS(float fMAS) override;
- virtual RET_STATUS SetFO(int nFO) override;
- virtual RET_STATUS SetTechMode(int nET) override;
- virtual RET_STATUS SetAECField(int nAECFieldSel) override;
- virtual RET_STATUS SetDensity(float nAECDensity) override;
- virtual RET_STATUS SetBodySize(string strSize) override;
- //悬吊特有
- RET_STATUS StopAllAxis();
- RET_STATUS MoveToRelativeDistance(int axisNum, int distance);
- RET_STATUS MoveToPositionNumber(int axisNum, int PosNum);
- RET_STATUS GetAllAxisPosition();
- RET_STATUS SetAxisPositionNumber(int axisNum, int xPos, int yPos, int zPos, int rPos);
- #if Dios_V3
- //V3新方法
- LogicClient* m_pSynClient; //订阅SYN调用端
- #endif
- bool SetFunToOtherUnit(const char* Signal, int SWstatus);
- static int m_iLoopTime; //循环间隔时间(毫秒)
- Axis MechStatus[AxisCount]{ {"X"}, {"Y"}, {"Z"}, {"R"} };//4个轴[位置,运动状态]
- HANDLE m_hExitEvent;//退出事件
- HANDLE m_hMoveBeginEvent;//开始移动事件
-
- private:
- //错误上报
- std::unique_ptr<nsDetail::MSGUnit> m_MSGUnit;
- HANDLE m_pHardwareStatusThread; //轮询线程句柄
- bool StartHardwareStatusThread(); //启动轮询线程
- static DWORD HardwareStatusThread(LPVOID pParam); //定时查询状态信息
- RET_STATUS HWSend(const char* strCommand, int lengh, bool reSend = false, int nTimeOut = TIMEOUTVALUE); //指令发送接口
- void OnCallBack(); //处理指令回调函数
- void Register(); //注册对外提供的属性、方法
- void FireNotify(std::string key, std::string context); //向上层上报消息
- void FireNotify(std::string key, const int context); //向上层上报消息
- void FireNotify(std::string key, const float context); //向上层上报消息
- void FireErrorMessage(const bool Act, const int Code, const char* ResInfo = ""); //上报错误消息
- void FireWarnMessage(const bool Act, const int Code, const char* ResInfo = ""); //上报告警消息
- protected:
- ResDataObject m_MechConfig;
- map<int, tTomoResult> m_mTomoResult;//TOMO每张图的位置信息
- int m_nFPDLengh{ 43 };//探测器长度
- //拼接计划使用
- int m_nMinAngle{ -150 };//标装-170~170,球管旋转90度是水平正对立柱
- int m_nMaxAngle{ 150 };
- int m_nMinHeight{ 22 };//标装20~200,球管中心是最低22,最高198
- int m_nMaxHeight{ 198 };
- //发生器参数记录
- int m_nWS{ 0 };
- int m_nKV{ 0 };
- int m_fMA{ 0 };
- int m_fMS{ 0 };
- int m_fMAS{ 0 };
- int m_nFocus{ 0 };
- int m_nET{ 0 };
- int m_nAECField{ 0 };
- int m_nAECFilm{ 0 };
- int m_nAECDensity{ 0 };
- int m_nBodySize{ 0 };
- };
- }
- //-----------------------------------------------------------------------------
- // DEMODriver
- //-----------------------------------------------------------------------------
- namespace DIOS::Dev::Detail::MECH
- {
- class _DIOSDEVMECHOTCSTITCH_API HanQing3DDriver : public IODriverWithSCF <DriverMould>
- {
- using super = IODriverWithSCF <DriverMould>;
- ResDataObject m_GenConfig;
- public:
- HanQing3DDriver();
- virtual ~HanQing3DDriver();
- virtual void Prepare() override;
- virtual bool Connect() override;
- virtual void Disconnect() override;
- virtual bool isConnected() const override;
- virtual void Dequeue(const char* Packet, DWORD Length) override;
- virtual void FireNotify(int code, std::string key, std::string content) override;
- virtual auto CreateDevice(int index)->std::unique_ptr <IODevice> override;
- virtual std::string DriverProbe() override;
- virtual std::string GetResource() override;
- virtual std::string DeviceProbe() override;
- virtual bool GetDeviceConfig(std::string& Cfg) override;
- virtual bool SetDeviceConfig(std::string Cfg) override;
- HanQing3DDevice* m_pDriGenDev;// = nullptr;
- private:
- static PACKET_RET callbackPackageProcess(const char* RecData, DWORD nLength, DWORD& PacketLength);
- //for webconfig
- ResDataObject m_DeviceConfigSend;
- ResDataObject m_DeviceConfig;
- string g_strAppPath;
- ResDataObject m_ConfigAll; //存储当前的配置,用于修改配置时写回文件
- ResDataObject m_Configurations; //存储当前配置中“CONFIGURATION”节点的内容
- std::unique_ptr <ResDataObject> m_pAttribute;
- std::unique_ptr <ResDataObject> m_pDescription;
- bool SaveConfigFile(bool bSendNotify);
- bool GetDeviceConfigValue(ResDataObject config, const char* pInnerKey, int nPathID, string& strValue);
- bool SetDeviceConfigValue(ResDataObject& config, const char* pInnerKey, int nPathID, const char* szValue);
- };
- }
|