cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Rule Timers on the Axeda Platform

No ratings
Sometimes you need to do something on a schedule. Axeda Platform is primarily focused on processing events as they happen. But in the case where some action needs to take place periodically, there are Rule Timers. A Rule Timer has a schedule to run, and a list of rules its associated with.

Rule Timer Schedules

A schedule is defined by a string using the cron syntax. This syntax is extremely flexible and powerful, but can be hard to understand. The fields are as follows:

  1. Seconds (0-59)
  2. Minutes (0-59)
  3. Hours (0-23)
  4. Day-of-Month (1-31)
  5. Month (1-12) OR jan,feb,mar, apr ...
  6. Day-of-Week (0-7) (Sunday is 0 or 7) OR sun, mon, tue, wed, thu, fri, sat
  7. Year (optional field)

Some examples

"0 0 12 ? * WED" - which means "every Wednesday at 12:00 pm"

"0 0/5 * * * ?" - means Fire every 5 minutes

"0 0 2 * * ?" - means Fire at 2am every day

Note: Rule Timer schedules are in GMT/UTC.


Associated Expression Rules

The Rule timer has no other purpose but to run Expression Rules. These rules can be System or Asset. SystemTimer means an Expression Rule with type set to SystemTimer. This rule will be run once per scheduled time. A system timer can run a script to export data every day, or enable some rules at the end of a beta program.

The other type is an Expression Rule with type AssetTimer. This rule will be run for all associated assets at the scheduled time. Say you want to save the max speed every day for a fleet of vehicles. You have an Expression Rule that's associated with the model Vehicle. The rule  A Rule Timer is set to run every day.

Rule SetMax
Type Data
If: Speed > MaxSpeed
Then: SetDataItem("MaxSpeed", Speed)
Rule DailyMax
Type AssetTimer
If MaxSpeed > 0
Then: SetDataItem("DailyMax", MaxSpeed) && SetDataItem("MaxSpeed", 0)
Associated to Vehicles
RuleTimer NightlyUpdate
Schedule "0 0 9 * * * ?"
Associated rule: DailyMax

The SetMax rule stores the max speed in a dataitem for each Vehicle asset. The NightlyUpdate timer runs at 9am UTC (which is 3am Eastern US, and midnight PST.) It writes the max into a DailyMax dataitem and clears the MaxSpeed to get ready for another day. The effect of the timer is that each Vehicle asset will process an event and run any rules that apply to it.

Note! If you create the MaxSpeed dataitem through the model wizard, it doesn't have an initial value! So the rule IF Speed > MaxSpeed will not do the comparison until the first day when the timer sets its value to be 0.

Version history
Last update:
‎Dec 20, 2017 11:14 AM
Updated by:
Labels (1)