30 IDENTIFICATION = 5100,
31 ID_MANUFACTURER = 5101,
59 PROD_ACTIVEPROG = 5301,
60 PROD_PARTCOUNT = 5302,
64 NOTIF_SEVERITY = 5402,
72 const UmatiMachineTool *mt;
74UmatiCtx s_umati = {
nullptr};
77void set_str(OpcUaVariant *o,
const char *s)
79 o->type = OpcUaVariantType::OPCUA_VAR_STRING;
81 o->str_len = (int32_t)strnlen(o->str, 0xFFFF);
83void set_u32(OpcUaVariant *o, uint32_t v)
85 o->type = OpcUaVariantType::OPCUA_VAR_UINT32;
88void set_i32(OpcUaVariant *o, int32_t v)
90 o->type = OpcUaVariantType::OPCUA_VAR_INT32;
93void set_f64(OpcUaVariant *o,
double v)
95 o->type = OpcUaVariantType::OPCUA_VAR_DOUBLE;
98void set_bool(OpcUaVariant *o,
bool v)
100 o->type = OpcUaVariantType::OPCUA_VAR_BOOL;
107int32_t add_ref(OpcUaReference *out, int32_t n, uint32_t max, uint32_t target_id,
const char *name, uint32_t node_class,
108 bool organizes =
false)
110 if ((uint32_t)n >= max)
114 OpcUaReference *r = &out[n];
115 r->ref_type_id = organizes ? OPCUA_REFTYPE_ORGANIZES : OPCUA_REFTYPE_HAS_COMPONENT;
116 r->is_forward =
true;
118 r->target_id = target_id;
120 r->browse_name = name;
121 r->display_name = name;
122 r->node_class = node_class;
124 (node_class == OPCUA_NODECLASS_VARIABLE) ? OPCUA_TYPEDEF_BASE_DATA_VARIABLE : OPCUA_TYPEDEF_BASE_OBJECT;
127int32_t add_obj(OpcUaReference *out, int32_t n, uint32_t max, uint32_t
id,
const char *name)
129 return add_ref(out, n, max,
id, name, OPCUA_NODECLASS_OBJECT);
131int32_t add_var(OpcUaReference *out, int32_t n, uint32_t max, uint32_t
id,
const char *name)
133 return add_ref(out, n, max,
id, name, OPCUA_NODECLASS_VARIABLE);
140void pc_umati_bind(
const UmatiMachineTool *mt)
145bool pc_umati_read(uint16_t ns, uint32_t
id, uint32_t attribute, OpcUaVariant *out)
147 const UmatiMachineTool *mt = s_umati.mt;
148 if (!mt || ns !=
PC_UMATI_NS || attribute != OPCUA_ATTR_VALUE)
155 case ID_MANUFACTURER:
156 set_str(out, mt->ident.manufacturer);
159 set_str(out, mt->ident.model);
162 set_str(out, mt->ident.serial_number);
165 set_u32(out, mt->ident.year_of_construction);
168 set_str(out, mt->ident.software_revision);
171 set_str(out, mt->ident.product_instance_uri);
175 set_i32(out, (int32_t)mt->operation_mode);
178 set_f64(out, mt->power_on_duration_s);
182 set_i32(out, (int32_t)mt->channel.state);
185 set_f64(out, mt->channel.feed_override);
188 set_f64(out, mt->channel.rapid_override);
191 set_str(out, mt->channel.active_program);
195 set_f64(out, mt->spindle.rotation_speed);
198 set_f64(out, mt->spindle.override_value);
201 set_bool(out, mt->spindle.is_rotating);
205 set_f64(out, mt->axis_x.actual_position);
208 set_f64(out, mt->axis_y.actual_position);
211 set_f64(out, mt->axis_z.actual_position);
214 case PROD_ACTIVEPROG:
215 set_str(out, mt->active_program);
218 set_u32(out, mt->produced_part_count);
222 set_str(out, mt->message_text);
225 set_u32(out, mt->message_severity);
232int32_t pc_umati_browse(uint16_t ns, uint32_t
id, OpcUaReference *out, uint32_t max)
234 const UmatiMachineTool *mt = s_umati.mt;
241 if (ns == 0 &&
id == 85)
243 return add_ref(out, 0, max, MACHINETOOL, mt->name ? mt->name :
"MachineTool", OPCUA_NODECLASS_OBJECT,
256 n = add_obj(out, n, max, IDENTIFICATION,
"Identification");
257 n = add_obj(out, n, max, MONITORING,
"Monitoring");
258 n = add_obj(out, n, max, PRODUCTION,
"Production");
259 n = add_obj(out, n, max, NOTIFICATION,
"Notification");
262 n = add_var(out, n, max, ID_MANUFACTURER,
"Manufacturer");
263 n = add_var(out, n, max, ID_MODEL,
"Model");
264 n = add_var(out, n, max, ID_SERIAL,
"SerialNumber");
265 n = add_var(out, n, max, ID_YEAR,
"YearOfConstruction");
266 n = add_var(out, n, max, ID_SWREV,
"SoftwareRevision");
267 n = add_var(out, n, max, ID_PRODURI,
"ProductInstanceUri");
270 n = add_obj(out, n, max, MON_MACHINE,
"MachineTool");
271 n = add_obj(out, n, max, MON_CHANNEL,
"Channel");
272 n = add_obj(out, n, max, MON_SPINDLE,
"Spindle");
273 n = add_obj(out, n, max, MON_AXIS_X,
"Axis_X");
274 n = add_obj(out, n, max, MON_AXIS_Y,
"Axis_Y");
275 n = add_obj(out, n, max, MON_AXIS_Z,
"Axis_Z");
278 n = add_var(out, n, max, MON_OPMODE,
"OperationMode");
279 n = add_var(out, n, max, MON_POWERON,
"PowerOnDuration");
282 n = add_var(out, n, max, CH_STATE,
"ChannelState");
283 n = add_var(out, n, max, CH_FEEDOVR,
"FeedOverride");
284 n = add_var(out, n, max, CH_RAPIDOVR,
"RapidOverride");
285 n = add_var(out, n, max, CH_ACTIVEPROG,
"ActiveProgram");
288 n = add_var(out, n, max, SP_SPEED,
"RotationSpeed");
289 n = add_var(out, n, max, SP_OVERRIDE,
"OverrideValue");
290 n = add_var(out, n, max, SP_ROTATING,
"IsRotating");
293 return add_var(out, 0, max, AX_X_POS,
"ActualPosition");
295 return add_var(out, 0, max, AX_Y_POS,
"ActualPosition");
297 return add_var(out, 0, max, AX_Z_POS,
"ActualPosition");
299 n = add_var(out, n, max, PROD_ACTIVEPROG,
"ActiveProgram");
300 n = add_var(out, n, max, PROD_PARTCOUNT,
"ProducedPartCount");
303 n = add_var(out, n, max, NOTIF_MESSAGE,
"ActiveMessage");
304 n = add_var(out, n, max, NOTIF_SEVERITY,
"Severity");
311void pc_umati_install(
const UmatiMachineTool *mt)
314 pc_opcua_set_read_handler(pc_umati_read);
315 pc_opcua_set_browse_handler(pc_umati_browse);
#define PC_UMATI_NS
NamespaceIndex the umati MachineTool nodes live at (default 1).
umati - OPC UA for Machine Tools (OPC 40501-1) information model (PC_ENABLE_UMATI).