Giter Club home page Giter Club logo

tia-openness-api-client's Introduction

tia-openness-api-client

tia-openness-api-client is a Python library used to create a client for accessing the TIA Openness API in Python. With this library, you can interact with TIA Portal and perform various tasks programmatically, such as creating and modifying project files, exporting and importing data, and much more.

TIA Openness API

The TIA Openness API is a powerful tool for automating tasks in TIA Portal, Siemens' engineering framework for automation projects. Using the API, you can develop custom software that interacts with TIA Portal, allowing you to automate repetitive tasks, streamline workflows, and improve productivity.

The API provides access to all the features of TIA Portal, including creating and modifying project files, adding and configuring devices, configuring network settings, and much more. With the TIA Openness API, you can automate complex engineering tasks and accelerate your development processes.

Usage

Here's an example of how to use tia-openness-api-client to create a new project in TIA Portal:

import tia_portal.config as tia_config
from tia_portal import Client

tia_config.load()

tia_client = Client()

tia_client.open_project("C:\\Users\\user\\Documents\\Automation", "NAME")

tia_client.project.save_as("NAME_2")

plcs = tia_client.project.get_plcs()

if len(plcs) == 0:
    print("No PLCs found in project")
elif len(plcs) > 1:
    print("Multiple PLCs found in project")
else:
    plc = plcs[0]

    software = plc.get_software()

    software_blocks = software.get_all_blocks(True)

    print("Compiling project...", end="\r")
    tia_client.project.compile()
    print("Compiling project... Done")

    for block in software_blocks:
        print(block.name, end="\r")
        try:
            block.export()
        except Exception as e:
            print(e)
            continue

input("Press Enter to continue...")

The example code above uses the tia_portal library to open a project in TIA Portal located at "C:\Users\user\Documents\Automation" with project name "NAME", saves it as a new project with name "NAME_2", and then exports all the software blocks from the project.

Please note that some lines of code have been commented out and are not being executed, and that the input() call at the end is used to keep the console window open until the user presses Enter.

Installation

To install tia-openness-api-client, you can use pip:

pip install -e .

This will install the tia_portal library as an editable package, allowing you to make changes to the source code and have them reflected in your Python environment.

This repository is developed using Python 3.11, but with some modifications, it may be possible to make it compatible with older versions of Python. However, since I cannot test the code myself due to the unavailability of TIA Portal and TIA Openness, I cannot guarantee full compatibility or provide specific instructions for adapting the code to older Python versions. If you choose to make it compatible with an older version, it is advisable to review the code carefully, resolve any potential syntax or module compatibility issues, and thoroughly test the modified code to ensure its proper functioning.

Additionally, if you are able to make the necessary changes to make this repository compatible with older versions of Python, I encourage you to contribute your modifications back to the project. By doing so, you can help other users who may be in a similar situation and ensure the codebase remains accessible and useful to a wider audience. Sharing your updates, bug fixes, or compatibility improvements with the community is a valuable contribution that can benefit the entire development community.

Contributing

If you'd like to contribute to tia-openness-api-client, please fork the repository and create a new branch for your changes. Once you've made your changes, submit a pull request and we'll review your changes.

License

tia-openness-api-client is licensed under the MIT License. See LICENSE for more information.

tia-openness-api-client's People

Contributors

repsay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

tia-openness-api-client's Issues

Documentation

Can you provide some sort of condensed down documentation as to how to do things like access, create, export, import PLCs, HMIs, and various hardware components, because it is hard to navigate any of the code?

When I try to run config.py file, I get the following error 'NoModuleFoundError'

Traceback (most recent call last):
  File "d:\Thangz\Projekte\dev\TIA openness\tia-openness-api-client-main\tia_portal\config.py", line 12, in <module>
    from tia_portal.version import TiaVersion
ModuleNotFoundError: No module named 'tia_portal'

What should I do in order to run the config.py script?

Thank you in advance

Regards,
Thangz

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.