Subversion Repositories group.NITPanels

Rev

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

Rev 7 Rev 11
Line 69... Line 69...
69
            this.resetAllRotary();
69
            this.resetAllRotary();
70
 
70
 
71
            this.flipcomm = 0;
71
            this.flipcomm = 0;
72
            this.flipnav = 0;
72
            this.flipnav = 0;
73
 
73
 
74
            this.simStatus = 0;
74
            this.simStatus = 2;
75
            this.assigned = 1;
75
            this.assigned = 1;
76
 
76
 
77
            this.comStatus = 0;
77
            this.comStatus = 0;
78
            this.navAvailable = true;
78
            this.navAvailable = true;
79
            this.avionicsMaster = false;
79
            this.avionicsMaster = false;
Line 109... Line 109...
109
        }
109
        }
110
 
110
 
111
        public void powerDown() {
111
        public void powerDown() {
112
            this.simStatus = 2;
112
            this.simStatus = 2;
113
            this.resetAllRotary();
113
            this.resetAllRotary();
-
 
114
 
114
            this.blankDisplay();
115
            this.blankDisplay();
115
            this.inputTimer.Enabled = false;
116
            this.inputTimer.Enabled = false;
116
        }
117
        }
117
 
118
 
118
        public void powerUp() {
119
        public void powerUp() {
119
            this.simStatus = 0;
120
            this.simStatus = 0;
120
            this.resetAllRotary();
121
            this.resetAllRotary();
121
            this.inputTimer.Enabled = true;
122
            this.inputTimer.Enabled = true;
-
 
123
 
-
 
124
            this.points[0] = 0x0084;
-
 
125
            this.points[1] = 0x0084;
-
 
126
 
-
 
127
            this.sendPoints();
122
            
128
           
123
            if (this.assigned == 1)
129
            if (this.assigned == 1)
124
                this.fsx.requestNavComm1Data();
130
                this.fsx.requestNavComm1Data();
125
            else if (this.assigned == 2)
131
            else if (this.assigned == 2)
126
                this.fsx.requestNavComm2Data();
132
                this.fsx.requestNavComm2Data();
127
        }
133
        }
Line 130... Line 136...
130
            byte[] blank = { 0x0a, 0x0a, 0x0a, 0x0a, 0x0a };
136
            byte[] blank = { 0x0a, 0x0a, 0x0a, 0x0a, 0x0a };
131
            for (byte i = 0; i < 4; i++)
137
            for (byte i = 0; i < 4; i++)
132
                setFreq(i, ref blank);
138
                setFreq(i, ref blank);
133
            this.points[0] = 0x0000;
139
            this.points[0] = 0x0000;
134
            this.points[1] = 0x0000;
140
            this.points[1] = 0x0000;
-
 
141
            this.sendPoints();
135
            this.UpdateDisplay();
142
            this.UpdateDisplay();
136
        }
143
        }
137
 
144
 
138
        public byte[] getFreq(byte freq) {
145
        public byte[] getFreq(byte freq) {
139
            byte[] ret = new byte[5];
146
            byte[] ret = new byte[5];
Line 199... Line 206...
199
                bytes[i] = (byte)(digits[i] - '0');
206
                bytes[i] = (byte)(digits[i] - '0');
200
            }
207
            }
201
            return bytes;
208
            return bytes;
202
        }
209
        }
203
 
210
 
-
 
211
        private void sendData(byte dis) {
-
 
212
            for (byte i = 0; i < 10; i++) {
-
 
213
                this.sendDigit(dis, i, display[dis, i]);
-
 
214
            }
-
 
215
        }
-
 
216
 
-
 
217
        public void UpdateDisplay() {
-
 
218
            this.sendData(0);
-
 
219
            this.latchDisplay(0);
-
 
220
            this.sendData(1);
-
 
221
            this.latchDisplay(1);
-
 
222
            
-
 
223
        }
-
 
224
 
