TIA Portal Openness: Introduction And Demo Application - Siemens

Transcription

TIA Portal Openness:Introduction andDemo ApplicationTIA Portal V14 iew/108716692SiemensIndustryOnlineSupport

Warranty and liabilityWarranty and liabilityNoteThe Application Examples are not binding and do not claim to be completeregarding the circuits shown, equipping and any eventuality. The ApplicationExamples do not represent customer-specific solutions. They are only intendedto provide support for typical applications. You are responsible for ensuring thatthe described products are used correctly. These Application Examples do notrelieve you of the responsibility to use safe practices in application, installation,operation and maintenance. When using these Application Examples, yourecognize that we cannot be made liable for any damage/claims beyond theliability clause described. We reserve the right to make changes to theseApplication Examples at any time without prior notice.If there are any deviations between the recommendations provided in theseApplication Examples and other Siemens publications – e.g. Catalogs – thecontents of the other documents have priority. Siemens AG 2017 All rights reservedWe do not accept any liability for the information contained in this document.Any claims against us – based on whatever legal reason – resulting from the use ofthe examples, information, programs, engineering and performance data etc.,described in this Application Example shall be excluded. Such an exclusion shallnot apply in the case of mandatory liability, e.g. under the German Product LiabilityAct ("Produkthaftungsgesetz"), in case of intent, gross negligence, or injury of life,body or health, guarantee for the quality of a product, fraudulent concealment of adeficiency or breach of a condition which goes to the root of the contract("wesentliche Vertragspflichten"). The damages for a breach of a substantialcontractual obligation are, however, limited to the foreseeable damage, typical forthe type of contract, except in the event of intent or gross negligence or injury tolife, body or health. The above provisions do not imply a change of the burden ofproof to your detriment.Any form of duplication or distribution of these Application Examples or excerptshereof is prohibited without the expressed consent of the Siemens AG.SecurityinformationSiemens provides products and solutions with industrial security functions thatsupport the secure operation of plants, systems, machines and networks.In order to protect plants, systems, machines and networks against cyberthreats, it is necessary to implement – and continuously maintain – a holistic,state-of-the-art industrial security concept. Siemens’ products and solutions onlyform one element of such a concept.Customer is responsible to prevent unauthorized access to its plants, systems,machines and networks. Systems, machines and components should only beconnected to the enterprise network or the internet if and to the extent necessaryand with appropriate security measures (e.g. use of firewalls and networksegmentation) in place.Additionally, Siemens’ guidance on appropriate security measures should betaken into account. For more information about industrial security, please mens’ products and solutions undergo continuous development to make themmore secure. Siemens strongly recommends to apply product updates as soonas available and to always use the latest product versions. Use of productversions that are no longer supported, and failure to apply latest updates mayincrease customer’s exposure to cyber threats.To stay informed about product updates, subscribe to the Siemens IndustrialSecurity RSS Feed under http://www.siemens.com/industrialsecurity.TIA Portal OpennessEntry ID: 108716692,V1.2,05/20172

Table of ContentsTable of ContentsWarranty and liability . 21Task . 42Solution. 52.12.22.2.12.2.23Mode of Operation . 73.13.1.13.1.23.23.34 Siemens AG 2017 All rights reservedInstalling TIA Portal Openness . 10Managing user rights . 10Creating a project . 12Configuration file/AssemblyResolve . 13Permitting access . 14StartOpenness . 155.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. 15"TIA Portal" group . 17"Project" group . 18"Add" group . 19"Compile" group . 20TIA Openness Demo . eneral . 21Application examples . 21Methods . 22Description of the application . 23General settings . 23Flexible AssemblyResolve . 24TIA Portal functions . 24Project functions . 26Importing/exporting objects . 29Libraries . 31PLC. 327Related literature . 358History. 35TIA Portal OpennessEntry ID: 108716692,V1.2,05/20173

