0% found this document useful (0 votes)
173 views

GraphWorX64 Scripting - Interacting With A TrendWorX64 Viewer

GraphWorX64 Scripting
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
173 views

GraphWorX64 Scripting - Interacting With A TrendWorX64 Viewer

GraphWorX64 Scripting
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

GraphWorX64 Scripting

Interacting with a TrendWorX64 Viewer


August 2014

Description: A scripting guide demonstrating how to interact Scroll down to the bottom of the References window and click in
with the TrendWorX64 Viewer control. the cell for Assembly Codebase in the last empty row. Click the
General Requirement: General knowledge of GraphWorX64 and button that will appear when you click in the cell. Browse to
its scripting capabilities; familiarity with the TrendWorX64 Viewer the following file and add it:
control.
C:/Program Files/ICONICS/GENESIS64/Components/
Introduction IcoDataConnector.DLL
C:/Program Files/ICONICS/GENESIS64/Components/
This guide will introduce you to writing scripts that interface with IcoCommonConnectors.DLL
the TrendWorX64 Viewer. It includes examples of how to add a
new pen, delete or modify an existing pen and toggle legend Add Pen script
using GraphWorX64 Scripting.
First we need to prepare the connection configuration, which
This document assumes that you have read the GraphWorX64 means what type of data source we want to connect and its
Scripting Quick Start application note. properties. In the following script we will define a connection to
TrendWorX64 Logger pen without any aggregates.
Preparing the display
var config : Ico.Data.DataConnector.UaSessionConfiguration;
config = new Ico.Data.DataConnector.UaSessionConfiguration();
To create this example we will need a display containing a config.PointName = "@ICONICS.TWXSQLSvr64.1\\Database Group.Logging
TrendWorX64 Viewer control with a plot. You will not be able to Group.Ramp.History";
config.UsageType = Ico.Data.DataConnector.UaSessionConfiguration.Usage.History;
add pens to your control unless it contains at least one plot. config.AggregateType = ""; // raw data
config.MaxSamplesForRawData = 125;
It is very important that the trend viewer control, chart and its
plot have unique names. Our scripts will use this name to Next we will create a new pen and will attach the above
identify which trend viewer to interact with (in case there is more connection configuration to it.
than one on a display). The names can be assigned in the
var pen : Ico.Twx.TwxChartPen = new Ico.Twx.TwxChartPen();
Advanced tab of the respective item.
pen.RangeAxis.ShowTitle = true;
pen.Name = "Pen1";
pen.Stroke = new SolidColorBrush(Colors.Blue);
pen.DataConnectionConfiguration = config.GetConfiguration();

Having created a pen with configuration we need to get a


reference to our TrendWorX64 Viewer where we want the pen to
be added. Also we have to specify the appropriate plot (series).
Figure 1 TrendWorX64 Viewer called TWX with a plot called Plot1
var control : Ico.Twx.TwxViewControl = ThisDocument.GetElementByName("TWX");
var series : Ico.Twx.TwxSeries;
Adding References series = control.FindSeries("Plot1");

The following code requires some extra references beyond the Finally we just add the pen.
defaults. To add these references, open the Script Editor and
series.Pens.Add(pen);
click on the Add References button on the left.
The code is complete. We can save our display, go to runtime
mode, then press the button add our new pen.

NOTE: Wait a moment if you do not see the pen immediately. It may
need a few seconds to begin drawing its line.

Figure 2 - Add References button

Copyright 2014 ICONICS, Inc. Page 1 of 2 GraphWorX64 Scripting - Interacting with a TrendWorX64 Viewer
GraphWorX64 Scripting
Interacting with a TrendWorX64 Viewer
August 2014

Edit Pen Script Toggle Legend Script

First we need to get a reference to our TrendWorX64 Viewer and Get reference to your control and chart.
the concerned pen.
var control : Ico.Twx.TwxViewControl = ThisDocument.GetElementByName("TWX"); var control : Ico.Twx.TwxViewControl = ThisDocument.GetElementByName("TWX");
var pen : Ico.Twx.TwxChartPen var chart: Ico.Twx.TwxChartComponent
pen = control.FindPen("Pen1"); chart = control.FindChartComponent("Chart1");

Next we may modify the properties such as color or stroke Toggle the legend visibility.
thickness in this example.
chart.ShowLegend = !chart.ShowLegend;

pen.Stroke = new SolidColorBrush(Colors.Red);


pen.StrokeThickness = 5; Conclusion
Delete Pen Script These simple examples show some important concepts, like how
to get a reference to a TrendWorX64 Viewer control. This is very
First we need to get a reference to our TrendWorX64 Viewer and similar to the procedure for getting a reference to other controls
the concerned pen. as well. Youve also learned about how the TrendWorX64 Viewer
is structured and how to interact with its elements.
var control : Ico.Twx.TwxViewControl = ThisDocument.GetElementByName("TWX");
var pen : Ico.Twx.TwxChartPen
Feel free to experiment with the other available methods. You
pen = control.FindPen("Pen1");
can find these by using the Intelli-sense built into the Script
When removing pen we also need to get reference of the series Editor, or by browsing the GENESIS64 API Reference Help.
where the plot is located.
ICONICS Customer Connection Portal hosts a library of
var series : Ico.Twx.TwxSeries;
automation examples that are very handy when you start
series = control.FindSeries("Plot1");
scripting.
Then we can delete our pen.

series.Pens.Remove(pen);

Copyright 2014 ICONICS, Inc. Page 2 of 2 GraphWorX64 Scripting - Interacting with a TrendWorX64 Viewer

You might also like