class AllPoof(PatternBase): def __init__(self, *args): self.inputParams = { 'poofButton' : { 'descriptionInPattern' : 'Poof!', 'type' : 'pulse', 'subType' : 'button', 'bindToFunction' : 'poofButton' }, 'stayOnTime' : { 'descriptionInPattern' : 'Time to stay on for(ms)', 'type' : 'value', 'subType' : 'int', 'min' : 100, 'max' : 1000, 'default' : 200 }, } PatternBase.__init__(self, *args) self.patternName = 'Allpoof' self.timer = Timer(False, self.inputs.stayOnTime, self.turnOff) self.poofState = False def poofButton(self, *args): if self.inputs.poofButton: self.timer.changeInterval(self.inputs.stayOnTime) self.timer.refresh() self.poofState = True self.requestUpdate() def turnOff(self): self.poofState = False self.requestUpdate() def getState(self, row, col): return self.poofState def stop(self): self.timer.stop() PatternBase.stop(self)
class AllPoof(PatternBase): def __init__(self, *args): self.inputParams = { 'poofButton': { 'descriptionInPattern': 'Poof!', 'type': 'pulse', 'subType': 'button', 'bindToFunction': 'poofButton' }, 'stayOnTime': { 'descriptionInPattern': 'Time to stay on for(ms)', 'type': 'value', 'subType': 'int', 'min': 100, 'max': 1000, 'default': 200 }, } PatternBase.__init__(self, *args) self.patternName = 'Allpoof' self.timer = Timer(False, self.inputs.stayOnTime, self.turnOff) self.poofState = False def poofButton(self, *args): if self.inputs.poofButton: self.timer.changeInterval(self.inputs.stayOnTime) self.timer.refresh() self.poofState = True self.requestUpdate() def turnOff(self): self.poofState = False self.requestUpdate() def getState(self, row, col): return self.poofState def stop(self): self.timer.stop() PatternBase.stop(self)
class TimerPulseInput(InputBase): def __init__(self, *args): InputBase.__init__(self, *args) self.timer = Timer(True, self.inParams[0].getValue(), getattr(self, 'sendPulse')) def stop(self): self.timer.stop() InputBase.stop(self) def refresh(self): self.timer.refresh() def sendPulse(self): self.outParams[0].setValue(True) def setInputValue(self, *args): InputBase.setInputValue(self, *args) self.timer.changeInterval(self.inParams[0].getValue()) def updateOutputValues(self): pass