Page 1 of 1

My first...plugin for Velleman k8055 USB board

Posted: Sat Mar 01, 2008 10:23 am
by krambriw
Hello,

I have found a nice little device that is a must (I think) in a home automation system. Its the Velleman USB board and it has "very nice to have" inputs and outputs of various kind:
-8 digital outputs
-2 analog outputs
-5 digital inputs
-2 analog inputs
-2 counters

So I created a plugin for it.

In total you can have 4 bourds connected via USB (0,1,2,3). This first version only supports board address 0 but in following version I´m aiming to get the "canMultiLoad" to work. I tried but runned into problems...need some support with this :D

To get going, you need the board (I think its globally available, check Velleman´s home page in Belgium http://www.velleman.be) and install the software. Then you need to copy the updated K8055D_C.dll to your system32 directory. The setup and file is on the cd that comes with the board.

Then just add the plugin in EG as normal, create your macros, actions and events.

Best regards, Walter

Re: My first...plugin for Velleman k8055 USB board

Posted: Sat Mar 01, 2008 12:21 pm
by Bitmonster
I just took a short look at the code. Some things I noticed so far:

1. You seem to have an animosity against lists. :)
Instead of writing di_1_event_trigger, di_2_event_trigger, etc. why not do something like:
d1_event_triggers = [0, 0, 0, 0, 0]
and then handle it with loops like:
for event_trigger in d1_event_triggers:
Also take a look at the "enumerate()" function of Python to handle arrays indexes in loops.

2. Its no good idea to write configurations to the plugin directory, because it might be read-only on some setups. Configuration of the events should normally go to the plugin configuration and not be an action. Is there any special reason here to do it this way?

Re: My first...plugin for Velleman k8055 USB board

Posted: Sat Mar 01, 2008 5:24 pm
by krambriw
Thanks for supporting, I'm a novis in python so really, I'm happy for all suggestions.

1) OK, I will try to use this instead

2) I try to explain what I need to do; When I start the plugin first time, I configure various actions and define treshold levels for events. Like setting the level for analog inputs (1-254) so that if the signal goes above 150 (or any other configured value) an event is generated. Or that 0 or 1 at a digital input shall generate an event. Or the counter level shall be 35 and so on.

I use those settings in the rest of the plugin logic and to make those available I use "global" variables.

When I restart the plugin, I need to set the globals to an initial value. To be sure to get the correct settings, I use pickle to dump and load the original action configurations.

I do not how to do it but I would preferre to let the actions be re-configured automatically at plugin startup so that they would run their configuration code themselves.

I would need this also to be able to support more boards, the plugin shall configure the "global b_nbr" when it starts. But how can this be done?

Best regards, Walter

Re: My first...plugin for Velleman k8055 USB board

Posted: Sat Mar 01, 2008 7:03 pm
by Bitmonster
But these default values are global to the plugin, so they don't need to be gathered by actions. They can be assigned in the Configure of the plugin and then the __start__ method will receive them as all plugins handle their parameters.

If you later want to modify these default values through action, you can do it in the __call__method. But never assign any parameters directly in any Configure() method, as this is outside of the logic plugins and actions work.

Only if an action is executed, it should have some impact.

Re: My first...plugin for Velleman k8055 USB board

Posted: Sat Mar 01, 2008 8:22 pm
by krambriw
Ok, could you change some part in the plugin to show me?