Go to the documentation of this file.
92 using namespace xsens;
141 : m_useFakeMessages(true)
143 , m_lastHwErrorDeviceId(0)
151 , m_restoreCommunication(nullptr)
203 for (std::vector<XsDevice*>::iterator it = localList.begin(); it != localList.end(); ++it)
208 (*it)->prepareForTermination();
219 #ifndef XSENS_NO_PORT_NUMBERS
337 std::vector<XsDeviceId> result;
343 for (
auto child : childrn)
345 result.push_back(child->deviceId());
469 portLock.
lock(
false);
472 std::vector<XsDeviceId> ids;
490 portLock.
lock(
false);
492 std::vector<XsDeviceId> result;
496 if (
main->isMotionTracker())
497 result.push_back(
main->deviceId());
622 if (!object->openLogFile(filename))
643 #ifndef XSENS_NO_PORT_NUMBERS
660 JLDEBUGG(
"port " << (
int32_t) portNr <<
" baudrate " << baudrate <<
" timeout " << timeout <<
" detectRs485 " << (
int32_t)detectRs485);
664 return openPort(pinfo, timeout, detectRs485);
689 localPortInfo.setVidPid(vid, pid);
690 return openPort(localPortInfo, timeout, detectRs485);
712 serialPort->setGotoConfigTimeout(timeout);
714 bool retval = serialPort->openPort(portinfo,
OPS_Full, detectRs485);
715 if (serialPort->masterDeviceId().isValid())
716 portinfo.setDeviceId(serialPort->masterDeviceId());
720 m_lastResult.
set(serialPort->lastResult(), serialPort->lastResultText());
741 JLDEBUGG(
"port " << portinfo <<
" timeout " << timeout <<
" detectRs485 " << (
int32_t)detectRs485);
747 if (xs3info->
masterDeviceId().isValid() && !portinfo.deviceId().isValid())
767 JLDEBUGG(
"port " << portinfo <<
" id " <<
id <<
" key " << key <<
" timeout " << timeout);
900 JLDEBUGG(deviceId.toString().toStdString());
903 portLock.
lock(
false);
906 if (!deviceId.isMtw())
1001 if (deviceId.toInt() == 0)
1067 if (portName ==
m_deviceList[i]->communicator()->portInfo().portName())
1178 #ifndef XDA_PRIVATE_BUILD
1181 #include "xscontrolex.h"
void addChainedManager(CallbackManagerXda *cm)
Add a chained manager to the list.
void copyCallbackHandlersTo(CallbackManagerXda *cm, bool chain=true)
Copy all handlers from this manager into cm.
std::vector< XsDevice * > m_deviceList
This list contains device-information and cached data per device.
XsResultValue startRestoreCommunication(const XsString &portName)
Starts restore communication procedure.
XsDeviceId dockDeviceId(const XsDeviceId &deviceId) const
Get the device ID of the dock device for the given deviceId.
XsDeviceId const & deviceId() const
Return the device ID of the device.
@ XSO_Calibrate
Compute calibrated inertial data from raw data and temperature.
void removeChainedManager(CallbackManagerXda *cm)
Remove achained manager from the list.
A class that represents a vector of real numbers.
void close()
Close all ports and files.
void stop()
Stops the restore communication procedure.
XsDeviceId lastHardwareErrorDeviceId() const
bool gotoConfig() override
Put the device in config mode.
@ XSO_Orientation
Compute orientation, the orientation is typically only computed in one stream. If not specified the s...
A list of uint8_t values.
bool openPort(const XsString &portname, XsBaudRate baudrate, uint32_t timeout=0, bool detectRs485=false)
Open a communication channel on serial port with the given portname.
bool setInitialPositionLLA(const XsVector &lla)
Sets the current GNSS position of the system.
virtual bool setInitialPositionLLA(const XsVector &lla)
Sets the 'Latitude Longitude Altitude' setting of the device to the given vector.
XsOption disabledOptions() const
Return the currently explicitly disabled options.
virtual bool isDeviceDocked(const XsDeviceId &deviceId) const
Test if the given deviceId is docked.
XsString lastResultText() const
virtual bool loadFilterProfiles(const XsString &filename)
Load filter profile definitions from a settings file with the given filename.
virtual void removeRef()
Decrease this XsDevices reference counter with 1.
int mainDeviceCount() const
Get the number of main devices.
ROSCPP_DECL bool get(const std::string &key, bool &b)
void setOptionsForce(XsOption enabled)
Peristently enable or disable options.
bool lock(bool write)
Make sure that the lock has exactly the given lock state.
class XSNOEXPORT BroadcastDevice
bool openCustomPort(int channelId, uint32_t channelLatency, bool detectRs485=false)
Open a custom communication channel.
XsDeviceId masterDeviceId() const
virtual std::vector< XsDeviceId > deviceIds() const
Get the device IDs of all the connected devices.
void closePort(const XsString &portname)
Close the serial port with the given portname.
#define XSO_All
All options, note that setting 'all options' is not valid, but it is useful for clearing all options.
bool isMasterDevice() const
Returns true if this is the master device (not a child of another device)
bool openLogFile(const XsString &filename)
Open the log file with the given filename.
void stopRestoreCommunication()
Stops restore communication procedure.
bool openPortWithCredentials(XsPortInfo &portinfo, XsString const &id, XsString const &key, uint32_t timeout=0)
Open a communication channel using the details in the supplied XsPortInfo structure using the supplie...
An abstract internal struct of a control object.
A readers-writer lock class.
High level Motion Tracker (MT) management class.
void closeCustomPort(int channelId)
Closes a custom communication channel.
virtual std::vector< XsDevice * > children() const
Return a managed array containing the child-devices this device has. For standalone devices this is a...
XsResultValue lastResult() const
Get the result value of the last operation.
@ XRV_NOTFOUND
262: The requested item was not found
bool isReadingFromFile() const override final
Returns true if the device is reading from a file.
XdaCommunicatorFactory * m_communicatorFactory
The communicator factory object.
@ XRV_ALREADYOPEN
269: An I/O device is already opened with this object
virtual int childCount() const
Return the number of child-devices this device has. For standalone devices this is always 0.
DeviceFactory * m_deviceFactory
The device factory object.
static XSNOEXPORT XsControl * construct()
virtual void flushInputBuffers()
Clear the inbound data buffers of the device.
void registerCommunicatorTypes() override
Register the communicator types.
@ XRV_DEVICEERROR
40: The device generated an error, try updating the firmware
@ XRV_OK
0: Operation was performed successfully
Communicator XSNOEXPORT * communicator() const
XsDevicePtrArray mainDevices() const
Returns all main XsDevice interface objects.
XsOption
Xda options, used to control the kind of data processing done by XDA.
XsResultValue
Xsens result values.
RestoreCommunication * m_restoreCommunication
The restore communication object.
void setOptions(XsOption enable, XsOption disable)
Peristently enable or disable options.
void set(XsResultValue res, XsString const &text)
Sets the last results.
XsOption m_optionsDisable
Contsins all disabled options.
void closePortByIndex(uint32_t index)
volatile std::atomic_bool m_recording
AwindaStationIndication of threads started or not.
~XsControl()
Destroy this XsControl object.
class XSNOEXPORT ProxyCommunicator
XsOption enabledOptions() const
Return the currently enabled options.
virtual bool isMotionTracker() const
Returns true if this is a motion tracker.
XsResultValue start(const XsString &portName)
Starts the restore communication procedure.
A base struct for a communication interface.
struct XsPortInfo XsPortInfo
XsDeviceId m_lastHwErrorDeviceId
Contains the XsDevice ID of the device that caused the last hardware error.
virtual XsDevice * findDevice(XsDeviceId const &deviceid) const
Find the child device with deviceid.
enum XsBaudRate XsBaudRate
Communication speed.
@ XRV_NOFILEORPORTOPEN
289: No file or serial port opened for reading/writing
virtual XSNOEXPORT void prepareForTermination()
Contains a descriptor for opening a communication port to an Xsens device.
LastResultManager m_lastResult
The last result of an operation.
std::map< int, ProxyCommunicator * > m_proxyChannels
This map contains the proxy channels.
XsString lastResultText() const
Get the accompanying error text for the value returned by lastResult()
virtual void setCredentials(XsString const &id, XsString const &key)
Set the credentials required for using the device.
virtual XsDevice * createMasterDevice(Communicator *communicator, bool doInitialize=true)
Creates and initializes a master device with a specified communicator. The type of the new device is ...
XsOption m_optionsEnable
Contains all enable options.
Communicator * create(const XsPortInfo &portInfo) const
Create a communicator based on a port info.
virtual std::vector< XsDeviceId > mtDeviceIds() const
Get the device IDs of the available MTs.
Communicator * findXbusInterface(const XsDeviceId &deviceId) const
Find the xs3 info of the given id.
virtual XsDevice *XSNOCOMEXPORT addMasterDevice(Communicator *communicator)
void setGotoConfigOnClose(bool gotoConfigOnClose)
On closePort the device will go to config by default, with this function it is possible to prevent th...
virtual void removeExistingDevice(XsDeviceId const &deviceId)
std::vector< XsDeviceId > mainDeviceIds() const
Get the device IDs of the available main devices.
virtual bool XSNOEXPORT finalizeOpenPort(Communicator *communicator, XsPortInfo &portinfo, uint32_t timeout, bool detectRs485)
static XsPortInfo createPortInfo(int channelId)
Creates a default port info object based on the given user-provided channel identifier.
XsDevice * getDeviceFromLocationId(uint16_t locationId) const
Get the device of the device on the given locationId.
struct XsDeviceId XsDeviceId
virtual int mtCount() const
Get the number of connected MTs.
void updateRecordingState()
XsDevice * broadcast() const
Returns the broadcast device.
XsDevice * device(const XsDeviceId &deviceId) const
Returns the XsDevice interface object associated with the supplied deviceId.
void gotoMeasurement()
Place all sensors connected through a serial port into Measurement Mode.
int deviceCount() const
Get the number of connected devices.
XsResultValue lastHardwareError() const
Get the last hardware error code.
XsResultValue m_lastHwError
Contains the last serious error reported by CMT3.
Contains an Xsens device ID and provides operations for determining the type of device.
Namespace for mathematical constants and operations.
A list of XsDevicePtr values.
const char * XsResultValue_toString(XsResultValue result)
Retrieve a character string corresponding to the given result code.
XsPortInfo customPortInfo(int channelId) const
Returns the port information for a custom communication channel.
virtual bool resetLogFileReadPosition()
Set the read position of the open log file to the start of the file.
@ XRV_INVALIDID
264: Invalid id supplied
void clearHardwareError()
Clear the last hardware error.
class XSNOEXPORT RestoreCommunication
void gotoConfig()
Place all sensors connected through a serial port into Configuration Mode.
virtual bool isDeviceWireless(const XsDeviceId &deviceId) const
Test if the given deviceId is an MTw and if it is wirelessly connected.
void flushInputBuffers()
Clear the inbound data buffers of all devices.
static UniquePtr< T > createUniquePtr()
Constructs a new Communicator of type T and returns it as a UniquePtr<T>
XsControl()
Construct a new Xsens Device API control object.
void setPersistentSettings(XsDevice *dev)
virtual bool openImarPort_internal(const XsString &portname, XsBaudRate baudrate, int imarType, uint32_t timeout=0)
Open a communication channel on serial port with the given portname.
virtual void setOptions(XsOption enable, XsOption disable)
Enable and disable processing options.
bool setInitialPositionLLA(const XsVector &lla) override
Sets the 'Latitude Longitude Altitude' setting of the device to the given vector.
bool gotoMeasurement() override
Put this device in measurement mode.
XsResultValue lastResult() const
static uint16_t vidFromString(std::string const &string)
XsDevice * findDevice(const XsDeviceId &deviceId) const
XDA communication factory.
xsens::MutexReadWrite m_portMutex
Controls access to the serial ports, also used to suspend the thread.
virtual void registerDevices()
register all known device types
static uint16_t pidFromString(std::string const &string)
XsVector3 m_latLonAlt
This vector contains the latitude, longitude and altitude.
static XsString resultText(XsResultValue resultCode)
Get a descriptive text for the given resultCode.
BroadcastDevice * m_broadcaster
The broadcast device object.
A Factory for the devices.
A 0-terminated managed string of characters.
void transmissionReceived(int channelId, const XsByteArray &data)
Feed data coming back from an Xsens device over a custom channel into XDA.
void setOptions(XsOption enable, XsOption disable) override
Enable and disable processing options.
@ XRV_INVALIDPARAM
33: An invalid parameter is supplied