This commit is contained in:
Eduard Gerlitz 2025-03-13 14:35:46 +01:00
parent ccfbac1768
commit 8d726ccaae
8 changed files with 88 additions and 64 deletions

15
CHANGELOG.md Normal file
View File

@ -0,0 +1,15 @@
# CHANGELOG
v2.0.1
- Anpassung funct_gen.py
- Anpassung Layout
- Felder --> mehrzeilig möglich
- Anpassung INSTALLER und MAIN.ps1
v2
- Beschränkung nur auf Inlay, Werkstück, Schraubstock
- neue Parameter definiert und Abhängigkeit implementiert
- Generator für die Visualisierung komplett überarbeitet
- neue Platzhalter-Bilder

View File

@ -1,8 +1,9 @@
# Construct the full path to the Python script #---------- USER DEFINE --------------
$ymlPath = "./_condaenv.yml" $ymlPath = "./condaenv.yml"
#-------------------------------------
# Execute the Python script # Execute the Python script
& conda env create -f $ymlPath & conda env create -f $ymlPath
# Pause at the end of the script # Pause at the end of the script
Read-Host -Prompt "Press any key to exit" # Read-Host -Prompt "Press any key to exit"

View File

@ -3,14 +3,8 @@ $venvName = "dmu50_wingui"
$scriptPath = "./MAIN.py" $scriptPath = "./MAIN.py"
#------------------------------------- #-------------------------------------
# Get the current username # Activate the Conda environment and execute the Python script
$username = [System.Environment]::UserName cmd.exe /c "conda activate $venvName && python $scriptPath"
# Construct the path to the Python executable
$pythonExe = "C:\Users\user58\.conda\envs\$venvName\python.exe"
# Execute the Python script
& $pythonExe $scriptPath
# Pause at the end of the script # Pause at the end of the script
Read-Host -Prompt "Press Enter to exit" # Read-Host -Prompt "Press Enter to exit"

74
MAIN.py
View File

