Need advise about an application

azrael jura.grozni at gmail.com
Mon Apr 6 01:16:08 EDT 2009


On Apr 5, 9:48 pm, Dennis Lee Bieber <wlfr... at ix.netcom.com> wrote:
> On Sun, 5 Apr 2009 10:14:08 -0700 (PDT), azrael <jura.gro... at gmail.com>
> declaimed the following in gmane.comp.python.general:
>
> > DB saving, and anotherone for statistics and other stuff because it is
> > very important to save the signal which comes every second. if the
> > statistics generation can use the rest of the time, then it should be
> > done.
>
>         In computer terms, 1 second is a very long time.
>
>         If the source of the data is that regular (give or take a quarter
> second) I'd probably code a repeating timed event with a 0.25s repeat
> interval.
>
>         <event triggers>
>                 check serial port for data packet (been a long time, does
> pySerial buffer stuff for one? how long are these packets, and are they
> identified by a line end character or pure binary?).
>                 if packet received:
>                         process it
>
>         As long as the event process takes less than 0.25s when a packet is
> received (the empty packet case should be practically instantaneous:
> test/return) you should get back to other GUI events in time for screen
> updates, and without running into the start of the next timed check.
> (The simplistic route would be to just schedule the next check 0.25s
> from when the previous one returned, but that leads to creeping time
> quantums. More complex is to compute    next = 0.25 -
> time-spent-processing           assuming the GUI library does not
> incorporate a static timed repeat call.)
>
>         If going thread-based, the thread would contain no GUI related code
> (it seems easier to make the GUI the main program, and shove non-UI work
> into threads). The thread would basically loop
>
>         wait for packet [blocking I/O, not polling loop]
>         compute updates statistics
>         do database update
>
>         Now, how to get the statistics to the display? You either need some
> GUI event (timed again) which reads the statistics values from
> <somewhere> [global structure, from a queue with the thread PUT the
> updates, etc.] and formats the display update. Or, again, some event
> that can be triggered asynchronously (the timer is a synchronous update
> -- you've said "every xxx update the status portion of the display") so
> that the status portion is only updated when the data is changed.

That's what I meant but was not sure. I guess that I will be
callculating the remaining time using decorators. this should give an
elegant way.
The part about the threads looks like the right thing I needed. Today
I will be seing the serial port device so to play a bit with it but
also to see what it supports. It would be great if the meassunring
signal from the device could have a function as a trigger. this way I
could form it as a custom trigger for wxPython. I guess I will just
have to have a look at it.

Could anyone give me some good literature about custom made events in
python. Either to send me the material to my email or to give me some
links

> --
>         Wulfraed        Dennis Lee Bieber               KD6MOG
>         wlfr... at ix.netcom.com             wulfr... at bestiaria.com
>                 HTTP://wlfraed.home.netcom.com/
>         (Bestiaria Support Staff:               web-a... at bestiaria.com)
>                 HTTP://www.bestiaria.com/




More information about the Python-list mailing list