-
Notifications
You must be signed in to change notification settings - Fork 2
/
MainForm.vb
2675 lines (2381 loc) · 136 KB
/
MainForm.vb
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
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
' some important sources for techniques saverageused here:
'https://eshkay.wordpress.com/2013/03/25/vb-net-serial-port-communication-with-datareceived-event/
'https://msdn.microsoft.com/en-us/library/ms171728.aspxvelocityse
Imports System.Text
Imports System.Windows.Forms.DataVisualization.Charting
Imports System.Text.RegularExpressions
Imports System.IO.Ports
Imports System.ComponentModel
Imports System.Threading
Public Class MainForm
' Dim file As System.IO.StreamWriter
Dim captureFile As System.IO.StreamWriter ' this is the log file to capture data
Dim captureFileName As String = "" ' this is the name of the log file to capture data
Dim currentcapturefile As String = "logfile1.txt"
Public positionSeries As New Series
Public velocitySeries As New Series
Public angleseries As New Series
Public fftSeries As New Series
Public fftSeries2 As New Series
Public chartcounter As UInt64
Dim FFTdone As Boolean = True
' Creates and initializes a new Queue.
Public displacementQueuex As New Queue()
Public displacementQueuey As New Queue()
Dim velocityQueuex As New Queue()
Dim velocityQueuey As New Queue()
Dim angleQueuex As New Queue()
Dim angleQueuey As New Queue()
'defining the menu items for the main menu bar
Dim menuItems As New List(Of MenuItem)
Dim myMenuItemfinish As New MenuItem("&Finish")
Dim myMenuItemLogFile As New MenuItem("&Open Log File")
Dim myMenuItemConfiguration As New MenuItem("&Interferometer Configuration")
Dim myMenuItemCompensation As New MenuItem("&Environmental Compensation")
Dim myMenuItemTestMode As New MenuItem("&Test Mode")
Dim myMenuItemUSBPort As New MenuItem("&COM Port")
Dim myMenuItemHelp As New MenuItem("&Help")
Dim myMenuItemInformation As New MenuItem("&Information")
Dim myMenuItemAbout As New MenuItem("&About")
Dim myMenuItemNew As New MenuItem("&New")
Dim myMenuItemUSBSubMenuCOMPorts As New MenuItem("&DummyText")
'defining the main menu bar
Dim mnuBar As New MainMenu()
' buffer for serial port object
Dim spDrLine As String = ""
Dim spBuffer As String = ""
Public zeroAdjustment As Double = 0 ' this is what we need to set the data back to zero
Public zeroAdjustment1 As Double = 0
Public zeroAdjustment2 As Double = 0
Public zeroAdjustment3 As Double = 0
Public unitCorrectionFactor As Double = 1.0 ' 1.0 = nm 0.001 = um etc
Public unitCorrectmm As Double = 1.0 ' 1.0 = mm 0.001 = um etc
Public angleCorrectionFactor As Double = 3600.0 ' 3600 = arcsec 60 = arcmin 1 = degree
Public angleCorrectdegree As Double = 1
Public Angle_Reflector_Spacing As Double = 32.61
Public multiplier As Double = 2 ' needed for interferometer type 1x 2x 4x
Public multipliercoefficient As Double = 2 ' needed for interferometer type 1x 2x 4x
Public straightnessMultiplier As Double = 1 ' needed for straightness measurements
Public SLCoefficient As Double = 360
Public SSCoefficient As Double = 36
Public currentValue As Double = 0
Public currentValue1 As Double = 0
Public currentValue2 As Double = 0
Public currentValue3 As Double = 0
Public previousValue As Double = 0
Public previousValue1 As Double = 0
Public previousValue2 As Double = 0
Public previousValue3 As Double = 0
Dim velocityValue As Double = 0
Dim velocityValue1 As Double = 0
Dim velocityValue2 As Double = 0
Dim velocityValue3 As Double = 0
Dim angleValue As Double = 0
Dim angleValue1 As Double = 0
Dim angleValue2 As Double = 0
Dim angleValue3 As Double = 0
Dim averagingValue As Double = 0
Public displayValue As Double = 0
Public displayValue1 As Double = 0
Public displayValue2 As Double = 0
Public displayValue3 As Double = 0
Dim velocityValueList As New List(Of Double)
Dim DFTValueList As New List(Of Double)
Dim angleValueList As New List(Of Double)
Dim averagingFromPrevious As Double = 0
Dim velocityFromPrevious As Double = 0
Dim angleFromPrevious As Double = 0
Public average As Double = 0
Public average1 As Double = 0
Public average2 As Double = 0
Public average3 As Double = 0
Public PreviousAverage As Double = 0
Public velocity As Double = 0
Public velocity1 As Double = 0
Public velocity2 As Double = 0
Public velocity3 As Double = 0
Public angle As Double = 0
Public angle1 As Double = 0
Public angle2 As Double = 0
Public angle3 As Double = 0
Public TestmodeFlag As Integer = 0
Public Dimension As Integer = 1024 ' this value determines both the size of the plot graphs and the number of data points in the DFT
Dim RealPartOfDFT(CInt(Dimension / 2)) As Double
Dim averagingFromCurrent As Double = 0
Dim velocityFromCurrent As Double = 0
Dim angleFromCurrent As Double = 0
Dim ImaginaryPartOfDFT(CInt(Dimension / 2)) As Double
Dim DFTMax As Double = 0
Public needsInitialZero As Integer = 0
Dim outerLoopCounter, innerLoopCounter As Integer
Public DifferenceValue As Double = 0
Dim CurrentREFCount As Int64 = 0
Dim PreviousREFCount As Int64 = 0
Dim CurrentMEASCount As Int64 = 0
Dim PreviousMEASCount As Int64 = 0
Public ErrorFlag As Integer = 0
Public SuspendFlag As Integer = 0
Dim MeasCountCorrection As UInt64 = 0
Public CurrentValueCorrection As Double = 0
Public CurrentValueCorrection1 As Double = 0
Public CurrentValueCorrection2 As Double = 0
Public CurrentValueCorrection3 As Double = 0
Dim SuspenREFCount As UInt64 = 0
Dim SuspendMEASCount As UInt64 = 0
Dim graphCount As UInt64 = CULng(Dimension)
Dim plotCount As UInt64 = CULng(Dimension)
Public SuspendCurrentValue As Double = 0
Public SuspendCurrentValue1 As Double = 0
Public SuspendCurrentValue2 As Double = 0
Public SuspendCurrentValue3 As Double = 0
Public REFFrequency As Double = 0
Public MEASFrequency As Double = 0
Public DIFFFrequency As Double = 0
Dim previousREFFrequency As Double = 0
Dim previousMEASFrequency As Double = 0
Dim currentREFFrequency As Double = 0
Dim currentMEASFrequency As Double = 0
Dim previousDIFFFrequency As Double = 0
Dim currentDIFFFrequency As Double = 0
Public previousserialnumber As UInt64 = 0
Dim serialnumberdifference As UInt64 = 0
Public Wavelength As Double = 632.991372 ' Corrected wavelength
Public previousSimulationDistance As Int64 = 0
Public waveform As Double = 0
Public previoussimulationVelocity As Int64 = 0
Public previoussimREFCount As Int64 = 0
Public previoussimMEASCount As Int64 = 0
Public simrefcount As Int64 = 0
Public simmeascount As Int64 = 0
Public simulationDistance As Int64 = 0
Public simulationVelocity As Int64 = 0
Public simulationPhase As Int64 = 0
Public simMEASFrequencyCount1 As Int64 = 0
Public simulationDistance1 As Int64 = 0
Public simulationVelocity1 As Int64 = 0
Public simulationPhase1 As Int64 = 0
Public simMEASFrequencyCount2 As Int64 = 0
Public simulationDistance2 As Int64 = 0
Public simulationVelocity2 As Int64 = 0
Public simulationPhase2 As Int64 = 0
Public simMEASFrequencyCount3 As Int64 = 0
Public simulationDistance3 As Int64 = 0
Public simulationVelocity3 As Int64 = 0
Public simulationPhase3 As Int64 = 0
Public simulationSerial As UInt64 = 0
Public simulationLowSpeedCode As Int16 = 0
Public simulationLowSpeedData As Int32 = 0
Public bangbang As Double = 1
Public counter As Double = 0
Dim simulatedData As String
Public simcount As Double = 0
Public TMUnitsFactor As Double = 0
Public TMFreqMult As Double = 1
Public TMAmpMult As Double = 1
Public TMOfsMult As Double = 1
Public TMFreqValue As Double = 1
Public TMAmpValue As Double = 1
Public TMOfsValue As Double = 1
Public EDEnabled As Integer = 1
'Dim DFTThread As New Thread(AddressOf DFT)
Private DFTThread As New System.ComponentModel.BackgroundWorker 'set new backgroundworker
Dim resetEvent As ManualResetEvent = New ManualResetEvent(False)
Public IgnoreCount As Integer = 0
Public phase As Double = 0
Dim incomingData As String
Dim Capture_Flag As Integer = 0
Dim Capture_Enable As Integer = 0
Dim range As Double = 0
Dim ScrollRate As Integer = 1
Public MFLoaded As Integer = 0
Dim TMWaveform As Integer = 0
Dim TMREFFrequency As Double = 1
Dim temp1 As Integer = 0
Public TMWaveformFlag As Integer = 4
Dim DFT_Skip_Factor As Integer = 1
Dim zero As Double = 0
Dim ClearCounter As Integer = 0
Dim CurrentValuePhase As Double = 0
Dim CurrentValuePhase1 As Double = 0
Dim CurrentValuePhase2 As Double = 0
Dim CurrentValuePhase3 As Double = 0
Dim PreviousCurrentValuePhase As Double = 0
Dim PhaseValue As Integer = 0
Dim PhaseValue1 As Integer = 0
Dim PhaseValue2 As Integer = 0
Dim PhaseValue3 As Integer = 0
Dim Diagnostic2Value As Integer = 0
Dim Diagnostic3Value As Integer = 0
Dim Diagnostic4Value As Integer = 0
Dim Diagnostic4Count As Integer = 0
Dim Diagnostic4Save As Integer = 0
Dim Diagnostic5Value As Integer = 0
Dim DP32COMCounts As Integer = 0
Dim DP32PRCCounts As Integer = 0
Dim LowSpeedCode As Integer = 0
Dim LowSpeedData As Integer = 0
Dim TemperatureAutoValue As Integer = -1
Dim PressureAutoValue As Integer = -1
Dim HumidityAutoValue As Integer = -1
Dim AxisData(4, 5) As Int64 ' First index selects Axis Primary,1,2,3; second parameter selects REFFreqCount,MEASFreqCount, Displacement, Velocity, Phase.
Public PrimaryAxisSelect As Integer = 1
Public PrimaryAxisFlip As Integer = 1 ' 1 -> no flip, -1 -> flip
Public Axis1Flip As Integer = 1
Public Axis2Flip As Integer = 1
Public Axis3Flip As Integer = 1
Public MultipleAxesFlag As Integer = 1 ' Bits 0,1,2 = Axis 1,2,3, bit 4 is multiaxis enable
Public AxesPolarityFlag As Integer = 0 ' Bits 0,1,2 = Axis 1,2,3, flip sign
Public TMMultipleAxesFlag As Integer = 1
Dim FirmwareVersion As Integer = 0
Dim FirmwareVersionSet As Integer = 0
' Dim uMDVersion As String = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() ' + ", " +
Dim SampleFrequency As Double = 610.35
Dim SamplePeriod As Double = 1638.4
Dim SimulationSamples As Integer = 15
Dim buildRevision As String
Dim parts As String()
Dim build As Integer = 0
Dim revision As Integer = 0
Dim dateTimeOfBuild As String
Private Sub MainForm_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
'SerialPort1.Close() ' this hangs the program. known MS bug https://social.msdn.microsoft.com/Forums/en-US/ce8ce1a3-64ed-4f26-b9ad-e2ff1d3be0a5/serial-port-hangs-whilst-closing?forum=Vsexpressvcs
'End
'file.Close()
If Not (captureFile Is Nothing) Then
captureFile.Close()
End If
My.Settings.AveragingValue = TrackBar1.Value
My.Settings.ScrollFactor = CInt(NumericUpDown_Scale.Value)
My.Settings.TMUnitsFactor = TMUnitsFactor
My.Settings.DFT_Skip_Factor = DFT_Skip_Factor
My.Settings.LogFile = currentcapturefile
If (Configuration.Interpolation_CheckBox.Checked = True) Then
My.Settings.InterpolationFlag = 1
Else
My.Settings.InterpolationFlag = 0
End If
If (TestMode.Diagnostic_Enable_CheckBox.Checked = True) Then
My.Settings.DiagnosticReadoutFlag = 1
Else
My.Settings.DiagnosticReadoutFlag = 0
End If
If (TestMode.Error_Detection_CheckBox.Checked = True) Then
My.Settings.ErrorDetectionFlag = 1
Else
My.Settings.ErrorDetectionFlag = 0
End If
My.Settings.Temperature = Compensation.NumericUpDown_Temperature.Value
My.Settings.Pressure = Compensation.NumericUpDown_Pressure.Value
My.Settings.Humidity = Compensation.NumericUpDown_Humidity.Value
My.Settings.TempFactor = Compensation.TextBox_TempFactor.Text
My.Settings.PresFactor = Compensation.TextBox_PresFactor.Text
My.Settings.HumiFactor = Compensation.TextBox_HumiFactor.Text
My.Settings.TFactor = Compensation.TCorrection
My.Settings.PFactor = Compensation.PCorrection
My.Settings.HFactor = Compensation.HCorrection
If (Compensation.Temperature_Auto_CheckBox.Checked = True) Then
My.Settings.TemperatureCompAutoFlag = 1
Else
My.Settings.TemperatureCompAutoFlag = 0
End If
If (Compensation.Pressure_Auto_CheckBox.Checked = True) Then
My.Settings.PressureCompAutoFlag = 1
Else
My.Settings.PressureCompAutoFlag = 0
End If
If (Compensation.Humidity_Auto_Checkbox.Checked = True) Then
My.Settings.HumidityCompAutoFlag = 1
Else
My.Settings.HumidityCompAutoFlag = 0
End If
My.Settings.Save()
End Sub
Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles Me.Load
buildRevision = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()
parts = buildRevision.Split("."c)
build = Integer.Parse(parts(2))
revision = Integer.Parse(parts(3))
dateTimeOfBuild = (New DateTime(2000, 1, 1) + New TimeSpan(build, 0, 0, 0) + TimeSpan.FromSeconds(revision * 2)).ToString()
About.uMD_Version.Text = buildRevision + ", " + dateTimeOfBuild
AddHandler DFTThread.DoWork, AddressOf DFT
DisplacementButton_Click(sender, e)
Chart1.Series.Clear()
Chart1.ChartAreas(0).AxisX.LabelStyle.Enabled = False
Chart1.ChartAreas(0).AxisX.MajorTickMark.Enabled = False
Chart1.ChartAreas(0).AxisY.MajorTickMark.Enabled = False
Chart1.ChartAreas(0).AxisX.MinorTickMark.Enabled = False
Chart1.ChartAreas(0).AxisY.MinorTickMark.Enabled = False
Chart1.ChartAreas(0).AxisY.LabelStyle.Format = "e2" 'https://msdn.microsoft.com/en-us/library/dwhawy9k.aspx
Chart1.ChartAreas(0).AxisY.LabelAutoFitStyle = LabelAutoFitStyles.None
Chart1.ChartAreas(0).AxisX.LabelStyle.Font = New System.Drawing.Font("Trebuchet MS", 2.25F, System.Drawing.FontStyle.Bold)
positionSeries.ChartType = SeriesChartType.FastLine
For chartcounter = 0 To CULng(Dimension - 1)
positionSeries.Points.AddXY(chartcounter, 0.5 * Math.Sin(chartcounter / 40))
Next
Chart1.Series.Add(positionSeries)
velocitySeries.ChartType = SeriesChartType.FastLine
For chartcounter = 0 To CULng(Dimension - 1)
velocitySeries.Points.AddXY(chartcounter, 0.5 * Math.Cos(chartcounter / 40))
velocityValueList.Add(0.0) ' make sure the list is not empty
DFTValueList.Add(0.0) ' make sure the list is not empty
Next
angleseries.ChartType = SeriesChartType.FastLine
For chartcounter = 0 To CULng(Dimension - 1)
angleseries.Points.AddXY(chartcounter, 0.25 * Math.Asin(Math.Sin(chartcounter / 40)))
angleValueList.Add(0.0) ' make sure the list is not empty
Next
DFTThread.RunWorkerAsync()
fftSeries.ChartType = SeriesChartType.FastLine
' Menu Stuff
' first lets create an empty submenu for the com port list under the USB top menu
menuItems.Add(myMenuItemUSBSubMenuCOMPorts) ' need an empty list to be able to delete/change them at runtime
' Next, attach that list to the USB top menu
myMenuItemUSBPort.MenuItems.Add(myMenuItemUSBSubMenuCOMPorts)
' Next attach all the top menus to the menu bar.
mnuBar.MenuItems.Add(myMenuItemfinish)
mnuBar.MenuItems.Add(myMenuItemLogFile)
mnuBar.MenuItems.Add(myMenuItemConfiguration)
mnuBar.MenuItems.Add(myMenuItemCompensation)
mnuBar.MenuItems.Add(myMenuItemTestMode)
' mnuBar.MenuItems.Add(myMenuItemHelp)
mnuBar.MenuItems.Add(myMenuItemHelp)
mnuBar.MenuItems.Add(myMenuItemUSBPort)
' mnuBar.MenuItems.Add(myMenuItemOptions)
' AddHandler myMenuItemConfiguration.Click, AddressOf Me.myMenuItemhelp_Click
' myMenuItemHelp.MenuItems.Add(myMenuItemConfiguration)
myMenuItemHelp.MenuItems.Add(myMenuItemInformation)
AddHandler myMenuItemInformation.Click, AddressOf Me.myMenuIteminformation_Click
myMenuItemHelp.MenuItems.Add(myMenuItemAbout)
AddHandler myMenuItemAbout.Click, AddressOf Me.myMenuItemabout_Click
' Next replace the application with the menu bar we just crafted
Me.Menu = mnuBar
' Finally, add the handlers to the menu items so that they can respond to clicks
AddHandler myMenuItemfinish.Click, AddressOf Me.myMenuItemfinish_Click
AddHandler myMenuItemLogFile.Click, AddressOf Me.myMenuItemLogFile_Click
AddHandler myMenuItemConfiguration.Click, AddressOf Me.myMenuItemConfiguration_Click
AddHandler myMenuItemCompensation.Click, AddressOf Me.myMenuItemCompensation_Click
AddHandler myMenuItemTestMode.Click, AddressOf Me.myMenuItemTestMode_Click
AddHandler myMenuItemUSBPort.Popup, AddressOf Me.myMenuItemUSBPort_Click
' AddHandler myMenuItemHelp.Popup, AddressOf Me.myMenuItemhelp_Click
' load user settings
multiplier = My.Settings.Multiplier
If multiplier = 1 Then
Configuration.Button1x.BackgroundImage = uMDGUI.My.Resources.Resources.ActiveButton6
Configuration.Button1x.ForeColor = Color.FromKnownColor(KnownColor.ActiveCaptionText)
Configuration.Button2x.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Button2x.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Button4x.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Button4x.ForeColor = Color.FromKnownColor(KnownColor.Black)
ElseIf multiplier = 2 Then
Configuration.Button1x.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Button1x.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Button2x.BackgroundImage = uMDGUI.My.Resources.Resources.ActiveButton6
Configuration.Button2x.ForeColor = Color.FromKnownColor(KnownColor.ActiveCaptionText)
Configuration.Button4x.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Button4x.ForeColor = Color.FromKnownColor(KnownColor.Black)
ElseIf multiplier = 4 Then
Configuration.Button1x.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Button1x.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Button2x.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Button2x.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Button4x.BackgroundImage = uMDGUI.My.Resources.Resources.ActiveButton6
Configuration.Button4x.ForeColor = Color.FromKnownColor(KnownColor.ActiveCaptionText)
End If
multipliercoefficient = multiplier
unitCorrectionFactor = My.Settings.UnitCorrectionFactor
If unitCorrectionFactor = 0.000001 Then
Configuration.Buttonnm.BackgroundImage = uMDGUI.My.Resources.Resources.ActiveButton6
Configuration.Buttonnm.ForeColor = Color.FromKnownColor(KnownColor.ActiveCaptionText)
Configuration.Buttonum.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonum.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttonmm.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonmm.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttoncm.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttoncm.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttonm.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonm.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttonin.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonin.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttonft.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonft.ForeColor = Color.FromKnownColor(KnownColor.Black)
UnitLabel.Text = "nm"
ElseIf unitCorrectionFactor = 0.001 Then
Configuration.Buttonnm.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonnm.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttonum.BackgroundImage = uMDGUI.My.Resources.Resources.ActiveButton6
Configuration.Buttonum.ForeColor = Color.FromKnownColor(KnownColor.ActiveCaptionText)
Configuration.Buttonmm.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonmm.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttoncm.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttoncm.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttonm.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonm.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttonin.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonin.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttonft.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonft.ForeColor = Color.FromKnownColor(KnownColor.Black)
UnitLabel.Text = "μm"
ElseIf unitCorrectionFactor = 1 Then
Configuration.Buttonnm.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonnm.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttonum.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonum.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttonmm.BackgroundImage = uMDGUI.My.Resources.Resources.ActiveButton6
Configuration.Buttonmm.ForeColor = Color.FromKnownColor(KnownColor.ActiveCaptionText)
Configuration.Buttoncm.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttoncm.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttonm.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonm.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttonin.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonin.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttonft.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonft.ForeColor = Color.FromKnownColor(KnownColor.Black)
UnitLabel.Text = "mm"
ElseIf unitCorrectionFactor = 10 Then
Configuration.Buttonnm.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonnm.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttonum.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonum.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttonmm.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonmm.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttoncm.BackgroundImage = uMDGUI.My.Resources.Resources.ActiveButton6
Configuration.Buttoncm.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttonm.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonm.ForeColor = Color.FromKnownColor(KnownColor.ActiveCaptionText)
Configuration.Buttonin.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonin.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttonft.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonft.ForeColor = Color.FromKnownColor(KnownColor.Black)
UnitLabel.Text = "cm"
ElseIf unitCorrectionFactor = 1000 Then
Configuration.Buttonnm.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonnm.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttonum.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonum.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttonmm.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonmm.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttoncm.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttoncm.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttonm.BackgroundImage = uMDGUI.My.Resources.Resources.ActiveButton6
Configuration.Buttonm.ForeColor = Color.FromKnownColor(KnownColor.ActiveCaptionText)
Configuration.Buttonin.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonin.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttonft.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonft.ForeColor = Color.FromKnownColor(KnownColor.Black)
UnitLabel.Text = "m"
ElseIf unitCorrectionFactor = 25.4 Then
Configuration.Buttonnm.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonnm.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttonum.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonum.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttonmm.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonmm.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttoncm.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttoncm.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttonm.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonm.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttonin.BackgroundImage = uMDGUI.My.Resources.Resources.ActiveButton6
Configuration.Buttonin.ForeColor = Color.FromKnownColor(KnownColor.ActiveCaptionText)
Configuration.Buttonft.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonft.ForeColor = Color.FromKnownColor(KnownColor.Black)
UnitLabel.Text = "in"
ElseIf unitCorrectionFactor = 304.8 Then
Configuration.Buttonnm.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonnm.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttonum.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonum.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttonmm.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonmm.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttoncm.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttoncm.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttonm.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonm.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttonin.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonin.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttonft.BackgroundImage = uMDGUI.My.Resources.Resources.ActiveButton6
Configuration.Buttonft.ForeColor = Color.FromKnownColor(KnownColor.ActiveCaptionText)
UnitLabel.Text = "ft"
End If
Axis1_Units_Label.Text = UnitLabel.Text
Axis2_Units_Label.Text = UnitLabel.Text
Axis3_Units_Label.Text = UnitLabel.Text
angleCorrectionFactor = My.Settings.AngleCorrectionFactor
If angleCorrectionFactor = 3600.0 Then
Configuration.Buttonarcsec.BackgroundImage = uMDGUI.My.Resources.Resources.ActiveButton6
Configuration.Buttonarcsec.ForeColor = Color.FromKnownColor(KnownColor.ActiveCaptionText)
Configuration.Buttonarcmin.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonarcmin.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttondegree.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttondegree.ForeColor = Color.FromKnownColor(KnownColor.Black)
AngleLabel.Text = "arcsec"
ElseIf angleCorrectionFactor = 60.0 Then
Configuration.Buttonarcsec.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonarcsec.ForeColor = Color.FromKnownColor(KnownColor.ActiveCaptionText)
Configuration.Buttonarcmin.BackgroundImage = uMDGUI.My.Resources.Resources.ActiveButton6
Configuration.Buttonarcmin.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttondegree.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttondegree.ForeColor = Color.FromKnownColor(KnownColor.Black)
AngleLabel.Text = "arcmin"
ElseIf angleCorrectionFactor = 1.0 Then
Configuration.Buttonarcsec.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonarcsec.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttonarcmin.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Configuration.Buttonarcmin.ForeColor = Color.FromKnownColor(KnownColor.Black)
Configuration.Buttondegree.BackgroundImage = uMDGUI.My.Resources.Resources.ActiveButton6
Configuration.Buttondegree.ForeColor = Color.FromKnownColor(KnownColor.ActiveCaptionText)
AngleLabel.Text = "degree"
End If
Axis1_Angle_Label.Text = AngleLabel.Text
Axis2_Angle_Label.Text = AngleLabel.Text
Axis3_Angle_Label.Text = AngleLabel.Text
Axis_UnitsA.Text = AngleLabel.Text
Axis_UnitsD.Text = UnitLabel.Text
RangeUnits.Text = UnitLabel.Text
Label_RangeTime.Visible = False
RangeUnits.Visible = False
Axis1Flip = My.Settings.Axis1Flip
If (Axis1Flip = 1) Then
Configuration.Axis1_Polarity_CheckBox.Checked = False
Else
Configuration.Axis1_Polarity_CheckBox.Checked = True
End If
PrimaryAxisFlip = Axis1Flip
Axis2Flip = My.Settings.Axis2Flip
If (Axis2Flip = 1) Then
Configuration.Axis2_Polarity_CheckBox.Checked = False
Else
Configuration.Axis2_Polarity_CheckBox.Checked = True
End If
Axis3Flip = My.Settings.Axis3Flip
If (Axis3Flip = 1) Then
Configuration.Axis3_Polarity_CheckBox.Checked = False
Else
Configuration.Axis3_Polarity_CheckBox.Checked = True
End If
Configuration.NumericUpDown_SL_Coefficient.Value = CDec(My.Settings.SLCoefficient)
Configuration.NumericUpDown_SS_Coefficient.Value = CDec(My.Settings.SSCoefficient)
Configuration.NumericUpDown_ARS.Value = CDec(My.Settings.Angle_Reflector_Spacing)
Compensation.ComboBox_TempUnits.Text = My.Settings.TempUnits
Compensation.NumericUpDown_Temperature.Minimum = 32
Compensation.NumericUpDown_Temperature.Maximum = 158
If Compensation.ComboBox_TempUnits.Text = "Degrees C" Then
Compensation.NumericUpDown_Temperature.Minimum = 0
Compensation.NumericUpDown_Temperature.Maximum = 70
ElseIf Compensation.ComboBox_TempUnits.Text = "Degrees K" Then
Compensation.NumericUpDown_Temperature.Minimum = 273
Compensation.NumericUpDown_Temperature.Maximum = 343
End If
Compensation.NumericUpDown_Temperature.Value = CDec(My.Settings.Temperature)
Compensation.ComboBox_Pressure_Units.Text = My.Settings.PressureUnits
Compensation.NumericUpDown_Pressure.Minimum = 500
Compensation.NumericUpDown_Pressure.Maximum = 2000
If Compensation.ComboBox_Pressure_Units.Text = "mm/Hg" Then
Compensation.NumericUpDown_Pressure.Minimum = 380
Compensation.NumericUpDown_Pressure.Maximum = 1520
End If
Compensation.NumericUpDown_Pressure.Value = CDec(My.Settings.Pressure)
Compensation.NumericUpDown_Humidity.Value = CDec(My.Settings.Humidity)
Compensation.TextBox_TempFactor.Text = My.Settings.TempFactor
Compensation.TextBox_PresFactor.Text = My.Settings.PresFactor
Compensation.TextBox_HumiFactor.Text = My.Settings.HumiFactor
Compensation.TCorrection = My.Settings.TFactor
Compensation.PCorrection = My.Settings.PFactor
Compensation.HCorrection = My.Settings.HFactor
Compensation.ECFactor = My.Settings.ECFactor
If Compensation.ECFactor = 1 Then
Compensation.ECOff_Button.BackgroundImage = uMDGUI.My.Resources.Resources.ActiveButton6
Compensation.ECOff_Button.ForeColor = Color.FromKnownColor(KnownColor.ActiveCaptionText)
Compensation.ECOn_Button.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Compensation.ECOn_Button.ForeColor = Color.FromKnownColor(KnownColor.Black)
Else
Compensation.ECOff_Button.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
Compensation.ECOff_Button.ForeColor = Color.FromKnownColor(KnownColor.Black)
Compensation.ECOn_Button.BackgroundImage = uMDGUI.My.Resources.Resources.ActiveButton6
Compensation.ECOn_Button.ForeColor = Color.FromKnownColor(KnownColor.ActiveCaptionText)
End If
Compensation.NumericUpDown_Wavelength.Value = CDec(My.Settings.VacuumWavelength)
Wavelength = Compensation.ECFactor * CDbl(My.Settings.VacuumWavelength)
WLText.Text = Wavelength.ToString("000.000000")
If My.Settings.TemperatureCompAutoFlag = 1 Then
Compensation.Temperature_Auto_CheckBox.Checked = True
Else
Compensation.Temperature_Auto_CheckBox.Checked = False
End If
If My.Settings.PressureCompAutoFlag = 1 Then
Compensation.Pressure_Auto_CheckBox.Checked = True
Else
Compensation.Pressure_Auto_CheckBox.Checked = False
End If
If My.Settings.HumidityCompAutoFlag = 1 Then
Compensation.Humidity_Auto_Checkbox.Checked = True
Else
Compensation.Humidity_Auto_Checkbox.Checked = False
End If
TMWaveformFlag = My.Settings.TMWaveformFlag
TestMode.Button_Constant.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
TestMode.Button_Constant.ForeColor = Color.FromKnownColor(KnownColor.Black)
TestMode.Button_Ramp.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
TestMode.Button_Ramp.ForeColor = Color.FromKnownColor(KnownColor.Black)
TestMode.Button_Triangle.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
TestMode.Button_Triangle.ForeColor = Color.FromKnownColor(KnownColor.Black)
TestMode.Button_Sine.BackgroundImage = uMDGUI.My.Resources.Resources.InActiveButton4
TestMode.Button_Sine.ForeColor = Color.FromKnownColor(KnownColor.Black)
If TMWaveformFlag = 1 Then
TestMode.Button_Constant.BackgroundImage = uMDGUI.My.Resources.Resources.ActiveButton6
TestMode.Button_Constant.ForeColor = Color.FromKnownColor(KnownColor.ActiveCaptionText)
ElseIf TMWaveformFlag = 2 Then
TestMode.Button_Ramp.BackgroundImage = uMDGUI.My.Resources.Resources.ActiveButton6
TestMode.Button_Ramp.ForeColor = Color.FromKnownColor(KnownColor.ActiveCaptionText)
ElseIf TMWaveformFlag = 4 Then
TestMode.Button_Triangle.BackgroundImage = uMDGUI.My.Resources.Resources.ActiveButton6
TestMode.Button_Triangle.ForeColor = Color.FromKnownColor(KnownColor.ActiveCaptionText)
ElseIf TMWaveformFlag = 8 Then
TestMode.Button_Sine.BackgroundImage = uMDGUI.My.Resources.Resources.ActiveButton6
TestMode.Button_Sine.ForeColor = Color.FromKnownColor(KnownColor.ActiveCaptionText)
End If
TMUnitsFactor = My.Settings.TMUnitsFactor
If TMUnitsFactor = 0.001 Then
TestMode.ComboBox_Units.Text = "μm"
ElseIf TMUnitsFactor = 1 Then
TestMode.ComboBox_Units.Text = "mm"
ElseIf TMUnitsFactor = 10 Then
TestMode.ComboBox_Units.Text = "cm"
ElseIf TMUnitsFactor = 1000 Then
TestMode.ComboBox_Units.Text = "m"
ElseIf TMUnitsFactor = 25.4 Then
TestMode.ComboBox_Units.Text = "in"
ElseIf TMUnitsFactor = 304.8 Then
TestMode.ComboBox_Units.Text = "ft"
End If
TMFreqValue = TestMode.Trackbar_Frequency.Value * 10 * TMFreqMult
TestMode.Textbox_Frequency.Text = (TMFreqValue / 10).ToString("0.000")
TMAmpValue = TestMode.TrackBar_Amplitude.Value * TMAmpMult / 2
TestMode.TextBox_Amplitude.Text = (TMAmpValue / 50).ToString("0.0000")
TMOfsValue = TestMode.TrackBar_Offset.Value * TMOfsMult
TestMode.TextBox_Offset.Text = (TMOfsValue / 10).ToString("0.00")
TestMode.NumericUpDown_FGREF_Value.Value = CDec(My.Settings.TMREFFrequency)
TMREFFrequency = CDec(My.Settings.TMREFFrequency)
TrackBar1.Value = CInt(My.Settings.AveragingValue)
averagingValue = 1000 * (1 - (1 / (Math.Pow(10, CDbl(TrackBar1.Value / 333)))))
AverageLabel.Text = (averagingValue / 1000).ToString("F3")
If ((TrackBar1.Value >= 0) And (TrackBar1.Value < 100)) Then
Averaging_Label.ForeColor = Color.FromKnownColor(KnownColor.ActiveCaptionText)
AverageLabel.ForeColor = Color.FromKnownColor(KnownColor.ActiveCaptionText)
ElseIf ((TrackBar1.Value >= 100) And (TrackBar1.Value < 300)) Then
Averaging_Label.ForeColor = Color.FromKnownColor(KnownColor.Brown)
AverageLabel.ForeColor = Color.FromKnownColor(KnownColor.Brown)
ElseIf ((TrackBar1.Value >= 300) And (TrackBar1.Value < 500)) Then
Averaging_Label.ForeColor = Color.FromKnownColor(KnownColor.DarkRed)
AverageLabel.ForeColor = Color.FromKnownColor(KnownColor.DarkRed)
ElseIf ((TrackBar1.Value >= 500) And (TrackBar1.Value < 600)) Then
Averaging_Label.ForeColor = Color.FromKnownColor(KnownColor.DarkOrange)
AverageLabel.ForeColor = Color.FromKnownColor(KnownColor.DarkOrange)
ElseIf ((TrackBar1.Value >= 600) And (TrackBar1.Value < 700)) Then
Averaging_Label.ForeColor = Color.FromKnownColor(KnownColor.DarkGoldenrod)
AverageLabel.ForeColor = Color.FromKnownColor(KnownColor.DarkGoldenrod)
ElseIf ((TrackBar1.Value >= 700) And (TrackBar1.Value < 800)) Then
Averaging_Label.ForeColor = Color.FromKnownColor(KnownColor.DarkGreen)
AverageLabel.ForeColor = Color.FromKnownColor(KnownColor.DarkGreen)
ElseIf ((TrackBar1.Value >= 800) And (TrackBar1.Value < 900)) Then
Averaging_Label.ForeColor = Color.FromKnownColor(KnownColor.DarkBlue)
AverageLabel.ForeColor = Color.FromKnownColor(KnownColor.DarkBlue)
Else : Averaging_Label.ForeColor = Color.FromKnownColor(KnownColor.DarkViolet)
AverageLabel.ForeColor = Color.FromKnownColor(KnownColor.DarkViolet)
End If
Timer1.Start()
' file = My.Computer.FileSystem.OpenTextFileWriter("data.txt", True)
' Initialize graph
TestModeLabel.Visible = False
EDOff_Label.Visible = False
straightnessMultiplier = 1
NumericUpDown_Scale.Value = My.Settings.ScrollFactor
ScrollRate = CInt(NumericUpDown_Scale.Value)
DFT_Skip_Factor = My.Settings.DFT_Skip_Factor
If DFT_Skip_Factor = 30 Then
Frequency_Axis.Text = " 0.3 1 2 3 4 5 6 7 8 9 10"
ComboBox_DFT_Range.Text = "10"
ElseIf DFT_Skip_Factor = 10 Then
Frequency_Axis.Text = " 1 3 6 9 12 15 18 21 24 27 30"
DFT_Skip_Factor = 10
ComboBox_DFT_Range.Text = "30"
ElseIf DFT_Skip_Factor = 3 Then
Frequency_Axis.Text = "1 3 6 10 20 30 40 50 60 70 80 90 100"
ComboBox_DFT_Range.Text = "100"
ElseIf DFT_Skip_Factor = 1 Then
Frequency_Axis.Text = " 10 30 60 90 120 150 180 210 240 270 300"
ComboBox_DFT_Range.Text = "300"
End If
Graph_Averaging_CheckBox.Visible = True
If My.Settings.InterpolationFlag = 1 Then
Configuration.Interpolation_CheckBox.Checked = True
Else
Configuration.Interpolation_CheckBox.Checked = False
End If
If My.Settings.DiagnosticReadoutFlag = 1 Then
TestMode.Diagnostic_Enable_CheckBox.Checked = True
Else
TestMode.Diagnostic_Enable_CheckBox.Checked = False
End If
If My.Settings.ErrorDetectionFlag = 1 Then
TestMode.Error_Detection_CheckBox.Checked = True
Else
TestMode.Error_Detection_CheckBox.Checked = False
End If
currentcapturefile = My.Settings.LogFile
Logfile_Text.Visible = False
Logfile_Label.Visible = False
DFT_Hz.Visible = False
Phase_Value.Visible = False
Phase_Label.Visible = False
PBA_RM_Value.Visible = False
PORTB_Label.Visible = False
RMA_RM_Value.Visible = False
REFMEAS_Label.Visible = False
Phase_Error_Value.Visible = False
Phase_Error_Label.Visible = False
Sample_Frequency_Value.Visible = False
Sample_Frequency_Label.Visible = False
DP32_PRC_Percent_Value.Visible = False
DP32_PRC_Percent_Label.Visible = False
DP32_COM_Percent_Label.Visible = False
MFLoaded = 1
End Sub
Private Sub Comport_Click(sender As Object, e As EventArgs)
' extract COM port name
Dim comportstrting As String = sender.ToString
Dim a() As String = Regex.Split(comportstrting, "Text: ")
'MsgBox(a(1))
' open COM port
If SerialPort1.IsOpen = False Then
Try
SerialPort1.Close()
Catch ex As Exception
' nothing
End Try
SerialPort1.PortName = a(1)
SerialPort1.BaudRate = 115200
SerialPort1.Parity = Parity.None
SerialPort1.StopBits = StopBits.One
SerialPort1.DataBits = 8
SerialPort1.Handshake = Handshake.None
SerialPort1.NewLine = vbCr
SerialPort1.DtrEnable = True 'important
SerialPort1.RtsEnable = True 'important
Try
SerialPort1.Open()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
If TestmodeFlag = 0 Then
needsInitialZero = 1 ' make sure to zero out the reference system
End If
End If
End Sub
Private Sub DataReceivedHandler(sender As Object, e As SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
Try
If SerialPort1.IsOpen Then
'Dim incomingData As String
incomingData = SerialPort1.ReadExisting()
If Not (captureFile Is Nothing) And Capture_Flag = 1 And IgnoreCount = 0 And TestmodeFlag = 0 And TMWaveformFlag = 1 Then
captureFile.Write(incomingData) ' Back door to capture all incoming data: Test Mode off but set to Constant
End If
spDrLine = spDrLine & incomingData ' important
If InStr(1, spDrLine, vbLf) > 0 Then
spBuffer = spDrLine.Substring(0, spDrLine.LastIndexOf(vbLf)) ' pull in the buffer up to the last line feed
spDrLine = spDrLine.Substring(spDrLine.LastIndexOf(vbLf) + 1) ' stuff the rest back into the incoming buffer
Try
If False = SimulationTimer.Enabled Then
Me.SetText(spBuffer)
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Else
Exit Sub
End If
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub SetText(ByVal [text] As String)
' InvokeRequired required compares the thread ID of the
' calling thread to the thread ID of the creating thread.
' If these threads are different, it returns true.
Dim k As Integer
If Me.Chart1.InvokeRequired Then 'what is good for chart1 is also good for chart2
Dim d As New SetTextCallback(AddressOf SetText)
Me.Invoke(d, New Object() {[text]})
Else
Try
' first split data into sets
Dim sets() As String = [text].Split(vbLf.ToCharArray)
For k = 0 To sets.Length - 1
' any line beginning with a '!' is debug info.
If sets(k).StartsWith("!") Then
Console.Write(sets(k) + vbCrLf)
End If
Dim values() As String = sets(k).Split(" ".ToCharArray)
'make sure the current set has exactly 8 fields or 16 fields
If values.Length.Equals(8) Or values.Length.Equals(16) Then
AxisData(1, 0) = Convert.ToInt64(values(0)) ' REFFreqCount (same for all 3 axes)
AxisData(1, 1) = Convert.ToInt64(values(1)) ' MEAS1FreqCount
AxisData(1, 2) = Convert.ToInt64(values(2)) ' TotalDistance1
AxisData(1, 3) = Convert.ToInt64(values(3)) ' Velocity1Count
AxisData(1, 4) = Convert.ToInt32(values(4)) ' Phase1Value
If values.Length.Equals(16) Then
AxisData(2, 1) = Convert.ToInt64(values(8)) ' MEAS2FreqCount
If AxisData(2, 1) > 0 Then ' Test for MEAS2FreqCounts
MultipleAxesFlag = MultipleAxesFlag Or &HA ' Set Mutiple-Axis Mode with axis 2 enabled
End If
AxisData(3, 1) = Convert.ToInt64(values(12)) ' MEAS3FreqCount
If AxisData(3, 1) > 0 Then ' Test for MEAS3FreqCounts
MultipleAxesFlag = MultipleAxesFlag Or &HC ' Set Mutiple-Axis Mode with axis 3 enabled
End If
If MultipleAxesFlag > 1 Then
AxisData(2, 0) = Convert.ToInt64(values(0)) ' REFFreqCount (same for all 3 axes)
AxisData(2, 2) = Convert.ToInt64(values(9)) ' TotalDistance2
AxisData(2, 3) = Convert.ToInt64(values(10)) ' Velocity2Count
AxisData(2, 4) = Convert.ToInt32(values(11)) ' Phase2Value
AxisData(3, 0) = Convert.ToInt64(values(0)) ' REFFreqCount (same for all 3 axes)
AxisData(3, 2) = Convert.ToInt64(values(13)) ' TotalDistance3
AxisData(3, 3) = Convert.ToInt64(values(14)) ' Velocity3Count
AxisData(3, 4) = Convert.ToInt32(values(15)) ' Phase3Value
currentValue1 = (Convert.ToDouble(AxisData(1, 2)) - CurrentValuePhase1) * Wavelength / 2.0 - CurrentValueCorrection1 ' Difference in nm; 1/2 wavelength, because path traveled at least twice
currentValue2 = (Convert.ToDouble(AxisData(2, 2)) - CurrentValuePhase2) * Wavelength / 2.0 - CurrentValueCorrection2 ' Difference in nm; 1/2 wavelength, because path traveled at least twice
currentValue3 = (Convert.ToDouble(AxisData(3, 2)) - CurrentValuePhase3) * Wavelength / 2.0 - CurrentValueCorrection3 ' Difference in nm; 1/2 wavelength, because path traveled at least twice
velocityValue1 = (currentValue1 - previousValue1) * SampleFrequency
velocityValue2 = (currentValue2 - previousValue2) * SampleFrequency
velocityValue3 = (currentValue3 - previousValue3) * SampleFrequency
previousValue1 = currentValue1
previousValue2 = currentValue2
previousValue3 = currentValue3
angleValue1 = Math.Asin((currentValue1 - zeroAdjustment1) / Configuration.NumericUpDown_ARS.Value / 1000000) * angleCorrectionFactor * 57.296
angleValue2 = Math.Asin((currentValue2 - zeroAdjustment2) / Configuration.NumericUpDown_ARS.Value / 1000000) * angleCorrectionFactor * 57.296
angleValue3 = Math.Asin((currentValue3 - zeroAdjustment3) / Configuration.NumericUpDown_ARS.Value / 1000000) * angleCorrectionFactor * 57.296
If Configuration.Interpolation_CheckBox.Checked = True Then
' PhaseValue = Convert.ToInt32(values(4))
PhaseValue1 = CInt(AxisData(1, 4))
PhaseValue2 = CInt(AxisData(2, 4))
PhaseValue3 = CInt(AxisData(3, 4))
If (PhaseValue1 And &H7E00) = 0 Then
CurrentValuePhase1 = (CDbl(PhaseValue1)) / 256
ElseIf (PhaseValue1 < 0) Then ' REF and MEAS both valid
CurrentValuePhase1 = (CDbl(PhaseValue1)) / 256
Else
Diagnostic4Count = 10
Diagnostic4Save = PhaseValue1
CurrentValuePhase1 = 0
End If
If (PhaseValue2 And &H7E00) = 0 Then
CurrentValuePhase2 = (CDbl(PhaseValue2)) / 256
ElseIf (PhaseValue2 < 0) Then ' REF and MEAS both valid
CurrentValuePhase2 = (CDbl(PhaseValue2)) / 256
Else
Diagnostic4Count = 10
Diagnostic4Save = PhaseValue2
CurrentValuePhase2 = 0
End If
If (PhaseValue3 And &H7E00) = 0 Then
CurrentValuePhase3 = (CDbl(PhaseValue3)) / 256
ElseIf (PhaseValue3 < 0) Then ' REF and MEAS both valid
CurrentValuePhase3 = (CDbl(PhaseValue3)) / 256
Else
Diagnostic4Count = 10
Diagnostic4Save = PhaseValue1
CurrentValuePhase3 = 0
End If
Else
CurrentValuePhase1 = 0
CurrentValuePhase2 = 0
CurrentValuePhase3 = 0
End If
End If
End If
AxisData(0, 0) = AxisData(PrimaryAxisSelect, 0) ' REFFreqCount (same for all 3 axes)
AxisData(0, 1) = AxisData(PrimaryAxisSelect, 1) ' Primary MEASFreqCount
AxisData(0, 2) = AxisData(PrimaryAxisSelect, 2) ' Primary TotalDistance
AxisData(0, 3) = AxisData(PrimaryAxisSelect, 3) ' Primary VelocityCount
AxisData(0, 4) = AxisData(PrimaryAxisSelect, 4) ' Primary PhaseValue
If Not (captureFile Is Nothing) And Capture_Flag = 1 And IgnoreCount = 0 Then
If TestmodeFlag = 1 Then ' Capture all in Test Mode
captureFile.Write("R:" + values(0) + " M:" + values(1) + " D:" + values(2) + " V:" + values(3) + " P:" + values(4) + " N:" + values(5) + "T" + vbCrLf)
ElseIf TestmodeFlag = 0 And Not TMWaveformFlag = 1 Then ' Capture only Displacement and SN if normal mode
captureFile.Write("D:" + values(2) + " N:" + values(5) + vbCrLf)
End If
End If
LowSpeedCode = Convert.ToInt32(values(6)) ' Low Speed Code
LowSpeedData = Convert.ToInt32(values(7)) ' Low Speed Data