Transformer - Build a data loading program

Transformer is a DLL (Dynamic Link Library) containing helper methods for sending structured data to your Network. You can also send data to Doodlebase by building your own XML data structures and send https POST messages.

The following programming environments work well with Transformer:

  • LabVIEW by National Instruments.
  • The .NET framework by Microsoft.

Prerequisites

The following examples utilize the Transformer library and are written in C#. You should have the latest version of Microsoft Visual Studio installed on your computer. You can download a free version of Visual Studio called Visual Studio Community by clicking the link here. The Transformer library is also loaded, and a reference to the library is added to your project.

Data Collection Goals and Options

Your data loading program should be responsible for the following activities:

  • Parsing Raw Data generated by your process and devices or machines.
  • Transforming Raw Data into structured XML files called events.
  • Adding Files such as images, PDF documents, audio clips, etc.
  • Loading data to your Network.
  • Handling Network connectivity issues.
  • Verifying data was properly loaded to your Network.

Sample Console Application Using Transfomer

The sample console application below demonstrates how to achieve the program goals stated above using Transfomer methods and properties. The sample program creates a file compatible with the simple device model schema shown on the Schema page.

static void Main(string[] args)
{
    // Set Event params.
    // These are provided by the Doodlebase WebApp when you setup your Routes
    string routeKey = "14b5a20a-5ce6-4a0e-9cd7-3bacc127694e";
    string password = "4190fedf-ab1d-417e-a03b-22dbbb10f267";
    string destination = "https://api.doodlebase.io/data/v1/events";

    // Create Event
    var tEvent = new Event(routeKey, password, destination);

    // Add Elements to Event
    var tSession = new Element("Session", tEvent);
    tSession.AddData("dateTimeUtc", "2024-01-12T09:04:00.0000000Z");
    tSession.AddData("machineName", "ESS SN 13");

    var tDevice = new Element("Device", tEvent);
    tDevice.AddData("name", "serialnumber");
    tDevice.AddData("value", "C226-97456");

    var tVariable = new Element("Variable", tEvent);
    tVariable.AddData("name", "temperature");
    tVariable.AddData("value", "200");
    tVariable.AddData("unit", "C");

    tVariable = new Element("Variable", tEvent);
    tVariable.AddData("name", "duration");
    tVariable.AddData("value", "400");
    tVariable.AddData("unit", "milliseconds");

    // Write XML to Console
    Console.WriteLine(tEvent.Write());
    Console.ReadLine();

    // Write XML file to disk and check if loaded properly
    tEvent.WriteXmlFile(@"D:\Data\TransformerData", "MyXmlFile.xml");

    // Load XML to Doodlebase
    var loadInfo = tEvent.LoadAsync().Result;
    
    Console.WriteLine("File Load Result: " + loadInfo.Result);
    Console.ReadLine();

    // Package Event with another file and a directory (maximum package size is 5MB)
    var pkg = new Package(tEvent);
    pkg.AddFile(@"D:\Data\TransformerData\test.csv");
    pkg.AddDirectory(@"D:\Data\TransformerData\PackageTest");

    // Write zipped package to disk
    pkg.WriteZipFile(@"D:\Data\TransformerData", "MyZippedPackageTest.zip");

    // Load package to Doodlebase and check if loaded properly
    var loadPkgInfo = pkg.LoadAsync().Result;
    Console.WriteLine("Package Load Result: " + loadPkgInfo.Result);
    Console.ReadLine();
}

Next Steps

Explore Viewing your data.


© - Schemaport LLC. Doodlebase is a registered trademark of Schemaport LLC | Technology Patent Pending