Эта страница является
переводом страницы
Trends. Перевод выполнен на 90%.
API iRidium. Trends
Methods and properties to work with time graphs
Linear Trend is a type of graphic item that displays a time graph as one or several curves. One of the curves is main and it sets the apppearance of the whole trend.
Time axis - horizontal X axis. Date, the starting point (StartTime) and the ending point (EndTime) can be set. It allows to display history (archive) data on the trend. A trend can also keep track of coming curve values in real time and change display of all curves. In this case use .SetDynamic() method.
Example
Download the example
Trend functions work with two projects: for the server (.sirpz file) and for a panel (.irpz file). The server gets a tag value and stores it in its database. A panel asks the server for data in a required time range and then displays them as a trend on the screen. Trend appearance is controlled in the script of a panel project (.irpz).
For projects to start successfully upload a server project to a real controller or a PC with launched iRidium server via iRidium transfer. A panel project can be uploaded to a real device or can be launched in the Emulator. Before launching a panel project set in it the correct IP address of the server:
Methods of Linear Trend object
.SetDynamic()
sets the time range on the time axis of the trend and automatically assigns the utmost right point of the axis to the current time
Syntax
.SetDynamic(range);
| range
|
1.0
|
type: number time range in a day in the following format
iDate
|
-
Sample
IR.GetPage("Page 1").GetItem("Trend 1").SetDynamic(5/(24*60)); // range = 5 min
.GetCurve()
gives access to a trend curve and its settings.
Syntax
.GetCurve(name);
| name
|
"Curve 1"
|
type: string the name of the curve, access to which is required
|
| -
|
[ ]
|
type: object object of the curve
|
Sample
var Curve1 = IR.GetPage("Main_page").GetItem("Trend").GetCurve("Temperature");
.GetCurve().SetCurveTag()
.SetCurveTag() позволяет указать переменную, график которой будет отображать кривая тренда. Для использования метода, получите доступ к кривой методом .GetCurve()
Синтаксис
.GetCurve(name).SetCurveTag(path);
| на входе
|
значение
|
описание
|
| name
|
"Drivers.Modbus.Register 12"
|
type: string полное имя переменной (можно посмотреть примеры в диалоге Relations, в панели Programming элемента)
|
Пример
IR.GetPage("Main_page").GetItem("Trend").GetCurve("Setpoint").SetCurveTag("Drivers.iRidium Server.KNX.1/4/1");
IR.GetPage("Main_page").GetItem("Trend").GetCurve("Current").SetCurveTag("Drivers.Modbus.Register 12");
IR.GetPage("Main_page").GetItem("Trend").GetCurve("Fan speed").SetCurveTag(""); // clear
Properties of Linear Trend object
.StartTime
| StartTime
|
43259.4621924
|
type: number Date and time of the starting point on the time axis of the trend in the following format iDate.
|
.EndTime
| EndTime
|
43260.4621924
|
type: number Date and time of the ending point on the time axis of the trend in the following format iDate.
|
var tomorrow = new iDate()-1;
var tomorrow_start = new iDate(tomorrow[0], tomorrow[1], tomorrow[2]); // midnight time 00:00:00.000
IR.GetPage("Main_page").GetItem("Trend").StartTime = tomorrow_start;
IR.GetPage("Main_page").GetItem("Trend").EndTime = tomorrow_start+1;
Curve properties
.XInterval
| XInterval
|
365.0
|
type: number Time interval in a day between inscriptions on the time axis in the following format iDate.
|
The property is applied only to the main curve of the trend.
For the trend to be displayed correctly, set XInterval several times shorter than the length of the time axis on the trend (EndTime - StartTime).
IR.GetPage("Main_page").GetItem("Trend").GetCurve("Temperature").XInterval=1/24; // one hour
.XLabelTemplate
| XLabelTemplate
|
"%yy/%mm/%dd"
|
type: string Format of date and time on the time axis
|
The property is applied only to the main curve of the trend.
var time = "%hh:%nn:%ss.%ms"; // hh:mm:ss.ms format
var date = "%dd.%mm.%yy"; // dd.mm.yyyy format
IR.GetPage("Main_page").GetItem("Trend").GetCurve("Temperature").XLabelTemplate = time + " " + date;