manual twincat 3 analytics storage provider · 2020. 8. 12. · technical data librarytf3520 tc 3...

70
Manual | EN TF3520 TwinCAT 3 Analytics Storage Provider 8/12/2020 | Version: 1.0

Upload: others

Post on 15-Oct-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Manual | EN

TF3520TwinCAT 3 Analytics Storage Provider

8/12/2020 | Version: 1.0

Page 2: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT
Page 3: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Table of contents

TF3520 3Version: 1.0

Table of contents1 Foreword .................................................................................................................................................... 5

1.1 Notes on the documentation.............................................................................................................. 51.2 Safety instructions ............................................................................................................................. 6

2 Overview..................................................................................................................................................... 7

3 Installation.................................................................................................................................................. 83.1 System requirements......................................................................................................................... 83.2 Installation ......................................................................................................................................... 83.3 Licensing ......................................................................................................................................... 11

4 Analytics Workflow - First Steps............................................................................................................ 144.1 Recording data from the machine ................................................................................................... 144.2 Communication................................................................................................................................ 174.3 Historicize data ................................................................................................................................ 184.4 Analyse data.................................................................................................................................... 234.5 24h Analytics application ................................................................................................................. 27

5 Technical introduction ............................................................................................................................ 37

6 Configuration ........................................................................................................................................... 396.1 Service............................................................................................................................................. 396.2 Databases/Stores ............................................................................................................................ 41

6.2.1 Analytics Binary File ........................................................................................................  416.2.2 Microsoft SQL ..................................................................................................................  426.2.3 Microsoft Azure Blob........................................................................................................  44

6.3 Recorder .......................................................................................................................................... 466.4 Working with Historical Data............................................................................................................ 50

7 PLC API..................................................................................................................................................... 557.1 Function blocks................................................................................................................................ 55

7.1.1 Topic Architecture............................................................................................................  557.1.2 FB_ALY_StorageProvider ...............................................................................................  61

7.2 Data types ....................................................................................................................................... 647.2.1 E_CancelType .................................................................................................................  647.2.2 E_RawDataFormat ..........................................................................................................  657.2.3 E_SymbolMode ...............................................................................................................  657.2.4 ST_ALY_SP_Config ........................................................................................................  657.2.5 ST_ConnectionSettings ...................................................................................................  667.2.6 E_RecordMode................................................................................................................  667.2.7 E_RingBufferMode ..........................................................................................................  67

8 Appendix .................................................................................................................................................. 688.1 FAQ - frequently asked questions and answers.............................................................................. 68

Page 4: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Table of contents

TF35204 Version: 1.0

Page 5: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Foreword

TF3520 5Version: 1.0

1 Foreword

1.1 Notes on the documentationThis description is only intended for the use of trained specialists in control and automation engineering whoare familiar with applicable national standards.It is essential that the documentation and the following notes and explanations are followed when installingand commissioning the components. It is the duty of the technical personnel to use the documentation published at the respective time of eachinstallation and commissioning.

The responsible staff must ensure that the application or use of the products described satisfy all therequirements for safety, including all the relevant laws, regulations, guidelines and standards.

Disclaimer

The documentation has been prepared with care. The products described are, however, constantly underdevelopment.We reserve the right to revise and change the documentation at any time and without prior announcement.No claims for the modification of products that have already been supplied may be made on the basis of thedata, diagrams and descriptions in this documentation.

Trademarks

Beckhoff®, TwinCAT®, EtherCAT®, EtherCAT G®, EtherCAT G10®, EtherCAT P®, Safety over EtherCAT®,TwinSAFE®, XFC®, XTS® and XPlanar® are registered trademarks of and licensed by Beckhoff AutomationGmbH.Other designations used in this publication may be trademarks whose use by third parties for their ownpurposes could violate the rights of the owners.

Patent Pending

The EtherCAT Technology is covered, including but not limited to the following patent applications andpatents:EP1590927, EP1789857, EP1456722, EP2137893, DE102015105702with corresponding applications or registrations in various other countries.

EtherCAT® is a registered trademark and patented technology, licensed by Beckhoff Automation GmbH,Germany

Copyright

© Beckhoff Automation GmbH & Co. KG, Germany.The reproduction, distribution and utilization of this document as well as the communication of its contents toothers without express authorization are prohibited.Offenders will be held liable for the payment of damages. All rights reserved in the event of the grant of apatent, utility model or design.

Page 6: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Foreword

TF35206 Version: 1.0

1.2 Safety instructions

Safety regulations

Please note the following safety instructions and explanations!Product-specific safety instructions can be found on following pages or in the areas mounting, wiring,commissioning etc.

Exclusion of liability

All the components are supplied in particular hardware and software configurations appropriate for theapplication. Modifications to hardware or software configurations other than those described in thedocumentation are not permitted, and nullify the liability of Beckhoff Automation GmbH & Co. KG.

Personnel qualification

This description is only intended for trained specialists in control, automation and drive engineering who arefamiliar with the applicable national standards.

Description of symbols

In this documentation the following symbols are used with an accompanying safety instruction or note. Thesafety instructions must be read carefully and followed without fail!

DANGERSerious risk of injury!Failure to follow the safety instructions associated with this symbol directly endangers the life and health ofpersons.

WARNINGRisk of injury!Failure to follow the safety instructions associated with this symbol endangers the life and health of per-sons.

CAUTIONPersonal injuries!Failure to follow the safety instructions associated with this symbol can lead to injuries to persons.

NOTEDamage to the environment or devicesFailure to follow the instructions associated with this symbol can lead to damage to the environment orequipment.

Tip or pointerThis symbol indicates information that contributes to better understanding.

Page 7: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Overview

TF3520 7Version: 1.0

2 OverviewBeckhoff offers with the TwinCAT Analytics Storage Provider a possibility to store your high resolution datainto a database or store by the usage of the TwinCAT Analytics Binary data format. The key is that the userdoes not have to worry about the structure of the data or tables. This is done automatically by the StorageProvider, which puts all that has been configured into a database or store and also searches the desiredvariables for the post-analysis.

