Go to the documentation of this file.
65 #ifndef COMMUNICATOR_H
66 #define COMMUNICATOR_H
112 template <
typename T>
116 template <
typename T>
123 template <
typename T>
void removeProtocolHandler(XsProtocolType type)
Removes a protocol handler.
Abstract reply object. Blocks on a semaphore when requesting the message until the message has been s...
bool hasProtocol(XsProtocolType type) const
XsString lastResultText() const
Get the accompanying error text for the value returned by lastResult() It may provide situation-speci...
virtual XsResultValue gotoMeasurement()=0
Request a device to go to measurement mode.
virtual bool isDockedAt(Communicator *other) const =0
Returns true if the other device is docked at this device.
A list of uint8_t values.
virtual bool allowReprocessing() const
virtual XsPortInfo portInfo() const =0
OpenPortStage
Port opening stages.
uint32_t defaultTimeout() const
bool sanityCheck(XsMessage const &msg) const
Do a sanity check on a potential message.
virtual void setGotoConfigTimeout(uint32_t timeout)=0
Set the timeout for the gotoConfig function.
void setMasterDevice(XsDevice *masterDevice)
Sets a master device.
XsDeviceId m_masterDeviceId
A master device ID.
std::shared_ptr< ProtocolManager > protocolManager() const
Structure containing a full device configuration as returned by the ReqConfig message.
void setMasterDeviceId(const XsDeviceId &deviceId)
Sets a master device ID.
The communicator deleter.
XsDeviceId masterDeviceId() const
virtual void handleMessage(const XsMessage &message)
Handles a message.
bool m_preparedForDestruction
Prepared for destruction boolean variable.
std::shared_ptr< ReplyObject > addReplyObject(uint8_t mid)
Add a MidReplyObject.
XsResultValue m_lastResult
A last result variable.
virtual XsResultValue gotoConfig(bool detectRs485=false)=0
Request a device to go to config mode.
virtual XsFilePos logFileReadPosition() const =0
virtual bool isPortOpen() const =0
Communicator(void)
Constructor, creates some management objects and clears the rest by calling initialize()
virtual bool isReadingFromFile() const =0
virtual void addProtocolHandler(IProtocolHandler *handler)
Adds a protocol handler.
virtual void flushPort()=0
Flushes all remaining data on the open port.
virtual void loadLogFile(XsDevice *device)=0
Load a complete logfile.
XsResultValue
Xsens result values.
XsResultValue lastResult() const
Get the result value of the last operation.
std::unique_ptr< xsens::ReplyMonitor > m_replyMonitor
An unique pointer to a reply monitor.
xsens::Mutex m_handleMux
A handle mutex.
virtual XsMessage readMessage(uint8_t msgId=0)=0
Read a message from the open file.
bool doTransaction(const XsMessage &message)
Write a message and await the reply.
A base struct for a communication interface.
static UniquePtr< T > createUniquePtr(T *communicator)
Creates a UniquePtr<T> from a Communicator*.
Contains a descriptor for opening a communication port to an Xsens device.
virtual void setCredentials(XsString const &id, XsString const &key)
Set the credentials required for using the device.
virtual bool isLoadLogFileInProgress() const
Interface class for protocol handlers.
void setDefaultTimeout(uint32_t timeout)
Sets a default timeout.
XsDevice * masterDevice() const
size_t XsSize
XsSize must be unsigned number!
void operator()(Communicator *c)
A function that destroys communicator.
virtual void waitForLastTaskCompletion()=0
Wait for the last processing task to complete in the threadpool.
XsDevice * m_masterInfo
A master device object.
Structure for storing a single message.
virtual void resetLogFileReadPosition(void)=0
Resets the logfile read position.
virtual XsMessage readMessageFromStartOfFile(uint8_t msgId, int maxMsgs=0)=0
Read a message from the start of the open file.
Contains an Xsens device ID and provides operations for determining the type of device.
virtual bool openLogFile(const XsString &filename)=0
Open the log file `.
virtual XsResultValue getDeviceId()=0
Request a device to get device ID.
virtual std::deque< XsMessage > readMessagesFromStartOfFile(uint8_t msgId, int maxMsgs=0)=0
Read multiple similar messages from the start of the open file.
virtual XsTimeStamp logFileDate() const =0
virtual void setKeepAlive(bool enable)=0
Either disable or enable (default) the keep alive mechanism (if supported by the device)
virtual bool reopenPort(OpenPortStage stage=OPS_Full, bool skipDeviceIdCheck=false)=0
Reopens the port.
static int configurationMessageSearchLimit()
virtual void prepareForDestruction()
Prepares communicator for destruction.
virtual void scheduleClosePort()
Schedules to close the open port.
virtual bool writeMessage(const XsMessage &message)=0
Write message to the device.
virtual XsFilePos logFileSize() const =0
std::shared_ptr< ProtocolManager > m_protocolManager
A shared pointer to protocl manager.
virtual ~Communicator()
Destructor, waits for the last scheduled task to complete and then cleans up the object by calling cl...
XsString m_lastResultText
A last result string.
XsSize childDeviceCount() const
virtual void abortLoadLogFile()=0
Aborts loading a logfile.
static UniquePtr< T > createUniquePtr()
Constructs a new Communicator of type T and returns it as a UniquePtr<T>
std::unique_ptr< T, Deleter > UniquePtr
Initializes of UniquePtr<T>
XsProtocolType
Protocol types (XsDevice::enableProtocol())
virtual XsString logFileName() const =0
void setLastResult(XsResultValue lastResult, XsString const &text=XsString()) const
Sets the last result.
void destroy()
Destroys the communicator.
Class that delegates callbacks to registered XsCallbackHandlerItems.
virtual void closeLogFile()=0
Close the log file.
virtual bool openPort(const XsPortInfo &portInfo, OpenPortStage stage=OPS_Full, bool detectRs485=false)=0
Opens a port.
XsResultValue setAndReturnLastResult(XsResultValue lastResult, XsString const &text=XsString()) const
Sets the last result and returns it.
virtual void closePort()=0
Closes the open port.
int64_t XsFilePos
The type that is used for positioning inside a file.
A 0-terminated managed string of characters.
This class contains method to set, retrieve and compare timestamps.
uint32_t m_defaultTimeout
A default timeout variable.