| Directory: | ./ |
|---|---|
| File: | src/devices/Movitrac.h |
| Date: | 2026-09-03 16:05:57 |
| 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 <pdserv.h> | ||
| 38 | #include <stdint.h> | ||
| 39 | #include <string> | ||
| 40 | |||
| 41 | /****************************************************************************/ | ||
| 42 | |||
| 43 | namespace EcApp { | ||
| 44 | |||
| 45 | class Master; | ||
| 46 | class Domain; | ||
| 47 | |||
| 48 | template <Mode mode> | ||
| 49 | class Movitrac | ||
| 50 | { | ||
| 51 | public: | ||
| 52 | Movitrac( | ||
| 53 | pdserv *, | ||
| 54 | pdtask *, | ||
| 55 | const std::string &, | ||
| 56 | Master *, | ||
| 57 | uint16_t, | ||
| 58 | uint16_t, | ||
| 59 | Domain *, | ||
| 60 | Domain *); | ||
| 61 | |||
| 62 | void updateInputs(); | ||
| 63 | void updateOutputs(); | ||
| 64 | |||
| 65 | /** Broader "something is wrong" check than the FaultFlag | ||
| 66 | * channel alone -- also true while not ready, or with no | ||
| 67 | * device state at all. What bda's own control logic actually | ||
| 68 | * uses to decide whether this drive has a problem. */ | ||
| 69 | 1 | bool getFault() const | |
| 70 | { | ||
| 71 |
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; |
| 72 | } | ||
| 73 | |||
| 74 | void setEnableMotor(bool); | ||
| 75 | void setTargetSpeed(double); | ||
| 76 | |||
| 77 | 1 | uint16_t getStatusWord() const { return statusWord; } | |
| 78 | ✗ | double getCurrentSpeed() const { return currentSpeed; } | |
| 79 | ✗ | bool getStatus0Enabled() const { return status0Enabled; } | |
| 80 | ✗ | bool getStatus1Ready() const { return status1Ready; } | |
| 81 | ✗ | bool getStatus2PaDataEnabled() const { return status2PaDataEnabled; } | |
| 82 | ✗ | bool getStatus5FaultWarning() const { return status5FaultWarning; } | |
| 83 | 1 | bool getFaultFlag() const { return faultFlag; } | |
| 84 | ✗ | bool getWarning() const { return warning; } | |
| 85 | ✗ | uint8_t getDeviceState() const { return deviceState; } | |
| 86 | ✗ | uint8_t getErrorNumber() const { return errorNumber; } | |
| 87 | |||
| 88 | private: | ||
| 89 | ec_slave_config_t *sc; | ||
| 90 | Domain *const domainOut; | ||
| 91 | Domain *const domainIn; | ||
| 92 | |||
| 93 | int offControl; | ||
| 94 | int offTargetSpeed; | ||
| 95 | int offStatus; | ||
| 96 | int offCurrentSpeed; | ||
| 97 | |||
| 98 | bool enable; | ||
| 99 | uint16_t controlWord; | ||
| 100 | uint16_t statusWord; | ||
| 101 | double targetSpeed; | ||
| 102 | double currentSpeed; | ||
| 103 | double speedScale; | ||
| 104 | |||
| 105 | bool enableForcing; | ||
| 106 | uint16_t forcedControlWord; | ||
| 107 | double forcedTargetSpeed; | ||
| 108 | uint16_t effControlWord; | ||
| 109 | double effTargetSpeed; | ||
| 110 | int16_t rawTargetSpeed; | ||
| 111 | |||
| 112 | bool status0Enabled; | ||
| 113 | bool status1Ready; | ||
| 114 | bool status2PaDataEnabled; | ||
| 115 | bool status5FaultWarning; | ||
| 116 | bool faultFlag; | ||
| 117 | bool warning; | ||
| 118 | uint8_t deviceState; | ||
| 119 | uint8_t errorNumber; | ||
| 120 | }; | ||
| 121 | |||
| 122 | } // namespace EcApp | ||
| 123 | |||
| 124 | #endif // ECAPP_MOVITRAC_H | ||
| 125 | |||
| 126 | /****************************************************************************/ | ||
| 127 |