Subversion Repositories group.electronics

Rev

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

Rev 155 Rev 156
Line 15... Line 15...
15
 
15
 
16
        public enum DATA_REQUESTS {
16
        public enum DATA_REQUESTS {
17
            AIRCRAFT,
17
            AIRCRAFT,
18
            AVIONICS,
18
            AVIONICS,
19
            NAVCOM1_REQ,
19
            NAVCOM1_REQ,
20
            NAVCOM2_REQ
20
            NAVCOM2_REQ,
-
 
21
            AUDIOSEL_REQ
21
        }
22
        }
22
 
23
 
23
        public enum DEFINITIONS {
24
        public enum DEFINITIONS {
24
            AIRCRAFT,
25
            AIRCRAFT,
25
            AVIONICS,
26
            AVIONICS,
26
            NAVCOM1_DATA,
27
            NAVCOM1_DATA,
27
            NAVCOM2_DATA
28
            NAVCOM2_DATA,
-
 
29
            AUDIOSEL_DATA
28
        }
30
        }
29
 
31
 
30
        public enum EVENT_ID {
32
        public enum EVENT_ID {
-
 
33
            // AudioSel Events, these go first to make mapping easy (0-7)
-
 
34
            COM1_TRANSMIT_SELECT,
-
 
35
            COM2_TRANSMIT_SELECT,
-
 
36
            COM_RECEIVE_ALL_TOGGLE,
-
 
37
            RADIO_VOR1_IDENT_TOGGLE,
-
 
38
            RADIO_VOR2_IDENT_TOGGLE,
-
 
39
            MARKER_SOUND_TOGGLE,
-
 
40
            RADIO_DME1_IDENT_TOGGLE,
-
 
41
            RADIO_ADF_IDENT_TOGGLE,
-
 
42
 
-
 
43
            // NavCom1 Events
31
            COM1_SWAP_FREQ,
44
            COM1_SWAP_FREQ,
32
            NAV1_SWAP_FREQ,
45
            NAV1_SWAP_FREQ,
33
            COM_RADIO_WHOLE_INC,
46
            COM_RADIO_WHOLE_INC,
34
            COM_RADIO_WHOLE_DEC,
47
            COM_RADIO_WHOLE_DEC,
35
            COM_RADIO_FRACT_INC,
48
            COM_RADIO_FRACT_INC,
36
            COM_RADIO_FRACT_DEC,
49
            COM_RADIO_FRACT_DEC,
37
            NAV1_RADIO_WHOLE_INC,
50
            NAV1_RADIO_WHOLE_INC,
38
            NAV1_RADIO_WHOLE_DEC,
51
            NAV1_RADIO_WHOLE_DEC,
39
            NAV1_RADIO_FRACT_INC,
52
            NAV1_RADIO_FRACT_INC,
40
            NAV1_RADIO_FRACT_DEC,
53
            NAV1_RADIO_FRACT_DEC,
-
 
54
 
-
 
55
            // NavComm2 Events
41
            COM2_SWAP_FREQ,
56
            COM2_SWAP_FREQ,
42
            NAV2_SWAP_FREQ,
57
            NAV2_SWAP_FREQ,
43
            COM2_RADIO_WHOLE_INC,
58
            COM2_RADIO_WHOLE_INC,
44
            COM2_RADIO_WHOLE_DEC,
59
            COM2_RADIO_WHOLE_DEC,
45
            COM2_RADIO_FRACT_INC,
60
            COM2_RADIO_FRACT_INC,
46
            COM2_RADIO_FRACT_DEC,
61
            COM2_RADIO_FRACT_DEC,
47
            NAV2_RADIO_WHOLE_INC,
62
            NAV2_RADIO_WHOLE_INC,
48
            NAV2_RADIO_WHOLE_DEC,
63
            NAV2_RADIO_WHOLE_DEC,
49
            NAV2_RADIO_FRACT_INC,
64
            NAV2_RADIO_FRACT_INC,
50
            NAV2_RADIO_FRACT_DEC,
65
            NAV2_RADIO_FRACT_DEC,
-
 
66
 
51
        }
67
        }
52
 
68
 
