/usr/share/cain/simulation/TriggerEvent.py is in cain 1.9-8.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | """Implements the TriggerEvent class."""
from Event import Event
from math import *
class TriggerEvent(Event):
def __init__(self, model, assignmentString, triggerExpression, delay,
useValuesFromTriggerTime):
Event.__init__(self, model, assignmentString)
self.triggerExpression = triggerExpression
self.delay = delay
self.useValuesFromTriggerTime = useValuesFromTriggerTime
def initialize(self):
Event.initialize(self)
e = self.model.decorateExceptTime(self.triggerExpression)
self.trigger = lambda m, t: eval(e)
self.value = self.trigger(self.model, self.model.time)
def evaluate(self, time):
oldValue = self.value
self.value = self.trigger(self.model, time)
# Return True if the trigger became true.
return not oldValue and self.value
|