1 Task1TaskIntroductionIn STEP 7 or WinCC V14 SP1 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 2017 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.2,05/20174

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 2017 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 V14 SP1Components usedThe application was created with the following components:Software componentsTable 2-1ComponentNo.Article numberSTEP 7 ProfessionalV14 SP116ES7822-1AA04-0YA5WinCC AdvancedV14 SP116AV2102-0AA04-0AA5TIA Portal Openness1Microsoft VisualStudio 20151TIA Portal OpennessEntry ID: 108716692,V1.2,05/2017NoteIncluded in the delivery of STEP7 or WinCC V14 SP1 (insubfolder "Support" of theinstallation files)5

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 V14SP1.zipIntroductory example for the use of TIAPortal Openness (see chapter 5)108716692 TIA Openness GettingStartedAndDemo V14SP1 en.pdfThis document. Siemens AG 2017 All rights reserved108716692 TiaPortalOpennessDemo V14SP1.zipTIA Portal OpennessEntry ID: 108716692,V1.2,05/20176

3 Mode of Operation3Mode of Operation3.1TIA Portal OpennessIn STEP 7 or WinCC V14 SP1 TIA Portal Openness is available for free on therespective product DVDs. Prerequisite for the use is an installation of STEP 7 orWinCC V14 SP1.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 2017 All rights reservedDeviceFunctionseeThroughoutthe projectOpening TIA PortalP. 24Throughoutthe projectClosing/separating TIAPortalP. 25Throughoutthe projectConnecting TIA PortalprocessP. 24Throughoutthe projectOpening projectP. 26Throughoutthe projectSaving projectP. 26Throughoutthe projectClosing projectP. 26Throughoutthe projectNumerating devices andsubnetsP. 27Throughoutthe projectOpening network andtopology editorP. 27Throughoutthe projectCreating folderP. 28Throughoutthe projectDeleting elementsP. 29Throughoutthe projectExporting/importing projectgraphicsP. 29LibrariesOpening global libraryP. 31LibrariesClosing global libraryP. 31LibrariesTypes: Update check ofinstancesP. 32HMICompiling hardware and/orsoftwareP. 29HMIExporting screen as XMLP. 29HMIImporting screens fromXMLP. 29HMIExporting of the screenP. 29TIA 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 2017 All rights reservedmanagement as ing elements of thescreen management fromXMLP. 29HMIExporting tags/tag tables asXMLP. 29HMIImporting tags/tag tablesfrom XMLP. 29HMIExporting connections asXMLP. 29Non-integrated connectionsHMIImporting connections fromXMLP. 29Non-integrated connectionsHMIExporting scripts as XMLP. 29HMIImporting scripts from XMLP. 29HMIExporting cycles as XMLP. 29HMIImporting cycles from XMLP. 29HMIExporting text and graphiclists as XMLP. 29HMIImporting text and graphiclists from XMLP. 29PLCCompiling hardware and/orsoftwareP. 29PLCConnecting/separatingcontroller onlineP. 32PLCOnline/offline comparisonP. 33PLCOffline/offline comparisonP. 33PLCDisplaying blocks in theeditorP. 27PLCExporting blocks as XMLP. 29No SCL blocksPLCImporting blocks from XMLP. 29Only with enabler filePLCImporting external sourcesP. 33PLCGenerating blocks fromsources.P. 34PLCGenerating sources fromblocksP. 34PLCDisplaying tag tables anddata types in the editorP. 27PLCExporting tag tables anddata types as XMLP. 29PLCExporting tag tables anddata types as XMLP. 29PLCExporting individual tagsP. 29TIA Portal OpennessEntry ID: 108716692,V1.2,05/2017Exception: Pop-up and slide-inwindowsSTL and SCL blocks8

3 Mode of Operation3.1.23.2Restrictions With TIA Portal Openness V14 SP1 you can only access projects and librarieswith version V14 SP1. 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. At present, it is not possible to access the WinCC Runtime Professionalconfiguration or the data from Startdrive objects via TIA Portal Openness."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 2017 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.2,05/20179

