-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from DankoCaboski/abas
Abas
- Loading branch information
Showing
17 changed files
with
610 additions
and
170 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
from openness.services.UDTService import UDTService | ||
from openness.services.Utils import Utils | ||
|
||
|
||
class RobotService: | ||
def __init__(self, tia_service) -> None: | ||
self.tia_service = tia_service | ||
self.dependencies = r"\\AXIS-SERVER\Users\Axis Server\Documents\xmls\dependence" | ||
|
||
|
||
def manege_robot(self, robots_association: dict): | ||
try: | ||
brands = list(robots_association.keys()) | ||
for robot_brand in brands: | ||
qtd = robots_association.get(robot_brand) | ||
if qtd is None or str(qtd) == '': | ||
continue | ||
qtd = int(qtd) | ||
if qtd > 1: | ||
print("qtd > 1") | ||
for i in range(qtd): | ||
self.create_robot_structure(robot_brand + "_" + str(i), robot_brand) | ||
else: | ||
self.create_robot_structure(robot_brand, robot_brand) | ||
except Exception as e: | ||
print("Error manege_robot: ", e) | ||
|
||
|
||
def create_robot_structure(self, robot_name, robot_brand): | ||
op_gp = self.tia_service.recursive_folder_search(None, "03_Blocos Operacionais") | ||
if not op_gp: | ||
op_gp = self.tia_service.create_group(None, "03_Blocos Operacionais", None) | ||
|
||
rb_gp = self.tia_service.recursive_folder_search(op_gp.Groups, "03.5_Robos") | ||
if not rb_gp: | ||
rb_gp = self.tia_service.create_group(None, "03.5_Robos", "03_Blocos Operacionais") | ||
|
||
group_name = robot_name + '_group' | ||
robot_group = self.tia_service.create_group(None, group_name, "03.5_Robos") | ||
self.import_robot_bk(robot_group, robot_brand) | ||
|
||
|
||
def import_robot_bk(self, robot_group, robot_robot_brand : str): | ||
try: | ||
robot_robot_brand = robot_robot_brand.upper() | ||
|
||
generated_block_name = Utils().get_attibutes(["Name"],robot_group) | ||
print(f'Importing {robot_robot_brand} robot block to {generated_block_name[0]}...') | ||
bk_path:str = "" | ||
if robot_robot_brand == 'ABB': | ||
bk_path = r"\\AXIS-SERVER\Users\Axis Server\Documents\xmls\03_Blocos Operacionais\robots\bk_abb.xml" | ||
elif robot_robot_brand == 'FANUC': | ||
bk_path = r"\\AXIS-SERVER\Users\Axis Server\Documents\xmls\03_Blocos Operacionais\robots\bk_fanuc.xml" | ||
|
||
udts = UDTService().list_udt_from_bk(bk_path) | ||
|
||
for udt in udts: | ||
udt_path = self.dependencies + '\\' + udt + '.xml' | ||
device = self.tia_service.get_device_by_index(0) | ||
self.tia_service.import_data_type(device, udt_path) | ||
|
||
self.tia_service.import_block(robot_group.Blocks, bk_path) | ||
|
||
except Exception as e: | ||
print("Error importing robot block: ", e) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import re | ||
|
||
class UDTService: | ||
def __init__(self) -> None: | ||
pass | ||
|
||
def list_udt_from_bk(self, bk_path): | ||
udts = [] | ||
with open(bk_path, 'r', encoding='utf-8') as file: | ||
conteudo = file.read() | ||
pattern = r'<Member[^>]+Datatype=""([^&]+)""[^>]*>' | ||
|
||
matches = re.findall(pattern, conteudo) | ||
for match in matches: | ||
udts.append(match) | ||
return udts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from CustomTkinter import customtkinter | ||
from tkinter import BooleanVar | ||
|
||
class InputConveyor: | ||
def __init__(self, frame): | ||
self.frame: customtkinter.CTkFrame = frame | ||
|
||
self.inversor = BooleanVar() | ||
self.sensor_presenca = BooleanVar() | ||
self.sensor_posicao = BooleanVar() | ||
|
||
self.main_content() | ||
|
||
|
||
def main_content(self): | ||
|
||
lb_inversor = customtkinter.CTkLabel(self.frame, text="Intversor?") | ||
lb_inversor.grid(row=0, column=0, padx=3, pady=3, sticky='ws') | ||
inversor = customtkinter.CTkCheckBox(self.frame, variable=self.inversor) | ||
inversor.grid(row=1, column=0, padx=3, pady=3, sticky='wn') | ||
|
||
lb_s_presenca = customtkinter.CTkLabel(self.frame, text="Sensor de presença?") | ||
lb_s_presenca.grid(row=0, column=1, padx=3, pady=3, sticky='ws') | ||
s_presenca = customtkinter.CTkCheckBox(self.frame, variable=self.sensor_presenca) | ||
s_presenca.grid(row=1, column=1, padx=3, pady=3, sticky='wn') | ||
|
||
lb_s_pos = customtkinter.CTkLabel(self.frame, text="Sensor de posição?") | ||
lb_s_pos.grid(row=0, column=2, padx=3, pady=3, sticky='ws') | ||
s_pos = customtkinter.CTkCheckBox(self.frame, variable=self.sensor_posicao) | ||
s_pos.grid(row=1, column=2, padx=3, pady=3, sticky='wn') |
Oops, something went wrong.