AddTrace method (XY Plot object)
Adds a new trace to the runtime chart. This method returns
True
if the trace was
successfully added to the XY Plot, False
if the trace was not added.Syntax
XYPlot1
.AddTrace
(String xTagName
, String yTagName
, [xModelName
], [yModelName
], [Integer xTraceType
], [Integer yTraceType
]) As Boolean
where
XYPlot1
- is the name of an XY Plot object or an expression that evaluates to an XY Plot object.xTagName
- is a parameter of the type String that specifies the name of the x tag to
add to the XY Plot.yTagName
- is a parameter of the type String that specifies the name of the y tag to
add to the XY Plot.xModelName
- is an optional parameter of the type String that specifies the Data Log
model name, DataLogPro group name, FactoryTalk Historian connection name, Asset Framework
connection name, or PI Server name for the x tag.yModelName
- is an optional parameter of the type String that specifies the Data Log
model name, DataLogPro group name, FactoryTalk Historian connection name, Asset Framework
connection name, or PI Server name for the y tag.xTraceType
- is a parameter of the XYTraceType
constant that specifies the
trace type of x tag.yTraceType
- is a parameter of the XYTraceType
constant that specifies the
trace type of y tag. Use the following types to specify the data source for
xTraceType
or yTraceType
:- XYTraceTypeEmpty(0): Uses the default trace type, Live Data.
- XYTraceTypeLiveData(1): FactoryTalk Live Data tags.
- XYTraceTypeDataLog(2): FactoryTalk View SE data log model tags.
- XYTraceTypeHistorian(3): FactoryTalk Historian tags (or points).
- XYTraceTypePIServer(6): PI Server tags (or points).
- XYTraceTypeDataLogProPlus(7): FactoryTalk View SE DataLogPro tags.
- XYTraceTypeAF(8): FactoryTalk Historian Asset Framework tags (or attributes).
Return Value
- If true
, it is a valid, online tag. If false
, it is an
invalid or offline tag. Note that if a Data Log or Historian tag has to fall back to the
Live Data tag, this returns true
because it is still a valid, online tag.If a Data Log or Historian name is provided, and the tag is not found, XY Plot will fall
back to determine if it is a Live Data tag, and if so, will add the trace as a Live Data
tag.
Example
Private Sub btnAddTrace() Dim result As Boolean 'Add a trace for the Live Data tags system\Second and system\Minute. result = XYPlot1.AddTrace("system\Second", "system\Minute") 'Add a trace for TagX from the Data Log Datalog1 and TagY from the Data Log Datalog2. result = XYPlot1.AddTrace("TagX", "TagY", "Datalog1", "Datalog2", XYTraceTypeDataLog, XYTraceTypeDataLog) 'Add a trace for Tag1X from the historian server Historian1 and Tag1Y from the historian server Historian2. result = XYPlot1.AddTrace("Tag1X", "Tag1Y", "Historian1", "Historian2", XYTraceTypeHistorian, XYTraceTypeHistorian) 'Add a trace for Tag2X from the PI Server connection PIServer1 and Tag2Y from the PI Server connection PIServer2. result = XYPlot1.AddTrace("Tag2X", "Tag2Y", "PIServer1", "PIServer2", XYTraceTypePIServer, XYTraceTypePIServer) 'Add a trace for LogX and LogY from DataLogPro. result = XYPlot1.AddTrace("LogX", "LogY", "DataLogPro", "DataLogPro", XYTraceTypeDataLogProPlus, XYTraceTypeDataLogProPlus) 'Add a trace for motor speed from the Asset Framework connections AssetFramework1 and AssetFramework2. result = XYPlot1.AddTrace("Motor.X", "Motor.Y", "AssetFramework1", "AssetFramework2", XYTraceTypeAF, XYTraceTypeAF) End Sub
Provide Feedback