Applies To:
  • CitectSCADA 5.xx

Summary:
How do I get the value of a trend tag from a Citect trend file in the run time system using cicode? I want to get one point at any specified time. 

Solution:
The following function will get the value of any trend tag at a specified time and date.


/*
** Function Name: GetTrendFileData()
** Called by :
** Inputs: The trend Tag Name, Time and Date (as strings)
**
*/

REAL rFileData[1];


FUNCTION

GetTrendFileData(STRING sTrendTag, STRING sDate, STRING sTime)

STRING sPeriod = TrnInfo(sTrendTag, 2);
STRING sEnd_Time;
INT iSamples;

iSamples =1;
sEnd_Time = StrToDate(sDate) + StrToTime(sTime);

ErrSet(1);
TrnGetTable(sTrendTag, sEnd_Time, 0, iSamples, rFileData[0], 1);
ErrSet(0);
YourTagName = rFileData[0];
END

When you need to get the value, call the function like this;

GetTrendFileData("Loop_1_PV", "22/09/2000", "12:30")

 

Keywords:
 

Attachments