Motion Master 6.0.0-alpha.86
Next-generation motion control software
Loading...
Searching...
No Matches
process_image.h
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4#include <cstddef>
5#include <cstdint>
6#include <expected>
7#include <optional>
8#include <span>
9#include <string>
10#include <vector>
11
14
15namespace mm::node {
16
17class Device;
18
26 uint32_t size = 0;
27 std::array<uint8_t, mm::comm::kMaxProcessImageBytes> bytes{};
28};
29
38 uint16_t slavePosition = 0;
39 uint16_t index = 0;
40 uint8_t subindex = 0;
41 uint16_t bitLength = 0;
42 uint32_t bitOffset = 0;
43
60 const DeviceParameter* parameter = nullptr;
61};
62
70 std::vector<ProcessImageEntry> outputs;
71 std::vector<ProcessImageEntry> inputs;
72 uint32_t outputBytes = 0;
73 uint32_t inputBytes = 0;
74 int expectedWkc = 0;
75
77 struct Location {
78 uint32_t bitOffset;
79 uint16_t bitLength;
80 bool isOutput;
81 size_t entryIndex;
83 };
84
87 std::optional<Location> find(uint16_t slavePosition, uint16_t index, uint8_t subindex) const;
88};
89
95std::vector<uint8_t> extractBits(std::span<const uint8_t> src, uint32_t bitOffset,
96 uint16_t bitLength);
97
114void extractBits(std::span<const uint8_t> src, uint32_t bitOffset, uint16_t bitLength,
115 std::span<uint8_t> out);
116
120void insertBits(std::span<uint8_t> dst, uint32_t bitOffset, uint16_t bitLength,
121 std::span<const uint8_t> value);
122
134std::expected<ProcessImage, std::string> buildProcessImage(const mm::comm::PdoLayout& layout,
135 const std::vector<Device>& devices);
136
137} // namespace mm::node
uint8_t subindex
Definition esi_entry.cc:283
uint16_t bitOffset
Definition esi_entry.cc:287
Definition bus_health_source.h:7
void insertBits(std::span< uint8_t > dst, uint32_t bitOffset, uint16_t bitLength, std::span< const uint8_t > value)
Inserts bitLength bits of value (LSB-first) into dst at bitOffset.
Definition process_image.cc:156
std::expected< ProcessImage, std::string > buildProcessImage(const mm::comm::PdoLayout &layout, const std::vector< Device > &devices)
Assembles a ProcessImage from the driver layout and per-device PDO mappings.
Definition process_image.cc:50
void extractBits(std::span< const uint8_t > src, uint32_t bitOffset, uint16_t bitLength, std::span< uint8_t > out)
Extracts bitLength bits at bitOffset from src into the caller's out buffer.
Definition process_image.cc:124
Layout of the process-data images, produced by configureProcessData.
Definition fieldbus_driver.h:173
A single object dictionary entry held by a Device.
Definition device_parameter.h:194
Fixed-capacity byte buffer for one direction of the process image.
Definition process_image.h:25
std::array< uint8_t, mm::comm::kMaxProcessImageBytes > bytes
Definition process_image.h:27
uint32_t size
Definition process_image.h:26
Locates one mapped object within the flat process image.
Definition process_image.h:37
uint16_t index
CoE object index.
Definition process_image.h:39
uint16_t bitLength
Width of the value in bits.
Definition process_image.h:41
uint8_t subindex
CoE object subindex.
Definition process_image.h:40
uint32_t bitOffset
Absolute bit offset within the direction's image.
Definition process_image.h:42
const DeviceParameter * parameter
The owning device's parameter, resolved once when the image is built.
Definition process_image.h:60
uint16_t slavePosition
1-based bus position of the owning device.
Definition process_image.h:38
Where a mapped object sits in the image, and which direction it belongs to.
Definition process_image.h:77
uint32_t bitOffset
Absolute bit offset within the direction's image.
Definition process_image.h:78
uint16_t bitLength
Width of the value in bits.
Definition process_image.h:79
size_t entryIndex
Definition process_image.h:81
bool isOutput
True for an RxPDO output, false for a TxPDO input.
Definition process_image.h:80
The whole bus's process-data layout, resolved to absolute positions.
Definition process_image.h:69
uint32_t inputBytes
Size of the input image.
Definition process_image.h:73
std::optional< Location > find(uint16_t slavePosition, uint16_t index, uint8_t subindex) const
Locates a mapped object by bus position and CoE address.
Definition process_image.cc:104
uint32_t outputBytes
Size of the output image.
Definition process_image.h:72
std::vector< ProcessImageEntry > outputs
Master→slave objects, located in the output image.
Definition process_image.h:70
int expectedWkc
Working counter when every slave exchanges.
Definition process_image.h:74
std::vector< ProcessImageEntry > inputs
Slave→master objects, located in the input image.
Definition process_image.h:71