Formulas

Create notification and automatic intervention formulas using TAG and Advanced TAG data. Prevents unnecessary consumption. Notifies important situations early.

Overview

The Formulas module is the brain of the Smart Energy system. With formulas, you can monitor TAG values, create conditions and perform automatic interventions. For example, you can automatically shut down compressors when production stops or shut down unnecessarily running motors during off-hours.

Important Note

Formulas can automatically intervene with PLCs. Test each formula carefully. Initially keep Writing Mode off, monitor only notifications and activate automatic intervention after ensuring the formula works correctly.

Key Features

  • TAG and Advanced TAG usage
  • Mathematical and logical operators
  • Automatic TAG writing (with Writing Mode)
  • Notification sending (Success/Warning messages)
  • Flexible scheduling (Storage Schedule)
  • Test by monitoring formula results
  • Detailed tracking with Notification Logs

Formula Builder - Why Important?

Formula Builder Advantages

Formula Builder is a visual tool that allows you to easily create complex formulas. You can set up powerful automations with drag-and-drop logic without writing code.

🎯 Ease of Use

  • ✅ No coding knowledge required
  • ✅ Visual calculator buttons
  • ✅ TAG selection with dropdown
  • ✅ Formula preview
  • ✅ Error checking

⚡ Powerful Features

  • ✅ Mathematical operations
  • ✅ Comparison operators
  • ✅ Logical operators (AND, OR)
  • ✅ Parentheses support
  • ✅ Multiple TAG usage

🔄 Automation

  • ✅ Automatic intervention (Writing Mode)
  • ✅ Notification generation
  • ✅ Flexible scheduling
  • ✅ Test by monitoring notifications
  • ✅ Real-time monitoring

💰 Business Value

  • ✅ Energy savings
  • ✅ Cost reduction
  • ✅ Efficiency increase
  • ✅ Error prevention
  • ✅ 24/7 automatic control

📝 Formula Examples

1. Simple Mathematical Operation:

[Temperature] + 10

Add 10 degrees to temperature value

2. Average Calculation:

([Pressure1] + [Pressure2]) / 2

Average of two pressure sensors

3. Conditional Control:

[Value] > 100 && [Status] = 1

If value is greater than 100 AND status is 1

4. Complex Calculation:

[Tag1] + ([Tag2] * 2)

Tag1 plus twice Tag2

5. Energy Optimization:

[CompressorPressure] > 8 && [ProductionStatus] = 0

If compressor pressure is high while production stopped → Turn off compressor

6. Multiple Conditions:

([Temp] > 80 || [Pressure] > 10) && [SafetyStatus] = 1

If temperature or pressure is high AND safety is active

Supported Operators

Arithmetic Operators

  • + Addition
  • - Subtraction
  • * Multiplication
  • / Division
  • % Modulo (remainder)
  • () Parentheses

Comparison Operators

  • == Equal
  • != Not equal
  • > Greater than
  • < Less than
  • >= Greater or equal
  • <= Less or equal

Logical Operators

  • && AND
  • || OR
  • ! NOT

Formula Structure

How Does Formula Work?

Formulas perform mathematical and logical operations using TAG values. Formula result returns TRUE or FALSE and action is taken according to this result.

Formula Examplesjavascript
// Kompresör Optimizasyonu
[CompressorPressure] > 8.5 && [ProductionStatus] = 0

// Aydınlatma Kontrolü
[LightSensor] < 300 && [WorkingHours] = 0

// Soğutma Sistemi
[Temperature] > 75 && [CoolingFan] = 0

Formula Components

  • Formula Name: Formula name
  • Formula Text: Mathematical/logical expression
  • Success Message: Message for TRUE result
  • Warning Message: Message for FALSE result
  • Writing Mode: Automatic TAG writing (optional)
  • Scheduling: Run time

Operating Modes

  • Notification Only: Writing Mode off, only generates notification
  • Automatic Intervention: Writing Mode on, writes to TAGs
  • Scheduled Run: Runs at specific times with Scheduling
  • Continuous Monitoring: Checks at each cronjob run

Writing Mode

TAG Writing Based on Formula Results

With Writing Mode feature, you can write different values to different TAGs based on formula result (true/false). This feature is ideal for automatic control systems.

StatusDescriptionSettings
True ResultWhen formula returns trueValue to write and target TAG
False ResultWhen formula returns falseValue to write and target TAG
Target TAGTAG to writeMust be Writable

Örnek Senaryo:

Formül: Temperature > 80

  • True ise: CoolingFan TAG'ine 1 yaz (Fanı aç)
  • False ise: CoolingFan TAG'ine 0 yaz (Fanı kapat)

Scheduling Configuration

Formula Run Time

Determines how often formulas will run. Has same structure as Storage Schedule in TAGs. Offers flexible scheduling options with advanced cronjob structure:

Schedule TypeDescriptionUsage Example
SecondRun every X secondsCheck every 10 seconds for critical formulas
MinuteRun every X minutesEvery 5 minutes for compressor control
HourlyRun every X hoursEvery 1 hour for lighting control
DailyRun at specific time each dayAt 23:59 each day for daily reporting
WeeklyRun on specific days of weekAt 08:00 every Monday for weekly maintenance check
MonthlyRun on specific day of monthOn 1st of each month for monthly optimization
CustomRun with custom time rangesWorking hours: Every 10 minutes between 08:00-17:00 Mon-Fri

Custom Scheduling Example

With Custom option, you can define different time ranges for each day:

  • Working hours: Check every 5 minutes between 08:00-17:00 Mon-Fri
  • Off hours: Check every 30 minutes between 17:00-08:00 Mon-Fri
  • Weekend: Check every 1 hour Sat-Sun

Recommendations

  • Use short intervals (1-5 minutes) for critical formulas
  • Long intervals (1 hour+) are sufficient for informational formulas
  • Define different intervals for working hours and off hours
  • Very frequently running formulas can affect system performance

Notification System

Notification Sending

Each formula result is automatically recorded in Notification Logs. Notifications can be viewed in two ways:

Notification Logs:

  • All formula results
  • Timestamped records
  • Detailed log information

Notification List (Error List):

  • Filtered notifications
  • Repeated records merged
  • Only active issues

Creating New Formula

Step by Step Formula Creation

  1. Go to Formula List page
  2. Click "Add New Formula" button
  3. Enter formula name
  4. Create formula with Formula Builder (TAG selection + operators)
  5. Write Success Message (for TRUE result)
  6. Write Warning Message (for FALSE result)
  7. Set Scheduling Configuration (how often to run)
  8. Keep Writing Mode off (Writing Mode is off as long as target TAG is not set)
  9. Save and activate formula
  10. Monitor results from Notification Logs (A few hours)
  11. If formula works correctly, activate Writing Mode

Testing Formula

Safe Testing with Notifications

There is no special "Test Mode" for testing new formulas. Instead, you can safely test by keeping Writing Mode off when creating the formula. Writing Mode is off as long as target TAG is not set.

Test Process

  1. Writing Mode Off: Don't activate Writing Mode when creating formula
  2. Notification Messages: Write Success and Warning messages in detail
  3. Activate Formula: Save and activate formula
  4. Monitor Notification Logs: Track formula results from Notification Logs
  5. Verification: Check that formula returns SUCCESS or WARNING message in expected situations
  6. Activate Writing Mode: If formula works correctly, activate Writing Mode

Advantages

  • ✅ No intervention to PLC
  • ✅ You can safely test formula logic
  • ✅ You see all results in Notification Logs
  • ✅ You detect errors early
  • ✅ You can test as much as you want

Recommendations

  • Run new formulas for a few hours with Writing Mode off
  • Test different scenarios (working hours, weekend, night)
  • Fix formula if there are unexpected results in Notification Logs
  • Use longer test periods (at least 24 hours+) for critical systems
  • Monitor closely for first few days even after activating Writing Mode

Example Use Cases

Scenario 1: Compressor Optimization

Situation: Compressor still running when production stops

Formula: [CompressorPressure] > 8.5 && [ProductionStatus] = 0

Action: Write 0 to CompressorControl TAG with Writing Mode (Turn off compressor)

Result: Unnecessary energy consumption prevented, cost reduced

Scenario 2: Off-Hours Lighting

Situation: Some areas remain lit when shift ends

Formula: [WorkingHours] = 0 && [LightStatus] = 1

Action: Write 0 to LightControl TAG with Writing Mode (Turn off lights)

Result: Unnecessary off-hours lighting prevented

Scenario 3: Temperature Control

Situation: Equipment temperature approaching critical level

Formula: [Temperature] > 75 && [CoolingFan] = 0

Action: Write 1 to CoolingFan TAG with Writing Mode (Turn on fan)

Result: Equipment protected from overheating, failure prevented

Scenario 4: Motor Protection

Situation: Motor current above normal

Formula: [MotorCurrent] > 50 && [MotorStatus] = 1

Action: Only send notification (Writing Mode off)

Result: Operator alerted, motor damage prevented