/// <summary> /// Sets the current input channel data. /// </summary> public void SetCurCnlData(CnlTag cnlTag, CnlData cnlData, DateTime nowDT) { int cnlIndex = cnlTag.Index; DateTime prevTimestamp = Timestamps[cnlIndex]; CnlData prevCnlData = CnlData[cnlIndex]; cnlDataChangeHandler.HandleCurDataChanged(cnlTag, ref cnlData, prevCnlData, nowDT, prevTimestamp); PrevTimestamps[cnlIndex] = prevTimestamp; PrevCnlData[cnlIndex] = prevCnlData; Timestamps[cnlIndex] = nowDT; CnlData[cnlIndex] = cnlData; }
/// <summary> /// Sets the current channel data. /// </summary> public void SetCurrentData(CnlTag cnlTag, ref CnlData cnlData, DateTime timestamp, bool enableEvents = true) { int cnlIndex = cnlTag.Index; CnlData prevCnlData = CnlData[cnlIndex]; CnlData prevCnlDataDef = prevCnlData.IsDefined ? prevCnlData : PrevCnlDataDef[cnlIndex]; dataChangingHandler(cnlTag, ref cnlData, prevCnlData, prevCnlDataDef, enableEvents); PrevTimestamps[cnlIndex] = Timestamps[cnlIndex]; PrevCnlData[cnlIndex] = prevCnlData; if (prevCnlData.IsDefined) { PrevCnlDataDef[cnlIndex] = prevCnlData; } Timestamps[cnlIndex] = timestamp; CnlData[cnlIndex] = cnlData; }
/// <summary> /// Calculates the channel data. /// </summary> public CnlData CalcCnlData(CnlTag cnlTag, CnlData initialCnlData) { if (cnlTag != null && cnlTag.CalcEngine != null && cnlTag.CalcCnlDataFunc != null) { try { cnlTag.CalcEngine.BeginCalcCnlData(cnlTag.CnlNum, cnlTag.Cnl, initialCnlData); return(cnlTag.CalcCnlDataFunc()); } catch { return(new CnlData(initialCnlData.Val, CnlStatusID.FormulaError)); } finally { cnlTag.CalcEngine.EndCalcCnlData(); } } else { return(initialCnlData); } }