Subversion Repositories group.NITPanels

Rev

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

Rev 4 Rev 5
Line 39... Line 39...
39
        private const int TIMER_COMMFLIP = 1;
39
        private const int TIMER_COMMFLIP = 1;
40
        private const int TIMER_NAVSWAP = 2;
40
        private const int TIMER_NAVSWAP = 2;
41
        private const int TIMER_NAVFLIP = 3;
41
        private const int TIMER_NAVFLIP = 3;
42
        Timer[] timers = new Timer[TIMER_COUNT];
42
        Timer[] timers = new Timer[TIMER_COUNT];
43
 
43
 
-
 
44
        Timer inputTimer = new Timer();
-
 
45
 
44
        public NITNavCommDevice(NITDevice nitDevice) :
46
        public NITNavCommDevice(NITDevice nitDevice) :
45
            base(nitDevice.usbRegistry, "NITNavComm", nitDevice.vid, nitDevice.pid) {
47
            base(nitDevice.usbRegistry, "NITNavComm", nitDevice.vid, nitDevice.pid) {
46
            this.init();
48
            this.init();
47
        }
49
        }
48
 
50
 
Line 82... Line 84...
82
                timer.AutoReset = false;
84
                timer.AutoReset = false;
83
                timer.Interval = NITPanels.CFG_BUTTON_DEBOUNCE_TIME;
85
                timer.Interval = NITPanels.CFG_BUTTON_DEBOUNCE_TIME;
84
                timer.Elapsed += OnDebounceTimer;
86
                timer.Elapsed += OnDebounceTimer;
85
                timers[i] = timer;
87
                timers[i] = timer;
86
            }
88
            }
-
 
89
 
-
 
90
            inputTimer.Enabled = false;
-
 
91
            inputTimer.AutoReset = true;
-
 
92
            inputTimer.Interval = NITPanels.CFG_INPUT_TIMER_INTERVAL;
-
 
93
            inputTimer.Elapsed += inputTimer_Elapsed;
87
            
94
            
88
        }
95
        }
89
 
96
 
-
 
97
        void inputTimer_Elapsed(object sender, ElapsedEventArgs e) {
-
 
98
            this.SimButtons();
-
 
99
        }
-
 
100
 
90
        private static void OnDebounceTimer(Object source, ElapsedEventArgs e) {
101
        private static void OnDebounceTimer(Object source, ElapsedEventArgs e) {
91
            Timer timer = (Timer)source;
102
            Timer timer = (Timer)source;
92
            timer.Enabled = false;
103
            timer.Enabled = false;
93
        }
104
        }
94
 
105
 
95
        public override bool Close() {
106
        public override bool Close() {
96
            this.blankDisplay();
107
            this.powerDown();
97
            return base.Close();
108
            return base.Close();
98
        }
109
        }
99
 
110
 
100
        public void powerDown() {
111
        public void powerDown() {
-
 
112
            this.simStatus = 2;
101
            this.resetAllRotary();
113
            this.resetAllRotary();
102
            this.blankDisplay();
114
            this.blankDisplay();
103
            this.simStatus = 2;
115
            this.inputTimer.Enabled = false;
104
        }
116
        }
105
 
117
 
106
        public void powerUp() {
118
        public void powerUp() {
107
            this.resetAllRotary();
-
 
108
            this.simStatus = 0;
119
            this.simStatus = 0;
-
 
120
            this.resetAllRotary();
-
 
121
            this.inputTimer.Enabled = true;
109
            
122
            
110
            if (this.assigned == 1)
123
            if (this.assigned == 1)
111
                this.fsx.requestNavComm1Data();
124
                this.fsx.requestNavComm1Data();
112
            else if (this.assigned == 2)
125
            else if (this.assigned == 2)
113
                this.fsx.requestNavComm2Data();
126
                this.fsx.requestNavComm2Data();
Line 288... Line 301...
288
                this.setFreq(2, ref right);
301
                this.setFreq(2, ref right);
289
                this.setFreq(3, ref left);
302
                this.setFreq(3, ref left);
290
            }
303
            }
291
        }
304
        }
292
 
305
 
-
 
306
        // @TODO: Remove these, not unneeded
293
        public override void FsxInit() { }
307
        public override void FsxInit() { }
-
 
308
        public override void MapEvents() { }
294
 
309
 
295
        public override void MapEvents() {
310
        public override void FsxReady() {
296
 
-
 
297
        
311
            this.powerUp();
298
        }
312
        }
299
 
313
 
-
 
314
        //public override void FsxClose() {
-
 
315
        //    this.powerDown();
-
 
316
        //}
-
 
317
 
300
        public override void FsxEvent(SIMCONNECT_RECV_SIMOBJECT_DATA data) {
318
        public override void FsxEvent(SIMCONNECT_RECV_SIMOBJECT_DATA data) {
301
 
319
 
302
            if (data.dwRequestID == (uint)FSXObject.DATA_REQUESTS.AVIONICS) {
320
            if (data.dwRequestID == (uint)FSXObject.DATA_REQUESTS.AVIONICS) {
303
                
321
                
304
                FSXObject.Avionics_Data avionics = (FSXObject.Avionics_Data)data.dwData[0];
322
                FSXObject.Avionics_Data avionics = (FSXObject.Avionics_Data)data.dwData[0];
Line 336... Line 354...
336
            if (this.assigned == 2 && data.dwRequestID == (uint)FSXObject.DATA_REQUESTS.NAVCOM2_REQ) {
354
            if (this.assigned == 2 && data.dwRequestID == (uint)FSXObject.DATA_REQUESTS.NAVCOM2_REQ) {
337
                FSXObject.NavCom_Data navcomdata = (FSXObject.NavCom_Data)data.dwData[0];
355
                FSXObject.NavCom_Data navcomdata = (FSXObject.NavCom_Data)data.dwData[0];
338
                this.setNavComFreqs(navcomdata);
356
                this.setNavComFreqs(navcomdata);
339
            }
357
            }
340
 
358
 
341
        }
359
        }     
342
 
-
 
343
        public override void FsxReady() {
-
 
344
 
-
 
345
        }
-
 
346
        
-
 
347
 
360
 
348
        // @TODO: Make this work with COMM1/COMM2
-
 
349
        public override void SimButtons() {
361
        public override void SimButtons() {
350
 
362
 
351
            if (this.simStatus != 0)
363
            if (this.simStatus != 0)
352
                return;
364
                return;
353
 
365