CArmGeneralModel.cpp 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. #include "stdafx.h"
  2. #include "CArmGeneralModel.h"
  3. #include "CArmGeneralMotionStageArgs.h"
  4. #include "MotionStages.h"
  5. #include "IMachineryManager.h"
  6. #include "CArmComponentNameDef.h"
  7. #include "ICircularController.h"
  8. #include "ISwingController.h"
  9. #include "ConfigurerMotion.h"
  10. #include "ISensorEncoderController.h"
  11. #include "IPositionManager.h"
  12. #include "FluoroSwitchController.h"
  13. using namespace DIOS::Dev::Detail::MachineryECOM;
  14. CArmGeneralModel::CArmGeneralModel()
  15. :m_StageName(""),
  16. m_stageArgs(new CArmGeneralMotionStageArgs()),
  17. m_coordinates(nullptr),
  18. m_circular(nullptr),
  19. m_swing(nullptr),
  20. m_circularencoder(nullptr),
  21. m_swingencoder(nullptr),
  22. m_fluoroSwitch(nullptr),
  23. m_tubeCircularMotionPeriod(150),
  24. m_tubeSwingMotionPeriod(150)
  25. {
  26. }
  27. CArmGeneralModel::~CArmGeneralModel()
  28. {
  29. }
  30. void CArmGeneralModel::ChangeStage(const std::string &stageName)
  31. {
  32. m_StageName = stageName;
  33. OnMotionStage(stageName);
  34. }
  35. std::string CArmGeneralModel::GetStageName()
  36. {
  37. return m_StageName;
  38. }
  39. IMotionStageArgs *CArmGeneralModel::GetStageArgs()
  40. {
  41. return m_stageArgs;
  42. }
  43. void CArmGeneralModel::Initialize(IMachineryManager *machineryManager, IPositionManager *coordinates)
  44. {
  45. m_coordinates = coordinates;
  46. m_circular = (ICircularController*)machineryManager->Resove(CONTROLLER_CARM_TUBE_CIRCULAR);
  47. m_swing = (ISwingController*)machineryManager->Resove(CONTROLLER_CARM_TUBE_SWING);
  48. m_circularencoder = (ISensorEncoderController*)machineryManager->Resove(CONTROLLER_CARM_TUBE_CIRCULAR_ENCODER);
  49. m_swingencoder = (ISensorEncoderController*)machineryManager->Resove(CONTROLLER_CARM_TUBE_SWING_ENCODER);
  50. m_fluoroSwitch = (IOutputController*)(machineryManager->Resove(CONTROLLER_FLUOROSWITCH));
  51. }
  52. void CArmGeneralModel::LoadMachineryParams(ResDataObject &params)
  53. {
  54. m_tubeSwingMotionPeriod = (DWORD)atoi((const char *)params["ResetRotatePeriod"]);
  55. m_tubeCircularMotionPeriod = (DWORD)atoi((const char *)params["ResetHeightPeriod"]);
  56. }
  57. void CArmGeneralModel::LoadModelParams(ResDataObject &params)
  58. {
  59. }
  60. void CArmGeneralModel::SetTechnicalParams(ResDataObject &params)
  61. {
  62. }
  63. void CArmGeneralModel::OnFeedbackMotionParams(ResDataObject &params)
  64. {
  65. }
  66. BOOL CArmGeneralModel::GetMotionParams(ResDataObject &params)
  67. {
  68. return FALSE;
  69. }
  70. void CArmGeneralModel::OnMotionStage(const std::string &name)
  71. {
  72. if (name == CARM_GENERAL_MOVE_TUBE_CIRCULAR)
  73. {
  74. OnMotionStageMoveTubeCircular();
  75. }
  76. else if (name == CARM_GENERAL_MOVE_TUBE_SWING)
  77. {
  78. OnMotionStageMoveTubeSwing();
  79. }
  80. else if (name == CARM_GENERAL_GET_TUBE_CIRCULAR_ENCODER)
  81. {
  82. OnMotionStageGetTubeCircularEncoder();
  83. }
  84. else if (name == CARM_GENERAL_GET_TUBE_SWING_ENCODER)
  85. {
  86. OnMotionStageGetTubeSwingEncoder();
  87. }
  88. else if (name == CARM_GENERAL_ACTIVE_TUBE_SWING_Z_AXIS)
  89. {
  90. OnMotionStageActiveTubeSwingZAxis();
  91. }
  92. else if (name == CARM_GENERAL_CANCLE_TUBE_SWING_Z_AXIS)
  93. {
  94. OnMotionStageCancleTubeSwingZAxis();
  95. }
  96. else if (name == CARM_GENERAL_ACTIVE_TUBE_CIRCULAR_Z_AXIS)
  97. {
  98. OnMotionStageActiveTubeCircularZAxis();
  99. }
  100. else if (name == CARM_GENERAL_CANCLE_TUBE_CIRCULAR_Z_AXIS)
  101. {
  102. OnMotionStageCancleTubeCircularZAxis();
  103. }
  104. else if (name == CARM_GENERAL_STOP_MECH_MOVING)
  105. {
  106. OnMotionStageStopMechMoving();
  107. }
  108. else if (name == CARM_GENERAL_MOVE_TUBE_SWING_AS_PHYSICAL)
  109. {
  110. OnMotionStageMoveTubeSwingAsPhysical();
  111. }
  112. else if (name == CARM_GENERAL_MOVE_TUBE_CIRCULAR_AS_PHYSICAL)
  113. {
  114. OnMotionStageMoveTubeCircularAsPhysical();
  115. }
  116. else if (name == CARM_GENERAL_START_EXPOSURE)
  117. {
  118. OnStartExposure();
  119. }
  120. else if (name == CARM_GENERAL_STOP_EXPOSURE)
  121. {
  122. OnStopExposure();
  123. }
  124. }
  125. void CArmGeneralModel::OnMotionStageMoveTubeCircular()
  126. {
  127. m_circular->Rotate(
  128. m_stageArgs->TubeCircularMoveDirection,
  129. m_stageArgs->TubeCircularMoveStep,
  130. m_tubeCircularMotionPeriod);
  131. }
  132. void CArmGeneralModel::OnMotionStageMoveTubeSwing()
  133. {
  134. m_swing->Swing(
  135. m_stageArgs->TubeSwingDirection,
  136. m_stageArgs->TubeSwingStep,
  137. m_tubeSwingMotionPeriod);
  138. }
  139. void CArmGeneralModel::OnMotionStageGetTubeCircularEncoder()
  140. {
  141. auto value = m_circularencoder->GetCurrentEncoderValue();
  142. m_stageArgs->TubeCircularEncoder = value;
  143. }
  144. void CArmGeneralModel::OnMotionStageGetTubeSwingEncoder()
  145. {
  146. auto value = m_swingencoder->GetCurrentEncoderValue();
  147. m_stageArgs->TubeSwingEncoder = value;
  148. }
  149. void CArmGeneralModel::OnMotionStageActiveTubeSwingZAxis()
  150. {
  151. m_swingencoder->BindZAxis();
  152. m_swingencoder->ActiveAutoNotifyWhenZClear(true);
  153. }
  154. void CArmGeneralModel::OnMotionStageCancleTubeSwingZAxis()
  155. {
  156. m_swingencoder->UnBindZAxis();
  157. m_swingencoder->ActiveAutoNotifyWhenZClear(false);
  158. }
  159. void CArmGeneralModel::OnMotionStageActiveTubeCircularZAxis()
  160. {
  161. m_circularencoder->BindZAxis();
  162. m_circularencoder->ActiveAutoNotifyWhenZClear(true);
  163. }
  164. void CArmGeneralModel::OnMotionStageCancleTubeCircularZAxis()
  165. {
  166. m_circularencoder->UnBindZAxis();
  167. m_circularencoder->ActiveAutoNotifyWhenZClear(false);
  168. }
  169. void CArmGeneralModel::OnMotionStageStopMechMoving()
  170. {
  171. m_circular->StopRotation();
  172. m_swing->StopSwing();
  173. }
  174. void CArmGeneralModel::OnMotionStageMoveTubeSwingAsPhysical()
  175. {
  176. auto step = m_coordinates->ConvertMotorStepValue(m_swing->Name(), m_stageArgs->TubeSwingPhysical);
  177. m_swing->Swing(
  178. m_stageArgs->TubeSwingDirection,
  179. step,
  180. m_tubeSwingMotionPeriod);
  181. }
  182. void CArmGeneralModel::OnMotionStageMoveTubeCircularAsPhysical()
  183. {
  184. auto step = m_coordinates->ConvertMotorStepValue(m_circular->Name(), m_stageArgs->TubeCircularMovePhysical);
  185. m_circular->Rotate(
  186. m_stageArgs->TubeCircularMoveDirection,
  187. step,
  188. m_tubeCircularMotionPeriod);
  189. }
  190. void CArmGeneralModel::SwitchScanningComponents(int nSwitch)
  191. {
  192. }
  193. void CArmGeneralModel::OnStartExposure()
  194. {
  195. if (m_fluoroSwitch)
  196. {
  197. if (gbusinessLog) gbusinessLog->Info("[CArmGeneralModel][OnStartExposure]->[Enable fluoro switch signal]");
  198. m_fluoroSwitch->OutputSignal(true);
  199. }
  200. }
  201. void CArmGeneralModel::OnStopExposure()
  202. {
  203. if (m_fluoroSwitch)
  204. {
  205. if (gbusinessLog) gbusinessLog->Info("[CArmGeneralModel][OnStopExposure]->[Disable fluoro switch signal]");
  206. m_fluoroSwitch->OutputSignal(false);
  207. }
  208. }
  209. void CArmGeneralModel::SwitchWorkstation(string ws)
  210. {
  211. m_CurWS = ws;
  212. }