caprez95 - 2024-06-11

Hallo

Ich möchte eine laufende Trendaufzeichnung stoppen, den Inhalt löschen und Trend-Diagramm auf 0 zurücksetzen.

Laut Codesys soll das mit dem folgenden Code möglich sein:

You can insert an input element in the visualization which the operator can use to delete the previous value recording in the trend visualization at runtime. The curve displayed until then is removed and the display starts over.

In the application (example: in the program PLC_PRG), implement the following code:

itfTrendRecording : ITrendRecording;
itfTrendStorageWriter : ITrendStorageWriter;
itfTrendStorageWriter3 : ITrendStorageWriter3;
sTrendRecordingName : STRING := 'TrendRecording';
itfTrendRecording := GlobalInstances.g_TrendRecordingManager.FindTrendRecording(ADR(sTrendRecordingName));
xClearHistoryTrend: BOOL;

IF xClearHistoryTrend THEN
itfTrendRecording := GlobalInstances.g_TrendRecordingManager.FindTrendRecording(ADR(sTrendRecordingName));
IF itfTrendRecording <> 0 THEN
    itfTrendStorageWriter := itfTrendRecording.GetTrendStorageWriter();
    IF __QUERYINTERFACE(itfTrendStorageWriter, itfTrendStorageWriter3) THEN itfTrendStorageWriter3.ClearHistory();
    END_IF
END_IF
In the visualization of the trend recording, add a button for deleting the previous curve. Configure its Toggle property with the variable PLC_PRG.xClearHistoryTrend.

⇒ When xClearHistoryTrend is set to TRUE, the previously recorded curve is deleted. The recording immediately starts again.

Dies löscht auch die Daten vom Trend, aber das Diagramm wird nicht auf 0 zurückgesetzt, sondern läuft einfach da weiter wo man gestoppt hat.

Braucht es für den Diagramm-Reset noch einen zusätzlichen Befehl?

Gruss