GCC Code Coverage Report


Directory: ./
File: src/devices/Ex20xx.h
Date: 2026-09-03 16:05:57
Exec Total Coverage
Lines: 1 1 100.0%
Branches: 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 * Beckhoff/Wago-style digital output terminals with a uniform PDO shape
22 * (one bit per channel, optional per-channel diagnosis bit): EL2004,
23 * EL2008, EL2024, EL2034, EP2028-0032, EL2521, EL2622, EL2808. This
24 * grouping is an implementation detail -- application code never names
25 * Ex20xx directly, it goes through createSubDevice("EL2008") and gets
26 * an EcApp::SubDevice back.
27 *
28 ****************************************************************************/
29
30 #ifndef ECAPP_EX20XX_H
31 #define ECAPP_EX20XX_H
32
33 /****************************************************************************/
34
35 #include "ecapp/Mode.h"
36
37 #include <ecrt.h> // EtherCAT realtime interface
38 #include <pdserv.h>
39 #include <stdint.h>
40 #include <string>
41 #include <vector>
42
43 /****************************************************************************/
44
45 namespace EcApp {
46
47 class Master;
48 class Domain;
49
50 struct Ex20xxType;
51
52 template <Mode mode>
53 1 class Ex20xx
54 {
55 public:
56 enum Type {
57 EL2004,
58 EL2008,
59 EL2024,
60 EL2034,
61 EP2028_0032,
62 EL2521,
63 EL2622,
64 EL2808,
65 NumTypes
66 };
67
68 Ex20xx(pdserv *,
69 pdtask *,
70 const std::string &,
71 Master *,
72 uint16_t,
73 uint16_t,
74 Domain *,
75 Domain *,
76 Type);
77
78 void setOutput(unsigned int, bool); // Control
79 bool getOutput(unsigned int) const; // Simulation
80 void updateInputs(); // reads per-channel diagnosis, if present
81 void updateOutputs(); // toggle/forcing logic, writes process data
82
83 unsigned int numChannels() const;
84 bool hasDiagnosis() const;
85 bool getDiagnosis(unsigned int) const;
86
87 private:
88 const Ex20xxType &type;
89 ec_slave_config_t *sc;
90 Domain *const domainOut;
91 Domain *const domainIn;
92
93 std::vector<int> off_out;
94 std::vector<unsigned int> off_out_bit;
95 int off_in; // diagnosis inputs
96
97 std::vector<uint8_t> input; // value originating from setOutput()
98 std::vector<uint8_t> prevInput;
99 std::vector<unsigned int> toggle;
100 std::vector<unsigned int> prevToggle;
101 std::vector<uint8_t> autoValue; // toggled input value
102 std::vector<uint8_t> enableForcing;
103 std::vector<uint8_t> forcedValue;
104 std::vector<uint8_t> output; // value sent to hardware
105 std::vector<uint8_t> diagnosis;
106 };
107
108 } // namespace EcApp
109
110 #endif // ECAPP_EX20XX_H
111
112 /****************************************************************************/
113