| 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 |
|
1 |
class EL6224 |
| 53 |
|
|
{ |
| 54 |
|
|
public: |
| 55 |
|
|
static constexpr unsigned int NumPorts = 4; |
| 56 |
|
|
|
| 57 |
|
|
EL6224(pdserv *, |
| 58 |
|
|
pdtask *, |
| 59 |
|
|
const std::string &, |
| 60 |
|
|
Master *, |
| 61 |
|
|
uint16_t, |
| 62 |
|
|
uint16_t, |
| 63 |
|
|
Domain *, |
| 64 |
|
|
Domain *); |
| 65 |
|
|
|
| 66 |
|
|
/** Takes ownership of an (unconfigured) driver for one port; |
| 67 |
|
|
* ports are not board slots that can be reassigned once |
| 68 |
|
|
* configure() has run. */ |
| 69 |
|
|
void |
| 70 |
|
|
setPortDevice(unsigned int port, std::unique_ptr<IoLinkDevice> device); |
| 71 |
|
|
|
| 72 |
|
|
IoLinkDevice *portDevice(unsigned int port); |
| 73 |
|
|
const IoLinkDevice *portDevice(unsigned int port) const; |
| 74 |
|
|
|
| 75 |
|
|
/** Pushes the dynamic PDO/SDO configuration for every assigned |
| 76 |
|
|
* port. A no-op if this instance has no real slave config |
| 77 |
|
|
* (master was null at construction). */ |
| 78 |
|
|
void configure(); |
| 79 |
|
|
|
| 80 |
|
|
void updateInputs(); |
| 81 |
|
|
void updateOutputs(); |
| 82 |
|
|
|
| 83 |
|
1 |
uint16_t portState(unsigned int port) const { return state[port]; } |
| 84 |
|
1 |
bool portStateOp(unsigned int port) const { return stateOp[port]; } |
| 85 |
|
|
|
| 86 |
|
|
private: |
| 87 |
|
|
ec_slave_config_t *sc; |
| 88 |
|
|
Domain *const domainOut; |
| 89 |
|
|
Domain *const domainIn; |
| 90 |
|
|
pdserv *const serv; |
| 91 |
|
|
pdtask *const task; |
| 92 |
|
|
const std::string prefix; |
| 93 |
|
|
|
| 94 |
|
|
int offState; |
| 95 |
|
|
std::vector<uint8_t> state; |
| 96 |
|
|
std::vector<uint8_t> stateOp; |
| 97 |
|
|
|
| 98 |
|
|
std::vector<std::unique_ptr<IoLinkDevice>> devices; |
| 99 |
|
|
}; |
| 100 |
|
|
|
| 101 |
|
|
} // namespace EcApp |
| 102 |
|
|
|
| 103 |
|
|
#endif // ECAPP_EL6224_H |
| 104 |
|
|
|
| 105 |
|
|
/****************************************************************************/ |
| 106 |
|
|
|