Components• TwinCAT Analytics Storage Provider Service: Is a Windows Service who manages the communication.• TwinCAT Analytics Storage Provider PLC Library: Is a TwinCAT 3 PLC library with functions to control

the Storage Provider from a PLC application.

Principle of operation

The Analytics Storage Provider receives and sends data by MQTT. Therefore, he is connected to a nativeMQTT Message Broker somewhere in the network.

Supported databases/stores• TwinCAT Analytics Binary File• Microsoft SQL• Microsoft Azure Blob

Page 8: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Installation

TF35208 Version: 1.0

3 Installation

3.1 System requirementsSee the requirements of the Service and the PLC library of the Analytics Storage Provider in the followingtables. It is also possible to install both on one system as well.

Technical data Service TF3520 TC 3 Analytics Storage ProviderTarget system Windows 7, Windows 8, Windows 10.NET Framework .Net 4.5.1 or higherMin. TwinCAT version 3.1.4022.25Min. TwinCAT level TC1000 TC3 | ADS

Technical data Library TF3520 TC 3 Analytics Storage ProviderTarget system Windows 7, Windows 8, Windows 10Min. TwinCAT version 3.1.4022.29Min. TwinCAT level TC1200 TC3 | PLC

3.2 InstallationThe following section describes how to install the TwinCAT 3 Function for Windows-based operatingsystems.

ü The TwinCAT 3 Function setup file was downloaded from the Beckhoff website.1. Run the setup file as administrator. To do this, select the command Run as administrator in the context

menu of the file.ð The installation dialog opens.

2. Accept the end user licensing agreement and click Next.

Page 9: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Installation

TF3520 9Version: 1.0

3. Enter your user data.

4. If you want to install the full version of the TwinCAT 3 Function, select Complete as installation type. Ifyou want to install the TwinCAT 3 Function components separately, select Custom.

Page 10: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Installation

TF352010 Version: 1.0

5. Select Next, then Install to start the installation.

ð A dialog box informs you that the TwinCAT system must be stopped to proceed with the installation.6. Confirm the dialog with Yes.

Page 11: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Installation

TF3520 11Version: 1.0

7. Select Finish to exit the setup.

ð The TwinCAT 3 Function has been successfully installed and can be licensed (see Licensing [} 11]).

3.3 LicensingThe TwinCAT 3 function can be activated as a full version or as a 7-day test version. Both license types canbe activated via the TwinCAT 3 development environment (XAE).

Licensing the full version of a TwinCAT 3 Function

A description of the procedure to license a full version can be found in the Beckhoff Information System inthe documentation "TwinCAT 3 Licensing".

Licensing the 7-day test version of a TwinCAT 3 Function

Note: A 7-day test version cannot be enabled for a TwinCAT 3 license dongle.

1. Start the TwinCAT 3 development environment (XAE).2. Open an existing TwinCAT 3 project or create a new project.3. If you want to activate the license for a remote device, set the desired target system. To do this, select

the target system from the Choose Target System drop-down list in the toolbar.ð The licensing settings always refer to the selected target system. When the project is activated on

the target system, the corresponding TwinCAT 3 licenses are automatically copied to this system.

Page 12: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Installation

TF352012 Version: 1.0

4. In the Solution Explorer, double-click License in the SYSTEM subtree.

ð The TwinCAT 3 license manager opens.5. Open the Manage Licenses tab. In the Add License column, check the check box for the license you

want to add to your project (e.g. "TF6420: TC3 Database Server").

6. Open the Order Information (Runtime) tab.ð In the tabular overview of licenses, the previously selected license is displayed with the status

“missing”.

Page 13: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Installation

TF3520 13Version: 1.0

7. Click 7-Day Trial License... to activate the 7-day trial license.

ð A dialog box opens, prompting you to enter the security code displayed in the dialog.8. Enter the code exactly as it appears, confirm it and acknowledge the subsequent dialog indicating

successful activation.ð In the tabular overview of licenses, the license status now indicates the expiry date of the license.

9. Restart the TwinCAT system.ð The 7-day trial version is enabled.

Page 14: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Analytics Workflow - First Steps

TF352014 Version: 1.0

4 Analytics Workflow - First StepsThis step by step documentation presents the complete TwinCAT Analytics workflow. From the dataacquisition over the communication and historizing up to the evaluation and analysis of the data and to thepresentation of the data in web-based dashboard.

4.1 Recording data from the machineOn the machine side is the Analytics Logger the recorder of process data from the machine image, PLC, NCand so on. The Logger is working in the real-time context of TwinCAT.

The TwinCAT Analytics Logger is installed with TwinCAT XAE and XAR. The Logger can act as MQTT Clientto communicate the recorded data to a native MQTT Message Broker or store the data in the same dataformat in a local binary file. By the usage as MQTT Client the Logger is able to bypass short disconnects tothe Message Broker with a ring buffer functionality. You can configure a ring buffer as well for the localbinary file storage.

• To configure the Analytics Logger you have to navigate in your existing TwinCAT Project to theAnalytics tree node

Page 15: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Analytics Workflow - First Steps

TF3520 15Version: 1.0

• Right click on this node and click on “Add Data Logger” to add one new instance to your configuration

• For configuring the base settings, please double click on the new tree item

You can make your specific Analytics Logger settings

    -Data Format: Binary file or MQTT stream

        -FILE format: Analytics Logger stores the data in local binary files and all other settings are notnecessary anymore. The files will be stored in C:\TwinCAT\3.1\Boot\Analytics.

        -BINARY: Data will be sent to the configured MQTT Message Broker. You can have multiple Logger inone TwinCAT project to communicate data to different MQTT Message Broker.

    -Data Compression: on (default) or off

Page 16: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Analytics Workflow - First Steps

TF352016 Version: 1.0

    -Max Compression: mode of the compression

    -MQTT host name

    -MQTT Tcp port

    -MQTT main topic for own hierarchical levels to keep the identification easy

    -MQTT Client ID should be unique in the network

    -MQTT username

    -MQTT password to make authentication at the message broker

    -At the TLS (Transport Layer Security) tab, security settings can be configured. TLS is a securecommunication channel between client and server. By the usage of certificates, the TCP port 8883 isexclusively reserved for MQTT over TLS. Analytics Logger is supporting the modes CA Certificates, CACertificates & Client Certificate and Preshared Key (PSK) mode.

