124 virtual void setName(
const std::string& name);
140 template <
class InputT,
class OutputT>
150 const auto ptrAsInt =
reinterpret_cast<std::uint64_t
>(ptr);
152 <<
"\nThe alignment is wrong!\nIt has to be " <<
alignof(InputT)
153 <<
", but the data is aligned with " << ptrAsInt %
alignof(std::max_align_t)
154 <<
"!\nThis is an offset of " << (ptrAsInt %
alignof(InputT))
156 <<
sizeof(InputT) <<
" bytes";
157 inputs =
static_cast<InputT*
>(ptr);
163 const auto ptrAsInt =
reinterpret_cast<std::uint64_t
>(ptr);
165 <<
"\nThe alignment is wrong!\nIt has to be " <<
alignof(OutputT)
166 <<
", but the data is aligned with " << ptrAsInt %
alignof(std::max_align_t)
167 <<
"!\nThis is an offset of " << (ptrAsInt %
alignof(OutputT))
169 <<
sizeof(OutputT) <<
" bytes";
170 outputs =
static_cast<OutputT*
>(ptr);
196 template <
typename Slave>
197 std::unique_ptr<armarx::control::ethercat::SlaveInterface>
201 sidWithDefaultName.
setName(Slave::getDefaultName());
203 if (Slave::isSlaveIdentifierAccepted(sidWithDefaultName))
205 return std::make_unique<Slave>(sidWithDefaultName);
Base Class for all Logging classes.
Brief description of class Bus.
Brief description of class SlaveErrorRegistersDevice.
The SlaveIdentifier class is a POD-type representing a unique set of values identifying an EtherCAT s...
bool setName(const std::string &name)
Sets the slave name of a SlaveIdentifier and returns whether the new name fits together with the pare...
OutputT * getOutputsPtr()
bool hasPDOMapping() const final override
SlaveInterface(const SlaveIdentifier &slaveIdentifier)
void setInputPDO(void *ptr) override
void setOutputPDO(void *ptr) override
SlaveErrorRegistersDevicePtr getErrorRegistersDevice() const
SlaveErrorRegistersDevicePtr errorRegistersDevice
virtual void finishPreparingForOp()
This gets called after prepareForOp() was called.
virtual bool hasError()=0
This function indicates if there is a error or Problem with this slave.
virtual void prepareForSafeOp()
virtual bool isEmergencyStopActive() const
virtual void doMappings()=0
This is called after EtherCAT Bus is PreOp Mode.
virtual void setOutputPDO(void *ptr)=0
virtual bool handleErrors()
This tries to clear oder fix the errors or problems of the slave or just gives detailed information a...
SlaveIdentifier slaveIdentifier
virtual void finishPreparingForSafeOp()
virtual void setInputPDO(void *ptr)=0
virtual void setName(const std::string &name)
SlaveInterface(const SlaveIdentifier &slaveIdentifier)
virtual ~SlaveInterface() override
void setParentDeviceName(const std::string &name)
virtual bool hasPDOMapping() const
const SlaveIdentifier & getSlaveIdentifier() const
virtual bool recoverFromEmergencyStop()
virtual bool prepareForRun()=0
This gets triggered by the bus controller before it will start the control loop.
virtual void execute()=0
This method gets triggered by the Bus Controller, this function hast to be implemented cooperative.
virtual bool shutdown()=0
This gets triggered by the bus Controller before it will close the EtherCAT bus.
std::uint16_t getSlaveNumber() const
This returns the slave number of the slave on the bus +1 because slave 0 is the master.
virtual void prepareForOp()=0
This gets called between the SafeOp an the Op state of the bus at the initizialisation.
void setErrorRegistersDevice(SlaveErrorRegistersDevicePtr errorRegistersDevice)
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
std::shared_ptr< SlaveErrorRegistersDevice > SlaveErrorRegistersDevicePtr
std::unique_ptr< armarx::control::ethercat::SlaveInterface > createSlave(const SlaveIdentifier &sid)
std::string GetTypeString(const std::type_info &tinf, bool withoutNamespaceSpecifier=false)