Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Plug-in design discussion

Got a good idea? You can suggest new features here.
Post Reply
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Plug-in design discussion

Post by krambriw »

Hi Bitmonster,

I have thought about creating a python version of my application NexaSunRise and I would like to discuss some design ideas, which would be best etc....

See picture below

Create two eg plug-ins (or one big)???

A brief description of the function would be;

The first plug-in execution is started by an eg.timer every 30 seconds and calculates the sunset/rise for your location and sends the result to the second plug-in.

The second plug-in takes this result, checks actual day type, time offset settings and time of day, compares this with data in tables to find if its time to switch one or more "things" on/off

If so, it sends the appropriate events to eg

For plug-in configuration purposes I would need to read eg configurations for events and to link them in a table with time and offset settings for each daytype

Other configurations of the plug-ins would be setting geographical position, the holidays, the time trigger settings, the offset time settings etc

Would this be feasible?

Best regards, Walter
Attachments
Image1.jpg
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: Plug-in design discussion

Post by Bitmonster »

Building plugins that depend on each other is always a bad idea. I also see no need to poll the time. Once the plugin is started, it would know when the next event should happen and can therefore schedule its next execution. You can also consider to make all configurations through actions, that can be added to the autostart macro for example. So the user can create one action to schedule a sunset event and another action to schedule a sunrise event (each having its own location and time offset). The "Timer" plugin of Bartman works this way (and it is also quite similar in its functionality, so it might be worth considering to enhance the Timer plugin with a new action type, instead of writing a new plugin).


If Bartman is reading this:
@Bartman
Looking at the Timer code, you run a small thread to handle the time scheduling. It might be a not so bad idea, if EG would have a small scheduler in its core code, so other code can simply add callbacks to given times. But this would need some rewrite of your plugin (making it callback based and not loop based).
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
Bartman
Plugin Developer
Posts: 881
Joined: Sun Feb 12, 2006 9:03 am

Re: Plug-in design discussion

Post by Bartman »

Bitmonster wrote:Looking at the Timer code, you run a small thread to handle the time scheduling. It might be a not so bad idea, if EG would have a small scheduler in its core code, so other code can simply add callbacks to given times. But this would need some rewrite of your plugin (making it callback based and not loop based).
I'm not to happy with the waiting thread either. The threads may be referenced a long time and therefore not removed from memory and the waiting does not consider DST or timezone changes, nor pauses caused by standby.
I could probably change this. Most time went off with creating the GUI.
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Plug-in design discussion

Post by krambriw »

Regarding the sunset/sunrise calculation, I was lucky and found this:

http://kortis.to/radix/python/code/Sun.py

Could this be re-used in the plug-in somehow (it has infact more functions than needed)

Best regards, Walter
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: Plug-in design discussion

Post by Bitmonster »

Of course this could be used in a plugin. But actually most work for such kind of plugin is the GUI, because you have many values the user must be able to edit.

So it is also an alternative to handle this task by a script instead of a plugin. If the script is prepared in a way to easily edit the needed geographical locations and so on and has some documentation (in the wiki for example) it might be nearly as handy as a plugin and will not take much coding time.

I have written a small scheduler now for EG, that will be included in one of the next versions. Once I have completed testing it, I will show you how you can schedule events with it.
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Plug-in design discussion

Post by krambriw »

Thanks a lot, will be great to see. I guess for me, samples where you can guide me a bit to start with is very kind of you since I'm new to python .

BTW, once upon a time I worked in a team where we used ST (SmallTalk). I think there are many similarities with Python...or is it not?

Best regards, Walter
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: Plug-in design discussion

Post by Bitmonster »

Yes, some concepts of Python are borrowed from Smalltalk.
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: Plug-in design discussion

Post by Bitmonster »

Ok, I've included the scheduler code in the latest beta and updated the API docs. You find a description of it here:
http://www.eventghost.org/apidocs/eg.Sc ... class.html
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Plug-in design discussion

Post by krambriw »

Thanks m8, this will be very interesting!!!

Walter
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Plug-in design discussion

Post by krambriw »

@Bitmonster
Thanks for the scheduler, I have played with it and I understand how it works.

I'm diving into python scripting to update myself...and I have started the walk to migrate my code to a python script. I expect I will run into situations when I would need your help & advice. For the moment everything is working as expected...

All the best, Walter
Post Reply