This commit is contained in:
Eduard Gerlitz 2025-03-18 16:23:31 +01:00
parent 044f9c1bc4
commit 0dd8a929f5
11 changed files with 112 additions and 173 deletions

View File

@ -1,4 +1,11 @@
# CHANGELOG # CHANGELOG
v2.1.1
- Installer und Run Skripte als BAT (ehemals als PS1)
- Bugfix funct_gen: WP_NUM
- Add Button GEN+TRANSFER CFG_DMUAUT.SPF
- Anpassen funct_probe Positionen
v2.1 v2.1
- Add funct_probe - Add funct_probe
- abhängig von WP- und CLP-Werten - abhängig von WP- und CLP-Werten

12
EXEC_INSTALL.bat Normal file
View File

@ -0,0 +1,12 @@
@echo off
setlocal
:: ---------- USER DEFINE --------------
set "ymlPath=condaenv.yml"
:: -------------------------------------
:: Execute the Python script
conda env create -f "%ymlPath%"
:: Pause at the end of the script
pause

View File

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

14
EXEC_MAIN.bat Normal file
View File

@ -0,0 +1,14 @@
@echo off
setlocal
:: ---------- USER DEFINE --------------
set "venvName=dmu50_wingui"
set "scriptPath=MAIN.py"
:: -------------------------------------
:: Activate the Conda environment and execute the Python script
call conda activate %venvName%
python "%scriptPath%"
:: Pause at the end of the script
pause

View File

@ -1,10 +0,0 @@
#---------- USER DEFINE --------------
$venvName = "dmu50_wingui"
$scriptPath = "./MAIN.py"
#-------------------------------------
# Activate the Conda environment and execute the Python script
cmd.exe /c "conda activate $venvName && python $scriptPath"
# Pause at the end of the script
# Read-Host -Prompt "Press Enter to exit"

28
MAIN.py
View File

@ -2,7 +2,6 @@
from functions import * from functions import *
from funct_inlay import * from funct_inlay import *
from funct_wp import * from funct_wp import *
from funct_grp import *
from funct_clp import * from funct_clp import *
from funct_gen import * from funct_gen import *
from funct_probe import * from funct_probe import *
@ -278,22 +277,27 @@ def setup_evaluation(root, folder_pictures, data, folder_output, input_vars, sel
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)
# Function to generate configuration file based on current parameters # Function to generate configuration file based on current parameters
def btn_gen(): def btn_gen_cfg_dmuaut1():
generate_config_spf(folder_output, input_vars, selected_params) gen_cfg_dmuaut(folder_output, input_vars, selected_params)
def btn_gen_custom1(): def btn_gen_cfg_dmuaut2():
generate_config_spf_custom1(folder_output, input_vars, selected_params) gen_cfg_dmuaut(folder_output, input_vars, selected_params, filetransfer=True)
def btn_gen_custom2(): def btn_gen_cfg_inlay1():
generate_config_spf_custom1(folder_output, input_vars, selected_params, filetransfer=True) gen_cfg_inlay(folder_output, input_vars, selected_params)
def btn_gen_cfg_inlay2():
gen_cfg_inlay(folder_output, input_vars, selected_params, filetransfer=True)
# Place buttons in the vertical frame for operations # Place buttons in the vertical frame for operations
button_frame = ttk.Frame(frame) button_frame = ttk.Frame(frame)
button_frame.grid(row=0, column=1, padx=10, pady=10, sticky="n") button_frame.grid(row=0, column=1, padx=10, pady=10, sticky="n")
button1 = ttk.Button(button_frame, text="GEN CFG_DMUAUT.SPF FILE", width=45, command=btn_gen) button1 = ttk.Button(button_frame, text="GEN CFG_DMUAUT.SPF FILE", width=45, command=btn_gen_cfg_dmuaut1)
button1.grid(row=0, column=0, padx=10, pady=5) button1.grid(row=0, column=0, padx=10, pady=5)
button2 = ttk.Button(button_frame, text="GEN CFG_INLAY.SPF FILE", width=45, command=btn_gen_custom1) button2 = ttk.Button(button_frame, text="GEN+TRANSFER CFG_DMUAUT.SPF FILE", width=45, command=btn_gen_cfg_dmuaut2)
button2.grid(row=1, column=0, padx=5, pady=5) button2.grid(row=0, column=1, padx=10, pady=5)
button3 = ttk.Button(button_frame, text="GEN+TRANSFER CFG_INLAY.SPF FILE", width=45, command=btn_gen_custom2)
button3.grid(row=1, column=1, padx=5, pady=5) button3 = ttk.Button(button_frame, text="GEN CFG_INLAY.SPF FILE", width=45, command=btn_gen_cfg_inlay1)
button3.grid(row=1, column=0, padx=5, pady=5)
button4 = ttk.Button(button_frame, text="GEN+TRANSFER CFG_INLAY.SPF FILE", width=45, command=btn_gen_cfg_inlay2)
button4.grid(row=1, column=1, padx=5, pady=5)
root.grid_columnconfigure(0, weight=1) root.grid_columnconfigure(0, weight=1)

