Update cookies preferences
Promotic

onTrendParamsChange - event of the PmgTrendViewer object

Description:
The event is triggered on viewer start or if basic parameter of one of tvTrend objects has been changed (if an object of the tvTrend type is created or deleted or if the change is in the properties: tvTrend.GraphDefault.Color, tvTrend.ValueMin, tvTrend.ValueMax, tvTrend.Name, tvTrend.Unit or tvTrend.ID).
In this event, it is handy, for example, to use script to set the properties of other Pmg objects (e.g. trend headers - of the PmgWTable object) that are supposed to change based on the current status of the trend viewer.
Parameters:
pMe(Object) Reference to the PmgTrendViewer object where the event rises.
pEvent(Object) Reference to an object describing detailed information about the specific event.
pEvent.Init - (Boolean) [for reading] If this parameter is true, then it signals that this event is triggered for the first time (on start).
Note:
This event is also functional in Web panels.
Connection of trend variables from trConnect parameter:
Initialization of trend variables acquired from trConnect parameter and refresh of values into the table configured as trend viewer header
JavaScriptVBScriptSelect and copy to clipboard

//#pragma variable sName=Macro("$.text('sys','name')")
//#pragma variable sUnit=Macro("$.text('sys','unit')")
//#pragma variable sMin=Macro("$.text('sys','minimum')")
//#pragma variable sMax=Macro("$.text('sys','maximum')")
//#pragma variable sValue=Macro("$.text('sys','value')")

var oTHead = pMe.Items("../AxTrendsHead");
var oTView = pMe;
var oTrend, nLength, aTr, trConnect, iTrend, nCount;

if (bInit)
{
oTHead.SetCellText(0, 2, sName);
oTHead.SetCellText(0, 3, sUnit);
oTHead.SetCellText(0, 4, sMin);
oTHead.SetCellText(0, 5, sMax);
oTHead.SetCellText(0, 6, sValue);
// start read and connection parameter "trConnect"
trConnect = pMe.GetPar("trConnect");
if (Pm.IsValid(trConnect) && trConnect != "")
{
aTr = Pm.StringSplit(trConnect, ",", "empty:1;");
nLength = aTr.GetSize(1);
for (iTrend = 0; iTrend < nLength; iTrend += 2)
{
oTrend = oTView.AddTrend("t" + iTrend, "$default");
oTrend.Connect(1, "local", aTr.GetItem(iTrend), aTr.GetItem(iTrend + 1), "iniread=name,unit,min,max,color");
}
}
// end read and connection parameter "trConnect"
pMe.Vars("cfgini").Value = oTView.GetCfg("Trends;TimeZoom;", "");
}

nCount = oTView.TrendsCount;
oTHead.Rows = nCount + 1;

for (iTrend = 1; iTrend <= nCount; iTrend++)
{
oTrend = oTView.Trends(iTrend, -1);
oTHead.SetCellText(iTrend, 1, oTrend.Visible ? "" : "X");
oTHead.SetCellText(iTrend, 2, oTrend.Name);
oTHead.SetCellTextAlign(iTrend, 2, 0);
oTHead.SetCellText(iTrend, 3, oTrend.Unit);
oTHead.SetCellText(iTrend, 4, Pm.Round(oTrend.ValueMin, 0.001));
oTHead.SetCellText(iTrend, 5, Pm.Round(oTrend.ValueMax, 0.001));
if (! oTView.Autoscroll)
{
oTHead.SetCellText(iTrend, 6, Pm.Round(oTrend.CursorValue(2), 0.001));
}
oTHead.SetCellBackColor(iTrend, 0, oTrend.GraphDefault.Color);
}
oTHead.SetCellBackColor(oTHead.FocusedRow, -3, "transparent");
oTHead.FocusedRow = oTView.TrendActive + 1;
oTHead.SetCellBackColor(oTView.TrendActive + 1, -3, "#009898");

// text align cols
oTHead.SetCellTextAlign(-3, 1, 1);   // Visible - align center
oTHead.SetCellTextAlign(-3, 2, 0);   // Name - align left
oTHead.SetCellTextAlign(-3, 3, 1);   // Unit - align center
oTHead.SetCellTextAlign(-3, 4, 1);   // Min - align center
oTHead.SetCellTextAlign(-3, 5, 1);   // Max - align center
oTHead.SetCellTextAlign(-3, 6, 2);   // Value - align right
oTHead.Draw();
if (bInit && ! oTView.Autoscroll)
{
oTView.ReadData();
}
PROMOTIC 9.0.31 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r.o.