53
        public enum GROUP_ID {
69
        public enum GROUP_ID {
54
            NAVCOM1,
70
            NAVCOM1,
55
            NAVCOM2
71
            NAVCOM2,
-
 
72
            AUDIOSEL
56
        }
73
        }
57
 
74
 
58
        public struct SimData {
75
        public struct SimData {
59
            public uint objectid;
76
            public uint objectid;
60
            public Aircraft_Data aircraft;
77
            public Aircraft_Data aircraft;
Line 67... Line 84...
67
            public double Freq2;
84
            public double Freq2;
68
            public double Freq3;
85
            public double Freq3;
69
        }
86
        }
70
 
87
 
71
        [StructLayout(LayoutKind.Sequential, Pack = 1)]
88
        [StructLayout(LayoutKind.Sequential, Pack = 1)]
-
 
89
        public struct AudioSel_Data {
-
 
90
            public double com1;
-
 
91
            public double com2;
-
 
92
            public double comb;
-
 
93
            public double vor1;
-
 
94
            public double vor2;
-
 
95
            public double mkr;
-
 
96
            public double dme;
-
 
97
            public double adf;
-
 
98
        }
-
 
99
 
-
 
100
        [StructLayout(LayoutKind.Sequential, Pack = 1)]
72
        public struct Avionics_Data {
101
        public struct Avionics_Data {
73
            public bool avionics_master;
102
            public bool avionics_master;
74
            public double com1_status;
103
            public double com1_status;
75
            public double com2_status;
104
            public double com2_status;
-
 
105
            public bool nav1_available;
-
 
106
            public bool nav2_available;
76
        }
107
        }
77
 
108
 
78
        [StructLayout(LayoutKind.Sequential, Pack = 1)]
109
        [StructLayout(LayoutKind.Sequential, Pack = 1)]
