-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDCS.MH-60R.hif.lua
More file actions
435 lines (414 loc) · 16 KB
/
DCS.MH-60R.hif.lua
File metadata and controls
435 lines (414 loc) · 16 KB
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
-- Exports.Lua from Helios MH-60R interface
-- "source": "Helios",
-- Version: 1.6.6160.0000
-- Commit: f114afb9621c70d0211b82d84cb4664ab140dec4
-- "type": "DCS",
-- "name": "DCS H-60 (MH-60R Seahawk)",
-- "module": "MH-60R",
-- "vehicles": [
-- "MH-60R"
driver.state = {}
function driver.processHighImportance(mainPanelDevice)
-- Pilot VSI ball combined movement values
helios.send(2049, string.format("%0.3f;0.0;%0.3f", mainPanelDevice:get_argument_value(420), mainPanelDevice:get_argument_value(421)))
-- Copilot VSI ball combined movement values
helios.send(2050, string.format("%0.3f;0.0;%0.3f", mainPanelDevice:get_argument_value(433), mainPanelDevice:get_argument_value(434)))
-- Pilot Barometric Altimeter
helios.send(
2051,
string.format(
"%0.4f;%0.4f;%0.4f",
mainPanelDevice:get_argument_value(62),
mainPanelDevice:get_argument_value(61),
mainPanelDevice:get_argument_value(60)
)
)
helios.send(
2052,
string.format(
"%0.2f;%0.2f;%0.2f;%0.3f",
mainPanelDevice:get_argument_value(64),
mainPanelDevice:get_argument_value(65),
mainPanelDevice:get_argument_value(66),
mainPanelDevice:get_argument_value(67)
)
)
-- Copilot Barometric Altimeter
helios.send(
2053,
string.format(
"%0.4f;%0.4f;%0.4f",
mainPanelDevice:get_argument_value(72),
mainPanelDevice:get_argument_value(71),
mainPanelDevice:get_argument_value(70)
)
)
helios.send(
2054,
string.format(
"%0.2f;%0.2f;%0.2f;%0.3f",
mainPanelDevice:get_argument_value(74),
mainPanelDevice:get_argument_value(75),
mainPanelDevice:get_argument_value(76),
mainPanelDevice:get_argument_value(77)
)
)
-- Pilot RADAR Altimeter
helios.send(
2055,
string.format(
"%0.2f;%0.2f;%0.2f;%0.3f",
mainPanelDevice:get_argument_value(174),
mainPanelDevice:get_argument_value(175),
mainPanelDevice:get_argument_value(176),
mainPanelDevice:get_argument_value(177)
)
)
-- Copilot RADAR Altimeter
helios.send(
2056,
string.format(
"%0.2f;%0.2f;%0.2f;%0.3f",
mainPanelDevice:get_argument_value(187),
mainPanelDevice:get_argument_value(188),
mainPanelDevice:get_argument_value(189),
mainPanelDevice:get_argument_value(190)
)
)
end
driver.UH60Lindicator = {{{0,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,1000,1050,1100,1150,1200,1250,1300,1350,1400,1450},
{0,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,1000,1050,1100,1150,1200,1250,1300,1350,1400,1450},
{-50,-40,-30,-20,-10,0,10,20,30,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120,130,140,150,160},
{0,5,10,15,20,25,30,32.5,35,37.5,40,42.5,45,47.5,50,52.5,55,57.5,60,62.5,65,67.5,70,80,90,100,110,130,150,170},
{-50,-40,-30,-20,-10,0,10,20,30,40,50,60,70,75,80,85,90,95,100,105,110,115,120,125,130,135,150,160,170},
{-50,-40,-30,-20,-10,0,10,20,30,40,50,60,70,75,80,85,90,95,100,105,110,115,120,125,130,135,150,160,170},
{10,15,20,25,30,35,40,42.5,45,47.5,50,52.5,55,57.5,60,62.5,65,67.5,70,72.5,75,77.5,80,82.5,85,87.5,90,100,110,120},
{10,15,20,25,30,35,40,42.5,45,47.5,50,52.5,55,57.5,60,62.5,65,67.5,70,72.5,75,77.5,80,82.5,85,87.5,90,100,110,120},
{0,50,100,150,200,250,300,350,400,425,450,475,500,525,550,575,600,625,650,675,700,725,750,775,800,825,850,875,900,925},
{0,50,100,150,200,250,300,350,400,425,450,475,500,525,550,575,600,625,650,675,700,725,750,775,800,825,850,875,900,925},
{0,10,20,30,40,45,50,55,60,65,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108},
{0,10,20,30,40,45,50,55,60,65,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108}},
{{0,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},
{0,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},
{0,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},
{0,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},
{0,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}},
{{0,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},
{0,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},
{0,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},
{0,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},
{0,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}}
}
driver.displayNames = {"TotalFuel","TGT1","TGT2","Ng1","Ng2","Torque1","Torque2"}
driver.state.indications = {}
function driver.processLowImportance(mainPanelDevice)
local li
do -- constrain variable scope
local results={}
-- Indicator 0 for the Center panel bar graphs and numeric displays
li = list_indication(0)
if li ~= driver.state.indications[0] then
local currentGaugeNumber = 1
local currentSegment = 1
local segNextValue = 9999
local segCursor = nil
local segStart = 0
local segNumberStart = 0
local displayNum = 0
--[[
We need to pull out twelve bar graphs and 5 numeric displays (the easy bit). There appears to be no delimiter
between the bar graphs, and several of them have non-linear scales which poses an additional challenge so we use
a table based approach to identify the specific gauge.
All of the temperatures start at their origins.
This routine relies on the bar graphs all appearing in the same order!
]]
local m = li:gmatch("-----------------------------------------\n([^\n]+)\n([^\n]*)\n")
while true do
local name, value = m()
if not name then
results["gauge" .. currentGaugeNumber] = string.format("%s;%s;%s;%s", segStart, helios.ensureString(segCursor), segNumberStart, currentSegment)
break
end
local seg = name:gsub("segment_","")
local segNumeric
if name == seg then
-- non segment ie numeric display data
if value ~= "" then
displayNum = displayNum + 1
results[driver.displayNames[displayNum]] = value
end
else
-- process a segment entry
segNumeric = tonumber(seg)
if segCursor == nil then -- first time processing a segement
segStart = segNumeric -- we must be a start entry
segCursor = segStart -- cursor set to the first segement
segNextValue = segStart
end
if segStart == segCursor and segNextValue == segStart then
for currSegment = 1,30,1 do
if segNumeric == driver.UH60Lindicator[1][currentGaugeNumber][currSegment] then
segNumberStart = currSegment
segNextValue = driver.UH60Lindicator[1][currentGaugeNumber][currSegment+1]
currentSegment = currSegment
break
end
end
else
if segNumeric == segNextValue then
currentSegment = currentSegment + 1
segNextValue = driver.UH60Lindicator[1][currentGaugeNumber][currentSegment+1]
segCursor = segNumeric
else
results["gauge" .. currentGaugeNumber] = string.format("%s;%s;%s;%s", segStart, segCursor, segNumberStart, currentSegment)
currentGaugeNumber = currentGaugeNumber + 1
for currSegment = 1,30,1 do
if segNumeric == driver.UH60Lindicator[1][currentGaugeNumber][currSegment] then
segNumberStart = currSegment
segNextValue = driver.UH60Lindicator[1][currentGaugeNumber][currSegment+1]
currentSegment = currSegment
break
end
end
segStart = segNumeric
segCursor = segStart
end
end
end
end
helios.send(2060,string.format("%s", helios.ensureString(results["TotalFuel"])))
helios.send(2061,string.format("%s", helios.ensureString(results["TGT1"])))
helios.send(2062,string.format("%s", helios.ensureString(results["TGT2"])))
helios.send(2063,string.format("%s", helios.ensureString(results["Ng1"])))
helios.send(2064,string.format("%s", helios.ensureString(results["Ng2"])))
for ii=1,12,1 do
if results["gauge"..ii] then
helios.send(2064+ii,string.format("%s", helios.ensureString(results["gauge"..ii]))) -- bar gauge
end
end
driver.state.indications[0] = li
end
end
for jj= 1,2,1 do
local results={}
-- Indicator 1 and 2 for the RPM and Torque bar graphs and numeric displays for Pilot and Copilot
li = list_indication(jj)
if li ~= driver.state.indications[jj] then
local currentGaugeNumber = 1
local currentSegment = 1
local segNextValue = 9999
local segCursor = nil
local segStart = 0
local segNumberStart = 0
local displayNum = 5
--[[
We need to pull out five bar graphs and 2 numeric displays. There appears to be no delimiter
between the bar graphs so we use a table based approach to identify the specific gauge.
This routine relies on the bar graphs all appearing in the same order!
]]
local m = li:gmatch("-----------------------------------------\n([^\n]+)\n([^\n]*)\n")
while true do
local name, value = m()
if not name then
results["gauge" .. currentGaugeNumber] = string.format("%s;%s;%s;%s", segStart, helios.ensureString(segCursor), segNumberStart, currentSegment)
break
end
local seg = name:gsub("segment_","")
local segNumeric
if name == seg then
-- non segment ie numeric display data
if value ~= "" then
displayNum = displayNum + 1
results[driver.displayNames[displayNum]] = value
end
else
-- process a segment entry
segNumeric = tonumber(seg)
if segCursor == nil then -- first time processing a segement
segStart = segNumeric -- we must be a start entry
segCursor = segStart -- cursor set to the first segement
segNextValue = segStart
end
if segStart == segCursor and segNextValue == segStart then
for currSegment = 1,30,1 do
if segNumeric == driver.UH60Lindicator[jj+1][currentGaugeNumber][currSegment] then
segNumberStart = currSegment
segNextValue = driver.UH60Lindicator[jj+1][currentGaugeNumber][currSegment+1]
currentSegment = currSegment
break
end
end
else
if segNumeric == segNextValue then
currentSegment = currentSegment + 1
segNextValue = driver.UH60Lindicator[jj+1][currentGaugeNumber][currentSegment+1]
segCursor = segNumeric
else
results["gauge" .. currentGaugeNumber] = string.format("%s;%s;%s;%s", segStart, segCursor, segNumberStart, currentSegment)
currentGaugeNumber = currentGaugeNumber + 1
for currSegment = 1,30,1 do
if segNumeric == driver.UH60Lindicator[jj+1][currentGaugeNumber][currSegment] then
segNumberStart = currSegment
segNextValue = driver.UH60Lindicator[jj+1][currentGaugeNumber][currSegment+1]
currentSegment = currSegment
break
end
end
segStart = segNumeric
segCursor = segStart
end
end
end
end
helios.send(2077+((jj-1)*7),string.format("%s", helios.ensureString(results["Torque1"])))
helios.send(2078+((jj-1)*7),string.format("%s", helios.ensureString(results["Torque2"])))
for ii=1,5,1 do
if results["gauge"..ii] then
helios.send(2078+((jj-1)*7)+ii,string.format("%s", helios.ensureString(results["gauge"..ii]))) -- bar gauge
end
end
driver.state.indications[jj] = li
end
end
do
jj = 5
local results={}
-- Indicator 5 for the nav computer
li = list_indication(jj)
if li ~= driver.state.indications[jj] then
local z = li:gmatch("-----------------------------------------\n([^\n]+)\n([^\n]*)\n")
local currentLine = 0
while true do
local name, value = z()
if not name then
break
end
if value ~= "" then
if currentLine < 4 then
results["Line"..currentLine]= string.format("%-16s",value)
currentLine = currentLine + 1
else
if value == "end" or value == "more" then
results["Line3"] = string.format("%-12s%4s",results["Line3"]:sub(1,12),value)
else
results["Line1"] = string.format("%-11s%5s",results["Line1"]:sub(1,11),value)
end
end
end
end
for ii=0,3,1 do
if results["Line"..ii] then
helios.send(2091+ii,string.format("%-16s", helios.ensureString(results["Line"..ii]:gsub(":","!"))))
end
end
driver.state.indications[jj] = li
end
end
for jj = 6,7,1 do
-- These are the two chronographs Reserve 4 codes for each Codes run 2095 - 2103
li = list_indication(jj)
local results={}
local currentLine = 0
if li ~= driver.state.indications[jj] then
local z = li:gmatch("-----------------------------------------\n([^\n]+)\n([^\n]*)\n")
while true do
local name, value = z()
if not name then
break
end
if value ~= "" and value ~= ":" then
if currentLine < 3 then
results["Line"..currentLine]= string.format("%02d",value)
currentLine = currentLine + 1
else
if currentLine == 3 then
results["Line3"] = string.format("%s",value)
else
results["Line4"] = value
end
end
end
end
helios.send(2096+((jj-6)*2),string.format("%s!%s %s", helios.ensureString(results["Line0"]), helios.ensureString(results["Line1"]), helios.ensureString(results["Line2"])))
helios.send(2097+((jj-6)*2),string.format("%s", helios.ensureString(results["Line3"])))
driver.state.indications[jj] = li
end
end
-- 8 are the frequency preset frequencies
for jj = 9,10,1 do
local results={}
-- Indicators 9 and 10 are the AN/ARC-201 FM 1 & 2 displays
li = list_indication(jj)
if li ~= driver.state.indications[jj] then
local z = li:gmatch("-----------------------------------------\n([^\n]+)\n([^\n]*)\n")
local currentLine = 0
while true do
local name, value = z()
if not name then
break
end
if value ~= "" then
results["Line"]= string.format("%s",value)
end
end
if results["Line"] then
helios.send(2104+jj-9,string.format("%s", helios.ensureString(results["Line"]:gsub(":","!"))))
end
driver.state.indications[jj] = li
end
end
do
jj = 11
local results={}
-- Indicator 11 for the AHRU display
li = list_indication(jj)
if li ~= driver.state.indications[jj] then
local z = li:gmatch("-----------------------------------------\n([^\n]+)\n([^\n]*)\n")
local currentLine = 0
while true do
local name, value = z()
if not name then
break
end
if value ~= "" then
results["Line"]= string.format("%-16s",value)
end
end
if results["Line"] then
helios.send(2106,string.format("%-16s", helios.ensureString(results["Line"]:gsub(":","!"))))
end
driver.state.indications[jj] = li
end
end
do
jj = 12
local results={}
-- Indicator 12 for the Aux Fuel display
li = list_indication(jj)
if li ~= driver.state.indications[jj] then
local z = li:gmatch("-----------------------------------------\n([^\n]+)\n([^\n]*)\n")
local currentLine = 0
while true do
local name, value = z()
if not name then
break
end
if value ~= "" then
results["AuxFuel"..currentLine]= string.format("%s",value)
currentLine = currentLine + 1
end
end
for ii=0,3,1 do
if results["AuxFuel"..ii] then
helios.send(2107+ii,string.format("%s", helios.ensureString(results["AuxFuel"..ii]:gsub(":","!"):gsub("%%",""))))
end
end
driver.state.indications[jj] = li
end
end
-- next code is 2111
end
function driver.clearState()
log.write("Helios.Export",log.DEBUG,"Driver: MH-60R - Driver clearState() called")
driver.state.indications = {}
end