cola_parser.h
Go to the documentation of this file.
1 /*
2  * @brief sim_loc_cola_parser parses and converts binary Cola telegrams to ros messages SickLocColaTelegramMsg
3  * and vice versa.
4  *
5  * See Operation-Instruction-v1.1.0.241R.pdf, chapter 5.8 "About CoLa-A telegrams", page 46-48,
6  * Telegram-Listing-v1.1.0.241R.pdf, chapter 2.3.9 "Command: LocRequestTimestamp", page 21, and
7  * Technical_information_Telegram_Listing_NAV_LOC_en_IM0076556.PDF for further details about
8  * Cola telegrams.
9  *
10  * Copyright (C) 2019 Ing.-Buero Dr. Michael Lehning, Hildesheim
11  * Copyright (C) 2019 SICK AG, Waldkirch
12  *
13  * Licensed under the Apache License, Version 2.0 (the "License");
14  * you may not use this file except in compliance with the License.
15  * You may obtain a copy of the License at
16  *
17  * http://www.apache.org/licenses/LICENSE-2.0
18  *
19  * Unless required by applicable law or agreed to in writing, software
20  * distributed under the License is distributed on an "AS IS" BASIS,
21  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22  * See the License for the specific language governing permissions and
23  * limitations under the License.
24  *
25  * All rights reserved.
26  *
27  * Redistribution and use in source and binary forms, with or without
28  * modification, are permitted provided that the following conditions are met:
29  *
30  * * Redistributions of source code must retain the above copyright
31  * notice, this list of conditions and the following disclaimer.
32  * * Redistributions in binary form must reproduce the above copyright
33  * notice, this list of conditions and the following disclaimer in the
34  * documentation and/or other materials provided with the distribution.
35  * * Neither the name of SICK AG nor the names of its
36  * contributors may be used to endorse or promote products derived from
37  * this software without specific prior written permission
38  * * Neither the name of Ing.-Buero Dr. Michael Lehning nor the names of its
39  * contributors may be used to endorse or promote products derived from
40  * this software without specific prior written permission
41  *
42  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
43  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
45  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
46  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
47  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
48  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
49  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
50  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
51  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
52  * POSSIBILITY OF SUCH DAMAGE.
53  *
54  * Authors:
55  * Michael Lehning <michael.lehning@lehning.de>
56  *
57  * Copyright 2019 SICK AG
58  * Copyright 2019 Ing.-Buero Dr. Michael Lehning
59  *
60  */
61 #ifndef __SIM_LOC_COLA_PARSER_H_INCLUDED
62 #define __SIM_LOC_COLA_PARSER_H_INCLUDED
63 
64 #include "sick_scan/ros_wrapper.h"
66 
67 namespace sick_scan
68 {
78  class ColaParser
79  {
80  public:
81 
93  {
94  sINVALID = 0,
95  sRN = 1,
96  sRA = 2,
97  sMN = 3,
98  sAN = 4,
99  sMA = 5,
100  sWN = 6,
101  sWA = 7,
102  sEN = 8,
103  sEA = 9,
104  sSN = 10,
105  sFA = 11,
108 
116  static sick_scan::SickLocColaTelegramMsg createColaTelegram(const COLA_SOPAS_COMMAND & command_type,
117  const std::string & command_name, const std::vector<std::string> & parameter = std::vector<std::string>());
118 
127  static sick_scan::SickLocColaTelegramMsg decodeColaTelegram(const std::vector<uint8_t> & cola_binary);
128 
134  static sick_scan::SickLocColaTelegramMsg decodeColaTelegram(const std::string & cola_ascii);
135 
142  static std::vector<uint8_t> encodeColaTelegram(const sick_scan::SickLocColaTelegramMsg & cola_telegram, bool parameter_is_ascii = true);
143 
151  static std::vector<uint8_t> encodeColaTelegram(const COLA_SOPAS_COMMAND & command_type, const std::string & command_name,
152  const std::vector<std::string> & parameter = std::vector<std::string>(), bool parameter_is_ascii = true);
153 
158  static const std::string & asciiSTX(void) { return s_cola_ascii_start_tag; }
159 
164  static const std::string & asciiETX(void) { return s_cola_ascii_end_tag; }
165 
170  static std::vector<uint8_t> binarySTX(void){ return sick_scan::ColaAsciiBinaryConverter::ConvertColaAscii(asciiSTX()); }
171 
176  static std::vector<uint8_t> binaryETX(void){ return sick_scan::ColaAsciiBinaryConverter::ConvertColaAscii(asciiETX()); }
177 
184  static std::string convertSopasCommand(COLA_SOPAS_COMMAND command_type);
185 
192  static COLA_SOPAS_COMMAND convertSopasCommand(const std::string & sopas_command);
193 
201  static int32_t convertColaArg(const std::string & cola_arg, int base = 10, int32_t default_value = 0);
202 
210  static uint32_t convertColaArg(const std::string & cola_arg, int base = 10, uint32_t default_value = 0);
211 
218  static bool convertColaResponseBool(const std::string & cola_response_arg, bool default_value);
219 
220  protected:
221 
222  static const std::string s_command_type_string[MAX_COLA_COMMAND_NUMBER];
223  static const std::map<std::string, COLA_SOPAS_COMMAND> s_command_type_map;
224  static const std::string s_cola_ascii_start_tag;
225  static const std::string s_cola_ascii_end_tag;
226 
227  }; // class ColaParser
228 
229 } // namespace sick_scan
230 #endif // __SIM_LOC_COLA_PARSER_H_INCLUDED
sick_scan::ColaParser::convertColaResponseBool
static bool convertColaResponseBool(const std::string &cola_response_arg, bool default_value)
Definition: cola_parser.cpp:288
sick_scan::ColaParser::binaryETX
static std::vector< uint8_t > binaryETX(void)
Returns the binary "end of text" tag in a Cola-Binary command, i.e. {0x03}.
Definition: cola_parser.h:176
sick_scan::ColaParser
class ColaParser parses and converts binary Cola telegrams to ros messages SickLocColaTelegramMsg and...
Definition: cola_parser.h:78
sick_scan::ColaParser::sSN
@ sSN
Answer (response)
Definition: cola_parser.h:104
pcap_json_converter.cola_ascii
bool cola_ascii
Definition: pcap_json_converter.py:132
sick_scan::ColaParser::asciiSTX
static const std::string & asciiSTX(void)
Returns the "start of text" tag in a Cola ASCII command, i.e. "<STX>".
Definition: cola_parser.h:158
sick_scan::ColaParser::sMN
@ sMN
Method by name (request)
Definition: cola_parser.h:97
sick_scan::ColaParser::convertColaArg
static int32_t convertColaArg(const std::string &cola_arg, int base=10, int32_t default_value=0)
Definition: cola_parser.cpp:245
sick_scan::ColaParser::COLA_SOPAS_COMMAND
enum sick_scan::ColaParser::COLA_SOPAS_COMMAND_ENUM COLA_SOPAS_COMMAND
Enumeration of SOPAS commands in cola telegrams: The command_type in SickLocColaTelegramMsg is one of...
sick_scan::ColaParser::sINVALID
@ sINVALID
uninitialized, command_type should never have this value)
Definition: cola_parser.h:94
sick_scan::ColaParser::sEA
@ sEA
Event answer (response)
Definition: cola_parser.h:103
sick_scan::ColaParser::encodeColaTelegram
static std::vector< uint8_t > encodeColaTelegram(const sick_scan::SickLocColaTelegramMsg &cola_telegram, bool parameter_is_ascii=true)
Encodes and returns a Cola Binary telegram from ros message SickLocColaTelegramMsg.
Definition: cola_parser.cpp:182
cola_converter.h
sick_scan::ColaParser::sEN
@ sEN
Event by name (request)
Definition: cola_parser.h:102
sick_scan::ColaParser::s_command_type_map
static const std::map< std::string, COLA_SOPAS_COMMAND > s_command_type_map
static map to convert COLA_SOPAS_COMMANDs from string to enum, f.e. s_command_type_map["sRN"]:=sRN,...
Definition: cola_parser.h:223
sick_scan::ColaParser::sWA
@ sWA
Write answer (response)
Definition: cola_parser.h:101
sick_scan::ColaParser::s_cola_ascii_end_tag
static const std::string s_cola_ascii_end_tag
All Cola-ACSII telegrams start with s_cola_ascii_start_tag := "<ETX>" ("End of TeXt")
Definition: cola_parser.h:225
sick_scan::ColaParser::sFA
@ sFA
Error Answer with error code (response)
Definition: cola_parser.h:105
sick_scan::ColaParser::sWN
@ sWN
Write by name (request)
Definition: cola_parser.h:100
sick_scan::ColaParser::sMA
@ sMA
Method by name (response)
Definition: cola_parser.h:99
sick_scan::ColaParser::COLA_SOPAS_COMMAND_ENUM
COLA_SOPAS_COMMAND_ENUM
Enumeration of SOPAS commands in cola telegrams: The command_type in SickLocColaTelegramMsg is one of...
Definition: cola_parser.h:92
sick_scan::ColaParser::sRN
@ sRN
Read by name (request)
Definition: cola_parser.h:95
sick_scan::ColaParser::MAX_COLA_COMMAND_NUMBER
@ MAX_COLA_COMMAND_NUMBER
Number of possible COLA_SOPAS_COMMANDs incl. invalid command.
Definition: cola_parser.h:106
sick_scan::ColaParser::binarySTX
static std::vector< uint8_t > binarySTX(void)
Returns the binary "start of text" tag in a Cola-Binary command, i.e. {0x02}.
Definition: cola_parser.h:170
sick_scan::ColaParser::createColaTelegram
static sick_scan::SickLocColaTelegramMsg createColaTelegram(const COLA_SOPAS_COMMAND &command_type, const std::string &command_name, const std::vector< std::string > &parameter=std::vector< std::string >())
Creates and returns a Cola telegram (type SickLocColaTelegramMsg).
Definition: cola_parser.cpp:100
sick_scan
Definition: abstract_parser.cpp:50
sick_scan::ColaParser::asciiETX
static const std::string & asciiETX(void)
Returns the "end of text" tag in a Cola ASCII command, i.e. "<ETX>".
Definition: cola_parser.h:164
sick_scan::ColaParser::s_command_type_string
static const std::string s_command_type_string[MAX_COLA_COMMAND_NUMBER]
static table to convert COLA_SOPAS_COMMAND to string, f.e. s_command_type_string[sRN]:="sRN",...
Definition: cola_parser.h:222
sick_scan::ColaParser::sRA
@ sRA
Read by name (response)
Definition: cola_parser.h:96
sick_scan::ColaParser::convertSopasCommand
static std::string convertSopasCommand(COLA_SOPAS_COMMAND command_type)
Converts and returns a COLA_SOPAS_COMMAND to string. Example: convertSopasCommand(sMN) returns "sMN".
Definition: cola_parser.cpp:220
sick_scan::ColaParser::decodeColaTelegram
static sick_scan::SickLocColaTelegramMsg decodeColaTelegram(const std::vector< uint8_t > &cola_binary)
Decodes and returns a Cola message of type SickLocColaTelegramMsg from a Cola-Binary telegram....
Definition: cola_parser.cpp:119
ros_wrapper.h
sick_scan::ColaAsciiBinaryConverter::ConvertColaAscii
static std::string ConvertColaAscii(const std::vector< uint8_t > &cola_telegram)
Converts and returns a Cola-ASCII telegram to string.
Definition: cola_converter.cpp:105
sick_scan::ColaParser::s_cola_ascii_start_tag
static const std::string s_cola_ascii_start_tag
All Cola-ACSII telegrams start with s_cola_ascii_start_tag := "<STX>" ("Start of TeXt")
Definition: cola_parser.h:224
sick_scan::ColaParser::sAN
@ sAN
Response to sMN.
Definition: cola_parser.h:98


sick_scan
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Thu Sep 8 2022 02:30:19