GRAPHING WITH KNOBS AND SLIDERS


williamlynn

Recommended Posts

The attached example was in a previous post(July 27,07) and the example shure works great but when I try to use it in my application I come up with a lot of questions.

1. I have several graphs on a page. How do I direct a knob and slider to a specific graph. The example shows to "SET CHANNEL" to "Component.mygraph.gslide(or gwidth or setdate). Can you explain a little about how this works? I guess that the "mygraph" refers to the graph in the example but I cannot see where the graph is labled"mygraph"??

2. The traces have subsetting of [s,e], Can you explain how this works?

3. The time scaling shows DQFactory time format but what do the three digits at the end of the 10 digit format mean. I figured out that the time scaling gets set by the knob parameters.

I also need you guidance on timing, persist and history.

My application gets its data from a file using "AddValue" and the sequence reads the file every 5 seconds. I have timing set to 0. The channel table shows a new data point every 5 seconds so is a "HISTORY" point 5 seconds long or 1 second? If I set history to 100 will I get 500 seconds of data at 5 second intervals or 100 secons of data with each 5 being equal??? Same for persist??? If I set persist at 86400 will I get 24 hours or 5 days of data???

Any information on timing, persist and history will be appreciated.

Thanks againn for your help.

Bill

historysample2.ctl

Link to comment
Share on other sites

Truthfully, this is an older sample, and I think the way graphs are done in QuickMod Pro to be far superior, so you may want to use that instead. QuickMod Pro comes with a document that explains how the graph works, both of which are in the latest DAQFactory download.

That said, most of the work for this sample is done in the OnLoad and OnPaint events of the graph. To view these events, go to View - Event. You'll also see the name of the component (mygraph). s and e are local variable to the graph.

I don't know where you are referencing in question 3.

As for the persist/history, these are in data points, not time. So, if you have a history of 100 and do addvalue() every 5 seconds you'll get 500 seconds worth of data kept in memory. Same for persist. A persist of 86400 updated every 5 seconds is 5 days worth.

Link to comment
Share on other sites

Thanks for the response.

Finally got it to work; I found I had to add the startup and updatetypecombo sequenceds to get it to work.

But I still want to displayt several graphs with different scaling; how can I do this; I tried putting the graph on different pages with different compoinent name and different up[date combo sequence for each but the X-Y scaling controls change both graphs.

Thanks again

Bill

Link to comment
Share on other sites

You need to name each graph with a different name, and then in the controls (knob / slider), change the name from mygraph to whatever you named your graph. That is actually all you should have to do. Make sure and duplicate (or copy/paste) the sample graph. There is code added in the sample that does all this stuff that is not in a blank graph.

Link to comment
Share on other sites

I'm using the graph from QucikMod Pro as you suggested, not the one in the example from the 2007 posting.

I copied the graph and the controls from Quick mod pro and named each graph with a different name. When I open the controls I cannot see where to direct the control to a graph; out of frustration I tried using "Component.maingraph.xscalewidth" for the "set Channel" field but it would do nothing.

fOUND ANOTHER DISTURBING THING; THE TRACES ADDED TO THE GRAPHS DO NOT GET SAVED. If I save the file before exiting and then reopen the file the graphs are there but there are no traces.

Link to comment
Share on other sites

  • 9 months later...

I'm using the "historysample2.ctl" example to do variable time scales on my graphing. My graphs use the sums of a number of V channels I've set up. All my channels are sampled once / minute. And I set up radio buttons to show me:

Hourly (one day's worth of data)

Daily (one week of data)

Weekly (8 weeks of data)

Monthly (one year of data)

Everything works fine in terms of the changing time scales. I understand that DF limits the number of points on a graph to keep it from taking too long to paint. But the graphs are far too finely grained to be meaningful. I would like to dynamically average the subsets in order to smooth the graph like this:

Hourly - One day of data average over each hour in the day. So the graph would have 24 unique points.

Daily - One week of data averaged over each day in the week. 7 points

Weekly - 8 weeks of data averaged over each week. 8 data points

Monthly - 12 months and 12 data points.

I cannot find any way to enter a mean or average or smoothing function within the graph expression. Do I have to set up additional v channels and do the math there?

Thanks

Link to comment
Share on other sites

What you want is a pivot function like DAQConnect has, but alas DAQFactory does not have it yet. DAQFactory does have a boxcar function, but that would only work if you knew how many data points there were in each period and it was always the same. Otherwise, you'd need to use a V channel for each of those time periods, V.Hour, V.Daily, etc (or better yet, use a Test channel, which I like better than V channels for many reasons, persistance between restarts being one of them). Anyhow, then in the event for your input channel, calculate the hourly, daily, etc averages and put them in the correct place. To tell when you need to do the calculation, use the formatdatetime() function. So for example, to know that the hour changed, do:

if (formatdatetime("%H",mychannel.time[0]) != formatdatetime("%H",mychannel.time[1]))

Basically the formatdatetime function with the correct specifier can be used to pull out a particular hour, day, week #, day of week, etc and then used for comparisons. Doing mychannel.time[0] vs [1] means we are comparing the most recent and next most recent data points.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.