@ -16,8 +16,8 @@ folder_pictures = "cfg_picture"
folder_output = "_out" folder_output = "_out"
file_def = "def.yml" file_def = "def.yml"
file_jobs = "jobs.yml" file_jobs = "jobs.yml"
name_newparset = "<<new par set>>" name_newparset = "<new parset>"
name_newjob = "<<new job>>" name_newjob = "<new job>"
pic_sizelimit = 200 pic_sizelimit = 200
@ -26,18 +26,24 @@ def setup_group(frame, group_name, data, input_vars, selected_params, group_widg
picture_name = group_data['cfg']['picture_name'] # Picture name defined in def.yml picture_name = group_data['cfg']['picture_name'] # Picture name defined in def.yml
picture_path = os.path.join(folder_parsets, picture_name) # Full path to the picture picture_path = os.path.join(folder_parsets, picture_name) # Full path to the picture
# Dropdown for parameter sets
param_values = get_existing_parameters(group_name, folder_parsets) param_values = get_existing_parameters(group_name, folder_parsets)
param_values.append(name_newparset) param_values.append(name_newparset)
param_var = selected_params[group_name] # Bind the dropdown to the corresponding selected_param entry param_var = selected_params[group_name] # Bind the dropdown to the corresponding selected_param entry
param_dropdown = ttk.Combobox(frame, textvariable=param_var, values=param_values)
multicolumn_idx = group_data['cfg'].get('multicolumn_idx', [])
colspan = (len(multicolumn_idx)+1)*2
# Dropdown for parameter sets
frame_parset = ttk.Frame(frame)
frame_parset.grid(row=2, column=0, columnspan=colspan, pady=5, sticky="w")
param_dropdown = ttk.Combobox(frame_parset, textvariable=param_var, values=param_values, width=14)
group_widgets[group_name] = {"param_dropdown": param_dropdown} # Save for later reference group_widgets[group_name] = {"param_dropdown": param_dropdown} # Save for later reference
source_path = f"{folder_pictures}/{data['general']['notavailablepic_name']}" source_path = f"{folder_pictures}/{data['general']['notavailablepic_name']}"
# Handle missing picture case # Dropdown field
# if not os.path.exists(picture_path): ttk.Label(frame_parset, text="Parameter-Set:", width=14).grid(row=0, column=0, padx=5, pady=5, sticky="w")
# shutil.copy(source_path, picture_path) param_dropdown.grid(row=0, column=1, padx=5, pady=5, sticky="w")
# Function to update the picture based on inputs or use the init picture # Function to update the picture based on inputs or use the init picture
@ -134,30 +140,33 @@ def setup_group(frame, group_name, data, input_vars, selected_params, group_widg
group_image_tk = load_image(source_path, pic_sizelimit) group_image_tk = load_image(source_path, pic_sizelimit)
image_label = ttk.Label(frame, image=group_image_tk) image_label = ttk.Label(frame, image=group_image_tk)
image_label.image = group_image_tk # Keep a reference to avoid garbage collection image_label.image = group_image_tk # Keep a reference to avoid garbage collection
image_label.grid(row=0, column=0, columnspan=2, padx=10, pady=10, sticky="") # Center the image in the middle image_label.grid(row=0, column=0, columnspan=colspan, padx=10, pady=10, sticky="") # Center the image in the middle
frame.grid_rowconfigure(0, minsize=230) frame.grid_rowconfigure(0, minsize=230)
# Add horizontal line # Add horizontal line
ttk.Separator(frame, orient='horizontal').grid(row=1, column=0, columnspan=2, sticky="ew", pady=10) ttk.Separator(frame, orient='horizontal').grid(row=1, column=0, columnspan=colspan, sticky="ew", pady=10)
# Dropdown field and buttons for save/load/delete # buttons for save/load/delete
ttk.Label(frame, text="Parameter Set:").grid(row=2, column=0, padx=5, pady=5, sticky="w") ttk.Button(frame_parset, text="Save", width=12, command=save_current_param).grid(row=1, column=0, padx=5, pady=5, sticky="w")
param_dropdown.grid(row=2, column=1, padx=5, pady=5) ttk.Button(frame_parset, text="Delete", width=12, command=delete_current_param).grid(row=1, column=1, padx=5, pady=5, sticky="w")
# ttk.Button(frame, text="Load", command=load_selected_param).grid(row=3, column=0, padx=5, pady=5, sticky="w")
ttk.Button(frame, text="Save", command=save_current_param).grid(row=3, column=0, padx=5, pady=5, sticky="w")
ttk.Button(frame, text="Delete", command=delete_current_param).grid(row=3, column=1, padx=5, pady=5, sticky="w")
# Add horizontal line # Add horizontal line
ttk.Separator(frame, orient='horizontal').grid(row=4, column=0, columnspan=2, sticky="ew", pady=10) ttk.Separator(frame, orient='horizontal').grid(row=3, column=0, columnspan=colspan, sticky="ew", pady=10)
# Setup input fields below dropdown and buttons # Setup input fields below dropdown and buttons
row = 5 row = 0
col = 0
group_vars = {} group_vars = {}
for var_name, _ in group_data['parameter'].items(): frame_var = ttk.Frame(frame) # Kein Innenabstand mehr
ttk.Label(frame, text=var_name).grid(row=row, column=0, padx=5, pady=5, sticky="e") frame_var.grid(row=4, column=0, columnspan=colspan, padx=5, pady=5, sticky="nsew")
for idx, (var_name, _) in enumerate(group_data['parameter'].items()):
if idx+1 in multicolumn_idx:
col += 2
row = 0
ttk.Label(frame_var, text=var_name, font=("TkDefaultFont", 7)).grid(row=row, column=col, padx=5, pady=5, sticky="e")
var = tk.StringVar() var = tk.StringVar()
group_vars[var_name] = var group_vars[var_name] = var
ttk.Entry(frame, textvariable=var).grid(row=row, column=1, padx=5, pady=5, sticky="w") ttk.Entry(frame_var, textvariable=var, font=("TkDefaultFont", 7), width=7).grid(row=row, column=col + 1, padx=5, pady=5, sticky="w")
row += 1 row += 1
input_vars[group_name] = group_vars input_vars[group_name] = group_vars
@ -210,20 +219,6 @@ def setup_jobs(frame, data, selected_job, selected_params, input_vars, group_wid
for key in input_vars[group_name]: for key in input_vars[group_name]:
input_vars[group_name][key].set('') # Clear the input fields input_vars[group_name][key].set('') # Clear the input fields
# Function to load the selected parameter set for a group and update inputs
def load_selected_param_for_group(group_name, param_set):
try:
param_data = load_yaml(group_name, param_set, folder_parsets)
for key, value in param_data.items():
input_vars[group_name][key].set(value)
# Trigger the picture update by generating the ComboboxSelected event
param_dropdown = group_widgets[group_name]["param_dropdown"]
param_dropdown.event_generate("<<ComboboxSelected>>")
except FileNotFoundError:
# Handle missing parameter set gracefully
selected_params[group_name].set(name_newparset)
clear_input_fields(group_name)
# Function to save the current job # Function to save the current job
def save_current_job(): def save_current_job():
job_name = selected_job.get() job_name = selected_job.get()
@ -254,8 +249,8 @@ def setup_jobs(frame, data, selected_job, selected_params, input_vars, group_wid
ttk.Label(frame, text="Job:").grid(row=0, column=0, padx=5, pady=5, sticky="w") ttk.Label(frame, text="Job:").grid(row=0, column=0, padx=5, pady=5, sticky="w")
job_dropdown = ttk.Combobox(frame, textvariable=selected_job, values=job_values) job_dropdown = ttk.Combobox(frame, textvariable=selected_job, values=job_values)
job_dropdown.grid(row=0, column=1, padx=5, pady=5) job_dropdown.grid(row=0, column=1, padx=5, pady=5)
ttk.Button(frame, text="Save", command=save_current_job).grid(row=1, column=0, padx=5, pady=5, sticky="w") ttk.Button(frame, text="Save", command=save_current_job).grid(row=0, column=2, padx=5, pady=5, sticky="w")
ttk.Button(frame, text="Delete", command=delete_current_job).grid(row=1, column=1, padx=5, pady=5, sticky="w") ttk.Button(frame, text="Delete", command=delete_current_job).grid(row=0, column=3, padx=5, pady=5, sticky="w")
# Bind job selection to loading the selected job and updating the groups # Bind job selection to loading the selected job and updating the groups
job_dropdown.bind("<<ComboboxSelected>>", lambda event: load_selected_job()) job_dropdown.bind("<<ComboboxSelected>>", lambda event: load_selected_job())
@ -277,7 +272,7 @@ def setup_evaluation(root, folder_pictures, data, folder_output, input_vars, sel
# Load and display the specific initial picture # Load and display the specific initial picture
picture_path = f"{folder_pictures}/{data['general']['generatorpic_name']}" picture_path = f"{folder_pictures}/{data['general']['generatorpic_name']}"
group_image_tk = load_image(picture_path, 200) # Assuming a function load_image exists and works as expected group_image_tk = load_image(picture_path, 100) # Assuming a function load_image exists and works as expected
image_label = ttk.Label(frame, image=group_image_tk) image_label = ttk.Label(frame, image=group_image_tk)
image_label.image = group_image_tk # Keep a reference to avoid garbage collection image_label.image = group_image_tk # Keep a reference to avoid garbage collection
image_label.grid(row=0, column=0, rowspan=2, padx=10, pady=10) image_label.grid(row=0, column=0, rowspan=2, padx=10, pady=10)
@ -309,6 +304,7 @@ def main():
# Tkinter root setup # Tkinter root setup
root = tk.Tk() root = tk.Tk()
root.title("DMU50") root.title("DMU50")
root.geometry("+0+0")
# Load object definitions from YAML # Load object definitions from YAML
with open(file_def, 'r') as file: with open(file_def, 'r') as file:
@ -322,7 +318,7 @@ def main():
def setup_ui(): def setup_ui():
# ---- Setup Jobs UI # ---- Setup Jobs UI
frame = ttk.LabelFrame(root, text="Jobs", padding=(10, 10)) frame = ttk.LabelFrame(root, text="Jobs", padding=(10, 10))
frame.grid(row=0, column=0, columnspan=5, padx=10, pady=10, sticky="nsew") frame.grid(row=0, column=0, columnspan=len(data['groups']), padx=10, pady=10, sticky="nsew")
load_selected_job = setup_jobs(frame, data, selected_job, selected_params, input_vars, group_widgets) load_selected_job = setup_jobs(frame, data, selected_job, selected_params, input_vars, group_widgets)
# ---- Create the UI for each group # ---- Create the UI for each group

View File

@ -18,12 +18,7 @@ Diese GUI dient zur Erfassung verschiedener Parameter für die Maschinenautomati
3. Job auswählen oder erstellen 3. Job auswählen oder erstellen
4. G-Code-Datei generieren und optional auf die Steuerung übertragen 4. G-Code-Datei generieren und optional auf die Steuerung übertragen
---
# CHANGELOG
v2
- Beschränkung nur auf Inlay, Werkstück, Schraubstock
- neue Parameter definiert und Abhängigkeit implementiert
- Generator für die Visualisierung komplett überarbeitet
- neue Platzhalter-Bilder
## Systemvoraussetzung
- Windows
- Bildschirmauflösung ab: 1280 x 1024

View File

@ -12,5 +12,7 @@ dependencies:
- openpyxl - openpyxl
- paramiko - paramiko
- matplotlib - matplotlib
- pip
- pip:
- trimesh - trimesh
- manifold3d - manifold3d

20
def.yml
View File

@ -12,6 +12,7 @@ groups:
INL_Y_OFFSET: double INL_Y_OFFSET: double
cfg: cfg:
picture_name: img_inlay.png picture_name: img_inlay.png
multicolumn_idx: []
wp: wp:
parameter: parameter:
WPR_X: double WPR_X: double
@ -24,6 +25,7 @@ groups:
WP_GRP_OFFSET_Z: double WP_GRP_OFFSET_Z: double
cfg: cfg:
picture_name: img_wp.png picture_name: img_wp.png
multicolumn_idx: [7]
clp: clp:
parameter: parameter:
CLP_BACKENWEITE: double CLP_BACKENWEITE: double
@ -36,3 +38,21 @@ groups:
MESSPOS_TOL: double MESSPOS_TOL: double
cfg: cfg:
picture_name: img_clp.png picture_name: img_clp.png
multicolumn_idx: [5]
# probe:
# parameter:
# PRB_BOD_RE_Y: double
# PRB_BOD_RE_Z: double
# PRB_BOD_LI_Y: double
# PRB_BOD_LI_Z: double
# PRB_SEI_HI_X: double
# PRB_SEI_HI_Y: double
# PRB_SEI_VO_X: double
# PRB_SEI_VO_Y: double
# PRB_VERS_X_X: double
# PRB_VERS_X_Y: double
# cfg:
# picture_name: img_probe.png
# multicolumn_idx: [5]

View File

@ -31,9 +31,10 @@ def generate_config_spf(folder_output, input_vars, selected_params):
for group_name, variables in input_vars.items(): for group_name, variables in input_vars.items():
for var_name, var_value in variables.items(): for var_name, var_value in variables.items():
spf_file.write(f"{var_name.upper()} = {var_value.get()}\n") spf_file.write(f"{var_name.upper()} = {var_value.get()}\n")
spf_file.write("\n")
spf_file.write("; ---------------------------------------------------\n") spf_file.write("; ---------------------------------------------------\n")
spf_file.write(f"M17\n")
# Define the file path for the text file with selected parameter sets # Define the file path for the text file with selected parameter sets
selected_params_file_path = os.path.join(folder_path, "selected_param_sets.txt") selected_params_file_path = os.path.join(folder_path, "selected_param_sets.txt")
@ -89,15 +90,15 @@ def generate_config_spf_custom1(folder_output, input_vars, selected_params, file
# Write WP_X[i] and WP_Y[i] values # Write WP_X[i] and WP_Y[i] values
cnt = 0 cnt = 0
spf_file.write(f"WP_NUM={cnt}\n")
for j in range(y_num): # Rows for j in range(y_num): # Rows
for i in range(x_num): # Columns for i in range(x_num): # Columns
if df.iloc[i, j] == 1: # Consider only marked positions if df.iloc[i, j] == 1: # Consider only marked positions
spf_file.write(f"WP_X[{cnt}]={x_offset * i}\n") spf_file.write(f"WP_X[{cnt}]={x_offset * i}\n")
spf_file.write(f"WP_Y[{cnt}]={y_offset * j}\n") spf_file.write(f"WP_Y[{cnt}]={y_offset * j}\n")
cnt += 1 cnt += 1
spf_file.write(f"WP_NUM={cnt}\n") spf_file.write("; ---------------------------------------------------\n")
spf_file.write(f"M17\n") spf_file.write(f"M17\n")
spf_file.write("\n; ---------------------------------------------------\n")
print(f"Configuration file saved at: {spf_file_path}") print(f"Configuration file saved at: {spf_file_path}")