ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
umati.h
Go to the documentation of this file.
1// ProtoCore v1.0.16 - Copyright (C) 2026 Douglas Quigg (dstroy0) <dquigg123@gmail.com>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4#ifndef PROTOCORE_UMATI_H
5#define PROTOCORE_UMATI_H
6
7#include "protocore_config.h" // the entry point: protocore_types.h for the widths
8
9EMBED_BEGIN_DECLS
10
11/**
12 * @file umati.h
13 * @brief umati - OPC UA for Machine Tools (OPC 40501-1) information model (PROTOCORE_ENABLE_UMATI).
14 *
15 * umati ("universal machine technology interface") is the OPC UA companion specification for machine
16 * tools (VDW / OPC Foundation, OPC 40501-1, namespace `http://opcfoundation.org/UA/MachineTool/`). It
17 * standardizes how a machine tool exposes its identity and live state so any umati / OPC UA client (the
18 * umati dashboard, UaExpert, python `asyncua`, ...) reads the same structure across vendors.
19 *
20 * This module builds the MachineTool address space on top of the OPC UA Binary server
21 * (`services/opcua`, PROTOCORE_ENABLE_OPCUA): it registers a Browse + Read resolver that answers for the
22 * MachineTool node hierarchy and serves live values out of a caller-owned @ref UmatiMachineTool struct
23 * you refresh in your loop. No heap, no stdlib - the model is a fixed node table, the values are
24 * pointers/scalars in your struct.
25 *
26 * Model exposed (BrowseNames per OPC 40501-1), under the Objects folder:
27 *
28 * MachineTool
29 * Identification Manufacturer, Model, SerialNumber, YearOfConstruction, SoftwareRevision,
30 * ProductInstanceUri
31 * Monitoring
32 * MachineTool OperationMode, PowerOnDuration
33 * Channel ChannelState, FeedOverride, RapidOverride, ActiveProgram
34 * Spindle RotationSpeed, OverrideValue, IsRotating
35 * Axis_X/Y/Z ActualPosition
36 * Production ActiveProgram, ProducedPartCount
37 * Notification ActiveMessage, Severity
38 *
39 * The model is read-only (a monitoring model - the machine reports, the client observes). Scope note:
40 * a single Channel/Spindle and three linear axes are exposed (the common embedded machine); the values
41 * carry faithful BrowseNames, but the companion-spec TypeDefinitions and the NamespaceArray entry for
42 * the MachineTool URI (which needs array-Variant support in the base server) are a documented follow-on
43 * - a generic OPC UA client still browses the structure and reads every value by BrowseName today.
44 *
45 * @c work is PROTOCORE_UMATI_BORROW bytes the CALLER took, at an address it knows. It is not held past the call, so
46 * nothing here aliases it. How those bytes are carved is this module's and is never named here.
47 *
48 * @author Douglas Quigg (dstroy0)
49 * @date 2026
50 */
51
52/** @brief The OPC UA for Machine Tools companion-spec namespace URI (OPC 40501-1). */
53#define UMATI_NS_URI "http://opcfoundation.org/UA/MachineTool/"
54
55/**
56 * @brief MachineTool OperationMode (OPC 40501-1 MachineOperationMode). Exposed as Int32; the numeric
57 * values follow the companion-spec enumeration. The machine reports its current mode.
58 */
59EMBED_ENUM_BYTE(UmatiOperationMode,
60 UMATI_OP_OTHER = 0, ///< a mode outside the ones below.
61 UMATI_OP_MANUAL = 1, ///< hand / jog operation.
62 UMATI_OP_MDA = 2, ///< manual data automatic (single-block MDI).
63 UMATI_OP_AUTOMATIC = 3, ///< running a stored program automatically.
64 UMATI_OP_SETUP = 4, ///< set-up / preparation.
65);
66
67/**
68 * @brief Channel state (OPC 40501-1 ChannelState). Exposed as Int32; the numeric values follow the
69 * companion-spec enumeration.
70 */
71EMBED_ENUM_BYTE(UmatiChannelState,
72 UMATI_CH_INTERRUPTED = 0, ///< program interrupted / feed hold.
73 UMATI_CH_RESET = 1, ///< channel reset (no program active).
74 UMATI_CH_RUNNING = 2, ///< a program is executing.
75 UMATI_CH_WAITING = 3, ///< waiting (e.g. for a synchronization / dwell).
76);
77
78/** @brief MachineTool identification (OPC 40501-1 Identification, subtype of Machinery MachineIdentification). */
79typedef struct
80{
81 const char *manufacturer; ///< Manufacturer (LocalizedText -> String).
82 const char *model; ///< Model (LocalizedText -> String).
83 const char *serial_number; ///< SerialNumber (String).
84 const char *software_revision; ///< SoftwareRevision (String).
85 const char *product_instance_uri; ///< ProductInstanceUri (String) - the unique instance URI.
86 uint16_t year_of_construction; ///< YearOfConstruction (UInt16, exposed as UInt32).
88
89/** @brief One Channel's live monitoring values (OPC 40501-1 ChannelType, common subset). */
90typedef struct
91{
92 UmatiChannelState state; ///< ChannelState.
93 double feed_override; ///< FeedOverride (%).
94 double rapid_override; ///< RapidOverride (%).
95 const char *active_program; ///< ActiveProgram.Name (the running NC program).
97
98/** @brief One Spindle's live monitoring values (OPC 40501-1 SpindleType, common subset). */
99typedef struct
100{
101 double rotation_speed; ///< RotationSpeed (rpm).
102 double override_value; ///< OverrideValue (%).
103 embed_bool is_rotating; ///< IsRotating.
105
106/** @brief One linear Axis' live monitoring value (OPC 40501-1 LinearAxisType, common subset). */
107typedef struct
108{
109 double actual_position; ///< ActualPosition (mm).
110} UmatiAxis;
111
112/**
113 * @brief The whole MachineTool the server exposes. Own it in your sketch and refresh its fields each
114 * loop from your machine I/O. The umati resolvers read straight out of it (no copy). String
115 * fields may be null (served as an empty String).
116 */
117typedef struct
118{
119 const char *name; ///< MachineTool BrowseName / DisplayName (the machine's name).
120 UmatiIdentification ident; ///< Identification.
121 UmatiOperationMode operation_mode; ///< Monitoring.MachineTool.OperationMode.
122 double power_on_duration_s; ///< Monitoring.MachineTool.PowerOnDuration (seconds).
123 UmatiChannel channel; ///< Monitoring.Channel.
124 UmatiSpindle spindle; ///< Monitoring.Spindle.
125 UmatiAxis axis_x; ///< Monitoring.Axis_X.
126 UmatiAxis axis_y; ///< Monitoring.Axis_Y.
127 UmatiAxis axis_z; ///< Monitoring.Axis_Z.
128 const char *active_program; ///< Production.ActiveProgram.Name.
129 uint32_t produced_part_count; ///< Production.ProducedPartCount.
130 const char *message_text; ///< Notification.ActiveMessage (most-recent active message text).
131 uint32_t message_severity; ///< Notification.Severity (0..1000, OPC UA event severity scale).
133
134/** @brief Dispatch table. Addressed by offset, so the layout is asserted below. */
135typedef struct
136{
137 void (*bind)(uint8_t *, const UmatiMachineTool *);
138 void (*install)(uint8_t *, const UmatiMachineTool *);
139} UmatiNs;
141
142/**
143 * @brief Bind the MachineTool the resolvers serve. mt must outlive the .
144 * @param work PROTOCORE_UMATI_BORROW bytes the caller took. Not held past the call.
145 * @param mt Mt
146 */
147void protocore_umati_bind(uint8_t *work, const UmatiMachineTool *mt);
148/**
149 * @brief Convenience: bind mt and register both resolvers on the OPC UA .
150 * @param work PROTOCORE_UMATI_BORROW bytes the caller took. Not held past the call.
151 * @param mt Mt
152 */
153void protocore_umati_install(uint8_t *work, const UmatiMachineTool *mt);
154
155/**
156 * @brief The PROTOCORE_UMATI_BORROW bytes this module's state lives in.
157 *
158 * Stated beside the namespace rather than on it: an entry takes a borrow, and this is where
159 * that borrow comes from. Taken once from the end of the pool, which no mark and no release
160 * walks, so the state lasts the life of the program.
161 *
162 * @return the span.
163 */
164uint8_t *protocore_umati_span(void);
165
166/** @brief Module namespace. */
168
169EMBED_END_DECLS
170
171#endif // PROTOCORE_UMATI_H
#define PROTOCORE_UNUSED
Suppress the unused warning. Every module ends in a namespace most callers only partly use.
Definition ns_contract.h:36
#define PROTOCORE_NS_LAYOUT(T,...)
Pin every dispatch slot of a table that is nothing but function pointers.
#define PROTOCORE_NS
Storage for a dispatch table. The const is load bearing.
One linear Axis' live monitoring value (OPC 40501-1 LinearAxisType, common subset).
Definition umati.h:108
double actual_position
ActualPosition (mm).
Definition umati.h:109
One Channel's live monitoring values (OPC 40501-1 ChannelType, common subset).
Definition umati.h:91
double feed_override
FeedOverride (%).
Definition umati.h:93
double rapid_override
RapidOverride (%).
Definition umati.h:94
const char * active_program
ActiveProgram.Name (the running NC program).
Definition umati.h:95
UmatiChannelState state
ChannelState.
Definition umati.h:92
MachineTool identification (OPC 40501-1 Identification, subtype of Machinery MachineIdentification).
Definition umati.h:80
const char * product_instance_uri
ProductInstanceUri (String) - the unique instance URI.
Definition umati.h:85
const char * manufacturer
Manufacturer (LocalizedText -> String).
Definition umati.h:81
const char * serial_number
SerialNumber (String).
Definition umati.h:83
const char * model
Model (LocalizedText -> String).
Definition umati.h:82
const char * software_revision
SoftwareRevision (String).
Definition umati.h:84
uint16_t year_of_construction
YearOfConstruction (UInt16, exposed as UInt32).
Definition umati.h:86
The whole MachineTool the server exposes. Own it in your sketch and refresh its fields each loop from...
Definition umati.h:118
double power_on_duration_s
Monitoring.MachineTool.PowerOnDuration (seconds).
Definition umati.h:122
UmatiIdentification ident
Identification.
Definition umati.h:120
const char * name
MachineTool BrowseName / DisplayName (the machine's name).
Definition umati.h:119
UmatiAxis axis_z
Monitoring.Axis_Z.
Definition umati.h:127
uint32_t produced_part_count
Production.ProducedPartCount.
Definition umati.h:129
UmatiAxis axis_x
Monitoring.Axis_X.
Definition umati.h:125
UmatiAxis axis_y
Monitoring.Axis_Y.
Definition umati.h:126
const char * message_text
Notification.ActiveMessage (most-recent active message text).
Definition umati.h:130
UmatiChannel channel
Monitoring.Channel.
Definition umati.h:123
const char * active_program
Production.ActiveProgram.Name.
Definition umati.h:128
uint32_t message_severity
Notification.Severity (0..1000, OPC UA event severity scale).
Definition umati.h:131
UmatiSpindle spindle
Monitoring.Spindle.
Definition umati.h:124
UmatiOperationMode operation_mode
Monitoring.MachineTool.OperationMode.
Definition umati.h:121
Dispatch table. Addressed by offset, so the layout is asserted below.
Definition umati.h:136
void(* install)(uint8_t *, const UmatiMachineTool *)
Definition umati.h:138
void(* bind)(uint8_t *, const UmatiMachineTool *)
Definition umati.h:137
One Spindle's live monitoring values (OPC 40501-1 SpindleType, common subset).
Definition umati.h:100
double override_value
OverrideValue (%).
Definition umati.h:102
double rotation_speed
RotationSpeed (rpm).
Definition umati.h:101
embed_bool is_rotating
IsRotating.
Definition umati.h:103
void protocore_umati_bind(uint8_t *work, const UmatiMachineTool *mt)
Bind the MachineTool the resolvers serve. mt must outlive the .
uint8_t * protocore_umati_span(void)
The PROTOCORE_UMATI_BORROW bytes this module's state lives in.
EMBED_ENUM_BYTE(UmatiOperationMode, UMATI_OP_OTHER=0, UMATI_OP_MANUAL=1, UMATI_OP_MDA=2, UMATI_OP_AUTOMATIC=3, UMATI_OP_SETUP=4,)
MachineTool OperationMode (OPC 40501-1 MachineOperationMode). Exposed as Int32; the numeric values fo...
void protocore_umati_install(uint8_t *work, const UmatiMachineTool *mt)
Convenience: bind mt and register both resolvers on the OPC UA .