GCC Code Coverage Report


Directory: ./
File: src/devices/EL6224.h
Date: 2026-09-23 16:22:15
Exec Total Coverage
Lines: 3 3 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 * EL6224: a 4-port IO-Link master terminal. Each port can carry a
22 * different IO-Link device with its own PDO layout and named
23 * channels, assigned at configuration time -- see
24 * EcApp::IoLinkMaster and EcApp::IoLinkDevice. This is the one
25 * ecapp terminal whose channel list is not fixed by its type alone.
26 *
27 ****************************************************************************/
28
29 #ifndef ECAPP_EL6224_H
30 #define ECAPP_EL6224_H
31
32 /****************************************************************************/
33
34 #include "ecapp/IoLinkDevice.h"
35 #include "ecapp/Mode.h"
36
37 #include <ecrt.h> // EtherCAT realtime interface
38 #include <memory>
39 #include <pdserv.h>
40 #include <stdint.h>
41 #include <string>
42 #include <vector>
43
44 /****************************************************************************/
45
46 namespace EcApp {
47
48 class Master;
49 class Domain;
50
51 template <Mode mode>
52 class EL6224Adapter; // EL6224.cpp -- the SubDevice wrapping this class,
53 // friended below so it can reach serv/task/prefix
54 // (to build each port's prefix) and state/stateOp
55 // (for pdserv publishing) directly.
56
57 template <Mode mode>
58 1 class EL6224
59 {
60 friend class EL6224Adapter<mode>;
61
62 public:
63 static constexpr unsigned int NumPorts = 4;
64
65 EL6224(pdserv *,
66 pdtask *,
67 const std::string &,
68 Master *,
69 uint16_t,
70 uint16_t,
71 Domain *,
72 Domain *);
73
74 /** Takes ownership of an (unconfigured) driver for one port;
75 * ports are not board slots that can be reassigned once
76 * configure() has run. */
77 void
78 setPortDevice(unsigned int port, std::unique_ptr<IoLinkDevice> device);
79
80 IoLinkDevice *portDevice(unsigned int port);
81 const IoLinkDevice *portDevice(unsigned int port) const;
82
83 /** Pushes the dynamic PDO/SDO configuration for every assigned
84 * port. A no-op if this instance has no real slave config
85 * (master was null at construction). */
86 void configure();
87
88 void updateInputs();
89 void updateOutputs();
90
91 1 uint16_t portState(unsigned int port) const { return state[port]; }
92 1 bool portStateOp(unsigned int port) const { return stateOp[port]; }
93
94 private:
95 ec_slave_config_t *sc;
96 Domain *const domainOut;
97 Domain *const domainIn;
98 pdserv *const serv;
99 pdtask *const task;
100 const std::string prefix;
101
102 int offState;
103 std::vector<uint8_t> state;
104 std::vector<uint8_t> stateOp;
105
106 std::vector<std::unique_ptr<IoLinkDevice>> devices;
107 };
108
109 } // namespace EcApp
110
111 #endif // ECAPP_EL6224_H
112
113 /****************************************************************************/
114