5#include <nlohmann/json_fwd.hpp>
141 std::vector<std::uint8_t>
data;
158 std::optional<std::uint16_t>
adp;
159 std::optional<std::uint16_t>
ado;
160 std::optional<std::uint32_t>
addr;
161 std::vector<std::uint8_t>
data;
163 std::optional<std::uint32_t>
cnt;
180 std::vector<std::uint8_t>
data;
240 std::optional<EniProcessDataWindow>
send;
241 std::optional<EniProcessDataWindow>
recv;
334 std::optional<EniDc>
dc;
345 std::optional<std::uint16_t>
adp;
346 std::optional<std::uint16_t>
ado;
347 std::optional<std::uint32_t>
addr;
348 std::vector<std::uint8_t>
data;
350 std::optional<std::uint32_t>
cnt;
359 std::vector<EniCyclicCmd>
cmds;
388 std::optional<EniProcessImageArea>
inputs;
425 std::optional<EniEoe>
eoe;
456std::string
eniPhysics(std::uint16_t physicalPort);
EniCoeCommandSpecifier
The CoE command specifier of a mailbox init command (ENI Ccs).
Definition eni.h:131
@ Download
SDO initiate download: the master writes data to the object.
@ Upload
SDO initiate upload: the master reads the object.
EniTransition
EtherCAT Network Information (ENI) — the configuration a master replays to start a bus.
Definition eni.h:49
EniSyncManagerType
What a Sync Manager carries (ENI SyncManagerSettings/Type).
Definition eni.h:107
@ MailboxIn
Device-to-master mailbox.
@ MailboxOut
Master-to-device mailbox.
@ Outputs
Master-to-device process data.
@ Inputs
Device-to-master process data.
void to_json(nlohmann::json &j, const EniNetwork &network)
Serialises a network as JSON, for a client that renders rather than replays it.
Definition eni.cc:907
std::string eniPhysics(std::uint16_t physicalPort)
Renders the ENI Physics string for a device from its SII physical-port word.
Definition eni.cc:994
std::expected< std::string, std::string > writeEni(const EniNetwork &network)
Renders a network as an ENI document.
Definition eni.cc:1024
EniRequires
Whether an init command needs a frame or a cycle of its own (ENI <Requires>).
Definition eni.h:92
@ Frame
The command requires a separate frame.
@ Cycle
The command requires a separate cycle.
@ None
No requirement; the element is not written and the command may share a frame.
EniPort
A port of the device upstream of this one (ENI Slave/PreviousPort Port).
Definition eni.h:288
@ A
Port 0. Rejected by the schema; see above.
EniCmd
EtherCAT command type of an init or cyclic command (ENI Cmd, ETG.2100 Table 21).
Definition eni.h:73
@ Lrd
Logical-memory read.
@ Frmw
Configured-address physical read, multiple write.
@ Armw
Auto-increment physical read, multiple write.
@ Brw
Broadcast read-write.
@ Aprw
Auto-increment physical read-write.
@ Lrw
Logical-memory read-write.
@ Fprw
Configured-address physical read-write.
@ Lwr
Logical-memory write.
@ Fprd
Configured-address physical read.
@ Apwr
Auto-increment physical write.
@ Aprd
Auto-increment physical read.
@ Fpwr
Configured-address physical write.
EniMailboxProtocol
A mailbox protocol a device supports (ENI Mailbox/Protocol).
Definition eni.h:115
@ Coe
CANopen over EtherCAT.
@ Voe
Vendor-specific over EtherCAT.
@ Soe
Servo Profile over EtherCAT.
@ Foe
File Access over EtherCAT.
@ Eoe
Ethernet over EtherCAT.
EniState
An AL state a cyclic command is sent in (ENI Cyclic/Frame/Cmd/State).
Definition eni.h:99
One CoE transfer the master runs at a transition (ENI CoE/InitCmds/InitCmd).
Definition eni.h:173
bool disabled
Written to the file but not to be sent.
Definition eni.h:181
std::uint32_t timeoutMs
Timeout for this transfer.
Definition eni.h:176
std::vector< EniTransition > transitions
At least one; the schema requires it.
Definition eni.h:174
EniCoeCommandSpecifier ccs
Read or write.
Definition eni.h:177
std::string comment
Free text a master may log.
Definition eni.h:175
std::uint8_t subindex
Object subindex.
Definition eni.h:179
std::vector< std::uint8_t > data
Payload of a download; empty for an upload.
Definition eni.h:180
std::uint16_t index
Object index.
Definition eni.h:178
One datagram of a cyclic frame (ENI Cyclic/Frame/Cmd).
Definition eni.h:341
std::vector< std::uint8_t > data
Bytes to write. Excludes dataLength.
Definition eni.h:348
std::optional< std::uint16_t > adp
Device address, with ado. Excludes addr.
Definition eni.h:345
std::vector< EniState > states
AL states to send this frame in; at least one, at most four.
Definition eni.h:342
std::uint32_t inputOffs
Where the read data lands in the input image.
Definition eni.h:351
std::optional< std::uint32_t > addr
Logical start address. Excludes adp and ado.
Definition eni.h:347
std::optional< std::uint16_t > ado
Offset in the device's ESC memory. Excludes addr.
Definition eni.h:346
EniCmd cmd
Usually Lrw: one datagram exchanges the whole image.
Definition eni.h:344
std::uint32_t outputOffs
Definition eni.h:352
std::string comment
Free text a master may log.
Definition eni.h:343
std::optional< std::uint32_t > dataLength
Bytes to exchange. Excludes data.
Definition eni.h:349
std::optional< std::uint32_t > cnt
Working counter a healthy bus returns.
Definition eni.h:350
The cyclic task that exchanges process data (ENI Config/Cyclic).
Definition eni.h:363
std::optional< std::uint32_t > priority
Task priority, as the master reads it.
Definition eni.h:366
std::string comment
Free text a master may log.
Definition eni.h:364
std::string taskId
Task name, as the master reads it.
Definition eni.h:367
std::optional< std::uint32_t > cycleTimeUs
Cycle period in microseconds.
Definition eni.h:365
std::vector< EniFrame > frames
At least one; the schema requires it.
Definition eni.h:368
A device's distributed-clock configuration (ENI Slave/DC).
Definition eni.h:319
std::optional< std::int32_t > cycleTime1Ns
The derived SYNC1 figure above, in nanoseconds.
Definition eni.h:323
std::optional< bool > potentialReferenceClock
The device has the registers to be one.
Definition eni.h:320
std::optional< bool > referenceClock
The device is the reference clock.
Definition eni.h:321
std::optional< std::int32_t > shiftTimeNs
SYNC0 shift time, in nanoseconds.
Definition eni.h:324
std::optional< std::int32_t > cycleTime0Ns
SYNC0 cycle time, in nanoseconds.
Definition eni.h:322
One EtherCAT datagram the master sends at a transition (ENI ECatCmdType).
Definition eni.h:152
std::optional< std::uint32_t > addr
Logical start address. Excludes adp and ado.
Definition eni.h:160
std::optional< std::uint16_t > ado
Offset in the device's ESC memory. Excludes addr.
Definition eni.h:159
std::optional< std::uint32_t > timeoutMs
Plain timeout. Excludes validate.
Definition eni.h:166
std::optional< std::uint32_t > retries
Re-sends allowed before the command fails.
Definition eni.h:164
bool beforeSlave
Send before the addressed device's own commands.
Definition eni.h:154
std::string comment
Free text a master may log. Empty is not written.
Definition eni.h:155
std::vector< std::uint8_t > data
Bytes to write. Excludes dataLength.
Definition eni.h:161
std::optional< std::uint32_t > dataLength
Bytes to read. Excludes data.
Definition eni.h:162
EniRequires requirement
Frame or cycle isolation.
Definition eni.h:156
std::optional< std::uint32_t > cnt
Working counter a successful datagram returns.
Definition eni.h:163
std::optional< std::uint16_t > adp
Device address, with ado. Excludes addr.
Definition eni.h:158
EniCmd cmd
The datagram type, which also fixes the addressing mode.
Definition eni.h:157
std::vector< EniTransition > transitions
Transitions to send this command at.
Definition eni.h:153
std::optional< EniValidate > validate
Retry-until condition. Excludes timeoutMs.
Definition eni.h:165
The virtual Ethernet switch the master runs for Ethernet over EtherCAT (ENI Master/EoE).
Definition eni.h:408
std::uint32_t maxFrames
Frames the switch may queue.
Definition eni.h:410
std::uint32_t maxPorts
Ports that may be connected to the switch.
Definition eni.h:409
std::uint32_t maxMacs
MAC addresses the switch may hold.
Definition eni.h:411
One cyclic frame (ENI Cyclic/Frame).
Definition eni.h:357
std::string comment
Free text a master may log.
Definition eni.h:358
std::vector< EniCyclicCmd > cmds
At least one; the schema requires it.
Definition eni.h:359
The master's cyclic check of every mailbox on the bus (ENI Master/MailboxStates).
Definition eni.h:398
std::uint32_t startAddr
Logical address the cyclic read covers.
Definition eni.h:399
std::uint32_t count
Devices whose mailbox state is checked.
Definition eni.h:400
One mailbox window of a device (ENI MailboxSendInfoType / MailboxRecvInfoType).
Definition eni.h:248
std::uint16_t length
Window length in bytes.
Definition eni.h:250
std::uint16_t start
Offset in the device's ESC memory.
Definition eni.h:249
std::optional< std::uint32_t > statusBitAddr
Mailbox-status bit the master may poll instead.
Definition eni.h:252
std::optional< std::uint32_t > pollTime
How often the master polls for a reply.
Definition eni.h:251
A device's mailbox configuration (ENI Slave/Mailbox).
Definition eni.h:260
std::optional< EniMailboxWindow > bootstrapSend
Master-to-device window in BOOT.
Definition eni.h:263
std::vector< EniCoeCmd > coeInitCmds
CoE transfers, under Mailbox/CoE.
Definition eni.h:266
std::vector< EniMailboxProtocol > protocols
Protocols the device supports.
Definition eni.h:265
EniMailboxWindow recv
Device-to-master window.
Definition eni.h:262
EniMailboxWindow send
Master-to-device window.
Definition eni.h:261
std::optional< EniMailboxWindow > bootstrapRecv
Device-to-master window in BOOT.
Definition eni.h:264
The master itself (ENI Config/Master).
Definition eni.h:418
std::vector< EniEcatCmd > initCmds
Bus-wide datagrams, under Master/InitCmds.
Definition eni.h:426
std::vector< std::uint8_t > source
Source MAC, six bytes.
Definition eni.h:421
std::optional< EniMailboxStates > mailboxStates
The cyclic mailbox-state check.
Definition eni.h:424
std::optional< std::uint16_t > etherType
Definition eni.h:422
std::string name
Master name, for a human reading the file.
Definition eni.h:419
std::optional< EniEoe > eoe
The virtual switch, where EoE is in use.
Definition eni.h:425
std::vector< std::uint8_t > destination
Destination MAC, six bytes.
Definition eni.h:420
A complete network configuration (ENI EtherCATConfig/Config).
Definition eni.h:430
std::vector< EniSlave > slaves
Devices in bus order.
Definition eni.h:432
std::optional< EniProcessImage > processImage
The image the cyclic task exchanges.
Definition eni.h:434
EniMaster master
The master and its bus-wide init commands.
Definition eni.h:431
std::optional< EniCyclic > cyclic
The process-data task.
Definition eni.h:433
One object mapped into a PDO (ENI EntryType).
Definition eni.h:213
std::uint16_t bitLen
Width in bits, padding included.
Definition eni.h:216
std::string dataType
Type name as an ESI spells it: "UINT", "DINT".
Definition eni.h:218
std::string name
Object name.
Definition eni.h:217
std::uint16_t index
Object index; zero marks padding.
Definition eni.h:214
std::uint8_t subindex
Object subindex.
Definition eni.h:215
std::string comment
Free text.
Definition eni.h:219
One process-data object of a device (ENI PdoType).
Definition eni.h:228
std::string name
Required by the schema; at minimum, name it after its index.
Definition eni.h:231
std::optional< std::uint8_t > syncManager
The Sync Manager carrying it (the Sm attribute).
Definition eni.h:232
bool mandatory
The PDO must be assigned to a Sync Manager.
Definition eni.h:234
std::vector< EniPdoEntry > entries
Mapped objects, in window order.
Definition eni.h:235
bool fixed
The device does not allow this PDO to be reconfigured.
Definition eni.h:233
std::uint16_t index
Mapping-object index: 0x16xx for an RxPDO, 0x1Axx for a TxPDO.
Definition eni.h:229
Where this device sits in the ring (ENI Slave/PreviousPort).
Definition eni.h:303
std::optional< std::uint32_t > deviceId
Definition eni.h:307
bool selected
This is the connection, not merely a possible one.
Definition eni.h:305
EniPort port
The upstream device's port.
Definition eni.h:304
std::optional< std::uint16_t > physAddr
Station address of the upstream device.
Definition eni.h:306
Where one device's process data sits in the master's image (ENI ProcessData/Send or ProcessData/Recv)...
Definition eni.h:186
std::uint32_t bitStart
Offset of the window within the image, in bits.
Definition eni.h:187
std::uint32_t bitLength
Length of the window, in bits.
Definition eni.h:188
A device's process-data description (ENI Slave/ProcessData).
Definition eni.h:239
std::vector< EniSyncManager > syncManagers
Sync Managers, in any order; index places them.
Definition eni.h:242
std::optional< EniProcessDataWindow > send
Window in the master's output image.
Definition eni.h:240
std::optional< EniProcessDataWindow > recv
Window in the master's input image.
Definition eni.h:241
std::vector< EniPdo > txPdos
Device-to-master PDOs, so the inputs.
Definition eni.h:244
std::vector< EniPdo > rxPdos
Master-to-device PDOs, so the outputs.
Definition eni.h:243
One half of the master's process image (ENI ProcessImage/Inputs or /Outputs).
Definition eni.h:381
std::uint32_t byteSize
Total size of this half, in bytes.
Definition eni.h:382
std::vector< EniVariable > variables
Named values in it; may be empty.
Definition eni.h:383
The master's process image (ENI Config/ProcessImage).
Definition eni.h:387
std::optional< EniProcessImageArea > outputs
Master-to-device half.
Definition eni.h:389
std::optional< EniProcessImageArea > inputs
Device-to-master half.
Definition eni.h:388
A device's identity (ENI Slave/Info).
Definition eni.h:270
std::uint32_t vendorId
Vendor ID from the device's SII.
Definition eni.h:276
std::uint16_t physAddr
Configured station address the master assigns.
Definition eni.h:272
std::string name
Device name, for a human reading the file.
Definition eni.h:271
std::uint16_t autoIncAddr
Definition eni.h:273
std::uint32_t revisionNo
Revision number from the device's SII.
Definition eni.h:278
std::uint32_t productCode
Product code from the device's SII.
Definition eni.h:277
std::string physics
One character per port; see eniPhysics.
Definition eni.h:275
std::uint32_t serialNo
Serial number from the device's SII.
Definition eni.h:279
One device on the bus (ENI Config/Slave).
Definition eni.h:328
std::optional< EniProcessData > processData
Absent for a device with no process data.
Definition eni.h:330
std::vector< EniPreviousPort > previousPorts
Where the device sits in the ring.
Definition eni.h:333
std::vector< EniEcatCmd > initCmds
Datagrams, under Slave/InitCmds.
Definition eni.h:332
std::optional< EniDc > dc
Distributed clocks; absent means free-run.
Definition eni.h:334
EniSlaveInfo info
Identity and address.
Definition eni.h:329
std::optional< EniMailbox > mailbox
Absent for a device with no mailbox.
Definition eni.h:331
One Sync Manager of a device (ENI SyncManagerSettings).
Definition eni.h:195
bool enable
Whether the master enables it.
Definition eni.h:200
std::uint8_t controlByte
SM control register: buffer mode, direction, watchdog.
Definition eni.h:199
std::optional< std::uint32_t > minSize
Smallest window the device accepts, in bytes.
Definition eni.h:201
EniSyncManagerType type
What it carries.
Definition eni.h:197
std::optional< std::uint32_t > defaultSize
Window size before any PDO re-assignment.
Definition eni.h:203
std::optional< std::uint32_t > maxSize
Largest window the device accepts, in bytes.
Definition eni.h:202
std::uint8_t index
Sync Manager number, 0 to 15.
Definition eni.h:196
std::uint16_t startAddress
Start of the guarded window in the device's ESC memory.
Definition eni.h:198
std::optional< std::uint32_t > watchdog
Process-data watchdog time.
Definition eni.h:204
The value a read init command must return before the master goes on (ENI Validate).
Definition eni.h:140
std::vector< std::uint8_t > data
The value the read must return.
Definition eni.h:141
std::uint32_t timeoutMs
How long to keep re-sending.
Definition eni.h:143
std::vector< std::uint8_t > dataMask
Bits of data that must match; empty compares all.
Definition eni.h:142
One named value in the master's process image (ENI ProcessImage Variable).
Definition eni.h:372
std::string dataType
Type name, as an ESI writes it: "INT", "UDINT", "BOOL".
Definition eni.h:375
std::string name
Variable name; a master shows it to an operator.
Definition eni.h:373
std::uint32_t bitOffs
Offset within its half of the image, in bits.
Definition eni.h:377
std::uint32_t bitSize
Length in bits.
Definition eni.h:376
std::string comment
Free text.
Definition eni.h:374