Mapping of the logger function

This documentation describes how to send or store data in Analytics format using the Analytics Data Exchange API.

License

A license for the TwinCAT 3 Analytics Logger is required for writing data in TwinCAT Analytics format. The Data Exchange API can be tested with a 7-day license.

Create and configure a data storage:

To send or save data in Analytics format, the first step is to create a builder to configure the data storage:

Factory = SinkFactory()

Builder = Factory.ToFile(FilePath)

Builder = Factory.ToMessageBroker(Broker, 1883)

The different builders provide different methods for configuration. Symbols can be added using the "WithSymbol" method. Any number of symbols can be used. Symbol implementations are already available for most basic data types. Structured data types and arrays can also be implemented.

class MyStruct(Struct):

def __init__(self, name : str):
self.b = Bool("b")
self.i64 = Int64("i64")
self.f64 = Real64("f64")
super().__init__(name)

TestValInt = Int32("i32")
TestValFloat = Real32("f32")
TestValArray = Array("arrf64", Real64(), [10])
TestValStruct = MyStruct("myStruct")
Builder.WithSymbol(TestValInt)
Builder.WithSymbol(TestValFloat)
Builder.WithSymbol(TestValArray)
Builder.WithSymbol(TestValStruct)

Once the builder is fully configured, a new sink is created using the Build method, which is initialized with InitWrite. The current value of the symbols is then written using the Write method. The values of the symbols can be updated between several calls of the Write method. Once all the data has been written, the write process is ended with CompleteWrite:

SampleCount = 32

TestValInt.Value = 1000
TestValFloat.Value = 0.25
Sink.Write()
for i in range(0, SampleCount):
TestValInt.Value += 1
TestValFloat.Value += 0.25
Sink.Write()
Sink.CompleteWrite()

Sample:

You can find the complete sample here: SampleLogger.zip