• If variables in your PLC application are marked in the declaration with the attribute {attribute'TcAnalytics'} they will be shown automatically as a stream below the Data Logger tree node.

An additional device stream will be shown if your configuration provides an EtherCAT Process Image.

Page 17: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Analytics Workflow - First Steps

TF3520 17Version: 1.0

• In the stream a Selection tab is available to choose the variables that should be recorded

• Finally it is possible to change the package size for the frames or to configure the ring buffer fordisconnects and file in the Data Handling tab.

4.2 CommunicationCurrently, the Analytics workflow is fully mappable via MQTT. The engineering tools can also access thedata of the machines via ADS and carry out analyzes.

Page 18: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Analytics Workflow - First Steps

TF352018 Version: 1.0

If you choose for the IoT communication protocol MQTT you have to setup a native MQTT Message Brokersomewhere in the network (VM in a cloud system is also possible). This Message Broker provides adecoupling of the different applications in the Analytics Workflow.

4.3 Historicize dataAfter installation of the TwinCAT Analytics Storage Provider you are able to configure the service running inthe background. You will find therefore the TcAnalyticsStorageProvider_Config application in the folder C:\TwinCAT\Functions\TF3520-Analytics-StorageProvider\WinService.

Page 19: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Analytics Workflow - First Steps

TF3520 19Version: 1.0

The main part of the topic can be set in the configuration as well as the comment which will be used foridentification if more than one Storage Provider is registered at the Message Broker.

You are able to provide the Message Broker settings and to decide for storage type:

• Analytics File (binary file)• Microsoft SQL• Microsoft Azure Blob (Azure Cloud necessary)

Finally, you can save the config and start the service. The next step is the configuration of the specificrecord. Therefore you should choose in your development environment the Storage Provider Recorder.

Page 20: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Analytics Workflow - First Steps

TF352020 Version: 1.0

The recorder has also to connect to the Message Broker. So you have to provide the same settings as forthe background service.

After this you can click to icon with the small cloud to search Storage Providers at the configured MessageBroker. Here you will find also the comment you gave already by the service configuration to identify yourStorage Provider.

Page 21: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Analytics Workflow - First Steps

TF3520 21Version: 1.0

The configuration of the record is very easy. You have just to choose your target in the Target Browser. Clickon Live data and choose one or more variables by multiselect and put them by drag and drop to the recorderwindow.

The recorder will ask you if you like to add just the chose variables or the complete source process image ofthe variables.

Page 22: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Analytics Workflow - First Steps

TF352022 Version: 1.0

You can also configure record names and a duration (otherwise endless until manual stop). A ringbuffer canbe set by memory or time.

Click the Start button to start the record. After this you can also disconnect the recorder, because thebackground service do the work. It is also possible that someone else connect to this Storage Providerservice and control the running record.

Page 23: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Analytics Workflow - First Steps

TF3520 23Version: 1.0

After and also during the record you can choose the historical data as input for your analysis in the TargetBrowser. In the Target Browser you will find for historical data a new control on the right hand site. There youcan choose the time span for your data.

4.4 Analyse dataOpen your TwinCAT engineering environment to start the analysis of the data.

Open Visual Studio® >> File >> New >> Project…Choose from TwinCAT Measurement the Analytics project template.

Page 24: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Analytics Workflow - First Steps

TF352024 Version: 1.0

The new project will be shown in the Solution Explorer. After a click on the Analytics Project tree node item astart window opens where you can select your first action. From here, you can add a Network, open theToolbox, open the Target Browser or open the Analytics Storage Provider Recorder. You will do all theseactions in the following steps.

It makes sense to open in a first step the Toolbox of Visual Studio®. There you will find all the supportedalgorithm of TwinCAT Analytics. Algorithm must be organized and grouped into networks. Right click on theAnalytics Project to add a new Network or add a Network using the start page. The first Network is alwaysgenerated by default.

If you click on the Network an editor will be open. Now you can take the algorithm you like by drag and dropinto the editor surface. After choosing the algorithm you need to connect input variables to the modules(algorithm). Therefor open the Target Browser.

TwinCAT >> Target Browser >> Target Browser

Page 25: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Analytics Workflow - First Steps

TF3520 25Version: 1.0

Choose now the TcAnalytics or TcAnalyticsFile tab in the Target Browser. We go ahead with the TcAnalyticstab (MQTT). Click on the green marked icon in the toolbar of this Analytics extension. A window will be openwhere you can provide your Message Broker connectivity data.

Choose your MQTT Analytics client (TwinCAT Analytics Logger, TwinCAT IoT Data Agent or BeckhoffEK9160). For each controller you have a unique ID. This ID is shown in the Target Browser. Not very legible,of course. Therefore, click on the icon with the gear to get to the machine administration page. Here you canprovide a System Alias name which is shown in the Target Browser instead of the GUID.

In the next step you can choose between Live Data and Historical Data for each MQTT Analytics client.Historical Data are only provided by the TwinCAT Analytics Storage Provider.

Page 26: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Analytics Workflow - First Steps

TF352026 Version: 1.0

You can take the variables by drag and drop into the inputs of the specific algorithm. For the most algorithmit is possible to set conditions like thresholds, time intervals, logic operators and so on. You can do thesesettings in the middle of each module.

Finally, your first Analytics Project is finished. To start the analysis, click on “Start Analytics”. To stop theanalysis, click on “Stop Analytics”.

Page 27: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Analytics Workflow - First Steps

TF3520 27Version: 1.0

Before starting Analytics or also during the runtime you can click on the button “Add Reference Scope”. AScope configuration is automatically built to fit your Analytics project.

Results of the analysis can be show in the Scope View charts by drag and drop. For example, an averagevalue can be shown as new channel in the view. Timestamps as Marker at the x-axes to show significantvalues.

