Skip to content

Commit

Permalink
Refactor Openness.py
Browse files Browse the repository at this point in the history
  • Loading branch information
DankoCaboski committed May 29, 2024
1 parent 3206e48 commit 83968ad
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 12 deletions.
41 changes: 31 additions & 10 deletions Core/Openness.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,47 @@
import os
import shutil
import clr
from repositories import UserConfig

from System.IO import DirectoryInfo

tuple = UserConfig.getDllPath(151)
project_dll = r'' + tuple[0]
# project_dll = r'C:\Program Files\Siemens\Automation\Portal V15_1\PublicAPI\V15.1\Siemens.Engineering.dll'
clr.AddReference(project_dll)
def add_DLL(tia_Version):
try:
tuple = UserConfig.getDllPath(tia_Version)
project_dll = r'' + tuple[0]
clr.AddReference(project_dll)

global tia
global hwf
global comp

import Siemens.Engineering as tia
import Siemens.Engineering.HW.Features as hwf
import Siemens.Engineering.Compiler as comp

import os
RPA_status = 'DLL reference added successfully!'
print(RPA_status)

import Siemens.Engineering as tia
import Siemens.Engineering.HW.Features as hwf
import Siemens.Engineering.Compiler as comp
except Exception as e:
print ("Error adding DLL reference: ")
RPA_status = str(e)
print(RPA_status)

if UserConfig.CheckDll(151):
add_DLL(151)

project_dir = 'C:\\Users\\Willian\\Desktop\\tia_python'
project_dir = ""
mytia = None

RPA_status = ""

def set_project_dir(path):
global project_dir
project_dir = path.replace("/", "\\")

def create_project(project_path, project_name, hardware):

set_project_dir(project_path)

try:
project_path = DirectoryInfo (project_dir)

Expand Down
Binary file added Core/repositories/Openness.db
Binary file not shown.
2 changes: 2 additions & 0 deletions Core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
os.path.join("repositories", "UserConfig.py"),
os.path.join("repositories", "ValidateDb.py"),
os.path.join("repositories", "Openness.db"),
os.path.join("Database", "ddl.sql"),
os.path.join("Database", "mlfb", "PLC_List.csv"),
os.path.join(sys.base_prefix, 'DLLs', 'sqlite3.dll')
]
}
Expand Down
Empty file added Openness.db
Empty file.
4 changes: 2 additions & 2 deletions build.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import subprocess
import os
from Core.repositories.ValidateDb import create_db
from Core.repositories.ValidateDb import validate_db

current_path = os.path.abspath(__file__)
core_path = os.path.join(os.path.dirname(current_path), "Core")
Expand All @@ -19,7 +19,7 @@ def uninstall_dependencies():
subprocess.call(["pip", "uninstall", "-r", requirements_file])

def build():
create_db()
validate_db()
global core_path
os.chdir(core_path)
setup_file = os.path.join(core_path, "setup.py")
Expand Down

0 comments on commit 83968ad

Please sign in to comment.