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] + 10Add 10 degrees to temperature value
2. Average Calculation:
([Pressure1] + [Pressure2]) / 2Average of two pressure sensors
3. Conditional Control:
[Value] > 100 && [Status] = 1If 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] = 0If compressor pressure is high while production stopped → Turn off compressor
6. Multiple Conditions:
([Temp] > 80 || [Pressure] > 10) && [SafetyStatus] = 1If 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.
// Kompresör Optimizasyonu
[CompressorPressure] > 8.5 && [ProductionStatus] = 0
// Aydınlatma Kontrolü
[LightSensor] < 300 && [WorkingHours] = 0
// Soğutma Sistemi
[Temperature] > 75 && [CoolingFan] = 0Formula 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.
| Status | Description | Settings |
|---|---|---|
| True Result | When formula returns true | Value to write and target TAG |
| False Result | When formula returns false | Value to write and target TAG |
| Target TAG | TAG to write | Must be Writable |
Örnek Senaryo:
Formül: Temperature > 80
- True ise:
CoolingFanTAG'ine1yaz (Fanı aç) - False ise:
CoolingFanTAG'ine0yaz (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 Type | Description | Usage Example |
|---|---|---|
| Second | Run every X seconds | Check every 10 seconds for critical formulas |
| Minute | Run every X minutes | Every 5 minutes for compressor control |
| Hourly | Run every X hours | Every 1 hour for lighting control |
| Daily | Run at specific time each day | At 23:59 each day for daily reporting |
| Weekly | Run on specific days of week | At 08:00 every Monday for weekly maintenance check |
| Monthly | Run on specific day of month | On 1st of each month for monthly optimization |
| Custom | Run with custom time ranges | Working 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
- Go to Formula List page
- Click "Add New Formula" button
- Enter formula name
- Create formula with Formula Builder (TAG selection + operators)
- Write Success Message (for TRUE result)
- Write Warning Message (for FALSE result)
- Set Scheduling Configuration (how often to run)
- Keep Writing Mode off (Writing Mode is off as long as target TAG is not set)
- Save and activate formula
- Monitor results from Notification Logs (A few hours)
- 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
- Writing Mode Off: Don't activate Writing Mode when creating formula
- Notification Messages: Write Success and Warning messages in detail
- Activate Formula: Save and activate formula
- Monitor Notification Logs: Track formula results from Notification Logs
- Verification: Check that formula returns SUCCESS or WARNING message in expected situations
- 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