TIA Portal Openness: Introduction And Demo Application

Transcription

TIA Portal Openness:Introduction andDemo ApplicationTIA Portal /view/108716692SiemensIndustryOnlineSupport

Legal informationLegal informationUse of application examplesApplication examples illustrate the solution of automation tasks through an interaction of severalcomponents in the form of text, graphics and/or software modules. The application examples area free service by Siemens AG and/or a subsidiary of Siemens AG (“Siemens”). They are nonbinding and make no claim to completeness or functionality regarding configuration andequipment. The application examples merely offer help with typical tasks; they do not constitutecustomer-specific solutions. You yourself are responsible for the proper and safe operation of theproducts in accordance with applicable regulations and must also check the function of therespective application example and customize it for your system.Siemens grants you the non-exclusive, non-sublicensable and non-transferable right to have theapplication examples used by technically trained personnel. Any change to the applicationexamples is your responsibility. Sharing the application examples with third parties or copying theapplication examples or excerpts thereof is permitted only in combination with your own products.The application examples are not required to undergo the customary tests and quality inspectionsof a chargeable product; they may have functional and performance defects as well as errors. It isyour responsibility to use them in such a manner that any malfunctions that may occur do notresult in property damage or injury to persons. Siemens AG 2019 All rights reservedDisclaimer of liabilitySiemens shall not assume any liability, for any legal reason whatsoever, including, withoutlimitation, liability for the usability, availability, completeness and freedom from defects of theapplication examples as well as for related information, configuration and performance data andany damage caused thereby. This shall not apply in cases of mandatory liability, for exampleunder the German Product Liability Act, or in cases of intent, gross negligence, or culpable loss oflife, bodily injury or damage to health, non-compliance with a guarantee, fraudulentnon-disclosure of a defect, or culpable breach of material contractual obligations. Claims fordamages arising from a breach of material contractual obligations shall however be limited to theforeseeable damage typical of the type of agreement, unless liability arises from intent or grossnegligence or is based on loss of life, bodily injury or damage to health. The foregoing provisionsdo not imply any change in the burden of proof to your detriment. You shall indemnify Siemensagainst existing or future claims of third parties in this connection except where Siemens ismandatorily liable.By using the application examples you acknowledge that Siemens cannot be held liable for anydamage beyond the liability provisions described.Other informationSiemens reserves the right to make changes to the application examples at any time withoutnotice. In case of discrepancies between the suggestions in the application examples and otherSiemens publications such as catalogs, the content of the other documentation shall haveprecedence.The Siemens terms of use (https://support.industry.siemens.com) shall also apply.Security informationSiemens provides products and solutions with industrial security functions that support the secureoperation of plants, systems, machines and networks.In order to protect plants, systems, machines and networks against cyber threats, it is necessaryto implement – and continuously maintain – a holistic, state-of-the-art industrial security concept.Siemens’ products and solutions constitute one element of such a concept.Customers are responsible for preventing unauthorized access to their plants, systems, machinesand networks. Such systems, machines and components should only be connected to anenterprise network or the Internet if and to the extent such a connection is necessary and onlywhen appropriate security measures (e.g. firewalls and/or network segmentation) are in place.For additional information on industrial security measures that may be implemented, please emens’ products and solutions undergo continuous development to make them more secure.Siemens strongly recommends that product updates are applied as soon as they are availableand that the latest product versions are used. Use of product versions that are no longersupported, and failure to apply the latest updates may increase customer’s exposure to cyberthreats.To stay informed about product updates, subscribe to the Siemens Industrial Security RSS Feedat: https://www.siemens.com/industrialsecurity.TIA Portal OpennessEntry ID: 108716692,V1.4,05/20192

Table of ContentsTable of ContentsLegal information . 21Task . 42Solution. 52.12.22.2.12.2.23Mode of Operation . 73.13.1.13.1.23.23.34 Siemens AG 2019 All rights reservedTIA Portal V15.1 . 10Managing user rights . 10Creating a project . 12Configuration file/AssemblyResolve . 13Permitting access . 13StartOpenness . 145.15.25.35.45.56TIA Portal Openness . 7Range of functions . 7Restrictions . 9"StartOpenness" application example . 9"DemoOpenness" application example . 9Creating a New TIA Portal Openness Application . 104.14.24.34.44.55Overview. 5Hardware and software components . 5Validity . 5Components used . 5Overview. 14"TIA Portal" group . 16"Project" group . 17"Add" group . 18"Compile" group . 19TIA Openness Demo . eneral . 20Application examples . 20Methods . 21Description of the application . 22General settings . 22Flexible AssemblyResolve . 23TIA Portal functions . 23Project functions . 25Importing/exporting objects . 28Libraries . 30PLC. 317Related literature . 348History. 34TIA Portal OpennessEntry ID: 108716692,V1.4,05/20193

1 Task1TaskIntroductionIn STEP 7 or WinCC V15.1 TIA Portal Openness is included in the delivery ofSTEP 7 or WinCC in TIA Portal. This enables you to program the applicationswhich automate the engineering in TIA Portal.Overview of the automation task Siemens AG 2019 All rights reservedFigure 1-1Public APIOwnprogramImport/ExportScenarios Based on a text database, project texts are to be complied program-controlledautomatically and applied in the TIA Portal project. This way, you can quicklyuse standardized texts in new projects. The visualization is to be created automatically with the help of exported PLCdata. Project statistics or backups can be created automatically. With the help ofyour program you can check whether programming guidelines were met. Projects can be automatically compared with global libraries and if required,updated and compiled. The offline project can be automatically compared with the online projects inorder to ensure plant consistency. With the help of a tool the entire project is to be created based on prefabricatedproject parts.TIA Portal OpennessEntry ID: 108716692,V1.4,05/20194

2 Solution2Solution2.1OverviewAdvantagesThe solution presented here, offers you the following advantages More efficiency by executing the task faster Accuracy by automating constant processes Short commissioning times through configuration setup Competitiveness by targeted use of resourcesDelimitation Siemens AG 2019 All rights reservedThis application does not contain a description of: Basics on object-oriented programming Basics on programming environment, such as e.g. Microsoft Visual Studio Basics on TIA Portal configurationBasic knowledge of these topics is assumed.2.2Hardware and software components2.2.1ValidityThis application is valid for 2.2.2STEP 7 / WinCC TIA Portal V15.1Components usedThe application was created with the following components:Software componentsTable 2-1ComponentNo.Article numberSTEP 7 ProfessionalV15.116ES7822-1AA05-0YA5WinCC V15.116AV2102-0AA05-0AA5TIA Portal Openness1Microsoft VisualStudio 20151TIA Portal OpennessEntry ID: 108716692,V1.4,05/2019NoteIncluded in the delivery of STEP7 or WinCC V15.15

2 SolutionExample files and projectsThe following list includes all files and projects that are used in this example.Table 2-2ComponentNoteDemo application for the use of TIAPortal Openness (see chapter 6)108716692 StartOpenness V15 1.zipIntroductory example for the use of TIAPortal Openness (see chapter 5)108716692 TIA Openness GettingStartedAndDemo V15 1 en.pdfThis document. Siemens AG 2019 All rights reserved108716692 TiaPortalOpennessDemo V15 1.zipTIA Portal OpennessEntry ID: 108716692,V1.4,05/20196

3 Mode of Operation3Mode of Operation3.1TIA Portal OpennessIn STEP 7 or WinCC V15.1 TIA Portal Openness is available for free on therespective product DVDs. Prerequisite for the use is an installation of STEP 7 orWinCC V15.1.TIA Portal Openness provides DLLs via which you can access the TIA Portalplatform. These DLLs are based on .NET Framework 4.6.1.3.1.1Range of functionsTable 3-1 Siemens AG 2019 All rights reservedDeviceFunctionseeThroughoutthe projectOpening TIA PortalP. 23Throughoutthe projectClosing/separating TIAPortalP. 24Throughoutthe projectConnecting TIA PortalprocessP. 23Throughoutthe projectOpening projectP. 25Throughoutthe projectSaving projectP. 25Throughoutthe projectClosing projectP. 25Throughoutthe projectNumerating devices andsubnetsP. 26Throughoutthe projectOpening network andtopology editorP. 26Throughoutthe projectCreating folderP. 27Throughoutthe projectDeleting elementsP. 28Throughoutthe projectExporting/importing projectgraphicsP. 28LibrariesOpening global libraryP. 30LibrariesClosing global libraryP. 30LibrariesTypes: Update check ofinstancesP. 31HMICompiling hardware and/orsoftwareP. 28HMIExporting screen as XMLP. 28HMIImporting screens fromXMLP. 28HMIExporting of the screenP. 28TIA Portal OpennessEntry ID: onsRestrictions: TIA PortalOpenness help chap. 8.3.7.1Overview of exportable screenobjectsException: Pop-up and slide-in7

3 Mode of OperationDeviceFunctionsee Siemens AG 2019 All rights reservedmanagement as ing elements of thescreen management fromXMLP. 28HMIExporting tags/tag tables asXMLP. 28HMIImporting tags/tag tablesfrom XMLP. 28HMIExporting connections asXMLP. 28Non-integrated connectionsHMIImporting connections fromXMLP. 28Non-integrated connectionsHMIExporting scripts as XMLP. 28HMIImporting scripts from XMLP. 28HMIExporting cycles as XMLP. 28HMIImporting cycles from XMLP. 28HMIExporting text and graphiclists as XMLP. 28HMIImporting text and graphiclists from XMLP. 28PLCCompiling hardware and/orsoftwareP. 28PLCConnecting/separatingcontroller onlineP. 31PLCOnline/offline comparisonP. 32PLCOffline/offline comparisonP. 32PLCDisplaying blocks in theeditorP. 26PLCExporting blocks as XMLP. 28PLCImporting blocks from XMLP. 28PLCImporting external sourcesP. 32PLCGenerating blocks fromsources.P. 33PLCGenerating sources fromblocksP. 33PLCDisplaying tag tables anddata types in the editorP. 26PLCExporting tag tables anddata types as XMLP. 28PLCExporting tag tables anddata types as XMLP. 28PLCExporting individual tagsP. 28TIA Portal OpennessEntry ID: 108716692,V1.4,05/2019Exception: Pop-up and slide-inwindowsOnly with enabler fileSTL and SCL blocks8

3 Mode of Operation3.1.23.2Restrictions With TIA Portal Openness V15.1 you can only access projects and librarieswith version V15.1. If required, upgrade your project or your library beforeusing TIA Portal Openness. Compatibility between the TIA Portal Openness versions cannot beguaranteed. A new version may require changes in your program."StartOpenness" application exampleThe "StartOpenness" program is to facilitate access to programming your firstindependent Openness application.Some basic functions are already programmed in the program (e.g. starting TIAPortal) so that you can develop your own applications, based on this. Siemens AG 2019 All rights reserved3.3"DemoOpenness" application exampleThe "Demo Openness" program includes many fully programmed functions of TIAPortal Openness. This is to give you a function overview as well as detailedprogramming help.TIA Portal OpennessEntry ID: 108716692,V1.4,05/20199

4 Creating a New TIA Portal Openness Application4Creating a New TIA Portal OpennessApplication4.1TIA Portal V15.1Install TIA Portal V15.1.NOTE4.2TIA Portal Openness is included in the delivery of STEP 7 V15.1 or WinCCV15.1 and is installed by default.Managing user rightsIn order to use or create a TIA Portal Openness application, the user has to beadded to the "Siemens TIA Openness" user group.Table 4-1 Siemens AG 2019 All rights reservedNo.Action1.Right click "Computer" in the windows taskbar and select "Manage".2.Open "Local Users and Groups and Groups Users" and double click the user.TIA Portal OpennessEntry ID: 108716692,V1.4,05/201910

4 Creating a New TIA Portal Openness Application Siemens AG 2019 All rights reservedNo.Action3.Go to the "Member Of" tab and click the "Add" button.4.Enter "Siemens TIA Openness" and confirm by pressing OK.5.Close the opened dialog boxes and log in again.TIA Portal OpennessEntry ID: 108716692,V1.4,05/201911

4 Creating a New TIA Portal Openness Application4.3Creating a projectTable 4-2No.ActionCreate a new project (e.g. in Microsoft Visual Studio).2.Create the references for the Openness DLLs ((Siemens.Engineering.dll andSiemens.Engineering.HMI.dll). They are located in the TIA Portal installationdirectory in ". Siemens Automation Portal V15 1 PublicAPI V15.1".3.Set the property "Copy Local" of the two DLLs to "False". Siemens AG 2019 All rights reserved1.TIA Portal OpennessEntry ID: 108716692,V1.4,05/201912

4 Creating a New TIA Portal Openness Application4.4Configuration file/AssemblyResolveTo detect the path of the Openness DLLs, you can either use a configuration file orthe "AssemblyResolve" event.Table 4-3No.4.5Action1.Configuration fileIf you have selected a different path for the installation of WinCC or STEP 7 (TIAPortal), replace the default path in the configuration file by your installation path.Store the application configuration file in the same directory as the Opennessapplication.2.AssemblyResolveIn order to establish the connection to the TIA Portal, the "AssemblyResolve"method was used here.The installation path of the TIA Portal is read out of the registry so that theprogram can be used irrespective of the installation path.Permitting access Siemens AG 2019 All rights reservedTable 4-4No.1.ActionWhen starting your application for the first time, the following security messagewill appear:System en/view/109477163)2.NoteConfirm the message with "Yes" in order to permit the access once.Confirm the message with "Yes to all" in order to always permit access to thisapplication.Click "No" to deny the access.If you are working with Microsoft Visual Studio, it can happen that you willreceive the message, although you have already clicked "Yes to all". In order toavoid this, follow the instructions in entry \5\.TIA Portal OpennessEntry ID: 108716692,V1.4,05/201913

5 StartOpenness5StartOpenness5.1OverviewThe "StartOpenness" program is to facilitate access to programming your firstindependent Openness application.NoteYou find a ready compiled "exe"-file in the download"108716692 StartOpenness V15 1.zip" with the path" \StartOpenness\StartOpenness\bin\Release". Siemens AG 2019 All rights reservedFigure 5-11The status information is output via the text field (1).TIA Portal OpennessEntry ID: 108716692,V1.4,05/201914

5 StartOpennessTable 5-1 Siemens AG 2019 All rights reservedNo.Action1.Open the project "StartOpenness".2.Open the "Form1" class.3.In order to establish the connection to the TIA Portal, the "AssemblyResolve"method was used here.4.Two tags were created: "MyTiaPortal" of the "TiaPortal" type "MyProject" of the "Project" typeTIA Portal OpennessEntry ID: 108716692,V1.4,05/201915

5 StartOpenness5.2"TIA Portal" groupFigure 5-2123Table 5-2 Siemens AG 2019 All rights reservedNo.Description1.Select whether the TIA Portal is to be started with or without user interface viathe option boxes "With User Interface" and "Without User Interface".In the "StartTIA()" method, the state of the option boxes is requested.2.Click the "Start TIA" button in order to start the TIA Portal.The "StartTIA()" method is called.The "MyTiaPortal" tag is assigned a new TIA Portal instance.3.Click the "Dispose TIA" button in order to end the TIA Portal or the connection tothe TIA Portal.The "DisposeTIA()" method is called.With "mytiaportal.Dispose()" the connection to the TIA Portal is terminated (if theTIA Portal was not started with the user interface) or the TIA Portal wasterminated (if the TIA Portal was started without user interface).TIA Portal OpennessEntry ID: 108716692,V1.4,05/201916

5 StartOpenness5.3"Project" groupFigure 5-31234Table 5-3No. Siemens AG 2019 All rights reserved1.DescriptionClick the "Open Project" button in order to open a new project. Select the projectyou would like to open in the file browser.The "SearchProject()" method is called.The file browser is opened. If a project has been selected the "OpenProject()"method is called.The "MyProject" project tag is initialized via ))".2.Click the "Connect to Open TIA Project" button in order to connect to an openTIA Project.3.Click the "Save Project" button to save the project.The "SaveProject()" method is called.The project is saved via "MyProject.Save()".TIA Portal OpennessEntry ID: 108716692,V1.4,05/201917

