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 <stdexcept>
9 #include "dot.h"
10
11 enum FunctionType
12 {
13 CurveFamily = 'S',
14 Curve = 'C',
15 Level = 'P'
16 };
17
20 class PlottyFile
21 {
22 public:
27 void addDot(Dot& dot);
28
33 void addDot(Dot dot);
34
39 void setFunctionType(FunctionType function_type);
40
45 void setQuadrant(uint8_t quadrant);
46
51 void setRefX(uint16_t ref_x);
52
57 void setRefY(uint16_t ref_y);
58
64 void setParaFirstCurve(uint16_t para_first);
65
70 void setParaStepWidth(uint16_t para_stepwidth);
71
76 void setUnitX(std::string unit_x);
77
82 void setDescX(std::string desc_x);
83
88 void setUnitY(std::string unit_y);
89
94 void setDescY(std::string desc_y);
95
100 void setUnitPara(std::string unit_para);
105 void setDescPara(std::string desc_para);
106
107
108
112 FunctionType getFunctionType(void) const;
113
117 uint8_t getQuadrant(void) const;
118
122 uint16_t getRefX(void) const;
123
127 uint16_t getRefY(void) const;
128
132 uint16_t getParaFirstCurve(void) const;
133
137 uint16_t getParaStepWidth(void) const;
138
142 std::string getUnitX(void) const;
143
147 std::string getDescX(void) const;
148
152 std::string getUnitY(void) const;
153
157 std::string getDescY(void) const;
158
162 std::string getUnitPara(void) const;
163
167 std::string getDescPara(void) const;
168
169
174 void writeToFile(std::string filename);
175
180 void startPlotty(std::string filename);
181 private:
182 void prepStr(std::string& str, uint8_t len);
183
184 std::vector<Dot> dots;
185
186 int8_t command = 0x1D;
187 const std::string head = "HTWK-HWLab";
188 const std::string filetype = "MD";
189 int16_t version = 1;
190 int16_t subversion = 0;
191 FunctionType function_type = FunctionType::Curve;
192 uint8_t quadrant = 1;
193 uint16_t ref_x = 1023;
194 uint16_t ref_y = 1023;
195 uint16_t para_first = 1;
196 uint16_t para_stepwidth = 1;
197 std::string unit_x;
198 std::string desc_x;
199 std::string unit_y;
200 std::string desc_y;
201 std::string unit_para;
202 std::string desc_para;
203 const uint8_t eof = 0xD;
204
205 constexpr static uint8_t STR_LEN_SHORT = 10;
206 constexpr static uint8_t STR_LEN_LARGE = 20;
207 };
208
209 #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:196
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:20
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