示例#1
0
        //Накапливает абсолютное значение
        private Moment ConnectAbsolute(DateTime absEnd, Moment absVal, TimeInterval baseInt, Moment baseVal)
        {
            if (absVal == null)
            {
                return(baseVal.Clone(baseInt.Begin));
            }
            var absInt = new TimeInterval(absVal.Time, absEnd);

            switch (ArchiveParam.SuperProcess)
            {
            case SuperProcess.AverageA:
            case SuperProcess.AveragePA:
                var m = absVal.Clone(DataType);
                m.Nd  |= baseVal.Nd;
                m.Real = (m.Real * absInt.Length() + baseVal.Real * baseInt.Length()) / (absInt.Length() + baseInt.Length());
                return(m);

            case SuperProcess.SummA:
            case SuperProcess.SummPA:
                m     = absVal.Clone(DataType);
                m.Nd |= baseVal.Nd;
                if (m.DataType.LessOrEquals(DataType.Integer))
                {
                    m.Integer += baseVal.Integer;
                }
                else if (m.DataType == DataType.Real)
                {
                    m.Real += baseVal.Real;
                }
                else
                {
                    m.String = StringSummConnect(m.String, baseVal.String);
                }
                return(m);

            case SuperProcess.MinA:
            case SuperProcess.MinPA:
                return(baseVal > absVal ? absVal : baseVal.Clone(absInt.Begin));

            case SuperProcess.MaxA:
            case SuperProcess.MaxPA:
                return(baseVal < absVal ? absVal : baseVal.Clone(absInt.Begin));

            case SuperProcess.FirstA:
            case SuperProcess.FirstPA:
                return(absVal);

            case SuperProcess.LastA:
            case SuperProcess.LastPA:
                return(baseVal.Clone(absInt.Begin));
            }
            return(null);
        }
示例#2
0
            public object Clone()
            {
                UserOptions uo = new UserOptions((Moment)mStart.Clone(), (Moment)mEnd.Clone());

                uo.Divisions = (Division[])this.Divisions.Clone();
                return(uo);
            }
示例#3
0
        protected override CalcValue GetValue()
        {
            if (_signal.SourceSignal == null)
            {
                if (_signal.HasFormula)
                {
                    _signal.CalcSignalValue = Inputs[0].SingleValue;
                    return(Inputs[0]);
                }
                return(new CalcValue(new SingleValue(new List <Moment>())));
            }
            SingleValue sv = _signal.SourceSignal.Value;

            if (sv == null || !sv.HasMoment)
            {
                sv = _handDefaultValue != null ? new SingleValue(_handDefaultValue.Clone(Thread.PeriodBegin)) : new SingleValue(new List <Moment>());
            }
            return(new CalcValue(sv, _signal));
        }
示例#4
0
        //Вычисляет значение функции Пред f от параметров par
        private SingleValue CalcPrev(string f, CalcValue[] par)
        {
            string acode = par[0].SingleValue.LastMoment.String;
            string scode = acode.Split('.')[0];
            var    pr    = CalcParam.Project;
            var    cpr   = CalcRun;

            while (cpr != pr.RootParam && !cpr.CalcParam.Methods.ContainsKey(scode))
            {
                cpr = cpr.Owner;
            }
            while (cpr != pr.RootParam)
            {
                while (cpr.Inputs.Count != 0)
                {
                    cpr = cpr.Caller;
                }
                acode = cpr.CalcParam.Code + "." + acode;
                cpr   = cpr.Owner;
            }
            if (!pr.ArchiveParams.ContainsKey(acode))
            {
                var err = new ErrorCalc("Не найден архивный параметр " + acode, CalcParam.FullCode);
                return(new SingleValue(new Moment(par[1].SingleValue.DataType, err)));
            }
            var beg = pr.ThreadCalc.PeriodBegin;
            var p1  = par[1].SingleValue.LastMoment.Clone(beg);

            if (f == "prevabs")
            {
                var ap = pr.ArchiveParams[acode];
                var m  = ((ap.AbsoluteEnd == beg && ap.AbsoluteValue != null) ? ap.AbsoluteValue : p1).Clone();
                if (par.Length == 2 || !par[2].SingleValue.LastMoment.Boolean)
                {
                    m.Time = beg;
                }
                return(new SingleValue(m));
            }
            var    pp  = pr.PrevParams[acode];
            Moment mom = null;

            if (f == "prev")
            {
                mom = (pp.LastBase == null || pp.LastBase.DataType == DataType.Value) ? p1 : pp.LastBase;
            }
            if (f == "prevhour")
            {
                mom = (pp.LastHour == null || pp.LastHour.DataType == DataType.Value) ? p1 : pp.LastHour;
            }
            if (f == "prevday")
            {
                mom = (pp.LastDay == null || pp.LastDay.DataType == DataType.Value) ? p1 : pp.LastDay;
            }
            if (mom != null)
            {
                return(new SingleValue(mom.Clone(beg)));
            }
            if (f == "prevmom")
            {
                return(new SingleValue(pp.ManyMoments.Where(m => beg.Subtract(m.Time).TotalMinutes <= p1.Real).ToList()));
            }
            if (f == "prevperiod")
            {
                return(new SingleValue(pp.ManyBase.Where(m => beg.Subtract(m.Time).TotalMinutes <= p1.Real).ToList()));
            }
            if (f == "prevhourperiod")
            {
                return(new SingleValue(pp.ManyHour.Where(m => beg.Subtract(m.Time).TotalHours <= p1.Real).ToList()));
            }
            if (f == "prevdayperiod")
            {
                return(new SingleValue(pp.ManyDay.Where(m => beg.Subtract(m.Time).TotalDays <= p1.Real).ToList()));
            }
            return(null);
        }
示例#5
0
 protected override CalcValue GetValue(CalcParamRun calcRun)
 {
     return(new CalcValue(new SingleValue(_moment.Clone(_thread.PeriodBegin))));
 }
示例#6
0
 protected override CalcValue GetValue()
 {
     return(new CalcValue(new SingleValue(_moment.Clone(Thread.PeriodBegin))));
 }