-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathParameters.cpp
257 lines (201 loc) · 5.93 KB
/
Parameters.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
#include <string>
#include <array>
#include "CPlusPlus_Common.h"
#include "Parameters.h"
#pragma region Evals
int
Parameters::evalActive(const OP_Inputs* input)
{
return input->getParInt(ActiveName);
}
int
Parameters::evalStandart(const OP_Inputs* input)
{
return input->getParInt(StandartModeName);
}
int
Parameters::evalQuality(const OP_Inputs* input)
{
return input->getParInt(QualityName);
}
int
Parameters::evalConnectionType(const OP_Inputs* input)
{
return input->getParInt(ConnectName);
}
int
Parameters::evalNetworkType(const OP_Inputs* input)
{
return input->getParInt(NetworkTypeName);
}
int
Parameters::evalMotorSpeed(const OP_Inputs* input)
{
return input->getParInt(SpeedName);
}
int
Parameters::evalPrecision(const OP_Inputs* input)
{
return input->getParInt(PrecisionName);
}
CoordMenuItems
Parameters::evalCoord(const OP_Inputs* input)
{
return static_cast<CoordMenuItems>(input->getParInt(CoordsName));
}
#pragma endregion
#pragma region Setup
void
Parameters::setup(OP_ParameterManager* manager)
{
// is active
{
OP_NumericParameter isActive;
isActive.name = ActiveName;
isActive.label = ActiveLabel;
isActive.page = PageMainName;
isActive.defaultValues[0] = 0;
OP_ParAppendResult res = manager->appendToggle(isActive);
assert(res == OP_ParAppendResult::Success);
}
// is standart
{
OP_NumericParameter isStandart;
isStandart.name = StandartModeName;
isStandart.label = StandartModeLabel;
isStandart.page = PageMainName;
isStandart.defaultValues[0] = 0;
OP_ParAppendResult res = manager->appendToggle(isStandart);
assert(res == OP_ParAppendResult::Success);
}
// Connection type toogle
{
OP_NumericParameter isNetwork;
isNetwork.name = ConnectName;
isNetwork.label = ConnectLabel;
isNetwork.page = PageConnectionsName;
isNetwork.defaultValues[0] = 0;
OP_ParAppendResult res = manager->appendToggle(isNetwork);
assert(res == OP_ParAppendResult::Success);
}
// COM Port
{
OP_StringParameter cp;
cp.name = PortName;
cp.label = PortLabel;
cp.page = PageConnectionsName;
cp.defaultValue = "COM3";
OP_ParAppendResult res = manager->appendString(cp);
assert(res == OP_ParAppendResult::Success);
}
// Bandwitch
{
OP_StringParameter bw;
bw.name = BaudrateName;
bw.label = BaudrateLabel;
bw.page = PageConnectionsName;
bw.defaultValue = "1000000";
std::array<const char*, 4> Names =
{
"115200", "256000", "460800", "1000000"
};
std::array<const char*, 4> Labels =
{
"115200", "256000", "460800", "1000000"
};
OP_ParAppendResult res = manager->appendMenu(bw, int(Names.size()), Names.data(), Labels.data());
//OP_ParAppendResult res = manager->appendMenu(sp, int(Names.size()), names, labels);
assert(res == OP_ParAppendResult::Success);
}
// Connection type toogle
{
OP_NumericParameter isUdp;
isUdp.name = NetworkTypeName;
isUdp.label = NetworkTypeLabel;
isUdp.page = PageConnectionsName;
isUdp.defaultValues[0] = 1;
OP_ParAppendResult res = manager->appendToggle(isUdp);
assert(res == OP_ParAppendResult::Success);
}
// IP Address
{
OP_StringParameter ip;
ip.name = IpName;
ip.label = IpLabel;
ip.page = PageConnectionsName;
ip.defaultValue = "192.168.11.2";
OP_ParAppendResult res = manager->appendString(ip);
assert(res == OP_ParAppendResult::Success);
}
// Network port
{
OP_StringParameter np;
np.name = NetworkPortName;
np.label = NetworkPortLabel;
np.page = PageConnectionsName;
np.defaultValue = "8089";
OP_ParAppendResult res = manager->appendString(np);
assert(res == OP_ParAppendResult::Success);
}
// Precision
{
OP_NumericParameter np;
np.name = PrecisionName;
np.label = PrecisionLabel;
np.page = PageOutputName;
np.minSliders[0] = 1;
np.maxSliders[0] = 4;
np.minValues[0] = 1;
np.maxValues[0] = 4;
np.clampMins[0] = true;
np.clampMaxes[0] = true;
np.defaultValues[0] = 2;
OP_ParAppendResult res = manager->appendInt(np);
assert(res == OP_ParAppendResult::Success);
}
// quality check
{
OP_NumericParameter isQuality;
isQuality.name = QualityName;
isQuality.label = QualityLabel;
isQuality.page = PageOutputName;
isQuality.defaultValues[0] = 0;
OP_ParAppendResult res = manager->appendToggle(isQuality);
assert(res == OP_ParAppendResult::Success);
}
// Distance
{
OP_NumericParameter np;
np.name = DistanceName;
np.label = DistanceLabel;
np.page = PageOutputName;
np.minValues[0] = 0;
np.maxValues[0] = 40;
np.clampMins[0] = true;
np.defaultValues[0] = 0;
np.minValues[1] = 0;
np.maxValues[1] = 40;
np.clampMins[1] = true;
OP_ParAppendResult res = manager->appendFloat(np, 2);
assert(res == OP_ParAppendResult::Success);
}
// Coordinate system
{
OP_StringParameter sp;
sp.name = CoordsName;
sp.label = CoordsLabel;
sp.page = PageOutputName;
sp.defaultValue = "Polar";
std::array<const char*, 2> Names =
{
"Polar", "Cartesian"
};
std::array<const char*, 2> Labels =
{
"Polar", "Cartesian"
};
OP_ParAppendResult res = manager->appendMenu(sp, int(Names.size()), Names.data(), Labels.data());
assert(res == OP_ParAppendResult::Success);
}
}
#pragma endregion