29 IDENTIFICATION = 5100,
30 ID_MANUFACTURER = 5101,
58 PROD_ACTIVEPROG = 5301,
59 PROD_PARTCOUNT = 5302,
63 NOTIF_SEVERITY = 5402,
71 const UmatiMachineTool *mt;
73UmatiCtx s_umati = {
nullptr};
76void set_str(OpcUaVariant *o,
const char *s)
78 o->type = OpcUaVariantType::OPCUA_VAR_STRING;
80 o->str_len = (int32_t)strnlen(o->str, 0xFFFF);
82void set_u32(OpcUaVariant *o, uint32_t v)
84 o->type = OpcUaVariantType::OPCUA_VAR_UINT32;
87void set_i32(OpcUaVariant *o, int32_t v)
89 o->type = OpcUaVariantType::OPCUA_VAR_INT32;
92void set_f64(OpcUaVariant *o,
double v)
94 o->type = OpcUaVariantType::OPCUA_VAR_DOUBLE;
97void set_bool(OpcUaVariant *o,
bool v)
99 o->type = OpcUaVariantType::OPCUA_VAR_BOOL;
106int32_t add_ref(OpcUaReference *out, int32_t n, uint32_t max, uint32_t target_id,
const char *name, uint32_t node_class,
107 bool organizes =
false)
109 if ((uint32_t)n >= max)
111 OpcUaReference *r = &out[n];
112 r->ref_type_id = organizes ? OPCUA_REFTYPE_ORGANIZES : OPCUA_REFTYPE_HAS_COMPONENT;
113 r->is_forward =
true;
115 r->target_id = target_id;
117 r->browse_name = name;
118 r->display_name = name;
119 r->node_class = node_class;
121 (node_class == OPCUA_NODECLASS_VARIABLE) ? OPCUA_TYPEDEF_BASE_DATA_VARIABLE : OPCUA_TYPEDEF_BASE_OBJECT;
124int32_t add_obj(OpcUaReference *out, int32_t n, uint32_t max, uint32_t
id,
const char *name)
126 return add_ref(out, n, max,
id, name, OPCUA_NODECLASS_OBJECT);
128int32_t add_var(OpcUaReference *out, int32_t n, uint32_t max, uint32_t
id,
const char *name)
130 return add_ref(out, n, max,
id, name, OPCUA_NODECLASS_VARIABLE);
137void umati_bind(
const UmatiMachineTool *mt)
142bool umati_read(uint16_t ns, uint32_t
id, uint32_t attribute, OpcUaVariant *out)
144 const UmatiMachineTool *mt = s_umati.mt;
150 case ID_MANUFACTURER:
151 set_str(out, mt->ident.manufacturer);
154 set_str(out, mt->ident.model);
157 set_str(out, mt->ident.serial_number);
160 set_u32(out, mt->ident.year_of_construction);
163 set_str(out, mt->ident.software_revision);
166 set_str(out, mt->ident.product_instance_uri);
170 set_i32(out, (int32_t)mt->operation_mode);
173 set_f64(out, mt->power_on_duration_s);
177 set_i32(out, (int32_t)mt->channel.state);
180 set_f64(out, mt->channel.feed_override);
183 set_f64(out, mt->channel.rapid_override);
186 set_str(out, mt->channel.active_program);
190 set_f64(out, mt->spindle.rotation_speed);
193 set_f64(out, mt->spindle.override_value);
196 set_bool(out, mt->spindle.is_rotating);
200 set_f64(out, mt->axis_x.actual_position);
203 set_f64(out, mt->axis_y.actual_position);
206 set_f64(out, mt->axis_z.actual_position);
209 case PROD_ACTIVEPROG:
210 set_str(out, mt->active_program);
213 set_u32(out, mt->produced_part_count);
217 set_str(out, mt->message_text);
220 set_u32(out, mt->message_severity);
227int32_t umati_browse(uint16_t ns, uint32_t
id, OpcUaReference *out, uint32_t max)
229 const UmatiMachineTool *mt = s_umati.mt;
234 if (ns == 0 &&
id == 85)
235 return add_ref(out, 0, max, MACHINETOOL, mt->name ? mt->name :
"MachineTool", OPCUA_NODECLASS_OBJECT,
245 n = add_obj(out, n, max, IDENTIFICATION,
"Identification");
246 n = add_obj(out, n, max, MONITORING,
"Monitoring");
247 n = add_obj(out, n, max, PRODUCTION,
"Production");
248 n = add_obj(out, n, max, NOTIFICATION,
"Notification");
251 n = add_var(out, n, max, ID_MANUFACTURER,
"Manufacturer");
252 n = add_var(out, n, max, ID_MODEL,
"Model");
253 n = add_var(out, n, max, ID_SERIAL,
"SerialNumber");
254 n = add_var(out, n, max, ID_YEAR,
"YearOfConstruction");
255 n = add_var(out, n, max, ID_SWREV,
"SoftwareRevision");
256 n = add_var(out, n, max, ID_PRODURI,
"ProductInstanceUri");
259 n = add_obj(out, n, max, MON_MACHINE,
"MachineTool");
260 n = add_obj(out, n, max, MON_CHANNEL,
"Channel");
261 n = add_obj(out, n, max, MON_SPINDLE,
"Spindle");
262 n = add_obj(out, n, max, MON_AXIS_X,
"Axis_X");
263 n = add_obj(out, n, max, MON_AXIS_Y,
"Axis_Y");
264 n = add_obj(out, n, max, MON_AXIS_Z,
"Axis_Z");
267 n = add_var(out, n, max, MON_OPMODE,
"OperationMode");
268 n = add_var(out, n, max, MON_POWERON,
"PowerOnDuration");
271 n = add_var(out, n, max, CH_STATE,
"ChannelState");
272 n = add_var(out, n, max, CH_FEEDOVR,
"FeedOverride");
273 n = add_var(out, n, max, CH_RAPIDOVR,
"RapidOverride");
274 n = add_var(out, n, max, CH_ACTIVEPROG,
"ActiveProgram");
277 n = add_var(out, n, max, SP_SPEED,
"RotationSpeed");
278 n = add_var(out, n, max, SP_OVERRIDE,
"OverrideValue");
279 n = add_var(out, n, max, SP_ROTATING,
"IsRotating");
282 return add_var(out, 0, max, AX_X_POS,
"ActualPosition");
284 return add_var(out, 0, max, AX_Y_POS,
"ActualPosition");
286 return add_var(out, 0, max, AX_Z_POS,
"ActualPosition");
288 n = add_var(out, n, max, PROD_ACTIVEPROG,
"ActiveProgram");
289 n = add_var(out, n, max, PROD_PARTCOUNT,
"ProducedPartCount");
292 n = add_var(out, n, max, NOTIF_MESSAGE,
"ActiveMessage");
293 n = add_var(out, n, max, NOTIF_SEVERITY,
"Severity");
300void umati_install(
const UmatiMachineTool *mt)
303 opcua_set_read_handler(umati_read);
304 opcua_set_browse_handler(umati_browse);
#define DETWS_UMATI_NS
NamespaceIndex the umati MachineTool nodes live at (default 1).
umati - OPC UA for Machine Tools (OPC 40501-1) information model (DETWS_ENABLE_UMATI).