Re: Monitoring using Mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg104677] Re: Monitoring using Mathematica
- From: David Bailey <dave at removedbailey.co.uk>
- Date: Sat, 7 Nov 2009 06:43:37 -0500 (EST)
- References: <hd0svo$7pp$1@smc.vnet.net>
Harrie Kraai wrote: > Hi there, > > I would like to write monitoring applications in Mathematica using > Dynamic(Module) and Refresh, etc. An example is monitoring an RSS feed. > I would like the interface to stay responsive, hence a simple Module > with an infinite loop or something would not work. > > The "problem" with Dynamic constructs is that they are too "smart". They > stop updating when they are not visible anymore. Of course in > many/most cases that is a great feature. But not for monitoring. I would > like the monitoring application to attract my attention while I am > working on something else. > > The following graphic can be used for one hour to check whether the > updating continues or not: > > panel = Table[Blue, {60}, {60}]; > Dynamic[Refresh[dl = DateList[]; > panel[[dl[[-2]] + 1, (dl[[-1]] // Floor) + 1]] = Red; > ArrayPlot@panel, UpdateInterval -> 0.5, TrackedSymbols -> {}]] > > Scrolling the panel out of sight for a couple of seconds yields gaps in > the Red trail. > > It would be very useful if I could force the Dynamic to keep on updating. > Anyone an idea how to do this? (An option in Dynamic would be very > helpful of course). > > HK > I would create some controls, and then enter the infinite loop which you described and rejected. The loop can interrogate the RSS feed (maybe using Pause, to prevent the loop being a CPU hog). Your controls can set variables, e.g: Button["Stop",readyToFinish=True] The variables can be interrogated from within your loop and the appropriate action taken. Responding to interface requests from within the main loop also avoids tricky, hard to reproduce timing bugs that arise when a dynamic calculation happens to occur at an inconvenient point in the main task. David Bailey http://www.dbaileyconsultancy.co.uk