View File

@ -8,6 +8,7 @@ Diese GUI dient zur Erfassung verschiedener Parameter für die Maschinenautomati
- **Inlay** - **Inlay**
- **Werkstück Roh- und Fertigmaße (WP Raw & Finish)** - **Werkstück Roh- und Fertigmaße (WP Raw & Finish)**
- **Schraubstock** - **Schraubstock**
- **Antasten Werkstück**
- Verwaltung von Parameter-Sets und Jobs - Verwaltung von Parameter-Sets und Jobs
- Erstellung einer ausführbaren G-Code-Datei mit allen erfassten Parametern - Erstellung einer ausführbaren G-Code-Datei mit allen erfassten Parametern
- Möglichkeit zur direkten Übertragung der G-Code-Datei auf die Steuerung - Möglichkeit zur direkten Übertragung der G-Code-Datei auf die Steuerung

16
def.yml
View File

@ -41,16 +41,16 @@ groups:
multicolumn_idx: [5] multicolumn_idx: [5]
probe: probe:
parameter: parameter:
PRB_BOD_RE_X: double # Z PRB_BOD_RE_X: double
PRB_BOD_RE_Y: double PRB_BOD_RE_Y: double
PRB_BOD_LI_X: double # Z PRB_BOD_LI_X: double
PRB_BOD_LI_Y: double PRB_BOD_LI_Y: double
PRB_SEI_HI_Y: double PRB_SEI_HI_X: double
PRB_SEI_HI_Z: double # X PRB_SEI_HI_Z: double
PRB_SEI_VO_Y: double PRB_SEI_VO_X: double
PRB_SEI_VO_Z: double # X PRB_SEI_VO_Z: double
PRB_VERS_Y_X: double PRB_VERS_X_Y: double
PRB_VERS_Y_Z: double PRB_VERS_X_Z: double
cfg: cfg:
picture_name: img_probe.png picture_name: img_probe.png
multicolumn_idx: [5] multicolumn_idx: [5]

View File

