GCC Code Coverage Report


Directory: ./
File: ecapp/IoLinkMaster.h
Date: 2026-09-23 16:22:15
Exec Total Coverage
Lines: 2 2 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 ****************************************************************************/
22
23 #ifndef ECAPP_IOLINKMASTER_H
24 #define ECAPP_IOLINKMASTER_H
25
26 /****************************************************************************/
27
28 #include "ecapp/Capability.h"
29 #include "ecapp_export.h"
30
31 #include <string>
32
33 /****************************************************************************/
34
35 namespace EcApp {
36
37 class SubDevice;
38
39 /** Capability interface for IO-Link master terminals (e.g. EL6224).
40 * Unlike every other capability in ecapp, a device implementing this
41 * has channels that are not fully known until setPortDevice() and
42 * applyPortConfig() have run -- each port can have a different IO-Link
43 * device plugged in, discovered/assigned at configuration time, not
44 * baked into the terminal type the way an EL2008's 8 outputs are.
45 *
46 * A port's plugged device is itself a full SubDevice (see
47 * IoLinkDevice); this interface only adds port assignment/
48 * configuration and access to that per-port SubDevice -- the actual
49 * channel values are read/written through the returned SubDevice via
50 * the usual getInput()/readInput<T>()/bindInput<T>() etc., not through
51 * anything declared here. */
52 1 class ECAPP_EXPORT IoLinkMaster
53 {
54 public:
55 1 virtual ~IoLinkMaster() = default;
56
57 virtual unsigned int numPorts() const = 0;
58
59 /** Assigns a driver (see createIoLinkDevice(), whose name this
60 * forwards to) to a port. Must be followed by
61 * applyPortConfig() before the master is activated.
62 *
63 * `alias`, if given, replaces the port's bare numeric path
64 * segment (e.g. "/EtherCAT/Slave17/2/Flow") with a plant-specific
65 * tag (e.g. "/EtherCAT/Slave17/I1_FI-1120/Flow") for every
66 * channel this port ends up publishing to pdserv -- the port-level
67 * counterpart of SubDevice::setAlias()'s per-channel aliasing,
68 * needed because renaming a pdserv path after the fact isn't
69 * possible (pdserv has no rename operation, only
70 * pdserv_set_alias() on an already-registered single variable);
71 * unlike setAlias(), this must therefore be decided before the
72 * assigned driver is even constructed, not called later on
73 * port()'s returned SubDevice. Left empty, the default, the port
74 * keeps its bare index as before. */
75 virtual void setPortDevice(
76 unsigned int port,
77 const std::string &deviceName,
78 const std::string &alias = "") = 0;
79
80 /** Pushes the dynamic PDO/SDO configuration for every assigned
81 * port to the slave, and rebuilds each assigned port's channel
82 * list to match. Must be called once, before the master is
83 * activated. Before this has run, port() still returns a
84 * valid SubDevice for an assigned port, just with an empty
85 * channel list. */
86 virtual void applyPortConfig() = 0;
87
88 /** Throws UnknownChannel if port is out of range. Never null,
89 * regardless of whether a device has been assigned to it yet
90 * -- an assigned-but-not-yet-configured or unassigned port
91 * simply has no channels. */
92 virtual SubDevice &port(unsigned int port) = 0;
93 virtual const SubDevice &port(unsigned int port) const = 0;
94 };
95
96 } // namespace EcApp
97
98 #endif // ECAPP_IOLINKMASTER_H
99
100 /****************************************************************************/
101