diff --git a/.gitignore b/.gitignore index 8c65d69..50897f0 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,6 @@ /__pycache__/ *ARCHIV* *BAK* -*BACKUP* \ No newline at end of file +*BACKUP* +out +cfg_inlay_PUTx.xlsx diff --git a/EXEC_MAIN.ps1 b/EXEC_MAIN.ps1 index fc207a5..2263491 100644 --- a/EXEC_MAIN.ps1 +++ b/EXEC_MAIN.ps1 @@ -7,7 +7,7 @@ $scriptPath = "./MAIN.py" $username = [System.Environment]::UserName # Construct the path to the Python executable -$pythonExe = "C:\Users\$username\AppData\Local\miniconda3\envs\$venvName\python.exe" +$pythonExe = "C:\Users\user58\.conda\envs\$venvName\python.exe" # Execute the Python script & $pythonExe $scriptPath diff --git a/MAIN.py b/MAIN.py index 1fbf5a3..eccd04e 100644 --- a/MAIN.py +++ b/MAIN.py @@ -284,12 +284,20 @@ def setup_evaluation(root, folder_pictures, data, folder_output, input_vars, sel # Function to generate configuration file based on current parameters def btn_gen(): generate_config_spf(folder_output, input_vars, selected_params) + def btn_gen_custom1(): + generate_config_spf_custom1(folder_output, input_vars, selected_params) + def btn_gen_custom2(): + generate_config_spf_custom1(folder_output, input_vars, selected_params, filetransfer=True) # Place buttons in the vertical frame for operations button_frame = ttk.Frame(frame) button_frame.grid(row=0, column=1, padx=10, pady=10, sticky="n") button1 = ttk.Button(button_frame, text="GENERATE DMUAUT_CFG.SPF FILE", width=45, command=btn_gen) 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.grid(row=1, column=0, padx=5, 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) root.grid_columnconfigure(0, weight=1) diff --git a/_condaenv.yml b/_condaenv.yml index 4cb3d4c..41b1b4a 100644 --- a/_condaenv.yml +++ b/_condaenv.yml @@ -7,4 +7,8 @@ dependencies: - pyyaml - jsonschema - tk - - pillow \ No newline at end of file + - pillow + - pandas + - openpyxl + - paramiko + - matplotlib \ No newline at end of file diff --git a/cfg_parsets/inlay.yml b/cfg_parsets/inlay.yml index 2258b1d..6cb620e 100644 --- a/cfg_parsets/inlay.yml +++ b/cfg_parsets/inlay.yml @@ -1,12 +1,12 @@ -inlay7: +'2': kos: '4' - x_num: '4' - x_offset: '30' - y_num: '3' - y_offset: '30' -inlay_kleinteil: - kos: '4' - x_num: '7' + x_num: '5' x_offset: '5' - y_num: '4' - y_offset: '4' + y_num: '5' + y_offset: '5' +inlay1: + kos: '4' + x_num: '6' + x_offset: '120' + y_num: '5' + y_offset: '250' diff --git a/cfg_parsets/jobs.yml b/cfg_parsets/jobs.yml index 4cfa5c8..1ecb1c1 100644 --- a/cfg_parsets/jobs.yml +++ b/cfg_parsets/jobs.yml @@ -1,7 +1,6 @@ job1: clp: clp1 - grp: grp1 - inlay: inlay7 + inlay: inlay1 wp_fin: wpfin1 wp_raw: wpraw1 job3: diff --git a/cfg_parsets/wp_fin.yml b/cfg_parsets/wp_fin.yml index fb8ec07..5869126 100644 --- a/cfg_parsets/wp_fin.yml +++ b/cfg_parsets/wp_fin.yml @@ -1,5 +1,6 @@ wpfin1: - l_wpfin: '8' - x_wpfin: '20' + h_grp_wpfin: '' + l_wpfin: '10' + x_wpfin: '30' y_wpfin: '10' z_wpfin: '13' diff --git a/cfg_parsets/wp_raw.yml b/cfg_parsets/wp_raw.yml index 25c1341..a14e156 100644 --- a/cfg_parsets/wp_raw.yml +++ b/cfg_parsets/wp_raw.yml @@ -3,6 +3,7 @@ test: y_wpraw: '10' z_wpraw: '20' wpraw1: - x_wpraw: '10' + h_grp_wpraw: '' + x_wpraw: '20' y_wpraw: '10' - z_wpraw: '20' + z_wpraw: '30' diff --git a/cfg_picture/Thumbs.db b/cfg_picture/Thumbs.db index b695f3f..1446612 100644 Binary files a/cfg_picture/Thumbs.db and b/cfg_picture/Thumbs.db differ diff --git a/cfg_picture/img_clp.png b/cfg_picture/img_clp.png index fd00736..ea3cd80 100644 Binary files a/cfg_picture/img_clp.png and b/cfg_picture/img_clp.png differ diff --git a/cfg_picture/img_grp.png b/cfg_picture/img_grp.png index f746530..451467d 100644 Binary files a/cfg_picture/img_grp.png and b/cfg_picture/img_grp.png differ diff --git a/cfg_picture/img_inlay.png b/cfg_picture/img_inlay.png index c33977b..213c9c1 100644 Binary files a/cfg_picture/img_inlay.png and b/cfg_picture/img_inlay.png differ diff --git a/cfg_picture/img_wpfin.png b/cfg_picture/img_wpfin.png index 2252538..ffd0bfe 100644 Binary files a/cfg_picture/img_wpfin.png and b/cfg_picture/img_wpfin.png differ diff --git a/cfg_picture/img_wpraw.png b/cfg_picture/img_wpraw.png index 8a10263..def9349 100644 Binary files a/cfg_picture/img_wpraw.png and b/cfg_picture/img_wpraw.png differ diff --git a/def.yml b/def.yml index 2d50973..1566130 100644 --- a/def.yml +++ b/def.yml @@ -17,6 +17,7 @@ groups: x_wpraw: double y_wpraw: double z_wpraw: double + h_grp_wpraw: double cfg: picture_name: img_wpraw.png wp_fin: @@ -25,20 +26,13 @@ groups: y_wpfin: double z_wpfin: double l_wpfin: double + h_grp_wpfin: double cfg: picture_name: img_wpfin.png - grp: - parameter: - hub: double - h_offset: double - h_step: double - w_offset: double - w_step: double - steps_num: int - cfg: - picture_name: img_grp.png clp: parameter: clp_offset: double + + cfg: picture_name: img_clp.png diff --git a/funct_clp.py b/funct_clp.py index dfd4a3d..c9d5930 100644 --- a/funct_clp.py +++ b/funct_clp.py @@ -81,8 +81,8 @@ def generate_picture_clp(all_group_vars, picture_path, DEBUG=False): # Add the origin sparrow (a small 3D marker at the origin) max_size3 = max(x_cube, y_cube, z_cube) * 0.3 # Scale the arrows relative to the smallest dimension - ax.quiver(x_wpraw, y_wpraw, 0, max_size3, 0, 0, color='red', linewidth=3, label='X-axis') # Red arrow for X-axis - ax.quiver(x_wpraw, y_wpraw, 0, 0, max_size3, 0, color='green', linewidth=3, label='Y-axis') # Green arrow for Y-axis + ax.quiver(x_wpraw, y_wpraw, 0, 0, max_size3, 0, color='red', linewidth=3, label='X-axis') # Red arrow for X-axis + ax.quiver(x_wpraw, y_wpraw, 0, -max_size3, 0, 0, color='green', linewidth=3, label='Y-axis') # Green arrow for Y-axis ax.quiver(x_wpraw, y_wpraw, 0, 0, 0, max_size3, color='blue', linewidth=3, label='Z-axis') # Blue arrow for Z-axis # Set viewing angle diff --git a/funct_gen.py b/funct_gen.py index 087e69c..95269c8 100644 --- a/funct_gen.py +++ b/funct_gen.py @@ -2,7 +2,10 @@ import os import time - +import pandas as pd +import paramiko +import yaml +import shutil # Function to generate the DMUAUT_CFG.SPF configuration file and save selected parameter sets def generate_config_spf(folder_output, input_vars, selected_params): @@ -42,5 +45,89 @@ def generate_config_spf(folder_output, input_vars, selected_params): print(f"Configuration files saved in {folder_path}") -# def generate_config_spf(): -# tbd + + + +def generate_config_spf_custom1(folder_output, input_vars, selected_params, filetransfer=False): + filename = "CFG_INL.SPF" + filename2 = "_N_CFG_INL_SPF" + + + # Get the current timestamp for folder name (format: YYMMDD_HHmmSS) + timestamp = time.strftime("%y%m%d_%H%M%S") + folder_path = os.path.join(folder_output, f"{timestamp}") + + # Create the folder with the timestamp + if not os.path.exists(folder_path): + os.makedirs(folder_path) + + # Define the file path for the SPF configuration file + spf_file_path = os.path.join(folder_path, filename) + xlsx_path = "cfg_inlay_PUTx.xlsx" + + # Extract grid parameters + x_num = int(input_vars['inlay']['x_num'].get()) # Number of columns + y_num = int(input_vars['inlay']['y_num'].get()) # Number of rows + x_offset = float(input_vars['inlay']['x_offset'].get()) # X offset + y_offset = float(input_vars['inlay']['y_offset'].get()) # Y offset + + # Check if Excel file exists, if not create it with 'x' values + if not os.path.exists(xlsx_path): + df = pd.DataFrame("x", index=range(x_num), columns=range(y_num)) + df.to_excel(xlsx_path, index=False, header=False) + + # Load Excel file + df = pd.read_excel(xlsx_path, header=None, dtype=str).fillna("") + df = df.reindex(range(x_num), fill_value=0).reindex(columns=range(y_num), fill_value=0) + df = df.map(lambda x: 1 if str(x).strip().lower() == "x" else 0) + + # Generate the SPF file content + with open(spf_file_path, "w") as spf_file: + spf_file.write(f"; CFG FILE FOR DMU50 AUTOMATION\n") + spf_file.write(f"; GENERATED: {timestamp}\n") + spf_file.write("; ---------------------------------------------------\n") + + # Write WP_X[i] and WP_Y[i] values + cnt = 0 + for j in range(y_num): # Rows + for i in range(x_num): # Columns + 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_Y[{cnt}]={y_offset * j}\n") + cnt += 1 + spf_file.write(f"WP_NUM={cnt}\n") + spf_file.write(f"M17\n") + spf_file.write("\n; ---------------------------------------------------\n") + + print(f"Configuration file saved at: {spf_file_path}") + + if filetransfer: + spf_file_path2 = os.path.join(folder_path, filename2) + 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: + os.startfile(folder_path) + diff --git a/funct_inlay.py b/funct_inlay.py index f9e9b73..011e9f1 100644 --- a/funct_inlay.py +++ b/funct_inlay.py @@ -45,6 +45,8 @@ def generate_picture_inlay(all_group_vars, picture_path, DEBUG=False): ax.set_ylim(0, 1) ax.set_xticks([]), ax.set_yticks([]) plt.subplots_adjust(left=0.1, right=0.9, top=0.9, bottom=0.1) # Adjusting the margins + ax.set_xlim(1, 0) # Flipping the x-axis + ax.set_ylim(1, 0) # Flipping the y-axis if DEBUG: plt.show() diff --git a/out/241016_164629/DMUAUT_CFG.SPF b/out/241016_164629/DMUAUT_CFG.SPF deleted file mode 100644 index 849ed91..0000000 --- a/out/241016_164629/DMUAUT_CFG.SPF +++ /dev/null @@ -1,29 +0,0 @@ -; CFG FILE FOR DMU50 AUTOMATION -; GENERATED: 241016_164629 -; --------------------------------------------------- -X_NUM = 8 -X_OFFSET = 5 -Y_NUM = 7 -Y_OFFSET = 4 -KOS = 4 - -; --------------------------------------------------- -X_WPRAW = 10 -Y_WPRAW = 1 -Z_WPRAW = 1 - -; --------------------------------------------------- -X_WPFIN = -Y_WPFIN = -Z_WPFIN = -L_WPFIN = - -; --------------------------------------------------- -HUB = 10 -H_OFFSET = 20 -H_STEP = 5 -W_OFFSET = 20 -W_STEP = 10 -STEPS_NUM = 6 - -; --------------------------------------------------- diff --git a/out/241016_164629/selected_param_sets.txt b/out/241016_164629/selected_param_sets.txt deleted file mode 100644 index da27e1a..0000000 --- a/out/241016_164629/selected_param_sets.txt +++ /dev/null @@ -1,5 +0,0 @@ -Selected Parameter Sets: -inlay: inlay7 -wp_raw: wpraw1 -wp_fin: <> -grp: grp1 diff --git a/out/241017_101415/DMUAUT_CFG.SPF b/out/241017_101415/DMUAUT_CFG.SPF deleted file mode 100644 index 6021115..0000000 --- a/out/241017_101415/DMUAUT_CFG.SPF +++ /dev/null @@ -1,29 +0,0 @@ -; CFG FILE FOR DMU50 AUTOMATION -; GENERATED: 241017_101415 -; --------------------------------------------------- -X_NUM = 11 -X_OFFSET = 5 -Y_NUM = 4 -Y_OFFSET = 4 -KOS = 4 - -; --------------------------------------------------- -X_WPRAW = 10 -Y_WPRAW = 10 -Z_WPRAW = 20 - -; --------------------------------------------------- -X_WPFIN = 10 -Y_WPFIN = 10 -Z_WPFIN = 20 -L_WPFIN = 10 - -; --------------------------------------------------- -HUB = 10 -H_OFFSET = 20 -H_STEP = 5 -W_OFFSET = 20 -W_STEP = 10 -STEPS_NUM = 6 - -; --------------------------------------------------- diff --git a/out/241017_101415/selected_param_sets.txt b/out/241017_101415/selected_param_sets.txt deleted file mode 100644 index 485e528..0000000 --- a/out/241017_101415/selected_param_sets.txt +++ /dev/null @@ -1,5 +0,0 @@ -Selected Parameter Sets: -inlay: inlay4 -wp_raw: wpraw1 -wp_fin: wpfin1 -grp: grp1 diff --git a/out/241017_103326/DMUAUT_CFG.SPF b/out/241017_103326/DMUAUT_CFG.SPF deleted file mode 100644 index 9148e71..0000000 --- a/out/241017_103326/DMUAUT_CFG.SPF +++ /dev/null @@ -1,29 +0,0 @@ -; CFG FILE FOR DMU50 AUTOMATION -; GENERATED: 241017_103326 -; --------------------------------------------------- -X_NUM = 7 -X_OFFSET = 5 -Y_NUM = 4 -Y_OFFSET = 4 -KOS = g54 - -; --------------------------------------------------- -X_WPRAW = 5 -Y_WPRAW = 5 -Z_WPRAW = 15 - -; --------------------------------------------------- -X_WPFIN = 10 -Y_WPFIN = 10 -Z_WPFIN = 13 -L_WPFIN = 8 - -; --------------------------------------------------- -HUB = 10 -H_OFFSET = 10 -H_STEP = 5 -W_OFFSET = 25 -W_STEP = 4 -STEPS_NUM = 6 - -; --------------------------------------------------- diff --git a/out/241017_103326/selected_param_sets.txt b/out/241017_103326/selected_param_sets.txt deleted file mode 100644 index 8868e76..0000000 --- a/out/241017_103326/selected_param_sets.txt +++ /dev/null @@ -1,5 +0,0 @@ -Selected Parameter Sets: -inlay: inlay_kleinteil -wp_raw: wpraw2 -wp_fin: wpfin1 -grp: grp1 diff --git a/out/241017_180108/DMUAUT_CFG.SPF b/out/241017_180108/DMUAUT_CFG.SPF deleted file mode 100644 index 4570c00..0000000 --- a/out/241017_180108/DMUAUT_CFG.SPF +++ /dev/null @@ -1,32 +0,0 @@ -; CFG FILE FOR DMU50 AUTOMATION -; GENERATED: 241017_180108 -; --------------------------------------------------- -X_NUM = 8 -X_OFFSET = 5 -Y_NUM = 7 -Y_OFFSET = 4 -KOS = 4 - -; --------------------------------------------------- -X_WPRAW = 10 -Y_WPRAW = 10 -Z_WPRAW = 20 - -; --------------------------------------------------- -X_WPFIN = 10 -Y_WPFIN = 10 -Z_WPFIN = 13 -L_WPFIN = 8 - -; --------------------------------------------------- -HUB = 50 -H_OFFSET = 30 -H_STEP = 10 -W_OFFSET = 40 -W_STEP = 45 -STEPS_NUM = 5 - -; --------------------------------------------------- -CLP_OFFSET = - -; --------------------------------------------------- diff --git a/out/241017_180108/selected_param_sets.txt b/out/241017_180108/selected_param_sets.txt deleted file mode 100644 index d5904ab..0000000 --- a/out/241017_180108/selected_param_sets.txt +++ /dev/null @@ -1,6 +0,0 @@ -Selected Parameter Sets: -inlay: inlay7 -wp_raw: wpraw1 -wp_fin: wpfin1 -grp: grp1 -clp: <> diff --git a/out/241017_181437/DMUAUT_CFG.SPF b/out/241017_181437/DMUAUT_CFG.SPF deleted file mode 100644 index a9244de..0000000 --- a/out/241017_181437/DMUAUT_CFG.SPF +++ /dev/null @@ -1,32 +0,0 @@ -; CFG FILE FOR DMU50 AUTOMATION -; GENERATED: 241017_181437 -; --------------------------------------------------- -X_NUM = 8 -X_OFFSET = 5 -Y_NUM = 7 -Y_OFFSET = 4 -KOS = 4 - -; --------------------------------------------------- -X_WPRAW = 5 -Y_WPRAW = 5 -Z_WPRAW = 15 - -; --------------------------------------------------- -X_WPFIN = 10 -Y_WPFIN = 10 -Z_WPFIN = 13 -L_WPFIN = 8 - -; --------------------------------------------------- -HUB = 50 -H_OFFSET = 30 -H_STEP = 10 -W_OFFSET = 40 -W_STEP = 45 -STEPS_NUM = 5 - -; --------------------------------------------------- -CLP_OFFSET = 0 - -; --------------------------------------------------- diff --git a/out/241017_181437/selected_param_sets.txt b/out/241017_181437/selected_param_sets.txt deleted file mode 100644 index dd0b10b..0000000 --- a/out/241017_181437/selected_param_sets.txt +++ /dev/null @@ -1,6 +0,0 @@ -Selected Parameter Sets: -inlay: inlay7 -wp_raw: wpraw2 -wp_fin: wpfin1 -grp: grp1 -clp: clp2 diff --git a/out/241017_184239/DMUAUT_CFG.SPF b/out/241017_184239/DMUAUT_CFG.SPF deleted file mode 100644 index a4a4465..0000000 --- a/out/241017_184239/DMUAUT_CFG.SPF +++ /dev/null @@ -1,32 +0,0 @@ -; CFG FILE FOR DMU50 AUTOMATION -; GENERATED: 241017_184239 -; --------------------------------------------------- -X_NUM = -X_OFFSET = -Y_NUM = -Y_OFFSET = -KOS = - -; --------------------------------------------------- -X_WPRAW = 10 -Y_WPRAW = 10 -Z_WPRAW = 20 - -; --------------------------------------------------- -X_WPFIN = 10 -Y_WPFIN = 10 -Z_WPFIN = 13 -L_WPFIN = 8 - -; --------------------------------------------------- -HUB = 10 -H_OFFSET = 10 -H_STEP = 5 -W_OFFSET = 25 -W_STEP = 45 -STEPS_NUM = 2 - -; --------------------------------------------------- -CLP_OFFSET = 4 - -; --------------------------------------------------- diff --git a/out/241017_184239/selected_param_sets.txt b/out/241017_184239/selected_param_sets.txt deleted file mode 100644 index 774e8ea..0000000 --- a/out/241017_184239/selected_param_sets.txt +++ /dev/null @@ -1,6 +0,0 @@ -Selected Parameter Sets: -inlay: <> -wp_raw: wpraw1 -wp_fin: wpfin1 -grp: grp3 -clp: clp1