forked from BastianGschrey/PowerTune
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dashboard.cpp
5177 lines (4825 loc) · 146 KB
/
dashboard.cpp
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
#include <dashboard.h>
#include <QStringList>
#include <QDebug>
#include <QVector>
#include "math.h"
////
QVector<int>averageSpeed(0);
QVector<int>averageRPM(0);
QVector<qreal>averageexanaloginput7(0);
int avgspeed;
int avgrpm;
qreal avgexanaloginput7;
qreal R2 = 1430; // R2 is always Fixed ( Two resistors in line 1100 + 330 Ohms
qreal R3 = 100; // R2 is always Fixed ( Two resistors in line 1100 + 330 Ohms
qreal R4 = 1000; // R2 is always Fixed ( Two resistors in line 1100 + 330 Ohms
qreal AN0R3 = 0;
qreal AN1R3 = 0;
qreal AN2R3 = 0;
qreal AN0R4 = 0;
qreal AN1R4 = 0;
qreal AN2R4 = 0;
qreal Rtotalexan0; // Resistance of all internal Resistors of the EX Board for AN0
qreal Rtotalexan1; // Resistance of all internal Resistors of the EX Board for AN1
qreal Rtotalexan2; // Resistance of all internal Resistors of the EX Board for AN2
qreal AN00;
qreal AN05;
qreal AN10;
qreal AN15;
qreal AN20;
qreal AN25;
qreal AN30;
qreal AN35;
qreal AN40;
qreal AN45;
qreal AN50;
qreal AN55;
qreal AN60;
qreal AN65;
qreal AN70;
qreal AN75;
qreal AN80;
qreal AN85;
qreal AN90;
qreal AN95;
qreal AN100;
qreal AN105;
// Ex Board Analog
qreal EXAN00;
qreal EXAN05;
qreal EXAN10;
qreal EXAN15;
qreal EXAN20;
qreal EXAN25;
qreal EXAN30;
qreal EXAN35;
qreal EXAN40;
qreal EXAN45;
qreal EXAN50;
qreal EXAN55;
qreal EXAN60;
qreal EXAN65;
qreal EXAN70;
qreal EXAN75;
qreal ResistanceEXAN0;
qreal ResistanceEXAN1;
qreal ResistanceEXAN2;
int EXsteinhart0; //Flag to use Steinhart/hart for Analog input 0
int EXsteinhart1; //Flag to use Steinhart/hart for Analog input 1
int EXsteinhart2; //Flag to use Steinhart/hart for Analog input 2
qreal lamdamultiplicator = 1;
int brightness;
DashBoard::DashBoard(QObject *parent)
: QObject(parent)
, m_Odo(0)
, m_Trip(0)
, m_rpm(0)
, m_Intakepress(0)
, m_PressureV(0)
, m_ThrottleV(0)
, m_Primaryinp(0)
, m_Fuelc(0)
, m_Leadingign(0)
, m_Trailingign(0)
, m_Fueltemp(0)
, m_Moilp(0)
, m_Boosttp(0)
, m_Boostwg(0)
, m_Watertemp(0)
, m_Intaketemp(0)
, m_Knock(0)
, m_BatteryV(0)
, m_speed(0)
, m_Iscvduty(0)
, m_O2volt(0)
, m_na1(0)
, m_Secinjpulse(0)
, m_na2(0)
, m_InjDuty(0)
, m_InjDuty2(0)
, m_InjAngle(0)
, m_EngLoad(0)
, m_MAF1V(0)
, m_MAF2V(0)
, m_injms(0)
, m_Inj(0)
, m_Ign(0)
, m_Dwell(0)
, m_BoostPres(0)
, m_BoostPreskpa(0)
, m_BoostDuty(0)
, m_MAFactivity(0)
, m_O2volt_2(0)
, m_Cyl1_O2_Corr(0)
, m_Cyl2_O2_Corr(0)
, m_Cyl3_O2_Corr(0)
, m_Cyl4_O2_Corr(0)
, m_Cyl5_O2_Corr(0)
, m_Cyl6_O2_Corr(0)
, m_Cyl7_O2_Corr(0)
, m_Cyl8_O2_Corr(0)
//Boost
, m_pim(0)
//Aux Inputs
, m_auxcalc1(0.00)
, m_auxcalc2(0.00)
, m_auxcalc3(0.00)
, m_auxcalc4(0.00)
// Sensor Info FD3S
, m_sens1(0.00)
, m_sens2(0.00)
, m_sens3(0.00)
, m_sens4(0.00)
, m_sens5(0.00)
, m_sens6(0.00)
, m_sens7(0.00)
, m_sens8(0.00)
//Flag Strings
, m_FlagString1 ("F-1")
, m_FlagString2 ("F-2")
, m_FlagString3 ("F-3")
, m_FlagString4 ("F-4")
, m_FlagString5 ("F-5")
, m_FlagString6 ("F-6")
, m_FlagString7 ("F-7")
, m_FlagString8 ("F-8")
, m_FlagString9 ("F-9")
, m_FlagString10 ("F10")
, m_FlagString11 ("F11")
, m_FlagString12 ("F12")
, m_FlagString13 ("F13")
, m_FlagString14 ("F14")
, m_FlagString15 ("F15")
, m_FlagString16 ("F16")
//Sensor Srings
, m_SensorString1 ("SEN1")
, m_SensorString2 ("SEN2")
, m_SensorString3 ("SEN3")
, m_SensorString4 ("SEN4")
, m_SensorString5 ("SEN5")
, m_SensorString6 ("SEN6")
, m_SensorString7 ("SEN7")
, m_SensorString8 ("SEN8")
//Bit Flags for Sensors
, m_Flag1(0)
, m_Flag2(0)
, m_Flag3(0)
, m_Flag4(0)
, m_Flag5(0)
, m_Flag6(0)
, m_Flag7(0)
, m_Flag8(0)
, m_Flag9(0)
, m_Flag10(0)
, m_Flag11(0)
, m_Flag12(0)
, m_Flag13(0)
, m_Flag14(0)
, m_Flag15(0)
, m_Flag16(0)
, m_Flag17(0)
, m_Flag18(0)
, m_Flag19(0)
, m_Flag20(0)
, m_Flag21(0)
, m_Flag22(0)
, m_Flag23(0)
, m_Flag24(0)
, m_Flag25(0)
//Adaptronic extra
, m_MAP(0)
, m_MAP2(0)
, m_PANVAC(0)
, m_AUXT(0)
, m_AFR(0)
, m_AFRLEFTBANKTARGET(0)
, m_AFRRIGHTBANKTARGET(0)
//
, m_AFRLEFTBANKACTUAL(0)
, m_AFRRIGHTBANKACTUAL(0)
, m_BOOSTOFFSET(0)
, m_REVLIM3STEP(0)
, m_REVLIM2STEP(0)
, m_REVLIMGIGHSIDE(0)
, m_REVLIMBOURNOUT(0)
, m_LEFTBANKO2CORR(0)
, m_RIGHTBANKO2CORR(0)
, m_TRACTIONCTRLOFFSET(0)
, m_DRIVESHAFTOFFSET(0)
, m_TCCOMMAND(0)
, m_FSLCOMMAND(0)
, m_FSLINDEX(0)
, m_AFRcyl1(0)
, m_AFRcyl2(0)
, m_AFRcyl3(0)
, m_AFRcyl4(0)
, m_AFRcyl5(0)
, m_AFRcyl6(0)
, m_AFRcyl7(0)
, m_AFRcyl8(0)
, m_TPS(0)
, m_IdleValue(0)
, m_MVSS(0)
, m_SVSS(0)
, m_Inj1(0)
, m_Inj2(0)
, m_Inj3(0)
, m_Inj4(0)
, m_Ign1(0)
, m_Ign2(0)
, m_Ign3(0)
, m_Ign4(0)
, m_TRIM(0)
, m_LAMBDA(0)
, m_LAMBDATarget(0)
, m_FuelPress(0)
, m_GearOilPress(0)
//GPS Strings
, m_gpsTime ("0")
, m_gpsAltitude (0)
, m_gpsLatitude (0)
, m_gpsLongitude (0)
, m_gpsSpeed (0)
, m_gpsVisibleSatelites (0)
, m_gpsFIXtype ("no connection")
, m_gpsbaering (0)
//units
, m_units("unit")
, m_speedunits("unit")
, m_pressureunits("unit")
//Sensors
, m_accelx(0)
, m_accely(0)
, m_accelz(0)
, m_gyrox(0)
, m_gyroy(0)
, m_gyroz(0)
, m_compass(0)
, m_ambitemp(0)
, m_ambipress(0)
// ,m_TimeoutStat("----")
// ,m_RecvData("----")
//calculations
, m_Gear(0)
, m_Gearoffset(0)
, m_GearCalculation(0)
, m_Power(0)
, m_Torque(0)
, m_AccelTimer(0)
, m_Weight(0)
//Official Pi screen present screen
, m_screen(0)
, m_accelpedpos(0)
, m_airtempensor2(0)
, m_antilaglauchswitch(0)
, m_antilaglaunchon(0)
, m_auxrevlimitswitch(0)
, m_avfueleconomy(0)
, m_battlight(0)
, m_boostcontrol(0)
, m_brakepress(0)
, m_clutchswitchstate(0)
, m_coolantpress(0)
, m_decelcut(0)
, m_diffoiltemp(0)
, m_distancetoempty(0)
, m_egt1(0)
, m_egt2(0)
, m_egt3(0)
, m_egt4(0)
, m_egt5(0)
, m_egt6(0)
, m_egt7(0)
, m_egt8(0)
, m_egt9(0)
, m_egt10(0)
, m_egt11(0)
, m_egt12(0)
, m_excamangle1(0)
, m_excamangle2(0)
, m_flatshiftstate(0)
, m_fuelclevel(0)
, m_fuelcomposition(0)
, m_fuelconsrate(0)
, m_fuelcutperc(0)
, m_fuelflowdiff(0)
, m_fuelflowret(0)
, m_fueltrimlongtbank1(0)
, m_fuelflow(0)
, m_fueltrimlongtbank2(0)
, m_fueltrimshorttbank1(0)
, m_fueltrimshorttbank2(0)
, m_gearswitch(0)
, m_handbrake(0)
, m_highbeam(0)
, m_lowBeam(0)
, m_tractionControl(0)
, m_homeccounter(0)
, m_incamangle1(0)
, m_incamangle2(0)
, m_knocklevlogged1(0)
, m_knocklevlogged2(0)
, m_knockretardbank1(0)
, m_knockretardbank2(0)
, m_lambda2(0)
, m_lambda3(0)
, m_lambda4(0)
, m_launchcontolfuelenrich(0)
, m_launchctrolignretard(0)
, m_leftindicator(0)
, m_limpmode(0)
, m_mil(0)
, m_missccount(0)
, m_nosactive(0)
, m_nospress(0)
, m_nosswitch(0)
, m_oilpres(0)
, m_oiltemp(0)
, m_rallyantilagswitch(0)
, m_rightindicator(0)
, m_targetbstlelkpa(0)
, m_timeddutyout1(0)
, m_timeddutyout2(0)
, m_timeddutyoutputactive(0)
, m_torqueredcutactive(0)
, m_torqueredlevelactive(0)
, m_transientthroactive(0)
, m_transoiltemp(0)
, m_triggerccounter(0)
, m_triggersrsinceasthome(0)
, m_turborpm(0)
, m_turborpm2(0)
, m_wastegatepress(0)
, m_wheeldiff(0)
, m_wheelslip(0)
, m_wheelspdftleft(0)
, m_wheelspdftright(0)
, m_wheelspdrearleft(0)
, m_wheelspdrearright(0)
, m_speedpercent(1)
, m_maxRPM(8000)
, m_rpmStage1(3000)
, m_rpmStage2(4000)
, m_rpmStage3(6000)
, m_rpmStage4(7000)
, m_waterwarn(999)
, m_rpmwarn(9999)
, m_knockwarn(999)
, m_boostwarn(999)
, m_smoothrpm(0)
, m_smoothspeed(0)
, m_smoothexAnalogInput7(0)
, m_gearcalc1(0)
, m_gearcalc2(0)
, m_gearcalc3(0)
, m_gearcalc4(0)
, m_gearcalc5(0)
, m_gearcalc6(0)
, m_gearcalcactivation(0)
, m_ecu(0)
, m_Error("")
, m_autogear("")
, m_ExternalSpeed(0)
//laptimer
, m_currentLap(0)
, m_laptime("00:00.000")
, m_Lastlaptime("00:00.000")
, m_bestlaptime("00:00.000")
, m_draggable(0)
, m_wifi()
, m_Analog0(0)
, m_Analog1(0)
, m_Analog2(0)
, m_Analog3(0)
, m_Analog4(0)
, m_Analog5(0)
, m_Analog6(0)
, m_Analog7(0)
, m_Analog8(0)
, m_Analog9(0)
, m_Analog10(0)
, m_AnalogCalc0()
, m_AnalogCalc1()
, m_AnalogCalc2()
, m_AnalogCalc3()
, m_AnalogCalc4()
, m_AnalogCalc5()
, m_AnalogCalc6()
, m_AnalogCalc7()
, m_AnalogCalc8()
, m_AnalogCalc9()
, m_AnalogCalc10()
, m_EXAnalogCalc0()
, m_EXAnalogCalc1()
, m_EXAnalogCalc2()
, m_EXAnalogCalc3()
, m_EXAnalogCalc4()
, m_EXAnalogCalc5()
, m_EXAnalogCalc6()
, m_EXAnalogCalc7()
, m_Lambdamultiply()
, m_Userchannel1()
, m_Userchannel2()
, m_Userchannel3()
, m_Userchannel4()
, m_Userchannel5()
, m_Userchannel6()
, m_Userchannel7()
, m_Userchannel8()
, m_Userchannel9()
, m_Userchannel10()
, m_Userchannel11()
, m_Userchannel12()
, m_FuelLevel()
, m_SteeringWheelAngle()
, m_Brightness()
, m_Visibledashes(1)
, m_oilpressurelamp()
, m_overtempalarm()
, m_alternatorfail()
, m_AuxTemp1()
//Quartermiletimer
, m_sixtyfoottime()
, m_sixtyfootspeed()
, m_threehundredthirtyfoottime()
, m_threehundredthirtyfootspeed()
, m_eightmiletime()
, m_eightmilespeed()
, m_quartermiletime()
, m_quartermilespeed()
, m_thousandfoottime()
, m_thousandfootspeed()
, m_zerotohundredt()
, m_hundredtotwohundredtime()
, m_twohundredtothreehundredtime()
, m_reactiontime()
, m_IGBTPhaseATemp()
, m_IGBTPhaseBTemp()
, m_IGBTPhaseCTemp()
, m_GateDriverTemp()
, m_ControlBoardTemp()
, m_RtdTemp1()
, m_RtdTemp2()
, m_RtdTemp3()
, m_RtdTemp4()
, m_RtdTemp5()
, m_EMotorTemperature()
, m_TorqueShudder()
, m_DigInput1FowardSw()
, m_DigInput2ReverseSw()
, m_DigInput3BrakeSw()
, m_DigInput4RegenDisableSw()
, m_DigInput5IgnSw()
, m_DigInput6StartSw()
, m_DigInput7Bool()
, m_DigInput8Bool()
, m_EMotorAngle()
, m_EMotorSpeed()
, m_ElectricalOutFreq()
, m_DeltaResolverFiltered()
, m_PhaseACurrent()
, m_PhaseBCurrent()
, m_PhaseCCurrent()
, m_DCBusCurrent()
, m_DCBusVoltage()
, m_OutputVoltage()
, m_VABvdVoltage()
, m_VBCvqVoltage()
, m_TirepresLF()
, m_TirepresRF()
, m_TirepresRR()
, m_TirepresLR()
, m_TiretempLF()
, m_TiretempRF()
, m_TiretempRR()
, m_TiretempLR()
, m_DigitalInput1()
, m_DigitalInput2()
, m_DigitalInput3()
, m_DigitalInput4()
, m_DigitalInput5()
, m_DigitalInput6()
, m_DigitalInput7()
//
, m_igncut()
, m_undrivenavgspeed()
, m_drivenavgspeed()
, m_dsettargetslip()
, m_tractionctlpowerlimit()
, m_knockallpeak()
, m_knockcorr()
, m_knocklastcyl()
, m_totalfueltrim()
, m_totaligncomp()
, m_egthighest()
, m_cputempecu()
, m_errorcodecount()
, m_lostsynccount()
, m_egtdiff()
, m_activeboosttable()
, m_activetunetable()
, m_genericoutput1()
, m_CalibrationSelect()
{
}
// Odometer
void DashBoard::setOdo(const qreal &Odo)
{
if (m_Odo == Odo)
return;
m_Odo = Odo;
emit odoChanged(Odo);
}
// Tripmeter
void DashBoard::setTrip(const qreal &Trip)
{
if (m_Trip == Trip)
return;
m_Trip = Trip;
emit tripChanged(Trip);
}
void DashBoard::setAnalogVal(const qreal &A00,const qreal &A05,const qreal &A10,const qreal &A15,const qreal &A20,const qreal &A25,const qreal &A30,const qreal &A35,const qreal &A40,const qreal &A45,const qreal &A50,const qreal &A55,const qreal &A60,const qreal &A65,const qreal &A70,const qreal &A75,const qreal &A80,const qreal &A85,const qreal &A90,const qreal &A95,const qreal &A100,const qreal &A105)
{
AN00 = A00;
AN05 = A05;
AN10 = A10;
AN15 = A15;
AN20 = A20;
AN25 = A25;
AN30 = A30;
AN35 = A35;
AN40 = A40;
AN45 = A45;
AN50 = A50;
AN55 = A55;
AN60 = A60;
AN65 = A65;
AN70 = A70;
AN75 = A75;
AN80 = A80;
AN85 = A85;
AN90 = A90;
AN95 = A95;
AN100 = A100;
AN105 = A105;
//qDebug()<< "AN75 " <<AN75;
}
void DashBoard::setEXAnalogVal(const qreal &EXA00,const qreal &EXA05,const qreal &EXA10,const qreal &EXA15,const qreal &EXA20,const qreal &EXA25,const qreal &EXA30,const qreal &EXA35,const qreal &EXA40,const qreal &EXA45,const qreal &EXA50,const qreal &EXA55,const qreal &EXA60,const qreal &EXA65,const qreal &EXA70,const qreal &EXA75, const int &steinhartcalc0on, const int &steinhartcalc1on, const int &steinhartcalc2on,const int &AN0R3VAL,const int &AN0R4VAL,const int &AN1R3VAL,const int &AN1R4VAL,const int &AN2R3VAL,const int &AN2R4VAL)
{
EXAN00 = EXA00;
EXAN05 = EXA05;
EXAN10 = EXA10;
EXAN15 = EXA15;
EXAN20 = EXA20;
EXAN25 = EXA25;
EXAN30 = EXA30;
EXAN35 = EXA35;
EXAN40 = EXA40;
EXAN45 = EXA45;
EXAN50 = EXA50;
EXAN55 = EXA55;
EXAN60 = EXA60;
EXAN65 = EXA65;
EXAN70 = EXA70;
EXAN75 = EXA75;
EXsteinhart0 = steinhartcalc0on;
EXsteinhart1 = steinhartcalc1on;
EXsteinhart2 = steinhartcalc2on;
// Calculating the Boad internal resistance of the Voltage divider
// EX Analog 0
if (AN0R3VAL !=0 && AN0R4VAL !=0)
{
Rtotalexan0 = 1/((1/R2)+(1/R3)+(1/R4));
}
if (AN0R3VAL ==0 && AN0R4VAL !=0)
{
Rtotalexan0 = (R2*R4)/(R2+R4);
}
if (AN0R3VAL !=0 && AN0R4VAL ==0)
{
Rtotalexan0 = (R2*R3)/(R2+R3);
}
if (AN0R3VAL ==0 && AN0R4VAL ==0)
{
Rtotalexan0 = R2;
}
// EX Analog 1
if (AN1R3VAL !=0 && AN1R4VAL !=0)
{
Rtotalexan1 = 1/((1/R2)+(1/R3)+(1/R4));
}
if (AN1R3VAL ==0 && AN1R4VAL !=0)
{
Rtotalexan1 = (R2*R4)/(R2+R4);
}
if (AN1R3VAL !=0 && AN1R4VAL ==0)
{
Rtotalexan1 = (R2*R3)/(R2+R3);
}
if (AN1R3VAL ==0 && AN1R4VAL ==0)
{
Rtotalexan1 = R2;
}
// EX Analog 2
if (AN2R3VAL !=0 && AN2R4VAL !=0)
{
Rtotalexan2 = 1/((1/R2)+(1/R3)+(1/R4));
}
if (AN2R3VAL ==0 && AN2R4VAL !=0)
{
Rtotalexan2 = (R2*R4)/(R2+R4);
}
if (AN2R3VAL !=0 && AN2R4VAL ==0)
{
Rtotalexan2 = (R2*R3)/(R2+R3);
}
if (AN2R3VAL ==0 && AN2R4VAL ==0)
{
Rtotalexan2 = R2;
}
/*
qDebug() <<"///////////////////////////////////////////////////////////// :" ;
qDebug() <<AN0R3VAL<<AN0R4VAL<<AN1R3VAL<<AN1R4VAL<<AN2R3VAL<<AN2R4VAL ;
qDebug() <<"RTotal AN0 :" <<Rtotalexan0 ;
qDebug() <<"RTotal AN1 :" <<Rtotalexan1 ;
qDebug() <<"RTotal AN2 :" <<Rtotalexan2 ;
qDebug() <<"///////////////////////////////////////////////////////////// :" ;
*/
}
void DashBoard::setSteinhartcalc(const qreal &T01,const qreal &T02,const qreal &T03,const qreal &R01,const qreal &R02,const qreal &R03,const qreal &T11,const qreal &T12,const qreal &T13,const qreal &R11,const qreal &R12,const qreal &R13,const qreal &T21,const qreal &T22,const qreal &T23,const qreal &R21,const qreal &R22,const qreal &R23)
{
//qDebug() <<"Values :" <<T01 << R01 << T02 <<R02 <<T03 << R03 << T11 << R11 << T12 <<R12 <<T13 << R13 << T21 << R21 << T22 <<R22 <<T23 << R23;
//EX Analog 0 Calculation
long double L01 = log(R01); //Logrythm of Resistance 1
long double L02 = log(R02); //Logrythm of Resistance 2
long double L03 = log(R03); //Logrythm of Resistance 3
//Convert Temperature from CELCIUS to Kelvin and get factor
long double Y01 = 1/(T01+273.15);
long double Y02 = 1/(T02+273.15);
long double Y03 = 1/(T03+273.15);
//Coefficent of L and Y
long double V02 = (Y02-Y01)/(L02-L01);
long double V03 = (Y03-Y01)/(L03-L01);
//Coefficent Calculations
C0 = ((V03 - V02)/(L03-L02))*(pow((L01+L02+L02),-1));
B0 = (V03-C0*(pow(L01,2)+L01*L02+pow(L02,2)));
A0 = Y01 -(B0+pow(L01,2)*C0)*L01;
//EX Analog 1 Calculation
long double L11 = log(R11); //Logrythm of Resistance 1
long double L12 = log(R12); //Logrythm of Resistance 2
long double L13 = log(R13); //Logrythm of Resistance 3
//Convert Temperature from CELCIUS to Kelvin and get factor
long double Y11 = 1/(T11+273.15);
long double Y12 = 1/(T12+273.15);
long double Y13 = 1/(T13+273.15);
//Coefficent of L and Y
long double V12 = (Y12-Y11)/(L12-L11);
long double V13 = (Y13-Y11)/(L13-L11);
//Coefficent Calculations
C1 = ((V13 - V12)/(L13-L12))*(pow((L11+L12+L12),-1));
B1 = (V13-C1*(pow(L11,2)+L11*L12+pow(L12,2)));
A1 = Y11 -(B1+pow(L11,2)*C1)*L11;
//EX Analog 2 Calculation
long double L21 = log(R21); //Logrythm of Resistance 1
long double L22 = log(R22); //Logrythm of Resistance 2
long double L23 = log(R23); //Logrythm of Resistance 3
//Convert Temperature from CELCIUS to Kelvin and get factor
long double Y21 = 1/(T21+273.15);
long double Y22 = 1/(T22+273.15);
long double Y23 = 1/(T23+273.15);
//Coefficent of L and Y
long double V22 = (Y22-Y21)/(L22-L21);
long double V23 = (Y23-Y21)/(L23-L21);
//Coefficent Calculations
C2 = ((V23 - V22)/(L23-L22))*(pow((L21+L22+L22),-1));
B2 = (V23-C2*(pow(L21,2)+L22*L22+pow(L22,2)));
A2 = Y21 -(B2+pow(L21,2)*C2)*L21;
//
}
// Advanced Info FD3S
void DashBoard::setrpm(const qreal &rpm)
{
if (m_rpm == rpm)
return;
m_rpm = rpm;
//Smoothing
if (m_smoothrpm >0)
{
averageRPM.removeFirst();
averageRPM.append(m_rpm);
avgrpm = 0;
for (int i = 0; i <= m_smoothrpm-1; i++){avgrpm+= averageRPM[i];}
m_rpm = avgrpm/m_smoothrpm;
}
emit rpmChanged(rpm);
}
void DashBoard::setIntakepress(const qreal &Intakepress)
{
if (m_Intakepress == Intakepress)
return;
if (m_pressureunits == "metric")
{m_Intakepress = Intakepress;}
if (m_pressureunits == "imperial")
{m_Intakepress = Intakepress * 0.145038;}
emit intakepressChanged(Intakepress);
return;
}
void DashBoard::setPressureV(const qreal &PressureV)
{
if (m_PressureV == PressureV)
return;
m_PressureV = PressureV;
emit pressureVChanged(PressureV);
}
void DashBoard::setThrottleV(const qreal &ThrottleV)
{
if (m_ThrottleV == ThrottleV)
return;
m_ThrottleV= ThrottleV;
emit throttleVChanged(ThrottleV);
}
void DashBoard::setPrimaryinp(const qreal &Primaryinp)
{
if (m_Primaryinp == Primaryinp)
return;
m_Primaryinp= Primaryinp;
emit primaryinpChanged(Primaryinp);
}
void DashBoard::setFuelc(const qreal &Fuelc)
{
if (m_Fuelc == Fuelc)
return;
m_Fuelc= Fuelc;
emit fuelcChanged(Fuelc);
}
void DashBoard::setLeadingign(const qreal &Leadingign)
{
if (m_Leadingign == Leadingign)
return;
m_Leadingign= Leadingign;
emit leadingignChanged(Leadingign);
}
void DashBoard::setTrailingign(const qreal &Trailingign)
{
if (m_Trailingign == Trailingign)
return;
m_Trailingign= Trailingign;
emit trailingignChanged(Trailingign);
}
void DashBoard::setFueltemp(const qreal &Fueltemp)
{
if (m_Fueltemp == Fueltemp)
return;
if (m_units == "metric")
{m_Fueltemp = Fueltemp;}
if (m_units == "imperial")
{m_Fueltemp = Fueltemp * 1.8 + 32;}
emit fueltempChanged(Fueltemp);
}
void DashBoard::setMoilp(const qreal &Moilp)
{
if (m_Moilp == Moilp)
return;
m_Moilp = Moilp;
emit moilpChanged(Moilp);
}
void DashBoard::setBoosttp(const qreal &Boosttp)
{
if (m_Boosttp == Boosttp)
return;
m_Boosttp = Boosttp;
emit boosttpChanged(Boosttp);
}
void DashBoard::setBoostwg(const qreal &Boostwg)
{
if (m_Boostwg == Boostwg)
return;
m_Boostwg = Boostwg;
emit boostwgChanged(Boostwg);
}
void DashBoard::setWatertemp(const qreal &Watertemp)
{
if (m_Watertemp == Watertemp)
return;
if (m_units == "metric")
{m_Watertemp = Watertemp;}
if (m_units == "imperial")
{m_Watertemp = Watertemp * 1.8 + 32;}
emit watertempChanged(Watertemp);
}
void DashBoard::setIntaketemp(const qreal &Intaketemp)
{
if (m_units == "metric")
{ m_Intaketemp = Intaketemp;}
if (m_units == "imperial")
{m_Intaketemp = Intaketemp * 1.8 + 32;}
emit intaketempChanged(Intaketemp);
}
void DashBoard::setKnock(const qreal &Knock)
{
if (m_Knock == Knock)
return;
m_Knock = Knock;
emit knockChanged(Knock);
}
void DashBoard::setBatteryV(const qreal &BatteryV)
{
if (m_BatteryV == BatteryV)
return;
m_BatteryV = BatteryV;
emit batteryVChanged(BatteryV);
}
void DashBoard::setSpeed(const qreal &speed)
{
//qDebug()<< "SPEED" << m_speed;
if (m_speed == speed)
return;
if (m_speedunits == "metric")
{m_speed = qRound(speed * m_speedpercent);}
if (m_speedunits == "imperial")
{m_speed = qRound((speed * 0.621371) * m_speedpercent);}
if (m_smoothspeed != 0)
{
averageSpeed.removeFirst();
averageSpeed.append(m_speed);
//qDebug() << "Vector Speed " << averageSpeed;
avgspeed = 0;
for (int i = 0; i <= m_smoothspeed-1; i++){avgspeed+= averageSpeed[i];}
m_speed = avgspeed/m_smoothspeed;
// qDebug() << "Average Speed " << m_speed;
}
if (m_ExternalSpeed == 0){
emit speedChanged(m_speed);
}
}
void DashBoard::setIscvduty(const qreal &Iscvduty)
{
if (m_Iscvduty == Iscvduty)
return;
m_Iscvduty = Iscvduty;
emit iscvdutyChanged(Iscvduty);
}
void DashBoard::setO2volt(const qreal &O2volt)
{
if (m_O2volt == O2volt)
return;
m_O2volt = O2volt;
emit o2voltChanged(O2volt);
}
void DashBoard::setCyl1_O2_Corr(const qreal &Cyl1_O2_Corr)
{
if (m_Cyl1_O2_Corr == Cyl1_O2_Corr)
return;
m_Cyl1_O2_Corr = Cyl1_O2_Corr;
emit Cyl1_O2_CorrChanged(Cyl1_O2_Corr);
}
void DashBoard::setCyl2_O2_Corr(const qreal &Cyl2_O2_Corr)
{
if (m_Cyl2_O2_Corr == Cyl2_O2_Corr)
return;
m_Cyl2_O2_Corr = Cyl2_O2_Corr;
emit Cyl2_O2_CorrChanged(Cyl2_O2_Corr);
}
void DashBoard::setCyl3_O2_Corr(const qreal &Cyl3_O2_Corr)
{
if (m_Cyl3_O2_Corr == Cyl3_O2_Corr)
return;
m_Cyl3_O2_Corr = Cyl3_O2_Corr;
emit Cyl3_O2_CorrChanged(Cyl3_O2_Corr);
}
void DashBoard::setCyl4_O2_Corr(const qreal &Cyl4_O2_Corr)
{
if (m_Cyl4_O2_Corr == Cyl4_O2_Corr)
return;
m_Cyl4_O2_Corr = Cyl4_O2_Corr;
emit Cyl4_O2_CorrChanged(Cyl4_O2_Corr);
}
void DashBoard::setCyl5_O2_Corr(const qreal &Cyl5_O2_Corr)
{
if (m_Cyl5_O2_Corr == Cyl5_O2_Corr)
return;
m_Cyl5_O2_Corr = Cyl5_O2_Corr;
emit Cyl5_O2_CorrChanged(Cyl5_O2_Corr);
}
void DashBoard::setCyl6_O2_Corr(const qreal &Cyl6_O2_Corr)
{
if (m_Cyl6_O2_Corr == Cyl6_O2_Corr)
return;
m_Cyl6_O2_Corr = Cyl6_O2_Corr;
emit Cyl6_O2_CorrChanged(Cyl6_O2_Corr);
}
void DashBoard::setCyl7_O2_Corr(const qreal &Cyl7_O2_Corr)
{
if (m_Cyl7_O2_Corr == Cyl7_O2_Corr)