====Creating Your Own Distributor==== [[start|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... 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 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. ===Internal Functions=== Internally, each of these Distribution methods run in their own thread and maintain their own queue of messages to be transmitted. This means that a disruption/slowdown in one destination shouldn't have effects on the performance of others. The main potential issue is //excessive queue size//. If possible, steps should be taken to prevent the queue from reaching extreme size. This may involve purging the queue of older records, duplicates etc. during outages. Each distribution method has exception handling to avoid errors causing the whole Consolidator from failing. You may need to add your own exception handling to understand any errors, which may otherwise be captured and quietly discarded.