5 StartOpennessNo.Description4.5.4Click the "Close Project" button to close the project.The "CloseProject()" method is called.The project is closed via "MyProject.Close()"."Add" groupFigure 5-412 Siemens AG 2019 All rights reserved34Tabelle 5-4Nr.Beschreibung1.Enter in the text field the name of the device you would like to add.2.Enter in the text field the order number of the device you would like to add.3.Enter in the text field the version of the device you would like to add.4.Click the "Add Device" button to add the device.The "btn AddHW Click()" is called.If no device with the entered name is found, the device is added and output in thestatus field.TIA Portal OpennessEntry ID: 108716692,V1.4,05/201918

5 StartOpenness5.5"Compile" groupFigure 5-512Table 5-5No.DescriptionEnter in the text field the name of the controller or the operator panel you wouldlike to compile.In the method Compile() the name of all devices and their DeviceItems arecompared with the entered names.2.Click the "Compile" button in order to compile the device.The "Compile()" method is called.If a controller or an operator panel with this name is found, the device iscompiled. The result is saved in the "result" tag of the "CompilerResult" type andoutput via the status field. Siemens AG 2019 All rights reserved1.TIA Portal OpennessEntry ID: 108716692,V1.4,05/201919

6 TIA Openness Demo6TIA Openness Demo6.1GeneralThe "TIAPortalOpennessDemo" application consists of two projects. TiaOpennessHelperSome, especially the recurring methods were realized in the"TiaOpennessHelper". With the help of a reference to "TiaOpennessHelper.dll",you can use these methods in your own applications. TIAPortalOpennessDemoThe demo application is to give you an overview of the functions that can beused with TIA Portal Openness. Due to the multitude of fully programmedexamples, the application also provides detailed help for programming.Below, you will find two directories which are to make handling of the applicationeasier. If you are looking for a specific function or a specific application, you canuse one of the following directories. Siemens AG 2019 All rights reservedIn order to comprehend the description start the "TIAPortalOpennessDemo.exe"program and open the project with Microsoft Visual Studio.Note6.2You find a ready compiled "exe"-file in the download"108716692 TiaPortalOpennessDemo V15 1.zip” with the path“ \TiaPortalOpennessDemo n\Release”.Application examplesFlexible AssemblyResolve . 23Starting the TIA Portal. 23Connecting with the active TIA Portal instance . 23Separating from TIA Portal . 24Opening/saving/closing project . 25Reading out devices . 26Opening editors . 26Creating folder . 27Deleting elements . 28Compiling . 28Importing/exporting objects . 28Opening/closing global libraries . 30Update check . 31Online connection to controller . 31Comparing controllers . 32Integrating external sources . 32Generating block from source . 33Generating source from block . 33TIA Portal OpennessEntry ID: 108716692,V1.4,05/201920

