Exemplo n.º 1
0
 public void WriteToDB(RealtimeWindTurbineRecord record)
 {
     using (var db = new DatabaseContext(_sqlConnectionString))
     {
         record.Timestamp = DateTime.Now;
         db.Add(record);
         db.SaveChanges();
     }
 }
Exemplo n.º 2
0
        private RealtimeWindTurbineRecord GenerateRegularRealtimeRecord(bool stopWake)
        {
            var    currentRecords = ringBuffer.ToList();
            double windDirection  = currentRecords.Select(x => x.OverallWindDirection).Average() * gen.GetRandomNumber(0.9, 1.1);
            var    windSpeed      = currentRecords.Select(x => x.WindSpeedAverage).Average() * gen.GetRandomNumber(0.9, 1.1);
            double turbineSpeed   = windSpeed * gen.GetRandomNumber(0.25, 1.75);

            if (stopWake)
            {
                turbineSpeed  = windSpeed * gen.GetRandomNumber(0.97, 1.03);
                windDirection = gen.GetRandomNumber(40.0, 45.0);
            }

            var generatorSpeed = gen.GetGeneratorSpeed(windSpeed);
            var activePower    = gen.GetGeneratorActivePower(windSpeed);
            var toReturn       = new RealtimeWindTurbineRecord
            {
                RecordId             = Guid.NewGuid(),
                TurbineId            = 15443,
                TurbineGuid          = TurbineGuid,
                GearboxOilLevel      = currentRecords.Select(x => x.GearboxOilLevel).Average() * gen.GetRandomNumber(0.95, 1.05),
                GearboxOilTemp       = currentRecords.Select(x => x.GearboxOilTemp).Average() * gen.GetRandomNumber(0.95, 1.05),
                GeneratorActivePower = gen.GetGeneratorActivePower(windSpeed),
                GeneratorSpeed       = generatorSpeed,
                GeneratorTemp        = gen.GetGeneratorStatorTemp(generatorSpeed),
                GeneratorTorque      = gen.GetGeneratorTorque(generatorSpeed, activePower),
                GridFrequency        = gen.GetGridFrequency(activePower),
                GridVoltage          = gen.GetVoltage(activePower),
                HydraulicOilPressure = gen.GetHydraulicOilPressure(),
                NacelleAngle         = gen.GetNacelleAngle(windDirection),
                PitchAngle           = gen.GetPitchAngle(windSpeed),
                Vibration            = gen.GetVibration(windSpeed),
                WindSpeedAverage     = windSpeed,
                Precipitation        = gen.GetRandomBool(20),
                WindTempAverage      = gen.GetRandomNumber(-10.0, 30),
                OverallWindDirection = windDirection,
                TurbineWindDirection = windDirection * gen.GetRandomNumber(0.97, 1.03),
                TurbineSpeedAverage  = turbineSpeed,
                WindSpeedStdDev      = gen.CalculateStandardDeviation(ringBuffer.ToList().Select(x => x.WindSpeedAverage).TakeLast(10)),
                TurbineSpeedStdDev   = gen.CalculateStandardDeviation(ringBuffer.ToList().Select(x => x.TurbineSpeedAverage).TakeLast(10)),
                Timestamp            = DateTime.Now
            };

            ringBuffer.PushFront(toReturn);
            return(toReturn);
        }
Exemplo n.º 3
0
        private RealtimeWindTurbineRecord GenerateFirstRealtimeRecord()
        {
            var windSpeed      = gen.GetRandomNumber(15.0, 25.0);
            var generatorSpeed = gen.GetGeneratorSpeed(windSpeed);
            var activePower    = gen.GetGeneratorActivePower(windSpeed);
            var windDirection  = gen.GetRandomNumber(41.0, 44.0);
            var toReturn       = new RealtimeWindTurbineRecord
            {
                RecordId             = Guid.NewGuid(),
                TurbineId            = 15443,
                TurbineGuid          = TurbineGuid,
                GearboxOilLevel      = gen.GetGearBoxOilLevel(),
                GearboxOilTemp       = gen.GetGearBoxTemp(),
                GeneratorActivePower = gen.GetGeneratorActivePower(windSpeed),
                GeneratorSpeed       = generatorSpeed,
                GeneratorTemp        = gen.GetGeneratorStatorTemp(generatorSpeed),
                GeneratorTorque      = gen.GetGeneratorTorque(generatorSpeed, activePower),
                GridFrequency        = gen.GetGridFrequency(activePower),
                GridVoltage          = gen.GetVoltage(activePower),
                HydraulicOilPressure = gen.GetHydraulicOilPressure(),
                NacelleAngle         = gen.GetNacelleAngle(windDirection),
                PitchAngle           = gen.GetPitchAngle(windSpeed),
                Vibration            = gen.GetVibration(windSpeed),
                WindSpeedAverage     = windSpeed,
                Precipitation        = gen.GetRandomBool(20),
                WindTempAverage      = gen.GetRandomNumber(-10.0, 30),
                OverallWindDirection = windDirection,
                TurbineWindDirection = windDirection * gen.GetRandomNumber(0.97, 1.03),
                TurbineSpeedAverage  = windSpeed * gen.GetRandomNumber(0.97f, 1.03f),
                WindSpeedStdDev      = 4.885422,
                TurbineSpeedStdDev   = 4.978619,
                Timestamp            = DateTime.Now
            };

            ringBuffer.PushFront(toReturn);
            return(toReturn);
        }