Architecture Question

Posted on
Sat Oct 21, 2017 9:30 pm
dgarozzo offline
Posts: 132
Joined: Jan 08, 2009

Architecture Question

I'm making great progress on my Automatic ODB-II plugin for Indigo, but I have an architecture question that I need help with.

I think things are probably pretty straightforward if I only had one Automatic ODB device - but I have two.

I currently have my plugin set up in Indigo such that I have created a single Automatic ODB device. That single device is responsible for receiving all updates from all Automatic ODB devices. I can create Triggger events that cam e e specific to one Vehicle, but I think I would prefer to create two (three) separate "devices" within Indigo.

The problem is, I should only have one web socket listener, and as it receives messages, it should signal the appropriate vehicle-based device, where Triggers can fire based on events received for a specific vehicle.

How do I set things up such that I would create one main "Automatic ODB" device, and then two separate Vehicle-Specific Automatic ODB device?

Posted on
Sun Oct 22, 2017 4:44 am
DaveL17 offline
User avatar
Posts: 6755
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Architecture Question

Have two device types defined in Devices.xml. Have one listener in your code that is responsible for communication. When new data comes in, evaluate the data and direct it to the appropriate device and then update the status of the device within Indigo. Something like this?

Code: Select all

def listener(self):
    while True:
        # listen for data
       
        if new_data:
            self.got_new_data(data)
           
def got_new_data(self, data):

    # evaluate the data
   
    if data is main_device:
        self.do_main_stuff(data)
       
    elif data is vehicle_device:
        self.do_vehicle_stuff(data)

def do_main_stuff(self, data):
    # parse data to main device
   
def do_vehicle_stuff(self, data):
    # parse data to vehicle device

So you'd need only two defined device types: a main device type and a vehicle device type. The user could create additional instances of the vehicle device type to taste.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sun Oct 22, 2017 11:43 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Architecture Question

Another approach, assuming you'll always just have a single socket listener, would be to put the socket-level config in the plugin's config dialog. Then create a single device type that represents each Vehicle in that device you configure the ID (or whatever is used to distinguish them).

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 6 guests