beckhoff TE1000 TwinCAT 3 — 6.9.2 Creating and handling TwinCAT Analytics projects

Samples | Measurement Creating a TwinCAT Measurement project TwinCAT Measurement is a global "container" that can host one or more measurement projects, e.g. a TwinCAT Scope configuration. Similar to a regular TwinCAT configuration, each project is first described with the aid of a template file. This template file is used when adding a new project to the solution, which can be done by calling the AddFromTemplate() method from the Visual Studio DTE object. Note that this procedure is the same when adding a regular TwinCAT project.

The following code snippet assumes that you have already acquired a DTE instance and created a Visual Studio solution, as shown in our article about accessing TwinCAT configurations. A reference to the DTE instance is stored in the "dte" object. EnvDTE.Project scopeProject = dte.Solution.AddFromTemplate(template, destination, name); Creating, accessing and handling a TwinCAT Analytics configuration A TwinCAT Analytics project represents an analysis configuration. This means that all elements inserted into the project are subject to the same analysis settings.

You can add an analytics project via the Automation Interface by specifying the appropriate "TwinCAT Analytics Project" template when adding a project using the AddFromTemplate() method, as described above. The EnvDTE.Project element thus added can then be mapped to the IMeasurementAnalyticsProject interface, which provides the following methods: Creating, accessing and handling networks A TwinCAT Analytics network represents the level at which function blocks are created, managed and visualized. A network can contain multiple instances of different functions, as well as other networks as sub-networks. TE1000 289 Version: 1.7.0 int StartAnalytics() Starts the analysis process.

int StopAnalytics(); Stops the analysis process. int AddReferencedScope(); Adds an instance of a TwinCAT Scope project to the solution and links the analytics elements. The TwinCAT Scope instance can be adapted with the IMeasurementScope interface via Automation Interface. int ChangeName(string name); Method of changing the project name. int ShowControl(); Brings the Microsoft Visual Studio® Editor to the foreground to display the Analytics project. int CloseControl(); Closes the editor. int GetAvailableModules(out Hashtable modules); Fills a hash table with the data from the analytics engine modules provided. The hash table might look like this:

{02040109-0000-0000-f000-000000000064} "Min Max Avg 1Ch" {02040103-0000-0000-f000-000000000064} "Edge Counter OnOff 2Ch" {02040102-0000-0000-f000-000000000064} "Edge Counter OnOff 1Ch" {02040101-0000-0000-f000-000000000064} "Edge Counter 1Ch" The GUIDs are necessary for later generation of the analysis functions. int AddNetwork(out ProjectItem item, string name = ""); Adds a network to the Analytics project and issues the instance of the EnvDTE.ProjectItem with which you can continue. The object EnvDTE.ProjectItem.Object can be mapped to the IMeasurementAnalyticsNetwork interface.