DESERT 4.0.0
uwinterpreters2c.h
Go to the documentation of this file.
1//
2// Copyright (c) 2019 Regents of the SIGNET lab, University of Padova.
3// All rights reserved.
4//
5// Redistribution and use in source and binary forms, with or without
6// modification, are permitted provided that the following conditions
7// are met:
8// 1. Redistributions of source code must retain the above copyright
9// notice, this list of conditions and the following disclaimer.
10// 2. Redistributions in binary form must reproduce the above copyright
11// notice, this list of conditions and the following disclaimer in the
12// documentation and/or other materials provided with the distribution.
13// 3. Neither the name of the University of Padova (SIGNET lab) nor the
14// names of its contributors may be used to endorse or promote products
15// derived from this software without specific prior written permission.
16//
17// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
37#ifndef UWINTERPRETERS2C_H
38#define UWINTERPRETERS2C_H
39
40#include <cstdarg>
41#include <iterator>
42#include <memory>
43#include <string>
44#include <vector>
45
49struct USBLInfo {
50 double curr_time;
51 double meas_time;
53 double X;
54 double Y;
55 double Z;
56 double E;
57 double N;
58 double U;
59 double accuracy;
60};
61
63{
64
65public:
110
114 virtual ~UwInterpreterS2C();
115
124 std::string buildSend(std::string msg, int dest);
125
135 std::string buildSendIM(std::string msg, int dest, bool ack);
136
143 std::string buildATZ(int level);
144
149 std::string buildGetATL();
150
156 std::string buildSetATL(int level);
157
162 std::string buildGetATAL();
163
169 std::string buildSetATAL(int addr);
170
175 std::string buildATDI();
176
183 std::string buildATS();
184
191 std::string buildATV();
192
202 UwInterpreterS2C::Response findResponse(std::vector<char>::iterator beg,
203 std::vector<char>::iterator end, std::vector<char>::iterator &rsp);
204
220 std::vector<char>::iterator end,
221 std::vector<char>::iterator rsp_beg,
222 std::vector<char>::iterator &rsp_end, std::string &rx_payload);
223
228 void setExtProtoMode(bool enabled);
229
235 std::shared_ptr<USBLInfo> getUSBLInfo();
236
240 void
241 setTerminator(std::string terminator)
242 {
243 w_term = terminator;
244 };
245
246private:
247 std::string sep;
248 std::string r_term;
249 std::string w_term;
253 std::shared_ptr<USBLInfo>
262 static std::vector<std::pair<std::string, UwInterpreterS2C::Response>>
264};
265
266#endif
Definition uwinterpreters2c.h:63
virtual ~UwInterpreterS2C()
Definition uwinterpreters2c.cpp:85
static std::vector< std::pair< std::string, UwInterpreterS2C::Response > > syntax_pool
Definition uwinterpreters2c.h:36
std::string buildATDI()
Definition uwinterpreters2c.cpp:152
bool ext_proto_mode
Definition uwinterpreters2c.h:251
std::shared_ptr< USBLInfo > getUSBLInfo()
Definition uwinterpreters2c.cpp:1306
std::string buildATV()
Definition uwinterpreters2c.cpp:166
UwInterpreterS2C()
Definition uwinterpreters2c.cpp:75
Response
Definition uwinterpreters2c.h:70
std::string buildSetATAL(int addr)
Definition uwinterpreters2c.cpp:207
std::string buildATZ(int level)
Definition uwinterpreters2c.cpp:137
std::string buildGetATL()
Definition uwinterpreters2c.cpp:173
std::string w_term
Definition uwinterpreters2c.h:249
void setTerminator(std::string terminator)
Definition uwinterpreters2c.h:241
UwInterpreterS2C::Response findResponse(std::vector< char >::iterator beg, std::vector< char >::iterator end, std::vector< char >::iterator &rsp)
Definition uwinterpreters2c.cpp:222
bool parseResponse(UwInterpreterS2C::Response rsp, std::vector< char >::iterator end, std::vector< char >::iterator rsp_beg, std::vector< char >::iterator &rsp_end, std::string &rx_payload)
Definition uwinterpreters2c.cpp:248
std::string sep
Definition uwinterpreters2c.h:247
void setExtProtoMode(bool enabled)
Definition uwinterpreters2c.cpp:1300
std::string r_term
Definition uwinterpreters2c.h:248
std::string buildSendIM(std::string msg, int dest, bool ack)
Definition uwinterpreters2c.cpp:108
std::shared_ptr< USBLInfo > usbl_info
Definition uwinterpreters2c.h:254
std::string buildATS()
Definition uwinterpreters2c.cpp:159
std::string buildSetATL(int level)
Definition uwinterpreters2c.cpp:182
std::string buildSend(std::string msg, int dest)
Definition uwinterpreters2c.cpp:90
std::string buildGetATAL()
Definition uwinterpreters2c.cpp:197
Definition uwinterpreters2c.h:49
double Y
Definition uwinterpreters2c.h:54
double accuracy
Definition uwinterpreters2c.h:59
double X
Definition uwinterpreters2c.h:53
double U
Definition uwinterpreters2c.h:58
int r_address
Definition uwinterpreters2c.h:52
double meas_time
Definition uwinterpreters2c.h:51
double E
Definition uwinterpreters2c.h:56
double N
Definition uwinterpreters2c.h:57
double Z
Definition uwinterpreters2c.h:55
double curr_time
Definition uwinterpreters2c.h:50