Subversion Repositories group.NITPanels

Rev

Rev 12 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 12 Rev 14
Line 26... Line 26...
26
 
26
 
27
        public int flipcomm { get; set; }
27
        public int flipcomm { get; set; }
28
        public int flipnav { get; set; }
28
        public int flipnav { get; set; }
29
 
29
 
30
        public uint simStatus { get; set; }
30
        public uint simStatus { get; set; }
-
 
31
        private bool SimButtonsOn;
31
 
32
 
32
        public int comStatus { get; set; }
33
        public int comStatus { get; set; }
33
        public bool navAvailable { get; set; }
34
        public bool navAvailable { get; set; }
34
        public bool avionicsMaster { get; set; }
35
        public bool avionicsMaster { get; set; }
35
 
36
 
Line 82... Line 83...
82
            this.assigned = 1;
83
            this.assigned = 1;
83
 
84
 
84
            this.comStatus = 0;
85
            this.comStatus = 0;
85
            this.navAvailable = true;
86
            this.navAvailable = true;
86
            this.avionicsMaster = false;
87
            this.avionicsMaster = false;
-
 
88
            this.SimButtonsOn = false;
87
 
89
 
88
            for (int i = 0; i < TIMER_COUNT; i++) {
90
            for (int i = 0; i < TIMER_COUNT; i++) {
89
                Timer timer = new Timer();
91
                Timer timer = new Timer();
90
                timer.Enabled = false;
92
                timer.Enabled = false;
91
                timer.AutoReset = false;
93
                timer.AutoReset = false;
Line 155... Line 157...
155
            for (byte i = 0; i < 4; i++)
157
            for (byte i = 0; i < 4; i++)
156
                setFreq(i, ref blank);
158
                setFreq(i, ref blank);
157
            this.points[0] = 0x0000;
159
            this.points[0] = 0x0000;
158
            this.points[1] = 0x0000;
160
            this.points[1] = 0x0000;
159
            this.sendPoints();
161
            this.sendPoints();
160
            this.UpdateDisplay();
162
            this.UpdateAllDisplays();
161
        }
163
        }
162
 
164
 
