6/13/2019 8:51 PM | |
Joined: 5/30/2013 Last visit: 10/31/2024 Posts: 50 Rating: (23) |
In case someone would be interested to try openness with python (using pythonnet) I wrote a basic example on github: https://github.com/Maroder1/TIA-openness Update 20.01.2020: Created a repo with more functionality demonstrated (compile, export/import networking) https://github.com/Maroder1/Openness_examples_python Recommandation: develop using Jupyter notebook |
Last edited by: JK_NO at: 01/23/2020 13:22:19Last edited by: JK_NO at: 01/23/2020 13:22:37 |
|
This contribution was helpful to10 thankful Users |
6/14/2019 11:40 PM | |
Posts: 111 Rating: (31) |
ATT: JK_NO Your suggestion and demo that builds on PythonNet works very well. I have followed your suggestion with installing the run environment that uses MiniConda. Also a brilliant suggestion. Some small changes to the code example is added in the attachment. Changes are:
Do you known how an object can be attached to the TIA project that is already open? OpennessScripter names this method "Connect Portal {filename}". Other issue is for error handling. Can TRY be used in Python to open the project?
Attachmentopenness-001.py.txt (1005 Downloads) |
Last edited by: AutoGen_1801304 at: 06/15/2019 00:54:08Last edited by: AutoGen_1801304 at: 06/15/2019 00:55:00 |
|
6/15/2019 8:09 PM | |
Joined: 5/30/2013 Last visit: 10/31/2024 Posts: 50 Rating: (23) |
Jupyter will unfortiuantly not help you any further with information about the actual .dll as it is a generic editor, commonly used especally within data science/ML/AI. The thing is that it is interactive, meaning that you code in different cells(of your own choice), and then run them one at the time. Example: Cell 1: Do all imports Cell 2: Start TIA Cell 3: Create project Cell 4: Add HW Cell 5 Set IP Lets say you are trying to figure out how to set ip address when programming in a normal editor, then you would have to run the entire script each time you would like to verify your IP adress implementation. As you know: this takes a lot of time, and when trying to figure out openness you will need many attemps for such. This is where the magic of jupyter comes: back to the lists of cells above: you run them in order, and when you come to cell 5: in case it fails, you can just rewrite it and run it again, without the need of rerunning cell 1-4. Maybe better illustrated in the following gif: http://www.ccri.com/wp-content/uploads/2016/06/JupyterAnimated.gif Note about the gif: instead of cikcing the run icon all the time, just press shift+enter. Not sure if above was understandable? Thing is that it is perfect for openness since you will spend alot of time working on a "single line" of code to make it work wihtout needing to run everything that allready works again and again. As for understading the API. You allready have the answers: - Openness helper - Documentation/help file - Also look at the provided examples ( I just open the .cs file in notepad++ and search for what I need to get a clue) - Most timportantly: try try try and try, with jupyter it is extreeemly quick: Eventually you will figure it out. And the more you figure our the easier it will become as you start to figure out the API. |
Last edited by: JK_NO at: 06/15/2019 20:14:08 |
|
6/17/2019 10:19 AM | |
Posts: 111 Rating: (31) |
About having Openness API autocomplete for Python in vscode A Github project called "ironpython-stubs" shows hope to create additional autocomplete phrases for Intellisense. The module is executed under IronPython to generate multiple Python shell programs. These represent the DLL for the Openness API. "ironpython-stubs" does function. But too many C# structures are skipped over. For example the whole "Siemens.Engineering.TiaPortal" branch is not there. But "Siemens.Engineering.HW" branch is there. About executing code in Jupyter This is very helpful as you stated. The attached Python file was exported for a Jupyter session. The program can decide to activate a project: The "Siemens.Engineering.TiaPortal.Projects[0]" element in the array was the biggest breakthrough. I wish OpennessScripter could detect how to open a project like this Python script does. Attachment001-starter.py.txt (1002 Downloads) |
Last edited by: AutoGen_1801304 at: 06/17/2019 10:21:11 |
|
This contribution was helpful to1 thankful Users |
Follow us on