79
        public struct Aircraft_Data {
110
        public struct Aircraft_Data {
80
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
111
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
Line 89... Line 120...
89
 
120
 
90
        public FSXObject() {
121
        public FSXObject() {
91
            this.simdata = new SimData();
122
            this.simdata = new SimData();
92
        }
123
        }
93
 
124
 
94
        public void Comm1DecFract() {
125
        private void transmitEvent(Enum eventid, Enum groupid) {
-
 
126
            this.transmitEvent(eventid, groupid, 1);
-
 
127
        }
-
 
128
 
-
 
129
        private void transmitEvent(Enum eventid, Enum groupid, uint data) {
95
            this.hSimConnect.TransmitClientEvent(
130
            this.hSimConnect.TransmitClientEvent(
96
                this.simdata.objectid,
131
                this.simdata.objectid,
97
                FSXObject.EVENT_ID.COM_RADIO_FRACT_DEC, 1,
-
 
98
                FSXObject.GROUP_ID.NAVCOM1,
132
                eventid, data, groupid,
99
                SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
133
                SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
100
            );
134
            );
101
        }
135
        }
102
 
136
 
103
        public void Comm1DecWhole() {
137
        private void requestData(Enum dataRequest, Enum definition) {
104
            this.hSimConnect.TransmitClientEvent(
138
            hSimConnect.RequestDataOnSimObject(
-
 
139
                dataRequest,
-
 
140
                definition,
105
                this.simdata.objectid,
141
                this.simdata.objectid,
106
                FSXObject.EVENT_ID.COM_RADIO_WHOLE_DEC, 1,
142
                SIMCONNECT_PERIOD.ONCE,
107
                FSXObject.GROUP_ID.NAVCOM1,
143
                SIMCONNECT_DATA_REQUEST_FLAG.DEFAULT,
-
 
144
                0, 0, 0);
-
 
145
        }
-
 
146
 
-
 
147
        // Individual data requests
-
 
148
        public void requestNavComm1Data() {
-
 
149
            this.requestData(FSXObject.DATA_REQUESTS.NAVCOM1_REQ, FSXObject.DEFINITIONS.NAVCOM1_DATA);
-
 
150
        }
-
 
151
 
-
 
152
        public void requestNavComm2Data() {
-
 
153
            this.requestData(FSXObject.DATA_REQUESTS.NAVCOM2_REQ, FSXObject.DEFINITIONS.NAVCOM2_DATA);
-
 
154
        }
-
 
155
 
-
 
156
        public void requestAudioSelData() {
-
 
157
            this.requestData(FSXObject.DATA_REQUESTS.AUDIOSEL_REQ, FSXObject.DEFINITIONS.AUDIOSEL_DATA);
-
 
158
        }
-
 
159
 
-
 
160
        // AudioSel Events
-
 
161
        public void AudioSelButton(int button) {
108
                SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
162
            this.transmitEvent((FSXObject.EVENT_ID)button, FSXObject.GROUP_ID.AUDIOSEL);
-
 
163
        }
-
 
164
 
-
 
165
 
-
 
166
        // NavComm1 Events
-
 
167
        public void Comm1DecFract() {
-
 
168
            this.transmitEvent(FSXObject.EVENT_ID.COM_RADIO_FRACT_DEC, FSXObject.GROUP_ID.NAVCOM1);
109
            );
169
        }
-
 
170
 
-
 
171
        public void Comm1DecWhole() {
-
 
172
            this.transmitEvent(FSXObject.EVENT_ID.COM_RADIO_WHOLE_DEC, FSXObject.GROUP_ID.NAVCOM1);
110
        }
173
        }
111
 
174
 
112
        public void Comm1IncFract() {
175
        public void Comm1IncFract() {
113
            this.hSimConnect.TransmitClientEvent(
-
 
114
                this.simdata.objectid,
-
 
115
                FSXObject.EVENT_ID.COM_RADIO_FRACT_INC, 1,
176
            this.transmitEvent(FSXObject.EVENT_ID.COM_RADIO_FRACT_INC, FSXObject.GROUP_ID.NAVCOM1);
116
                FSXObject.GROUP_ID.NAVCOM1,
-
 
117
                SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
-
 
118
            );
-
 
119
        }
177
        }
120
 
178
 
121
        public void Comm1IncWhole() {
179
        public void Comm1IncWhole() {
122
            this.hSimConnect.TransmitClientEvent(
-
 
123
                this.simdata.objectid,
-
 
124
                FSXObject.EVENT_ID.COM_RADIO_WHOLE_INC, 1,
180
            this.transmitEvent(FSXObject.EVENT_ID.COM_RADIO_WHOLE_INC, FSXObject.GROUP_ID.NAVCOM1);
125
                FSXObject.GROUP_ID.NAVCOM1,
-
 
126
                SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
-
 
127
            );
-
 
128
        }
181
        }
129
 
182
 
130
        public void Comm1SwapFreq() {
183
        public void Comm1SwapFreq() {
131
            this.hSimConnect.TransmitClientEvent(
-
 
132
                this.simdata.objectid,
-
 
133
                FSXObject.EVENT_ID.COM1_SWAP_FREQ, 1,
184
            this.transmitEvent(FSXObject.EVENT_ID.COM1_SWAP_FREQ, FSXObject.GROUP_ID.NAVCOM1);
134
                FSXObject.GROUP_ID.NAVCOM1,
-
 
135
                SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
-
 
136
            );
-
 
137
        }
185
        }
138
 
186
 
139
        public void Nav1DecFract() {
187
        public void Nav1DecFract() {
140
            this.hSimConnect.TransmitClientEvent(
-
 
141
                this.simdata.objectid,
-
 
142
                FSXObject.EVENT_ID.NAV1_RADIO_FRACT_DEC, 1,
188
            this.transmitEvent(FSXObject.EVENT_ID.NAV1_RADIO_FRACT_DEC, FSXObject.GROUP_ID.NAVCOM1);
143
                FSXObject.GROUP_ID.NAVCOM1,
-
 
144
                SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
-
 
145
            );
-
 
146
        }
189
        }
147
 
190
 
148
        public void Nav1DecWhole() {
191
        public void Nav1DecWhole() {
149
            this.hSimConnect.TransmitClientEvent(
-
 
150
                this.simdata.objectid,
-
 
151
                FSXObject.EVENT_ID.NAV1_RADIO_WHOLE_DEC, 1,
192
            this.transmitEvent(FSXObject.EVENT_ID.NAV1_RADIO_WHOLE_DEC, FSXObject.GROUP_ID.NAVCOM1);
152
                FSXObject.GROUP_ID.NAVCOM1,
-
 
153
                SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
-
 
154
            );
-
 
155
        }
193
        }
156
 
194
 
157
        public void Nav1IncFract() {
195
        public void Nav1IncFract() {
158
            this.hSimConnect.TransmitClientEvent(
-
 
159
                this.simdata.objectid,
-
 
160
                FSXObject.EVENT_ID.NAV1_RADIO_FRACT_INC, 1,
196
            this.transmitEvent(FSXObject.EVENT_ID.NAV1_RADIO_FRACT_INC, FSXObject.GROUP_ID.NAVCOM1);
161
                FSXObject.GROUP_ID.NAVCOM1,
-
 
162
                SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
-
 
163
            );
-
 
164
        }
197
        }
165
 
198
 
166
        public void Nav1IncWhole() {
199
        public void Nav1IncWhole() {
167
            this.hSimConnect.TransmitClientEvent(
-
 
168
                this.simdata.objectid,
-
 
169
                FSXObject.EVENT_ID.NAV1_RADIO_WHOLE_INC, 1,
200
            this.transmitEvent(FSXObject.EVENT_ID.NAV1_RADIO_WHOLE_INC, FSXObject.GROUP_ID.NAVCOM1);
170
                FSXObject.GROUP_ID.NAVCOM1,
-
 
171
                SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
-
 
172
            );
-
 
173
        }
201
        }
174
 
202
 
175
        public void Nav1SwapFreq() {
203
        public void Nav1SwapFreq() {
176
            this.hSimConnect.TransmitClientEvent(
-
 
177
                this.simdata.objectid,
-
 
178
                FSXObject.EVENT_ID.NAV1_SWAP_FREQ, 1,
204
            this.transmitEvent(FSXObject.EVENT_ID.NAV1_SWAP_FREQ, FSXObject.GROUP_ID.NAVCOM1);
179
                FSXObject.GROUP_ID.NAVCOM1,
-
 
180
                SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
-
 
181
            );
-
 
182
        }
205
        }
183
 
206
 
184
 
207
 
185
 
-
 
186
 
-
 
-
 
208
        // NavComm2 Events
187
        public void Comm2DecFract() {
209
        public void Comm2DecFract() {
188
            this.hSimConnect.TransmitClientEvent(
-
 
189
                this.simdata.objectid,
-
 
190
                FSXObject.EVENT_ID.COM2_RADIO_FRACT_DEC, 1,
210
            this.transmitEvent(FSXObject.EVENT_ID.COM2_RADIO_FRACT_DEC, FSXObject.GROUP_ID.NAVCOM2);
191
                FSXObject.GROUP_ID.NAVCOM2,
-
 
192
                SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
-
 
193
            );
-
 
194
        }
211
        }
195
 
212
 
196
        public void Comm2DecWhole() {
213
        public void Comm2DecWhole() {
197
            this.hSimConnect.TransmitClientEvent(
-
 
198
                this.simdata.objectid,
-
 
199
                FSXObject.EVENT_ID.COM2_RADIO_WHOLE_DEC, 1,
214
            this.transmitEvent(FSXObject.EVENT_ID.COM2_RADIO_WHOLE_DEC, FSXObject.GROUP_ID.NAVCOM2);
200
                FSXObject.GROUP_ID.NAVCOM2,
-
 
201
                SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
-
 
202
            );
-
 
203
        }
215
        }
204
 
216
 
205
        public void Comm2IncFract() {
217
        public void Comm2IncFract() {
206
            this.hSimConnect.TransmitClientEvent(
-
 
207
                this.simdata.objectid,
-
 
208
                FSXObject.EVENT_ID.COM2_RADIO_FRACT_INC, 1,
218
            this.transmitEvent(FSXObject.EVENT_ID.COM2_RADIO_FRACT_INC, FSXObject.GROUP_ID.NAVCOM2);
209
                FSXObject.GROUP_ID.NAVCOM2,
-
 
210
                SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
-
 
211
            );
-
 
212
        }
219
        }
213
 
220
 
214
        public void Comm2IncWhole() {
221
        public void Comm2IncWhole() {
215
            this.hSimConnect.TransmitClientEvent(
-
 
216
                this.simdata.objectid,
-
 
217
                FSXObject.EVENT_ID.COM2_RADIO_WHOLE_INC, 1,
222
            this.transmitEvent(FSXObject.EVENT_ID.COM2_RADIO_WHOLE_INC, FSXObject.GROUP_ID.NAVCOM2);
218
                FSXObject.GROUP_ID.NAVCOM2,
-
 
219
                SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
-
 
220
            );
-
 
221
        }
223
        }
222
 
224
 
223
        public void Comm2SwapFreq() {
225
        public void Comm2SwapFreq() {
224
            this.hSimConnect.TransmitClientEvent(
-
 
225
                this.simdata.objectid,
-
 
226
                FSXObject.EVENT_ID.COM2_SWAP_FREQ, 1,
226
            this.transmitEvent(FSXObject.EVENT_ID.COM2_SWAP_FREQ, FSXObject.GROUP_ID.NAVCOM2);
227
                FSXObject.GROUP_ID.NAVCOM2,
-
 
228
                SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
-
 
229
            );
-
 
230
        }
227
        }
231
 
228
 
232
        public void Nav2DecFract() {
229
        public void Nav2DecFract() {
233
            this.hSimConnect.TransmitClientEvent(
-
 
234
                this.simdata.objectid,
-
 
235
                FSXObject.EVENT_ID.NAV2_RADIO_FRACT_DEC, 1,
230
            this.transmitEvent(FSXObject.EVENT_ID.NAV2_RADIO_FRACT_DEC, FSXObject.GROUP_ID.NAVCOM2);
236
                FSXObject.GROUP_ID.NAVCOM1,
-
 
237
                SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
-
 
238
            );
-
 
239
        }
231
        }
240
 
232
 
241
        public void Nav2DecWhole() {
233
        public void Nav2DecWhole() {
242
            this.hSimConnect.TransmitClientEvent(
-
 
243
                this.simdata.objectid,
-
 
244
                FSXObject.EVENT_ID.NAV2_RADIO_WHOLE_DEC, 1,
234
            this.transmitEvent(FSXObject.EVENT_ID.NAV2_RADIO_WHOLE_DEC, FSXObject.GROUP_ID.NAVCOM2);
245
                FSXObject.GROUP_ID.NAVCOM2,
-
 
246
                SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
-
 
247
            );
-
 
248
        }
235
        }
249
 
236
 
250
        public void Nav2IncFract() {
237
        public void Nav2IncFract() {
251
            this.hSimConnect.TransmitClientEvent(
-
 
252
                this.simdata.objectid,
-
 
253
                FSXObject.EVENT_ID.NAV2_RADIO_FRACT_INC, 1,
238
            this.transmitEvent(FSXObject.EVENT_ID.NAV2_RADIO_FRACT_INC, FSXObject.GROUP_ID.NAVCOM2);
254
                FSXObject.GROUP_ID.NAVCOM2,
-
 
255
                SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
-
 
256
            );
-
 
257
        }
239
        }
258
 
240
 
259
        public void Nav2IncWhole() {
241
        public void Nav2IncWhole() {
260
            this.hSimConnect.TransmitClientEvent(
-
 
261
                this.simdata.objectid,
-
 
262
                FSXObject.EVENT_ID.NAV2_RADIO_WHOLE_INC, 1,
242
            this.transmitEvent(FSXObject.EVENT_ID.NAV2_RADIO_WHOLE_INC, FSXObject.GROUP_ID.NAVCOM2);
263
                FSXObject.GROUP_ID.NAVCOM2,
-
 
264
                SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
-
 
265
            );
-
 
266
        }
243
        }
267
 
244
 
268
        public void Nav2SwapFreq() {
245
        public void Nav2SwapFreq() {
269
            this.hSimConnect.TransmitClientEvent(
-
 
270
                this.simdata.objectid,
-
 
271
                FSXObject.EVENT_ID.NAV2_SWAP_FREQ, 1,
246
            this.transmitEvent(FSXObject.EVENT_ID.NAV2_SWAP_FREQ, FSXObject.GROUP_ID.NAVCOM2);
272
                FSXObject.GROUP_ID.NAVCOM2,
-
 
273
                SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
-
 
274
            );
-
 
275
        }
247
        }
-
 
248
 
-
 
249
 
-
 
250
 
276
    }
251
    }
277
}
252
}