11 std::string DeviceList;
12 DeviceList.resize(256);
13 size_t RequiredSize = DeviceList.size();
14 auto Result = SmarActSyms::SA_CTL_FindDevices(
"", DeviceList.data(), &RequiredSize);
17 if (DeviceList.size() < RequiredSize)
19 DeviceList.resize(RequiredSize + 1);
20 RequiredSize = DeviceList.size();
21 Result = SmarActSyms::SA_CTL_FindDevices(
"", DeviceList.data(), &RequiredSize);
25 DeviceList.resize(RequiredSize);
27 if (Result != SA_CTL_ERROR_NONE)
31 std::replace(DeviceList.begin(), DeviceList.end(),
'\n',
' ');
32 std::istringstream ss(DeviceList);
33 std::vector<std::string> DeviceDescriptors{ std::istream_iterator<std::string>(ss), std::istream_iterator<std::string>() };
35 return DeviceDescriptors;
42 std::find(SmarActDevices.cbegin(), SmarActDevices.cend(),
DeviceDescriptor) == std::cend(SmarActDevices))
44 if (SmarActDevices.empty())
52 : HardwareAdapterBase(OwnerThreadID, std::move(Params))
65 auto DerivedParams = dynamic_Params_cast<SmarActHardwareAdapter>(
GetParams());
108 if (Result == SA_CTL_ERROR_NONE)
111 std::string ErrorString(SmarActSyms::SA_CTL_GetResultInfo(Result));
145 auto Result = SmarActSyms::SA_CTL_GetProperty_i64(
SmarActHandle, Channel, SA_CTL_PKEY_POSITION, &Position,
nullptr);
156 auto Result = SmarActSyms::SA_CTL_GetProperty_i64(
SmarActHandle, Channel, SA_CTL_PKEY_TARGET_POSITION, &TargetPosition,
nullptr);
159 return TargetPosition;
167 auto Result = SmarActSyms::SA_CTL_GetProperty_i64(
SmarActHandle, Channel, SA_CTL_PKEY_MOVE_VELOCITY, &Velocity,
nullptr);
178 auto Result = SmarActSyms::SA_CTL_GetProperty_i32(
SmarActHandle, Channel, SA_CTL_PKEY_CHANNEL_STATE, &State, 0);
188 auto Result = SmarActSyms::SA_CTL_Calibrate(
SmarActHandle, Channel, 0);
198 auto Result = SmarActSyms::SA_CTL_Reference(
SmarActHandle, Channel, 0);
206 auto Result = SmarActSyms::SA_CTL_SetProperty_i64(
SmarActHandle, Channel, SA_CTL_PKEY_MOVE_VELOCITY, Velocity);
214 auto Result = SmarActSyms::SA_CTL_SetProperty_i32(
SmarActHandle, Channel, SA_CTL_PKEY_MOVE_MODE, SA_CTL_MOVE_MODE_CL_ABSOLUTE);
217 Result = SmarActSyms::SA_CTL_Move(
SmarActHandle, Channel, Position, 0);
225 auto Result = SmarActSyms::SA_CTL_SetProperty_i32(
SmarActHandle, Channel, SA_CTL_PKEY_MOVE_MODE, SA_CTL_MOVE_MODE_CL_RELATIVE);
228 Result = SmarActSyms::SA_CTL_Move(
SmarActHandle, Channel, Position, 0);
239 auto Result = SmarActSyms::SA_CTL_Stop(
SmarActHandle, Channel, 0);
Implementation of a hardware adapter to control SmarAct MCS2 hardware.
Param< TextList > DeviceDescriptor
void ConfigureParamsImpl(dispatch_tag< HardwareAdapterParamsBase >) override final
PositionType GetVelocity(const ChannelType Channel) const
int32_t GetChannelState(const ChannelType Channel) const
void MoveAbsolute(const ChannelType Channel, PositionType Position) const
bool IsConnectedChild() const noexcept override final
Determines the connection status of the hardware interface.
void ResetImpl(dispatch_tag< HardwareAdapterBase >) override final
std::atomic< bool > SmarActHandleValid
void MoveRelative(const ChannelType Channel, PositionType Position) const
void CheckError(const SmarActSyms::SA_CTL_Result_t Result, const std::source_location Location=std::source_location::current()) const
PositionType GetTargetPosition(const ChannelType Channel) const
SmarActSyms::SA_CTL_DeviceHandle_t SmarActHandle
void EnsureReadyStateChild() override final
Ensures that this Object instance is ready by possibly starting its worker thread or by opening conne...
void Calibrate(const ChannelType Channel) const
void SetVelocity(const ChannelType Channel, PositionType Velocity) const
bool IsOpened() const noexcept
void Reference(const ChannelType Channel) const
SmarActHardwareAdapter(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params)
std::string DeviceDescriptor
bool IsReadyChild() const override final
Returns wheter this Object instance is ready (e.g. it is running or connected to a hardware device) a...
virtual ~SmarActHardwareAdapter()
void StopMotion(const ChannelType Channel) const
PositionType GetCurrentPosition(const ChannelType Channel) const
static constexpr auto HardwareOperationTimeout
Default timeout used to lock the mutex provided by the base class Util::ILockable to synchronize acce...
void ThrowExceptionUnsafe(std::exception_ptr Exception) const
Stores Exception in LastException, wraps it in a Util::ForwardedException and throws the wrapped exce...
auto GetExceptionUnsafe() const
Getter for LastException.
ParamsConstTypeSyncPtrType GetParams(const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault) const
Locks the mutex of the parameter class instance Params assigned to this Object instance and returns a...
Refer to ParamsBase::dispatch_tag.
Tag for function dispatching mechanism within this class used when derived classes are not intended t...
Thrown when a list is expected to contain entries and when a query results in an empty answer or an e...
LockType AcquireLock(const std::chrono::milliseconds Timeout=DefaultTimeout) const
Locks the internal mutex. Blocks until the mutex is locked or until the timeout duration is exceeded.
DynExp's hardware namespace contains the implementation of DynExp hardware adapters which extend DynE...
std::unique_ptr< ParamsBase > ParamsBasePtrType
Alias for a pointer to the parameter system base class ParamsBase.
void ForwardException(std::exception_ptr e)
Wraps the exception passed to the function in a ForwardedException and throws the ForwardedException....
Accumulates include statements to provide a precompiled header.