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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
| using AKS16_AKS17_CalibrationGui_NewRev.View;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Controls;
using AKS16_AKS17_CalibrationGui_NewRev.ServiceClasses.UniversallyServiceClasses;
using AKS16_AKS17_CalibrationGui_NewRev.UserControls;
using AKS16_AKS17_CalibrationGui_NewRev.Model;
namespace AKS16_AKS17_CalibrationGui_NewRev.ViewModel
{
/// <summary>
/// View model for main window
/// </summary>
public class MainWindowViewModel: PropertyChangeSupervisorWindowBased
{
private GUIComboBoxElements ComboBoxes;
private DataModelAKS modelAKS;
/// <summary>
/// App title for MainWindow header
/// </summary>
private string sTitle = "AKS16 and AKS17 Calibration GUI Revision 2.0 ";
public string STitle
{
get { return sTitle; }
set
{
sTitle = value;
onPropertyChanged("STitle");
}
}
/// <summary>
/// State holder for selected execution mode.
/// True = development mode, false = production mode
/// </summary>
private bool bDevelopmentMode;
/// <summary>
/// bDevelopmentMode property superviser implement set and get methods for bIsInvertedRotation is neccessary for binding between view and data model.
/// </summary>
public bool BDevelopmentMode
{
get { return bDevelopmentMode; }
set
{
bDevelopmentMode = value;
onPropertyChanged("BDevelopmentMode");
}
}
/// <summary>
/// State holder for InvertedRotation property
/// </summary>
private bool bIsInvertedRotation = false;
/// <summary>
/// bIsInvertedRotation property superviser implement set and get methods for bIsInvertedRotation is neccessary for binding between view and data model.
/// </summary>
public bool BIsInvertedRotation
{
get { return bIsInvertedRotation; }
set
{
bIsInvertedRotation = value;
onPropertyChanged("BIsInvertedRotation");
}
}
/// <summary>
/// An state holder for property SaveRawData
/// </summary>
private bool bIsSaveRawData = false;
/// <summary>
/// bIsSaveRawData property superviser implement set and get methods for bIsSaveRawData is neccessary for binding between view and data model.
/// </summary>
public bool BIsSaveRawData
{
get { return bIsSaveRawData; }
set
{
bIsSaveRawData = value;
onPropertyChanged("BIsSaveRawData");
}
}
//Commands
//Menu commands
//File menu commands
public ICommand CommandSaveEncoderConfig { get; private set; }
public ICommand CommandLoadEncoderConfig { get; private set; }
public ICommand CommandCalibrationSetup { get; private set; }
public ICommand CommandPreference { get; private set; }
public ICommand CommandExit { get; private set; }
//Tools menu commands
public ICommand CommandProductInformation { get; private set; }
public ICommand CommandShowProtocolDataPacket { get; private set; }
public ICommand CommandOffsetCompensation { get; private set; }
public ICommand CommandMotorController { get; private set; }
public ICommand CommandSerialPortTriggerSignal { get; private set; }
public ICommand CommandSensorDemo { get; private set; }
//Help menu commands
public ICommand CommandSendReport { get; private set; }
public ICommand CommandAbout { get; private set; }
//GUIs itself commands
public ICommand CommandOneStepCalibration { get; private set; }
public ICommand CommandDetails { get; private set; }
//Navigation commands, implimentation of user control OrientationOptionView commands
public ICommand CommandNext { get; private set; }
public ICommand CommandPrev { get; private set; }
public ICommand CommandTest { get; private set; }
/// <summary>
/// Exemplar of OrientationOptionView user control
/// </summary>
private OrientationOptionUserControl orientationOptionControl;
/// <summary>
/// Property change supervizer of OrientationOptionView user control for binding into MainWindowView
/// </summary>
public OrientationOptionUserControl OrientationOptionControl
{
get { return orientationOptionControl; }
set
{
orientationOptionControl = value;
onPropertyChanged("OrientationOptionControl");
}
}
private Visibility vDetailsButton;
public Visibility VDetailsButton
{
get { return vDetailsButton; }
set
{
vDetailsButton = value;
onPropertyChanged("VDetailsButton");
}
}
/// <summary>
/// Constructor with mode argument
/// </summary>
/// <param name="mode">if true = development mode if false = production mode</param>
public MainWindowViewModel()
{
ComboBoxes = new GUIComboBoxElements();
ComboBoxSensor = ComboBoxes.CbSensorType;
ComboBoxSize = ComboBoxes.CbSize;
ComboBoxAbsoluteInterface = ComboBoxes.CbInterfaceAbsolut;
ComboBoxIncrementalInterface = ComboBoxes.CbInterfaceIncremental;
ComboBoxPolePairs = ComboBoxes.CbNumberOfPolePairs;
ComboBoxResolution = ComboBoxes.CbABZResolution;
ComboBoxVariables = ComboBoxResolution;
modelAKS = new DataModelAKS();
VDetailsButton = Visibility.Collapsed;
// show versions info in Title
System.Diagnostics.FileVersionInfo vi = System.Diagnostics.FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location);
System.IO.FileInfo fileInfo = new System.IO.FileInfo(vi.FileName);
Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
DateTime buildDate = new DateTime(2000, 1, 1).AddDays(version.Build).AddSeconds(version.Revision * 2);
string displayableVersion = $"{version} ({buildDate})";
STitle = STitle + " - Version " + displayableVersion;
#if DEBUG
STitle = STitle + " - Debug Version";
#endif
BDevelopmentMode = true;
//UserControl to show the orientations options
OrientationOptionControl = new OrientationOptionUserControl();
//Implements commands
CommandSaveEncoderConfig = new DelegateCommand(SaveEncoderConfig, CanSaveEncoderConfig);
CommandLoadEncoderConfig = new DelegateCommand(LoadEncoderConfig, CanLoadEncoderConfig);
CommandCalibrationSetup = new DelegateCommand(CalibrationSetup, CanCalibrationSetup);
CommandPreference = new DelegateCommand(Preference, CanPreference);
CommandExit = new DelegateCommand(Exit, CanExit);
CommandProductInformation = new DelegateCommand(ProductInformation, CanProductInformation);
CommandShowProtocolDataPacket = new DelegateCommand(ShowProtocolDataPacket, CanShowProtocolDataPacket);
CommandOffsetCompensation = new DelegateCommand(OffsetCompensation, CanOffsetCompensation);
CommandMotorController = new DelegateCommand(MotorController, CanMotorController);
CommandSerialPortTriggerSignal = new DelegateCommand(SerialPortTriggerSignal, CanSerialPortTriggerSignal);
CommandSensorDemo = new DelegateCommand(SensorDemo, CanSensorDemo);
CommandSendReport = new DelegateCommand(SendReport, CanSendReport);
CommandAbout = new DelegateCommand(About, CanAbout);
CommandOneStepCalibration = new DelegateCommand(OneStepCalibration, CanOneStepCalibration);
CommandDetails = new DelegateCommand(Details, CanDetails);
}
#region ComboBoxes
private ComboBox comboBoxVariables;
public ComboBox ComboBoxVariables
{
get { return comboBoxVariables; }
set
{
comboBoxVariables = value;
onPropertyChanged("ComboBoxVariables");
}
}
private ComboBox comboBoxSensor;
public ComboBox ComboBoxSensor
{
get { return comboBoxSensor; }
set
{
comboBoxSensor = value;
onPropertyChanged("ComboBoxSensor");
}
}
private ComboBox comboBoxIncrementalInterface;
public ComboBox ComboBoxIncrementalInterface
{
get { return comboBoxIncrementalInterface; }
set
{
comboBoxIncrementalInterface = value;
onPropertyChanged("ComboBoxIncrementalInterface");
}
}
private ComboBox comboBoxAbsoluteInterface;
public ComboBox ComboBoxAbsoluteInterface
{
get { return comboBoxAbsoluteInterface; }
set
{
comboBoxAbsoluteInterface = value;
onPropertyChanged("ComboBoxAbsoluteInterface");
}
}
private ComboBox comboBoxResolution;
public ComboBox ComboBoxResolution
{
get { return comboBoxResolution; }
set
{
comboBoxResolution = value;
onPropertyChanged("ComboBoxResolution");
}
}
private ComboBox comboBoxSize;
public ComboBox ComboBoxSize
{
get { return comboBoxSize; }
set
{
comboBoxSize = value;
onPropertyChanged("ComboBoxSize");
}
}
private ComboBox comboBoxPolePairs;
public ComboBox ComboBoxPolePairs
{
get { return comboBoxPolePairs; }
set
{
comboBoxPolePairs = value;
onPropertyChanged("ComboBoxPolePairs");
}
}
#endregion
private CheckBox checkBoxInvertedRotation;
public CheckBox CheckBoxInvertedRotation
{
get { return checkBoxInvertedRotation; }
set
{
checkBoxInvertedRotation = value;
onPropertyChanged("CheckBoxInvertedRotation");
}
}
private uint uiSelectedOrientation;
public uint UiSelectedOrientation
{
get { return uiSelectedOrientation; }
set
{
uiSelectedOrientation = value;
onPropertyChanged("UiSelectedOrientation");
}
}
private bool bFullRangeCalibration;
public bool BFullRangeCalibration
{
get { return bFullRangeCalibration; }
set
{
bFullRangeCalibration = value;
onPropertyChanged("BFullRangeCalibration");
}
}
private CheckBox checkBoxSaveRawData;
public CheckBox CheckBoxSaveRawData
{
get { return checkBoxSaveRawData; }
set
{
checkBoxSaveRawData = value;
onPropertyChanged("CheckBoxSaveRawData");
}
}
private string sVariativeComboBoxText;
public string SVariativeComboBoxtext
{
get { return sVariativeComboBoxText; }
set
{
sVariativeComboBoxText = value;
onPropertyChanged("SVariativeComboBoxtext");
}
}
private Visibility v_VariativeComboBoxVisibility;
public Visibility V_VariativeComboBoxVisibility
{
get { return v_VariativeComboBoxVisibility; }
set
{
v_VariativeComboBoxVisibility = value;
onPropertyChanged("V_VariativeComboBoxVisibility");
}
}
#region Commands
/// <summary>
/// Can execute path of Details command.
/// </summary>
/// <param name="parameter">Not neccessary parameter, can be useful in deverse implementatins</param>
/// <returns>true if command can execute or false if not.</returns>
public bool CanDetails(object parameter = null)
{
return false;
}
/// <summary>
/// Execute path of Details command, implements all aktions and command logic.
/// </summary>
private void Details()
{
}
/// <summary>
/// Can execute path of SaveEncodingConfig command.
/// </summary>
/// <param name="parameter">Not neccessary parameter, can be useful in deverse implementatins</param>
/// <returns>true if command can execute or false if not.</returns>
public bool CanSaveEncoderConfig(object parameter = null)
{
return false;
}
/// <summary>
/// Execute path of SaveEncoderConfig command, implements all aktions and command logic.
/// </summary>
private void SaveEncoderConfig()
{
}
/// <summary>
/// Can execute path of LoadEncoderConfig command.
/// </summary>
/// <param name="parameter">Not neccessary parameter, can be useful in deverse implementatins</param>
/// <returns>true if command can execute or false if not.</returns>
public bool CanLoadEncoderConfig(object parameter = null)
{
return false;
}
/// <summary>
/// Execute path of LoadEncoderConfig command, implements all aktions and command logic.
/// </summary>
private void LoadEncoderConfig()
{
}
/// <summary>
/// Can execute path of CalibrationSetup command.
/// </summary>
/// <param name="parameter">Not neccessary parameter, can be useful in deverse implementatins</param>
/// <returns>true if command can execute or false if not.</returns>
public bool CanCalibrationSetup(object parameter = null)
{
return false;
}
/// <summary>
/// Execute path of CalibrationSetup command, implements all aktions and command logic.
/// </summary>
private void CalibrationSetup()
{
}
/// <summary>
/// Can execute path of Preference command.
/// </summary>
/// <param name="parameter">Not neccessary parameter, can be useful in deverse implementatins</param>
/// <returns>true if command can execute or false if not.</returns>
public bool CanPreference(object parameter = null)
{
return false;
}
/// <summary>
/// Execute path of Preference command, implements all aktions and command logic.
/// </summary>
private void Preference()
{
}
/// <summary>
/// Can execute path of Exit command.
/// </summary>
/// <param name="parameter">Not neccessary parameter, can be useful in deverse implementatins</param>
/// <returns>true if command can execute or false if not.</returns>
public bool CanExit(object parameter = null)
{
return Application.Current != null && Application.Current.MainWindow != null && bDevelopmentMode;
}
/// <summary>
/// Execute path of Exit command, implements all aktions and command logic.
/// </summary>
private void Exit()
{
Application.Current.Shutdown();
}
/// <summary>
/// Can execute path of ProductInformation command.
/// </summary>
/// <param name="parameter">Not neccessary parameter, can be useful in deverse implementatins</param>
/// <returns>true if command can execute or false if not.</returns>
public bool CanProductInformation(object parameter = null)
{
return false;
}
/// <summary>
/// Execute path of ProductInformation command, implements all aktions and command logic.
/// </summary>
private void ProductInformation()
{
}
/// <summary>
/// Can execute path of ShowProtocolDataPacket command.
/// </summary>
/// <param name="parameter">Not neccessary parameter, can be useful in deverse implementatins</param>
/// <returns>true if command can execute or false if not.</returns>
public bool CanShowProtocolDataPacket(object parameter = null)
{
return false;
}
/// <summary>
/// Execute path of ShowProtocolDataPacket command, implements all aktions and command logic.
/// </summary>
private void ShowProtocolDataPacket()
{
}
/// <summary>
/// Can execute path of OffsetCompensation command.
/// </summary>
/// <param name="parameter">Not neccessary parameter, can be useful in deverse implementatins</param>
/// <returns>true if command can execute or false if not.</returns>
public bool CanOffsetCompensation(object parameter = null)
{
return false;
}
/// <summary>
/// Execute path of OffsetCompensation command, implements all aktions and command logic.
/// </summary>
private void OffsetCompensation()
{
}
/// <summary>
/// Can execute path of MotorController command.
/// </summary>
/// <param name="parameter">Not neccessary parameter, can be useful in deverse implementatins</param>
/// <returns>true if command can execute or false if not.</returns>
public bool CanMotorController(object parameter = null)
{
return true;
}
/// <summary>
/// Execute path of MotorController command, implements all aktions and command logic.
/// </summary>
private void MotorController()
{
MotorControllerView mc = new MotorControllerView();
mc.ShowDialog();
}
/// <summary>
/// Can execute path of SerialPortTriggerSignal command.
/// </summary>
/// <param name="parameter">Not neccessary parameter, can be useful in deverse implementatins</param>
/// <returns>true if command can execute or false if not.</returns>
public bool CanSerialPortTriggerSignal(object parameter = null)
{
return true;
}
/// <summary>
/// Execute path of SerialPortTriggerSignal command, implements all aktions and command logic.
/// </summary>
private void SerialPortTriggerSignal()
{
SignalTriggerView st = new SignalTriggerView();
st.ShowDialog();
}
/// <summary>
/// Can execute path of SensorDemo command.
/// </summary>
/// <param name="parameter">Not neccessary parameter, can be useful in deverse implementatins</param>
/// <returns>true if command can execute or false if not.</returns>
public bool CanSensorDemo(object parameter = null)
{
return false;
}
/// <summary>
/// Execute path of SensorDemo command, implements all aktions and command logic.
/// </summary>
private void SensorDemo()
{
}
/// <summary>
/// Can execute path of SendReport command.
/// </summary>
/// <param name="parameter">Not neccessary parameter, can be useful in deverse implementatins</param>
/// <returns>true if command can execute or false if not.</returns>
public bool CanSendReport(object parameter = null)
{
return false;
}
/// <summary>
/// Execute path of SendReport command, implements all aktions and command logic.
/// </summary>
private void SendReport()
{
}
/// <summary>
/// Can execute path of About command.
/// </summary>
/// <param name="parameter">Not neccessary parameter, can be useful in deverse implementatins</param>
/// <returns>true if command can execute or false if not.</returns>
public bool CanAbout(object parameter = null)
{
return true;
}
/// <summary>
/// Execute path of About command, implements all aktions and command logic.
/// </summary>
private void About()
{
About window = new About();
window.Show();
}
/// <summary>
/// Can execute path of OneStepCalibration command.
/// </summary>
/// <param name="parameter">Not neccessary parameter, can be useful in deverse implementatins</param>
/// <returns>true if command can execute or false if not.</returns>
public bool CanOneStepCalibration(object parameter = null)
{
return true;
}
/// <summary>
/// Execute path of OneStepCalibration command, implements all aktions and command logic.
/// </summary>
private void OneStepCalibration()
{
BDevelopmentMode = !BDevelopmentMode;
if(VDetailsButton == Visibility.Collapsed)
{
//ToDo: For Tests
Window nw = new FormShowProtocolContainer(10, 10, 10, AKS16_AKS17_API.FormShowProtocol.EProtocol.BiSS);
nw.ShowDialog();
VDetailsButton = Visibility.Visible;
}
else
{
//ToDo: For Tests
Window nw = new FormOffsetCompensationContainer();
nw.ShowDialog();
VDetailsButton = Visibility.Collapsed;
}
}
#endregion
}
} |