forked from s-d-a/DCS-ExportScripts
-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathF-15C.lua
More file actions
1426 lines (1291 loc) · 62.4 KB
/
F-15C.lua
File metadata and controls
1426 lines (1291 loc) · 62.4 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
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- F-15C
ExportScript.FoundFCModule = true
ExportScript.Version.F15C = "1.2.1"
-- auxiliary function
dofile(ExportScript.Config.ExportModulePath.."FC_AuxiliaryFuntions.lua")
-----------------------------------------
-- FLAMING CLIFFS AIRCRAFT / F-15C --
-- FC aircraft don't support GetDevice --
-----------------------------------------
function ExportScript.ProcessIkarusFCHighImportanceConfig()
local lFunctionTyp = "Ikarus" -- function type for shared function
local myData = LoGetSelfData()
if (myData) then
local lLatitude = myData.LatLongAlt.Lat -- LATITUDE
local lLongitude = myData.LatLongAlt.Long -- LONGITUDE
local lBasicAtmospherePressure = LoGetBasicAtmospherePressure() -- BAROMETRIC PRESSURE
local lAltBar = LoGetAltitudeAboveSeaLevel() -- ALTITUDE SEA LEVEL (Meter)
local lEngineRPMleft = LoGetEngineInfo().RPM.left -- ENG1 RPM %
local lEngineRPMright = LoGetEngineInfo().RPM.right -- ENG2 RPM %
local lEngineTempLeft = LoGetEngineInfo().Temperature.left -- ENG1 EGT �C
local lEngineTempRight = LoGetEngineInfo().Temperature.right -- ENG2 EGT �C
local lIAS = LoGetIndicatedAirSpeed() -- INDICATED AIRSPEED (Meter/Second)
local lMachNumber = LoGetMachNumber() -- MACH
local lAoA = LoGetAngleOfAttack() -- ANGLE OF ATTACK AoA (Radian)
local lAccelerationUnits = LoGetAccelerationUnits().y -- G-LOAD
local lEngineFuelConsumptionLeft = LoGetEngineInfo().FuelConsumption.left
local lEngineFuelConsumptionRight = LoGetEngineInfo().FuelConsumption.right
local lEngineHydraulicPressureLeft = LoGetEngineInfo().HydraulicPressure.left
local lEngineHydraulicPressureRight = LoGetEngineInfo().HydraulicPressure.right
--[[
local lAltRad = LoGetAltitudeAboveGroundLevel() -- ALTITUDE GROUND LEVEL (Meter)
local lTrueAirSpeed = LoGetTrueAirSpeed() -- TRUE AIRSPEED (Meter/Second)
local lPitch, lBank, lYaw = LoGetADIPitchBankYaw() -- PITCH, BANK, YAW (Radian)
local lHeading = myData.Heading -- HEADING (Radian)
local lVVI = LoGetVerticalVelocity() -- VERTICAL SPEED (Meter/Second)
local lGlide = LoGetGlideDeviation() -- VOR1 HORIZONTAL DEFLECTION (-1 +1)
local lSide = LoGetSideDeviation() -- VOR1 VERTICAL DEFLECTION (-1 +1)
local lSlipBallPosition = LoGetSlipBallPosition() -- SLIP BALL (-1 +1)
local lNavInfoPitch = LoGetNavigationInfo().Requirements.pitch -- AP REQUIRED PITCH (Radian)
local lNavInfoRoll = LoGetNavigationInfo().Requirements.roll -- AP REQUIRED BANK (Radian)
local lNavInfoSpeed = LoGetNavigationInfo().Requirements.speed -- AP SPEED (Meter/Second)
local lNavInfoAltitude = LoGetNavigationInfo().Requirements.altitude -- AP ALTITUDE (Meter)
local lNavInfoVerticalSpeed = LoGetNavigationInfo().Requirements.vertical_speed -- AP VERTICAL SPEED (Meter/Second)
local lControlPanel_HSI = LoGetControlPanel_HSI() -- HSI Data
local lHSI_RMI = LoGetControlPanel_HSI().RMI_raw -- VOR1 OBS (Radian)
local lHSI_ADF = LoGetControlPanel_HSI().ADF_raw -- ADF OBS (Radian)
local lHSI_Heading = LoGetControlPanel_HSI().Heading_raw -- Heading (Radian)
local lEngineFuelInternal = LoGetEngineInfo().fuel_internal -- TANK1 (INT) (KG)
local lEngineFuelExternal = LoGetEngineInfo().fuel_external -- TANK2 (EXT) (KG)
local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,...
local lPayloadInfo = LoGetPayloadInfo() -- Paylod, e.g. bombs, guns, rockets, fuel tanks,...
]]
local lDistanceToWay = 999
local lRoute = LoGetRoute()
if (myData and lRoute) then -- if neither are nil
local myLoc = LoGeoCoordinatesToLoCoordinates(lLongitude, lLatitude)
--lDistanceToWay = math.sqrt((myLoc.x - lRoute.goto_point.world_point.x)^2 + (myLoc.y - lRoute.goto_point.world_point.y)^2)
lDistanceToWay = math.sqrt((myLoc.x - lRoute.goto_point.world_point.x)^2 + (myLoc.z - lRoute.goto_point.world_point.z)^2)
end
-- ADI
ExportScript.AF.FC_US_ADI() -- ID 1 to 10
-- HSI
ExportScript.AF.FC_US_HSI(lDistanceToWay) -- ID 11 to 23
-- VVI
ExportScript.AF.FC_US_VVI() -- ID 24
-- G-LOAD
ExportScript.AF.FC_US_GLOAD() -- ID 25 to 27
-- Clock
ExportScript.AF.FC_US_Clock() -- ID 28 to 30
-- Standby Compass
ExportScript.AF.FC_US_Compass() -- ID 31 to 33
-- Standby ADI
ExportScript.AF.FC_US_stbyADI() -- ID 34, 35
-- Barometrisic Altimeter
--local lAltCounter = {[0] = 0.0, [1] = 0.11, [2] = 0.22, [3] = 0.33, [4] = 0.44, [5] = 0.55, [6] = 0.66, [7] = 0.77, [8] = 0.88, [9] = 0.99}
local lAltCounter = {[0] = 0.0, [1] = 0.1, [2] = 0.2, [3] = 0.3, [4] = 0.4, [5] = 0.5, [6] = 0.6, [7] = 0.7, [8] = 0.8, [9] = 0.9}
--local lAltBarTmp2 = string.format("%03d", ((lAltBar * 3.28084) / 100)) -- meter to feeds
lAltBar = lAltBar - (9.5 * (760 - lBasicAtmospherePressure)) -- 9.5 m per 1mmHg difference
--lAltBar = lAltBar + (9.5 * (760 - lBasicAtmospherePressure)) -- 9.5 m per 1mmHg difference
local lAltBarTmp = lAltBar * 3.28084 -- meter to feeds
local lAltBarTmp2 = ((lAltBar * 3.28084) / 100) -- meter to feeds
-- Export atmosphere pressure indicator
-- Because the damn ED has hidden the inHg value in the altimeter!
local AtmospherePressureFor_mmHg = ExportScript.Tools.round(lBasicAtmospherePressure, 2)
local AtmospherePressureFor_inHg = ExportScript.Tools.round(lBasicAtmospherePressure / 25.4, 2)
local AtmospherePressureFor_kPa = ExportScript.Tools.round(lBasicAtmospherePressure * 1.33322, 2)
-- mmHg
ExportScript.Tools.SendData(1011, AtmospherePressureFor_mmHg)
ExportScript.Tools.SendData(1021, AtmospherePressureFor_mmHg..'\nmmHg')
-- inHg
ExportScript.Tools.SendData(1012, AtmospherePressureFor_inHg)
ExportScript.Tools.SendData(1022, AtmospherePressureFor_inHg..'\ninHg')
-- kPa
ExportScript.Tools.SendData(1013, AtmospherePressureFor_kPa)
ExportScript.Tools.SendData(1023, AtmospherePressureFor_kPa..'\nhPa')
-- Combine mmHg, inHg, kPa
ExportScript.Tools.SendData(1025, AtmospherePressureFor_inHg..' inHg\n'..AtmospherePressureFor_mmHg..' mmHg\n'..AtmospherePressureFor_kPa..' hPa')
lAltBarTmp = lAltBarTmp / 1000
lAltBarTmp = lAltBarTmp - ExportScript.Tools.round(lAltBarTmp, 0, "floor")
local lAltCounter1 = 0
local lAltCounter2 = 0
local lAltCounter3 = 0
local lAltCounter4 = 0
local lAltBarTmp3 = string.format("%03d", lAltBarTmp2)
lAltCounter4 = lAltBarTmp * 10
if lAltCounter4 > 1.0 then
lAltCounter4 = lAltCounter4 - ExportScript.Tools.round(lAltCounter4, 0, "floor")
end
-- AltBar {0.0,1.0}
-- AltBar_10000 {0.0,1.0}
-- AltBar_1000 {0.0,1.0}
-- AltBar_100 {0.0,1.0}
-- AltBar_10 {0.0,1.0}
ExportScript.Tools.SendData(36, lAltBarTmp)
ExportScript.Tools.SendData(37, lAltCounter[tonumber(string.sub(lAltBarTmp3, 1, 1))])
ExportScript.Tools.SendData(38, lAltCounter[tonumber(string.sub(lAltBarTmp3, 2, 2))])
ExportScript.Tools.SendData(39, lAltCounter[tonumber(string.sub(lAltBarTmp3, 3, 3))])
ExportScript.Tools.SendData(40, lAltCounter4)
-- Barometrisic Altimeter end
-- Air Speed Indicator (IAS, Mach)
--[[
y_min = 0.0 -- minimaler Ausgabewert
y_max = 1.0 -- maximaler Ausgabewert
x_min = 0.0 -- minimaler Eingangswert
x_max = 514,44444443999953012349519517095 -- maximaler Eingangswert
x = 257.0 -- aktueller Eingangswert
d_y = 1.0 -- Delta Ausgabewerte (y_max - y_min)
d_x = 514,44444443999953012349519517095 -- Delta Eingangswerte (x_max - x_min)
m = 0.0019438444924574 -- Steigung der linearen Funktion (d_y / d_x)
n = 0.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max)
y = 0.4995680345615518 -- Ergebnis (m * x + n)
]]
lIAS = 0.0019438444924574 * lIAS
if lMachNumber < 1.01 then
--[[
y_min = 0.0 0.1 -- minimaler Ausgabewert
y_max = 0.1 1.0 -- maximaler Ausgabewert
x_min = 0.0 1.0 -- minimaler Eingangswert
x_max = 1.0 3.6 -- maximaler Eingangswert
x = 0.5 2.0 -- aktueller Eingangswert
d_y = 0.1 0.9 -- Delta Ausgabewerte (y_max - y_min)
d_x = 1.0 2.6 -- Delta Eingangswerte (x_max - x_min)
m = 0.1 0.34615384615384615384615384615385 -- Steigung der linearen Funktion (d_y / d_x)
n = 0.0 -0.24615384615384615384615384615385 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max)
y = 0.05 0.44615384615384615384615384615384 -- Ergebnis (m * x + n)
]]
lMachNumber = 0.1 * lMachNumber
else
lMachNumber = 0.34615384615384615384615384615385 * lMachNumber + -0.24615384615384615384615384615385
end
-- IAS {0.0,1.0}
-- MachNumber
--SendData(2, string.format("%.4f;%.4f", lIAS, lMachNumber))
ExportScript.Tools.SendData(44, string.format("%.4f", lIAS))
ExportScript.Tools.SendData(45, string.format("%.4f", lMachNumber))
-- Air Speed Indicator End
-- RPM Engine Left
ExportScript.AF.FC_OneNeedleGauge(lEngineRPMleft, 110, 46)
-- RPM Engine Right
ExportScript.AF.FC_OneNeedleGauge(lEngineRPMright, 110, 47)
-- Oil Pressure Left, no value but similar to Engine RPM
--[[
y_min = 0.0 0.76 -- minimaler Ausgabewert
y_max = 0.76 1.0 -- maximaler Ausgabewert
x_min = 0.0 74.0 -- minimaler Eingangswert
x_max = 74.0 95.0 -- maximaler Eingangswert
x = 74.0 90.0 -- aktueller Eingangswert
d_y = 0.76 0.24 -- Delta Ausgabewerte (y_max - y_min)
d_x = 74.0 21.0 -- Delta Eingangswerte (x_max - x_min)
m = 0.01027027027027027027027027027027 0.01142857142857142857142857142857 -- Steigung der linearen Funktion (d_y / d_x)
n = 0.0 -0.08571428571428571428571428571415 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max)
y = 0.7599999 0.943-- Ergebnis (m * x + n)
]]
if lEngineRPMleft < 74 then
ExportScript.AF.FC_OneNeedleGauge(1.027027027027027027027027027027 * lEngineRPMleft, 100, 48)
else
ExportScript.AF.FC_OneNeedleGauge(1.142857142857142857142857142857 * lEngineRPMleft + -8.571428571428571428571428571415, 100, 48)
end
-- Oil Pressure Right, no value but similar to Engine RPM
if lEngineRPMright < 74 then
ExportScript.AF.FC_OneNeedleGauge(1.027027027027027027027027027027 * lEngineRPMright, 100, 49)
else
ExportScript.AF.FC_OneNeedleGauge(1.142857142857142857142857142857 * lEngineRPMright + -8.571428571428571428571428571415, 100, 49)
end
-- Engine Exhaust Nozzle Position Indicator Left, very imprecise
--[[
y_min = 0.0 -- minimaler Ausgabewert
y_max = 0.76 -- maximaler Ausgabewert
x_min = 95.0 -- minimaler Eingangswert
x_max = 96.0 -- maximaler Eingangswert
x = 95.5 -- aktueller Eingangswert
d_y = 0.76 -- Delta Ausgabewerte (y_max - y_min)
d_x = 1.0 -- Delta Eingangswerte (x_max - x_min)
m = 0.76 -- Steigung der linearen Funktion (d_y / d_x)
n = -72.2 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max)
y = 0.5 -- Ergebnis (m * x + n)
]]
if lEngineRPMleft > 95.0 then
ExportScript.AF.FC_OneNeedleGauge((0.76 * lEngineRPMleft + -72.2) * 100, 100, 50)
else
ExportScript.AF.FC_OneNeedleGauge(0, 100, 50)
end
-- Engine Exhaust Nozzle Position Indicator Right, very imprecise
if lEngineRPMright > 95.0 then
ExportScript.AF.FC_OneNeedleGauge((0.76 * lEngineRPMright + -72.2) * 100, 100, 51)
else
ExportScript.AF.FC_OneNeedleGauge(0, 100, 51)
end
-- Exaust Gas Temperature Left
ExportScript.AF.FC_F15C_ExaustGasTemp(lEngineTempLeft - 1.4, 52, 53, 54, 55)
-- Exaust Gas Temperature Right
ExportScript.AF.FC_F15C_ExaustGasTemp(lEngineTempRight - 1.4, 56, 57, 58, 59)
-- Fuel Flow Left
ExportScript.AF.FC_OneNeedleGauge3Digits(((lEngineFuelConsumptionLeft * 2.2046223302272) * 3600), 10000, 2, 60, 61, 62, 63)
-- Fuel Flow Right
ExportScript.AF.FC_OneNeedleGauge3Digits(((lEngineFuelConsumptionRight * 2.2046223302272) * 3600), 10000, 2, 64, 65, 66, 67)
-- Hydraulic Pressure Left
ExportScript.AF.FC_OneNeedleGauge(lEngineHydraulicPressureLeft, 100, 68)
-- Hydraulic Pressure Right
ExportScript.AF.FC_OneNeedleGauge(lEngineHydraulicPressureRight, 100, 69)
-- AOA
--FC_US_AOA(16)
--ExportScript.Tools.WriteToLog('lAoA 1: '..ExportScript.Tools.dump(lAoA))
--local lAoATmp = math.deg(lAoA) + 10
--ExportScript.Tools.WriteToLog('lAoA 2: '..ExportScript.Tools.dump(lAoATmp))
--[[
y_min = 0.0 -- minimaler Ausgabewert
y_max = 1.0 -- maximaler Ausgabewert
x_min = 0.0 -- minimaler Eingangswert
x_max = 45.0 -- maximaler Eingangswert
x = 12.6 -- aktueller Eingangswert
d_y = 1.0 -- Delta Ausgabewerte (y_max - y_min)
d_x = 45.0 -- Delta Eingangswerte (x_max - x_min)
m = 0.02222222222222222222222222222222 -- Steigung der linearen Funktion (d_y / d_x)
n = 0.0000000000000000000000000000001 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max)
y = 0.2800000000000000000000000000001 -- Ergebnis (m * x + n)
]]
--lAoATmp = 0.02222222222222222222222222222222 * lAoATmp + 0.0000000000000000000000000000001
--SendData(16, string.format("%.4f;%d", lAoATmp, 0) )
if lAoA > 0.0 then -- positive AOA
--[[
y_min = 0.33 -- minimaler Ausgabewert
y_max = 1.0 -- maximaler Ausgabewert
x_min = 0.0 -- minimaler Eingangswert
x_max = 30.0 -- maximaler Eingangswert
x = 12.6 -- aktueller Eingangswert
d_y = 0.67 -- Delta Ausgabewerte (y_max - y_min)
d_x = 30.0 -- Delta Eingangswerte (x_max - x_min)
m = 0.02233333333333333333333333333333 -- Steigung der linearen Funktion (d_y / d_x)
n = 0.33 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max)
y = 0.6114 -- Ergebnis (m * x + n)
]]
lAoA = 0.02228571428571428571428571428571 * lAoA + 0.33
else
--[[
y_min = 0.0 -- minimaler Ausgabewert
y_max = 0.33 -- maximaler Ausgabewert
x_min = 0.0 -- minimaler Eingangswert
x_max = -10.0 -- maximaler Eingangswert
x = -2.6 -- aktueller Eingangswert
d_y = 0.33 -- Delta Ausgabewerte (y_max - y_min)
d_x = -10.0 -- Delta Eingangswerte (x_max - x_min)
m = -0.033 -- Steigung der linearen Funktion (d_y / d_x)
n = 0.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max)
y = 0.2442 -- Ergebnis 0.33 - (m * x + n)
]]
--lAoA = 0.22 - (-0.022 * lAoA)
lAoA = 0.33 - (-0.033 * lAoA)
end
ExportScript.Tools.SendData(70, string.format("%.4f", lAoA))
ExportScript.Tools.SendData(0, 0) -- AOA Off Flag off
-- AOA End
-- Hydraulic Pressure Util, no value but similar to Engine Hydraulic Pressure (left or right)
local lEngineHydraulicPressure = lEngineHydraulicPressureLeft
lEngineHydraulicPressure = lEngineHydraulicPressureRight > lEngineHydraulicPressureLeft and lEngineHydraulicPressureRight or lEngineHydraulicPressureLeft
ExportScript.AF.FC_OneNeedleGauge(lEngineHydraulicPressure, 100, 71)
-- Standby Air Speed Indicator (IAS, Mach)
-- value has been calculated (from top)
-- IAS {0.0,1.0}
ExportScript.Tools.SendData(72, string.format("%.4f", lIAS))
-- Standby Air Speed Indicator End
-- AccelerationUnits
--ExportScript.Tools.WriteToLog("lAccelerationUnits: "..ExportScript.Tools.dump(lAccelerationUnits))
if lAccelerationUnits > 0.0 then -- positive AccelerationUnits
--[[
y_min = 0.333 -- minimaler Ausgabewert
y_max = 1.0 -- maximaler Ausgabewert
x_min = 0.0 -- minimaler Eingangswert
x_max = 10.0 -- maximaler Eingangswert
x = 2.6 -- aktueller Eingangswert
d_y = 0.667 -- Delta Ausgabewerte (y_max - y_min)
d_x = 10.0 -- Delta Eingangswerte (x_max - x_min)
m = 0.0667 -- Steigung der linearen Funktion (d_y / d_x)
n = 0.333 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max)
y = 0.50642 -- Ergebnis (m * x + n)
]]
lAccelerationUnits = 0.0667 * lAccelerationUnits + 0.333
else
--[[
y_min = 0.0 -- minimaler Ausgabewert
y_max = 0.333 -- maximaler Ausgabewert
x_min = 0.0 -- minimaler Eingangswert
x_max = -5.0 -- maximaler Eingangswert
x = -2.6 -- aktueller Eingangswert
d_y = 0.333 -- Delta Ausgabewerte (y_max - y_min)
d_x = -5.0 -- Delta Eingangswerte (x_max - x_min)
m = -0.0666 -- Steigung der linearen Funktion (d_y / d_x)
n = 0.666 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max)
y = 0.17316 -- Ergebnis 0.666 - (m * x + n)
]]
lAccelerationUnits = 0.666 - (-0.0666 * lAccelerationUnits + 0.666)
end
ExportScript.Tools.SendData(73, string.format("%.4f", lAccelerationUnits))
-- AccelerationUnits End
-- Standby Barometrisic Altimeter
--lAltBarTmp = lAltBar - (9.5 * (760 - lBasicAtmospherePressure)) -- 9.5 m per 1mmHg difference, has been calculated
lAltBarTmp = lAltBar * 3.28084 -- meter to feeds
local AltBar_kilofeet_needle = 0
local AltBar_hektofeet_needle = 0
local AltBar_dafeet_needle = 0
if lAltBarTmp > 1000 then
AltBar_kilofeet_needle = lAltBarTmp / 10000
end
if lAltBarTmp > 10000 then
AltBar_hektofeet_needle = (lAltBarTmp - (ExportScript.Tools.round(lAltBarTmp / 10000, 0, "floor") * 10000)) / 1000
else
AltBar_hektofeet_needle = lAltBarTmp / 1000
end
if lAltBarTmp > 1000 then
AltBar_dafeet_needle = (lAltBarTmp - (ExportScript.Tools.round(lAltBarTmp / 1000, 0, "floor") * 1000)) / 100
else
AltBar_dafeet_needle = lAltBarTmp / 100
end
--[[
y_min = 0.0 -- minimaler Ausgabewert
y_max = 1.0 -- maximaler Ausgabewert
x_min = 0.0 -- minimaler Eingangswert
x_max = 10.0 -- maximaler Eingangswert
x = 2.5 -- aktueller Eingangswert
d_y = 1.0 -- Delta Ausgabewerte (y_max - y_min)
d_x = 10.0 -- Delta Eingangswerte (x_max - x_min)
m = 0.1 -- Steigung der linearen Funktion (d_y / d_x)
n = 0.0 -- Schnittpunkt der Funktion mit y-Achse (y_max - m * x_max)
y = 0.25 -- Ergebnis (m * x + n)
]]
AltBar_kilofeet_needle = 0.1 * AltBar_kilofeet_needle
AltBar_hektofeet_needle = 0.1 * AltBar_hektofeet_needle
AltBar_dafeet_needle = 0.1 * AltBar_dafeet_needle
-- AltBar_kilofeet_needle {0.0,1.0}
-- AltBar_hektofeet_needle {0.0,1.0}
-- AltBar_dafeet_needle {0.0,1.0}
ExportScript.Tools.SendData(41, string.format("%.4f", AltBar_kilofeet_needle))
ExportScript.Tools.SendData(42, string.format("%.4f", AltBar_hektofeet_needle))
ExportScript.Tools.SendData(43, string.format("%.4f", AltBar_dafeet_needle))
-- Standby Barometrisic Altimeter end
ExportScript.AF.FlareChaff(lFunctionTyp)
else
ExportScript.Tools.WriteToLog("Unknown FC Error, no LoGetSelfData.")
end
end
function ExportScript.ProcessDACConfigHighImportance()
local lFunctionTyp = "DAC" -- function type for shared function
-- your script
ExportScript.AF.FlareChaff(lFunctionTyp)
end
function ExportScript.ProcessIkarusFCLowImportanceConfig()
local lFunctionTyp = "Ikarus" -- function type for shared function
-- Gear Lamps
ExportScript.AF.MechanicalDevicesIndicator(lFunctionTyp)
ExportScript.AF.FuelQuantityIndicator(lFunctionTyp)
ExportScript.AF.SightingSystem(lFunctionTyp)
ExportScript.AF.StatusLamp(lFunctionTyp)
ExportScript.AF.RWRlite(lFunctionTyp)
end
function ExportScript.ProcessDACConfigLowImportance()
local lFunctionTyp = "DAC" -- function type for shared function
ExportScript.AF.MechanicalDevicesIndicator(lFunctionTyp)
ExportScript.AF.FuelQuantityIndicator(lFunctionTyp)
ExportScript.AF.SightingSystem(lFunctionTyp)
ExportScript.AF.StatusLamp(lFunctionTyp)
ExportScript.AF.WeaponStatusPanel(lFunctionTyp)
ExportScript.AF.RWRlite(lFunctionTyp)
end
-----------------------------
-- Custom functions --
-----------------------------
function ExportScript.AF.SightingSystem(FunctionTyp)
local lSightingSystemInfo = LoGetSightingSystemInfo()
local lFunctionTyp = FunctionTyp or "Ikarus"
if lSightingSystemInfo == nil then
return
end
--ExportScript.Tools.WriteToLog('lSightingSystemInfo: '..ExportScript.Tools.dump(lSightingSystemInfo)9
--[[
[PRF] = {
[selection] = string: "ILV"
[current] = string: "MED"
}
[laser_on] = boolean: "false"
[scale] = {
[azimuth] = number: "0.52359873056412"
[distance] = number: "10000"
}
[radar_on] = boolean: "false"
[optical_system_on] = boolean: "false"
[LaunchAuthorized] = boolean: "false"
[ECM_on] = boolean: "false"
[Manufacturer] = string: "RUS"
[TDC] = {
[y] = number: "0"
[x] = number: "0"
}
[ScanZone] = {
[coverage_H] = {
[min] = number: "0"
[max] = number: "20000"
}
[size] = {
[azimuth] = number: "1.0471974611282"
[elevation] = number: "0.17453290522099"
}
[position] = {
[exceeding_manual] = number: "0"
[distance_manual] = number: "0"
[azimuth] = number: "0"
[elevation] = number: "0"
}
}
]]
if ExportScript.Config.IkarusExport and lFunctionTyp == "Ikarus" then
ExportScript.Tools.SendData(600, lSightingSystemInfo.ECM_on == true and 1 or 0 )
--ExportScript.Tools.SendData(601, lSightingSystemInfo.laser_on == true and 1 or 0 )
--ExportScript.Tools.SendData(602, lSightingSystemInfo.optical_system_on == true and 1 or 0 )
ExportScript.Tools.SendData(603, lSightingSystemInfo.LaunchAuthorized == true and 1 or 0 )
ExportScript.Tools.SendData(604, lSightingSystemInfo.radar_on == true and 1 or 0 )
end
if ExportScript.Config.DACExport and lFunctionTyp == "DAC" then
ExportScript.Tools.SendDataDAC(600, lSightingSystemInfo.ECM_on == true and 1 or 0 )
--ExportScript.Tools.SendDataDAC(601, lSightingSystemInfo.laser_on == true and 1 or 0 )
--ExportScript.Tools.SendDataDAC(602, lSightingSystemInfo.optical_system_on == true and 1 or 0 )
ExportScript.Tools.SendDataDAC(603, lSightingSystemInfo.LaunchAuthorized == true and 1 or 0 )
ExportScript.Tools.SendDataDAC(604, lSightingSystemInfo.radar_on == true and 1 or 0 )
end
end
function ExportScript.AF.FuelQuantityIndicator(FunctionTyp)
local lFunctionTyp = FunctionTyp or "Ikarus"
-- Fuel quantity shows the fuel remaining in all tanks
local lEngineInfo = LoGetEngineInfo()
if lEngineInfo == nil then
return
end
--ExportScript.Tools.WriteToLog('lEngineInfo: '..ExportScript.Tools.dump(lEngineInfo))
--[[
[fuel_external] = number: "0"
[Temperature] = {
[left] = number: "626.99444580078"
[right] = number: "626.99444580078"
}
[RPM] = {
[left] = number: "87.453765869141"
[right] = number: "87.453758239746"
}
[FuelConsumption] = {
[left] = number: "0.1500396137767"
[right] = number: "0.1500396137767"
}
[fuel_internal] = number: "3773.2749023438"
[EngineStart] = {
[left] = number: "0"
[right] = number: "0"
}
[HydraulicPressure] = {
[left] = number: "210"
[right] = number: "210"
}
lPayloadInfo.Stations[8].CLSID == E8D4652F-FD48-45B7-BA5B-2AE05BB5A9CF -- ext 800l Fuel Tank
]]
local lEngineFuelTotal = (lEngineInfo.fuel_internal + lEngineInfo.fuel_external) * 2.2046223302272 -- kg to lbs
local lFuelNeedle = lEngineFuelTotal / 12000 -- 12000 = scala
lFuelNeedle = (lFuelNeedle > 1.0 and 1.0 or lFuelNeedle)
local lFuelCounterLeft = 1200
local lFuelCounterRight = 1500
if lEngineInfo.RPM.left > 0 then
if lEngineInfo.RPM.right > 0 then
if lEngineFuelTotal < 2700 then
lFuelCounterLeft = lEngineFuelTotal * 0.44444444444444444444444444444444
end
else
if lEngineFuelTotal < 1200 then
lFuelCounterLeft = lEngineFuelTotal
end
end
end
if lEngineInfo.RPM.right > 0 then
if lEngineInfo.RPM.left > 0 then
if lEngineFuelTotal < 2700 then
lFuelCounterRight = lEngineFuelTotal * 0.55555555555555555555555555555556
end
else
if lEngineFuelTotal < 1500 then
lFuelCounterRight = lEngineFuelTotal
end
end
end
if ExportScript.Config.IkarusExport and lFunctionTyp == "Ikarus" then
ExportScript.Tools.SendData(300, string.format("%d", lFuelCounterLeft)) -- Left Fuel
ExportScript.Tools.SendData(301, string.format("%d", lFuelCounterRight)) -- Right Fuel
ExportScript.Tools.SendData(302, string.format("%d", lEngineFuelTotal)) -- Total Fuel
ExportScript.Tools.SendData(303, string.format("%.4f", lFuelNeedle)) -- Needle
end
if ExportScript.Config.DACExport and lFunctionTyp == "DAC" then
ExportScript.Tools.SendDataDAC(300, string.format("%d", lFuelCounterLeft)) -- Left Fuel
ExportScript.Tools.SendDataDAC(301, string.format("%d", lFuelCounterRight)) -- Right Fuel
ExportScript.Tools.SendDataDAC(302, string.format("%d", lEngineFuelTotal)) -- Total Fuel
end
end
function ExportScript.AF.StatusLamp(FunctionTyp)
local lFunctionTyp = FunctionTyp or "Ikarus"
local lMCPState = LoGetMCPState() -- Warning Lights
if lMCPState == nil then
return
end
--ExportScript.Tools.WriteToLog('lMCPState: '..ExportScript.Tools.dump(lMCPState))
--[[
[RightTailPlaneFailure] = boolean: "false"
[EOSFailure] = boolean: "false"
[ECMFailure] = boolean: "false"
[RightAileronFailure] = boolean: "false"
[MasterWarning] = boolean: "false"
[RightEngineFailure] = boolean: "false"
[CannonFailure] = boolean: "false"
[MLWSFailure] = boolean: "false"
[ACSFailure] = boolean: "false"
[RadarFailure] = boolean: "false"
[HelmetFailure] = boolean: "false"
[HUDFailure] = boolean: "false"
[LeftMainPumpFailure] = boolean: "false"
[RightWingPumpFailure] = boolean: "false"
[LeftWingPumpFailure] = boolean: "false"
[MFDFailure] = boolean: "false"
[RWSFailure] = boolean: "false"
[GearFailure] = boolean: "false"
[HydraulicsFailure] = boolean: "false"
[AutopilotFailure] = boolean: "true"
[FuelTankDamage] = boolean: "false"
[LeftAileronFailure] = boolean: "false"
[CanopyOpen] = boolean: "false"
[RightMainPumpFailure] = boolean: "false"
[StallSignalization] = boolean: "false"
[LeftEngineFailure] = boolean: "false"
[AutopilotOn] = boolean: "false"
[LeftTailPlaneFailure] = boolean: "false"
]]
if ExportScript.Config.IkarusExport and lFunctionTyp == "Ikarus" then
ExportScript.Tools.SendData(700, lMCPState.LeftTailPlaneFailure == true and 1 or 0 )
ExportScript.Tools.SendData(701, lMCPState.RightTailPlaneFailure == true and 1 or 0 )
ExportScript.Tools.SendData(702, lMCPState.MasterWarning == true and 1 or 0 )
ExportScript.Tools.SendData(703, lMCPState.LeftEngineFailure == true and 1 or 0 )
ExportScript.Tools.SendData(704, lMCPState.RightEngineFailure == true and 1 or 0 )
ExportScript.Tools.SendData(705, lMCPState.LeftAileronFailure == true and 1 or 0 )
ExportScript.Tools.SendData(706, lMCPState.RightAileronFailure == true and 1 or 0 )
ExportScript.Tools.SendData(707, lMCPState.LeftMainPumpFailure == true and 1 or 0 )
ExportScript.Tools.SendData(708, lMCPState.RightMainPumpFailure == true and 1 or 0 )
ExportScript.Tools.SendData(709, lMCPState.LeftWingPumpFailure == true and 1 or 0 )
ExportScript.Tools.SendData(710, lMCPState.RightWingPumpFailure == true and 1 or 0 )
ExportScript.Tools.SendData(711, lMCPState.EOSFailure == true and 1 or 0 )
ExportScript.Tools.SendData(712, lMCPState.ECMFailure == true and 1 or 0 )
ExportScript.Tools.SendData(713, lMCPState.CannonFailure == true and 1 or 0 )
ExportScript.Tools.SendData(714, lMCPState.MLWSFailure == true and 1 or 0 )
ExportScript.Tools.SendData(715, lMCPState.ACSFailure == true and 1 or 0 )
ExportScript.Tools.SendData(716, lMCPState.RadarFailure == true and 1 or 0 )
ExportScript.Tools.SendData(717, lMCPState.HelmetFailure == true and 1 or 0 )
ExportScript.Tools.SendData(718, lMCPState.HUDFailure == true and 1 or 0 )
ExportScript.Tools.SendData(719, lMCPState.MFDFailure == true and 1 or 0 )
ExportScript.Tools.SendData(720, lMCPState.RWSFailure == true and 1 or 0 )
ExportScript.Tools.SendData(721, lMCPState.GearFailure == true and 1 or 0 )
ExportScript.Tools.SendData(722, lMCPState.HydraulicsFailure == true and 1 or 0 )
ExportScript.Tools.SendData(723, lMCPState.AutopilotFailure == true and 1 or 0 )
ExportScript.Tools.SendData(724, lMCPState.FuelTankDamage == true and 1 or 0 )
ExportScript.Tools.SendData(725, lMCPState.CanopyOpen == true and 1 or 0 )
ExportScript.Tools.SendData(726, lMCPState.StallSignalization == true and 1 or 0 )
ExportScript.Tools.SendData(727, lMCPState.AutopilotOn == true and 1 or 0 )
local lEngineInfo = LoGetEngineInfo()
if lEngineInfo ~= nil then
--ExportScript.Tools.WriteToLog('lEngineInfo: '..ExportScript.Tools.dump(lEngineInfo))
ExportScript.Tools.SendData(728, lEngineInfo.EngineStart.left ) -- lamp start left engine 1 (0|1)
ExportScript.Tools.SendData(729, lEngineInfo.EngineStart.right ) -- lamp start right engine 1 (0|1)
ExportScript.Tools.SendData(730, lEngineInfo.RPM.left < 45 and 1 or 0 ) -- lamp generator left engine 1 (0|1)
ExportScript.Tools.SendData(731, lEngineInfo.RPM.right < 45 and 1 or 0 ) -- lamp generator right engine 1 (0|1)
end
end
if ExportScript.Config.DACExport and lFunctionTyp == "DAC" then
ExportScript.Tools.SendDataDAC("700", lMCPState.LeftTailPlaneFailure == true and 1 or 0 )
ExportScript.Tools.SendDataDAC("701", lMCPState.RightTailPlaneFailure == true and 1 or 0 )
ExportScript.Tools.SendDataDAC("702", lMCPState.MasterWarning == true and 1 or 0 )
ExportScript.Tools.SendDataDAC("703", lMCPState.LeftEngineFailure == true and 1 or 0 )
ExportScript.Tools.SendDataDAC("704", lMCPState.RightEngineFailure == true and 1 or 0 )
ExportScript.Tools.SendDataDAC("705", lMCPState.LeftAileronFailure == true and 1 or 0 )
ExportScript.Tools.SendDataDAC("706", lMCPState.RightAileronFailure == true and 1 or 0 )
ExportScript.Tools.SendDataDAC("707", lMCPState.LeftMainPumpFailure == true and 1 or 0 )
ExportScript.Tools.SendDataDAC("708", lMCPState.RightMainPumpFailure == true and 1 or 0 )
ExportScript.Tools.SendDataDAC("709", lMCPState.LeftWingPumpFailure == true and 1 or 0 )
ExportScript.Tools.SendDataDAC("710", lMCPState.RightWingPumpFailure == true and 1 or 0 )
ExportScript.Tools.SendDataDAC("711", lMCPState.EOSFailure == true and 1 or 0 )
ExportScript.Tools.SendDataDAC("712", lMCPState.ECMFailure == true and 1 or 0 )
ExportScript.Tools.SendDataDAC("713", lMCPState.CannonFailure == true and 1 or 0 )
ExportScript.Tools.SendDataDAC("714", lMCPState.MLWSFailure == true and 1 or 0 )
ExportScript.Tools.SendDataDAC("715", lMCPState.ACSFailure == true and 1 or 0 )
ExportScript.Tools.SendDataDAC("716", lMCPState.RadarFailure == true and 1 or 0 )
ExportScript.Tools.SendDataDAC("717", lMCPState.HelmetFailure == true and 1 or 0 )
ExportScript.Tools.SendDataDAC("718", lMCPState.HUDFailure == true and 1 or 0 )
ExportScript.Tools.SendDataDAC("719", lMCPState.MFDFailure == true and 1 or 0 )
ExportScript.Tools.SendDataDAC("720", lMCPState.RWSFailure == true and 1 or 0 )
ExportScript.Tools.SendDataDAC("721", lMCPState.GearFailure == true and 1 or 0 )
ExportScript.Tools.SendDataDAC("722", lMCPState.HydraulicsFailure == true and 1 or 0 )
ExportScript.Tools.SendDataDAC("723", lMCPState.AutopilotFailure == true and 1 or 0 )
ExportScript.Tools.SendDataDAC("724", lMCPState.FuelTankDamage == true and 1 or 0 )
ExportScript.Tools.SendDataDAC("725", lMCPState.CanopyOpen == true and 1 or 0 )
ExportScript.Tools.SendDataDAC("726", lMCPState.StallSignalization == true and 1 or 0 )
ExportScript.Tools.SendDataDAC("727", lMCPState.AutopilotOn == true and 1 or 0 )
local lEngineInfo = LoGetEngineInfo()
if lEngineInfo ~= nil then
--ExportScript.Tools.WriteToLog('lEngineInfo: '..ExportScript.Tools.dump(lEngineInfo))
ExportScript.Tools.SendDataDAC("728", lEngineInfo.EngineStart.left ) -- lamp start left engine 1 (0|1)
ExportScript.Tools.SendDataDAC("729", lEngineInfo.EngineStart.right ) -- lamp start right engine 1 (0|1)
ExportScript.Tools.SendDataDAC("730", lEngineInfo.RPM.left < 45 and 1 or 0 ) -- lamp generator left engine 1 (0|1)
ExportScript.Tools.SendDataDAC("731", lEngineInfo.RPM.right < 45 and 1 or 0 ) -- lamp generator right engine 1 (0|1)
end
end
end
function ExportScript.AF.FlareChaff(FunctionTyp)
local lFunctionTyp = FunctionTyp or "Ikarus"
local lSnares = LoGetSnares() -- Flare and Chaff
if lSnares == nil then
return
end
--ExportScript.Tools.WriteToLog('lSnares: '..ExportScript.Tools.dump(lSnares))
--[chaff] = number: "30"
--[flare] = number: "30"
if ExportScript.AF.maxChaff == nil then
ExportScript.AF.maxChaff = lSnares.chaff
ExportScript.AF.tmpChaff = ExportScript.AF.maxChaff
end
if ExportScript.AF.maxFlare == nil then
ExportScript.AF.maxFlare = lSnares.flare
ExportScript.AF.tmpFlare = ExportScript.AF.maxFlare
end
if ExportScript.AF.timerChaff == nil then
ExportScript.AF.timerChaff = 0
ExportScript.AF.timerChaffCounter = 3
end
if ExportScript.AF.timerFlare == nil then
ExportScript.AF.timerFlare = 0
ExportScript.AF.timerFlareCounter = 3
end
local lblinkChaff = 0
local lblinkFlare = 0
local ltmp = 0
if ExportScript.AF.tmpChaff == 0 then
lblinkChaff = 1
end
if ExportScript.AF.tmpFlare == 0 then
lblinkFlare = 1
end
if lSnares.chaff < ExportScript.AF.tmpChaff then
--ExportScript.Tools.WriteToLog('Chaff: '..ExportScript.Tools.dump(lSnares.chaff)..', ExportScript.AF.tmpChaff:'..ExportScript.Tools.dump(ExportScript.AF.tmpChaff))
ExportScript.AF.tmpChaff = lSnares.chaff
--ExportScript.AF.timerChaff = os.time()
ExportScript.AF.timerChaff = os.clock()
ExportScript.Tools.WriteToLog('Chaff ausgeworfen, Zeit: '..ExportScript.Tools.dump(ExportScript.AF.timerChaff))
ExportScript.AF.timerChaffCounter = 3
end
if lSnares.flare < ExportScript.AF.tmpFlare then
--ExportScript.Tools.WriteToLog('Flare: '..ExportScript.Tools.dump(lSnares.flare)..', ExportScript.AF.tmpFlare:'..ExportScript.Tools.dump(ExportScript.AF.tmpFlare))
ExportScript.AF.tmpFlare = lSnares.flare
--ExportScript.AF.timerFlare = os.time()
ExportScript.AF.timerFlare = os.clock()
ExportScript.Tools.WriteToLog('Flare ausgeworfen, Zeit: '..ExportScript.Tools.dump(ExportScript.AF.timerFlare))
ExportScript.AF.timerFlareCounter = 3
end
if lblinkChaff == 0 and ExportScript.AF.timerChaff > 0.0 and ExportScript.AF.timerChaffCounter > 0 then
--local ldiffTimer = os.difftime (os.time(), ExportScript.AF.timerChaff)
local ldiffTimer = os.clock() - ExportScript.AF.timerChaff
ltmp, ldiffTimer = math.modf(ldiffTimer)
--ExportScript.Tools.WriteToLog('Zeit: '..ExportScript.AF.timerChaff..', Counter: '..ExportScript.AF.timerChaffCounter)
--ExportScript.Tools.WriteToLog('Zeit Diff: '..ldiffTimer)
if ExportScript.AF.timerChaffCounter == 1 and ldiffTimer > 0.9 then
--ExportScript.Tools.WriteToLog('0')
lblinkChaff = 0
ExportScript.AF.timerChaffCounter = 3
ExportScript.AF.timerChaff = 0.0
elseif ExportScript.AF.timerChaffCounter == 1 and ldiffTimer > 0.8 then
--ExportScript.Tools.WriteToLog('1')
lblinkChaff = 1
--ExportScript.AF.timerChaffCounter = ExportScript.AF.timerChaffCounter - 1
elseif ExportScript.AF.timerChaffCounter == 2 and ldiffTimer > 0.6 then
--ExportScript.Tools.WriteToLog('2')
lblinkChaff = 0
ExportScript.AF.timerChaffCounter = ExportScript.AF.timerChaffCounter - 1
elseif ExportScript.AF.timerChaffCounter == 2 and ldiffTimer > 0.4 then
--ExportScript.Tools.WriteToLog('3')
lblinkChaff = 1
--ExportScript.AF.timerChaffCounter = ExportScript.AF.timerChaffCounter - 1
elseif ExportScript.AF.timerChaffCounter == 3 and ldiffTimer > 0.2 then
--ExportScript.Tools.WriteToLog('4')
lblinkChaff = 0
ExportScript.AF.timerChaffCounter = ExportScript.AF.timerChaffCounter - 1
elseif ExportScript.AF.timerChaffCounter == 3 and ldiffTimer > 0.0 then
--ExportScript.Tools.WriteToLog('5')
lblinkChaff = 1
--ExportScript.AF.timerChaffCounter = ExportScript.AF.timerChaffCounter - 1
elseif ldiffTimer > 0.95 then
--ExportScript.Tools.WriteToLog('else')
lblinkChaff = 0
ExportScript.AF.timerChaffCounter = 3
ExportScript.AF.timerChaff = 0.0
end
--[[
if ExportScript.AF.timerChaffCounter == 3 and ldiffTimer < 0.5 then
ExportScript.Tools.WriteToLog('0')
lblinkChaff = 1
--ExportScript.AF.timerChaffCounter = ExportScript.AF.timerChaffCounter - 1
elseif ExportScript.AF.timerChaffCounter == 3 and ldiffTimer < 1.0 then
ExportScript.Tools.WriteToLog('1')
lblinkChaff = 0
ExportScript.AF.timerChaffCounter = ExportScript.AF.timerChaffCounter - 1
elseif ExportScript.AF.timerChaffCounter == 2 and ldiffTimer < 1.5 then
ExportScript.Tools.WriteToLog('2')
lblinkChaff = 1
--ExportScript.AF.timerChaffCounter = ExportScript.AF.timerChaffCounter - 1
elseif ExportScript.AF.timerChaffCounter == 2 and ldiffTimer < 2.0 then
ExportScript.Tools.WriteToLog('3')
lblinkChaff = 0
ExportScript.AF.timerChaffCounter = ExportScript.AF.timerChaffCounter - 1
elseif ExportScript.AF.timerChaffCounter == 1 and ldiffTimer < 2.5 then
ExportScript.Tools.WriteToLog('4')
lblinkChaff = 1
--ExportScript.AF.timerChaffCounter = ExportScript.AF.timerChaffCounter - 1
elseif ExportScript.AF.timerChaffCounter == 1 and ldiffTimer < 3.0 then
ExportScript.Tools.WriteToLog('5')
lblinkChaff = 0
ExportScript.AF.timerChaffCounter = ExportScript.AF.timerChaffCounter - 1
elseif ExportScript.AF.timerChaffCounter == 0 or ldiffTimer > 3.0 then
ExportScript.Tools.WriteToLog('else')
lblinkChaff = 0
ExportScript.AF.timerChaffCounter = 3
ExportScript.AF.timerChaff = 0
end]]
--[[
if ExportScript.AF.timerChaffCounter == 1 and ldiffTimer == 5 then
ExportScript.Tools.WriteToLog('0')
lblinkChaff = 0
ExportScript.AF.timerChaffCounter = ExportScript.AF.timerChaffCounter - 1
elseif ExportScript.AF.timerChaffCounter == 1 and ldiffTimer == 4 then
ExportScript.Tools.WriteToLog('1')
lblinkChaff = 1
--ExportScript.AF.timerChaffCounter = ExportScript.AF.timerChaffCounter - 1
elseif ExportScript.AF.timerChaffCounter == 2 and ldiffTimer == 3 then
ExportScript.Tools.WriteToLog('2')
lblinkChaff = 0
ExportScript.AF.timerChaffCounter = ExportScript.AF.timerChaffCounter - 1
elseif ExportScript.AF.timerChaffCounter == 2 and ldiffTimer == 2 then
ExportScript.Tools.WriteToLog('3')
lblinkChaff = 1
--ExportScript.AF.timerChaffCounter = ExportScript.AF.timerChaffCounter - 1
elseif ExportScript.AF.timerChaffCounter == 3 and ldiffTimer == 1 then
ExportScript.Tools.WriteToLog('4')
lblinkChaff = 0
ExportScript.AF.timerChaffCounter = ExportScript.AF.timerChaffCounter - 1
elseif ExportScript.AF.timerChaffCounter == 3 and ldiffTimer == 0 then
ExportScript.Tools.WriteToLog('5')
lblinkChaff = 1
--ExportScript.AF.timerChaffCounter = ExportScript.AF.timerChaffCounter - 1
elseif ExportScript.AF.timerChaffCounter == 0 or ldiffTimer > 5 then
ExportScript.Tools.WriteToLog('else')
lblinkChaff = 0
ExportScript.AF.timerChaffCounter = 3
ExportScript.AF.timerChaff = 0
end]]
end
if lblinkFlare == 0 and ExportScript.AF.timerFlare > 0.0 and ExportScript.AF.timerFlareCounter > 0 then
--local ldiffTimer = os.difftime (os.time(), ExportScript.AF.timerFlare)
local ldiffTimer = os.clock() - ExportScript.AF.timerFlare
ltmp, ldiffTimer = math.modf(ldiffTimer)
--ExportScript.Tools.WriteToLog('Zeit: '..ExportScript.AF.timerFlare..', Counter: '..ExportScript.AF.timerFlareCounter)
--ExportScript.Tools.WriteToLog('Zeit Diff: '..ldiffTimer)
if ExportScript.AF.timerFlareCounter == 1 and ldiffTimer > 0.9 then
--ExportScript.Tools.WriteToLog('0')
lblinkFlare = 0
ExportScript.AF.timerFlareCounter = 3
ExportScript.AF.timerFlare = 0.0
elseif ExportScript.AF.timerFlareCounter == 1 and ldiffTimer > 0.8 then
--ExportScript.Tools.WriteToLog('1')
lblinkFlare = 1
--ExportScript.AF.timerFlareCounter = ExportScript.AF.timerFlareCounter - 1
elseif ExportScript.AF.timerFlareCounter == 2 and ldiffTimer > 0.6 then
--ExportScript.Tools.WriteToLog('2')
lblinkFlare = 0
ExportScript.AF.timerFlareCounter = ExportScript.AF.timerFlareCounter - 1
elseif ExportScript.AF.timerFlareCounter == 2 and ldiffTimer > 0.4 then
--ExportScript.Tools.WriteToLog('3')
lblinkFlare = 1
--ExportScript.AF.timerFlareCounter = ExportScript.AF.timerFlareCounter - 1
elseif ExportScript.AF.timerFlareCounter == 3 and ldiffTimer > 0.2 then
--ExportScript.Tools.WriteToLog('4')
lblinkFlare = 0
ExportScript.AF.timerFlareCounter = ExportScript.AF.timerFlareCounter - 1
elseif ExportScript.AF.timerFlareCounter == 3 and ldiffTimer > 0.0 then
--ExportScript.Tools.WriteToLog('5')
lblinkFlare = 1
--ExportScript.AF.timerFlareCounter = ExportScript.AF.timerFlareCounter - 1
elseif ldiffTimer > 0.95 then
--ExportScript.Tools.WriteToLog('else')
lblinkFlare = 0
ExportScript.AF.timerFlareCounter = 3
ExportScript.AF.timerFlare = 0.0
end
end
--ExportScript.Tools.WriteToLog('lblinkChaff: '..lblinkChaff)
if ExportScript.Config.IkarusExport and lFunctionTyp == "Ikarus" then
ExportScript.Tools.SendData(800, lSnares.chaff ) -- display chaff
ExportScript.Tools.SendData(801, lSnares.flare ) -- display flare
ExportScript.Tools.SendData(802, lblinkChaff ) -- blink chaff active/aktive empty chaff
ExportScript.Tools.SendData(803, lblinkFlare ) -- blink flare active/aktive empty flare
ExportScript.Tools.SendData(804, ExportScript.AF.tmpChaff < 20 and 1 or 0 ) -- minimum chaff lamp
ExportScript.Tools.SendData(805, ExportScript.AF.tmpFlare < 10 and 1 or 0 ) -- minimum flare lamp
end
if ExportScript.Config.DACExport and lFunctionTyp == "DAC" then
ExportScript.Tools.SendDataDAC(800, lSnares.chaff ) -- display chaff
ExportScript.Tools.SendDataDAC(801, lSnares.flare ) -- display flare
ExportScript.Tools.SendDataDAC(802, lblinkChaff ) -- blink chaff active/aktive empty chaff
ExportScript.Tools.SendDataDAC(803, lblinkFlare ) -- blink flare active/aktive empty flare
ExportScript.Tools.SendDataDAC(804, ExportScript.AF.tmpChaff < 20 and 1 or 0 ) -- minimum chaff lamp
ExportScript.Tools.SendDataDAC(805, ExportScript.AF.tmpFlare < 10 and 1 or 0 ) -- minimum flare lamp
end
end
function ExportScript.AF.MechanicalDevicesIndicator(FunctionTyp)
local lFunctionTyp = FunctionTyp or "Ikarus"
-- The mechanical devices indicator shows the position of the landing gear, flaps, leading edge flaps and airbrake
local lMechInfo = LoGetMechInfo() -- mechanical components, e.g. Flaps, Wheelbrakes,...
if lMechInfo == nil then
return
end
local lTrueAirSpeed = LoGetTrueAirSpeed()
if lTrueAirSpeed == nil then
lTrueAirSpeed = 0
end
--ExportScript.Tools.WriteToLog('ExportScript.AF.MechanicalDevicesIndicator: '..ExportScript.Tools.dump(lMechInfo))
--[[
[hook] = {
[status] = number: "0"
[value] = number: "0"
}
[parachute] = {
[status] = number: "0"
[value] = number: "0"
}
[controlsurfaces] = {
[eleron] = {
[left] = number: "0"
[right] = number: "-0.21084336936474"
}
[elevator] = {
[left] = number: "-0"
[right] = number: "-0"
}
[rudder] = {
[left] = number: "0"
[right] = number: "0"
}
}
[airintake] = {
[status] = number: "0"
[value] = number: "0"
}
[canopy] = {
[status] = number: "0"
[value] = number: "0"
}
[refuelingboom] = {
[status] = number: "0"
[value] = number: "0"
}
[wing] = {
[status] = number: "0"
[value] = number: "0"
}
[noseflap] = {
[status] = number: "0"