Skip to main content

Robotiq::Platform Class

The OS services Gripper's threaded runtime needs, as an injectable interface: one exchange thread, one lockable object, and a yielding sleep.

Every Gripper runs on one: hosted applications pass makeDefaultPlatform(); an RTOS target implements this over the native primitives — ports/threadx/threadx_platform.hpp is the working reference. A single-threaded target (bare superloop) should skip Gripper entirely and drive GripperModbusClient itself — that layer needs no Platform. Read that class's warning first: it is the exception, not an alternative.

Concurrency contract for implementations: the sleeps may be called from several threads at once (the exchange thread paces with sleepUntil() while a blocked procedure like activate() polls with sleepFor()); makeMutex() and spawn() are called during gripper construction only.

RTOS-specific integration caveats (a yielding Serial::read, the backing of steady_clock, task priorities) are documented in the reference port, ports/threadx/threadx_platform.hpp — read them before implementing this interface for an RTOS.

Included Headers

#include <platform.hpp>

Members

Public Destructor
~Platform ()=default
Public Member Functions
std::unique_ptr< Mutex >makeMutex ()=0
std::unique_ptr< Thread >spawn (std::function< void()> fn)=0

Start a thread running fn. More...

voidsleepUntil (std::chrono::steady_clock::time_point timePoint)=0

Sleep the calling thread until a monotonic time point, yielding the CPU. More...

voidsleepFor (std::chrono::milliseconds duration)=0

Sleep the calling thread for a duration, yielding the CPU. More...

Public Destructor

~Platform()

virtual Robotiq::Platform::~Platform ()
virtual default

Public Member Functions

makeMutex()

virtual std::unique_ptr< Mutex > Robotiq::Platform::makeMutex ()
Returns

A newly constructed lockable object.

sleepFor()

virtual void Robotiq::Platform::sleepFor(std::chrono::millisecondsduration
)

Sleep the calling thread for a duration, yielding the CPU.

Parameters
duration

How long to sleep.

sleepUntil()

virtual void Robotiq::Platform::sleepUntil(std::chrono::steady_clock::time_pointtimePoint
)

Sleep the calling thread until a monotonic time point, yielding the CPU.

Parameters
timePoint

The point in time to sleep until.

spawn()

virtual std::unique_ptr< Thread > Robotiq::Platform::spawn(std::function< void()>fn
)

Start a thread running fn.

fn returns when its owner stops it; the returned handle is then join()ed before destruction.

Parameters
fn

The thread's entry function.

Returns

A handle to the running thread.


The documentation for this class was generated from the following file:

  • platform.hpp

Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.