4.5 24h Analytics applicationThe last big step in the TwinCAT Analytics workflow is the continuous 24h machine analysis. It runs parallelto the machine applications in the field. To do this in a very easy way the TwinCAT Analytics Workbench isable to generate automatically a PLC code and a HTML5-based Dashboard of your Analytics configuration.Both can be downloaded to a TwinCAT Analytics Runtime (TC3 PLC and HMI Server) and provide the sameanalysis results as the configurator tool in engineering environment.

At first save your configuration and open the Analytics Deploy Runtime wizard. You can do this via thecontext menu at the Analytics Project tree item or by the Start Page.

Page 28: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Analytics Workflow - First Steps

TF352028 Version: 1.0

When the wizard is open, there are some tabs available for you to click through. First one is called Solution.Here it is possible to decide how you like to use your Analytics project in PLC code: As…

• completely new solution• part of an existing solution• update of an existing Analytics solution

In the TwinCAT PLC Target tab you can choose the ADS target system which runs the TwinCAT AnalyticsRuntime (TF3550). The generated project is immediately executable. Therefore, you can set the optionActivate PLC Runtime. Also, that directly a boot project is created.

Page 29: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Analytics Workflow - First Steps

TF3520 29Version: 1.0

Specially for Virtual Machines it is important to run the project on isolated cores. Also, an option in this tab.The next tab Results is only necessary if you have chosen the Stream Results option in the algorithmproperties. If you like to send results you can decide here in which way (local in a file/ by MQTT) and format(binary/JSON). Also, this is generated automatically and starts running after activation.

Page 30: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Analytics Workflow - First Steps

TF352030 Version: 1.0

A down sampling of the results is possible by setting a cycle time. The next tab is reserved for the HMIDashboard. The prerequisite for the automatic Dashboard generation is the selection of HMI controls for thecorresponding algorithms whose results are to be displayed in the dashboard.

Page 31: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Analytics Workflow - First Steps

TF3520 31Version: 1.0

You can choose for your Analytics Dashboard different options like start page with a map, layouts, sortingalgorithm, own colors and logos. If you choose more languages for the Analytics controls a language switchmenu will be generated as well.

Page 32: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Analytics Workflow - First Steps

TF352032 Version: 1.0

Choose one of the installed Visual Studio versions. And whether the generation should start the instancevisibly or whether it should only be set up and activated in the background.

Page 33: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Analytics Workflow - First Steps

TF3520 33Version: 1.0

Finally you find a summery.

Page 34: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Analytics Workflow - First Steps

TF352034 Version: 1.0

Now you can click the Deploy button to start the generation process. The PLC project and the HMIDashboard will be generated now.

Page 35: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Analytics Workflow - First Steps

TF3520 35Version: 1.0

After the message Deploy Runtime succeeded you can find a new Visual Studio®/XAE Shell instance onyour desktop. The new Solution and both Projects are generated.

Page 36: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Analytics Workflow - First Steps

TF352036 Version: 1.0

Page 37: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Technical introduction

TF3520 37Version: 1.0

5 Technical introductionThe basic idea of the TwinCAT Analytics Storage Provider is to have a gateway, which takes the user fromthe configuration of the databases and stores behind. The user do not need to setup an own table structurein a database. He need just to configure which of the supported data sinks and variables from the datasource he likes to use.

Service management

The Analytics Storage Provider Service can run somewhere in the network. He is implemented as WindowsService. The service can run on hardware devices like Industrial PCs or Embedded PCs in the local networkand also on virtual machines in the same network or eg in a Cloud System.

Value management

The Storage Provider speaks the TwinCAT Analytics binary format. This enables him to receive and savestreams from a MQTT Message Broker, as well as to create and send new streams himself. The user ismanaging that just by the Recorder integrated in his own engineering system with TwinCAT AnalyticsWorkbench or Service Tool. The variables self are shown into the TwinCAT Target Browser. For theAnalytics binary format it is separated into Live and Historical data. Live data can be used as input for theAnalytics Storage Provider. Historical data are the values from the database/store provided by the StorageProvider.

Topologies

The many degrees of freedom of the IoT technologies enable a variety of topologies. The following pictureshows the most significant constellations.

1. Each SW package is running on own HW device or virtual machine2. The Windows Service of the Analytics Storage Provider is running on the same device as the data-

base/store3. Analytics Engineering, Analytics Storage Provider and database or store are on the same device. Only

the Message Broker and the Analytics Logger (data source) are on other devices

Page 38: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Technical introduction

TF352038 Version: 1.0

4. In this topology view is only the Analytics Logger on an own PC. Maybe in a machine application. Allother tools of the Analytics tool chain are on one device include the MQTT Message Broker.

Page 39: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Configuration

TF3520 39Version: 1.0

6 ConfigurationThe configuration of the Analytics Storage Provider is divided into two main parts. The user has to configurethe Service of the Storage Provider and variables by a Recorder. You will also find the supported databasesand stores in this chapter.

6.1 ServiceThe Windows Service of the Analytics Storage Provider needs at least a TwinCAT 3 ADS as basement. Thesetup detects automatically if a TwinCAT 3 XAE is available or not. If it is available we install the PLC libraryas well, otherwise just the Windows Service.

After installation you find everything you need under c:\TwinCAT\Functions\TF3520-Analytics-StorageProvider. One hierarchical level deeper you see the folder WinService where you find theTcAnalyticsStorageProvider_config.exe.

Open this executable and see the configuration surface.

• Analytics Storage ProviderMain Topic: Set here your own Main Topic to identify a stream with historical dataComment: You can set a comment which is later shown into the Recorder window in AnalyticsWorkbench or Service Tool

• Message Broker• Settings:

Provide here your Message Broker data like URL, User name, password or certificates.

Page 40: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Configuration

TF352040 Version: 1.0

It is possible to check the settings. The following window shows the result:

• StorageType: Choose here the type of your data sink like Analytics File or Microsoft SQLConnection String: You can configure your connection string manually or automatically by the givensettings mask.See here for Microsoft SQL

• Analytics Storage Provider Windows ServiceStatus: See here status and default settings for starting up the Windows Service

For sure it is possible to save the created configuration. If you click on “Save Config” the settings will bestored in TcAlySPWinService.exe.config in c:\TwinCAT\Functions\TF3520-Analytics-StorageProvider\WinService.

