Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
4
Erster Beitrag:
vor 2 Jahren, 7 Monaten
Letzter Beitrag:
vor 2 Jahren, 7 Monaten
Beteiligte Autoren:
Robert M, Fabrice Harari

WINDEV: CHART Control

Startbeitrag von Robert M am 14.07.2015 07:29

My dilemma is in 2 parts.

I am trying to plot data that is being collected real-time on a line chart. At any one time I wish to display only n samples. As new samples arrive the equivalent number drop off. In this way I am hoping to see a trend over time.

I am also archiving the samples to a database for later analysis or replay. Under this scenario I am wishing to simulate the real-time collection and plot the data as above.

So far I have the data logged, the chart drawn but I am at a loss on how to attach the chart to the data source for replay, or how to limit the display to a selected number of samples.

Has anyone had any experience with this type scenario? Any pointers would be greatfully received.

thanks

Rob

Antworten:

Hi Rob,

if I understand correctly what you are describing, you could create a query that will get your data sample from archives, and display your chart from there.

If you are filling your chart by code when getitng the data real time, than the same code will work with just geting the data from a hreadnext on the query

Best regards

von Fabrice Harari - am 14.07.2015 10:04
Thanks Fabrice.

Let me add ... the device that I am monitoring produces 20samples per second i.e. 20 plottable points. Over the space of a 10 hour day this is 720,000 samples. So the database at the end of the day will contain 720,000 records.

Now let this run for 6 days say, this is now 4,320,000 records.

Now a series can contain up to 8000 items, after that I don't know what happens. Now I don't wish to plot all 4M data points as the granularity will be too fine, however I would like to create a 1 hour view window over the data and let it unfold. At the raw level this would be 7200 records however I could do some aggregation and collapse 20 data points into 2 plots.

For the moment I am choosing to do the following: but I'm looking for best practice here.

Rob

arrDataSource is array of real
sDataSource is string = ""

sChartName is string = "CHART_REPLAY"

grCreate(sChartName,grCurve)
grDestinationWnd(sChartName,WIN_HOME,"Replay")
grAxisTitle(sChartName,"Volts",grYCoordinate)
grAxisTitle(sChartName,"Time",grXCoordinate)
grGridLines(sChartName,True,grXCoordinate)
grGridLines(sChartName,True,grYCoordinate)
grGraduate(sChartName,1,grYCoordinate)
grGraduate(sChartName,1,grXCoordinate)
grOrigin(sChartName,-5,5,grYCoordinate)
grOrigin(sChartName,0,60,grXCoordinate)

grAutoRefreshSeries(sChartName,1,False)

grLineThickness(sChartName,1,5)
grSeriesColor(sChartName,1,DarkRed)

grSourceSeries(sChartName,1,grProgramming,sDataSource)
grDraw(sChartName)

nRecNum is int = 0
// sSourceName is string = "c:\My Projects\mobileWeatherProducer\Exe\ZebraDB.sqlite"
// HDescribeConnection("MYZEBRA","sa","",sSourceName,"",hNativeAccessSQLite,hORead)

HOpenConnection(zebraDB)

HChangeConnection("*",zebraDB)

HReadFirst(CaptureData,CaptureDataID)
Add(arrDataSource,CaptureData.Volts)
nRecNum++
WHILE HOut(CaptureData) = False AND gbPortOpened = True
Trace(nRecNum + ": " + CaptureData.Volts)
grAddData(sChartName,1,CaptureData.Volts)
HReadNext(CaptureData,CaptureDataID)
IF CaptureData.Volts < -1 OR CaptureData.Volts > 1 THEN
grSeriesColor(sChartName,1,DarkRed)
ELSE
grSeriesColor(sChartName,1,DarkCyan)
END
grDraw(sChartName)
Wait(50)
nRecNum++
END

HClose("*")

von Robert M - am 14.07.2015 12:10
I have my viewer working in the following fashion updating a chart control developed in the IDE.

Once the list gets to 60 in length I keep dropping off the first element.

Any comments would be useful. thanks


arrDataSource is array of real
sDataSource is string = ""

nRecNum is int = 0

HOpenConnection(zebraDB)

HChangeConnection("*",zebraDB)

HReadFirst(CaptureData,CaptureDataID)
Add(garrVoltData,CaptureData.VoltsPerMetre)
grDraw(CHART_PLOT)

nRecNum++
WHILE HOut(CaptureData) = False AND gbStopPlot = False
Trace(nRecNum + ": " + CaptureData.VoltsPerMetre)
HReadNext(CaptureData,CaptureDataID)
ArrayAdd(garrVoltData,CaptureData.VoltsPerMetre)
nRecNum++
grDraw(CHART_PLOT)
ThreadPause(100)
IF ArrayInfo(garrVoltData,tiTotalNumber) > 60 THEN
ArrayDelete(garrVoltData,1)
END
END

HClose("*")

von Robert M - am 14.07.2015 13:28
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.