DeviceFullUCB.hpp 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. #pragma once
  2. #include "IODeviceWithSCF.tlh"
  3. #include "IODeviceWithSCF.tli"
  4. #include "DIOS.Dev.SYNBOX.Mould.hpp"
  5. #include "DIOS.Dev.MSGMould.hpp"
  6. #include "CommonFun.h"
  7. namespace DIOS::Dev::Detail::SYNBOX
  8. {
  9. // 枚举说明:UCB通道类型
  10. enum ECOM_UCB_CHANNEL_TYPE
  11. {
  12. UCB_DI = 0,
  13. UCB_DO = 1,
  14. UCB_ALL = 2
  15. };
  16. struct stru_IN_Signal
  17. {
  18. string strSyncName; //信号名
  19. string strChannel; //通道号
  20. string strEnableValue; //使能值
  21. string strDisableValue; //非使能值
  22. string strRELAYIo; //继电器通道号
  23. string strEnableIo; //使能关联通道号
  24. string strDisableIo; //非使能关联通道号
  25. stru_IN_Signal() {};
  26. stru_IN_Signal(string Key, string channel, string Enable, string Disable, string Relay, string SetEnable, string SetDisable) :
  27. strSyncName(Key), strChannel(channel), strEnableValue(Enable), strDisableValue(Disable), strRELAYIo(Relay), strEnableIo(SetEnable), strDisableIo(SetDisable){};
  28. };
  29. struct stru_OUT_Signal
  30. {
  31. string strSyncName; //信号名
  32. string strChannel; //通道号
  33. string strEnableValue; //使能值
  34. string strDisableValue; //非使能值
  35. int nConfAllowance{ 0 }; //单次流程发送次数限制
  36. int nCurrAllowance{ 0 }; //当前发送次数
  37. int nCurrStateValue{ -1 }; //当前信号使能值
  38. stru_OUT_Signal() {};
  39. stru_OUT_Signal(string Key, string channel, string Enable, string Disable, int allowance = 0) :
  40. strSyncName(Key), strChannel(channel), strEnableValue(Enable), strDisableValue(Disable), nConfAllowance(allowance) {};
  41. };
  42. //-----------------------------------------------------------------------------
  43. // DynBoxDevice
  44. //-----------------------------------------------------------------------------
  45. namespace nDev = DIOS::Dev;
  46. namespace nsDetail = DIOS::Dev::Detail;
  47. class DeviceFullUCB : public SYNBOXMould
  48. {
  49. using superGen = SYNBOXMould;
  50. public:
  51. DeviceFullUCB(std::shared_ptr <IOEventCenter> center, string configfile);
  52. ~DeviceFullUCB();
  53. void Register(Dispatch* Dispatch);
  54. void OnCallBack();
  55. bool DealtheSignal(const string& channel, int& state); //处理信号
  56. //由工作流调用
  57. RET_STATUS SetDirectExpSignal(int signal); //直接设置出线,用于rayence类似的探测器点片需求
  58. RET_STATUS SetPulseWidth(int value); //设置脉宽
  59. //刷新些数据
  60. RET_STATUS RefreshData();
  61. protected:
  62. // 同步盒方法
  63. virtual RET_STATUS SetWS(std::string value) override; //设置工作位,会修改m_strSYNMode进而影响配置文件中<SYN0>的读取选择
  64. virtual RET_STATUS SetExpMode(std::string value) override; //设置曝光模式,决定读取SingleRad、SerialRad、CoutineSerial、PulseSerial、TOMO
  65. virtual RET_STATUS SetGenAECSignal(int signal) override; //目前乳腺专用
  66. virtual RET_STATUS SimulateFootSwitchSignal(int signal) override;
  67. virtual RET_STATUS SimulateHandSwitchSignal(int signal) override; //3DDR因手闸连在机架上,所以使用特殊方法模拟收到手闸信号
  68. virtual RET_STATUS SetDirectSignal(string channel, bool state) override; //直接设置信号
  69. virtual RET_STATUS SetValue_PPS(FLOAT fluframerate) override;
  70. virtual RET_STATUS ActiveSyncMode(_tSyncModeArgs value) override;
  71. //发生器方法
  72. virtual RET_STATUS SetGeneratorHandSwitchStatus(int state); //设置发生器手闸
  73. virtual RET_STATUS SetGeneratorFootSwitchStatus(int state); //设置发生器脚闸
  74. virtual RET_STATUS SetGeneratortoSyncStatus(int state) override; //设置发生器同步消息
  75. virtual RET_STATUS SetExposureTimes(int nNum) override; //
  76. virtual RET_STATUS SetExpEnable() override; //曝光允许
  77. virtual RET_STATUS SetExpDisable() override; //曝光禁止
  78. //探测器方法
  79. virtual RET_STATUS SetFPDXwinStatus(int state); //设置探测器开窗消息
  80. virtual RET_STATUS PrepareAcquisition() override; //
  81. virtual RET_STATUS StartWindowRequest() override; //
  82. virtual RET_STATUS StopWindowRequest() override; //
  83. virtual RET_STATUS SetFrameRate(FLOAT frameRate) override; //
  84. private:
  85. //轮询
  86. bool StartHardwareThread();
  87. static DWORD HardwareStatusThread(LPVOID pParam);
  88. //消息上报
  89. void FireNotify(std::string key, std::string context);
  90. void FireNotify(std::string key, int context);
  91. //同步盒信号处理接口
  92. void SetMultipleSignal(const string& strname, int& state);
  93. bool SetSignal(const string& strname, int state); //发送IO信号给到硬件
  94. void ClearSignal(); //重置所有信号为无效状态
  95. int NotifyUnitAttribute(const string& strname, int &state); //根据盒子收到的信号,代替发生器、探测器上报他们曝光相关的属性状态
  96. //指令发送接口
  97. bool UCBCmdSEC(void);//通信(握手)测试
  98. bool UCBCmdSVR(void);//读取版本号
  99. bool UCBCmdSSN(const string& strSerial);//产品序列号写入
  100. bool UCBCmdSSP(void);//蜂鸣器提示功能
  101. bool UCBCmdSIT(void);//输出端口初始化
  102. bool UCBCmdSRE(void);//单片机冷启动
  103. bool UCBCmdSFR(void);//出厂恢复(放在软件高级配置工具里)
  104. bool UCBCmdSEE(const char& cZ1, const char& cZ2);//EEPROM区域COPY(放在测试工具里)
  105. bool UCBCmdSRF(void);//工作状态查询命令
  106. bool UCBCmdSCF(void);//清除工作状态存储区
  107. bool UCBCmdSAS(const string& strChannelID, const int& nValue, const char& cEnable);//ABS输出命令
  108. bool UCBCmdSAD(const string& strChannelID);//ADC开启/关闭命令
  109. bool UCBCmdSRA(const string& strChannelID);//ADC读取命令
  110. bool UCBCmdSAE(const char& cInChannel, const char& cOutChannel, const char& cIO, const char& cChannel, const int& nTime, const int& nMode, const bool& bEnable);//AEC开启/关闭功能
  111. bool UCBCmdSPT(const char& cInChannel, const int& nTime);//PT_STOP时间读取功能
  112. bool UCBCmdSTL(const int& nType, const char* cID, const int& nLen, const char* cData);//发送CAN数据
  113. bool UCBCmdSCS(const char& cProtocol, const char& cBaud, const char* cFilter, const char& cEnable);//CAN通讯设置
  114. bool UCBCmdSPS(const string& strChannelID, const int& nCycle, const int& nPulse);//PWM波形属性设置
  115. bool UCBCmdSPE(const string& strChannelID, const char& cMode, const char& cEnable);//PWM波形输出使能
  116. bool UCBCmdSMS(const char& cExpMode, const int& nExpCount);//曝光模式切换
  117. bool UCBCmdSCP(const char& cZone, const int& cZoneIndex, const string& strChannelID, const char* cIOSet);//通道属性设置
  118. bool UCBCmdSCD(const char& cZone, const int& cZoneIndex, const string& strChannelID, const char* cIOSet);//通道属性读取确认
  119. bool UCBCmdSPW(const char& cZone, const char* cIOConfVer);//通道属性版本号写入
  120. bool UCBCmdSPR(const char& cZone, const char* cIOConfVer);//通道属性版本号读出
  121. bool UCBCmdSRS(const string& strChannelID, const char& cValue);//读取通道状态
  122. bool UCBCmdSWS(const string& strChannelID, const bool& bValue);//通道输出设置
  123. int SetPWMState(bool state); //使能pwm参数
  124. int SetPWMParam(float fpps, int width); //设置pwm参数
  125. int SetAreaType(); //设置曝光模式
  126. //配置项获取
  127. bool GetConfData(string& configfile);
  128. bool GetConfChannel(string expMode);
  129. private:
  130. HANDLE m_pHardwareThread{ NULL };//轮询句柄
  131. HANDLE m_hExitEvent{ NULL };//退出
  132. HANDLE m_hPWMEvent{ NULL };//单次脉冲
  133. std::shared_ptr <IOEventCenter> EventCenter; //消息上报
  134. std::unique_ptr<nsDetail::MSGUnit> m_MSGUnit; //错误消息上报
  135. ResDataObject m_ResFullUCBConfig; //配置文件
  136. string m_AreaID; //SMS曝光模式
  137. string m_ExpCounts; //SMS曝光次数
  138. map<string, stru_IN_Signal> m_FullUCBMap_IN; //输入信号控制集
  139. map<string, stru_OUT_Signal> m_FullUCBMap_OUT; //输出信号控制集
  140. map<string, string> m_WorkStationMap; //工作位配置
  141. std::string m_strCurrSYNMode; //当前工作位信号配置
  142. int m_FootSwitchState{ 0 }; //脚闸状态
  143. float m_fPPS{ 0 }; //帧率
  144. int m_PulseWidth{ 10 }; //脉宽
  145. //曝光过程记录
  146. int m_nCurrentExpCount{ 0 }; //当前曝光出线数
  147. int m_nExpMaxCount{ -1 }; //曝光出线计数上限
  148. bool m_bINEEnable_Gen{ false }; //INE信号使能允许标志
  149. bool m_bINEEnable_FPD{ false }; //开窗使能
  150. //配置项
  151. map<string, string> m_SyncModeMap; //记录自身同步能力
  152. string m_bUpdateGenSyncStatusFlag{ "0000000000" }; //是否由同步盒更新发生器Sync状态
  153. string m_bUpdateFPDXWinStatusFlag{ "00" }; //是否由同步盒更新探测器Xwindow状态
  154. bool m_bIsAutoClearSignalFlag{ false }; //是否在更新曝光模式时自动重置所有输出信号
  155. bool m_bIsCtlPWMWithMode{ false }; //是否按模式控制PWM使能脉冲数量
  156. bool m_bIsCtlPWMWithGen{ false }; //是否按发生器状态控制PWM使能
  157. };
  158. }