Author |
Topic  |
|
soundar
51 Posts |
Posted - 02 May 2008 : 18:01:34
|
I am trying to display 5 charts in a single scrolling graph. The 5 process variables are attached to a single transform and a single scroll frame. One or more of the graphs can be turned on or off. When a graph is turned off I set DatasetEnableUpdate = FALSE
and set it to true when it is turned on.
In the example I have attached, graph 1's value go from 50 to 60
graph 2 : 60 to 70, graph 3 :70 to 80, graph 4 : 80 to 90
graph 5: 500 to 1000
When I start the program, all the graphs autoscale fine and the y-axis runs from 0 to 1000. but then when I turn off graphs 1 to 4, I would expect the y-axis (since graph 5 alone is displayed) to go from 500 to 1000 (approx). But it does not. The y-axis scale does not change at all.
I also tried TruncateProcessVarDataset when I turn off the graph. This does not help.
What am I doing wrong?
(I have emailed a sample program) |
|
quinncurtis
1586 Posts |
Posted - 03 May 2008 : 14:33:41
|
There is no need to send us example programs unless we ask for one.
If you want to prevent a process variable, already attached to a RTScrollFrame, from auto-scaling the scroll frame, you must remove it from the RTScrollFrame.
RTProcessVar currentTemperature1;
RTProcessVar currentTemperature2;
. // Initialize currentTemperature1 and currentTemperature2
.
.
// Initialize RTScrollFrame for both currentTemperature1
// and currentTemperature2
RTScrollFrame scrollFrame = new RTScrollFrame(this, currentTemperature1, pTransform1,
ChartObj.RT_FIXEDEXTENT_MOVINGSTART_AUTOSCROLL);
scrollFrame.AddProcessVar(currentTemperature2);
.
.
.
// Now you want to remove currentTemperature2 from the RTScrollFrame
scrollFrame.RTDataSource.ProcessVarList.Remove(currentTemperature2); |
 |
|
soundar
51 Posts |
Posted - 05 May 2008 : 13:33:59
|
I just tried it...it does not work. |
 |
|
quinncurtis
1586 Posts |
Posted - 05 May 2008 : 15:00:29
|
Actually it does work, and we tested it with your own program. Your program contains a testing error, you introduce 7 process variables (MAX_GRAPHS = 7), yet you only process 5 (0..4) of them with your check boxes. The process variables 5 and 6 are added to but never removed from the RTScrollFrame.
We skipped adding them with
graphFrame_ = New RTScrollFrame(Me, rtprocess_(0), graphTransform_, _
ChartObj.RT_FIXEDEXTENT_MOVINGSTART_AUTOSCROLL, ChartObj.RT_AUTOSCALE_Y_MINMAX)
For i = 1 To MAX_GRAPHS - 3
graphFrame_.AddProcessVar(rtprocess_(i))
Next And removed the others in your ShowGraph method
Public Sub ShowGraph(ByVal index As UShort, ByVal status As Boolean)
onOffFlag_(index) = status
If status = False Then
rtprocess_(index).TruncateProcessVarDataset(0)
rtprocess_(index).DatasetEnableUpdate = False
graphFrame_.RTDataSource.ProcessVarList.Remove(rtprocess_(index))
Else
rtprocess_(index).DatasetEnableUpdate = True
End If
End Sub |
 |
|
soundar
51 Posts |
Posted - 05 May 2008 : 17:54:59
|
I cleaned up my example my little bit to use only 5 process variables (MAX_GRAPHS=5) and changed graph 5 to go from 5000 to 5500 and tested it like you said. The code now looks like ------------------- Private Sub TimerUpdate_Tick.... y_(0) = 50 + Rnd() * 10 y_(1) = 60 + Rnd() * 10 y_(2) = 70 + Rnd() * 10 y_(3) = 80 + Rnd() * 10
y_(4) = 5000 + Rnd() * 500 Me.ScrollingGraph1.UpdateData( y_) End Sub -------------------------------
Public Sub ShowGraph(ByVal index As UShort, ByVal status As Boolean) onOffFlag_(index) = status If status = False Then rtprocess_(index).TruncateProcessVarDataset(0) rtprocess_(index).DatasetEnableUpdate = False graphFrame_.RTDataSource.ProcessVarList.Remove(rtprocess_(index)) Else rtprocess_(index).DatasetEnableUpdate = True graphFrame_.RTDataSource.ProcessVarList.Add(rtprocess_(index)) End If End Sub Public Sub UpdateData(ByVal y() As Double) 'pass all the channels and the total Dim tod As New ChartCalendar() For i As Byte = 0 To MAX_GRAPHS - 1 If onOffFlag_(i) = True Then rtprocess_(i).SetCurrentValue(tod, y(i)) End If Next End Sub ---------------------------------------------
This is what I see: ON OFF y-axis goes from ------------------------------------------------------ 1 to 4 5 0 to 90 5 1 to 4 0 to 5500 1 2 to 5 0 to 70 2 1, 3, 4, 5 0 to 80 -------------------------------------------------------- The graphs turn on and off as I want them to. But I cannot get yaxis to go from (around) 5000 to 5500 when graph 5 alone is on. (I have emailed my cleaned-up example just to save time. The error, if any, is not obvious to me.)
|
 |
|
soundar
51 Posts |
Posted - 05 May 2008 : 18:37:51
|
Sorry, the formatting was not correct in my previous post. The table should look like
This is what I see: ON ---------- OFF ---------- y-axis goes from ------------------------------------------------------ 1 to 4 ---------- 5 ---------- 0 to 90 5 ---------- 1 to 4 ---------- 0 to 5500 1 ---------- 2 to 5 ---------- 0 to 70 2 ---------- 1, 3, 4, 5 ---------- 0 to 80 |
 |
|
quinncurtis
1586 Posts |
Posted - 05 May 2008 : 18:39:04
|
The logic of your program is still flawed.
You are adding every process variable twice to the scroll frame. So when you delete a reference to one, another for the same process variable still exists.
The first time for each process variable is in the InitializeScrollGraph method. The second time is in your ShowGraph method, which is called from your check box initialization routine in your frmGraph_Load method. Place a break point in the ShowGraph method, on graphFrame_.RTDataSource.ProcessVarList.Add(rtprocess_(index)) and you will see it called before the graph is ever drawn.
So, set some sort of flag to prevent this on initialization.
Also, use graphFrame_.AddProcessVar, (not graphFrame_.RTDataSource.ProcessVarList.Add) to add process variables since that is what it's there for.
A simple, one line change to your program seems to work. The program now tries to REMOVE the process variable from this list before adding it again. If it isn't there nothing bad happens, if it is there, it is removed before you end up adding it again.
Public Sub ShowGraph(ByVal index As UShort, ByVal status As Boolean)
onOffFlag_(index) = status
If status = False Then
rtprocess_(index).TruncateProcessVarDataset(0)
rtprocess_(index).DatasetEnableUpdate = False
graphFrame_.RTDataSource.ProcessVarList.Remove(rtprocess_(index))
Else
rtprocess_(index).DatasetEnableUpdate = True
graphFrame_.RTDataSource.ProcessVarList.Remove(rtprocess_(index))
graphFrame_.AddProcessVar(rtprocess_(index))
End If
End Sub |
 |
|
soundar
51 Posts |
Posted - 05 May 2008 : 19:26:42
|
That fixed it! Thanks. Didn't see that error. |
 |
|
|
Topic  |
|
|
|