6 TIA Openness Demo6.3MethodsCompareTo(Object) . 32CompareToOnline() . 32CreateFromFile(sourcename, filename) . 33Delete() . 28ShowInEditor . 27Compile() . 28Dispose() . 24Export(path, exportOption) . 29Groups.Create(FolderName) . 27GenerateBlockFromSource() . 33GenerateSourceFromBlocks(blocklist, filepath) . 33TiaPortal.GetProcesses() . 24GlobalLibraries.Open( ilename) . 31GoOffline() . 32GoOnline() . 32 Siemens AG 2019 All rights reservedImport(file, importOption) . 29Project.Close() . 25Project.Save() . .Network) . .Topology) . 27Projects.Open(new FileInfo(filename)) . 25process.Attach() . 24ShowInEditor . 27TiaPortal . 23UpdateCheck . 31TIA Portal OpennessEntry ID: 108716692,V1.4,05/201921

6 TIA Openness Demo6.4Description of the application6.4.1General settingsTable 6-1No.ActionClick the „File- Settings“.2.Select whether the TIA Portal is to be started with or without user interface.3.Select the export settings.4.Select the default path for the export and import files.5.Click the “Save” button to save the settings. Siemens AG 2019 All rights reserved1.TIA Portal OpennessEntry ID: 108716692,V1.4,05/201922

