-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.cs
1304 lines (1226 loc) · 60.2 KB
/
Form1.cs
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
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;
namespace PlotDVT
{
//This class is too big.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
//Initialize the list of wanted columns
wantedcolumns = new List<Column>();
//values for the last measured result
XmlManager<DataCol> columnloader = new XmlManager<DataCol>();
datacolumns = columnloader.Load("Content/XMLFile1.xml");
realpowerdict = new Dictionary<string, Column>();
//columnobjectlist = new List<Baselist>();
colobjinterflistbl = new List<IBaselist>();//!
colobjinterflist = new List<IBaselist>();//!
//diff variable here baseline values and loaders
XmlManager<DataCol> columnloaderbl = new XmlManager<DataCol>();
datacolumnsbl = columnloaderbl.Load("Content/XMLFile1.xml");
realpowerdictbl = new Dictionary<string, Column>();
wantedcolumnsbl = new List<Column>();
phasebuttonarray = new Button[] { button6, button7, button8, button9, button10, button11, button12 };
phasebuttonlist = new List<Button>(phasebuttonarray);
phasemarkerstyles = new MarkerStyle[] { MarkerStyle.Circle, MarkerStyle.Cross, MarkerStyle.Diamond,
MarkerStyle.Square, MarkerStyle.Triangle, MarkerStyle.Star4, MarkerStyle.Star10 };
phasemarkerlist = new List<MarkerStyle>(phasemarkerstyles);
//some files to play with should remove/make another plan later
filenamedata = "C:/values/2015y09m24d_13h35m42s_SN121538001575_S230_60_LN_LoL_HiL_119.csv";//some test files
populatedatatestunit(filenamedata);
//****************************************populate the diff data******************************************************
filenamebl = "C:/values/2015y09m24d_13h35m42s_SN121538001575_S230_60_LN_LoL_HiL_119.csv";//some test files
populatedatabaseline(filenamebl);
//************************************************
//test for some answers
Richtextedit();
setupploatarea();
//plotIdc();
this.textBox1.Text = "0°";
}
/// <summary>
/// Setup some default values for the plotting area
/// </summary>
private void setupploatarea()
{
// textBox2.Text = "20";//delay synchronous plotting
numericUpDown6.Value = 1.0M;
numericUpDown5.Value = 1.0M;
numericUpDown4.Value = 1.0M;
numericUpDown3.Value = 1.0M;
textBox9.Text = "220";//Sac
textBox10.Text = "56.0";//minimum Sac to ignore
textBox13.Text = "350";//Maximum Sac
textBox5.Text = "15";//Minimum Vmp to ignore
textBox6.Text = "55";//Max vmp to ignore
numericUpDown2.Value = 2.0M; ;//Fulscale Wdc
//Xrid lines
chart1.ChartAreas[0].AxisX.MajorGrid.LineDashStyle = ChartDashStyle.Solid;
chart1.ChartAreas[0].AxisX.MinorGrid.Enabled = true;
chart1.ChartAreas[0].AxisX.MinorGrid.LineDashStyle = ChartDashStyle.Dot;
//Added below to get axes scaling to int and not float values in axes labelstyle
chart1.ChartAreas[0].AxisX.LabelStyle.Format = "{0:0}";
//Xrid lines
chart2.ChartAreas[0].AxisX.MajorGrid.LineDashStyle = ChartDashStyle.Solid;
chart2.ChartAreas[0].AxisX.MinorGrid.Enabled = true;
chart2.ChartAreas[0].AxisX.MinorGrid.LineDashStyle = ChartDashStyle.Dot;
//Ygrid lines
chart1.ChartAreas[0].AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Solid;
chart1.ChartAreas[0].AxisY.MinorGrid.Enabled = true;
chart1.ChartAreas[0].AxisY.MinorGrid.LineDashStyle = ChartDashStyle.Dot;
//YGrid lines
chart2.ChartAreas[0].AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Solid;
chart2.ChartAreas[0].AxisY.MinorGrid.Enabled = true;
chart2.ChartAreas[0].AxisY.MinorGrid.LineDashStyle = ChartDashStyle.Dot;
}
/// <summary>
/// populating data for the baseline file values
/// </summary>
/// <param name="filename"></param>
private void populatedatabaseline(string filename)
{
//clear the values id needed
if(wantedcolumnsbl.Count > 0)
wantedcolumnsbl.Clear();
if(realpowerdictbl.Count > 0)
realpowerdictbl.Clear();
if (colobjinterflistbl.Count > 0)
colobjinterflistbl.Clear();
if (!(File.Exists(filename)))
{
MessageBox.Show("The baseline file: !exist");
return;
}
//datacolumnsbl comes from xml so do not clear it
foreach (Column c in datacolumnsbl.namealiaslist)
{
//Clear the values in the columns
c.clearvalues();
wantedcolumnsbl.Add(c);
}
// Read sample data from CSV file
using (CsvFileReader reader = new CsvFileReader(filename))
{
CsvRow row = new CsvRow();
rowcount = 0;
while (reader.ReadRow(row))
{
if (rowcount == 0)
{
foreach (string s in row)
{
//the first row is the header
foreach (Column c in wantedcolumnsbl)
//if the name is in the wanted columns save position
if (c.columnname == s)
c.columnnumber = row.IndexOf(s);
}
}
else
{
foreach (Column c in wantedcolumnsbl)
{
c.colvalues.Add(row[c.columnnumber]);
}
}
rowcount++;
}
Richtextedit("Baseline rows imported: " + Convert.ToString(rowcount));
}
foreach (Column c in wantedcolumnsbl)
{
realpowerdictbl.Add(c.alias, c);
}
foreach (var VAR in realpowerdictbl)
{
/// <summary>
/// Below the instance is created and!!! the parameter is passes to it. I like it.
/// VAR.Value.Columnvalues is the value
/// </summary>
//columnobjectlistbl.Add((Baselist)Activator.CreateInstance(Type.GetType("PlotDVT." + VAR.Key), VAR.Value.Columnvalues));
if (VAR.Key == "Vdcconfigured")
{
///if it is Vdcconfigured, add it as VdcConfigured, some extra functionaly in Vdcconfigure
colobjinterflistbl.Add((IBaselist)Activator.CreateInstance
(Type.GetType("PlotDVT.VdcconfiguredI"), VAR.Value.Columnvalues, VAR.Key));
}
else if (VAR.Key == "Phaseconfigured")
{
///if it is Phaseconfigured add it as PhaseCongfigured, some extra functionaly in PhaseCongfigured
colobjinterflistbl.Add((IBaselist)Activator.CreateInstance
(Type.GetType("PlotDVT.PhaseconfiguredI"), VAR.Value.Columnvalues, VAR.Key));
}
else
{
//Add the rest just as ValuelistI
colobjinterflistbl.Add((IBaselist)Activator.CreateInstance(Type.GetType("PlotDVT.ValuelistI"), VAR.Value.Columnvalues, VAR.Key));
}
}
foreach (IBaselist Ibl in colobjinterflistbl)
{
if (Ibl.GetName() == "Phaseconfigured")
{
//Find Vdcconfigure to get slice parameters
foreach (IBaselist Ibltwo in colobjinterflistbl)
{
if (Ibltwo.GetName() == "Vdcconfigured")//if it is vdc configured
{
(Ibltwo as VdcconfiguredI).Setphaseslice((Ibl as PhaseconfiguredI).Listslices);//set first set
(Ibltwo as VdcconfiguredI).Setphaseslice((Ibl as PhaseconfiguredI).Listslices2);//set second set
}
}
break;
}
}
///<summary>
///Below loop creates the slices of the column in the CSV set up by Vdcconfigured.
///New with interface implementation
///</summary>
try
{
//Find Vdcconfigure to get slice parameters
foreach (IBaselist Ibltwo in colobjinterflistbl)
{
if (Ibltwo.GetName() == "Vdcconfigured")
{
// (Ibltwo as VdcconfiguredI)
foreach (IBaselist Ibl in colobjinterflistbl)
{
if (!(Ibl.GetName() == "Vdcconfigured"))//if it is not Vdcconfigured
{
Ibl.Populareslices((Ibltwo as VdcconfiguredI).Slicelist);
}
}
}
}
}
catch (InvalidCastException)
{
}
}
//************************************Done populating data for baseline*********************
//************************************Start populating UUT instances with data*************
/// <summary>
/// Populate data for the unit under test
/// </summary>
/// <param name="filename"></param>
private void populatedatatestunit(string filename)
{
//clear the old values
if (wantedcolumns.Count > 0)
wantedcolumns.Clear();
if (realpowerdict.Count > 0)
realpowerdict.Clear();
if (colobjinterflist.Count > 0)
colobjinterflist.Clear();
if (!(File.Exists(filename)))
{
MessageBox.Show("The data file: !exist");
return;
}
//datacolumnsbl come from xml so do not clear it
foreach (Column c in datacolumns.namealiaslist)
{
//Clear the values in the columns
c.clearvalues();
wantedcolumns.Add(c);
}
// Read data from CSV file
using (CsvFileReader reader = new CsvFileReader(filename))
{
CsvRow row = new CsvRow();
rowcount = 0;
while (reader.ReadRow(row))
{
//if the row count is 0, then headers
if (rowcount == 0)
{
foreach (string s in row)
{
//the first row is the header
foreach (Column c in wantedcolumns)
//if the name is in the wanted columns save position
if (c.columnname == s)
c.columnnumber = row.IndexOf(s);
}
}
else
{
foreach (Column c in wantedcolumns)
{
c.colvalues.Add(row[c.columnnumber]);
}
}
rowcount++;
}
Richtextedit("Datarows imported: " + Convert.ToString(rowcount));
}
foreach (Column c in wantedcolumns)
{
realpowerdict.Add(c.alias, c);
}
//Uses the CSVrowManager to load all the wanted data as they exist in rows
CSVrowManager = new CSVrowManager();
CSVrowManager.Load(wantedcolumns);
//columnobjectlist = new List<Baselist>();
foreach (var VAR in realpowerdict)
{
/// <summary>
/// Below the instance is created and!!! the parameter is passes to it. I like it.
/// VAR.Value.Columnvalues is the value
/// </summary>
//columnobjectlist.Add((Baselist)Activator.CreateInstance(Type.GetType("PlotDVT." + VAR.Key), VAR.Value.Columnvalues));
if(VAR.Key == "Vdcconfigured")
{
colobjinterflist.Add((IBaselist)Activator.CreateInstance
(Type.GetType("PlotDVT.VdcconfiguredI"), VAR.Value.Columnvalues, VAR.Key));
}
else if (VAR.Key == "Phaseconfigured")
{
colobjinterflist.Add((IBaselist)Activator.CreateInstance
(Type.GetType("PlotDVT.PhaseconfiguredI"), VAR.Value.Columnvalues, VAR.Key));
}
else
{
colobjinterflist.Add((IBaselist)Activator.CreateInstance(Type.GetType("PlotDVT.ValuelistI"), VAR.Value.Columnvalues, VAR.Key));
}
}
foreach (IBaselist Ibl in colobjinterflist)
{
if (Ibl.GetName() == "Phaseconfigured")
{
//Find Vdcconfigure to get slice parameters
foreach (IBaselist Ibltwo in colobjinterflist)
{
if (Ibltwo.GetName() == "Vdcconfigured")
{
(Ibltwo as VdcconfiguredI).Setphaseslice((Ibl as PhaseconfiguredI).Listslices);
(Ibltwo as VdcconfiguredI).Setphaseslice((Ibl as PhaseconfiguredI).Listslices2);
}
}
break;
}
}
///<summary>
///Below loop creates the slices of the column set up by Vdcconfigured.
///New with interface implementation
///</summary>
//slices = Ibl.GetSlices();
try
{
//Find Vdcconfigure to get slice parameters
foreach (IBaselist Ibltwo in colobjinterflist)
{
if (Ibltwo.GetName() == "Vdcconfigured")
{
// (Ibltwo as VdcconfiguredI)
foreach(IBaselist Ibl in colobjinterflist)
{
if (!(Ibl.GetName() == "Vdcconfigured"))
{
Ibl.Populareslices((Ibltwo as VdcconfiguredI).Slicelist);
}
}
}
}
}
catch (InvalidCastException)
{
}
}
//**************************************Done UUT data populatin****************************
private void chartdefaults()
{
chart1.ChartAreas[0].BackColor = Color.White;
chart1.Series.Clear();
chart1.Titles.Clear();
chart1.ChartAreas[0].AxisX.Minimum = Double.NaN;
chart1.ChartAreas[0].AxisY.Minimum = Double.NaN;
chart1.ChartAreas[0].AxisX.Maximum = Double.NaN;
chart1.ChartAreas[0].AxisY.Maximum = Double.NaN;
chart1.ChartAreas[0].AxisX.Title = "";
chart1.ChartAreas[0].AxisY.Title = "";
//chart1.ChartAreas.Clear();
chart2.ChartAreas[0].AxisX.Title = "";
chart2.ChartAreas[0].AxisY.Title = "";
chart2.ChartAreas[0].BackColor = Color.White;
chart2.Series.Clear();
chart2.Titles.Clear();
chart2.ChartAreas[0].AxisX.Minimum = Double.NaN;
chart2.ChartAreas[0].AxisY.Minimum = Double.NaN;
chart2.ChartAreas[0].AxisX.Maximum = Double.NaN;
chart2.ChartAreas[0].AxisY.Maximum = Double.NaN;
//chart2.ChartAreas.Clear();
}
//**********************************Done populating data for unit undertest*********************
private void plotIdc()//Changing this plot to deal with interface data
{
///<comments>
///Reset the chart default values twith this call
///</comments>
chartdefaults();
Title title = new Title("Reported Idc UUT vs. baseline. Ph angle: " + textBox1.Text,
Docking.Top, new Font("Verdana", 8, FontStyle.Regular), Color.Black);
chart2.Titles.Add(title);
title.IsDockedInsideChartArea = false;
title.DockedToChartArea = chart2.ChartAreas[0].Name;
Dictionary<float,List<float>> valuestoplot = new Dictionary<float,List<float>>();
foreach(IBaselist Ibl in colobjinterflist)
{
if (Ibl.GetName() == "Idcconfigured")
{
valuestoplot = Ibl.GetSlices();
break;
}
}
foreach (var kv in valuestoplot)
{
//Name the series
string chartseries = (Convert.ToString(kv.Key));
if (chartseries.Length > 4)
chartseries = chartseries.Substring(0, 4);
chartseries += "CNF";
//Add a series
chart1.Series.Add(chartseries);
chart1.Series[chartseries].IsVisibleInLegend = false;
//set the chart type
chart1.Series[chartseries].ChartType = SeriesChartType.Point;
chart1.Series[chartseries].Color = Color.CadetBlue;
chart1.Series[chartseries].MarkerStyle = MarkerStyle.Star6;
chart1.Series[chartseries].MarkerSize = 13;
//this.chart1.Series[chartseries].BorderWidth = 8;
foreach (var v in kv.Value)
{
chart1.Series[chartseries].Points.AddXY(kv.Key, v);
}
}
IBaselist ibl = colobjinterflist.First(item => item.GetName() == "Idcpowermeter");
//plot the power meter on chart1
valuestoplot = ibl.GetSlices();
foreach (var kv in valuestoplot)
{
//Name the series
string chartseries = (Convert.ToString(kv.Key));
if (chartseries.Length > 4)
chartseries = chartseries.Substring(0, 4);
chartseries += "UUT1";
//Add a series
this.chart1.Series.Add(chartseries);
//set the chart type
this.chart1.Series[chartseries].ChartType = SeriesChartType.Point;
this.chart1.Series[chartseries].MarkerStyle = MarkerStyle.Circle;
this.chart1.Series[chartseries].MarkerSize = 7;
this.chart1.Series[chartseries].Color = Color.Black;
foreach (var v in kv.Value)
{
if (v < 0.1f)
{
this.chart1.Series[chartseries].Color = Color.Red;
}
this.chart1.Series[chartseries].Points.AddXY(kv.Key, v);
}
}
// plot the DIFF V pcu on chart 2
//plot the pcu on chart 1
ibl = colobjinterflistbl.First(item => item.GetName() == "Idcpcu");
//plot the power meter on chart1
valuestoplot = ibl.GetSlices();
foreach (var kv in valuestoplot)
{
//Name the series
string chartseries = (Convert.ToString(kv.Key));
if (chartseries.Length > 4)
chartseries = chartseries.Substring(0, 4);
chartseries += "BL";
//Add a series
this.chart2.Series.Add(chartseries);
this.chart2.Series[chartseries].ChartType = SeriesChartType.Point;
//this.chart1.Series[chartseries].Palette = ChartColorPalette.Bright;
this.chart2.Series[chartseries].MarkerStyle = MarkerStyle.Circle;
this.chart2.Series[chartseries].MarkerSize = 7;
this.chart2.Series[chartseries].Color = Color.Black;
foreach (var v in kv.Value)
{
if (v < 0.1f)
{
this.chart2.Series[chartseries].Color = Color.Red;
}
this.chart2.Series[chartseries].Points.AddXY(kv.Key, v);
}
}
//plot the pcu current on chart 1
ibl = colobjinterflist.First(item => item.GetName() == "Idcpcu");
//plot the power meter on chart1
valuestoplot = ibl.GetSlices();
foreach (var kv in valuestoplot)
{
//Name the series
string chartseries = (Convert.ToString(kv.Key));
if (chartseries.Length > 4)
chartseries = chartseries.Substring(0, 4);
chartseries += "UUT";
//Add a series
chart1.Series.Add(chartseries);
//set the chart type
chart1.Series[chartseries].ChartType = SeriesChartType.Point;
chart1.Series[chartseries].MarkerStyle = MarkerStyle.Cross;
chart1.Series[chartseries].MarkerSize = 7;
chart1.Series[chartseries].Color = Color.DarkOrange;
// plot the pcu on chart 2
//Add a series
chart2.Series.Add(chartseries);
//set the chart type
chart2.Series[chartseries].ChartType = SeriesChartType.Point;
chart2.Series[chartseries].MarkerStyle = MarkerStyle.Cross;
chart2.Series[chartseries].MarkerSize = 7;
chart2.Series[chartseries].Color = Color.DarkOrange;
//Scale the x axis
foreach (var v in kv.Value)
{
if (v < 0.1f)
{
chart2.Series[chartseries].Color = Color.Red;
}
chart1.Series[chartseries].Points.AddXY(kv.Key, v);
chart2.Series[chartseries].Points.AddXY(kv.Key, v);
}
}
}
/// <summary>
/// Diff plotting starts
/// </summary>
private void ploteff()//Button1_Efficiency
{
chartdefaults();
Title title = new Title("Efficiency powermeter. The sum of the difference. ",
Docking.Top, new Font("Verdana", 8, FontStyle.Regular), Color.Black);
chart2.Titles.Add(title);
title.IsDockedInsideChartArea = false;
title.DockedToChartArea = chart2.ChartAreas[0].Name;
chart2.ChartAreas[0].AxisX.Title = "Vdc configured";
chart2.ChartAreas[0].AxisY.Title = "Sum of difference in Eff %.";
List<float> values = new List<float>();
/// plot the DIFF V powermeter on chart 2
///get the columns to print for the baseline unit
int i = 0;//set the marker style position to 1
int j = 1;
foreach (Button btn in phasebuttonlist)
{
//set the phase angle here, click the phase button
btn.PerformClick();
IBaselist ibl2 = colobjinterflistbl.First(item => item.GetName() == "Efficiency");
IBaselist ibl = colobjinterflist.First(item => item.GetName() == "Efficiency");
foreach (var kv in ibl.GetSlices())
{
//Name the series
string chartseries = (Convert.ToString(kv.Key));
if (chartseries.Length > 4)
chartseries += chartseries.Substring(0, 4);
chartseries += textBox1.Text;//This will be the phase angle
//Add a series
//Circle, Cross, Diamond, Square, Triangle, Star4, Star10
chart2.Series.Add(chartseries);
chart2.Series[chartseries].ChartType = SeriesChartType.Point;
//chart2.Series[chartseries].MarkerStyle = MarkerStyle.Circle;
chart2.Series[chartseries].MarkerSize = 10;
chart2.Series[chartseries].IsVisibleInLegend = false;
chart2.Series[chartseries].Color = Color.DarkOrange;
if (j != i)//only make the marker visible if it is the first iteratiion
chart2.Series[chartseries].IsVisibleInLegend = true;
j = i;
chart2.Series[chartseries].LegendText = textBox1.Text;//Legend text
chart2.Series[chartseries].MarkerStyle = phasemarkerlist[i];
if (ibl2.GetSlices().ContainsKey(kv.Key))
values = ibl2.GetSlices()[kv.Key];
if (values.Count <= kv.Value.Count)
{
float accumefficiency = 0.0f;
for (int k = 0; k < values.Count; k++)
{
float accuracy = kv.Value[k] - values[k];//Powermeter efficiencies subtrackted
float accuracy2 = (float)(Math.Round((double)accuracy, 2));
accumefficiency += accuracy2;//add all the defferences together
//chart2.Series[chartseries].Points.AddXY(kv.Key, accuracy2);
}
//if there is a bigger that 15 accumelated difference then red cross
if (accumefficiency > 15 || accumefficiency < -15)
{
accumefficiency = 0;
chart2.Series[chartseries].Color = Color.Red;
chart2.Series[chartseries].MarkerSize = 12;
}
chart2.Series[chartseries].Points.AddXY(kv.Key, accumefficiency);
}
}
i = i + 1;//move the marker list on 1
}
chart2.ChartAreas[0].BackColor = Color.White;
}
private void dcpowerdiff()
{
chartdefaults();
IBaselist ibl = colobjinterflistbl.First(item => item.GetName() == "Wdcpowermeter");
foreach (var kv in ibl.GetSlices())
{
//Name the series
string chartseries = (Convert.ToString(kv.Key));
if (chartseries.Length > 4)
chartseries = chartseries.Substring(0, 4);
chartseries += "BL";
//Add a series
chart2.Series.Add(chartseries);
chart2.Series[chartseries].ChartType = SeriesChartType.Point;
//this.chart1.Series[chartseries].Palette = ChartColorPalette.Bright;
chart2.Series[chartseries].MarkerStyle = MarkerStyle.Circle;
chart2.Series[chartseries].MarkerSize = 9;
chart2.Series[chartseries].Color = Color.Black;
foreach (var v in kv.Value)
{
chart2.Series[chartseries].Points.AddXY(kv.Key, v);
}
}
ibl = colobjinterflist.First(item => item.GetName() == "Wdcpowermeter");
foreach (var kv in ibl.GetSlices())
{
//Name the series
string chartseries = (Convert.ToString(kv.Key));
if (chartseries.Length > 4)
chartseries = chartseries.Substring(0, 4);
chartseries += "UUT";
//Add a series
this.chart2.Series.Add(chartseries);
this.chart2.Series[chartseries].ChartType = SeriesChartType.Point;
//this.chart1.Series[chartseries].Palette = ChartColorPalette.Bright;
this.chart2.Series[chartseries].MarkerStyle = MarkerStyle.Cross;
this.chart2.Series[chartseries].MarkerSize = 9;
this.chart2.Series[chartseries].Color = Color.DarkOrange;
foreach (var v in kv.Value)
{
this.chart2.Series[chartseries].Points.AddXY(kv.Key, v);
}
}
}
private void acpowerdiff()
{
chartdefaults();
IBaselist ibl = colobjinterflistbl.First(item => item.GetName() == "Wacpowermeter");
foreach (var kv in ibl.GetSlices())
{
//Name the series
string chartseries = (Convert.ToString(kv.Key));
if (chartseries.Length > 4)
chartseries = chartseries.Substring(0, 4);
chartseries += "BL";
//Add a series
this.chart2.Series.Add(chartseries);
this.chart2.Series[chartseries].ChartType = SeriesChartType.Point;
this.chart2.Series[chartseries].MarkerStyle = MarkerStyle.Circle;
this.chart2.Series[chartseries].MarkerSize = 9;
this.chart2.Series[chartseries].Color = Color.Black;
// this.chart2.ChartAreas[0].AxisX.Minimum = 13;
// this.chart2.ChartAreas[0].AxisY.Minimum = 0;
foreach (var v in kv.Value)
{
this.chart2.Series[chartseries].Points.AddXY(kv.Key, v);
}
}
ibl = colobjinterflist.First(item => item.GetName() == "Wacpowermeter");
foreach (var kv in ibl.GetSlices())
{
//Name the series
string chartseries = (Convert.ToString(kv.Key));
if (chartseries.Length > 4)
chartseries = chartseries.Substring(0, 4);
chartseries += "UUT";
//Add a series
this.chart2.Series.Add(chartseries);
this.chart2.Series[chartseries].ChartType = SeriesChartType.Point;
this.chart2.Series[chartseries].MarkerStyle = MarkerStyle.Cross;
this.chart2.Series[chartseries].MarkerSize = 9;
this.chart2.Series[chartseries].Color = Color.DarkOrange;
foreach (var v in kv.Value)
{
this.chart2.Series[chartseries].Points.AddXY(kv.Key, v);
}
}
}
//***************************************Diff plotting ends**********************************
//***************************************DC vOLT plot start here*****************************
/// <summary>
/// Plot the dc voltage power meter value on chart area
/// </summary>
private void PlotVdccompare()
{
chartdefaults();
Title title = new Title("Vdc compare: Vdc configured, powermeter and PCU",
Docking.Top, new Font("Verdana", 8, FontStyle.Regular), Color.Black);
chart1.Titles.Add(title);
title.IsDockedInsideChartArea = false;
title.DockedToChartArea = this.chart1.ChartAreas[0].Name;
Title title2 = new Title("Vdc reported: Test pm vs Baseline pm",
Docking.Top, new Font("Verdana", 8, FontStyle.Regular), Color.Black);
this.chart2.Titles.Add(title2);
title.DockedToChartArea = this.chart2.ChartAreas[0].Name;
//plot diagonal grey conf line
string series = "_conf";
//Add a series
chart1.Series.Add(series);
//set the chart type
chart1.Series[series].ChartType = SeriesChartType.Point;
chart1.Series[series].MarkerStyle = MarkerStyle.Star6;
chart1.Series[series].MarkerSize = 10;
chart1.Series[series].Color = Color.CadetBlue;
IBaselist ibl = colobjinterflist.First(item => item.GetName() == "Vdcpcu");
foreach (var kv in ibl.GetSlices())
{
//Name the series
chart1.Series[series].Points.AddXY(kv.Key, kv.Key);
}
series = "conf2";
//Add a series
chart1.Series.Add(series);
//set the chart type
chart1.Series[series].ChartType = SeriesChartType.Line;
chart1.Series[series].BorderWidth = 1;
chart1.Series[series].Color = Color.CadetBlue;
foreach (var kv in ibl.GetSlices())
{
//Name the series
chart1.Series[series].Points.AddXY(kv.Key, kv.Key);
}
// plot the DIFF V powermeter on chart 2
ibl = colobjinterflistbl.First(item => item.GetName() == "Vdcpowermeter");
foreach (var kv in ibl.GetSlices())
{
//Name the series
string chartseries = (Convert.ToString(kv.Key));
if (chartseries.Length > 4)
chartseries = chartseries.Substring(0, 4);
chartseries += "_basel_pm";
//Add a series
chart2.Series.Add(chartseries);
chart2.Series[chartseries].ChartType = SeriesChartType.Point;
//this.chart1.Series[chartseries].Palette = ChartColorPalette.Bright;
chart2.Series[chartseries].MarkerStyle = MarkerStyle.Circle;
chart2.Series[chartseries].MarkerSize = 9;
chart2.Series[chartseries].Color = Color.Black;
foreach (var v in kv.Value)
{
chart2.Series[chartseries].Points.AddXY(kv.Key, v);
}
}
//plot the power meter on chart1 and chart 2
ibl = colobjinterflist.First(item => item.GetName() == "Vdcpowermeter");
foreach (var kv in ibl.GetSlices())
{
//Name the series
string chartseries = (Convert.ToString(kv.Key));
if (chartseries.Length > 4)
chartseries = chartseries.Substring(0, 4);
chartseries += "_pm";
//Add a series
chart1.Series.Add(chartseries);
//set the chart type
chart1.Series[chartseries].ChartType = SeriesChartType.Point;
chart1.Series[chartseries].MarkerStyle = MarkerStyle.Circle;
chart1.Series[chartseries].MarkerSize = 7;
chart1.Series[chartseries].Color = Color.Black;
// plot the pcu on chart 2
//Add a series
chart2.Series.Add(chartseries);
//set the chart type
chart2.Series[chartseries].ChartType = SeriesChartType.Point;
chart2.Series[chartseries].MarkerStyle = MarkerStyle.Cross;
chart2.Series[chartseries].MarkerSize = 7;
chart2.Series[chartseries].Color = Color.DarkOrange;
//Scale the x axis
foreach (var v in kv.Value)
{
chart1.Series[chartseries].Points.AddXY(kv.Key, v);
chart2.Series[chartseries].Points.AddXY(kv.Key, v);
}
}
//plot the pcu on chart 1 and 2
ibl = colobjinterflist.First(item => item.GetName() == "Vdcpcu");
foreach (var kv in ibl.GetSlices())
{
//Name the series
string chartseries = (Convert.ToString(kv.Key));
if (chartseries.Length > 4)
chartseries = chartseries.Substring(0, 4);
chartseries += "_pcu";
//Add a series
chart1.Series.Add(chartseries);
//set the chart type
chart1.Series[chartseries].ChartType = SeriesChartType.Point;
chart1.Series[chartseries].MarkerStyle = MarkerStyle.Cross;
chart1.Series[chartseries].MarkerSize = 8;
chart1.Series[chartseries].Color = Color.DarkOrange;
foreach (var v in kv.Value)
{
chart1.Series[chartseries].Points.AddXY(kv.Key, v);
}
}
}
//************************************DC VOLT plot STOPS HERE***********************************
private void Richtextedit()
{
// float maxidc = plotidcpowermeter.GetMax;
//string value = Convert.ToString(maxidc);
this.richTextBox1.AppendText("Idc max (powermeter): ");
// this.richTextBox1.AppendText(value + "A\n");
// value = Convert.ToString(plotidcpowermeter.GetMin);
this.richTextBox1.AppendText("Idc min (powermeter): ");
// this.richTextBox1.AppendText(value + "A\n");
}
private void Richtextedit(string text)
{
this.richTextBox1.AppendText(text + "\n");
}
private Dictionary<string, Column> Realpowerdictionary
{
get { return realpowerdict; }
}
//Load DC voltage compare tables
//Check of the file is in use
protected virtual bool IsFileLocked(FileInfo file)
{
FileStream stream = null;
try
{
stream = file.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.None);
}
catch (IOException)
{
//the file is unavailable because it is:
//still being written to
//or being processed by another thread
//or does not exist (has already been processed)
return true;
}
finally
{
if (stream != null)
stream.Close();
}
//file is not locked
return false;
}
private void changeplotdegrees(float deg)
{
// private List<IBaselist> colobjinterflist;//This is new...Interface implementation
//private List<IBaselist> colobjinterflistbl;//This is new...Interface implementation
foreach(IBaselist IBase in colobjinterflist)
{
if(IBase is VdcconfiguredI)
{
foreach (IBaselist IBase2 in colobjinterflist)
if (!(IBase2.GetName() == "Vdcconfigured") || !(IBase2.GetName() == "Phaseconfigured"))
IBase2.Populareslices((IBase as VdcconfiguredI).Slicelist, deg);
}
}
foreach (IBaselist IBase3 in colobjinterflistbl)
{
if (IBase3 is VdcconfiguredI)
{
foreach (IBaselist IBase4 in colobjinterflistbl)
if (!(IBase4.GetName() == "Vdcconfigured") || !(IBase4.GetName() == "Phaseconfigured"))
IBase4.Populareslices((IBase3 as VdcconfiguredI).Slicelist, deg);
}
}
}
/// <summary>
/// Done the IBaselist implementation. Plot Dcv accuracy
/// </summary>
public void Accuracydcv()
{
chartdefaults();
Title title = new Title("PCU Vdc reporting accurancy. Vdc pcu - Vdc powermeter. Ph angle: " + textBox1.Text,
Docking.Top, new Font("Verdana", 10, FontStyle.Regular), Color.Black);
chart2.Titles.Add(title);
title.IsDockedInsideChartArea = false;
title.DockedToChartArea = chart2.ChartAreas[0].Name;
List<float> values = new List<float>();
/// plot the DIFF V powermeter on chart 2
///get the columns to print for the baseline unit
IBaselist baselinepowermeter = colobjinterflistbl.First(item => item.GetName() == "Vdcpowermeter");
IBaselist baselinepcu = colobjinterflistbl.First(item => item.GetName() == "Vdcpcu");
IBaselist uutpowermeter = colobjinterflist.First(item => item.GetName() == "Vdcpowermeter");
IBaselist uutpcu = colobjinterflist.First(item => item.GetName() == "Vdcpcu");
plotaccuracycomaprison(baselinepcu, baselinepowermeter, uutpcu, uutpowermeter);
}
//plot the accuracy of idc
public void Accuracyicv()
{
chartdefaults();
Title title = new Title("PCU Idc reporting accurancy. Idcpcu - Idc powermeter. Phase andgle: " + textBox1.Text,
Docking.Top, new Font("Verdana", 10, FontStyle.Regular), Color.Black);
chart2.Titles.Add(title);
title.IsDockedInsideChartArea = false;
title.DockedToChartArea = chart2.ChartAreas[0].Name;
List<float> values = new List<float>();
// plot the DIFF V powermeter on chart 2
///get the columns to print for the baseline unit
IBaselist baselinepowermeter = colobjinterflistbl.First(item => item.GetName() == "Idcpowermeter");
IBaselist baselinepcu = colobjinterflistbl.First(item => item.GetName() == "Idcpcu");
// plot the DIFF V powermeter on chart 2
IBaselist uutpowermeter = colobjinterflist.First(item => item.GetName() == "Idcpowermeter");
IBaselist uutpcu = colobjinterflist.First(item => item.GetName() == "Idcpcu");
plotaccuracycomaprison(baselinepcu, baselinepowermeter, uutpcu, uutpowermeter);
}
public void Accuracywdc()
{
chartdefaults();
Title title = new Title("PCU Wdc reporting accurancy. Phase andgle: " + textBox1.Text,
Docking.Top, new Font("Verdana", 10, FontStyle.Regular), Color.Black);
chart2.Titles.Add(title);
title.IsDockedInsideChartArea = false;
title.DockedToChartArea = chart2.ChartAreas[0].Name;
//Dictionary<float, List<float>> dictwdcpm =
// new Dictionary<float, List<float>>(plotwdcpowermeterbl.GetSlices);
List<float> values = new List<float>();
// plot the DIFF V powermeter on chart 2
///get the columns to print for the baseline unit
IBaselist baselinepowermeter = colobjinterflistbl.First(item => item.GetName() == "Wdcpowermeter");
IBaselist baselinepcu = colobjinterflistbl.First(item => item.GetName() == "Wdcpcu");
// plot the DIFF V powermeter on chart 2
IBaselist uutpowermeter = colobjinterflist.First(item => item.GetName() == "Wdcpowermeter");
IBaselist uutpcu = colobjinterflist.First(item => item.GetName() == "Wdcpcu");
plotaccuracycomaprison(baselinepcu, baselinepowermeter, uutpcu, uutpowermeter);
}
/// <summary>
/// Plots the Var vs real power triangle
/// </summary>
private async void acvarvapower()
{
//List<YourType> newList = new List<YourType>(oldList);
chartdefaults();
Title title = new Title("Powermeter VA against VAR: " + textBox1.Text,
Docking.Top, new Font("Verdana", 10, FontStyle.Regular), Color.Black);
chart1.Titles.Add(title);
title.IsDockedInsideChartArea = false;
title.DockedToChartArea = chart1.ChartAreas[0].Name;
///Get reference to all the column classes, to acces their data
IBaselist ibl = colobjinterflistbl.First(item => item.GetName() == "Wacpowermeter");
IBaselist ibl2 = colobjinterflistbl.First(item => item.GetName() == "Wacconfigured");
IBaselist ibl3 = colobjinterflistbl.First(item => item.GetName() == "Wacvarconfigured");
IBaselist ibl4 = colobjinterflistbl.First(item => item.GetName() == "ACvarpowermeter");
IBaselist ibl5 = colobjinterflist.First(item => item.GetName() == "Wacpowermeter");
IBaselist ibl6 = colobjinterflist.First(item => item.GetName() == "Wacconfigured");
IBaselist ibl7 = colobjinterflist.First(item => item.GetName() == "Wacvarconfigured");
IBaselist ibl8 = colobjinterflist.First(item => item.GetName() == "ACvarpowermeter");
//Below are the values for chart one
List<float> values = new List<float>();
List<float> waccnf = new List<float>();
List<float> wacvarcnf = new List<float>();
//Chart2 this is for chart 2 the baseline vlues
List<float> values2 = new List<float>();
List<float> values3 = new List<float>();
//congfigured values for chart 2 baseline unit
List<float> waccnfbl = new List<float>();
List<float> wacvarcnfbl = new List<float>();
foreach (var kv in ibl8.GetSlices())
{
//create the series name from the values
string seriesac = (Convert.ToString(kv.Key));
string seriesvar = "cnf";
string serieschart2 = "cmp";
string serieschart2cnf = "cn";
if (seriesac.Length > 4)
seriesac = seriesac.Substring(0, 4);
//create another series name
seriesvar += seriesac;
seriesac += "Wvar";
serieschart2 += seriesac;
serieschart2cnf += seriesac;
//chart1 stuff
chart1.Series.Add(seriesac);
chart1.Series[seriesac].ChartType = SeriesChartType.Line;