示例#1
0
        public override IBalanceItem Copy()
        {
            var s = new Substation
            {
                Id          = this.Id,
                Code        = this.Code,
                Name        = this.Name,
                Description = this.Description,
                Departament = this.Departament,
                Voltage     = this.Voltage
            };

            s.SetSubstation(this.Substation);
            foreach (IBalanceItem child in this.Children)
            {
                s.Children.Add(child.Copy());
            }

            return(s);
        }
示例#2
0
 public void SetSubstation(Substation substation)
 {
     Substation = substation;
 }
示例#3
0
        /// <summary>
        /// Получение архивных данных по указанной подстанции
        /// </summary>
        /// <param name="startDate">Начальная дата</param>
        /// <param name="endDate">Конечная дата</param>
        /// <param name="substation">Подстанция</param>
        /// <param name="cts">Маркер отмены</param>
        /// <param name="callback">Функция обратного вызова, для информирования о прогрессе</param>
        /// <returns>True если успешно</returns>
        public static bool GetArchiveDataForSubstation(DateTime startDate, DateTime endDate,
                                                       Model.Balance.Substation substation, System.Threading.CancellationTokenSource cts, Action <int, int> callback)
        {
            bool error;

            int current = 0, total = 0;

            bool hasMonthData = HasDateIntervalMonth(startDate, endDate);
            // измерения - А энергия за сутки
            var measurementsDaysPart = @"T2_TYPE_0=MSF&T2_NAME_0=А энергия&T2_MSF_ID_0=14&T2_MSF_NAME_0=А энергия&T2_AGGS_TYPE_ID_0=3&T2_MS_TYPE_ID_0=1";
            // А энергия за месяц
            var measurementsMonthPart = @"&T2_TYPE_1=MSF&T2_NAME_1=А энергия&T2_MSF_ID_1=14&T2_MSF_NAME_1=А энергия&T2_AGGS_TYPE_ID_1=4&T2_MS_TYPE_ID_1=1";
            //
            var measurementsEndPartIfNotHasMonth = "&T2_COUNT=1&";
            var measurementsEndPartIfHasMonth    = "&T2_COUNT=2&";

            substation.Status = Model.DataStatus.Processing;
            error             = false;

            string[] wids = null;

            if (substation.Children == null || substation.Children.Count == 0)
            {
                error = true;
            }
            else
            {
                if (substation.Items == null)
                {
                    TMPApplication.TMPApp.LogInfo(String.Format("Подстанция <{0}> не имеет точек.", substation.Name));
                    error = true;
                }
                else
                {
                    try
                    {
                        var    items  = substation.Items.Cast <Model.IEmcosPoint>();
                        string points = EmcosSiteWrapper.Instance.CreatePointsParam(items);
                        wids = EmcosSiteWrapper.Instance.GetArchiveWIds(
                            hasMonthData
                              ? measurementsDaysPart + measurementsMonthPart + measurementsEndPartIfHasMonth
                              : measurementsDaysPart + measurementsEndPartIfNotHasMonth,
                            points, startDate, endDate, cts.Token);
                    }
                    catch (Exception e)
                    {
                        TMPApplication.TMPApp.LogInfo("GetSubstationsDaylyArchives - ошибка: " + e.Message);
                        error = true;
                    }
                    if (wids == null || wids.Length == 0)
                    {
                        TMPApplication.TMPApp.LogInfo("GetSubstationsDaylyArchives - ошибка получен неверный wid. Подстанция - " + substation.Name);
                        error = true;
                    }
                }
            }
            if (error == false)
            {
                var mls = EmcosSiteWrapper.Instance.GetParamsForArchiveData(wids[0]);

                var m = mls.ToList();

                total = substation.Items.Count;
                // получение архивных данных по каждой из точек
                foreach (Model.Balance.IBalanceItem item in substation.Items)
                {
                    if (item == null)
                    {
                        throw new ArgumentNullException();
                    }

                    current++;
                    if (callback != null)
                    {
                        callback.Invoke(current, total);
                    }

                    GetBalanceItemArchiveData(item, startDate, endDate, cts);
                }
            }
            substation.Status = Model.DataStatus.Processed;
            return(error == false);
        }