GCC Code Coverage Report


Directory: ./
File: sensors/MultiSensorSource.cpp
Date: 2026-12-01 12:27:28
Exec Total Coverage
Lines: 35 45 77.8%
Functions: 5 7 71.4%
Branches: 33 60 55.0%

Line Branch Exec Source
1 /*
2 * This file is part of the Falcon Player (FPP) and is Copyright (C)
3 * 2013-2022 by the Falcon Player Developers.
4 *
5 * The Falcon Player (FPP) is free software, and is covered under
6 * multiple Open Source licenses. Please see the included 'LICENSES'
7 * file for descriptions of what files are covered by each license.
8 *
9 * This source file is covered under the LGPL v2.1 as described in the
10 * included LICENSE.LGPL file.
11 */
12
13 #include "fpp-pch.h"
14
15 #include "fpp-json.h"
16
17 #include "MultiSensorSource.h"
18
19 2 MultiSensorSource::MultiSensorSource(Json::Value& config) :
20 2 SensorSource(config) {
21
4/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 1 times.
4 for (int x = 0; x < config["sources"].size(); x++) {
22
5/8
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
3 std::string sourcename = config["sources"][x]["source"].asString();
23
4/8
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
2 uint32_t chan = config["sources"][x]["channels"].asInt();
24
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 SensorSource* src = Sensors::INSTANCE.getSensorSource(sourcename);
25
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (src) {
26
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 sources.push_back(src);
27
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 channels.push_back(chan);
28 }
29 2 }
30 4 }
31 ✗ MultiSensorSource::~MultiSensorSource() {
32 ✗ }
33
34 1 void MultiSensorSource::Init(std::map<int, std::function<bool(int)>>& callbacks) {
35 1 std::map<int, std::function<bool(int)>> cb;
36
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 for (auto& a : sources) {
37
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (a) {
38
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 a->Init(cb);
39 }
40 }
41 1 }
42
43 ✗ void MultiSensorSource::lockToGroup(int i) {
44 ✗ for (auto& a : sources) {
45 ✗ if (a) {
46 ✗ a->lockToGroup(i);
47 }
48 }
49 ✗ }
50
51 1 void MultiSensorSource::update(bool forceInstant) {
52
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 for (auto& a : sources) {
53
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (a) {
54
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 a->update(forceInstant);
55 }
56 }
57 1 }
58 4 void MultiSensorSource::enable(int id) {
59
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (id < 0) {
60 ✗ return;
61 }
62
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 for (int x = 0; x < sources.size(); x++) {
63
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2 times.
6 if (id < channels[x]) {
64 4 sources[x]->enable(id);
65 4 return;
66 }
67 2 id -= channels[x];
68 }
69 }
70 4 int32_t MultiSensorSource::getValue(int id) {
71
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (id < 0) {
72 ✗ return 0;
73 }
74
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 for (int x = 0; x < sources.size(); x++) {
75
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2 times.
6 if (id < channels[x]) {
76 4 return sources[x]->getValue(id);
77 }
78 2 id -= channels[x];
79 }
80 ✗ return 0;
81 }
82