Motion Master 6.0.0-alpha.50
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 <cstdint>
5#include <expected>
6#include <optional>
7#include <span>
8#include <string>
9#include <type_traits>
10#include <vector>
11
13
14namespace mm::node {
15
16class Device;
17
25 uint32_t size = 0;
26 std::array<uint8_t, mm::comm::kMaxProcessImageBytes> bytes{};
27};
28
36 uint16_t slavePosition;
37 uint16_t index;
38 uint8_t subindex;
39 uint16_t bitLength;
40 uint32_t bitOffset;
41};
42
50 std::vector<ProcessImageEntry> outputs;
51 std::vector<ProcessImageEntry> inputs;
52 uint32_t outputBytes = 0;
53 uint32_t inputBytes = 0;
54 int expectedWkc = 0;
55
57 struct Location {
58 uint32_t bitOffset;
59 uint16_t bitLength;
60 bool isOutput;
61 size_t entryIndex;
63 };
64
67 std::optional<Location> find(uint16_t slavePosition, uint16_t index, uint8_t subindex) const;
68};
69
74std::vector<uint8_t> extractBits(std::span<const uint8_t> src, uint32_t bitOffset,
75 uint16_t bitLength);
76
80void insertBits(std::span<uint8_t> dst, uint32_t bitOffset, uint16_t bitLength,
81 std::span<const uint8_t> value);
82
94std::expected<ProcessImage, std::string> buildProcessImage(const mm::comm::PdoLayout& layout,
95 const std::vector<Device>& devices);
96
97} // namespace mm::node
Definition http_server.h:16
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:142
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:46
std::vector< uint8_t > extractBits(std::span< const uint8_t > src, uint32_t bitOffset, uint16_t bitLength)
Extracts bitLength bits at bitOffset from src into a fresh LSB-aligned little-endian byte vector (cei...
Definition process_image.cc:120
Layout of the process-data images, produced by configureProcessData.
Definition fieldbus_driver.h:155
Fixed-capacity byte buffer for one direction of the process image.
Definition process_image.h:24
std::array< uint8_t, mm::comm::kMaxProcessImageBytes > bytes
Definition process_image.h:26
uint32_t size
Definition process_image.h:25
Locates one mapped object within the flat process image.
Definition process_image.h:35
uint16_t index
CoE object index.
Definition process_image.h:37
uint16_t bitLength
Width of the value in bits.
Definition process_image.h:39
uint8_t subindex
CoE object subindex.
Definition process_image.h:38
uint32_t bitOffset
Absolute bit offset within the direction's image.
Definition process_image.h:40
uint16_t slavePosition
1-based bus position of the owning device.
Definition process_image.h:36
Where a mapped object sits in the image, and which direction it belongs to.
Definition process_image.h:57
uint32_t bitOffset
Absolute bit offset within the direction's image.
Definition process_image.h:58
uint16_t bitLength
Width of the value in bits.
Definition process_image.h:59
size_t entryIndex
Definition process_image.h:61
bool isOutput
True for an RxPDO output, false for a TxPDO input.
Definition process_image.h:60
The whole bus's process-data layout, resolved to absolute positions.
Definition process_image.h:49
uint32_t inputBytes
Size of the input image.
Definition process_image.h:53
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:100
uint32_t outputBytes
Size of the output image.
Definition process_image.h:52
std::vector< ProcessImageEntry > outputs
Master→slave objects, located in the output image.
Definition process_image.h:50
int expectedWkc
Working counter when every slave exchanges.
Definition process_image.h:54
std::vector< ProcessImageEntry > inputs
Slave→master objects, located in the input image.
Definition process_image.h:51