PlantLogic: What is PlantLogic MES? - ResgreenGroup/Botway-Documentation GitHub Wiki

PlantLogic MES Overview

Table of Contents


PlantLogic

PlantLogic Introduction

PlantLogic is a Manufacturing Execution System (MES) that enables high-level automation through triggers and logic statements. The software intends to allow automation at a high level, executed through various triggers and logic statements. These triggers and logic statements act off of elements in the DataStore, where all data is stored.

Understanding the DataStore

PlantLogic maintains an array of data points called the DataStore. Each data point is stored as a key/value pair. The DataStore is shared by all components of the Trunk. It is where data that comes in thru Roots are stored. Data points can be used in a Branch's trigger logic or created and updated from a Leaf. The DataStore can be thought of as the "working memory" of PlantLogic. You will use DataStore items as you would variables in a programming language.

Every item in the DataStore has:

  • Key – the name/identifier
  • Value – the data itself

Example:
If you need to trigger off of Sys.Time, you will use "Sys.Time" in your logic statement. This value updates from your computer’s clock.

There is no size limit to the DataStore. You can trigger off any element as long as it exists there.


Trunk Structure

The Trunk organizes all nodes in the tree (Roots, Branches, Leafs).
There’s only one tree (and therefore one trunk) per file.
You can have unlimited Roots, Branches, and Leafs.


Roots and Data Integration

Roots allow data to flow into and out of PlantLogic. It is where connections to the "outside" are made. PlantLogic comes with a collection of Roots for connecting to common data sources.

Root Type Description
DataStore Root Read from and write to the internal DataStore (always exists).
MQTT Root Receive and write data through an MQTT broker.
API Root Receive and write data through an API.
OPC Root Receive and write data through an OPC server.
SQL Root Receive and write data through an SQL server.
Socket Root Receive data through a WebSocket.
File Read Watch for and parse files in a specific location.
File Write Root Write files in a specific location (various formats).
Messaging Root Send email to a list or recipients (always exists).

3rd Party Roots and Extensibility

PlantLogic is also extensible and supports 3rd party Roots. Roots can be written in any language that can produce a .NET DLL. In this way, PlantLogic can be expanded to work with any data source that holds the data you need.


Branches: Logic Evaluation

Branches are the decision points. This is where PlantLogic decides whether or not to execute actions. In each Trunk cycle, PlantLogic will test each Branch's logic, one-by-one, in the order they appear in the Trunk. If a Branch's logic evaluates to TRUE, it will trigger its actions (Leafs). The Leafs are triggered one-by-one in the order they are listed.

Branch settings:

  • One-Shot – Triggers only once after evaluation is TRUE. Will not trigger again until the logic goes FALSE and back to TRUE
  • Continue After Fail – Continues triggering remaining Leafs even if one fails.

Leafs: Data Output

Leafs are the workers of PlantLogic. They perform data operations on the internal DataStore or on external data sources (thru an associated Root). With access to the DataStore, Leafs can output data points, in various structures, to many destinations. For instance, a Leaf can be configured to: create or update a DataStore item, create files and populate them with data, publish messages on a MQTT Topic, write a new record to an SQL data table, etc... Output is based on the associated Root. Depending on the selected Root, various parameters will be specified to support the targeted connection.

Root Type Key Meaning Value Meaning
DataStore Root Key of DataStore item Value of DataStore item
MQTT Root MQTT topic Value to write to MQTT
API Root Cosmetic/notation Full API call URL
OPC Root OPC label OPC tag being written
File Write Root Key of value being written Value being written
SQL Root SQL field Field value
Socket Root JSON key JSON value
Messaging Root Cosmetic/notation Email recipient(s)

Creating and Running a PLT

  1. Open the File menu (or press Alt + F).
  2. Create a new PLT project.
  3. Add Roots, Branches, and Leafs using the toolbar.
  4. Press the Run button to start the project.

Adding Branches:

  • Attach to the Main Trunk.
  • Set trigger logic (C#-based).
  • Optional: One-Shot and Continue After Fail.

Adding Roots:

  • Select a Root type from the list.
  • Enter required parameters.
  • Optionally add a prefix for all received data keys.

Adding Leafs:

  • Select a Branch to attach to.
  • Choose a Linked Root.
  • Set parameters and data to write.

Logic Triggers

Each branch has a single trigger. The logic for this trigger is based on the C# language and will always evaluate to TRUE or FALSE. It can be a simple as DS['Item1'] > 10 or as complex as a full C# code segment:

try {
   var now = DateTime.Now;
   var lastTime = DateTime.Parse(DS["Sensor.LastTime"].ToString());
   var lastValue = Convert.ToDouble(DS["Sensor.LastValue"]);
   var currentValue = Convert.ToDouble(DS["Sensor.CurrentValue"]);
   var deltaTime = (now - lastTime).TotalSeconds;
   var rate = (currentValue - lastValue) / deltaTime;
   return rate > 0.5;
} catch {
    return false;
}

Example Triggers

Description Logic
Every 5 seconds DateTime.Parse(DS["Sys.Time"].ToString()).Second % 5 == 0
Every 10 min, on 10th sec DateTime.Parse(DS["Sys.Time"].ToString()).Minute % 10 == 0 && DateTime.Parse(DS["Sys.Time"].ToString()).Second == 10
Robot Status (tag 304) (DS["BigBuddy.204.statusReport.Tag"]).ToString() == "304"
Task complete, no error DS["BigBuddy.Task.Status"].ToString() == "COMPLETE" && DS["BigBuddy.Task.Error"].ToString() == "0"
File deleted trigger DS["204.CLEAR.XML"].ToString() == "deleted"
API ACK response DS["203 Go"].ToString() == "ACK"
StatusReport with time restriction return (!(string.IsNullOrEmpty(DS["BigBuddy.204.statusReport.timestamp"]?.ToString()))) && DateTime.Parse(DS["Sys.Time"].ToString()).Second % 2 == 0;

Note:
The DataStore Root and Messaging Root always exist and cannot be deleted.
Deleting a Branch deletes all Leafs attached to it.

⚠️ **GitHub.com Fallback** ⚠️