GCC Code Coverage Report


Directory: ./
File: firmware/controllers/lua/script_impl.cpp
Date: 2025-10-03 00:57:22
Coverage Exec Excl Total
Lines: 40.0% 18 0 45
Functions: 66.7% 4 0 6
Branches: 24.0% 6 0 25
Decisions: 22.7% 5 - 22

Line Branch Decision Exec Source
1 /**
2 * @file script_impl.cpp
3 *
4 * @date Oct 5, 2014
5 * @author Andrey Belomutskiy, (c) 2012-2020
6 */
7
8 #include "pch.h"
9
10 #include "script_impl.h"
11
12 using namespace rusefi::stringutil;
13
14 static script1_Map3D_f32t scriptTable1{"script1"};
15 static script2_Map3D_f32t scriptTable2{"script2"};
16 static script3_Map3D_u8t scriptTable3{"script3"};
17 static script4_Map3D_u8t scriptTable4{"script4"};
18
19 2 ValueProvider3D *getscriptTable(int index) {
20
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 switch (index) {
21 default:
22 return &scriptTable1;
23
1/1
✓ Decision 'true' taken 2 times.
2 case 1:
24 2 return &scriptTable2;
25 case 2:
26 return &scriptTable3;
27 case 3:
28 return &scriptTable4;
29 }
30 }
31
32 // todo: template this copy-pasta
33 /**
34 * @return zero-based index of curve with given name
35 */
36 2 expected<int> getCurveIndexByName(const char *name) {
37
1/2
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
1/2
✓ Decision 'true' taken 8 times.
✗ Decision 'false' not taken.
8 for (int i = 0;i<SCRIPT_CURVE_COUNT;i++) {
38
3/3
✓ Branch 2 taken 8 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 6 times.
2/2
✓ Decision 'true' taken 2 times.
✓ Decision 'false' taken 6 times.
8 if (strEqualCaseInsensitive(name, engineConfiguration->scriptCurveName[i])) {
39 2 return i;
40 }
41 }
42
43 return unexpected;
44 }
45
46 expected<int> getTableIndexByName(const char *name) {
47 for (int i = 0;i<SCRIPT_TABLE_COUNT;i++) {
48 if (strEqualCaseInsensitive(name, engineConfiguration->scriptTableName[i])) {
49 return i;
50 }
51 }
52
53 return unexpected;
54 }
55
56 expected<int> getSettingIndexByName(const char *name) {
57 for (int i = 0;i<SCRIPT_SETTING_COUNT;i++) {
58 if (strEqualCaseInsensitive(name, engineConfiguration->scriptSettingName[i])) {
59 return i;
60 }
61 }
62
63 return unexpected;
64 }
65
66 1 float getCurveValue(int index, float key) {
67 // not great code at all :(
68
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 switch (index) {
69 default:
70 return interpolate2d(key, config->scriptCurve1Bins, config->scriptCurve1);
71 case 1:
72 return interpolate2d(key, config->scriptCurve2Bins, config->scriptCurve2);
73 case 2:
74 return interpolate2d(key, config->scriptCurve3Bins, config->scriptCurve3);
75
1/1
✓ Decision 'true' taken 1 time.
1 case 3:
76 1 return interpolate2d(key, config->scriptCurve4Bins, config->scriptCurve4);
77 case 4:
78 return interpolate2d(key, config->scriptCurve5Bins, config->scriptCurve5);
79 case 5:
80 return interpolate2d(key, config->scriptCurve6Bins, config->scriptCurve6);
81 }
82 }
83
84 584 void initScriptImpl() {
85 584 scriptTable1.initTable(config->scriptTable1, config->scriptTable1RpmBins, config->scriptTable1LoadBins);
86 584 scriptTable2.initTable(config->scriptTable2, config->scriptTable2RpmBins, config->scriptTable2LoadBins);
87 584 scriptTable3.initTable(config->scriptTable3, config->scriptTable3RpmBins, config->scriptTable3LoadBins);
88 584 scriptTable4.initTable(config->scriptTable4, config->scriptTable4RpmBins, config->scriptTable4LoadBins);
89 584 }
90