This sample program is intended to demonstrate one or more programming functions or methods and is presented as programming example only. Schneider Electric assumes no liability for the use or application of this example program or any portion thereof.
This example shows how to use TrendSpec in a Template. Since the full names of points will change from instance to instance, these names cannot be hard coded and an argument needs to be used instead.
Below is an example of a function that uses an argument in TrendSpec instead of the full name of a point. PointName is the argument in this example. The function code resides in one of the mimics from which it needs to be called to generate an Ad Hoc trend. For example, the function can be called from a button and the argument can be passed as below. Note the value of the argument is the point in the template.
Function DisplayTrends (PointName)
Dim showTrend, sTrendProperties, sTraces, sYAxis, sXAxis,
sTrend showTrend = False
msgbox ("You are trending " & PointName)
'Use TrendSpec to generate an Ad Hoc trend.
sTrend = "SCX:////Trend/TREND("
sTrendProperties = "Title = '" & PointName & "',"
sTrendProperties = sTrendProperties & "TitleColour = RGB(50,50,50),"
sTrendProperties = sTrendProperties & "TitleFontStyle = FontStyleBold),"
sXAxis = "XAXIS(RelativeNow, Position=Bottom,"
sXAxis = sXAxis & "Colour = RGB(50,50,50)),"
sTraces = "TRACE(ProcessedHistoric,'Y Axis 1',"
sTraces = sTraces & "SOURCE('" & PointName & "',XOffset = 0,"
sTraces = sTraces & "YOffset = 0, Multiplier = 1),"
sTraces = sTraces & "Label = '" & PointName & "',TraceStyle = TraceLine,"
sTraces = sTraces & "Interval = 200, PointLimit = 50,"
sTraces = sTraces & "ExtendToNow = True,"
sTraces = sTraces & "LineColour = RGB(50,50,50),"
sTraces = sTraces & "LineStyle = DashSolid,"
sTraces = sTraces & "LineWidth = 4, MarkerStyle = Diamond,"
sTraces = sTraces & "MarkerLimit = 250, MarkerSize = 2),"
sYAxis = "YAXIS('Y Axis 1',Label = 'Point Value',"
sYAxis = sYAxis & "LabelPos = Centre,LabelStyle = Normal,"
sYAxis = sYAxis & "Position = Left,ScaleType = Range,"
sYAxis = sYAxis & "Invert = False,ShowGrid = True,"
sYAxis = sYAxis & "Format = '%23%23.%23%23%23',"
sYAxis = sYAxis & "Colour = RGB(50,50,50)),"
'Display the Ad Hoc trend by setting the showTrend flag to True
showTrend = True
If showTrend = True Then
sTrend = sTrend & sTraces
sTrend = sTrend & sYAxis
sTrend = sTrend & sXAxis
sTrend = sTrend & sTrendProperties
Mimic.OpenInset( sTrend ),10,10,80,80
End If
End Function