-
 
225
        public void UpdateDisplay(byte dis) {
-
 
226
            this.sendData(dis);
-
 
227
            this.latchDisplay(dis);
-
 
228
        }
-
 
229
 
204
        public void setDisplay(byte dis, ref byte[] data) {
230
        public void setDisplay(byte dis, ref byte[] data) {
205
            for (byte i = 0; i < data.Length; i++) {
231
            for (byte i = 0; i < data.Length; i++) {
206
                display[dis, i] = data[i];
232
                display[dis, i] = data[i];
207
            }
233
            }
208
        }
234
        }
209
 
235
 
210
        private void sendDigit(byte dis, byte dig, byte val, byte dp) {
236
        private void sendDigit(byte dis, byte dig, byte val) {
211
            ushort wxValue = (ushort)(dis <<8);
237
            ushort wxValue = (ushort)(dis <<8);
212
            wxValue |= dig;
238
            wxValue |= dig;
213
            ushort wxIndex = (ushort)(dp << 8);
-
 
214
            wxIndex |= val;
239
            ushort wxIndex = val;
215
 
240
 
216
            base.SendCommand(21, (short)wxValue, (short)wxIndex);
241
            base.SendCommand(21, (short)wxValue, (short)wxIndex);
217
        }
242
        }
218
 
243
 
-
 
244
        private void sendPoints() {
-
 
245
            //ushort wxValue = (ushort)();
-
 
246
            //ushort wxIndex = (ushort)();
-
 
247
 
-
 
248
            base.SendCommand(23, (short)this.points[0], (short)this.points[1]);
-
 
249
        }
-
 
250
 
219
        private void sendLatch(byte dis) {
251
        private void sendLatch(byte dis) {
220
            if (!this.isOpen())
252
            if (!this.isOpen())
221
                return;
253
                return;
222
 
254
 
223
            base.SendCommand(20, (short)dis, 0);
255
            base.SendCommand(20, (short)dis, 0);
Line 258... Line 290...
258
            this.rotary[0, 1] = 0x00;
290
            this.rotary[0, 1] = 0x00;
259
            this.rotary[1, 0] = 0x00;
291
            this.rotary[1, 0] = 0x00;
260
            this.rotary[1, 1] = 0x00;
292
            this.rotary[1, 1] = 0x00;
261
        }
293
        }
262
 
294
 
263
        private void sendData(byte dis) {
-
 
264
            for (byte i = 0; i < 10; i++) {
-
 
265
                //this.sendDigit(dis, i, display[dis, i], this.GetBit(this.points[dis], i));
-
 
266
                this.sendDigit(dis, i, display[dis, i], 0);
-
 
267
            }            
-
 
268
        }
-
 
269
 
-
 
270
        public void UpdateDisplay() {
-
 
271
            this.sendData(0);
-
 
272
            this.latchDisplay(0);
-
 
273
            this.sendData(1);
-
 
274
            this.latchDisplay(1);
-
 
275
        }
-
 
276
 
-
 
277
        public void UpdateDisplay(byte dis) {
-
 
278
            this.sendData(dis);
-
 
279
            this.latchDisplay(dis);
-
 
280
        }
-
 
281
 
-
 
282
        private byte GetBit(ushort b, byte bitNumber) {
295
        private byte GetBit(ushort b, byte bitNumber) {
283
            if ((b & (1 << bitNumber)) != 0)
296
            if ((b & (1 << bitNumber)) != 0)
284
                return 1;
297
                return 1;
285
            return 0;
298
            return 0;
286
        }
299
        }
Line 301... Line 314...
301
                this.setFreq(2, ref right);
314
                this.setFreq(2, ref right);
302
                this.setFreq(3, ref left);
315
                this.setFreq(3, ref left);
303
            }
316
            }
304
        }
317
        }
305
 
318
 
306
        // @TODO: Remove these, not unneeded
-
 
307
        public override void FsxInit() { }
