11 auto InstrParams = DynExp::dynamic_Params_cast<PI_C_862>(Instance.
ParamsGetter());
14 Instance.
LockObject(InstrParams->HardwareAdapter, InstrData->HardwareAdapter);
15 InstrData->HardwareAdapter->Clear();
18 *InstrData->HardwareAdapter <<
"RT";
19 *InstrData->HardwareAdapter << std::string(1,
static_cast<char>(1)) + InstrParams->MercuryAddress.Get();
22 InstrData->HardwareAdapter->WaitForLine(3, std::chrono::milliseconds(50));
37 *InstrData->HardwareAdapter <<
"AB";
53 bool UpdateError =
false;
58 *InstrData->HardwareAdapter <<
"TP";
59 InstrData->SetCurrentPosition(Util::StrToT<PositionerStageData::PositionType>(
63 *InstrData->HardwareAdapter <<
"TY";
64 InstrData->SetVelocity(Util::StrToT<PositionerStageData::PositionType>(
68 *InstrData->HardwareAdapter <<
"TS";
70 StatusStream.exceptions(std::ofstream::failbit | std::ofstream::badbit);
71 StatusStream << std::hex;
77 InstrData->LM629Status.Set(
static_cast<uint8_t
>(Byte));
79 StatusStream.seekg(15);
90 if (InstrData->NumFailedStatusUpdateAttempts++ >= 3)
95 InstrData->NumFailedStatusUpdateAttempts = 0;
112 catch (
const std::stringstream::failure& e)
124 auto InstrData = DynExp::dynamic_InstrumentData_cast<PI_C_862>(Instance.
InstrumentDataGetter());
127 *InstrData->HardwareAdapter <<
"DH";
134 auto InstrData = DynExp::dynamic_InstrumentData_cast<PI_C_862>(Instance.
InstrumentDataGetter());
138 *InstrData->HardwareAdapter <<
"FE0";
140 *InstrData->HardwareAdapter <<
"FE1";
147 auto InstrData = DynExp::dynamic_InstrumentData_cast<PI_C_862>(Instance.
InstrumentDataGetter());
150 *InstrData->HardwareAdapter <<
"SV" +
Util::ToStr(Velocity);
157 auto InstrData = DynExp::dynamic_InstrumentData_cast<PI_C_862>(Instance.
InstrumentDataGetter());
160 *InstrData->HardwareAdapter <<
"GH";
167 auto InstrData = DynExp::dynamic_InstrumentData_cast<PI_C_862>(Instance.
InstrumentDataGetter());
170 *InstrData->HardwareAdapter <<
"MA" +
Util::ToStr(Position);
177 auto InstrData = DynExp::dynamic_InstrumentData_cast<PI_C_862>(Instance.
InstrumentDataGetter());
180 *InstrData->HardwareAdapter <<
"MR" +
Util::ToStr(Position);
187 auto InstrData = DynExp::dynamic_InstrumentData_cast<PI_C_862>(Instance.
InstrumentDataGetter());
190 *InstrData->HardwareAdapter <<
"AB";
199 NumFailedStatusUpdateAttempts = 0;
206 return !LM629Status.TrajectoryComplete();
211 return LM629Status.TrajectoryComplete();
216 return ErrorCode != 0
217 || LM629Status.CommandError() || LM629Status.PositionLimitExceeded()
218 || LM629Status.ExcessivePositionError() || LM629Status.BreakpointReached();
224 auto Pos = Answer.find(StartCode);
226 if (Pos == std::string::npos)
229 return Answer.substr(Pos + 2);
239 auto InstrData = DynExp::dynamic_InstrumentData_cast<PI_C_862>(
GetInstrumentData());
242 *InstrData->HardwareAdapter <<
"AB";
Implementation of an instrument to control the Physik Instrumente (PI) C-862 positioner stage.
virtual bool HasArrivedChild() const noexcept override
Returns whether the stage has arrived at its destiny position (result of HasArrivedChild())
virtual bool HasFailedChild() const noexcept override
Returns whether the stage is in an error state, i.e. moving has failed (result of HasFailedChild())
virtual bool IsMovingChild() const noexcept override
Returns whether the stage is currently moving (result of IsMovingChild())
void ResetImpl(dispatch_tag< PositionerStageData >) override final
Refer to DynExp::InstrumentDataBase::Reset(). Using tag dispatch mechanism to ensure that ResetImpl()...
void ExitFuncImpl(dispatch_tag< PositionerStageTasks::ExitTask >, DynExp::InstrumentInstance &Instance) override final
Deinitializes the respective instrument within the instrument inheritance hierarchy....
void InitFuncImpl(dispatch_tag< PositionerStageTasks::InitTask >, DynExp::InstrumentInstance &Instance) override final
Initializes the respective instrument within the instrument inheritance hierarchy....
virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance &Instance) override
Runs the task. Override RunChild() to define a derived task's action(s). Any exception leaving RunChi...
virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance &Instance) override
Runs the task. Override RunChild() to define a derived task's action(s). Any exception leaving RunChi...
virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance &Instance) override
Runs the task. Override RunChild() to define a derived task's action(s). Any exception leaving RunChi...
virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance &Instance) override
Runs the task. Override RunChild() to define a derived task's action(s). Any exception leaving RunChi...
virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance &Instance) override
Runs the task. Override RunChild() to define a derived task's action(s). Any exception leaving RunChi...
void UpdateFuncImpl(dispatch_tag< PositionerStageTasks::UpdateTask >, DynExp::InstrumentInstance &Instance) override final
Updates the respective instrument within the instrument inheritance hierarchy. Call UpdateFuncImpl() ...
void ResetImpl(dispatch_tag< PositionerStage >) override final
Refer to DynExp::Object::Reset(). Using tag dispatch mechanism to ensure that ResetImpl() of every de...
virtual void OnErrorChild() const override
Derived classes can perform critical shutdown actions after an error has occurred....
PI_C_862(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params)
static std::string AnswerToNumberString(std::string &&Answer, const char *StartCode)
Implementation of a meta instrument to control single-axis positioner stages.
Refer to DynExp::ParamsBase::dispatch_tag.
Refer to DynExp::ParamsBase::dispatch_tag.
InstrumentDataTypeSyncPtrType GetInstrumentData(const std::chrono::milliseconds Timeout=GetInstrumentDataTimeoutDefault)
Locks the mutex of the instrument data class instance InstrumentData assigned to this InstrumentBase ...
Refer to ParamsBase::dispatch_tag.
Defines data for a thread belonging to a InstrumentBase instance. Refer to RunnableInstance.
const InstrumentBase::InstrumentDataGetterType InstrumentDataGetter
Getter for instrument's data. Refer to InstrumentBase::InstrumentDataGetterType.
Refer to ParamsBase::dispatch_tag.
const Object::ParamsGetterType ParamsGetter
Invoke to obtain the parameters (derived from ParamsBase) of Owner.
void UnlockObject(LinkedObjectWrapperContainer< ObjectT > &ObjectWrapperContainer)
Unlocks an Object instance stored in the LinkedObjectWrapperContainer ObjectWrapperContainer....
void LockObject(const ParamsBase::Param< ObjectLink< ObjectT >> &LinkParam, LinkedObjectWrapperContainer< ObjectT > &ObjectWrapperContainer, std::chrono::milliseconds Timeout=ObjectLinkBase::LockObjectTimeoutDefault)
Locks an Object instance referenced by a parameter LinkParam of type ParamsBase::Param< ObjectLink< O...
const auto & GetOwner() const noexcept
Returns Owner.
Defines the return type of task functions.
Refer to DynExp::ParamsBase::dispatch_tag.
Data to operate on is invalid for a specific purpose. This indicates a corrupted data structure or fu...
Thrown when an operation timed out before it could be completed, especially used for locking shared d...
DynExp's instrument namespace contains the implementation of DynExp instruments which extend DynExp's...
std::unique_ptr< ParamsBase > ParamsBasePtrType
Alias for a pointer to the parameter system base class ParamsBase.
std::string ToStr(const T &Value, int Precision=-1)
Converts a (numeric) value of type T to a std::string using operator<< of std::stringstream.
Accumulates include statements to provide a precompiled header.