Page 41: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Configuration

TF3520 41Version: 1.0

6.2 Databases/Stores

6.2.1 Analytics Binary FileThe TwinCAT Analytics Binary File is and TwinCAT specific data storage. Therefore no external software isnecessary. You can use this kind of store directly after the installation of the Analytics Storage Provider. It isthe same file what the TwinCAT Analytics Logger is providing in his “offline” configuration without MQTTMessage Broker.

For the configuration it is enough that you choose your favorite folder on the local device where the StorageProvider is running.

Page 42: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Configuration

TF352042 Version: 1.0

As confirmation you will see the used folder in the Connection String window.

6.2.2 Microsoft SQLWith the support of Microsoft SQL Server (Azure SQL as well) you have an additional on-premises solutionto store Analytics binary data. You have just to provide the connection string for your MsSQL Server.

Page 43: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Configuration

TF3520 43Version: 1.0

To make that simple you are able to click on the “SQL ConnString” button to open the input mask. There youcan provide the configuration settings. Also of remote databases which are reachable by networkconnections.

After starting the WinService and finishing the very first configuration of the Recorder tool we start thecommunication to the database. In this moment the Storage Provider is creating the four necessary tables byhimself. As example see the following screenshot of Microsoft SQL Server Management Studio.

Page 44: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Configuration

TF352044 Version: 1.0

6.2.3 Microsoft Azure BlobTo use the Microsoft Azure Blob store you need to have a Microsoft Azure Cloud account. There you getalso your individual connection string for the configuration of the TwinCAT Analytics Storage Provider.

Page 45: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Configuration

TF3520 45Version: 1.0

You have to copy the connection string into the description field. In Azure itself, the storage is to begenerated. Choose “Storage accounts (classic)”.

After generating the storage you will find under “Access keys” the secondary connection string. This string isto be use in the Analytics Storage Provider configuration.

Page 46: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Configuration

TF352046 Version: 1.0

6.3 RecorderThe Analytics Storage Provider Recorder is part of the Analytics Engineering setups. So you will find theRecorder in the installation of TwinCAT Analytics Workbench and TwinCAT Analytics Service Tool.

Toolbar

(1) Connection Settings

Provide here your Message Broker data like URL, User name, password or certificates.

It is possible to check the settings. The following window shows the result:

Page 47: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Configuration

TF3520 47Version: 1.0

(2) Find TwinCAT Analytics StorageProvider

With the given connection settings, the recorder will connect to the message broker and search for everyconnected StorageProvider

(3) TwinCAT Analytics StorageProvider Instances

This DropDown field contains all connected StorageProvider instances from the connected message broker

(4) Info

Shows the description and other settings of the selected StorageProvider instance

(5) Filter

It is possible to filter the view of the live running recordings. You can see all recordings or you can see onlythe recordings which were started from your recorder

(6) Messages

Shows all Logs from the StorageProvider instance

(7) Clean Recordings

It is possible to delete recordings from the StorageProvider instance

Page 48: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Configuration

TF352048 Version: 1.0

(8) Download Recordings

You can download recordings which are stored in the cloud or on other systems from the StorageProviderinto a local AnalyticsFile.

Page 49: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Configuration

TF3520 49Version: 1.0

(9) RecorderAlias

Insert an alias name for the Recorder to get a better overview of all running recordings. Who has start therecording?

Start a recording

If you drag some symbols from the TwinCAT TargetBrowser into the Recorder Window the following Dialogwill start up.

Page 50: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Configuration

TF352050 Version: 1.0

All needed settings like record duration, record name, can be made. It is also possible to set the ringbufferoptions. Here are the different options:

6.4 Working with Historical DataHistorical Data can be analysed with the Analytics Workbench or the Analytics Service Tool. To see yourrecorded data, you need the TwinCAT Target Browser.

Select data from TwinCAT Target Browser

The Historical Data can directly be dragged from the Target Browser to an input of an analytics algorithm.First of all you have to click in the left corner of the Target Browser on TcAnalytics. There you can see yourconfigured broker which lists the live and historical data of your different devices. This should look like in thefollowing figure.

Page 51: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Configuration

TF3520 51Version: 1.0

Go to the historical stream that you have created and select the record you want to analyse. All of yourrecords are listed to the right in the Record Window. By default the last record is selected.

When you are live recording, the time range of the record will be updated every few seconds. By default thewhole time range of a record is used. Additionally you can edit the start and end time to analyse your desireddata range. This can be done with a range slider, textboxes or in a graphical calendar view. When you clickon the icon right next to the textboxes, the calendar view will be displayed.

After these steps you can drag and drop a symbol to an input of an algorithm as well as you can do with thesymbols of the live data.

After you have done this, a new input source is generated for your historical stream and can be seen in theSolution Explorer of your Visual Studio. Firstly, the dragged symbol and a timestamp of the current devicetime are listed below this stream. New dragged symbols of this stream will be listed as well there.

Page 52: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Configuration

TF352052 Version: 1.0

Analyse your historical data in the Analytics Configurator

To analyse your historical data press on the Start Analytics button. In contrast to analysing live data, a greenprogress bar appears. The speed of your analysis depends on your record length, the amount and size ofyour symbols as well as on your broadband speed to the broker. The analysis stops automatically when theprogress bar ends. The results will remain visible.

Analyse your historical data in your Analytics Runtime

You can deploy the configuration with your historical data to an Analytics Runtime (PLC). Additionally to thehistorical data also the live data will be analysed. So, you can switch between them and you will not lose anylive data by streaming historical data. This is because they are separated in two different tasks. Thehistorical data analysing must be triggered to start.

Calculation time of historical dataDifferent to the Analytics Configurator the analysis of historical data requires in the PLC the originaltime the data was recorded. 30 minutes of raw data needs 30 minutes to analyse.

Main differences of the folder structure in the generated plc project:

Page 53: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Configuration

TF3520 53Version: 1.0

NOTERealize logic in your TwinCAT HMIThe preparing and writing of values in your PLC is for test purpose. It is recommended to realize this andother logic in the PLC code with interactions from your TwinCAT HMI application if needed.

