xscontrol_def.cpp
Go to the documentation of this file.
1 
2 // Copyright (c) 2003-2021 Xsens Technologies B.V. or subsidiaries worldwide.
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification,
6 // are permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice,
9 // this list of conditions, and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice,
12 // this list of conditions, and the following disclaimer in the documentation
13 // and/or other materials provided with the distribution.
14 //
15 // 3. Neither the names of the copyright holders nor the names of their contributors
16 // may be used to endorse or promote products derived from this software without
17 // specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
24 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
26 // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
28 // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
29 // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
30 // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
31 //
32 
33 
34 // Copyright (c) 2003-2021 Xsens Technologies B.V. or subsidiaries worldwide.
35 // All rights reserved.
36 //
37 // Redistribution and use in source and binary forms, with or without modification,
38 // are permitted provided that the following conditions are met:
39 //
40 // 1. Redistributions of source code must retain the above copyright notice,
41 // this list of conditions, and the following disclaimer.
42 //
43 // 2. Redistributions in binary form must reproduce the above copyright notice,
44 // this list of conditions, and the following disclaimer in the documentation
45 // and/or other materials provided with the distribution.
46 //
47 // 3. Neither the names of the copyright holders nor the names of their contributors
48 // may be used to endorse or promote products derived from this software without
49 // specific prior written permission.
50 //
51 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
52 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
53 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
54 // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
56 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
58 // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
59 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
60 // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
61 // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
62 // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
63 //
64 
65 #include "xscontrol_def.h"
66 #include "xdacommunicatorfactory.h"
67 #include <xstypes/xsportinfo.h>
69 #include "xsdeviceconfiguration.h"
71 #include <xstypes/xsdatapacket.h>
72 
73 #include "proxycommunicator.h"
74 #include "restorecommunication.h"
75 
76 #include <xstypes/xsversion.h>
77 
78 #include "mtix0device.h"
79 #include "mtix00device.h"
80 #include "mtigdevice.h"
81 #include <xstypes/xsdid.h> // xddid and xsens_private for imar device id checks
82 #include "xsdeviceptrarray.h"
83 #include <xstypes/xssyncsetting.h>
84 #include <xstypes/xsmath.h>
86 #include <set>
87 #include <memory>
89 #include "broadcastdevice.h"
90 #include "idfetchhelpers.h"
91 
92 using namespace xsens;
93 using namespace XsMath;
94 
141  : m_useFakeMessages(true)
142  , m_lastHwError(XRV_OK)
143  , m_lastHwErrorDeviceId(0)
144  , m_recording(false)
145  , m_broadcaster(0)
146  , m_optionsEnable(XSO_Calibrate | XSO_Orientation)
147  , m_optionsDisable(XSO_None)
148  , m_latLonAlt(XsVector())
149  , m_deviceFactory(new DeviceFactory)
150  , m_communicatorFactory(new XdaCommunicatorFactory)
151  , m_restoreCommunication(nullptr)
152 {
155 
156  m_broadcaster = new BroadcastDevice(this);
158 }
159 
160 
166 {
167  try
168  {
169  close();
170  delete m_broadcaster;
171  delete m_restoreCommunication;
172  }
173  catch (...)
174  {}
175 
176  delete m_deviceFactory;
177  delete m_communicatorFactory;
178  m_broadcaster = nullptr;
179  m_restoreCommunication = nullptr;
180 }
181 
187 {
188  return XsResultValue_toString(resultCode);
189 }
190 
195 {
196  JLDEBUGG("");
198 
201 
202  std::vector<XsDevice*> localList = m_deviceList;
203  for (std::vector<XsDevice*>::iterator it = localList.begin(); it != localList.end(); ++it)
204  {
206 
207  // prepareForTermination is called automatically when the reference is removed
208  (*it)->prepareForTermination();
209  (*it)->removeRef();
210  }
211  m_deviceList.clear();
212 
215 
217 }
218 
219 #ifndef XSENS_NO_PORT_NUMBERS
220 
225 void XsControl::closePort(int portNr)
226 {
227  JLDEBUGG(portNr);
229 
230  closePort(XsPortInfo(portNr).portName());
231 }
232 #endif
233 
240 {
241  JLDEBUGG(device);
243 
244  for (uint16_t i = 0; i < m_deviceList.size(); ++i)
245  {
246  if (device == m_deviceList[i])
247  {
248  m_deviceList.erase(m_deviceList.begin() + i);
251  device->removeRef();
252  }
253  }
254 }
255 
260 void XsControl::closePort(const XsString& portname)
261 {
262  JLDEBUGG(portname.toStdString());
264 
265  // find appropriate port
266  LockReadWrite portLock(&m_portMutex);
267  portLock.lock(true);
268 
269  for (uint16_t i = 0; i < m_deviceList.size(); ++i)
270  {
271  if (portname == m_deviceList[i]->portName())
273  }
274 }
275 
281 void XsControl::closePort(const XsDeviceId& deviceId)
282 {
283  XsDevice* inf = findDevice(deviceId);
284  if (inf)
285  closePort(inf);
286 }
287 
293 void XsControl::closePort(const XsPortInfo& portinfo)
294 {
295  closePort(portinfo.portName());
296 }
297 
303 {
304  JLDEBUGG("");
306 
307  for (uint32_t i = 0; i < m_deviceList.size(); i++) // loop over all devices,
308  {
309  XsDevice* dev = m_deviceList[i];
310  dev->flushInputBuffers(); // flush data buffer of each device.
311  }
312 }
313 
318 {
319  int count = 0;
320  for (uint32_t i = 0; i < m_deviceList.size(); i++)
321  {
322  XsDevice* dev = m_deviceList[i];
323  count += 1 + (int) dev->childCount();
324  }
326  return count;
327 }
328 
333 std::vector<XsDeviceId> XsControl::deviceIds() const
334 {
335  LockReadWrite portLock(&m_portMutex, LS_Read);
336 
337  std::vector<XsDeviceId> result;
338  for (uint32_t index = 0; index < m_deviceList.size(); ++index)
339  {
340  XsDevice const* dev = m_deviceList[index];
341  result.push_back(dev->deviceId());
342  auto childrn = dev->children();
343  for (auto child : childrn)
344  if (child)
345  result.push_back(child->deviceId());
346  }
347  return result;
348 }
349 
362 XsDevice* XsControl::getDeviceFromLocationId(uint16_t locationId) const
363 {
364  JLDEBUGG((int) locationId);
366  for (uint16_t i = 0; i < m_deviceList.size(); ++i)
367  {
368  XsDevice* d = m_deviceList[i]->getDeviceFromLocationId(locationId);
369  if (!d)
370  continue;
372  return d;
373  }
375  return nullptr;
376 }
377 
382 {
385 }
386 
393 {
394  return m_lastHwError;
395 }
396 
400 {
401  return m_lastHwErrorDeviceId;
402 }
403 
410 {
411  return m_lastResult.lastResult();
412 }
413 
424 {
425  return m_lastResult.lastResultText();
426 }
427 
433 {
434  // m_lastResult = XRV_OK;
435  return (int) m_deviceList.size();
436 }
437 
445 /* We assume motion trackers cannot have children and if a device is a child device, it is a motion tracker */
447 {
448  int count = 0;
449  for (uint32_t i = 0; i < m_deviceList.size(); i++)
450  {
451  XsDevice* dev = m_deviceList[i];
452  if (dev->isMotionTracker())
453  count++;
454  }
456  return count;
457 }
458 
466 std::vector<XsDeviceId> XsControl::mainDeviceIds() const
467 {
468  LockReadWrite portLock(&m_portMutex);
469  portLock.lock(false);
470 
472  std::vector<XsDeviceId> ids;
473  ids.reserve(m_deviceList.size());
474  for (uint32_t index = 0; index < m_deviceList.size(); ++index)
475  ids.push_back(m_deviceList[index]->deviceId());
476  return ids;
477 }
478 
485 std::vector<XsDeviceId> XsControl::mtDeviceIds() const
486 {
488 
489  LockReadWrite portLock(&m_portMutex);
490  portLock.lock(false);
491 
492  std::vector<XsDeviceId> result;
493  for (uint32_t i = 0; i < m_deviceList.size(); ++i)
494  {
495  XsDevice const* main = m_deviceList.at(i);
496  if (main->isMotionTracker())
497  result.push_back(main->deviceId());
498  }
499  return result;
500 }
501 
511 {
512  JLDEBUGG("");
514 
516 }
517 
525 {
526  JLDEBUGG("");
528 
530 }
531 
539 {
540  return m_restoreCommunication->start(portName);
541 }
542 
546 {
548 }
549 
558 bool XsControl::isDeviceDocked(const XsDeviceId& deviceId) const
559 {
560  (void)deviceId;
561  return false;
562 }
563 
572 bool XsControl::isDeviceWireless(const XsDeviceId& deviceId) const
573 {
574  (void)deviceId;
575  return false;
576 }
577 
586 {
587  XsDevice* result = nullptr;
588  XsDevice* dev = m_deviceFactory->createMasterDevice(communicator);
589  if (dev != nullptr)
590  {
592  addChainedManager(dev);
593  m_deviceList.push_back(dev);
594  result = dev;
595  }
596  return result;
597 }
609 bool XsControl::openLogFile(const XsString& filename)
610 {
611  JLDEBUGG(filename.toStdString());
613 
614  LockReadWrite portLock(&m_portMutex);
615  portLock.lock(true);
616 
617  // try opening the file as a regular mtb file
619 
620  copyCallbackHandlersTo(object.get());
621  //object->addCallbackHandler(d);
622  if (!object->openLogFile(filename))
623  {
624  m_lastResult = object->lastResult();
625  return false;
626  }
627 
628  // note that addMasterDevice ALWAYS takes ownership of communicator
629  XsDevice* dev = addMasterDevice(object.release());
630  if (!dev)
631  {
633  return false;
634  }
635 
636  dev->resetLogFileReadPosition(); // this will and should call reinitializeProcessors();
637 
639  return true;
640 
641 }
642 
643 #ifndef XSENS_NO_PORT_NUMBERS
644 
658 bool XsControl::openPort(int portNr, XsBaudRate baudrate, uint32_t timeout, bool detectRs485)
659 {
660  JLDEBUGG("port " << (int32_t) portNr << " baudrate " << baudrate << " timeout " << timeout << " detectRs485 " << (int32_t)detectRs485);
662 
663  XsPortInfo pinfo(portNr, baudrate);
664  return openPort(pinfo, timeout, detectRs485);
665 }
666 #endif
667 
684 bool XsControl::openPort(const XsString& portname, XsBaudRate baudrate, uint32_t timeout, bool detectRs485)
685 {
686  XsPortInfo localPortInfo = XsPortInfo(portname, baudrate);
687  uint16_t vid = vidFromString(portname.toStdString());
688  uint16_t pid = pidFromString(portname.toStdString());
689  localPortInfo.setVidPid(vid, pid);
690  return openPort(localPortInfo, timeout, detectRs485);
691 }
692 
698 bool XsControl::finalizeOpenPort(Communicator* communicator, XsPortInfo& portinfo, uint32_t timeout, bool detectRs485)
699 {
701  if (!communicator)
702  {
704  return false;
705  }
706 
707  auto serialPort = Communicator::createUniquePtr(communicator);
708 
709  copyCallbackHandlersTo(serialPort.get());
710 
711  if (timeout)
712  serialPort->setGotoConfigTimeout(timeout);
713 
714  bool retval = serialPort->openPort(portinfo, OPS_Full, detectRs485);
715  if (serialPort->masterDeviceId().isValid())
716  portinfo.setDeviceId(serialPort->masterDeviceId());
717 
718  if (!retval)
719  {
720  m_lastResult.set(serialPort->lastResult(), serialPort->lastResultText());
721  return false;
722  }
723 
724  // note that addMasterDevice ALWAYS takes ownership of communicator
725  if (!addMasterDevice(serialPort.release()))
726  return false;
727 
728  return true;
729 }
739 bool XsControl::openPort(XsPortInfo& portinfo, uint32_t timeout, bool detectRs485)
740 {
741  JLDEBUGG("port " << portinfo << " timeout " << timeout << " detectRs485 " << (int32_t)detectRs485);
743 
744  Communicator* xs3info = findXbusInterface(portinfo);
745  if (xs3info)
746  {
747  if (xs3info->masterDeviceId().isValid() && !portinfo.deviceId().isValid())
748  portinfo.setDeviceId(xs3info->masterDeviceId());
750  return true;
751  }
752 
753  return finalizeOpenPort(m_communicatorFactory->create(portinfo), portinfo, timeout, detectRs485);
754 }
755 
765 bool XsControl::openPortWithCredentials(XsPortInfo& portinfo, XsString const& id, XsString const& key, uint32_t timeout)
766 {
767  JLDEBUGG("port " << portinfo << " id " << id << " key " << key << " timeout " << timeout);
769 
770  Communicator* xs3info = findXbusInterface(portinfo);
771  if (xs3info)
772  {
773  if (xs3info->masterDeviceId().isValid())
774  portinfo.setDeviceId(xs3info->masterDeviceId());
776  return true;
777  }
778 
779  xs3info = m_communicatorFactory->create(portinfo);
780  xs3info->setCredentials(id, key);
781  return finalizeOpenPort(xs3info, portinfo, timeout, false);
782 }
783 
792 bool XsControl::openCustomPort(int channelId, uint32_t channelLatency, bool detectRs485)
793 {
794  if (m_proxyChannels.find(channelId) != m_proxyChannels.end())
795  {
796  // We are assuming that the device is there in this case
798  return true;
799  }
800 
801  ProxyCommunicator* proxy = new ProxyCommunicator(channelId, channelLatency);
802  m_proxyChannels[channelId] = proxy;
803 
804  XsPortInfo portInfo = ProxyCommunicator::createPortInfo(channelId);
805  if (!finalizeOpenPort(proxy, portInfo, 0, detectRs485))
806  {
807  //Please note that finalizeOpenPort takes ownership of the Communicator pointer and will clean it up on error
808  m_proxyChannels.erase(channelId);
809  return false;
810  }
811 
812  return true;
813 }
814 
821 {
822  if (m_proxyChannels.find(channelId) == m_proxyChannels.end())
823  return XsPortInfo();
824 
825  return m_proxyChannels.at(channelId)->portInfo();
826 }
827 
833 void XsControl::closeCustomPort(int channelId)
834 {
835  auto it = m_proxyChannels.find(channelId);
836  if (it == m_proxyChannels.end())
837  return;
838 
839  ProxyCommunicator* p = it->second;
840  if (p)
841  {
842  XsDevice* dev = findDevice(p->masterDeviceId());
843  if (dev)
844  dev->setGotoConfigOnClose(false);
845  m_proxyChannels.erase(it);
847  }
848  else
849  m_proxyChannels.erase(it);
850 }
851 
857 void XsControl::transmissionReceived(int channelId, const XsByteArray& data)
858 {
859  if (m_proxyChannels.find(channelId) == m_proxyChannels.end())
860  return;
861  m_proxyChannels[channelId]->handleReceivedData(data);
862 }
863 
881 {
882  return false;
883 }
884 
899 {
900  JLDEBUGG(deviceId.toString().toStdString());
901 
902  LockReadWrite portLock(&m_portMutex);
903  portLock.lock(false);
904 
906  if (!deviceId.isMtw())
907  return XsDeviceId();
908 
909  XsDevice* dev = findDevice(deviceId);
910  if (!dev)
911  {
913  return XsDeviceId();
914  }
915 
916  for (uint32_t index = 0; index < m_deviceList.size(); ++index)
917  {
918  if (m_deviceList[index]->deviceIsDocked(dev))
919  return m_deviceList[index]->deviceId();
920  }
921 
922  return XsDeviceId();
923 }
924 
936 {
937  m_latLonAlt = lla;
939  return true;
940 }
941 
947 XsDevice* XsControl::device(const XsDeviceId& deviceId) const
948 {
949  return findDevice(deviceId);
950 }
951 
956 {
957  XsDevicePtrArray rv;
958  for (std::vector<XsDevice*>::const_iterator it = m_deviceList.begin(); it != m_deviceList.end(); ++it)
959  rv.push_back(*it);
960  return rv;
961 }
962 
969 {
970  return m_broadcaster;
971 }
972 
977 {
978  for (size_t i = 0 ; i < m_deviceList.size(); ++i)
979  if (m_deviceList[i]->isRecording())
980  m_recording = true;
981 
982  m_recording = false;
983 }
984 
991 XsDevice* XsControl::findDevice(const XsDeviceId& deviceId) const
992 {
993  if (m_deviceList.empty())
994  {
996  return NULL;
997  }
998 
1000 
1001  if (deviceId.toInt() == 0)
1002  return m_deviceList[0]; // simply return the first item in the list
1003 
1004  for (size_t i = 0; i < m_deviceList.size(); i++)
1005  {
1006  XsDevice* dev = m_deviceList[i];
1007 
1008  if (!dev)
1009  break;
1010 
1011  if (dev->deviceId() == deviceId)
1012  return dev;
1013 
1014  dev = dev->findDevice(deviceId);
1015  if (dev)
1016  return dev;
1017  }
1018 
1020  return NULL;
1021 }
1022 
1026 void XsControl::removeExistingDevice(XsDeviceId const& deviceId)
1027 {
1028  XsDevice* dev = findDevice(deviceId);
1029  if (!dev)
1030  return;
1031 
1032  if (dev->isMasterDevice())
1033  closePort(deviceId);
1034 }
1035 
1041 {
1042  XsDevice* dev = findDevice(deviceId);
1043  if (!dev)
1044  return NULL;
1045 
1046  return dev->communicator();
1047 }
1048 
1054 {
1055  return findXbusInterface(portInfo.portName());
1056 }
1057 
1062 Communicator* XsControl::findXbusInterface(const XsString& portName) const
1063 {
1064  for (size_t i = 0; i < m_deviceList.size(); ++i)
1065  {
1066  assert(m_deviceList[i]->communicator());
1067  if (portName == m_deviceList[i]->communicator()->portInfo().portName())
1068  return m_deviceList[i]->communicator();
1069  }
1070  return NULL;
1071 }
1087 {
1088  return false;
1089 }
1090 
1096 {
1097  JLDEBUGG(i);
1098  // XSEXITLOGD(gJournal);
1099 
1100  XsDevice* dev = m_deviceList[i];
1101  closePort(dev);
1102 }
1110 {
1111  return m_optionsEnable;
1112 }
1113 
1119 {
1120  return m_optionsDisable;
1121 }
1122 
1138 {
1139  m_optionsEnable = XsOption_purify(enable);
1140  m_optionsDisable = disable;
1142 }
1143 
1158 {
1159  m_optionsEnable = XsOption_purify(enabled);
1162 }
1163 
1170 {
1172 
1173  if (!m_latLonAlt.empty())
1175 }
1178 #ifndef XDA_PRIVATE_BUILD
1179  #include "xscontrol_public.h"
1180 #else
1181  #include "xscontrolex.h"
1182 #endif
1184 {
1185  return new XsControlEx;
1186 }
CallbackManagerXda::addChainedManager
void addChainedManager(CallbackManagerXda *cm)
Add a chained manager to the list.
Definition: callbackmanagerxda.cpp:262
restorecommunication.h
CallbackManagerXda::copyCallbackHandlersTo
void copyCallbackHandlersTo(CallbackManagerXda *cm, bool chain=true)
Copy all handlers from this manager into cm.
Definition: callbackmanagerxda.cpp:328
XsControl::m_deviceList
std::vector< XsDevice * > m_deviceList
This list contains device-information and cached data per device.
Definition: xscontrol_def.h:230
XsControl::startRestoreCommunication
XsResultValue startRestoreCommunication(const XsString &portName)
Starts restore communication procedure.
Definition: xscontrol_def.cpp:538
XsControl::dockDeviceId
XsDeviceId dockDeviceId(const XsDeviceId &deviceId) const
Get the device ID of the dock device for the given deviceId.
Definition: xscontrol_def.cpp:898
XsDevice::deviceId
XsDeviceId const & deviceId() const
Return the device ID of the device.
Definition: xsdevice_def.cpp:742
XSO_Calibrate
@ XSO_Calibrate
Compute calibrated inertial data from raw data and temperature.
Definition: xsoption.h:79
CallbackManagerXda::removeChainedManager
void removeChainedManager(CallbackManagerXda *cm)
Remove achained manager from the list.
Definition: callbackmanagerxda.cpp:298
XsVector
A class that represents a vector of real numbers.
Definition: xsvector.h:113
XsControl::close
void close()
Close all ports and files.
Definition: xscontrol_def.cpp:194
RestoreCommunication::stop
void stop()
Stops the restore communication procedure.
Definition: restorecommunication.cpp:135
XsControl::lastHardwareErrorDeviceId
XsDeviceId lastHardwareErrorDeviceId() const
Definition: xscontrol_def.cpp:399
BroadcastDevice::gotoConfig
bool gotoConfig() override
Put the device in config mode.
Definition: broadcastdevice.cpp:397
XSO_Orientation
@ XSO_Orientation
Compute orientation, the orientation is typically only computed in one stream. If not specified the s...
Definition: xsoption.h:80
XsByteArray
A list of uint8_t values.
XsControl::openPort
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.
Definition: xscontrol_def.cpp:684
XsControl::setInitialPositionLLA
bool setInitialPositionLLA(const XsVector &lla)
Sets the current GNSS position of the system.
Definition: xscontrol_def.cpp:935
XsDevice::setInitialPositionLLA
virtual bool setInitialPositionLLA(const XsVector &lla)
Sets the 'Latitude Longitude Altitude' setting of the device to the given vector.
Definition: xsdevice_def.cpp:2809
XsControl::disabledOptions
XsOption disabledOptions() const
Return the currently explicitly disabled options.
Definition: xscontrol_def.cpp:1118
XsControl::isDeviceDocked
virtual bool isDeviceDocked(const XsDeviceId &deviceId) const
Test if the given deviceId is docked.
Definition: xscontrol_def.cpp:558
LastResultManager::lastResultText
XsString lastResultText() const
Definition: lastresultmanager.h:101
XsControl::loadFilterProfiles
virtual bool loadFilterProfiles(const XsString &filename)
Load filter profile definitions from a settings file with the given filename.
Definition: xscontrol_def.cpp:1086
XsDevice::removeRef
virtual void removeRef()
Decrease this XsDevices reference counter with 1.
Definition: xsdevice_def.cpp:3831
XsControl::mainDeviceCount
int mainDeviceCount() const
Get the number of main devices.
Definition: xscontrol_def.cpp:432
get
ROSCPP_DECL bool get(const std::string &key, bool &b)
XsControl::setOptionsForce
void setOptionsForce(XsOption enabled)
Peristently enable or disable options.
Definition: xscontrol_def.cpp:1157
xsens::LockReadWrite::lock
bool lock(bool write)
Make sure that the lock has exactly the given lock state.
Definition: xsens_mutex.h:1129
ProxyCommunicator
Definition: proxycommunicator.h:73
BroadcastDevice
class XSNOEXPORT BroadcastDevice
Definition: xscontrol_def.h:87
XsControl::openCustomPort
bool openCustomPort(int channelId, uint32_t channelLatency, bool detectRs485=false)
Open a custom communication channel.
Definition: xscontrol_def.cpp:792
Communicator::masterDeviceId
XsDeviceId masterDeviceId() const
Definition: communicator.cpp:157
XsControl::deviceIds
virtual std::vector< XsDeviceId > deviceIds() const
Get the device IDs of all the connected devices.
Definition: xscontrol_def.cpp:333
XsControl::closePort
void closePort(const XsString &portname)
Close the serial port with the given portname.
Definition: xscontrol_def.cpp:260
XSO_All
#define XSO_All
All options, note that setting 'all options' is not valid, but it is useful for clearing all options.
Definition: xsoption.h:95
XsDevice::isMasterDevice
bool isMasterDevice() const
Returns true if this is the master device (not a child of another device)
Definition: xsdevice_def.cpp:1086
XsControl::openLogFile
bool openLogFile(const XsString &filename)
Open the log file with the given filename.
Definition: xscontrol_def.cpp:609
XsControl::stopRestoreCommunication
void stopRestoreCommunication()
Stops restore communication procedure.
Definition: xscontrol_def.cpp:545
XsControl::openPortWithCredentials
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...
Definition: xscontrol_def.cpp:765
XsControlEx
An abstract internal struct of a control object.
Definition: xscontrol_public.h:73
xsens::LockReadWrite
A readers-writer lock class.
Definition: xsens_mutex.h:1090
XsControl
High level Motion Tracker (MT) management class.
Definition: xscontrol_def.h:131
XsControl::closeCustomPort
void closeCustomPort(int channelId)
Closes a custom communication channel.
Definition: xscontrol_def.cpp:833
XsDevice::children
virtual std::vector< XsDevice * > children() const
Return a managed array containing the child-devices this device has. For standalone devices this is a...
Definition: xsdevice_def.cpp:4093
XsControl::lastResult
XsResultValue lastResult() const
Get the result value of the last operation.
Definition: xscontrol_def.cpp:409
main
int main(int argc, char *argv[])
Definition: configure_outputs.cpp:6
XRV_NOTFOUND
@ XRV_NOTFOUND
262: The requested item was not found
Definition: xsresultvalue.h:132
BroadcastDevice::isReadingFromFile
bool isReadingFromFile() const override final
Returns true if the device is reading from a file.
Definition: broadcastdevice.cpp:392
XsControl::m_communicatorFactory
XdaCommunicatorFactory * m_communicatorFactory
The communicator factory object.
Definition: xscontrol_def.h:285
XRV_ALREADYOPEN
@ XRV_ALREADYOPEN
269: An I/O device is already opened with this object
Definition: xsresultvalue.h:139
xsportinfo.h
XsDevice::childCount
virtual int childCount() const
Return the number of child-devices this device has. For standalone devices this is always 0.
Definition: xsdevice_def.cpp:4085
XsControl::m_deviceFactory
DeviceFactory * m_deviceFactory
The device factory object.
Definition: xscontrol_def.h:282
XsControl::construct
static XSNOEXPORT XsControl * construct()
Definition: xscontrol_def.cpp:1183
data
data
XsDevice::flushInputBuffers
virtual void flushInputBuffers()
Clear the inbound data buffers of the device.
Definition: xsdevice_def.cpp:1807
XdaCommunicatorFactory::registerCommunicatorTypes
void registerCommunicatorTypes() override
Register the communicator types.
Definition: xdacommunicatorfactory.cpp:128
XRV_DEVICEERROR
@ XRV_DEVICEERROR
40: The device generated an error, try updating the firmware
Definition: xsresultvalue.h:109
XRV_OK
@ XRV_OK
0: Operation was performed successfully
Definition: xsresultvalue.h:85
XsDevice::communicator
Communicator XSNOEXPORT * communicator() const
XsControl::mainDevices
XsDevicePtrArray mainDevices() const
Returns all main XsDevice interface objects.
Definition: xscontrol_def.cpp:955
XsOption
XsOption
Xda options, used to control the kind of data processing done by XDA.
Definition: xsoption.h:76
XsResultValue
XsResultValue
Xsens result values.
Definition: xsresultvalue.h:82
XsControl::m_restoreCommunication
RestoreCommunication * m_restoreCommunication
The restore communication object.
Definition: xscontrol_def.h:288
XsControl::setOptions
void setOptions(XsOption enable, XsOption disable)
Peristently enable or disable options.
Definition: xscontrol_def.cpp:1137
LastResultManager::set
void set(XsResultValue res, XsString const &text)
Sets the last results.
Definition: lastresultmanager.h:86
XsControl::m_optionsDisable
XsOption m_optionsDisable
Contsins all disabled options.
Definition: xscontrol_def.h:274
xscontrol_def.h
XsControl::closePortByIndex
void closePortByIndex(uint32_t index)
xsdeviceptrarray.h
XsControl::m_recording
volatile std::atomic_bool m_recording
AwindaStationIndication of threads started or not.
Definition: xscontrol_def.h:252
XsControl::~XsControl
~XsControl()
Destroy this XsControl object.
Definition: xscontrol_def.cpp:165
ProxyCommunicator
class XSNOEXPORT ProxyCommunicator
Definition: xscontrol_def.h:89
XsControl::enabledOptions
XsOption enabledOptions() const
Return the currently enabled options.
Definition: xscontrol_def.cpp:1109
XsDevice::isMotionTracker
virtual bool isMotionTracker() const
Returns true if this is a motion tracker.
Definition: xsdevice_def.cpp:813
RestoreCommunication::start
XsResultValue start(const XsString &portName)
Starts the restore communication procedure.
Definition: restorecommunication.cpp:108
Communicator
A base struct for a communication interface.
Definition: communicator.h:95
XsPortInfo
struct XsPortInfo XsPortInfo
Definition: xsportinfo.h:83
XsControl::m_lastHwErrorDeviceId
XsDeviceId m_lastHwErrorDeviceId
Contains the XsDevice ID of the device that caused the last hardware error.
Definition: xscontrol_def.h:242
XsDevice::findDevice
virtual XsDevice * findDevice(XsDeviceId const &deviceid) const
Find the child device with deviceid.
Definition: xsdevice_def.cpp:500
XsBaudRate
enum XsBaudRate XsBaudRate
Communication speed.
Definition: xsbaud.h:81
XRV_NOFILEORPORTOPEN
@ XRV_NOFILEORPORTOPEN
289: No file or serial port opened for reading/writing
Definition: xsresultvalue.h:160
XsDevice::prepareForTermination
virtual XSNOEXPORT void prepareForTermination()
uint32_t
unsigned int uint32_t
Definition: pstdint.h:485
XsPortInfo
Contains a descriptor for opening a communication port to an Xsens device.
Definition: xsportinfo.h:128
XsControl::m_lastResult
LastResultManager m_lastResult
The last result of an operation.
Definition: xscontrol_def.h:236
XsControl::m_proxyChannels
std::map< int, ProxyCommunicator * > m_proxyChannels
This map contains the proxy channels.
Definition: xscontrol_def.h:233
XsControl::lastResultText
XsString lastResultText() const
Get the accompanying error text for the value returned by lastResult()
Definition: xscontrol_def.cpp:423
Communicator::setCredentials
virtual void setCredentials(XsString const &id, XsString const &key)
Set the credentials required for using the device.
Definition: communicator.cpp:337
DeviceFactory::createMasterDevice
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 ...
Definition: devicefactory.cpp:160
XsControl::m_optionsEnable
XsOption m_optionsEnable
Contains all enable options.
Definition: xscontrol_def.h:271
XdaCommunicatorFactory::create
Communicator * create(const XsPortInfo &portInfo) const
Create a communicator based on a port info.
Definition: communicatorfactory.cpp:88
proxycommunicator.h
XsControl::mtDeviceIds
virtual std::vector< XsDeviceId > mtDeviceIds() const
Get the device IDs of the available MTs.
Definition: xscontrol_def.cpp:485
XsControl::findXbusInterface
Communicator * findXbusInterface(const XsDeviceId &deviceId) const
Find the xs3 info of the given id.
d
d
xssyncsettingarray.h
xsens::LS_Read
@ LS_Read
Definition: xsens_mutex.h:127
XsControl::addMasterDevice
virtual XsDevice *XSNOCOMEXPORT addMasterDevice(Communicator *communicator)
xsdid.h
XsDevice::setGotoConfigOnClose
void setGotoConfigOnClose(bool gotoConfigOnClose)
On closePort the device will go to config by default, with this function it is possible to prevent th...
Definition: xsdevice_def.cpp:519
XsControl::removeExistingDevice
virtual void removeExistingDevice(XsDeviceId const &deviceId)
XsControl::mainDeviceIds
std::vector< XsDeviceId > mainDeviceIds() const
Get the device IDs of the available main devices.
Definition: xscontrol_def.cpp:466
XsControl::finalizeOpenPort
virtual bool XSNOEXPORT finalizeOpenPort(Communicator *communicator, XsPortInfo &portinfo, uint32_t timeout, bool detectRs485)
xsdatapacket.h
ProxyCommunicator::createPortInfo
static XsPortInfo createPortInfo(int channelId)
Creates a default port info object based on the given user-provided channel identifier.
Definition: proxycommunicator.cpp:231
XsControl::getDeviceFromLocationId
XsDevice * getDeviceFromLocationId(uint16_t locationId) const
Get the device of the device on the given locationId.
Definition: xscontrol_def.cpp:362
xsversion.h
XsDeviceId
struct XsDeviceId XsDeviceId
Definition: xsdeviceid.h:912
XsControl::mtCount
virtual int mtCount() const
Get the number of connected MTs.
Definition: xscontrol_def.cpp:446
XsControl::updateRecordingState
void updateRecordingState()
XsControl::broadcast
XsDevice * broadcast() const
Returns the broadcast device.
Definition: xscontrol_def.cpp:968
XsControl::device
XsDevice * device(const XsDeviceId &deviceId) const
Returns the XsDevice interface object associated with the supplied deviceId.
Definition: xscontrol_def.cpp:947
broadcastdevice.h
XsControl::gotoMeasurement
void gotoMeasurement()
Place all sensors connected through a serial port into Measurement Mode.
Definition: xscontrol_def.cpp:524
XsControl::deviceCount
int deviceCount() const
Get the number of connected devices.
Definition: xscontrol_def.cpp:317
XsControl::lastHardwareError
XsResultValue lastHardwareError() const
Get the last hardware error code.
Definition: xscontrol_def.cpp:392
xsmath.h
XsControl::m_lastHwError
XsResultValue m_lastHwError
Contains the last serious error reported by CMT3.
Definition: xscontrol_def.h:239
XsDeviceId
Contains an Xsens device ID and provides operations for determining the type of device.
Definition: xsdeviceid.h:192
XsMath
Namespace for mathematical constants and operations.
XsDevicePtrArray
A list of XsDevicePtr values.
mtix00device.h
XsResultValue_toString
const char * XsResultValue_toString(XsResultValue result)
Retrieve a character string corresponding to the given result code.
Definition: xsresultvalue.c:78
xssyncsetting.h
XsControl::customPortInfo
XsPortInfo customPortInfo(int channelId) const
Returns the port information for a custom communication channel.
Definition: xscontrol_def.cpp:820
XsDevice::resetLogFileReadPosition
virtual bool resetLogFileReadPosition()
Set the read position of the open log file to the start of the file.
Definition: xsdevice_def.cpp:3198
XRV_INVALIDID
@ XRV_INVALIDID
264: Invalid id supplied
Definition: xsresultvalue.h:134
XsControl::clearHardwareError
void clearHardwareError()
Clear the last hardware error.
Definition: xscontrol_def.cpp:381
RestoreCommunication
class XSNOEXPORT RestoreCommunication
Definition: xscontrol_def.h:90
XSEXITLOGD
#define XSEXITLOGD(j)
Definition: xscontrollerconfig.h:215
XsControl::gotoConfig
void gotoConfig()
Place all sensors connected through a serial port into Configuration Mode.
Definition: xscontrol_def.cpp:510
idfetchhelpers.h
XsControl::isDeviceWireless
virtual bool isDeviceWireless(const XsDeviceId &deviceId) const
Test if the given deviceId is an MTw and if it is wirelessly connected.
Definition: xscontrol_def.cpp:572
JLDEBUGG
#define JLDEBUGG(msg)
Definition: journaller.h:280
mtix0device.h
XsControl::flushInputBuffers
void flushInputBuffers()
Clear the inbound data buffers of all devices.
Definition: xscontrol_def.cpp:302
Communicator::createUniquePtr
static UniquePtr< T > createUniquePtr()
Constructs a new Communicator of type T and returns it as a UniquePtr<T>
Definition: communicator.h:117
XsControl::XsControl
XsControl()
Construct a new Xsens Device API control object.
Definition: xscontrol_def.cpp:140
XsControl::setPersistentSettings
void setPersistentSettings(XsDevice *dev)
int32_t
signed int int32_t
Definition: pstdint.h:515
OPS_Full
@ OPS_Full
Definition: openportstage.h:83
XsControl::openImarPort_internal
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.
Definition: xscontrol_def.cpp:880
xdacommunicatorfactory.h
XsDevice::setOptions
virtual void setOptions(XsOption enable, XsOption disable)
Enable and disable processing options.
Definition: xsdevice_def.cpp:3411
BroadcastDevice::setInitialPositionLLA
bool setInitialPositionLLA(const XsVector &lla) override
Sets the 'Latitude Longitude Altitude' setting of the device to the given vector.
Definition: broadcastdevice.cpp:499
xsfilterprofile.h
BroadcastDevice::gotoMeasurement
bool gotoMeasurement() override
Put this device in measurement mode.
Definition: broadcastdevice.cpp:414
LastResultManager::lastResult
XsResultValue lastResult() const
Definition: lastresultmanager.h:94
vidFromString
static uint16_t vidFromString(std::string const &string)
Definition: idfetchhelpers.h:95
XsControl::findDevice
XsDevice * findDevice(const XsDeviceId &deviceId) const
XdaCommunicatorFactory
XDA communication factory.
Definition: xdacommunicatorfactory.h:70
XsControl::m_portMutex
xsens::MutexReadWrite m_portMutex
Controls access to the serial ports, also used to suspend the thread.
Definition: xscontrol_def.h:247
DeviceFactory::registerDevices
virtual void registerDevices()
register all known device types
Definition: devicefactory.cpp:246
xsdeviceconfiguration.h
pidFromString
static uint16_t pidFromString(std::string const &string)
Definition: idfetchhelpers.h:113
XsControl::m_latLonAlt
XsVector3 m_latLonAlt
This vector contains the latitude, longitude and altitude.
Definition: xscontrol_def.h:277
XsControl::resultText
static XsString resultText(XsResultValue resultCode)
Get a descriptive text for the given resultCode.
Definition: xscontrol_def.cpp:186
XsControl::m_broadcaster
BroadcastDevice * m_broadcaster
The broadcast device object.
Definition: xscontrol_def.h:268
DeviceFactory
A Factory for the devices.
Definition: devicefactory.h:75
XsString
A 0-terminated managed string of characters.
XsControl::transmissionReceived
void transmissionReceived(int channelId, const XsByteArray &data)
Feed data coming back from an Xsens device over a custom channel into XDA.
Definition: xscontrol_def.cpp:857
XsDevice
Definition: xsdevice_def.h:164
xscontrol_public.h
xsens
Definition: threading.cpp:78
xsportinfoarray.h
mtigdevice.h
XSO_None
@ XSO_None
No option.
Definition: xsoption.h:78
BroadcastDevice::setOptions
void setOptions(XsOption enable, XsOption disable) override
Enable and disable processing options.
Definition: broadcastdevice.cpp:504
gJournal
Journaller * gJournal
Definition: configure_outputs.cpp:4
xsdeviceidarray.h
XRV_INVALIDPARAM
@ XRV_INVALIDPARAM
33: An invalid parameter is supplied
Definition: xsresultvalue.h:105


xsens_mti_driver
Author(s):
autogenerated on Sun Sep 3 2023 02:43:20