GCC Code Coverage Report


Directory: ./
File: src/devices/Movitrac.h
Date: 2026-09-23 16:22:15
Exec Total Coverage
Lines: 4 12 33.3%
Branches: 2 12 16.7%

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 * SEW Movitrac frequency inverter. A single fixed product (no Type
22 * enum, unlike the Ex-family terminals): every channel is its own
23 * distinctly-named scalar, not a repeated kind, matching the ifm
24 * IO-Link drivers' shape more than the Beckhoff digital/analog
25 * families'.
26 *
27 ****************************************************************************/
28
29 #ifndef ECAPP_MOVITRAC_H
30 #define ECAPP_MOVITRAC_H
31
32 /****************************************************************************/
33
34 #include "ecapp/Mode.h"
35
36 #include <ecrt.h> // EtherCAT realtime interface
37 #include <stdint.h>
38 #include <string>
39
40 /****************************************************************************/
41
42 namespace EcApp {
43
44 class Master;
45 class Domain;
46
47 template <Mode mode>
48 class MovitracAdapter; // Movitrac.cpp -- the SubDevice wrapping this
49 // class, friended below so it can reach every
50 // channel/parameter member directly for pdserv
51 // publishing.
52
53 template <Mode mode>
54 class Movitrac
55 {
56 friend class MovitracAdapter<mode>;
57
58 public:
59 Movitrac(Master *, uint16_t, uint16_t, Domain *, Domain *);
60
61 void updateInputs();
62 void updateOutputs();
63
64 /** Broader "something is wrong" check than the FaultFlag
65 * channel alone -- also true while not ready, or with no
66 * device state at all. What bda's own control logic actually
67 * uses to decide whether this drive has a problem. */
68 1 bool getFault() const
69 {
70
2/12
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1 return faultFlag || !status1Ready || deviceState == 0;
71 }
72
73 void setEnableMotor(bool);
74 void setTargetSpeed(double);
75
76 1 uint16_t getStatusWord() const { return statusWord; }
77 ✗ double getCurrentSpeed() const { return currentSpeed; }
78 ✗ bool getStatus0Enabled() const { return status0Enabled; }
79 ✗ bool getStatus1Ready() const { return status1Ready; }
80 ✗ bool getStatus2PaDataEnabled() const { return status2PaDataEnabled; }
81 ✗ bool getStatus5FaultWarning() const { return status5FaultWarning; }
82 1 bool getFaultFlag() const { return faultFlag; }
83 ✗ bool getWarning() const { return warning; }
84 ✗ uint8_t getDeviceState() const { return deviceState; }
85 ✗ uint8_t getErrorNumber() const { return errorNumber; }
86
87 private:
88 ec_slave_config_t *sc;
89 Domain *const domainOut;
90 Domain *const domainIn;
91
92 int offControl;
93 int offTargetSpeed;
94 int offStatus;
95 int offCurrentSpeed;
96
97 bool enable;
98 uint16_t controlWord;
99 uint16_t statusWord;
100 double targetSpeed;
101 double currentSpeed;
102 double speedScale;
103
104 bool enableForcing;
105 uint16_t forcedControlWord;
106 double forcedTargetSpeed;
107 uint16_t effControlWord;
108 double effTargetSpeed;
109 int16_t rawTargetSpeed;
110
111 bool status0Enabled;
112 bool status1Ready;
113 bool status2PaDataEnabled;
114 bool status5FaultWarning;
115 bool faultFlag;
116 bool warning;
117 uint8_t deviceState;
118 uint8_t errorNumber;
119 };
120
121 } // namespace EcApp
122
123 #endif // ECAPP_MOVITRAC_H
124
125 /****************************************************************************/
126