onTrendParamsChange - událost objektu PmgTrendViewer
Parametry:
pMe | (Object) Reference na PmgTrendViewer objekt, ve kterém daná událost vzniká. |
pEvent | (Object) Reference na objekt, který popisuje informace o dané události.
pEvent.Init - ( Boolean) [ pro čtení] Pokud tento parametr je true, pak je to příznak, že tato událost je vyvolána poprvé (při startu). |
---|
Napojení trendovaných proměnných z parametru trConnect:
Inicializace trendovaných proměnných získaných z parametru trConnect a obnova hodnot do tabulky nakonfigurované jako hlavička prohlížeče trendů
JavaScriptVBScriptVyber a zkopíruj do schránky
//#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();
}
'#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')")
Dim oTHead, oTView, oTrend, nLength, aTr, trConnect, iTrend, nCount
Set oTHead = pMe.Items("../AxTrendsHead")
Set oTView = pMe
If bInit Then
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) And trConnect <> "" Then
aTr = Pm.StringSplit(trConnect, ",", "empty:1;")
nLength = UBound(aTr) + 1
For iTrend = 0 To nLength - 1 Step 2
Set oTrend = oTView.AddTrend("t" & iTrend, "$default")
oTrend.Connect 1, "local", aTr(iTrend), aTr(iTrend + 1), "iniread=name,unit,min,max,color"
Next
End If
' end read and connection parameter "trConnect"
pMe.Vars("cfgini").Value = oTView.GetCfg("Trends;TimeZoom;", "")
End If
nCount = oTView.TrendsCount
oTHead.Rows = nCount + 1
For iTrend = 1 To nCount
Set oTrend = oTView.Trends(iTrend, -1)
If oTrend.Visible Then
oTHead.SetCellText iTrend, 1, ""
Else
oTHead.SetCellText iTrend, 1, "X"
End If
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 Not oTView.Autoscroll Then
oTHead.SetCellText iTrend, 6, Pm.Round(oTrend.CursorValue(2), 0.001)
End If
oTHead.SetCellBackColor iTrend, 0, oTrend.GraphDefault.Color
Next
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 And Not oTView.Autoscroll Then
oTView.ReadData
End If