GCC Code Coverage Report


Directory: ./
File: src/SwappedSync.cpp
Date: 2026-09-03 16:05:57
Exec Total Coverage
Lines: 0 15 0.0%
Branches: 0 12 0.0%

Line Branch Exec Source
1 /*****************************************************************************
2 *
3 * This file is part of the ecapp library (EtherCAT application devices).
4 *
5 * Copyright (C) 2026 Florian Pose <fp@igh.de>
6 *
7 * The ecapp library is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * as published by the Free Software Foundation, version 3 of the
10 * License.
11 *
12 * The ecapp library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with the ecapp library. If not, see
19 * <https://www.gnu.org/licenses/>.
20 *
21 ****************************************************************************/
22
23 #include "ecapp/SwappedSync.h"
24
25 /****************************************************************************/
26
27 namespace EcApp {
28
29 template <Mode mode>
30 SwappedSync<mode>::SwappedSync(ec_sync_info_t *orig) : sync {nullptr}
31 {
32 if constexpr (mode == Mode::Control) {
33 sync = orig;
34 }
35 else { // Simulation
36 const ec_sync_info_t *cur {orig};
37 while (cur->index < EC_MAX_SYNC_MANAGERS) {
38 cur++;
39 }
40
41 long int count {cur - orig + 1};
42
43 sync = new ec_sync_info_t[count];
44
45 for (long int i = 0; i < count; i++) {
46 sync[i] = orig[i];
47
48 if (sync[i].dir == EC_DIR_INPUT) {
49 sync[i].dir = EC_DIR_OUTPUT;
50 }
51 else if (sync[i].dir == EC_DIR_OUTPUT) {
52 sync[i].dir = EC_DIR_INPUT;
53 }
54 }
55 }
56 }
57
58 /****************************************************************************/
59
60 template <Mode mode>
61 SwappedSync<mode>::~SwappedSync()
62 {
63 if constexpr (mode == Mode::Simulation) {
64 delete[] sync;
65 }
66 }
67
68 /****************************************************************************/
69
70 template class SwappedSync<Mode::Control>;
71 template class SwappedSync<Mode::Simulation>;
72
73 } // namespace EcApp
74
75 /****************************************************************************/
76