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 
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);
101 
106  void setDescPara(std::string desc_para);
107 
108 
109 
113  FunctionType getFunctionType(void) const;
114 
118  uint8_t getQuadrant(void) const;
119 
123  uint16_t getRefX(void) const;
124 
128  uint16_t getRefY(void) const;
129 
133  uint16_t getParaFirstCurve(void) const;
134 
138  uint16_t getParaStepWidth(void) const;
139 
143  std::string getUnitX(void) const;
144 
148  std::string getDescX(void) const;
149 
153  std::string getUnitY(void) const;
154 
158  std::string getDescY(void) const;
159 
163  std::string getUnitPara(void) const;
164 
168  std::string getDescPara(void) const;
169 
170 
175  void writeToFile(std::string filename);
176 
181  void startPlotty(std::string filename);
182 private:
183  void prepStr(std::string& str, uint8_t len);
184 
185  std::vector<Dot> dots;
186 
187  int8_t command = 0x1D;
188  const std::string head = "HTWK-HWLab";
189  const std::string filetype = "MD";
190  int16_t version = 1;
191  int16_t subversion = 0;
192  FunctionType function_type = FunctionType::Curve;
193  uint8_t quadrant = 1;
194  uint16_t ref_x = 1023;
195  uint16_t ref_y = 1023;
196  uint16_t para_first = 1;
197  uint16_t para_stepwidth = 1;
198  std::string unit_x;
199  std::string desc_x;
200  std::string unit_y;
201  std::string desc_y;
202  std::string unit_para;
203  std::string desc_para;
204  const uint8_t eof = 0xD;
205 
206  constexpr static uint8_t STR_LEN_SHORT = 10;
207  constexpr static uint8_t STR_LEN_LARGE = 20;
208 };
209 
210 #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