Beispiel #1
0
        public RealTimeHydro(CurrentData w)
        {
            using (Maintain mt = new Maintain()) {
                stationInfo = StationService.GetStationByRawId(w.StationID);
                waterInfo   = w;
                string   currentState = w.CurrentState;
                DateTime time         = w.DataTime;
                DateTime now          = DateTime.Now;
                switch (currentState)
                {
                case "EWarning": state = RealTimeState.Warning; break;

                case "EError": state = RealTimeState.Error; break;

                case "ENormal":
                    if (time.AddHours(1.5) > now)
                    {
                        state = RealTimeState.Normal;
                    }
                    else if (time.AddHours(2.5) < now)
                    {
                        state = RealTimeState.TwoHalfHour;
                    }
                    else
                    {
                        state = RealTimeState.OneHalfHour;
                    }
                    break;
                }
            }
        }
Beispiel #2
0
        public RealTimeRainWater(CurrentData raw)
        {
            if (raw != null)
            {
                Station station = StationService.GetStationByRawId(raw.StationID);
                stationId     = station.id;
                stationName   = station.stationName;
                stationType   = station.stationType;
                subcenterName = station.subcenterName;
                longtitude    = station.longtitude;
                latitude      = station.latitude;
                datatime      = raw.DataTime;
                voltage       = raw.Voltage;

                if (stationType == StationTypes.rainStation || stationType == StationTypes.rain2Station)
                {
                    excessRain = false;
                    if (station.RMax.HasValue)
                    {
                        if (raw.PeriodRain.HasValue)
                        {
                            if (raw.PeriodRain > station.RMax)
                            {
                                excessRain = true;
                            }
                            else
                            {
                                //一切正常>?
                                rainErrorCode = 0;
                            }
                            periodRain = raw.PeriodRain;
                        }
                        else
                        {
                            //雨量数据为空
                            rainErrorCode = -1;
                            periodRain    = null;
                        }
                    }
                    else
                    {
                        //雨量基值为空
                        rainErrorCode = -2;
                        if (raw.PeriodRain.HasValue)
                        {
                            periodRain = raw.PeriodRain;
                        }
                        periodRain = null;
                    }
                }
                else if (stationType == StationTypes.waterStation ||
                         stationType == StationTypes.hdStation ||
                         stationType == StationTypes.hpStation ||
                         stationType == StationTypes.hzStation ||
                         stationType == StationTypes.gqStation
                         )
                {
                    aboveWater = false;
                    belowWater = false;

                    if (station.WMax.HasValue && station.WMin.HasValue)
                    {
                        if (raw.WaterStage.HasValue)
                        {
                            if (raw.WaterStage < station.WMin)
                            {
                                belowWater = true;
                            }
                            else if (raw.WaterStage > station.WMax)
                            {
                                aboveWater = true;
                            }
                            else
                            {
                                //一切正常>?
                                waterErrorCode = 0;
                            }
                            waterStage = raw.WaterStage;
                        }
                        else
                        {
                            //水位数据为空
                            waterErrorCode = -1;
                            waterStage     = null;
                        }
                    }
                    else
                    {
                        //水位上下限为空
                        waterErrorCode = -2;
                        if (raw.WaterStage.HasValue)
                        {
                            waterStage = raw.WaterStage;
                        }
                        waterStage = null;
                    }

                    if (raw.WaterFlow.HasValue)
                    {
                        waterFlow = (decimal)raw.WaterFlow;
                    }
                    else
                    {
                        waterFlow = null;
                    }
                }
                else if (stationType == StationTypes.hydroStation)
                {
                    aboveWater = false;
                    belowWater = false;
                    excessRain = false;
                    if (station.RMax.HasValue)
                    {
                        if (raw.PeriodRain.HasValue)
                        {
                            if (raw.PeriodRain > station.RMax)
                            {
                                excessRain = true;
                            }
                            else
                            {
                                //一切正常>?
                                rainErrorCode = 0;
                            }
                            periodRain = raw.PeriodRain;
                        }
                        else
                        {
                            //雨量数据为空
                            rainErrorCode = -1;
                            periodRain    = null;
                        }
                    }
                    else
                    {
                        //雨量基值为空
                        rainErrorCode = -2;
                        if (raw.PeriodRain.HasValue)
                        {
                            periodRain = raw.PeriodRain;
                        }
                        periodRain = null;
                    }

                    if (station.WMax.HasValue && station.WMin.HasValue)
                    {
                        if (raw.WaterStage.HasValue)
                        {
                            if (raw.WaterStage < station.WMin)
                            {
                                belowWater = true;
                            }
                            else if (raw.WaterStage > station.WMax)
                            {
                                aboveWater = true;
                            }
                            else
                            {
                                //一切正常>?
                                waterErrorCode = 0;
                            }
                            waterStage = raw.WaterStage;
                        }
                        else
                        {
                            //水位数据为空
                            waterErrorCode = -1;
                            if (raw.WaterStage.HasValue)
                            {
                                waterStage = raw.WaterStage;
                            }
                            waterStage = null;
                        }
                    }
                    else
                    {
                        //水位上下限为空
                        waterErrorCode = -2;
                        waterStage     = null;
                    }

                    if (raw.WaterFlow.HasValue)
                    {
                        waterFlow = (decimal)raw.WaterFlow;
                    }
                    else
                    {
                        waterFlow = null;
                    }
                }
            }
        }