B15F Board 15 Famulus Edition

plottyfile.h
1 #ifndef PLOTTYFILE_H
2 #define PLOTTYFILE_H
3
4 #include <iostream>
5 #include <fstream>
6 #include <exception>
7 #include <vector>
8 #include "dot.h"
9
10 enum FunctionType
11 {
12 CurveFamily = 'S',
13 Curve = 'C',
14 Level = 'P'
15 };
16
19 class PlottyFile
20 {
21 public:
26 void addDot(Dot& dot);
27
32 void addDot(Dot dot);
33
38 void setFunctionType(FunctionType function_type);
39
44 void setQuadrant(uint8_t quadrant);
45
50 void setRefX(uint16_t ref_x);
51
56 void setRefY(uint16_t ref_y);
57
63 void setParaFirstCurve(uint16_t para_first);
64
69 void setParaStepWidth(uint16_t para_stepwidth);
70
75 void setUnitX(std::string unit_x);
76
81 void setDescX(std::string desc_x);
82
87 void setUnitY(std::string unit_y);
88
93 void setDescY(std::string desc_y);
94
99 void setUnitPara(std::string unit_para);
104 void setDescPara(std::string desc_para);
105
106
107
111 FunctionType getFunctionType(void) const;
112
116 uint8_t getQuadrant(void) const;
117
121 uint16_t getRefX(void) const;
122
126 uint16_t getRefY(void) const;
127
131 uint16_t getParaFirstCurve(void) const;
132
136 uint16_t getParaStepWidth(void) const;
137
141 std::string getUnitX(void) const;
142
146 std::string getDescX(void) const;
147
151 std::string getUnitY(void) const;
152
156 std::string getDescY(void) const;
157
161 std::string getUnitPara(void) const;
162
166 std::string getDescPara(void) const;
167
168
173 void writeToFile(std::string filename);
174
179 void startPlotty(std::string filename);
180 private:
181 void prepStr(std::string& str, uint8_t len);
182
183 std::vector<Dot> dots;
184
185 int8_t command = 0x1D;
186 const std::string head = "HTWK-HWLab";
187 const std::string filetype = "MD";
188 int16_t version = 1;
189 int16_t subversion = 0;
190 FunctionType function_type = FunctionType::Curve;
191 uint8_t quadrant = 1;
192 uint16_t ref_x = 1023;
193 uint16_t ref_y = 1023;
194 uint16_t para_first = 1;
195 uint16_t para_stepwidth = 1;
196 std::string unit_x;
197 std::string desc_x;
198 std::string unit_y;
199 std::string desc_y;
200 std::string unit_para;
201 std::string desc_para;
202 const uint8_t eof = 0xD;
203
204 constexpr static uint8_t STR_LEN_SHORT = 10;
205 constexpr static uint8_t STR_LEN_LARGE = 20;
206 };
207
208 #endif // PLOTTYFILE_H
PlottyFile::setParaStepWidth
void setParaStepWidth(uint16_t para_stepwidth)
Definition: plottyfile.cpp:40
PlottyFile::getQuadrant
uint8_t getQuadrant(void) const
Definition: plottyfile.cpp:80
PlottyFile::startPlotty
void startPlotty(std::string filename)
Definition: plottyfile.cpp:193
PlottyFile::writeToFile
void writeToFile(std::string filename)
Definition: plottyfile.cpp:147
PlottyFile::setUnitX
void setUnitX(std::string unit_x)
Definition: plottyfile.cpp:45
PlottyFile::setUnitPara
void setUnitPara(std::string unit_para)
Definition: plottyfile.cpp:65
PlottyFile::setDescY
void setDescY(std::string desc_y)
Definition: plottyfile.cpp:60
PlottyFile::setQuadrant
void setQuadrant(uint8_t quadrant)
Definition: plottyfile.cpp:18
PlottyFile::getDescY
std::string getDescY(void) const
Definition: plottyfile.cpp:120
PlottyFile
Definition: plottyfile.h:19
PlottyFile::setRefY
void setRefY(uint16_t ref_y)
Definition: plottyfile.cpp:30
PlottyFile::getDescX
std::string getDescX(void) const
Definition: plottyfile.cpp:110
PlottyFile::setFunctionType
void setFunctionType(FunctionType function_type)
Definition: plottyfile.cpp:13
PlottyFile::setDescX
void setDescX(std::string desc_x)
Definition: plottyfile.cpp:50
Dot
Definition: dot.h:12
PlottyFile::setRefX
void setRefX(uint16_t ref_x)
Definition: plottyfile.cpp:25
PlottyFile::setUnitY
void setUnitY(std::string unit_y)
Definition: plottyfile.cpp:55
PlottyFile::addDot
void addDot(Dot &dot)
Definition: plottyfile.cpp:3
PlottyFile::setDescPara
void setDescPara(std::string desc_para)
Definition: plottyfile.cpp:70
PlottyFile::getParaStepWidth
uint16_t getParaStepWidth(void) const
Definition: plottyfile.cpp:100
PlottyFile::getDescPara
std::string getDescPara(void) const
Definition: plottyfile.cpp:130
PlottyFile::setParaFirstCurve
void setParaFirstCurve(uint16_t para_first)
Definition: plottyfile.cpp:35
PlottyFile::getUnitY
std::string getUnitY(void) const
Definition: plottyfile.cpp:115
PlottyFile::getParaFirstCurve
uint16_t getParaFirstCurve(void) const
Definition: plottyfile.cpp:95
PlottyFile::getRefX
uint16_t getRefX(void) const
Definition: plottyfile.cpp:85
PlottyFile::getUnitPara
std::string getUnitPara(void) const
Definition: plottyfile.cpp:125
PlottyFile::getFunctionType
FunctionType getFunctionType(void) const
Definition: plottyfile.cpp:75
PlottyFile::getRefY
uint16_t getRefY(void) const
Definition: plottyfile.cpp:90
PlottyFile::getUnitX
std::string getUnitX(void) const
Definition: plottyfile.cpp:105