6 TIA Openness Demo6.4.2Flexible AssemblyResolveOpen the “General.cs” class of the “TiaOpennessHelper” project.In order for you to be able to use the application on any PC with the TIA Portal, theTIA Portal installation path is read out from the registry and is thus passed onflexibly.6.4.3TIA Portal functionsStarting the TIA PortalYou can open a new TIA Portal instance via “File Start TIA Portal”. Depending onyour settings the TIA Portal is started with or without user interface. Siemens AG 2019 All rights reservedFigure 6-1Open the “OpenTiaPortalCommand Executed” method in the“MainWindowViewModel.cs” class.The “tiaPortal” tag from the “TiaPortal” type is initialized. With the parameter“TiaPortalMode.WithoutUserInterface” or “TiaPortalMode.WithUserInterface” youspecify whether the TIA Portal is started with or without user interface.Connecting with the active TIA Portal instanceVia the “File- Connect Portal” the active TIA Portal instances are displayed.Figure 6-2TIA Portal OpennessEntry ID: 108716692,V1.4,05/201923

6 TIA Openness DemoFigure 6-3 Siemens AG 2019 All rights reservedBy clicking the instance, the demo application connects with this instance.Open the “CreateInstanceTreeView” method in the “MainWindowViewModel” class.For this purpose the “TiaPortal.GetProcesses()” method is used.In the “ShowConnectCommand Executed” method, the connection to the selectedinstance is established.For this purpose, the TIA Portal tag is assigned a value via “process.Attach()”.Separating from TIA PortalYou can end the connection to the TIA Portal instance again via “File DisposeTIA Portal”. If you have started the TIA Portal instance without user interface, theinstance is terminated. Otherwise the connection between your application and theTIA Portal instance is terminated.Figure 6-4Open

Basics on programming environment, such as e.g. Microsoft Visual Studio Basics on TIA Portal configuration Basic knowledge of these topics is assumed. 2.2 Hardware and software components 2.2.1 Validity This application is valid fo