• Articles
  • API reference
  • Previous Versions
Show / Hide Table of Contents
  • Introduction
  • How to
    • Implement recipe management
    • Connect to a influx database
    • Invoke C# from PLC
    • How to access TwinController
    • How to write documentation blocks
    • How to make Inxton compiler ignore unknown syntax
    • Cyclic, Synchronous and Batched access
    • How to generate UI
    • How to include TcOpen in your project 🔗
    • Video how tos 🔗
  • Core
    • Introduction
    • Compiler
      • Intro to compiler
      • Added Properties
      • Attributes
      • Documentation Block
      • Fake Comments
      • Ignoring Parts Of Code
      • Twin Controller
      • Twin Objects
      • Twins
    • Connector
      • About connector
      • Primitive Twins
  • Essentials
    • Introduction
    • Rendering engine
      • Generating user interface
      • How it works
      • Presentation types
    • Controls
      • Controls
    • Styling your app
      • Styling your application
      • Color system
      • How to apply styles
      • Override default colors
      • Buttons
    • Conmponents convetions 🔗
  • TcOpen 🔗
    • Messaging, Logging, sequences 🔗

InfluxDB

Video guide.

In this example, we collect data from InfluxData PLC structure. Any primitive (base type) items added to this structure will be collected automatically into the database.

FB fbInfluxPerformanceLogging has simple logic that populates InfluxData structure with values and executes a remote request to the .net application that takes care of storing data into the database.

There are two C# projects Console and Wpf applications. The console application runs fast data collection cycles. The WPF application also displays some online data and data from the database.

Solution WPF Console

How it operates

// fbInfluxPerformanceLogging (BODY)
IF(_logStart <= _logDone) THEN
    _logStart := _logStart + 1; // .net app is subscribed for this variable change.
END_IF
private void Register()
{
    // Gets object from the PLC twin
    var influx = HansPlc.Entry.HansPlc.prgInflux._influx;

    // Let's retrieve all value items from the our 'influx._data' twin.
    var primitives = influx._data.GetValueTags();

   // Subscribe for the change of the '_logStart' variable
   influx._logStart.Subscribe((sender, a) =>
   {
        SavePoint(); // for implementation of SavePoint() method see the code example.
   });
}

How to run InfluxDB

For this example to work, you will need to set-up a working instance of the InfluxDB database. Visit influxdata and download influxdb; these examples were tested with v1.8.0. You will also need to run the server instance with a config file that has flux-enabled set to true in the http section of the config file.

[http]
  # Determines whether HTTP endpoint is enabled.
  enabled = true

  # Determines whether the Flux query endpoint is enabled.
  flux-enabled = true

  # Determines whether the Flux query logging is enabled.
  # flux-log-enabled = false

For the server to use the config file, you will need to run it with parameters.

PS [YourDrive]:[InfluxDB bin directory]\> .\influxd.exe run -config .\influxdb.conf
  • Improve this Doc
In This Article
Back to top

Generated by DocFX | Developed with ❤ at MTS - putting the heart into manufacturing.