You can start the analysis of historical data by triggering “bGetHistoricalData” in “stCtrl_T1”. Furthermore,with triggering “bCancelHistoricalData” the historical analysis can be canceled. This can be done in the file“MAIN_Analytics_Historical” like in the following:

Page 54: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Configuration

TF352054 Version: 1.0

To switch for your HMI dashboard between the results of the live data and historical data you can set thesymbol “bHistorical” in the GVL “AnalyticsHMI”. With this possibility you do not need any additional controlsto show historical data (for sure, also own controls for historical data are possible). The analysis for the livedata will be not interrupted by calling some historical data. After showing the results of the historical data youare able to switch back to the current live results. This switching just concerns the variables in your GVL.

Page 55: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

PLC API

TF3520 55Version: 1.0

7 PLC API

7.1 Function blocks

7.1.1 Topic Architecture

7.1.1.1 T_ALY_SPGetHistorical_Cmd

Syntax

Definition:FUNCTION_BLOCK T_ALY_SPGetHistorical_Cmd EXTENDS T_ALY_JsonPayloadVAR_INPUT    sTopic  : T_MaxString;    sLayout : GUID;    eMode   : E_SymbolMode := E_SymbolMode.All;    eOutputFormat   : E_RawDataFormat := E_RawDataFormat.Bin;    nMaxSampleCount : UDINT := 3000;    nUserSampleTime : DINT := -1;    nRecordID : DINT;    nStartTimestamp : LINT;    nEndTimestamp   : LINT;    sResultTopic : T_MaxString;    arrSymbol : ARRAY [0..255] OF T_ALY_Symbol;END_VAR

Inheritence hierarchy

T_ALY_JsonPayload [} 60]

    T_ALY_SPGetHistorical_Cmd

Page 56: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

PLC API

TF352056 Version: 1.0

Inputs

Name Type DescriptionsTopic T_MaxString Topic name of the recorded

Live StreamsLayout GUID Layout GUID of the recordingeMode  E_SymbolMode [} 65] Get all symbols or only a

subseteOutputFormat  E_RawDataFormat [} 65] Format of the returned data

(actually only “Bin” supported)nMaxSampleCount UDINT Max count of samples in one

payload packetnUserSampleTime DINT Sampletime in milliseconds of

the returned stream. (-1 usethe recorded sampletime)

nRecordID DINT Number of the recordnStartTimestamp LINT StartTimenEndTimestamp  LINT EndTimesResultTopic T_MaxString Topicname of the result

stream.arrSymbol ARRAY [0..255] OF T_ALY_Symbol

[} 59]If SymbolMode is Subset, onlythe list of this symbols will bereturned

Methods

Name Definition location DescriptionReset Reset all values inside of the

payload FBInit_JsonValue Inherited from T_ALY_JsonPayload

[} 60]Initialize FB with Json object

Init_String Inherited from T_ALY_JsonPayload[} 60]

Initialize FB with Json string

GetJsonLength Inherited from T_ALY_JsonPayload[} 60]

Get Length of Json payload

GetJsonString Inherited from T_ALY_JsonPayload[} 60]

Get Json payload as String

Development environment Target platform PLC libraries to includeTwinCAT v3.1.4022.25 PC or CX (x64, x86, ARM) Tc3_AnalyticsStorageProvider

Page 57: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

PLC API

TF3520 57Version: 1.0

7.1.1.2 T_ALY_SPRecordData_Cmd

Syntax

Definition:FUNCTION_BLOCK T_ALY_SPRecordData_Cmd EXTENDS T_ALY_JsonPayloadVAR_INPUT    sAlias  : T_MaxString;    sRecordName : T_MaxString;    eRecording : E_RecordMode;    sRecorder : GUID;    sRecorderAlias : T_MaxString;    sTopic: T_MaxString;    eDataFormat : E_RawDataFormat;    nDuration : DINT;    eRingBufferMode : E_RingBufferMode;    nRingBufferParameter : DINT;    eMode : E_SymbolMode;    sSymbolLayout : GUID;    arrSymbols : ARRAY [0..255] OF T_ALY_Symbol;END_VAR

Inheritence hierarchy

T_ALY_JsonPayload [} 60]

    T_ALY_SPRecordData_Cmd

Page 58: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

PLC API

TF352058 Version: 1.0

Inputs

Name Type DescriptionsAlias T_MaxString Alias name for the RecordingsRecordName T_MaxString Name for this recordeRecording  E_RecordMode [} 66] Start or Stop the recordingsRecorder GUID Individual GUID of the

recordersRecorderAlias T_MaxString Alias name for the recordersTopic T_MaxString Topic name of the live streameDataFormat E_RawDataFormat [} 65] Store data format. (actually

only Binary format issupported)

nDuration DINT Duration in minutes of therecording. (-1 unlimited)

eRingBufferMode E_RingBufferMode [} 67] Ringbuffer modusnRingBufferParameter DINT TimeBased => Parameter in

minutesDataBased => Parameter inMegabytes

eMode E_SymbolMode [} 65] Record all symbols or only asubset

sSymbolLayout GUIDarrSymbols ARRAY [0..255] OF T_ALY_Symbol

[} 59]If SymbolMode is Subset, onlythe list of this symbols will berecorded

Methods

Name Definition location DescriptionReset Reset all values inside of the

payload FBInit_JsonValue Inherited from T_ALY_JsonPayload

[} 60]Initialize FB with Json object

Init_String Inherited from T_ALY_JsonPayload[} 60]

Initialize FB with Json string

GetJsonLength Inherited from T_ALY_JsonPayload[} 60]

Get Length of Json payload

GetJsonString Inherited from T_ALY_JsonPayload[} 60]

Get Json payload as String

Development environment Target platform PLC libraries to includeTwinCAT v3.1.4022.25 PC or CX (x64, x86, ARM) Tc3_AnalyticsStorageProvider

7.1.1.3 T_ALY_SPCancel_Cmd

Syntax

Definition:

Page 59: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

PLC API

TF3520 59Version: 1.0

