Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Tools for Microsoft .Net
 Real-Time Graphics Tools for .Net (VB and C#)
 Finding the last point in a curve ?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Procentaren

Sweden
8 Posts

Posted - 23 Nov 2014 :  10:33:12  Show Profile  Reply with Quote
I have a scrollgraph with a curve that starts at left and then grows towards the right.
At the right end it rescales. ScrollRescaleMargin = 0.95 ,so the curve starts again almost at the left limit.

I have also added a black line that follows the end of the curve, and illustrates the "slope" of the last part of the curve.
This works fine until the graph rescales.

After rescale the black "slopeline" is losing its position.
The reason is that before rescaling the last point in the inputchannel is index 1.
But after rescaling this is not true anymore.
I have tried but can't find how to get the correct index in the inputchannel after rescaling ?

The blue curve is the measurementvalue in a PID-controller. And the extra black line is used to describe how the D-function works in the controller.

Public pTransform1 As CartesianCoordinates
Public Dataset1 As SimpleDataset
Public scrollFrame1 As RTScrollFrame
Public chartVu As ChartView = Me
Public lineplot() As SimpleLinePlot
Public inputChannel() As RTProcessVar
Public DTrendLastPoint As Point2D 'Last point in curve.

Private attrib() As ChartAttribute 'Colorfor curve, thickness, dashstyle

pTransform1 = New CartesianCoordinates(0.0, min, X_range, Ymax) 'Used for the plotarean.

scrollFrame1 = New RTScrollFrame(Me, Nothing, pTransform1, ChartObj.RT_FIXEDEXTENT_MOVINGSTART_AUTOSCROLL)

attrib(I) = New ChartAttribute(DMeasColor, DMeasThickness, DashStyle.Solid)

scrollFrame1.AddProcessVar(inputChannel(I))
lineplot(I) = New SimpleLinePlot(pTransform1, Nothing, attrib(I)) 'attrib stter kurvfrg, tjocklek och dashstyle

inputChannel(I).DatasetEnableUpdate = True
rtPlot(I) = New RTSimpleSingleValuePlot(pTransform1, lineplot(I), inputChannel(I)) 'Skale 0 - 100 %




Add data to inputchannel
inputChannel(I).SetCurrentValue(x, inputChannelValue(I))

Get last point in curve. This point is then used to place the "Slopeline" at the end of the curve.
DTrendLastPoint = inputChannel(1).GetHistoryPoint(1) 'PhysPos

Edited by - Procentaren on 23 Nov 2014 10:40:24

quinncurtis

1585 Posts

Posted - 24 Nov 2014 :  08:56:09  Show Profile  Reply with Quote
The method GetHistoryPoint(1) will return, not the most recent, but the second most recent historical value. In your example you show different indices, using I for SetCurrentValue, and 1 for GetHistoryPoint. I don't know if this is an error or just an anomaly in your code

inputChannel(I).SetCurrentValue(x, inputChannelValue(I))
DTrendLastPoint = inputChannel(1).GetHistoryPoint(1) 'PhysPos


When you check the point returned by GetHistoryPoint, is it correct? That should be easy for you to tell.

If the value is correct, then the error must be in how you plot the slope line, which you do not show. So, show that code also, or send us a simple example which reproduces the problem.
Go to Top of Page

Procentaren

Sweden
8 Posts

Posted - 24 Nov 2014 :  13:02:36  Show Profile  Reply with Quote
Thank you for your quick answer.
The value for I is 1 in this case. There are more curves, but this black Dline is only involved in curve number 1.
The drawing of the black DLine is working as expected.
Given DTrendLastPoint that represents the end of the curve, it writes the black line at that Point.

But I must have misunderstood the thing with truncation and rescaling.
With settings AutoTruncateMinCount = 0 and AutoTruncateMaxCount = 300 I expected everything to restart from the left when curves reached the right.
But the value DTrendLastPoint.X continues to grow. Beyond the Max X-value 120 seconds.
This causes the DLine to be drawn "out of sight".


Initializedata I = 1 for curve number 1

inputChannel(I).TruncateProcessVarDataset(0)
inputChannel(I).AutoTruncateDataset = True
inputChannel(I).AutoTruncateMinCount = 0
inputChannel(I).AutoTruncateMaxCount = Reg.RegInfoSettings.NumPoints(RegNr) '300
inputChannel(I).MinimumValue = Reg.RegInfoSettings.Ymin(RegNr) '0
inputChannel(I).MaximumValue = Reg.RegInfoSettings.Ymax(RegNr) '100


Dim timebase As Double = Reg.RegInfoSettings.DX_Range(RegNr) '120 seconds


samplepoint = timebase / numpnts 'Seconds per update (numpnts = 300)

Timer2.Interval = samplepoint * 1000


Update curves and call routine for drawing the black "Dline".
Private Sub Timer2_Tick(sender As System.Object, e As System.EventArgs) Handles Timer2.Tick
Call AddDataToTrendCurves(RegNr)

DTrendLastPoint = inputChannel(1).GetHistoryPoint(1) 'PhysPos

Draw the black DLine
Call CalcDlinePoints(RegNr, Reg.Regulator(RegNr).Lutning, DTrendLastPoint)
Me.UpdateDraw()

End Sub


Routine for drawing the black line (Code simplified)
Dataset1 is the X- and y-values for the endpoints of the DLIne.
Public Sub CalcDlinePoints(ByVal RegNnr As Integer, ByVal Lutning As Single, ByVal MidPoint As Point2D)



DLineLengthSetup = 120


DLineLengthRaw = Math.Sqrt(Lutning * Lutning + 1 * 1) 'Linjens lngd fr en sekund.
Faktor = Sqrt(DLineLengthSetup / DLineLengthRaw) ' * (1 + Abs(Lutning) * 0.1)


Y_Length = Faktor * Lutning
X_Length = Faktor '* Reg.RegInfoSettings.X_Range(RegNr) * AspectRatio


x1(0) = MidPoint.X - (X_Length / 2)
y1(0) = MidPoint.Y - (Y_Length / 2)
x1(1) = MidPoint.X + (X_Length / 2)
y1(1) = MidPoint.Y + (Y_Length / 2)

Dataset1.SetXData(x1)
Dataset1.SetYData(y1)

End Sub
Go to Top of Page

quinncurtis

1585 Posts

Posted - 24 Nov 2014 :  13:36:34  Show Profile  Reply with Quote
You are not using the AutoTruncateMin (and Max) values properly, so that may be the cause of your problem. Their only use is to save memory. They have nothing to do with the scrolling. By setting them so low you are probably getting invalid values since you are setting the history buffer back to 0. So set them to values several time larger than one screens worth of data until you get your problem solved.

inputChannel(I).AutoTruncateMinCount = 5000
inputChannel(I).AutoTruncateMaxCount = 10000


The scrolling you describe is controlled by the RTScrollFrame.
So set RTScrollFrame for RT_FIXEDEXTENT_MOVINGSTART_AUTOSCROLL and the ScrollRescaleMargin to 1.0.

scrollFrame = New RTScrollFrame(Me, currentTemperature1, pTransform1, ChartObj.RT_FIXEDEXTENT_MOVINGSTART_AUTOSCROLL)

scrollFrame.ScrollRescaleMargin = 1.0
chartVu.AddChartObject(scrollFrame)


This will reset the start of the scrolling plot back to the left when the plot reaches the right edge of the frame. Or you can stick with your 0.95 number which will show some data when the plot is reset.
Go to Top of Page

Procentaren

Sweden
8 Posts

Posted - 25 Nov 2014 :  14:20:16  Show Profile  Reply with Quote
The suggested changes made no difference. But I came to think of one thing.
To improve the readability of the code, I removed what I thought was unimportant for the question.
But important to know is that the X-timescale is NOT scrolling along with the curve.
The scale is always numbered 0 - 120 Seconds.
The X-scale has it's own transform.

Public pTransform2 As CartesianCoordinates 'Used for X-axis and DLine
pTransform2 = New CartesianCoordinates(0.0, min, X_range, Ymax)

The problem was that i had assigned also the black DLine to this pTransform2.
Public DerivataPlot As SimpleLinePlot 'For the black DLine.
DerivataPlot = New SimpleLinePlot(pTransform2, Dataset1, DLineAttrib)
Changing pTransform2 to pTransform1 fixed everything.
Sorry for bothering you

Go to Top of Page

quinncurtis

1585 Posts

Posted - 25 Nov 2014 :  16:17:19  Show Profile  Reply with Quote
Sounds correct. Thanks for posting the solution.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Quinn-Curtis Forums © 2000-2018 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07