Promotic
WikipediaLinkedInYoutubeTwitterFacebook

onTrendParamsChange - event of object TrendsView

Description:
The event fires on viewer start or if basic parameter of one of the tvTrend object type has been changed (if an object of the tvTrend type is created or deleted or 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 items (e.g. trend headers - of the PmTable object) that are supposed to change based on the current status of the trend viewer.

Parameters:
pMe(Object) Reference to the PmiAx object that owns this ActiveX. The reference to the ActiveX object itself can be obtained by the pMe.Acx expression.
bInit(Boolean) If this parameter is true, then it signals that this event is called for the first time (on start).
Connection of trend values from trConnect marameter:
Initialization of trend values 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").Acx;
var oTView = pMe.Acx;
var oTrend, nLength, aTr, trConnect, i, 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 != "")  //end read and connection parameter "trConnect"
  {
    aTr = Pm.StringSplit(trConnect, ",", "empty:1;");
    nLength = aTr.GetSize(1);
    for (i = 0; i < nLength; i += 2)
    {
      oTrend = oTView.AddTrend("t" + i, "$default");
      oTrend.Connect(1, "local", aTr.GetItem(i), aTr.GetItem(i + 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 (i = 1; i <= nCount; i++)
{
  oTrend = oTView.Trends(i, -1);
  oTHead.SetCellText(i, 1, oTrend.Visible ? "" : "X");
  oTHead.SetCellText(i, 2, oTrend.Name);
  oTHead.SetCellTextAlign(i, 2, 0);
  oTHead.SetCellText(i, 3, oTrend.Unit);
  oTHead.SetCellText(i, 4, Pm.Round(oTrend.ValueMin, 0.001));
  oTHead.SetCellText(i, 5, Pm.Round(oTrend.ValueMax, 0.001));
  if (!oTView.Autoscroll)
    oTHead.SetCellText(i, 6, Pm.Round(oTrend.CursorValue(2), 0.001));
  oTHead.SetCellBackColor(i, 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 8.3.24 SCADA system documentation - MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice