Пример #1
0
        private Double ExpCurrentValue(String expression)
        {
            RTInterface RTDataAccess = DBAccess.GetRealTime();

            try {
                if (String.IsNullOrEmpty(expression))
                {
                    return(Double.MinValue);
                }
                int pos = expression.LastIndexOf("'") - 1;
                if (pos <= 0)
                {
                    return(double.MinValue);
                }
                String tagName  = expression.Substring(1, pos);
                double tagValue = RTDataAccess.GetSnapshotValue(tagName);
                String Token    = expression.Substring(pos + 2, 1);
                pos = expression.IndexOf(Token) + 1;
                String Val         = expression.Substring(pos, expression.Length - pos);
                double targetValue = Convert.ToDouble(Val);
                return(tagValue - targetValue);
            }
            catch (Exception ex) {
                m_Loger.Error("解析机组运行条件处发生错误", ex);
                return(double.MinValue);
            }
        }
Пример #2
0
        /// <summary>
        /// 根据当前电量和上一时刻电量计算电量差值
        /// </summary>
        /// <param name="tagName"></param>
        /// <param name="span"></param>
        /// <returns></returns>
        private double PowerDiff(String tagName, double span)
        {
            double   Result   = 0.0f;
            DateTime LastTime = DateTime.Now.AddMinutes(-1 * span);                //上一时刻
            //RTInterface RTDataAccess = DBAccess.GetRealTime();
            double CurrentValue = RTDataAccess.GetSnapshotValue(tagName);          //当前值
            double LastValue    = RTDataAccess.GetArchiveValue(tagName, LastTime); //上一时刻值

            Result = CurrentValue - LastValue;
            return(Result);
        }