Esempio n. 1
0
 internal void Update(DateTime now, SubStationData substationData)
 {
     RealDataModel.Update(now, "正常", PointState.OK);
     AnalogPointModels.ForEach(p => p.Update(now, substationData.SensorRealDataInfos));
     try
     {
         lock (_lock)
         {
             FluxPointModels.ForEach(p => p.Update(now, AnalogPointModels.Select(p => p.RealDataModel).ToList()));
         }
         SubStationRunModel.UpdateSubStationRun(ref _subStationRunModel, _subStationRunModels, RealDataModel, this);
     }
     catch (Exception ex)
     {
         LogD.Error(ex.ToString());
     }
 }
Esempio n. 2
0
        internal void UpdateBitError(DateTime now)
        {
            var value = "通信误码";
            var state = PointState.BitError;

            _bitErrorCount++;
            if (_bitErrorCount >= 3)
            {
                // 连续大于三次才算通信误码.
                RealDataModel.Update(now, value, state);
            }
            else
            {
                // 只更新时间
                RealDataModel.Update(now);
            }
            SubStationRunModel.UpdateSubStationRun(ref _subStationRunModel, _subStationRunModels, RealDataModel, this);
        }
Esempio n. 3
0
        private static SubStationRunModel NewSubStationRunModel(RealDataModel realDataModel, SubStationModel subStationModel)
        {
            var model = new SubStationRunModel();

            model.SubStationID         = realDataModel.SubStationID;
            model.SubStationName       = subStationModel.SubStationName;
            model.Location             = subStationModel.Location;
            model.SubStationState      = realDataModel.RealState;
            model.SubStationStateValue = realDataModel.RealValue;
            model.StartTime            = realDataModel.RealDate;
            model.EndTime       = realDataModel.RealDate;
            model.SpanTime      = 0;
            model.State         = 0;
            model.Treatement    = "";
            model.TreatmentTime = DateTime.Now;
            model.Writer        = 0;
            return(model);
        }
Esempio n. 4
0
        public void UpdateNetOff(DateTime now)
        {
            var value = "网络中断";
            var state = PointState.OFF;

            _tcpOffCount++;
            if (_tcpOffCount < DasConfig.NetworkOffCount &&
                this.RealDataModel.RealState == (int)PointState.OK)
            {
                RealDataModel.Update(now);
                AnalogPointModels.ForEach(p => p.Update(now));
            }
            else
            {
                RealDataModel.Update(now, value, state, FeedState.OK);
                AnalogPointModels.ForEach(p => p.UpdateWhenSubstationOff(now));
            }

            SubStationRunModel.UpdateSubStationRun(ref _subStationRunModel, _subStationRunModels, RealDataModel, this);
        }
Esempio n. 5
0
        public static void UpdateSubStationRun(ref SubStationRunModel subStationRunModel,
                                               List <SubStationRunModel> subStationRunModels,
                                               RealDataModel realDataModel, SubStationModel subStationModel)
        {
            if (subStationRunModel == null)
            {
                subStationRunModel       = NewSubStationRunModel(realDataModel, subStationModel);
                subStationRunModel.State = 0;
                subStationRunModels.Add(subStationRunModel.DeepClone());
            }
            else
            {
                subStationRunModel.EndTime = realDataModel.RealDate;

                if (subStationRunModel.IsTimeToSave(realDataModel))
                {
                    var newM = subStationRunModel.DeepClone();
                    SubStationRunModel existM;
                    if ((existM = subStationRunModels.FirstOrDefault(o => o.Key == newM.Key)) != null)
                    {
                        existM.EndTime              = newM.EndTime;
                        existM.SubStationState      = newM.SubStationState;
                        existM.SubStationStateValue = newM.SubStationStateValue;
                        existM.SpanTime             = (int)newM.EndTime.Subtract(existM.StartTime).TotalSeconds;
                    }
                    else
                    {
                        subStationRunModels.Add(subStationRunModel.DeepClone());
                    }
                }

                if (subStationRunModel.IsRequireNew(realDataModel))
                {
                    // 需要新增加一条数据.
                    subStationRunModel       = NewSubStationRunModel(realDataModel, subStationModel);
                    subStationRunModel.State = 0;
                    subStationRunModels.Add(subStationRunModel.DeepClone());
                }
            }
        }
Esempio n. 6
0
 public void UpdateAnalogOff(DateTime now)
 {
     RealDataModel.Update(now, "正常", PointState.OK);
     SubStationRunModel.UpdateSubStationRun(ref _subStationRunModel, _subStationRunModels, RealDataModel, this);
     AnalogPointModels.ForEach(p => p.Update(now));
 }