@ -9,7 +9,9 @@ import shutil
# Function to generate the CFG_DMUAUT.SPF configuration file and save selected parameter sets # Function to generate the CFG_DMUAUT.SPF configuration file and save selected parameter sets
def generate_config_spf(folder_output, input_vars, selected_params): def gen_cfg_dmuaut(folder_output, input_vars, selected_params, filetransfer=False):
filename = "CFG_DMUAUT.SPF"
# Get the current timestamp for folder name (format: YYMMDD_HHmmSS) # Get the current timestamp for folder name (format: YYMMDD_HHmmSS)
timestamp = time.strftime("%y%m%d_%H%M%S") timestamp = time.strftime("%y%m%d_%H%M%S")
folder_path = os.path.join(folder_output, f"{timestamp}") folder_path = os.path.join(folder_output, f"{timestamp}")
@ -19,7 +21,7 @@ def generate_config_spf(folder_output, input_vars, selected_params):
os.makedirs(folder_path) os.makedirs(folder_path)
# Define the file path for the SPF configuration file # Define the file path for the SPF configuration file
spf_file_path = os.path.join(folder_path, "CFG_DMUAUT.SPF") spf_file_path = os.path.join(folder_path, filename)
# Generate the SPF file content # Generate the SPF file content
with open(spf_file_path, "w") as spf_file: with open(spf_file_path, "w") as spf_file:
@ -47,12 +49,15 @@ def generate_config_spf(folder_output, input_vars, selected_params):
print(f"Configuration files saved in {folder_path}") print(f"Configuration files saved in {folder_path}")
os.startfile(folder_path) if filetransfer:
_transfer_to_sinumerik(filename, folder_path)
else:
os.startfile(folder_path)
def generate_config_spf_custom1(folder_output, input_vars, selected_params, filetransfer=False):
def gen_cfg_inlay(folder_output, input_vars, selected_params, filetransfer=False):
filename = "CFG_INL.SPF" filename = "CFG_INL.SPF"
filename2 = "_N_CFG_INL_SPF"
# Get the current timestamp for folder name (format: YYMMDD_HHmmSS) # Get the current timestamp for folder name (format: YYMMDD_HHmmSS)
timestamp = time.strftime("%y%m%d_%H%M%S") timestamp = time.strftime("%y%m%d_%H%M%S")
@ -90,44 +95,47 @@ 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("; ---------------------------------------------------\n")
spf_file.write(f"M17\n") spf_file.write(f"M17\n")
print(f"Configuration file saved at: {spf_file_path}") print(f"Configuration file saved at: {spf_file_path}")
if filetransfer: if filetransfer:
spf_file_path2 = os.path.join(folder_path, filename2) _transfer_to_sinumerik(filename, folder_path)
shutil.copyfile(spf_file_path, spf_file_path2)
# try:
# Transfer to Sinumerik
url2 = "192.168.214.1"
ssh_username = "manufact"
ssh_password = "SUNRISE"
upload_folder_nc = "/nckfs/_N_MPF_DIR/_N_AUTO_ROB_DIR"
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(url2, username=ssh_username, password=ssh_password)
sftp = ssh.open_sftp()
sftp.chdir(upload_folder_nc)
if filename2 in sftp.listdir():
sftp.remove(filename2)
sftp.put(spf_file_path2, filename2)
sftp.close()
ssh.close()
os.remove(spf_file_path2)
print(f"------->>>> FILE TRANSFERED TO SINUMERIK ------->>>> ")
# except Exception as e:
# print(f"ERROR IN FILETRANSFER {e}")
else: else:
os.startfile(folder_path) os.startfile(folder_path)
def _transfer_to_sinumerik(filename, folder_path):
filename2 = f"_N_{filename.replace('.', '_')}"
spf_file_path = os.path.join(folder_path, filename)
spf_file_path2 = os.path.join(folder_path, filename2)
shutil.copyfile(spf_file_path, spf_file_path2)
# Transfer to Sinumerik
url2 = "192.168.214.1"
ssh_username = "manufact"
ssh_password = "SUNRISE"
upload_folder_nc = "/nckfs/_N_MPF_DIR/_N_AUTO_ROB_DIR"
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(url2, username=ssh_username, password=ssh_password)
sftp = ssh.open_sftp()
sftp.chdir(upload_folder_nc)
if filename2 in sftp.listdir():
sftp.remove(filename2)
sftp.put(spf_file_path2, filename2)
sftp.close()
ssh.close()
os.remove(spf_file_path2)
print(f"------->>>> {filename} TRANSFERED TO SINUMERIK ------->>>> ")

View File

