{"id":2629,"date":"2025-04-09T04:37:57","date_gmt":"2025-04-09T04:37:57","guid":{"rendered":"https:\/\/www.woojin.help\/?p=2629"},"modified":"2025-06-12T11:16:11","modified_gmt":"2025-06-12T11:16:11","slug":"imc500-drive-configuration-generator-deprecated","status":"publish","type":"post","link":"https:\/\/www.woojin.help\/ko\/imc500-drive-configuration-generator-deprecated\/","title":{"rendered":"IMC500 KEB Dat.File Drive Configuration Generator (deprecated)"},"content":{"rendered":"<div class=\"pdfprnt-buttons pdfprnt-buttons-post pdfprnt-top-right\"><\/div>\n<p class=\"wp-block-paragraph\"><strong>Author: Moritz Wurian<\/strong><br><strong>Script path:<\/strong> <a href=\"https:\/\/svn.woojin.at\/svn\/RD\/02_Control\/00_Topics\/2022\/2022_TC09_TE_IMC500_KEB\/DatFile_Generator\/Python\">https:\/\/svn.woojin.at\/svn\/RD\/02_Control\/00_Topics\/2022\/2022_TC09_TE_IMC500_KEB\/DatFile_Generator\/Python<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"> <em>(no longer in active use)<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This Python-based generator was developed to support the initial configuration of drives in <strong>injection molding machines<\/strong> using a <strong>Combivis XML project file<\/strong>. It created a <code>.dat<\/code> configuration file that could be imported by the <strong>IMC500 controller<\/strong>, allowing for a predefined parameter set to be applied at machine startup.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Purpose<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The tool allowed users to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Convert drive parameters from a Combivis project (XML format)<\/li>\n\n\n\n<li>Generate a compatible <code>.dat<\/code> file for IMC500 systems<\/li>\n\n\n\n<li>Select either all parameters or only specific indices<\/li>\n\n\n\n<li>Automatically convert and byte-swap hex data into decimal format<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Key Features<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>GUI-based workflow<\/strong> using Tkinter (file selection, parameter selection, save path)<\/li>\n\n\n\n<li>Optional filtering using an index list (<code>.txt<\/code>)<\/li>\n\n\n\n<li>Automatic conversion and byte-order correction<\/li>\n\n\n\n<li>Structured output matching the IMC500 format: pythonKopierenBearbeiten<code>AXdat_DataObject[0] = 15360, 0, 2018915346, 4; Optional comment<\/code><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Deprecation Notice<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">This tool is <strong>no longer in active use<\/strong>.<br>Drive configurations are now handled via <strong>CSV files<\/strong>, which can be saved and reloaded directly through the IMC500 HMI or control interface. This approach is more transparent, flexible, and integrates better with versioning systems and parameter editors.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">Let me know if you want to include a download link or move it to an &#8220;archived tools&#8221; section.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import xml.etree.ElementTree as ET\nimport tkinter as tk\nfrom tkinter import filedialog, messagebox\nimport os\n\n# Liste der zu vergleichenden Indizes\ndef index_list_from_txt(filepath):\n    \"\"\"\n    Liest Indizes aus einer Textdatei, ignoriert Kommentare nach '#' und verarbeitet Kommas.\n\n    Args:\n        filepath: Der Pfad zur Textdatei.\n\n    Returns:\n        Eine Liste der extrahierten Indizes als Ganzzahlen.\n    \"\"\"\n    try:\n        with open(filepath, \"r\") as file:\n            parameter_list = &#91;]\n            for line in file:\n                # Split the line at the first occurrence of '#' or ','\n                parts = line.split('#', 1)&#91;0].split(',', 1)&#91;0].strip()\n\n                if parts.isdigit():\n                    parameter_list.append(int(parts))\n\n        return parameter_list\n    except FileNotFoundError:\n        messagebox.showerror(\"Fehler\", f\"Die Datei {filepath} wurde nicht gefunden.\")\n        exit(1) \n\ndef byteswap_und_hex_zu_dez(hex_str):\n    \"\"\"\n    F\u00fchrt einen Byteswap auf einer Hex-Zeichenkette durch und konvertiert sie in eine Dezimalzahl.\n\n    Args:\n        hex_str: Die Hex-Zeichenkette.\n\n    Returns:\n        Die entsprechende Dezimalzahl.\n    \"\"\"\n    swapped = bytes.fromhex(hex_str)&#91;::-1]\n    return int(swapped.hex(), 16)\n\ndef datalength_anpassen(data):\n    \"\"\"\n    Passt die Datenl\u00e4nge basierend auf der Anzahl der Hex-Zeichen an.\n\n    Args:\n        data: Die Daten.\n\n    Returns:\n        Die angepasste Datenl\u00e4nge.\n    \"\"\"\n    length = len(data) \/\/ 2 \n    if length == 0:\n        return 1\n    elif length == 3:\n        return 4\n    else:\n        return length\n\ndef xml_auslesen_und_verarbeiten(xml_datei, index_list, all_parameters):\n    \"\"\"\n    Liest eine XML-Datei, verarbeitet die Daten und schreibt sie in eine .dat-Datei.\n\n    Args:\n        xml_datei: Der Pfad zur XML-Datei.\n        index_list: Eine Liste der zu verarbeitenden Indizes (leer, wenn alle Parameter verarbeitet werden sollen).\n        all_parameters: Ein boolescher Wert, der angibt, ob alle Parameter verarbeitet werden sollen.\n    \"\"\"\n    try:\n        tree = ET.parse(xml_datei)\n        root = tree.getroot()\n\n        with open(datFilePath, \"w\") as dat_file:\n            counter = 0\n            for initCmd in root.findall(\".\/\/InitCmd\"):\n                index = int(initCmd.find(\"Index\").text)\n                if not all_parameters and index not in index_list:\n                    continue \n\n                subIndex = initCmd.find(\"SubIndex\").text\n                data = initCmd.find(\"Data\").text\n                comment_element = initCmd.find(\"Comment\")\n                comment = comment_element.text if comment_element is not None else \"\" \n                datalength = datalength_anpassen(data)\n                dez_data = byteswap_und_hex_zu_dez(data)\n\n                dat_file.write(f'\"AXdat_DataObject&#91;{counter}] = {index}, {subIndex}, {dez_data}, {datalength}\" {\";\"} {comment}\\n')\n                counter += 1\n    except ET.ParseError as e:\n        messagebox.showerror(\"Fehler\", f\"Fehler beim Parsen der XML-Datei: {e}\")\n        exit(1) \n\n# Tkinter Root-Fenster erstellen\nroot = tk.Tk()\nroot.withdraw()\n\n# Dialog zur Dateiauswahl \u00f6ffnen\nxml_datei = filedialog.askopenfilename(title=\"Parameter-File ausw\u00e4hlen\", filetypes=&#91;(\"XML\", \"*.xml\"), (\"Alle Dateien\", \"*.*\")])\n\n# \u00dcberpr\u00fcfung, ob eine Datei ausgew\u00e4hlt wurde\nif not xml_datei:\n    messagebox.showinfo(\"Info\", \"Keine XML-Datei ausgew\u00e4hlt. Das Programm wird beendet.\")\n    exit(0)\n\n# Auswahl, ob alle Parameter \u00fcbertragen werden sollen\nuser_choice = messagebox.askquestion(\"XML Eintr\u00e4ge \u00fcbertragen\", \"M\u00f6chten Sie alle Parameter \u00fcbertragen?\")\nall_parameters = user_choice == 'yes'\n\n# Indexliste laden, falls nicht alle Parameter \u00fcbertragen werden sollen\nif not all_parameters:\n    index_file_path = filedialog.askopenfilename(title=\"Index-Liste ausw\u00e4hlen\", filetypes=&#91;(\"Textdateien\", \"*.txt\"), (\"Alle Dateien\", \"*.*\")])\n    \n    if not index_file_path:\n        messagebox.showinfo(\"Info\", \"Keine Index-Liste ausgew\u00e4hlt. Das Programm wird beendet.\")\n        exit(0)\n\n    index_list = index_list_from_txt(index_file_path)\nelse:\n    index_list = &#91;]  # Leere Liste, wenn alle Parameter \u00fcbertragen werden sollen\n\n# Dialog zur Dateispeicherung \u00f6ffnen\ndatFilePath = filedialog.asksaveasfilename(defaultextension=\".dat\", filetypes=&#91;(\"Datendateien\", \"*.dat\"), (\"Alle Dateien\", \"*.*\")])\n\n# \u00dcberpr\u00fcfung, ob ein Speicherort ausgew\u00e4hlt wurde\nif not datFilePath:\n    messagebox.showinfo(\"Info\", \"Kein Speicherort ausgew\u00e4hlt. Das Programm wird beendet.\")\n    exit(0)\n\nroot.destroy()\n\n# XML-Datei verarbeiten und in .dat-Datei schreiben\nxml_auslesen_und_verarbeiten(xml_datei, index_list, all_parameters)\n\n# Erfolgsmeldung anzeigen\nmessagebox.showinfo(\"Erfolg\", \"Die Verarbeitung ist abgeschlossen. Die .dat-Datei wurde erstellt.\")<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Author: Moritz WurianScript path: https:\/\/svn.woojin.at\/svn\/RD\/02_Control\/00_Topics\/2022\/2022_TC09_TE_IMC500_KEB\/DatFile_Generator\/Python (no longer in active use) This Python-based generator was developed to support the initial configuration [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"disabled","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[379,392,394],"tags":[],"class_list":["post-2629","post","type-post","status-publish","format-standard","hentry","category-documentation","category-drive","category-keb"],"_links":{"self":[{"href":"https:\/\/www.woojin.help\/ko\/wp-json\/wp\/v2\/posts\/2629","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.woojin.help\/ko\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.woojin.help\/ko\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.woojin.help\/ko\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.woojin.help\/ko\/wp-json\/wp\/v2\/comments?post=2629"}],"version-history":[{"count":3,"href":"https:\/\/www.woojin.help\/ko\/wp-json\/wp\/v2\/posts\/2629\/revisions"}],"predecessor-version":[{"id":3065,"href":"https:\/\/www.woojin.help\/ko\/wp-json\/wp\/v2\/posts\/2629\/revisions\/3065"}],"wp:attachment":[{"href":"https:\/\/www.woojin.help\/ko\/wp-json\/wp\/v2\/media?parent=2629"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.woojin.help\/ko\/wp-json\/wp\/v2\/categories?post=2629"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.woojin.help\/ko\/wp-json\/wp\/v2\/tags?post=2629"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}