163
        public byte[] getFreq(byte freq) {
165
        public byte[] getFreq(byte freq) {
164
            byte[] ret = new byte[5];
166
            byte[] ret = new byte[5];
165
            switch (freq) {
167
            switch (freq) {
Line 208... Line 210...
208
            byte[] freq0 = this.charArrayToBytes(data.Freq0.ToString().ToCharArray());
210
            byte[] freq0 = this.charArrayToBytes(data.Freq0.ToString().ToCharArray());
209
            byte[] freq1 = this.charArrayToBytes(data.Freq1.ToString().ToCharArray());
211
            byte[] freq1 = this.charArrayToBytes(data.Freq1.ToString().ToCharArray());
210
            byte[] freq2 = this.charArrayToBytes(data.Freq2.ToString().ToCharArray());
212
            byte[] freq2 = this.charArrayToBytes(data.Freq2.ToString().ToCharArray());
211
            byte[] freq3 = this.charArrayToBytes(data.Freq3.ToString().ToCharArray());
213
            byte[] freq3 = this.charArrayToBytes(data.Freq3.ToString().ToCharArray());
212
 
214
 
-
 
215
            byte[] ofreq0 = this.getFreq(0);
-
 
216
            byte[] ofreq1 = this.getFreq(1);
-
 
217
            byte[] ofreq2 = this.getFreq(2);
-
 
218
            byte[] ofreq3 = this.getFreq(3);
-
 
219
 
213
            this.setFreq(0, ref freq0);
220
            this.setFreq(0, ref freq0);
214
            this.setFreq(1, ref freq1);
221
            this.setFreq(1, ref freq1);
-
 
222
 
215
            this.setFreq(2, ref freq2);
223
            this.setFreq(2, ref freq2);
216
            this.setFreq(3, ref freq3);
224
            this.setFreq(3, ref freq3);
217
 
225
 
-
 
226
            if (freq0 != ofreq0 || freq1 != ofreq1) this.UpdateDisplay(0);
218
            this.UpdateDisplay();
227
            if (freq2 != ofreq2 || freq3 != ofreq3) this.UpdateDisplay(1);
-
 
228
 
219
        }
229
        }
220
 
230
 
221
        private byte[] charArrayToBytes(char[] digits) {
231
        private byte[] charArrayToBytes(char[] digits) {
222
            byte[] bytes = new byte[5];
232
            byte[] bytes = new byte[5];
223
            for (byte i = 0; i < 5; i++) {
233
            for (byte i = 0; i < 5; i++) {
Line 230... Line 240...
230
            for (byte i = 0; i < 10; i++) {
240
            for (byte i = 0; i < 10; i++) {
231
                this.sendDigit(dis, i, display[dis, i]);
241
                this.sendDigit(dis, i, display[dis, i]);
232
            }
242
            }
233
        }
243
        }
234
 
244
 
-
 
245
        
235
        public void UpdateDisplay() {
246
        public void UpdateAllDisplays() {
236
            this.sendData(0);
247
            this.sendData(0);
237
            this.latchDisplay(0);
248
            this.latchDisplay(0);
238
            this.sendData(1);
249
            this.sendData(1);
239
            this.latchDisplay(1);
250
            this.latchDisplay(1);
240
            
251
            
Line 263... Line 274...
263
 
274
 
264
            base.SendCommand(21, (short)wxValue, (short)wxIndex);
275
            base.SendCommand(21, (short)wxValue, (short)wxIndex);
265
        }
276
        }
266
 
277
 
267
        private void sendPoints() {
278
        private void sendPoints() {
268
            //ushort wxValue = (ushort)();
-
 
269
            //ushort wxIndex = (ushort)();
-
 
270
 
-
 
271
            base.SendCommand(23, (short)this.points[0], (short)this.points[1]);
279
            base.SendCommand(23, (short)this.points[0], (short)this.points[1]);
272
        }
280
        }
273
 
281
 
274
        private void sendLatch(byte dis) {
282
        private void sendLatch(byte dis) {
275
            if (!this.isOpen())
283
            if (!this.isOpen())
Line 399... Line 407...
399
 
407
 
400
 
408
 
401
        }     
409
        }     
402
 
410
 
403
        public override void SimButtons() {
411
        public override void SimButtons() {
-
 
412
            if (this.SimButtonsOn)
-
 
413
                return;
-
 
414
 
-
 
415
            this.SimButtonsOn = true;
-
 
416
 
404
            this.inputTimer.Enabled = false;
417
            this.inputTimer.Enabled = false;
405
            if (this.simStatus != 0)
418
            if (this.simStatus != 0)
406
                return;
419
                return;
407
 
420
 
408
            this.updateInput();
421
            this.updateInput();
Line 454... Line 467...
454
 
467
 
455
            // Process the rotary encoders COMM1
468
            // Process the rotary encoders COMM1
456
            sbyte delta = this.getRotary(0, 0);
469
            sbyte delta = this.getRotary(0, 0);
457
            this.resetRotary(0, 0);
470
            this.resetRotary(0, 0);
458
            if (delta != 0) {
471
            if (delta != 0) {
-
 
472
                commRotaryPressed(delta);
-
 
473
            }
-
 
474
 
-
 
475
            // Process the rotary encoders NAV1
-
 
476
            delta = this.getRotary(1, 0);
-
 
477
            this.resetRotary(1, 0);
-
 
478
            if (delta != 0) {
-
 
479
                navRotaryPressed(delta);
-
 
480
            }
-
 
481
            this.inputTimer.Enabled = true;
-
 
482
 
-
 
483
            this.SimButtonsOn = false;
-
 
484
        } // End SimButtons
-
 
485
 
-
 
486
            private void commRotaryPressed(sbyte delta) {
459
                if (delta < 0) {
487
                if (delta < 0) {
460
                    delta = (sbyte)-delta;
488
                    delta = (sbyte)-delta;
461
 
-
 
462
                    if (this.flipcomm == 1)
489
                    for (int i = 0; i<delta; i++) {
463
                        if (this.assigned == 1)
490
                        if (this.flipcomm == 1)
464
                            fsx.Comm1DecFract();
491
                            if (this.assigned == 1)
465
                        else
-
 
466
                            fsx.Comm2DecFract();
492
                                fsx.Comm1DecFract();
467
                    else
493
                            else
468
                        if (this.assigned == 1)
-
 
469
                            fsx.Comm1DecWhole();
494
                                fsx.Comm2DecFract();
470
                        else
495
                        else
-
 
496
                            if (this.assigned == 1)
-
 
497
                                fsx.Comm1DecWhole();
-
 
498
                            else
471
                            fsx.Comm2DecWhole();
499
                                fsx.Comm2DecWhole();
-
 
500
                    }
472
                } else {
501
                } else {
473
 
-
 
474
                    if (this.flipcomm == 1)
502
                    for (int i = 0; i < delta; i++) {
475
                        if (this.assigned == 1)
503
                        if (this.flipcomm == 1)
476
                            fsx.Comm1IncFract();
504
                            if (this.assigned == 1)
477
                        else
-
 
478
                            fsx.Comm2IncFract();
505
                                fsx.Comm1IncFract();
479
                    else
506
                            else
480
                        if (this.assigned == 1)
-
 
481
                            fsx.Comm1IncWhole();
507
                                fsx.Comm2IncFract();
482
                        else
508
                        else
-
 
509
                            if (this.assigned == 1)
-
 
510
                                fsx.Comm1IncWhole();
-
 
511
                            else
483
                            fsx.Comm2IncWhole();
512
                                fsx.Comm2IncWhole();
-
 
513
                    }
484
                }
514
                }
485
            }
515
            }
486
 
516
 
487
            // Process the rotary encoders NAV1
-
 
488
            delta = this.getRotary(1, 0);
517
            private void navRotaryPressed(sbyte delta) {
489
            this.resetRotary(1, 0);
-
 
490
            if (delta != 0) {
-
 
491
                if (delta < 0) {
518
                if (delta < 0) {
492
                    delta = (sbyte)-delta;
519
                    delta = (sbyte)-delta;
493
 
-
 
494
                    if (this.flipnav == 1)
520
                    for (int i = 0; i < delta; i++) {
495
                        if (this.assigned == 1)
521
                        if (this.flipnav == 1)
496
                            fsx.Nav1DecFract();
522
                            if (this.assigned == 1)
497
                        else
-
 
498
                            fsx.Nav2DecFract();
523
                                fsx.Nav1DecFract();
499
                    else
524
                            else
500
                        if (this.assigned == 1)
-
 
501
                            fsx.Nav1DecWhole();
525
                                fsx.Nav2DecFract();
502
                        else
526
                        else
-
 
527
                            if (this.assigned == 1)
-
 
528
                                fsx.Nav1DecWhole();
-
 
529
                            else
503
                            fsx.Nav2DecWhole();
530
                                fsx.Nav2DecWhole();
-
 
531
                    }
504
                } else {
532
                } else {
-
 
533
                    for (int i = 0; i < delta; i++) {
505
                        if (this.flipnav == 1)
534
                        if (this.flipnav == 1)
506
                            if (this.assigned == 1)
535
                            if (this.assigned == 1)
507
                                fsx.Nav1IncFract();
536
                                fsx.Nav1IncFract();
508
                            else
537
                            else
509
                                fsx.Nav2IncFract();
538
                                fsx.Nav2IncFract();
510
                        else
539
                        else
511
                            if (this.assigned == 1)
540
                            if (this.assigned == 1)
512
                                fsx.Nav1IncWhole();
541
                                fsx.Nav1IncWhole();
513
                            else
542
                            else
514
                                fsx.Nav2IncWhole();
543
                                fsx.Nav2IncWhole();
-
 
544
                    }
515
                }
545
                }
-
 
546
 
516
            }
547
            }
517
            this.inputTimer.Enabled = true;
-
 
518
        } // End SimButtons
-
 
-
 
548
 
519
    }
549
    }
-
 
550
 
-
 
551
 
520
}
552
}