@ -1,88 +0,0 @@
import matplotlib.pyplot as plt
import numpy as np
def generate_picture_grp(all_group_vars, picture_path, DEBUG=False):
try:
# Extract variables for the gripper
vars = all_group_vars['grp']
h_offset = float(vars['h_offset'])
h_step = float(vars['h_step'])
w_offset = float(vars['w_offset'])
w_step = float(vars['w_step'])
steps_num = int(vars['steps_num'])
# ERROR HANDLING
if h_step <= 0 or w_step <= 0 or steps_num <= 0:
raise ValueError("h_step, w_step, and steps_num must be positive values.")
# Initialize figure
fig, ax = plt.subplots(figsize=(6, 6)) # Square figure
ax.set_aspect('equal')
# Draw the gripper finger
def draw_gripper(x_sign=1):
max_width = x_sign * (w_offset + w_step * (steps_num - 1))
current_height = h_offset
current_width = x_sign * w_offset
# Draw the first block
rect = plt.Rectangle((x_sign, 0), max_width - x_sign, h_offset, facecolor='black', linewidth=0)
ax.add_patch(rect)
# Draw the steps
for _ in range(steps_num):
rect = plt.Rectangle((current_width, current_height), max_width - current_width, h_step, facecolor='black', linewidth=0)
ax.add_patch(rect)
current_height += h_step
current_width += x_sign * w_step
# Draw original gripper finger and x flipped
draw_gripper()
draw_gripper(x_sign=-1)
# Plot the origin point at (0, 0)
ax.plot(0, 0, marker='o', markersize=10, color='red') # Red point at origin
# Flip the y-axis (invert it)
ax.invert_yaxis()
# Set equal aspect ratio to make grid cells look square
ax.set_aspect('equal')
# Hide major ticks and labels (only gridlines should be visible)
ax.set_xticks([])
ax.set_yticks([])
# Add a white border around the plot to ensure the outer gridlines are visible
fig.patch.set_facecolor('white')
plt.subplots_adjust(left=0.05, right=0.95, top=0.95, bottom=0.05) # Adjust padding for the white border
if not DEBUG:
# Save the figure to the specified picture path
plt.gca().set_aspect('equal', adjustable='box')
fig.savefig(picture_path, bbox_inches='tight', pad_inches=0.1, dpi=300, transparent=True)
else:
plt.show()
# Close the figure to free memory
plt.close()
except ValueError as ve:
# Handle value error (e.g., invalid input)
print(f"Invalid Input: Error: {ve}")
except Exception as e:
# Catch any other exceptions and show a generic error message
print(f"An error occurred while generating the gripper finger: {e}")
if __name__ == "__main__":
vars = {
'h_offset': 10,
'h_step': 5,
'w_offset': 20,
'w_step': 10,
'steps_num': 5
}
picture_path = "cfg_picture/TEST_gripper_finger.jpg"
generate_picture_grp(vars, picture_path, DEBUG=True)

View File

