示例#1
0
 protected internal DataTrend_Index _DataTrend_Index_VirtualBase = null;         //绑定对象(虚拟对象是存在)
 public DataTrend_Index(double value, DateTime time, DataAnalyse_Trend dataAnalyse_Index, DataTrend_Index dataVBase = null) : base(value, time)
 {
     _Tag                         = "DataIndex";
     _IsVirtual                   = dataVBase != null;
     _DataAnalyse_Trend           = dataAnalyse_Index;
     _DataTrend_Index_VirtualBase = dataVBase;
     _LabelInfo                   = new DataTrend_LabelInfo();
 }
示例#2
0
        //数据处理--数据趋势
        protected virtual bool dataHandle_DataTrend(DataTrend_Index data)
        {
            //趋势判断
            DataTrend_LabelInfo pLabelInfo = data.LabelInfo;
            double dDelta = pLabelInfo.Difference;

            if (Math.Abs(dDelta) >= _valueStep || Math.Abs(pLabelInfo.Difference_Ratio) >= _valueDelta)
            {
                pLabelInfo.DataTrend = dDelta > 0 ? typeDataTrend.RAISE : dDelta < 0 ? typeDataTrend.FALL : typeDataTrend.NONE;
            }
            else
            {
                pLabelInfo.DataTrend = typeDataTrend.NONE;
            }
            return(true);
        }
示例#3
0
        //数据处理--数据趋势关键线
        protected virtual bool dataHandle_DataTrend_KeyLine(DataTrend_Index data)
        {
            bool bResult = true;
            DataTrend_LabelInfo pLabelInfo       = data.LabelInfo;
            DataTrend_LabelInfo pLabelInfo_Orgin = null;

            foreach (var item in _dataKeyLines)
            {
                (typeDataTrend, typeDataTrend_KeyPoint, double)pResult = item.Value.Analysis(data.Value);
                if (pResult.Item1 != typeDataTrend.NONE)
                {
                    if (_useConsole)
                    {
                        zxcConsoleHelper.Debug(true, "监测值:{3}, {0} {1} ({2})", pResult.Item1.ToString(), pResult.Item2.ToString(), pResult.Item3, Math.Round(data.Value, 6));
                    }

                    //复制备用
                    if (pLabelInfo_Orgin == null)
                    {
                        pLabelInfo_Orgin = zxcCloneDeep.Clone <DataTrend_LabelInfo>(pLabelInfo);
                    }

                    //更新值
                    pLabelInfo.Tag                = item.Key;
                    pLabelInfo.DataTrend          = pResult.Item1;
                    pLabelInfo.DataTrend_KeyPoint = pResult.Item2;
                    pLabelInfo.Value_KeyLine      = pResult.Item3;
                    bResult = bResult && this.dataHandle_Event(data);
                }
            }

            //还原
            if (pLabelInfo_Orgin != null)
            {
                pLabelInfo.Tag                = pLabelInfo_Orgin.Tag;
                pLabelInfo.DataTrend          = pLabelInfo_Orgin.DataTrend;
                pLabelInfo.DataTrend_KeyPoint = pLabelInfo_Orgin.DataTrend_KeyPoint;
                pLabelInfo.Value_KeyLine      = pLabelInfo_Orgin.Value_KeyLine;
            }
            return(bResult);
        }
