Design Question. Data Acquisition/Display related.

Discussion in 'Python' started by StepH, May 17, 2005.

  1. StepH

    StepH Guest

    Hi,

    I'm building a little application, which the goal is to:

    1./ Collect data via Serial line and or via a file (for playback).
    2./ Display these data as graph, oscilloscope, ...

    How manage this ?

    1./ Is each "display" must responsible to acquire/read the data ?
    2./ Or an engine collect the data then send them to each "display" ?

    Also, how to "anim" this ?

    1./ Via a timer ?
    2./ Via a simple loop (read/update display/pause/read user key)

    The app. will be a GUI (tkInter) app. and the user must be able to stop
    the process at any time.

    Sure, all this must be maintenable, let's say to acquire data via other
    type of channel or to other type of display...

    Yes, it's like a "mini" labView...

    Any idea or link is welcome.

    Thanks.

    STepH.
    StepH, May 17, 2005
    #1
    1. Advertising

  2. StepH wrote:

    >1./ Is each "display" must responsible to acquire/read the data ?
    >2./ Or an engine collect the data then send them to each "display" ?
    >
    >
    >

    I'd keep it simple:

    - DataCollector class
    asociated with one or more display instances (implemented as a list of
    display subscribers)
    it collects data from a source and notifies each subscribed display that
    new data is available.
    could something like a 'collect' method which performs:

    for display in self.subscribed_displays:
    display.update( data )


    - Display class
    just a simple display class with an "update" method
    it should be able to receive new data
    and display new data
    (those 2 actions could be implemented in different methods, you might
    not want to display everytime new data is available... maybe you might
    want to consolidate data in some way and output it at some high interval)

    >Also, how to "anim" this ?
    >
    >1./ Via a timer ?
    >2./ Via a simple loop (read/update display/pause/read user key)
    >
    >


    a simple loop could do it
    - handle user events
    - collect data
    - update displays
    - sleep
    Alex Verstraeten, May 17, 2005
    #2
    1. Advertising

  3. StepH

    StepH Guest

    Alex Verstraeten a écrit :

    > StepH wrote:
    >
    >> 1./ Is each "display" must responsible to acquire/read the data ?
    >> 2./ Or an engine collect the data then send them to each "display" ?
    >>
    >>
    >>

    > I'd keep it simple:
    >
    > - DataCollector class
    > asociated with one or more display instances (implemented as a list of
    > display subscribers)
    > it collects data from a source and notifies each subscribed display
    > that new data is available.
    > could something like a 'collect' method which performs:
    >
    > for display in self.subscribed_displays:
    > display.update( data )
    >
    >
    > - Display class
    > just a simple display class with an "update" method
    > it should be able to receive new data
    > and display new data
    > (those 2 actions could be implemented in different methods, you might
    > not want to display everytime new data is available... maybe you might
    > want to consolidate data in some way and output it at some high interval)


    Ok, it was my first idea too...

    >
    >> Also, how to "anim" this ?
    >>
    >> 1./ Via a timer ?
    >> 2./ Via a simple loop (read/update display/pause/read user key)
    >>
    >>

    >
    > a simple loop could do it
    > - handle user events
    > - collect data
    > - update displays
    > - sleep
    >
    >
    >

    Here i've a prob. (due to the fact that I start both with Python &
    TkInter). In TkInter, you run your app by launching a mainloop()
    routine, right ? So, how, in my forever loop (handle user events /
    Collect data / Update Display / Sleep) handle the user data ?

    Sure, i can (i suppose), log user activity (via the event send by the Tk
    underlayer), the "poll" theses event in my for ever loop ? But in this
    case, are these event will be correctly generated (by Tk) ? How to
    "give the hand" to Tk in such scenario ?

    Thanks for your help.

    StepH.
    StepH, May 17, 2005
    #3
  4. StepH wrote:

    >>a simple loop could do it
    >> - handle user events
    >> - collect data
    >> - update displays
    >> - sleep
    >>
    >>

    >Here i've a prob. (due to the fact that I start both with Python &
    >TkInter). In TkInter, you run your app by launching a mainloop()
    >routine, right ? So, how, in my forever loop (handle user events /
    >Collect data / Update Display / Sleep) handle the user data ?
    >
    >Sure, i can (i suppose), log user activity (via the event send by the Tk
    >underlayer), the "poll" theses event in my for ever loop ? But in this
    >case, are these event will be correctly generated (by Tk) ? How to
    >"give the hand" to Tk in such scenario ?
    >
    >Thanks for your help.
    >
    >StepH.
    >
    >

    oops, sorry, I was thinking of a 'pygame' kind of loop, where you have
    control over it.
    I dont have experience on Tk, I allways use wxPython or pygame for gui's.

    you can forget about the loop I mentioned... it doesn't apply to
    event-driven applications where you have no control over the loop.
    you'd be using a timer that triggers a tick method at a certain
    interval, in that tick method you could tell your data collectors to
    collect data... then the data collectors would trigger all its
    subscribed displays's "update" function, so they draw the new available
    data, just like the "for display in self.subscribed_displays:
    display.update(data)".

    so it comes to something like this:

    tk mainloop is set to call tick() every 100ms through a timer.
    tick() will iterate through all data collectors and call their "collect"
    method
    each data collector will then collect data and iterate through all
    asociated displays calling their respective 'update' method on each.

    of course there are plenty of ways to design an app, this is just an idea.

    hope it helps,
    Alex
    Alex Verstraeten, May 17, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jude
    Replies:
    7
    Views:
    944
    Brock Allen
    Mar 15, 2005
  2. Ulysses

    Data acquisition Card- How to use with C?

    Ulysses, Jun 20, 2007, in forum: C Programming
    Replies:
    36
    Views:
    789
    Keith Thompson
    Jun 29, 2007
  3. Replies:
    0
    Views:
    353
  4. spintronic

    Data acquisition

    spintronic, Oct 25, 2011, in forum: Python
    Replies:
    10
    Views:
    306
    Dennis Lee Bieber
    Oct 26, 2011
  5. Steven Jenkins
    Replies:
    0
    Views:
    281
    Steven Jenkins
    Jan 19, 2004
Loading...

Share This Page