<?xml version="1.0"?>
<!--
###############################################################################
# #
# MODULE Events.xml #
# #
###############################################################################
PACKAGE: Raspberry Pi General Purpose Input/Output for Indigo (Pi GPIO)
MODULE: Events.xml
TITLE: Pi GPIO event (trigger) objects (Events.xml)
FUNCTION: Events.xml defines Pi GPIO events that may trigger specific indigo
actions. It identifies events, specifies GUI labels, and sets
default values.
USAGE: Events.xml is read and interpreted by the indigo server during
plugin startup. When a user creates a new trigger, indigo uses the
xml data to instantiate a trigger object per the indigo object model
(IOM).
AUTHOR: papamac
VERSION: 0.5.1
DATE: March 28, 2022
CHANGE LOG:
Major changes to the Pi GPIO plugin are described in the CHANGES.md file in the
top level PiGPIO folder. Changes of lesser importance may be described in
individual module docstrings if appropriate.
v0.5.0 11/28/2021 Fully functional beta version with minimal documentation.
v0.5.3 3/28/2022 Change event field id's and add events for pigpio errors.
-->
<Events>
<Event id="pigpioErrors">
<Name>pigpio Errors</Name>
<ConfigUI>
<Field id="triggerEvent" type="menu" defaultValue="any">
<Label>pigpio Errors:</Label>
<List>
<Option value="any">Any pigpio Error</Option>
<Option value="startError">Start Error</Option>
<Option value="stopError">Stop Error</Option>
<Option value="readError">Read Error</Option>
<Option value="writeError">Write Error</Option>
<Option value="interruptError">Interrupt Error</Option>
<Option value="interruptResetError">Interrupt Reset Error</Option>
</List>
</Field>
</ConfigUI>
</Event>
<Event id="limitFaults">
<Name>Limit Check Faults</Name>
<ConfigUI>
<Field id="triggerEvent" type="menu" defaultValue="anyFault">
<Label>Limit Check Fault:</Label>
<List>
<Option value="any">Any Limit Fault</Option>
<Option value="lowFault">Low Limit Fault</Option>
<Option value="highFault">High Limit Fault</Option>
</List>
</Field>
</ConfigUI>
</Event>
</Events>
@staticmethod
def _executeEventTrigger(eventType, event):
for trig in indigo.triggers.iter(u'self'):
triggerEventType = trig.pluginTypeId
if trig.enabled and triggerEventType == eventType:
triggerEvent = trig.pluginProps[u'triggerEvent']
if triggerEvent == u'any' or triggerEvent == event:
indigo.trigger.execute(trig)
self._executeEventTrigger(u'pigpioError', u'readError'). # Execute trigger if trigger GUI selects "Read Error" or "Any pigpen Error"
triggerStartProcessing()
triggerStopProcessing()
def triggerStartProcessing(self, trigger):
self.logger.debug(f"{trigger.name}: Adding {trigger.pluginTypeId} Trigger")
if trigger.pluginTypeId == "alertEvent":
assert trigger.id not in self.alert_triggers
self.alert_triggers[trigger.id] = trigger
elif trigger.pluginTypeId == "modeEvent":
assert trigger.id not in self.mode_triggers
self.mode_triggers[trigger.id] = trigger
elif trigger.pluginTypeId == "cameraEvent":
assert trigger.id not in self.camera_triggers
self.camera_triggers[trigger.id] = trigger
def triggerStopProcessing(self, trigger):
self.logger.debug(f"{trigger.name}: Removing {trigger.pluginTypeId} Trigger")
if trigger.pluginTypeId == "alertEvent":
assert trigger.id in self.alert_triggers
del self.alert_triggers[trigger.id]
elif trigger.pluginTypeId == "modeEvent":
assert trigger.id in self.mode_triggers
del self.mode_triggers[trigger.id]
elif trigger.pluginTypeId == "cameraEvent":
assert trigger.id in self.camera_triggers
del self.camera_triggers[trigger.id]
Users browsing this forum: No registered users and 2 guests