123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248 |
- #include "stdafx.h"
- #include "CArmGeneralModel.h"
- #include "CArmGeneralMotionStageArgs.h"
- #include "MotionStages.h"
- #include "IMachineryManager.h"
- #include "CArmComponentNameDef.h"
- #include "ICircularController.h"
- #include "ISwingController.h"
- #include "ConfigurerMotion.h"
- #include "ISensorEncoderController.h"
- #include "IPositionManager.h"
- #include "FluoroSwitchController.h"
- using namespace DIOS::Dev::Detail::MachineryECOM;
- CArmGeneralModel::CArmGeneralModel()
- :m_StageName(""),
- m_stageArgs(new CArmGeneralMotionStageArgs()),
- m_coordinates(nullptr),
- m_circular(nullptr),
- m_swing(nullptr),
- m_circularencoder(nullptr),
- m_swingencoder(nullptr),
- m_fluoroSwitch(nullptr),
- m_tubeCircularMotionPeriod(150),
- m_tubeSwingMotionPeriod(150)
- {
- }
- CArmGeneralModel::~CArmGeneralModel()
- {
- }
- void CArmGeneralModel::ChangeStage(const std::string &stageName)
- {
- m_StageName = stageName;
- OnMotionStage(stageName);
- }
- std::string CArmGeneralModel::GetStageName()
- {
- return m_StageName;
- }
- IMotionStageArgs *CArmGeneralModel::GetStageArgs()
- {
- return m_stageArgs;
- }
- void CArmGeneralModel::Initialize(IMachineryManager *machineryManager, IPositionManager *coordinates)
- {
- m_coordinates = coordinates;
- m_circular = (ICircularController*)machineryManager->Resove(CONTROLLER_CARM_TUBE_CIRCULAR);
- m_swing = (ISwingController*)machineryManager->Resove(CONTROLLER_CARM_TUBE_SWING);
- m_circularencoder = (ISensorEncoderController*)machineryManager->Resove(CONTROLLER_CARM_TUBE_CIRCULAR_ENCODER);
- m_swingencoder = (ISensorEncoderController*)machineryManager->Resove(CONTROLLER_CARM_TUBE_SWING_ENCODER);
- m_fluoroSwitch = (IOutputController*)(machineryManager->Resove(CONTROLLER_FLUOROSWITCH));
- }
- void CArmGeneralModel::LoadMachineryParams(ResDataObject ¶ms)
- {
- m_tubeSwingMotionPeriod = (DWORD)atoi((const char *)params["ResetRotatePeriod"]);
- m_tubeCircularMotionPeriod = (DWORD)atoi((const char *)params["ResetHeightPeriod"]);
- }
- void CArmGeneralModel::LoadModelParams(ResDataObject ¶ms)
- {
- }
- void CArmGeneralModel::SetTechnicalParams(ResDataObject ¶ms)
- {
- }
- void CArmGeneralModel::OnFeedbackMotionParams(ResDataObject ¶ms)
- {
- }
- BOOL CArmGeneralModel::GetMotionParams(ResDataObject ¶ms)
- {
- return FALSE;
- }
- void CArmGeneralModel::OnMotionStage(const std::string &name)
- {
- if (name == CARM_GENERAL_MOVE_TUBE_CIRCULAR)
- {
- OnMotionStageMoveTubeCircular();
- }
- else if (name == CARM_GENERAL_MOVE_TUBE_SWING)
- {
- OnMotionStageMoveTubeSwing();
- }
- else if (name == CARM_GENERAL_GET_TUBE_CIRCULAR_ENCODER)
- {
- OnMotionStageGetTubeCircularEncoder();
- }
- else if (name == CARM_GENERAL_GET_TUBE_SWING_ENCODER)
- {
- OnMotionStageGetTubeSwingEncoder();
- }
- else if (name == CARM_GENERAL_ACTIVE_TUBE_SWING_Z_AXIS)
- {
- OnMotionStageActiveTubeSwingZAxis();
- }
- else if (name == CARM_GENERAL_CANCLE_TUBE_SWING_Z_AXIS)
- {
- OnMotionStageCancleTubeSwingZAxis();
- }
- else if (name == CARM_GENERAL_ACTIVE_TUBE_CIRCULAR_Z_AXIS)
- {
- OnMotionStageActiveTubeCircularZAxis();
- }
- else if (name == CARM_GENERAL_CANCLE_TUBE_CIRCULAR_Z_AXIS)
- {
- OnMotionStageCancleTubeCircularZAxis();
- }
- else if (name == CARM_GENERAL_STOP_MECH_MOVING)
- {
- OnMotionStageStopMechMoving();
- }
- else if (name == CARM_GENERAL_MOVE_TUBE_SWING_AS_PHYSICAL)
- {
- OnMotionStageMoveTubeSwingAsPhysical();
- }
- else if (name == CARM_GENERAL_MOVE_TUBE_CIRCULAR_AS_PHYSICAL)
- {
- OnMotionStageMoveTubeCircularAsPhysical();
- }
- else if (name == CARM_GENERAL_START_EXPOSURE)
- {
- OnStartExposure();
- }
- else if (name == CARM_GENERAL_STOP_EXPOSURE)
- {
- OnStopExposure();
- }
- }
- void CArmGeneralModel::OnMotionStageMoveTubeCircular()
- {
- m_circular->Rotate(
- m_stageArgs->TubeCircularMoveDirection,
- m_stageArgs->TubeCircularMoveStep,
- m_tubeCircularMotionPeriod);
- }
- void CArmGeneralModel::OnMotionStageMoveTubeSwing()
- {
- m_swing->Swing(
- m_stageArgs->TubeSwingDirection,
- m_stageArgs->TubeSwingStep,
- m_tubeSwingMotionPeriod);
- }
- void CArmGeneralModel::OnMotionStageGetTubeCircularEncoder()
- {
- auto value = m_circularencoder->GetCurrentEncoderValue();
- m_stageArgs->TubeCircularEncoder = value;
- }
- void CArmGeneralModel::OnMotionStageGetTubeSwingEncoder()
- {
- auto value = m_swingencoder->GetCurrentEncoderValue();
- m_stageArgs->TubeSwingEncoder = value;
- }
- void CArmGeneralModel::OnMotionStageActiveTubeSwingZAxis()
- {
- m_swingencoder->BindZAxis();
- m_swingencoder->ActiveAutoNotifyWhenZClear(true);
- }
- void CArmGeneralModel::OnMotionStageCancleTubeSwingZAxis()
- {
- m_swingencoder->UnBindZAxis();
- m_swingencoder->ActiveAutoNotifyWhenZClear(false);
- }
- void CArmGeneralModel::OnMotionStageActiveTubeCircularZAxis()
- {
- m_circularencoder->BindZAxis();
- m_circularencoder->ActiveAutoNotifyWhenZClear(true);
- }
- void CArmGeneralModel::OnMotionStageCancleTubeCircularZAxis()
- {
- m_circularencoder->UnBindZAxis();
- m_circularencoder->ActiveAutoNotifyWhenZClear(false);
- }
- void CArmGeneralModel::OnMotionStageStopMechMoving()
- {
- m_circular->StopRotation();
- m_swing->StopSwing();
- }
- void CArmGeneralModel::OnMotionStageMoveTubeSwingAsPhysical()
- {
- auto step = m_coordinates->ConvertMotorStepValue(m_swing->Name(), m_stageArgs->TubeSwingPhysical);
- m_swing->Swing(
- m_stageArgs->TubeSwingDirection,
- step,
- m_tubeSwingMotionPeriod);
- }
- void CArmGeneralModel::OnMotionStageMoveTubeCircularAsPhysical()
- {
- auto step = m_coordinates->ConvertMotorStepValue(m_circular->Name(), m_stageArgs->TubeCircularMovePhysical);
- m_circular->Rotate(
- m_stageArgs->TubeCircularMoveDirection,
- step,
- m_tubeCircularMotionPeriod);
- }
- void CArmGeneralModel::SwitchScanningComponents(int nSwitch)
- {
- }
- void CArmGeneralModel::OnStartExposure()
- {
- if (m_fluoroSwitch)
- {
- if (gbusinessLog) gbusinessLog->Info("[CArmGeneralModel][OnStartExposure]->[Enable fluoro switch signal]");
- m_fluoroSwitch->OutputSignal(true);
- }
- }
- void CArmGeneralModel::OnStopExposure()
- {
- if (m_fluoroSwitch)
- {
- if (gbusinessLog) gbusinessLog->Info("[CArmGeneralModel][OnStopExposure]->[Disable fluoro switch signal]");
- m_fluoroSwitch->OutputSignal(false);
- }
- }
- void CArmGeneralModel::SwitchWorkstation(string ws)
- {
- m_CurWS = ws;
- }
|