4 Creating a New TIA Portal Openness Application4Creating a New TIA Portal OpennessApplication4.1Installing TIA Portal OpennessIn STEP 7 or WinCC V14 SP1 TIA Portal Openness can be installed via theproduct DVD.Table 4-1No. Siemens AG 2017 All rights reserved4.2Action1.Open the STEP 7 or WinCC V14 SP1 product DVD. Start the installation setup"Siemens TIA Openness V14SP1" in the "Support" folder.2.Follow the instructions of the installation setup.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-2No.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.2,05/201710

4 Creating a New TIA Portal Openness Application Siemens AG 2017 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.2,05/201711

4 Creating a New TIA Portal Openness Application4.3Creating a projectTable 4-3No.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 V14 PublicAPI V14 SP1".3.Set the property "Copy Local" of the two DLLs to "False". Siemens AG 2017 All rights reserved1.TIA Portal OpennessEntry ID: 108716692,V1.2,05/201712

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-4No.ActionConfiguration 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. Siemens AG 2017 All rights reserved1.The installation path of the TIA Portal is read out of the registry so that theprogram can be used irrespective of the installation path.TIA Portal OpennessEntry ID: 108716692,V1.2,05/201713

4 Creating a New TIA Portal Openness Application4.5Permitting accessTable 4-5No.1.ActionWhen starting your application for the first time, the following security messagewill appear: Siemens AG 2017 All rights reservedSystem 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.2,05/201714

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 V14.zip" with the path" \StartOpenness\StartOpenness\bin\Debug". Siemens AG 2017 All rights reservedFigure 5-11The status information is output via the text field (1).TIA Portal OpennessEntry ID: 108716692,V1.2,05/201715

5 StartOpennessTable 5-1 Siemens AG 2017 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.2,05/201716

5 StartOpenness5.2"TIA Portal" groupFigure 5-2123Table 5-2 Siemens AG 2017 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.2,05/201717

5 StartOpenness5.3"Project" groupFigure 5-31234Table 5-3No. Siemens AG 2017 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.2,05/201718

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 2017 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.2,05/201719

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 2017 All rights reserved1.TIA Portal OpennessEntry ID: 108716692,V1.2,05/201720

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 2017 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 V14SP1.zip" with the path" \TiaPortalOpennessDemo \bin\Release".Application examplesFlexible AssemblyResolve . 24Starting the TIA Portal. 24Connecting with the active TIA Portal instance . 24Separating from TIA Portal . 25Opening/saving/closing project . 26Reading out devices . 27Opening editors . 27Creating folder . 28Deleting elements . 29Compiling . 29Importing/exporting objects . 29Opening/closing global libraries . 31Update check . 32Online connection to controller . 32Comparing controllers . 33Integrating external sources . 33Generating block from source . 34Generating source from block . 34TIA Portal OpennessEntry ID: 108716692,V1.2,05/201721

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

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 2017 All rights reserved1.TIA Portal OpennessEntry ID: 108716692,V1.2,05/201723

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 2017 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.2,05/201724

6 TIA Openness DemoFigure 6-3 Siemens AG 2017 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 the "DisposeTiaPortalCommand Executed" method in the"MainWindowViewModel.cs" class.The connection is separated via the "Dispose()" method of the TIA Portal tag.TIA Portal OpennessEntry ID: 108716692,V1.2,05/201725

6 TIA Openness Demo6.4.4Project functionsOpening/saving/closing projectIf no project is opened yet, you can open a project via "File Open project".Figure 6-5 Siemens AG 2017 All rights reservedOpen the "OpenProjectCommand Executed" method in the"MainWindowViewModel.cs" class.For this purpose, a tag of the "Projec

STEP 7 Professional V14 SP1 1 6ES7822-1AA04-0YA5 WinCC Advanced V14 SP1 1 6AV2102-0AA04-0AA5 TIA Portal Openness 1 Included in the delivery of STEP 7 or WinCC V14 SP1 (in subfolder "Support" of the installation files) Microsoft Visual Studio 2015 1 . 2 Solution TIA Portal Openness Entry ID: 108716692, V1.2, 05/2017 .