FUNCTION_BLOCK T_ALY_SPCancel_Cmd EXTENDS T_ALY_JsonPayloadVAR_INPUT    eCancelType : E_CancelType;    arrParameter : ARRAY [0..99] OF T_MaxString;END_VAR

Inheritence hierarchy

T_ALY_JsonPayload [} 60]

    T_ALY_SPCancel_Cmd

Inputs

Name Type DescriptioneCancelType E_CancelType [} 64]arrParameter ARRAY [0..99] OF T_MaxString

Methods

Name Definition location DescriptionReset Reset all values inside of the

payload FBInit_JsonValue Inherited from T_ALY_JsonPayload

[} 60]Initialize FB with Json object

Init_String Inherited from T_ALY_JsonPayload[} 60]

Initialize FB with Json string

GetJsonLength Inherited from T_ALY_JsonPayload[} 60]

Get Length of Json payload

GetJsonString Inherited from T_ALY_JsonPayload[} 60]

Get Json payload as String

Development environment Target platform PLC libraries to includeTwinCAT v3.1.4022.25 PC or CX (x64, x86, ARM) Tc3_AnalyticsStorageProvider

7.1.1.4 SubTypes

7.1.1.4.1 T_ALY_Symbol

Syntax

Definition:FUNCTION_BLOCK T_ALY_Symbol EXTENDS T_ALY_JsonPayloadVAR_INPUT    sName  : T_MaxString;    sBaseType  : T_MaxString;    nBitOffset : UDINT;    nBitSize   : UDINT;END_VAR

Page 60: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

PLC API

TF352060 Version: 1.0

Inheritence hierarchy

T_ALY_JsonPayload [} 60]

    T_ALY_Symbol

Inputs

Name Type DescriptionsName T_MaxString Name of the symbolsBaseType T_MaxString DataType of the symbolnBitOffset UDINT BitOffset of the symbolnBitSize UDINT BitSize of the symbol

Methods

Name Definition location DescriptionReset Reset all values inside of the

payload FBInit_JsonValue Inherited from T_ALY_JsonPayload

[} 60]Initialize FB with Json object

Init_String Inherited from T_ALY_JsonPayload[} 60]

Initialize FB with Json string

GetJsonLength Inherited from T_ALY_JsonPayload[} 60]

Get Length of Json payload

GetJsonString Inherited from T_ALY_JsonPayload[} 60]

Get Json payload as String

Development environment Target platform PLC libraries to includeTwinCAT v3.1.4022.25 PC or CX (x64, x86, ARM) Tc3_AnalyticsStorageProvider

7.1.1.5 [Internal]

7.1.1.5.1 T_ALY_JsonPayload

Syntax

Definition:FUNCTION_BLOCK INTERNAL T_ALY_JsonPayload

Page 61: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

PLC API

TF3520 61Version: 1.0

Methods

Name Definition location DescriptionReset Reset all values inside of the

payload FBInit_JsonValue Inherited from T_ALY_JsonPayload

[} 60]Initialize FB with Json object

Init_String Inherited from T_ALY_JsonPayload[} 60]

Initialize FB with Json string

GetJsonLength Inherited from T_ALY_JsonPayload[} 60]

Get Length of Json payload

GetJsonString Inherited from T_ALY_JsonPayload[} 60]

Get Json payload as String

Development environment Target platform PLC libraries to includeTwinCAT v3.1.4022.25 PC or CX (x64, x86, ARM) Tc3_AnalyticsStorageProvider

7.1.2 FB_ALY_StorageProvider

The FB_ALY_StorageProvider is a client FB to communicate with a storage provider instance. The FBprovide methods to trigger historical data or start /stop recordings.

Syntax

Definition:FUNCTION_BLOCK FB_ALY_StorageProviderVAR_INPUT    stConfig : ST_ALY_SP_Config;END_VARVAR_OUTPUT    bBusy  : BOOL;    bError : BOOL;    ipResultMessage  : I_TcMessage;    eConnectionState : ETcIotMqttClientState;END_VAR

Inputs

Name Type DescriptionstConfig ST_ALY_SP_Config [} 65] Struct to configure the FB

Page 62: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

PLC API

TF352062 Version: 1.0

Outputs

Name Type DescriptionbBusy BOOL TRUE as soon as a method of the function block is

active.bError BOOL Becomes TRUE as soon as an error situation

occurs.ipResultMessage I_TcMessage Message interface from the TwinCAT 3

EventLogger, which provides details on the returnvalue.

eConnectionState ETcIotMqttClientState Indicates the state of the connection between clientand broker as enumeration ETcIotMqttClientState.

Methods

Name Definition location DescriptionCall [} 64] Local Method for background communication with the

TwinCAT driver. The method must be calledcyclically.

Cancel [} 62] Local Method to cancel activities from the TwinCATAnalytics StorageProvider

GetHistoricalData [} 63] Local Method to order historical Data

StartRecord [} 63] Local Starts the recording of a live MQTT binary stream

StopRecord [} 63] Local Stops the selected recording

Development environment Target platform PLC libraries to includeTwinCAT v3.1.4022.25 PC or CX (x64, x86, ARM) Tc3_AnalyticsStorageProvider

7.1.2.1 Cancel

SyntaxMETHOD Cancel : BOOLVAR_INPUT    stCmd : REFERENCE TO T_ALY_SPCancel_Cmd;END_VAR

Inputs

Name Type DescriptionstCmd REFERENCE TO

T_ALY_SPCancel_Cmd [} 58]Json command to canceloperations of the TwinCATAnalytics Storage Provider

Return value

Name Type DescriptionCancel BOOL Is TRUE if done

Page 63: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

PLC API

TF3520 63Version: 1.0

7.1.2.2 GetHistoricalData

SyntaxMETHOD GetHistoricalData : BOOLVAR_INPUT    stCmd : REFERENCE TO T_ALY_SPHistorical_Cmd;END_VAR

Inputs

Name Type DescriptionstCmd REFERENCE TO

T_ALY_SPGetHistorical_Cmd [} 55]Json command to get historicaldata from TwinCAT AnalyticsStorage Provider

Return value

