/
FormSystemStatus.cs
784 lines (698 loc) · 35.2 KB
/
FormSystemStatus.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
#region using
using System;
using System.ComponentModel;
using System.IO;
using System.Windows.Forms;
using System.Threading;
#endregion
namespace WindowsFormsApplication1
{
public partial class FormSystemStatus : Form
{
#region Variables
// Debugging only:
Random random = new Random();
// Twice a second:
private const int SAMPLING_INTERVAL = 500;
// Once every 5 seconds:
public static int ConstellationUpdateIntervalSec = 5;
private System.Diagnostics.Stopwatch constellationStopwatch = new System.Diagnostics.Stopwatch();
// Objects that need synchronization must be individually managed (see
// constellationLock.) This boolean tells the background message
// generator to stop requesting updates. Not currently (Nov 2011) used
private bool pauseFormUpdates = false;
private Constellation constellation = null;
private Object constellationLock = new Int16();
private Constellation.TRIGGER_RETURN_CODE constellationBackgroundResults;
// KeepAlive monitor.
private readonly int KEEP_ALIVE_FAILURE_THRESHOLD = 3;
private int keepAliveFailure;
private bool KeepAliveEnable = false;
// Keeping track of the GMAC and statistic selections,
// for use by non-GUI thread:
private GMAC gmacLeft = GMAC.gmac0;
private GMAC gmacRight = GMAC.gmac0;
private int gmacLeftSelection;
private int gmacRightSelection;
private bool EVB_Connection_up = true;
private StreamWriter sw;
public static bool MCS_per_BW = false;
readonly UInt32 SoCResetAddress = 0xe573e000;
#endregion
#region SystemStatusForm functionality
public FormSystemStatus( )
{
InitializeComponent();
this.comboBoxGraph0a.SelectedIndex = 0; // GMAC0
this.comboBoxGraph0b.SelectedIndex = 0; // Rx- MMC ethernet packet count
this.comboBoxGraph1a.SelectedIndex = 0; // GMAC0
this.comboBoxGraph1b.SelectedIndex = 7; // Tx- MMC ethernet packet count
this.radioButtonRSSI1.Checked = true;
// This checkbox is for development only
// chkBxTimerEnabled.Visible = true;
chkBxTimerEnabled.Checked = true; // invokes RunTimer()
//try
//{
// if (!File.Exists(@"C:\PTP\Log.csv"))
// {
// File.Create(@"C:\PTP\Log.csv");
// }
// FileStream _fs = new FileStream(@"C:\PTP\Log.csv", FileMode.Open, FileAccess.Write, FileShare.ReadWrite);
// sw = new StreamWriter(_fs);
// string DataToSave = "NACK0" + " , " + "ACK0" + " , " + "NACK1" + " , " + "ACK1"
// + " , " + "NackCtrl" + " , " + "AckCtrl" + " , "
// + "CINR1avg" + " , " + "RSSI1" + " , " + "STO1" + " , "
// + "CINR2avg" + " , " + "RSSI2" + " , " + "STO2" + " , "
// + "MCSRX" + "," + "MCSTX";
// sw.WriteLine(DataToSave);
//}
//catch { }
FormNodeProperties.instance.Visible = true;
FormNodeProperties.instance.Visible = false;
}
private void comboBoxGraph0a_SelectedIndexChanged(object sender, EventArgs e)
{
// gmacLeft is accessed by another, non-gui, thread:
gmacLeft = ((this.comboBoxGraph0a.SelectedIndex == 0) ? GMAC.gmac0 : GMAC.gmac1);
spPerfChart0.Clear();
// Remember previous selection:
int registerSelection = Math.Min(this.comboBoxGraph0b.SelectedIndex, gmacLeft.RegisterNames.Length - 1);
// reload combo of register names
this.comboBoxGraph0b.Items.Clear();
foreach (string s in gmacLeft.RegisterNames)
{
this.comboBoxGraph0b.Items.Add(s);
}
// change selection, if beyond end of list
this.comboBoxGraph0b.SelectedIndex = Math.Max(0, registerSelection);
}
private void comboBoxGraph1a_SelectedIndexChanged(object sender, EventArgs e)
{
// gmacRight is accessed by another, non-gui, thread:
gmacRight = ((this.comboBoxGraph1a.SelectedIndex == 0) ? GMAC.gmac0 : GMAC.gmac1);
spPerfChart1.Clear();
// Previous selection:
int registerSelection = Math.Min(this.comboBoxGraph1b.SelectedIndex, gmacRight.RegisterNames.Length - 1);
// reload combo of register names
this.comboBoxGraph1b.Items.Clear();
foreach (string s in gmacRight.RegisterNames)
{
this.comboBoxGraph1b.Items.Add(s);
}
// Try to restore previous selection (but not -1)
this.comboBoxGraph1b.SelectedIndex = Math.Max(0, registerSelection);
}
private void comboBoxGraph0b_SelectedIndexChanged(object sender, EventArgs e)
{
// gmacLeftSelection is for access by another, non-gui, thread:
gmacLeftSelection = comboBoxGraph0b.SelectedIndex;
spPerfChart0.Clear();
}
private void comboBoxGraph1b_SelectedIndexChanged(object sender, EventArgs e)
{
// gmacRightSelection is for access by another, non-gui, thread:
gmacRightSelection = comboBoxGraph1b.SelectedIndex;
spPerfChart1.Clear();
}
/*
* Adjusts GMAC charts to indicate how many seconds of data are shown. Based on
* 16 pixel horiz grid spacing, and sampling rate currently employed.
*/
private void updateGroupboxLabels()
{
// The TimerMode.Disabled will draw one datapoint per sample interval,
// and for each sample scroll the chart valueSpacing pixels.
int valueSpacing = 5; // from SpPerfChart
int GRID_SPACING = 16; // Horiz spacing, from SpPerfChart
// Pixels per second:
double pixelsPerSecond = valueSpacing * (1000.0 / SAMPLING_INTERVAL);
// Seconds per gridline:
double secPerGrid = ((double)GRID_SPACING) / ((double)pixelsPerSecond);
// Number of vert gridlines:
double gridlines = ((double)spPerfChart0.Width) / GRID_SPACING;
int numberOfSecondsDisplayed = (int)(spPerfChart0.Width / pixelsPerSecond);
// Since the container keeps both charts equal in width, same value applies to both:
this.groupBoxGMAC0.Text = String.Format("{0} {1} sec ", comboBoxGraph0a.SelectedItem.ToString(), numberOfSecondsDisplayed);
this.groupBoxGMAC1.Text = String.Format("{0} {1} sec ", comboBoxGraph1a.SelectedItem.ToString(), numberOfSecondsDisplayed);
}
#endregion
#region constellation
/*
* Must be reentrant, can be called by the gui or the background worker
* at the RunWorkerCompleted method.
*/
private void stopConstellation()
{
// Sometimes, will block processing of the button from 'off' to 'on',
// but if we don't block here, constellation.shutDown can happen at
// the same time that the bgWrk thread is iterating PhyConstellationData
// objects, registering with pcap, etc.
lock (constellationLock)
{
if (constellation != null)
{
constellation.shutDown();
}
buttonConstellation.Text = "Constellation";
constellation = null;
// Don't need to cancel the background task; just let
// it finish. It will detect null constellation
// during RunWorkerCompleted.
}
}
private void buttonConstellation_Click(object sender, EventArgs e)
{
if (buttonConstellation.Text == "Constellation")
{
lock (constellationLock)
{
if (constellation == null)
{
constellation = new Constellation();
// First time only, check that matlab folder exists
if (!File.Exists(Constellation.constellationExecutable ))
{
MessageBox.Show("The Matlab program is not present, at: " + Constellation.constellationExecutable
+ "\n\nUse Properties / Constellation page to select a different Matlab executable or location.",
"DAN PTP - Installation Error",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
constellation = null;
return;
}
}
buttonConstellation.Text = "Close Plot";
} // unlocked
// Get constellation data, write files and launch Matlab on a worker thread.
// It's possible (try double-clicking "Constellation" button) that the worker
// has already been started, so only invoke RunWorker when not busy:
if (!bgWrkConstellation.IsBusy)
{
bgWrkConstellation.RunWorkerAsync();
}
}
else
{
stopConstellation();
}
}
#endregion
#region Timer-driven methods, to poll EVB and collate constellation data
private void bgWrkConstellation_DoWork(object sender, DoWorkEventArgs e)
{
int delayDuration = Convert.ToInt32(e.Argument);
if (delayDuration > 0)
{
Thread.Sleep(delayDuration);
}
// Although this will be locked for a while, it is important to
// delay any "Close Constellation" button click until the trigger()
// completes waiting for EVB replies. This lock only blocks the GUI
// if the user clicks the button.
lock (constellationLock)
{
if (constellation != null)
{
// Take note of when the task begins
constellationStopwatch.Restart();
constellationBackgroundResults = constellation.trigger();
}
else
{
// This happens each time "Close Plot" is clicked
constellationBackgroundResults = Constellation.TRIGGER_RETURN_CODE.OK;
}
}
}
/*
* Requesting, processing constellation data is performed during the DoWork
* part of this BackgroundWorker.
* Here, results are considered, user is notified if the process failed,
* and - if success - the Constellation background worker is restarted.
*/
private void bgWrkConstellation_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
constellationStopwatch.Stop();
switch (constellationBackgroundResults)
{
case Constellation.TRIGGER_RETURN_CODE.SOC_UNRESPONSIVE:
MessageBox.Show("Timeout fetching constellation data - the EVB has stopped responding.",
"DAN PTP - Communication Error",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
stopConstellation();
return;
case Constellation.TRIGGER_RETURN_CODE.EXECUTABLE_FAILURE:
MessageBox.Show("The Matlab process failed to start",
"DAN PTP - Process Error",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
stopConstellation();
return;
case Constellation.TRIGGER_RETURN_CODE.FILE_WRITE_FAILURE:
MessageBox.Show("Error writing constellation files for the Matlab process",
"DAN PTP - File Error",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
stopConstellation();
return;
default:
// TRIGGER_RETURN_CODE_OK
if (constellation == null)
{
// Usually not needed; this is a typical exit from charting mode.
stopConstellation();
return; // ends
}
// Restart the task, specifying a certain delay. (Deduct the time
// spent waiting for responses from SOC and filesystem I/O)
int delayDuration = (ConstellationUpdateIntervalSec * 1000) - (int)constellationStopwatch.ElapsedMilliseconds;
if (delayDuration < 0) { delayDuration = 1; } // already used up our time
// Restart the task (bgWrkConstellation is not 'busy')
bgWrkConstellation.RunWorkerAsync(delayDuration);
break;
}
}
// This checkbox is helpful for development, not visible for release:
private void chkBxTimerEnabled_CheckedChanged(object sender, EventArgs e)
{
if (chkBxTimerEnabled.Checked && !bgWrkTimer.IsBusy)
{
RunTimer();
}
}
// The object bgWrkTimer has been configured as a one-shot timer,
// which may restart itself (if chkBxTimerEnabled) when its work
// is done.
private void RunTimer()
{
bgWrkTimer.RunWorkerAsync(SAMPLING_INTERVAL);
}
// Not allowed to interact with user-interface objects during this event handler!
private void bgWrkTimer_DoWork(object sender, DoWorkEventArgs e)
{
try
{
// Request Data from EVB for displayed objects
if (!pauseFormUpdates)
{
// request next values for GMAC's
GMAC.gmac0.getNextValues_GMAC0();
GMAC.gmac1.getNextValues_GMAC1();
// Request data for Link Status
LinkIndicator.links.getNextValues();
// update PHY
PHY.phy.getNextValues();
// update AMC
AMC.amc.getNextValues();
//update Debug tabs and unit control
//FormNodeProperties.instance.getNextValues();
}
}
catch (Exception ex)
{
System.Console.WriteLine("Exception {0}", ex.Message);
}
Thread.Sleep(Convert.ToInt32(e.Argument));
}
/*
* The sleep is done, DAN msg replies have probably arrived
*/
private void bgWrkTimer_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
try
{
if (KeepAliveEnable)
{
if (keepAliveFailure > KEEP_ALIVE_FAILURE_THRESHOLD)
{
// looking for heartbeat resume
if (PHY.phy.RxNumFrameIndsDelta > 0 && PHY.phy.TxNumFrameIndsDelta > 0)
{
// reset
keepAliveFailure = 0;
string msg = global::WindowsFormsApplication1.Properties.Resources.HeartbeatNotificationRegain;
MessageBox.Show(msg, "DAN PTP Heartbeat Notification",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
EVB_Connection_up = true;
}
}
else
{
if (PHY.phy.RxNumFrameIndsDelta == 0 || PHY.phy.TxNumFrameIndsDelta == 0)
{
if (++keepAliveFailure > KEEP_ALIVE_FAILURE_THRESHOLD)
{
// Notify user
string msg = global::WindowsFormsApplication1.Properties.Resources.HeartbeatNotificationError;
MessageBox.Show(msg, "DAN PTP Heartbeat Notification",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
EVB_Connection_up = false;
}
}
else
{
// One good heartbeat resets the counter
keepAliveFailure = 0;
}
}
}
if (EVB_Connection_up)
{
// Link Status
// this.panelLinkSync.BackColor = (LinkIndicator.links.SyncAchieved ? System.Drawing.Color.LightGreen : System.Drawing.Color.Yellow);
this.panelLinkTimingLoop.BackColor = (LinkIndicator.links.TimingLoopOK ? System.Drawing.Color.LightGreen : System.Drawing.Color.Yellow);
this.panelLinkTxOn.BackColor = (LinkIndicator.links.TxOn ? System.Drawing.Color.LightGreen : System.Drawing.Color.Yellow);
if (FormNodeProperties.instance.SisoMimoMode == "Single SISO")
{
this.panelLinkPllLock.BackColor = (LinkIndicator.links.PllLockAnt0 ? System.Drawing.Color.LightGreen : System.Drawing.Color.Yellow);
}
else
{
this.panelLinkPllLock.BackColor = ((LinkIndicator.links.PllLockAnt0 & LinkIndicator.links.PllLockAnt1) ? System.Drawing.Color.LightGreen : System.Drawing.Color.Yellow);
}
this.labelLinkStatus.Text = FormNodeProperties.instance.linkstatus;
// GMACs
updateGroupboxLabels();
decimal rate;
if (comboBoxGraph1a.SelectedIndex == 0)
{
rate = (decimal)gmacLeft.rateCounter_GMAC0(gmacLeftSelection);
}
else
{
rate = (decimal)gmacLeft.rateCounter_GMAC1(gmacLeftSelection);
}
this.spPerfChart0.AddValue(rate);
this.labelGraph0Max.Text = String.Format("Max: {0:0,0} f/s", spPerfChart0.MaxValue);
this.labelGraph0Latest.Text = String.Format("{0:0,0.0} f/s", rate);
// Repeat for Graph1:
if (comboBoxGraph0a.SelectedIndex == 0)
{
rate = (decimal)gmacRight.rateCounter_GMAC0(gmacRightSelection);
}
else
{
rate = (decimal)gmacRight.rateCounter_GMAC1(gmacRightSelection);
}
// rate = (decimal)gmacRight.rateCounter(gmacRightSelection);
this.spPerfChart1.AddValue(rate);
this.labelGraph1Max.Text = String.Format("Max: {0:0,0} f/s", spPerfChart1.MaxValue);
this.labelGraph1Latest.Text = String.Format("{0:0,0.0} f/s", rate);
/// RSSI Graph - range {-40..0}
/// (Since graphs don't support neg numbers, for now just chart abs(x) i.e, -1x)
try
{
if (FormNodeProperties.instance.SisoMimoMode == "Single SISO")
{
this.spPerfChartRSSI.AddValues((decimal)-PHY.phy.RSSI1, (decimal)-PHY.phy.RSSI1);
}
else
{
if ((PHY.phy.RSSI1 == 0) && (PHY.phy.RSSI2 == 0))
{
this.spPerfChartRSSI.AddValues((decimal)-PHY.phy.RSSI1, (decimal)-PHY.phy.RSSI2);
}
else
{
this.spPerfChartRSSI.AddValues((decimal)-PHY.phy.RSSI1, (decimal)-PHY.phy.RSSI2 + 1);
}
}
}
catch (Exception)
{
Console.WriteLine("Error adding values {0} & {1} to RSSI", -PHY.phy.RSSI1, -PHY.phy.RSSI2);
}
this.labelGraphRSSI0Current.Text = String.Format(" {0:0.0} dBFS", PHY.phy.RSSI1);
this.labelGraphRSSI1Current.Text = String.Format(" {0:0.0} dBFS", PHY.phy.RSSI2);
/// CINR - range {0..50}
try
{
decimal CINR_scale = 100.0m / (decimal)PHY.phy.CINR_Max;
if (FormNodeProperties.instance.SisoMimoMode == "Single SISO")
{
this.spPerfChartCINR.AddValues(((decimal)PHY.phy.CINR1) * CINR_scale, ((decimal)PHY.phy.CINR1) * CINR_scale);
}
else
{
this.spPerfChartCINR.AddValues(((decimal)PHY.phy.CINR1) * CINR_scale, ((decimal)PHY.phy.CINR2) * CINR_scale + 1);
}
}
catch (Exception)
{
Console.WriteLine("Error adding values {0} & {1} to CINR", PHY.phy.CINR1, PHY.phy.CINR2);
}
this.labelGraphCINR0Current.Text = String.Format(" {0:0.00} dB", PHY.phy.CINR1);
this.labelGraphCINR1Current.Text = String.Format(" {0:0.00} dB", PHY.phy.CINR2);
/// PER - % {0..100}
decimal nack = (decimal)PHY.phy.NACK0;
decimal ack = (decimal)PHY.phy.ACK0;
decimal nackB = (decimal)PHY.phy.NACK1;
decimal ackB = (decimal)PHY.phy.ACK1;
decimal val = ((ack + nack) == 0) ? 0m : nack / (ack + nack);
decimal valB = ((ackB + nackB) == 0) ? 0m : nackB / (ackB + nackB);
try
{
if (FormNodeProperties.instance.SisoMimoMode == "Single SISO")
{
this.spPerfChartPER.AddValues(val * 100, val * 100);
}
else
{
this.spPerfChartPER.AddValues(val * 100, valB * 100 + 1);
}
}
catch (Exception)
{
Console.WriteLine("Error adding values {0} & {1} to PER", val * 1000, valB * 1000);
}
this.labelGraphPER0Current.Text = String.Format(" {0:0.0} %", val * 100);
this.labelGraphPER1Current.Text = String.Format(" {0:0.0} %", valB * 100);
this.labelGraphPER0Nack.Text = nack.ToString();
this.labelGraphPER1Nack.Text = nackB.ToString();
/// AMC-Averaged CINR
// TODO: Get bandwidth from somewhere... right now, looks like a SOC build #define
MCS.BANDWIDTH bw = MCS.BANDWIDTH.MHZ80;
// Valid values are enforced by AMC
if (PHY.phy.controlChannelTx == null)
{
// may happen when PHY hasn't received a handleControlChannels
// message yet
Console.WriteLine("null controlChannelTx...");
}
else
{
//uint mcsCurrent = (radioButtonMCSAnt1.Checked ? PHY.phy.controlChannelTx.txAnnounced1 : PHY.phy.controlChannelTx.txAnnounced2);
uint mcsCurrent = PHY.phy.controlChannelRx.txAnnounced1;
uint mcsCurrentB = PHY.phy.controlChannelTx.txAnnounced2;
// Scale to 100
try
{
// Scale based on number of defined modulations
decimal scale = (100.0m / MCS.getMaxMCS());
decimal up_graph_offset = (decimal)-0.5;
// Multiply to scale {0..8} -> {0..100}, but then add 1/2 Grid_Y_, so they line up with the labels
// Note that this chart is in absolute mode.
decimal halfGridY = spPerfChartMCS.Grid_Y_Spacing / 2m; // current size of Chart
this.spPerfChartMCS.AddValues((mcsCurrent * scale) + up_graph_offset, (mcsCurrentB * scale) + up_graph_offset - 1);
this.labelMcsLatest.Text = String.Format("{0} ({1})", mcsCurrent, MCS.getMCS(bw, mcsCurrent).ToString());
}
catch (Exception)
{
Console.WriteLine("Error adding value {0} to MCS chart, or getting display string", mcsCurrent);
}
if (AMC.amc.AutoAMC)
{
this.labelMcsAuto.Text = "Auto";
this.labelMcsManualSetting.Text = "";
}
else
{
this.labelMcsAuto.Text = "Manual:";
// Note that current SOC uses antenna zero for both; but stores 2 values
uint specifiedMcs = AMC.amc.McsManualId0;
try
{
this.labelMcsManualSetting.Text = MCS.getMCS(bw, specifiedMcs).ToString();
}
catch (Exception ex2)
{
Console.WriteLine("Exception setting labelMcsManualSetting from MCS value {0} - {1}", specifiedMcs, ex2.Message);
}
}
}
if (PHY.phy.controlChannelRx != null)
{
uint txAnnouncedMCS = this.radioButtonMCSAnt1.Checked ? PHY.phy.controlChannelRx.txAnnounced1 : PHY.phy.controlChannelTx.txAnnounced2;
// Requested Rx Modulation
uint rxRequestedMcs = PHY.phy.controlChannelRx.rxRecommended1;
// textBoxReqRxMod0.Text = String.Format("{0} ({1})", rxRequestedMcs, MCS.getMCS(bw, rxRequestedMcs).modulation);
rxRequestedMcs = PHY.phy.controlChannelRx.rxRecommended2;
// textBoxReqRxMod1.Text = String.Format("{0} ({1})", rxRequestedMcs, MCS.getMCS(bw, rxRequestedMcs).modulation);
labelMcsLatest.Text = String.Format("{0} - {1}", txAnnouncedMCS, MCS.getMCS(bw, txAnnouncedMCS).ToString());
}
// Heartbeat monitor
// See PHY property RxNumFrameIndsDelta, which uses mmc_num_rx_frame_inds
// for heartbeat (and TxNumFrameIndsDelta which uses mmc_num_tx_frame_inds.)
// If the delta is zero, either this is the first (unlikely) sample
// or something is stuck in MMC. If delta is zero three times in a row,
// show a message.
// Once the message is shown, doesn't show it again until things have
// been corrected (heartbeat resumes.)
// Restart, will no-op if pauseFormUpdates
this.textBoxSTO1.Text = String.Format(" {0:0.0}", PHY.phy.STO1);
this.textBoxSTO2.Text = String.Format(" {0:0.0}", PHY.phy.STO2);
if (FormNodeProperties.instance.SisoMimoMode == "XPIC(MIMO)")
{
this.textBoxXPIAnt0.Text = String.Format(" {0:0.0}", PHY.phy.XPI1);
this.textBoxXPIAnt1.Text = String.Format(" {0:0.0}", PHY.phy.XPI2);
}
}
if (FormNodeProperties.instance.SisoMimoMode == "Single SISO")
{
labelGraphRSSI1Current.Visible = false;
radioButtonRSSI2.Visible = false;
labelGraphCINR1Current.Visible = false;
radioButtonCINR2.Visible = false;
labelGraphPER1Current.Visible = false;
labelGraphPER1Nack.Visible = false;
radioButtonPER2.Visible = false;
}
if (FormNodeProperties.instance.SisoMimoMode == "XPIC(MIMO)")
{
groupBoxXPI.Visible = true;
}
if (FormNodeProperties.instance.LOGS_Enable)
{
FormNodeProperties.instance.Save_Log_To_Files();
}
//if (chkBxTimerEnabled.Checked)
//{
// RunTimer();
//}
RunTimer();
}
catch (Exception ex)
{
System.Console.WriteLine("Exception {0}", ex.Message);
}
}
#endregion
private void radioButtonRSSI1_CheckedChanged(object sender, EventArgs e)
{
// This chart is a DualGraph. Highlight one or another dataset
spPerfChartRSSI.PerfChartStyle.ChartLinePen.Width =
(radioButtonRSSI1.Checked) ? 3 : 2;
if (!chkBxTimerEnabled.Checked)
{
spPerfChartRSSI.Invalidate();
}
}
private void radioButtonRSSI2_CheckedChanged(object sender, EventArgs e)
{
spPerfChartRSSI.PerfChartStyle.ChartLinePenB.Width =
(radioButtonRSSI2.Checked) ? 3 : 2;
if (!chkBxTimerEnabled.Checked)
{
spPerfChartRSSI.Invalidate();
}
}
private void radioButtonCINR1_CheckedChanged(object sender, EventArgs e)
{
spPerfChartCINR.PerfChartStyle.ChartLinePen.Width =
(radioButtonCINR1.Checked) ? 3 : 2;
if (!chkBxTimerEnabled.Checked)
{
spPerfChartCINR.Invalidate();
}
}
private void radioButtonCINR2_CheckedChanged(object sender, EventArgs e)
{
spPerfChartCINR.PerfChartStyle.ChartLinePenB.Width =
(radioButtonCINR2.Checked) ? 3 : 2;
if (!chkBxTimerEnabled.Checked)
{
spPerfChartCINR.Invalidate();
}
}
private void radioButtonPER1_CheckedChanged(object sender, EventArgs e)
{
spPerfChartPER.PerfChartStyle.ChartLinePen.Width =
(radioButtonPER1.Checked) ? 3 : 1;
spPerfChartPER.PerfChartStyle.ChartLinePenB.Width =
(radioButtonPER2.Checked) ? 3 : 1;
}
private void radioButtonPER2_CheckedChanged(object sender, EventArgs e)
{
spPerfChartPER.PerfChartStyle.ChartLinePen.Width =
(radioButtonPER1.Checked) ? 3 : 1;
spPerfChartPER.PerfChartStyle.ChartLinePenB.Width =
(radioButtonPER2.Checked) ? 3 : 1;
if (!chkBxTimerEnabled.Checked)
{
spPerfChartPER.Invalidate();
}
}
private void radioButtonMCSrx_CheckedChanged(object sender, EventArgs e)
{
spPerfChartMCS.PerfChartStyle.ChartLinePen.Width =
(radioButtonMCSAnt1.Checked) ? 3 : 1;
spPerfChartMCS.PerfChartStyle.ChartLinePenB.Width =
(radioButtonMCSAnt2.Checked) ? 3 : 1;
if (!chkBxTimerEnabled.Checked)
{
spPerfChartMCS.Invalidate();
}
}
private void radioButtonMCStx_CheckedChanged(object sender, EventArgs e)
{
spPerfChartMCS.PerfChartStyle.ChartLinePen.Width =
(radioButtonMCSAnt1.Checked) ? 3 : 1;
spPerfChartMCS.PerfChartStyle.ChartLinePenB.Width =
(radioButtonMCSAnt2.Checked) ? 3 : 1;
if (!chkBxTimerEnabled.Checked)
{
spPerfChartMCS.Invalidate();
}
}
private void buttonResetCounters_Click(object sender, EventArgs e)
{
//clear all PHY counters statistics and clear all graphs
ResetCounters();
}
private void buttonProperties_Click(object sender, EventArgs e)
{
if (FormNodeProperties.instance.IsDisposed)
{
FormNodeProperties.instance.Show(this);
}
else if (!FormNodeProperties.instance.Visible)
{
FormNodeProperties.instance.Visible = true;
}
else if (FormNodeProperties.instance.WindowState == FormWindowState.Minimized)
{
FormNodeProperties.instance.WindowState = FormWindowState.Normal;
}
FormNodeProperties.instance.initTabs();
FormNodeProperties.instance.BringToFront();
}
public void ResetCounters()
{
PHY.phy.resetAirlinkCounters();
GMAC.gmac0.resetGMACCounters();
spPerfChart0.Clear();
spPerfChart1.Clear();
spPerfChartRSSI.Clear();
spPerfChartCINR.Clear();
spPerfChartPER.Clear();
spPerfChartMCS.Clear();
}
private void buttonResetSOC_Click(object sender, EventArgs e)
{
DialogResult dialogResult = MessageBox.Show("This action will reset the unit.\n Do you want to continue?\n", "Reset SoC", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
UInt32 CG_Activate = 0x00010000;
DAN_write_msg wMsg = new DAN_write_msg(SoCResetAddress, CG_Activate);
PcapConnection.pcap.sendDanMsg(wMsg);
}
}
}
}