-
 
308
        public override void MapEvents() { }
-
 
309
 
-
 
310
        public override void FsxReady() {
319
        public override void FsxReady() {
311
            this.powerUp();
320
            this.powerUp();
312
        }
321
        }
313
 
322
 
314
        public override void reAssign() {
323
        public override void reAssign() {
Line 324... Line 333...
324
        //public override void FsxClose() {
333
        //public override void FsxClose() {
325
        //    this.powerDown();
334
        //    this.powerDown();
326
        //}
335
        //}
327
 
336
 
328
        public override void FsxEvent(SIMCONNECT_RECV_SIMOBJECT_DATA data) {
337
        public override void FsxEvent(SIMCONNECT_RECV_SIMOBJECT_DATA data) {
329
 
-
 
330
            if (data.dwRequestID == (uint)FSXObject.DATA_REQUESTS.AVIONICS) {
338
            if (data.dwRequestID == (uint)FSXObject.DATA_REQUESTS.AVIONICS) {
331
                
339
                
332
                FSXObject.Avionics_Data avionics = (FSXObject.Avionics_Data)data.dwData[0];
340
                FSXObject.Avionics_Data avionics = (FSXObject.Avionics_Data)data.dwData[0];
333
                
341
                
334
                this.avionicsMaster = avionics.avionics_master;
342
                this.avionicsMaster = avionics.avionics_master;
Line 364... Line 372...
364
            if (this.assigned == 2 && data.dwRequestID == (uint)FSXObject.DATA_REQUESTS.NAVCOM2_REQ) {
372
            if (this.assigned == 2 && data.dwRequestID == (uint)FSXObject.DATA_REQUESTS.NAVCOM2_REQ) {
365
                FSXObject.NavCom_Data navcomdata = (FSXObject.NavCom_Data)data.dwData[0];
373
                FSXObject.NavCom_Data navcomdata = (FSXObject.NavCom_Data)data.dwData[0];
366
                this.setNavComFreqs(navcomdata);
374
                this.setNavComFreqs(navcomdata);
367
            }
375
            }
368
 
376
 
-
 
377
 
369
        }     
378
        }     
370
 
379
 
371
        public override void SimButtons() {
380
        public override void SimButtons() {
372
 
-
 
-
 
381
            this.inputTimer.Enabled = false;
373
            if (this.simStatus != 0)
382
            if (this.simStatus != 0)
374
                return;
383
                return;
375
 
384
 
376
            this.updateInput();
385
            this.updateInput();
377
            
386
            
Line 451... Line 460...
451
                        if (this.assigned == 1)
460
                        if (this.assigned == 1)
452
                            fsx.Nav1DecWhole();
461
                            fsx.Nav1DecWhole();
453
                        else
462
                        else
454
                            fsx.Nav2DecWhole();
463
                            fsx.Nav2DecWhole();
455
                } else {
464
                } else {
456
 
-
 
457
                    if (this.flipcomm == 1)
465
                        if (this.flipnav == 1)
458
                        if (this.assigned == 1)
466
                            if (this.assigned == 1)
459
                            fsx.Nav1IncFract();
467
                                fsx.Nav1IncFract();
460
                        else
468
                            else
461
                            fsx.Nav2IncFract();
469
                                fsx.Nav2IncFract();
462
                    else
-
 
463
                        if (this.assigned == 1)
-
 
464
                            fsx.Nav1IncWhole();
-
 
465
                        else
470
                        else
-
 
471
                            if (this.assigned == 1)
-
 
472
                                fsx.Nav1IncWhole();
-
 
473
                            else
466
                            fsx.Nav2IncWhole();
474
                                fsx.Nav2IncWhole();
467
                }
475
                }
468
            }
476
            }
469
 
-
 
-
 
477
            this.inputTimer.Enabled = true;
470
        }
478
        } // End SimButtons
471
    }
479
    }
472
}
480
}