Name Type DescriptionGetHistoricalData BOOL Is TRUE if done

7.1.2.3 StartRecord

SyntaxMETHOD StartRecord : BOOLVAR_INPUT    stCmd : REFERENCE TO T_ALY_SPRecordData_Cmd;END_VAR

Inputs

Name Type DescriptionstCmd REFERENCE TO

T_ALY_SPRecordData_Cmd [} 57]Json command to start recording alive stream

Return value

Name Type DescriptionStartRecord BOOL Is TRUE if done

7.1.2.4 StopRecord

Page 64: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

PLC API

TF352064 Version: 1.0

SyntaxMETHOD StopRecord : BOOLVAR_INPUT    stCmd : REFERENCE TO T_ALY_SPRecordData_Cmd;END_VAR

Inputs

Name Type DescriptionstCmd REFERENCE TO

T_ALY_SPRecordData_Cmd [} 57]Json command to stop recording ofa live stream

Return value

Name Type DescriptionStopRecord BOOL Is TRUE if done

7.1.2.5 Call

SyntaxMETHOD Call : BOOL

Return value

Name Type DescriptionCall BOOL

7.2 Data types

7.2.1 E_CancelType

Syntax

Definition:TYPE E_CancelType :(    HistoricalData := 0,    AllRecordData)INT;END_TYPE

Parameter

Name DescriptiomHistoricalData Canceled the selected historical data streamAllRecordData Canceled all running recordings

Page 65: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

PLC API

TF3520 65Version: 1.0

7.2.2 E_RawDataFormat

Syntax

Definition:TYPE E_RawDataFormat :(    Bin := 0,    Json)INT;END_TYPE

Parameter

Name DescriptiomBin Analytics Binary Stream FormatJson TwinCAT Json Format (actually not supported)

7.2.3 E_SymbolMode

Syntax

Definition:TYPE E_SymbolMode :(    All := 0,    Subset)INT;END_TYPE

Parameter

Name DescriptiomAll All symbols of the stream will be usedSubset Only a subset of symbols will be used

7.2.4 ST_ALY_SP_Config

Syntax

Definition:TYPE ST_Msg :STRUCT    sMainTopic     : T_MaxString;    sProviderGuid  : GUID;    stConnSettings : ST_ConnectionSettingsEND_STRUCTEND_TYPE

Page 66: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

PLC API

TF352066 Version: 1.0

Parameter

Name Type DescriptiomsMainTopic T_MaxString The main topic where the TwinCAT

Analytics Storage Provider islocated on the message broker

sProviderGuid GUID The individual GUID of theTwinCAT Analytics StorageProvider Instance

stConnSettings ST_ConnectionSettings [} 66] MQTT connection settings toconnect with the message broker

7.2.5 ST_ConnectionSettings

Syntax

Definition:TYPE ST_ConnectionSettings :STRUCT    sHostName   : T_MaxString;    nHostPort   : UINT := 1883;    sUserId     : T_MaxString;    sPassword   : T_MaxString;    bWithCertificate : BOOL := BOOL;    sCA     : T_MaxString;    sCert   : T_MaxString;    sKey    : T_MaxString;sKeyPwd : T_MaxString;END_STRUCTEND_TYPE

Parameter

Name Type DescriptiomsHostName T_MaxString sHostName can be specified as name or as IP

address. If no information is provided, the localhost is used.

nHostPort UINT The host port can be specified here. The default is1883.

sUserId T_MaxString Optionally, a user name can be specified.sPassword T_MaxString A password for the user name can be entered

here.bWithCertificate BOOL If TRUE the certificates will be used for

communicationsCA T_MaxString Certificate of the certificate authority (CA)sCert T_MaxString Client certificate to be used for authentication at

the brokersKey T_MaxString Private key of the clientsKeyPwd T_MaxString Password of the private key, if applicable

7.2.6 E_RecordMode

Syntax

Definition:TYPE E_RecordMode :(    Start := 0,

Page 67: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

PLC API

TF3520 67Version: 1.0

    Stop)INT;END_TYPE

Parameter

Name DescriptiomStart Starts the recording of the configured recordStop Stops the recording

7.2.7 E_RingBufferMode

Syntax

Definition:TYPE E_RingBufferMode:(    None := 0,    TimeBased,         DataBased)INT;END_TYPE

Parameter

Name DescriptiomNone Recording without ringbuffer modeTimeBased Ringbuffer based on a given time periodeDataBased Ringbuffer based on a given max data size

Page 68: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Appendix

TF352068 Version: 1.0

8 Appendix

8.1 FAQ - frequently asked questions and answersIn this section frequently asked questions are answered in order to make your work with TwinCAT AnalyticsStorage Provider (ASP) easier. If you have further questions, please contact our support [email protected].

How I can manage the table schema of MS SQL with ASP? [} 68]

Can I control the Storage Provider in a programable way? [} 68]

Is it possible to store also results from Analytics Runtime? [} 68]

?How I can manage the table schema of MS SQL with ASP?

!You do not have to worry about the table schema. This is completely taken over by the Analytics StorageProvider. You just have to specify on which database server the data should be stored. If you like to see datain your own table structure you have to stream the data into a TwinCAT Analytics Runtime and write the datain your structure by the TwinCAT Database Server.

?Can I control the Storage Provider in a programable way?

!Yes, by the PLC interface for the TwinCAT Storage Provider. You can start/stop recordings or get historicaldata (raw data or result data).

?Is it possible to store also results from Analytics Runtime?

!Yes, this is possible. Therefore you can choose by generating the Analytics Runtime from AnalyticsWorkbench configurator that the results should be send to a MQTT Message Broker. This data stream canbe taken by the Storage Provider.

Page 69: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT
Page 70: Manual TwinCAT 3 Analytics Storage Provider · 2020. 8. 12. · Technical data LibraryTF3520 TC 3 Analytics Storage Provider Target system Windows 7, Windows 8, Windows 10 Min. TwinCAT

Beckhoff Automation GmbH & Co. KGHülshorstweg 2033415 VerlGermanyPhone: +49 5246 [email protected]

More Information: www.beckhoff.com/tf3520/