beckhoff TE1000 TwinCAT 3 — 6.7.3 Reloading TMC files

Samples | TcCOM "LREAL" => BitConverter.ToDouble(bytes, 0), "LINT" => BitConverter.ToInt64(bytes, 0), "DINT" => BitConverter.ToInt32(bytes, 0), "UDINT" or "DWORD" => BitConverter.ToUInt32(bytes, 0), "INT" => BitConverter.ToInt16(bytes, 0), "UINT" or "WORD" => BitConverter.ToUInt16(bytes, 0), "BOOL" => bytes[0] != 0, _ => bytes // Struct or unknown type — return raw bytes }; The _ branch catches structs and unknown types and returns the raw byte array. For composite types, you can determine the exact set-up using ITcTypeInstance.IecDeclaration if necessary and parse the byte array accordingly. This makes rule 3 the most robust approach when the parameter type is not known at development time.

It works for all scalar types without requiring prior knowledge of the byte size. For known scalar parameters, rule 1 remains the simplest solution. For details on the returned type descriptor, see the article ITcTypeInstance [ } 77] . 6.7.3 Reloading TMC files | Reloading TMC files The .tmc file of a TcCOM object describes the module's parameter interface. If the TMC file on the disk is updated, it must be reloaded into the solution for the changes to take effect. You can do this directly on the Tree Item via ConsumeXml , without closing or reopening the solution. The Mode parameter controls whether existing settings are retained.

Requirements TwinCAT from version 4024.10 an active DTE connection with an initialized ITcSysManager object. an existing TcCOM object in the solution, accessible via LookupTreeItem. C# sample The first snippet reloads the TMC file using the internally stored path. The second snippet explicitly specifies the path and Mode . The third snippet exports the currently loaded TMC file to a file before reloading it, which can be used as a backup copy.

ITcSmTreeItem tcComObject = sysManager.LookupTreeItem(@"TIRC^TcCOM Objects^MyModule"); // Reload TMC file of the object (using current path) tcComObject.ConsumeXml(" true "); // Load TMC file from explicit path with mode tcComObject.ConsumeXml(@" true "); // Export TMC file (optional, before reload) tcComObject.ConsumeXml(@" "); Mode determines which existing settings are retained after a reload: - warm (default): All saved settings are restored. - cold : Only settings that were not explicitly set are restored. - origin : No settings are restored. The object will be reset to factory settings. If the module's GUID has changed, the reload will fail.

In this case, the object must be created anew. TE1000 280 Version: 1.7.0