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

Events and Subscriptions for Timers and Schedulers

Highlighted
Level 9

Events and Subscriptions for Timers and Schedulers

Events

 

  • Timers and Schedulers both come with a specific Event inherited from the Thing Template:
    • Timer
    • ScheduledEvent
  • Both have a Data Shape allowing to capture the timestamp of when the Event was actually fired.
  • Events in ThingWorx are triggered when a specific condition is met. In this context the condition is met and the Event is fired when a Timer has expired or a Scheduler's time is reached.
  • Once an Event is triggered, Subscriptions will take care of executing custom Services to react to the Event.

Subscriptions

 

  • Subscriptions listen to Events and can be used to react to certain Events with running custom Service scripts.
  • To follow-up on Timers and Schedulers, a new Subscription must be created, listening to any related Event fired.
  • Add a new Subscription to the Thing with

 

 AddMySubscription.png

 

  • As the Subscription is usually listening to the Thing that it is configured on, the Source has to be left empty. When listening to other Entities' Subscriptions the corresponding Entity can be picked in the Source Entity picker.
  • Ensure to check the Enabled checkbox to actually enable the Subscription and allow it for executing code in the Script area.
  • The following Script will log into the ScriptLog once the Timer Event is fired

 

FireTimerSubscription.png

 

  • The following Script will log into the ScriptLog once the ScheduledEvent Event is fired

 FireScheduledEventSubscription.png