示例#4
0
        //数据处理--数据趋势关键点
        protected virtual bool dataHandle_DataTrend_KeyPoint(DataTrend_Index data, DataTrend_Index dataLast_Recursion = null)
        {
            //计算变化幅度
            DataTrend_LabelInfo pLabelInfo = data.LabelInfo;
            double dRatio = Math.Round(pLabelInfo.Difference / this._valueBase.Value, 6);

            pLabelInfo.Difference_Ratio = dRatio;
            if (_useConsole)
            {
                zxcConsoleHelper.Debug(true, "监测值:{1} ({0}),变动:{2},时间:{3}", Math.Round(data.Value, 6), dataLast_Recursion.Value, dRatio, data.Time.ToString("HH:mm:ss"));
            }
            if (dRatio == 0)
            {
                return(true);
            }


            //识别变化方向
            double dValue          = data.Value;
            int    nDirection_Last = (int)this._valueLast_Amend.LabelInfo.DataTrend; //升降标识,升为正,降为负

            if (dRatio * nDirection_Last >= 0)                                       //同方向,超限触发超限点及该值
            {
                if (dRatio > 0 && _valueMax <= data.Value)                           //上升,关键点--阶段新高
                {
                    if (data.Value - _valueMax >= 0.5 * _dataStatistics.Value_interval)
                    {
                        _valueMax = data.IsHitPoint ? this._dataStatistics.Max : this._dataStatistics.Max + 0.5 * _dataStatistics.Value_interval;
                        pLabelInfo.DataTrend_KeyPoint = typeDataTrend_KeyPoint.MAX;
                    }
                }
                else if (dRatio < 0 && _valueMin >= data.Value) //下降,关键点--阶段新低
                {
                    if (_valueMin - data.Value >= 0.5 * _dataStatistics.Value_interval)
                    {
                        _valueMin = data.IsHitPoint ? this._dataStatistics.Min : this._dataStatistics.Min - 0.5 * _dataStatistics.Value_interval;
                        pLabelInfo.DataTrend_KeyPoint = typeDataTrend_KeyPoint.MIN;
                    }
                }
                else if (_canRetreat && dRatio < 0 && _dataStatistics.Max_Original - data.Value >= _valueRetreatStep)     //回撤,关键点--阶段回撤
                {
                    if (_dataStatistics.Max_Original > _dataStatistics.Min_Original)
                    {
                        pLabelInfo.DataTrend_KeyPoint = typeDataTrend_KeyPoint.RETREAT;
                        pLabelInfo.Value_KeyLine      = this._dataStatistics.Max_Original;  //记录前值极点
                        pLabelInfo.DataTrend          = typeDataTrend.FALL;                 //修正当前方向
                        _canRetreat = false;
                    }
                }
            }
            else
            {
                //拐点判断(反向超限即为拐点)
                double valueLimit = nDirection_Last > 0 ? this._dataStatistics.Max_Original : this._dataStatistics.Min_Original;
                double ratioLimit = dValue - valueLimit;
                if (Math.Abs(ratioLimit) - this._valueStep > -0.00000001)
                {
                    //初始新统计对象
                    double dMin = nDirection_Last < 0 ? this._dataStatistics.Min_Original : dValue;
                    double dMax = nDirection_Last > 0 ? this._dataStatistics.Max_Original : dValue;
                    this.InitStatistics(dValue, data.Time, dMax, dMin);

                    //标识关键点--拐点信息
                    pLabelInfo.Value_KeyLine                  = valueLimit + _valueStep * nDirection_Last;
                    pLabelInfo.DataTrend_KeyPoint             = typeDataTrend_KeyPoint.INFLECTION;
                    pLabelInfo.Value_KeyLine                  = ratioLimit > 0 ? dMin : dMax;                              //记录前值极点
                    pLabelInfo.DataTrend                      = ratioLimit > 0 ? typeDataTrend.RAISE : typeDataTrend.FALL; //修正当前方向
                    this._valueLast_Amend.LabelInfo.DataTrend = pLabelInfo.DataTrend;                                      //修正前一(缓存修正对象)方向
                }
            }
            return(this.dataHandle_Event(data));
        }
示例#5
0
        //数据处理--数据趋势详情
        protected virtual bool dataHandle_DataTrend_Detail(DataTrend_Index data)
        {
            //趋势详情判断
            DataTrend_LabelInfo pLabelInfo = data.LabelInfo;
            double dDelta = pLabelInfo.Difference;

            //利用前值进行计算(屏蔽第一个值)
            if (data._DataTrend_Index_Last._DataTrend_Index_Last != null)
            {
                double dDelta1    = data._DataTrend_Index_Last.LabelInfo.Difference;
                double dDirection = dDelta * dDelta1;               //同向标识,升为正,降为负
                double dDRatio    = dDelta / dDelta1;               //前后差值升降幅度

                pLabelInfo.DataTrend_Detail = typeDataTrend_Detail.NONE;
                if (dDirection > 0)
                {
                    if (dDRatio > 1.125 && dDRatio < 1.5)
                    {
                        pLabelInfo.DataTrend_Detail = typeDataTrend_Detail.SPEEDUP;
                    }
                    else if (dDRatio >= 1.5)
                    {
                        pLabelInfo.DataTrend_Detail = typeDataTrend_Detail.SPEEDTOP;
                    }
                    else if (dDRatio < -0.25 && dDRatio > -1)
                    {
                        pLabelInfo.DataTrend_Detail = typeDataTrend_Detail.SLOWDOWN;
                    }
                    else if (dDRatio <= -1)
                    {
                        pLabelInfo.DataTrend_Detail = typeDataTrend_Detail.SLOWTOP;
                    }
                }
                else
                {
                    // 波动处
                    if (dDelta1 > 0)
                    {
                        if (dDRatio < -0.25 && dDRatio > -1)
                        {
                            pLabelInfo.DataTrend_Detail = typeDataTrend_Detail.SLOWDOWN;
                        }
                        else if (dDRatio <= -1)
                        {
                            pLabelInfo.DataTrend_Detail = typeDataTrend_Detail.SLOWTOP;
                        }
                    }
                    else
                    {
                        if (dDRatio > 1.125 && dDRatio < 1.5)
                        {
                            pLabelInfo.DataTrend_Detail = typeDataTrend_Detail.SPEEDUP;
                        }
                        else if (dDRatio >= 1.5)
                        {
                            pLabelInfo.DataTrend_Detail = typeDataTrend_Detail.SPEEDTOP;
                        }
                    }
                }
            }
            return(true);
        }