This is an old revision of the document!
Creating Your Own Distributor
Distributor files can be found in your Python library directory, under /ardi/consolidator.
Distribution modules are named 'dist_xxx', where 'xxx' is the type name used in the configuration file.
Installations will include a dist_custom to use as a starting point for creating your own live data distribution channel.
The script will look like the one below…
<code python> import ardi.consolidator.distribution as dist
class CustomDistribution(dist.Distribution):
def __init__(self, core):
super(CustomDistribution, self).__init__(core)
def configure(self, config):
self.config = config
#Read In Configuration Details Here
def isConnected(self):
#Return 'true' if connected
return True
def connect(self):
#Retrurn 'true' if connection is successful
return True
def sendData(self, code, value):
#This actually QUEUES data. If you need to re-format or manipulate data
# before adding it to the queue, here's where you do that.
self.queueData([str(code),str(value)])
def sendUpdate(self, payload):
#This is called when the queue processes an individual item added with 'sendData'.
# You can send this right now if pushing out individual pieces of information.
# If you're consolidating information to be pushed out in a batch, write the data
# into memory/storage here.
return True
def updateBatchComplete(self):
#This is called when the queue has been processed. If you're sending batched/
# consolidated updates, this is the place to transmit them.
pass
<code>
You will need to fill in the functions above.
Techniques
There are two main ways these distributions will usually work - sending out every individual update or sending out batched updates.
If every temperature, pressure and on/off status is going to be its own message, then you should transmit the messages in sendUpdate, as this is called for each new value.
If you'd instead like to combine updates so that they are sent less frequently, you can store the information in memory in sendUpdate and instead send the data to the destination in the updateBatchComplete function.