@ -5,12 +5,12 @@ from functions import *
def generate_picture_probe(all_group_vars, picture_path, DEBUG=False): def generate_picture_probe(all_group_vars, picture_path, DEBUG=False):
(PRB_BOD_RE_Y, PRB_BOD_RE_X, PRB_BOD_LI_Y, PRB_BOD_LI_X, (PRB_BOD_RE_Y, PRB_BOD_RE_X, PRB_BOD_LI_Y, PRB_BOD_LI_X,
PRB_SEI_HI_Z, PRB_SEI_HI_Y, PRB_SEI_VO_Z, PRB_SEI_VO_Y, PRB_SEI_HI_Z, PRB_SEI_HI_X, PRB_SEI_VO_Z, PRB_SEI_VO_X,
PRB_VERS_Y_X, PRB_VERS_Y_Z) = \ PRB_VERS_X_Y, PRB_VERS_X_Z) = \
(float(all_group_vars['probe'][k]) for k in [ (float(all_group_vars['probe'][k]) for k in [
'PRB_BOD_RE_Y', 'PRB_BOD_RE_X', 'PRB_BOD_LI_Y', 'PRB_BOD_LI_X', 'PRB_BOD_RE_Y', 'PRB_BOD_RE_X', 'PRB_BOD_LI_Y', 'PRB_BOD_LI_X',
'PRB_SEI_HI_Z', 'PRB_SEI_HI_Y', 'PRB_SEI_VO_Z', 'PRB_SEI_VO_Y', 'PRB_SEI_HI_Z', 'PRB_SEI_HI_X', 'PRB_SEI_VO_Z', 'PRB_SEI_VO_X',
'PRB_VERS_Y_X', 'PRB_VERS_Y_Z']) 'PRB_VERS_X_Y', 'PRB_VERS_X_Z'])
try: try:
CLP_BACKENWEITE, CLP_BACKENHOHE, CLP_SPANNHOHE, CLP_AUFLAGETIEFE = ( CLP_BACKENWEITE, CLP_BACKENHOHE, CLP_SPANNHOHE, CLP_AUFLAGETIEFE = (
@ -112,15 +112,15 @@ def generate_picture_probe(all_group_vars, picture_path, DEBUG=False):
#SEITE #SEITE
seiten_colr = "green" seiten_colr = "green"
drawball(x_cube, WPR_Y+PRB_SEI_HI_Y, PRB_SEI_HI_Z, seiten_colr, 0.03) drawball(WPR_X+PRB_SEI_HI_X, y_cube, PRB_SEI_HI_Z, seiten_colr, 0.03)
ax.text( x_cube, WPR_Y+PRB_SEI_HI_Y, PRB_SEI_HI_Z+txt_offs, f'PRB_SEI_HI', color=seiten_colr, fontsize=7, weight='bold', ha='center', va='bottom') ax.text(WPR_X+PRB_SEI_HI_X, y_cube, PRB_SEI_HI_Z+txt_offs, f'PRB_SEI_HI', color=seiten_colr, fontsize=7, weight='bold', ha='center', va='bottom')
drawball(0, WPR_Y+PRB_SEI_VO_Y, PRB_SEI_VO_Z, seiten_colr, 0.03) drawball(WPR_X+PRB_SEI_VO_X, 0, PRB_SEI_VO_Z, seiten_colr, 0.03)
ax.text(0, WPR_Y+PRB_SEI_VO_Y, PRB_SEI_VO_Z+txt_offs, f'PRB_SEI_VO', color=seiten_colr, fontsize=7, weight='bold', ha='center', va='bottom') ax.text(WPR_X+PRB_SEI_VO_X, 0, PRB_SEI_VO_Z+txt_offs, f'PRB_SEI_VO', color=seiten_colr, fontsize=7, weight='bold', ha='center', va='bottom')
#VERSATZ Y #VERSATZ Y
vers_colr = "blue" vers_colr = "blue"
drawball(WPR_X+PRB_VERS_Y_X, 0, PRB_VERS_Y_Z, vers_colr, 0.03) drawball(0, WPR_Y+PRB_VERS_X_Y, PRB_VERS_X_Z, vers_colr, 0.03)
ax.text( WPR_X+PRB_VERS_Y_X, 0-txt_offs, PRB_VERS_Y_Z, f'PRB_SEI_HI', color=vers_colr, fontsize=7, weight='bold', ha='left', va='bottom') ax.text( 0-txt_offs, WPR_Y+PRB_VERS_X_Y, PRB_VERS_X_Z, f'PRB_SEI_HI', color=vers_colr, fontsize=7, weight='bold', ha='left', va='bottom')
# Set view properties # Set view properties
@ -153,11 +153,11 @@ if __name__ == "__main__":
'PRB_BOD_RE_X': 0, 'PRB_BOD_RE_X': 0,
'PRB_BOD_LI_Y': 0, 'PRB_BOD_LI_Y': 0,
'PRB_BOD_LI_X': 0, 'PRB_BOD_LI_X': 0,
'PRB_SEI_HI_Y': 0, 'PRB_SEI_HI_X': 0,
'PRB_SEI_HI_Z': 0, 'PRB_SEI_HI_Z': 0,
'PRB_SEI_VO_Y': 0, 'PRB_SEI_VO_X': 0,
'PRB_SEI_VO_Z': 0, 'PRB_SEI_VO_Z': 0,
'PRB_VERS_Y_X': 5.0, 'PRB_VERS_X_Y': 5.0,
'PRB_VERS_Y_Z': 2.5 'PRB_VERS_X_Z': 2.5
} }
generate_picture_probe({'probe': all_group_vars}, "cfg_picture/TEST_wpraw.jpg", DEBUG=True) generate_picture_probe({'probe': all_group_vars}, "cfg_picture/TEST_wpraw.jpg", DEBUG=True)