SafeVisionaryDataStream.h
Go to the documentation of this file.
1 // -- BEGIN LICENSE BLOCK ----------------------------------------------
20 // -- END LICENSE BLOCK ------------------------------------------------
21 
22 #pragma once
23 
24 #include "TcpSocket.h"
25 #include "UdpSocket.h"
26 #include "VisionaryData.h"
27 #include <memory>
28 #include <vector>
29 
30 namespace visionary {
33 {
34  uint16_t blobNumber;
35  uint16_t fragmentNumber;
36  uint16_t dataLength;
38 };
39 
40 enum class DataStreamError
41 {
42  OK,
63 };
64 
66 {
67 public:
68  SafeVisionaryDataStream(std::shared_ptr<VisionaryData> dataHandler);
70 
81  bool openUdpConnection(std::uint16_t port);
82 
84  bool openTcpConnection(std::uint16_t port, std::string deviceIpAddress);
85 
88  void closeUdpConnection();
89 
90  // Close the Tcp connection
91  void closeTcpConnection();
92 
96  bool getNextBlobUdp();
97 
99  bool getNextBlobTcp(std::vector<std::uint8_t>& receiveBufferPacketSize);
100 
105 
106  // start bytes of Blob data have been found
107  bool getBlobStartTcp(std::vector<std::uint8_t>& receiveBufferPacketSize);
108 
109 private:
111  std::shared_ptr<VisionaryData> m_dataHandler;
112 
114  std::unique_ptr<UdpSocket> m_pTransportUdp;
115 
118 
120  std::vector<uint8_t> m_blobDataBuffer;
121 
123  uint16_t m_blobNumber;
124 
126  uint16_t m_numSegments;
127 
129  std::vector<uint32_t> m_offsetSegment;
130 
132  std::vector<uint32_t> m_changeCounter;
133 
136 
141  bool getNextFragment(std::vector<std::uint8_t>& receiveBuffer);
142 
147  int32_t getNextTcpReception(std::vector<std::uint8_t>& receiveBuffer);
148 
155  bool parseUdpHeader(std::vector<std::uint8_t>& buffer, UdpProtocolData& udpProtocolData);
156 
163  bool getBlobStartUdp(bool& lastFragment);
164 
170  bool parseBlobHeaderUdp();
171 
176  bool parseBlobHeaderTcp();
177 
181  bool parseBlobData();
182 };
183 
184 } // namespace visionary
visionary::DataStreamError::INVALID_BLOB_ID
@ INVALID_BLOB_ID
visionary::UdpProtocolData
Meta data contained in a UDP header.
Definition: SafeVisionaryDataStream.h:32
visionary::SafeVisionaryDataStream::parseBlobData
bool parseBlobData()
Definition: SafeVisionaryDataStream.cpp:531
TcpSocket.h
visionary::DataStreamError::INVALID_BLOB_HEADER
@ INVALID_BLOB_HEADER
visionary::DataStreamError::INVALID_PACKET_TYPE_BLOB_HEADER
@ INVALID_PACKET_TYPE_BLOB_HEADER
visionary::DataStreamError::CONNECTION_CLOSED
@ CONNECTION_CLOSED
visionary::DataStreamError::INVALID_VERSION_BLOB_HEADER
@ INVALID_VERSION_BLOB_HEADER
visionary::SafeVisionaryDataStream::getBlobStartTcp
bool getBlobStartTcp(std::vector< std::uint8_t > &receiveBufferPacketSize)
Definition: SafeVisionaryDataStream.cpp:344
visionary::SafeVisionaryDataStream::m_offsetSegment
std::vector< uint32_t > m_offsetSegment
Offset in byte for each data segment.
Definition: SafeVisionaryDataStream.h:129
visionary
Definition: AuthenticationLegacy.h:25
visionary::SafeVisionaryDataStream::getNextTcpReception
int32_t getNextTcpReception(std::vector< std::uint8_t > &receiveBuffer)
Definition: SafeVisionaryDataStream.cpp:203
visionary::SafeVisionaryDataStream::m_pTransportTcp
TcpSocket m_pTransportTcp
Unique TCP socket used to receive the measurement data output stream.
Definition: SafeVisionaryDataStream.h:117
UdpSocket.h
visionary::SafeVisionaryDataStream::parseUdpHeader
bool parseUdpHeader(std::vector< std::uint8_t > &buffer, UdpProtocolData &udpProtocolData)
Definition: SafeVisionaryDataStream.cpp:231
visionary::DataStreamError::DATA_SEGMENT_DEPTHMAP_ERROR
@ DATA_SEGMENT_DEPTHMAP_ERROR
visionary::DataStreamError::INVALID_BLOB_NUMBER
@ INVALID_BLOB_NUMBER
visionary::SafeVisionaryDataStream::parseBlobHeaderUdp
bool parseBlobHeaderUdp()
Definition: SafeVisionaryDataStream.cpp:456
visionary::SafeVisionaryDataStream::m_pTransportUdp
std::unique_ptr< UdpSocket > m_pTransportUdp
Unique pointer the UDP socket used to receive the measurement data output stream.
Definition: SafeVisionaryDataStream.h:114
visionary::DataStreamError::PARSE_XML_ERROR
@ PARSE_XML_ERROR
visionary::SafeVisionaryDataStream::m_numSegments
uint16_t m_numSegments
number of Blob data segments
Definition: SafeVisionaryDataStream.h:126
visionary::SafeVisionaryDataStream::m_lastDataStreamError
DataStreamError m_lastDataStreamError
Stores the last error which occurred while parsing the data stream.
Definition: SafeVisionaryDataStream.h:135
visionary::SafeVisionaryDataStream::m_changeCounter
std::vector< uint32_t > m_changeCounter
Change counter for each data segment.
Definition: SafeVisionaryDataStream.h:132
VisionaryData.h
visionary::SafeVisionaryDataStream::getLastError
DataStreamError getLastError()
Definition: SafeVisionaryDataStream.cpp:825
visionary::UdpProtocolData::fragmentNumber
uint16_t fragmentNumber
fragment number, incremented for each new fragment of the Blob
Definition: SafeVisionaryDataStream.h:35
visionary::DataStreamError::DATA_SEGMENT_IMU_ERROR
@ DATA_SEGMENT_IMU_ERROR
visionary::SafeVisionaryDataStream::m_dataHandler
std::shared_ptr< VisionaryData > m_dataHandler
Shared pointer to the Visionary data handler.
Definition: SafeVisionaryDataStream.h:111
visionary::DataStreamError::INVALID_VERSION_UDP_HEADER
@ INVALID_VERSION_UDP_HEADER
visionary::DataStreamError::INVALID_UDP_FRAGMENT_NUMBER
@ INVALID_UDP_FRAGMENT_NUMBER
visionary::SafeVisionaryDataStream::getNextBlobTcp
bool getNextBlobTcp(std::vector< std::uint8_t > &receiveBufferPacketSize)
Definition: SafeVisionaryDataStream.cpp:742
visionary::SafeVisionaryDataStream::SafeVisionaryDataStream
SafeVisionaryDataStream(std::shared_ptr< VisionaryData > dataHandler)
Definition: SafeVisionaryDataStream.cpp:118
visionary::DataStreamError::DATA_SEGMENT_DEVICESTATUS_ERROR
@ DATA_SEGMENT_DEVICESTATUS_ERROR
visionary::SafeVisionaryDataStream::openTcpConnection
bool openTcpConnection(std::uint16_t port, std::string deviceIpAddress)
Connects to the sensor data stream using the given TCP port and given IPAddress.
Definition: SafeVisionaryDataStream.cpp:144
visionary::SafeVisionaryDataStream::parseBlobHeaderTcp
bool parseBlobHeaderTcp()
Definition: SafeVisionaryDataStream.cpp:381
visionary::SafeVisionaryDataStream
Definition: SafeVisionaryDataStream.h:65
visionary::SafeVisionaryDataStream::openUdpConnection
bool openUdpConnection(std::uint16_t port)
Definition: SafeVisionaryDataStream.cpp:130
visionary::DataStreamError::INVALID_LENGTH_UDP_HEADER
@ INVALID_LENGTH_UDP_HEADER
visionary::DataStreamError::INVALID_CRC_UDP_HEADER
@ INVALID_CRC_UDP_HEADER
visionary::UdpProtocolData::blobNumber
uint16_t blobNumber
BLOB number, incremented for each new Blob.
Definition: SafeVisionaryDataStream.h:34
visionary::DataStreamError::DATA_SEGMENT_FIELDINFORMATION_ERROR
@ DATA_SEGMENT_FIELDINFORMATION_ERROR
visionary::UdpProtocolData::isLastFragment
bool isLastFragment
flag whether this was the last fragment of a Blob
Definition: SafeVisionaryDataStream.h:37
visionary::SafeVisionaryDataStream::~SafeVisionaryDataStream
~SafeVisionaryDataStream()
Definition: SafeVisionaryDataStream.cpp:128
visionary::DataStreamError::DATA_SEGMENT_LOCALIOS_ERROR
@ DATA_SEGMENT_LOCALIOS_ERROR
visionary::SafeVisionaryDataStream::getBlobStartUdp
bool getBlobStartUdp(bool &lastFragment)
Definition: SafeVisionaryDataStream.cpp:298
visionary::DataStreamError::DATA_SEGMENT_LOGICSIGNALS_ERROR
@ DATA_SEGMENT_LOGICSIGNALS_ERROR
visionary::DataStreamError::DATA_RECEIVE_TIMEOUT
@ DATA_RECEIVE_TIMEOUT
visionary::SafeVisionaryDataStream::getNextFragment
bool getNextFragment(std::vector< std::uint8_t > &receiveBuffer)
Definition: SafeVisionaryDataStream.cpp:174
visionary::SafeVisionaryDataStream::getNextBlobUdp
bool getNextBlobUdp()
Definition: SafeVisionaryDataStream.cpp:661
visionary::DataStreamError::DATA_SEGMENT_ROI_ERROR
@ DATA_SEGMENT_ROI_ERROR
visionary::UdpProtocolData::dataLength
uint16_t dataLength
length of the payload within the fragment
Definition: SafeVisionaryDataStream.h:36
visionary::DataStreamError
DataStreamError
Definition: SafeVisionaryDataStream.h:40
visionary::SafeVisionaryDataStream::m_blobDataBuffer
std::vector< uint8_t > m_blobDataBuffer
Buffer which stores the received Blob data.
Definition: SafeVisionaryDataStream.h:120
visionary::DataStreamError::OK
@ OK
visionary::SafeVisionaryDataStream::m_blobNumber
uint16_t m_blobNumber
Number of current Blob.
Definition: SafeVisionaryDataStream.h:123
visionary::DataStreamError::INVALID_PACKET_TYPE_UDP_HEADER
@ INVALID_PACKET_TYPE_UDP_HEADER
visionary::SafeVisionaryDataStream::closeTcpConnection
void closeTcpConnection()
Definition: SafeVisionaryDataStream.cpp:165
visionary::TcpSocket
Definition: TcpSocket.h:50
visionary::SafeVisionaryDataStream::closeUdpConnection
void closeUdpConnection()
Definition: SafeVisionaryDataStream.cpp:157


sick_safevisionary_base
Author(s):
autogenerated on Sat Oct 21 2023 02:24:26