Our team was confronted with the task of controlling two service pumps from one of our gateways with a twist.   These service pump are pumping from a standpipe, and they are faster than the well filling the tank.   So if the tank gets too low, we give the service pumps a break while the well catches up.   Plugins are written in python, and are pretty easy to read:


class PumpControlModule(baseModule):

    def __init__(self):
        self.last_data_pack = "0,0,0"
        self.data_pack = self.last_data_pack
        self.name = "Pump Control"

        self.low_standpipe_delay_active = False
        self.analog_control = 2 # pressure transducer (looking at scalled value)
        self.call_for_water_on_level = 70.5 # pump on level
        self.call_for_water_off_level = 99.5 # pump off level
        self.standpipe_low_status = 4 # status input numer 4

    def clear_standpipe_delay(self):
        self.devices[1].relay_off(2)
        self.devices[1].relay_on(1)
        self.low_standpipe_delay_active = False

    def check_for_low_standpipe(self):
        low_standpipe_bit = self.getStatus(self.standpipe_low_status)
        if self.low_standpipe_delay_active == 0 and low_standpipe_bit == 1:
            print "low standpipe detected"
            self.low_standpipe_delay_active = True
            reactor.callLater(1800,self.clear_standpipe_delay)
            reactor.callLater(10,self.devices[1].relay_off,2)

Contact us for the rest of this plug-in code for your SCADA Gateway.