proxycommunicator.h
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 #ifndef PROXYCOMMUNICATOR_H
66 #define PROXYCOMMUNICATOR_H
67 
68 #include "serialcommunicator.h"
69 #include "dataparser.h"
70 #include <xstypes/xsportinfo.h>
71 
72 class CallbackManagerXda;
74 {
75 public:
76  ProxyCommunicator(int channelId, uint32_t channelLatency);
77  ~ProxyCommunicator() override;
78 
80  XsResultValue processBufferedData(const XsByteArray& rawIn, std::deque<XsMessage>& messages) override;
81  void handleMessage(const XsMessage& message) override;
82 
83  void flushPort() override;
84  void closePort() override;
85  bool isPortOpen() const override;
86  bool openPort(const XsPortInfo& portInfo, OpenPortStage stage = OPS_Full, bool detectRs485 = false) override;
87  bool reopenPort(OpenPortStage stage = OPS_Full, bool skipDeviceIdCheck = false) override;
88  bool isDockedAt(Communicator* other) const override;
89  bool allowReprocessing() const override
90  {
91  return false;
92  }
93 
94  void handleReceivedData(const XsByteArray& data);
95 
96  bool doTransaction(const XsMessage& msg, XsMessage& rcv, uint32_t timeout) override;
97 
98  static XsPortInfo createPortInfo(int channelId);
99 protected:
100  XsResultValue writeRawData(const XsByteArray& data) override;
101  std::shared_ptr<StreamInterface> createStreamInterface(const XsPortInfo& pi) override
102  {
103  (void)pi;
104  return std::shared_ptr<StreamInterface>();
105  }
106 
107  uint32_t defaultInterfaceTimeout() const override;
108 
109 private:
112 };
113 
114 #endif
ProxyCommunicator::isPortOpen
bool isPortOpen() const override
Checks if the associated port is open.
Definition: proxycommunicator.cpp:113
dataparser.h
ProxyCommunicator::defaultInterfaceTimeout
uint32_t defaultInterfaceTimeout() const override
Returns the default timeout needed for this interface.
Definition: proxycommunicator.cpp:242
XsByteArray
A list of uint8_t values.
serialcommunicator.h
ProxyCommunicator::writeRawData
XsResultValue writeRawData(const XsByteArray &data) override
Writes raw data to the communication channel.
Definition: proxycommunicator.cpp:185
OpenPortStage
OpenPortStage
Port opening stages.
Definition: openportstage.h:76
SerialCommunicator
A class that uses serial communication.
Definition: serialcommunicator.h:75
ProxyCommunicator::createStreamInterface
std::shared_ptr< StreamInterface > createStreamInterface(const XsPortInfo &pi) override
Creates a stream interface.
Definition: proxycommunicator.h:101
ProxyCommunicator::openPort
bool openPort(const XsPortInfo &portInfo, OpenPortStage stage=OPS_Full, bool detectRs485=false) override
Opens a proxy port.
Definition: proxycommunicator.cpp:125
ProxyCommunicator
Definition: proxycommunicator.h:73
ProxyCommunicator::doTransaction
bool doTransaction(const XsMessage &msg, XsMessage &rcv, uint32_t timeout) override
Write a message and await the reply.
Definition: proxycommunicator.cpp:199
SerialCommunicator::portInfo
XsPortInfo portInfo() const override
Definition: serialcommunicator.cpp:236
ProxyCommunicator::processBufferedData
XsResultValue processBufferedData(const XsByteArray &rawIn, std::deque< XsMessage > &messages) override
Read all messages from the buffered read data after adding new data supplied in rawIn.
Definition: proxycommunicator.cpp:224
ProxyCommunicator::isDockedAt
bool isDockedAt(Communicator *other) const override
Has no effect for the ProxyCommunicator. Always returns false.
Definition: proxycommunicator.cpp:178
ProxyCommunicator::closePort
void closePort() override
Closes the port.
Definition: proxycommunicator.cpp:106
xsportinfo.h
ProxyCommunicator::reopenPort
bool reopenPort(OpenPortStage stage=OPS_Full, bool skipDeviceIdCheck=false) override
Closes and tries to reopen the port.
Definition: proxycommunicator.cpp:164
XsResultValue
XsResultValue
Xsens result values.
Definition: xsresultvalue.h:82
ProxyCommunicator::handleMessage
void handleMessage(const XsMessage &message) override
Handles a message received on the communication channel.
Definition: proxycommunicator.cpp:214
ProxyCommunicator::allowReprocessing
bool allowReprocessing() const override
Definition: proxycommunicator.h:89
Communicator
A base struct for a communication interface.
Definition: communicator.h:95
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
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
XsMessage
Structure for storing a single message.
Definition: xsmessage.h:202
ProxyCommunicator::m_channelLatency
uint32_t m_channelLatency
Definition: proxycommunicator.h:111
ProxyCommunicator::ProxyCommunicator
ProxyCommunicator(int channelId, uint32_t channelLatency)
Constructor.
Definition: proxycommunicator.cpp:85
ProxyCommunicator::readDataToBuffer
XsResultValue readDataToBuffer(XsByteArray &raw) override
Has no effect for the ProxyCommunicator.
Definition: proxycommunicator.cpp:206
ProxyCommunicator::handleReceivedData
void handleReceivedData(const XsByteArray &data)
Handles data received from the communication channel.
Definition: proxycommunicator.cpp:193
OPS_Full
@ OPS_Full
Definition: openportstage.h:83
ProxyCommunicator::~ProxyCommunicator
~ProxyCommunicator() override
Destructor.
Definition: proxycommunicator.cpp:93
CallbackManagerXda
Class that delegates callbacks to registered XsCallbackHandlerItems.
Definition: callbackmanagerxda.h:78
ProxyCommunicator::flushPort
void flushPort() override
Flushes all remaining data on the open port. Has no effect for the ProxyCommunicator.
Definition: proxycommunicator.cpp:99
ProxyCommunicator::m_channelId
int m_channelId
Definition: proxycommunicator.h:110


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