public DeleteConfirmationViewModel DeleteConfirmationForm(int id) { NoiseProtection noiseProtection = _noiseProtectionDAO.Get(id); DeleteConfirmationViewModel viewModel = new DeleteConfirmationViewModel { Id = "trans" + noiseProtection.Id, Title = noiseProtection.Title }; return(viewModel); }
public GenericTranslationViewModel EditNoiseProtectionForm(int id) { NoiseProtection noiseProtection = _noiseProtectionDAO.Get(id); GenericTranslationViewModel viewModel = new GenericTranslationViewModel(noiseProtection.CultureName) { Id = noiseProtection.Id, DefinitionId = noiseProtection.NoiseProtectionDefinition.Id, Title = noiseProtection.Title }; return(viewModel); }
public GenericTranslationViewModel Edit(GenericTranslationEditModel editModel) { NoiseProtection noiseProtection = _noiseProtectionDAO.Get(editModel.Id); noiseProtection.Title = editModel.Title; noiseProtection.CultureName = editModel.SelectedCultureName; _noiseProtectionDAO.Store(noiseProtection); GenericTranslationViewModel viewModel = new GenericTranslationViewModel(noiseProtection.CultureName) { DefinitionId = noiseProtection.NoiseProtectionDefinition.Id, Id = noiseProtection.Id, Title = noiseProtection.Title }; return(viewModel); }
public void CalculateTimeSpan_NoiseLevelIs76WithPercent10_145Minutes() { // Arrange var task = new Task { AllowedExposureMinutes = 360, NoiseLevelGuideline = 109 }; const int actualNoiseLevel = 76; const int percentage = 10; const int buttonPressed = 100; const int backgroundNoise = 70; var noiseProtection = new NoiseProtection(); // Act var allowedTimeSpan = task.CalculateTimeSpan("", actualNoiseLevel, buttonPressed, backgroundNoise, "", noiseProtection, percentage); // Assert Assert.AreEqual(145, allowedTimeSpan.TotalMinutes); }
public void CalculatePercentage_NoiseLevelIs109WithActualTime90AndNoiseLevelMeassuredIs115_39Percent() { // Arrange var task = new Task { AllowedExposureMinutes = 360, NoiseLevelGuideline = 109 }; var actualExposure = new TimeSpan(0, 0, 90, 0); const int actualNoiseLevel = 115; const int buttonPressed = 25; const int backgroundNoise = 70; var noiseProtection = new NoiseProtection() { NoiseDampening = 24 }; // Act var calculatedPercentage = task.CalculatePercentage("", actualNoiseLevel, buttonPressed, backgroundNoise, "", noiseProtection, actualExposure); // Assert Assert.AreEqual(39, (int)Math.Round(calculatedPercentage)); }
public void CalculateTimeSpan_NoiseLevelIs109WithNoiseLevelMeasured112AndPercent25AndButtonPressed25_114Minutes() { // Arrange var task = new Task { AllowedExposureMinutes = 360, NoiseLevelGuideline = 109 }; const int actualNoiseLevel = 112; const int percentage = 25; const int buttonPressed = 25; const int backgroundNoise = 70; var noiseProtection = new NoiseProtection() { NoiseDampening = 24 }; // Act var allowedTimeSpan = task.CalculateTimeSpan("", actualNoiseLevel, buttonPressed, backgroundNoise, "", noiseProtection, percentage); // Assert Assert.AreEqual(114, allowedTimeSpan.TotalMinutes); }
public GenericTranslationViewModel Create(GenericTranslationEditModel editModel) { NoiseProtectionDefinition definition = _noiseProtectionDefinitionDAO.Get(editModel.DefinitionId); NoiseProtection noiseProtection = new NoiseProtection { NoiseProtectionDefinition = definition, Title = editModel.Title, CultureName = editModel.SelectedCultureName }; definition.NoiseProtections.Add(noiseProtection); _noiseProtectionDefinitionDAO.Store(definition); GenericTranslationViewModel viewModel = new GenericTranslationViewModel(noiseProtection.CultureName) { DefinitionId = noiseProtection.NoiseProtectionDefinition.Id, Id = noiseProtection.Id, Title = noiseProtection.Title }; return(viewModel); }
public void Delete(int id) { NoiseProtection noiseProtection = _noiseProtectionDAO.Load(id); _noiseProtectionDAO.Delete(noiseProtection); }
public virtual decimal CalculatePercentage(decimal actualNoiseLevel, int buttonPressed, int backgroundNoise, NoiseProtection noiseProtection, TimeSpan actualExposure) { var noiseProtectionDampening = noiseProtection.NoiseDampening; const double timeInFullShift = 720; if (backgroundNoise == 0) { backgroundNoise = 80; } // Støynivå => 10* LOG(10^(støydef/10) + 10^(bakgrunnsstøy/10) var noiseLevel = 10 * Math.Log((Math.Pow(10, ((double)actualNoiseLevel / 10)) + Math.Pow(10, ((double)backgroundNoise / 10))), 10.0); // Norm verdi => 10 * LOG (10^(støynivå/10)) * knappen inne / 100) var normalizedValue = 10 * Math.Log((Math.Pow(10, (noiseLevel / 10)) * ((double)buttonPressed / 100)) + Math.Pow(10, ((double)backgroundNoise / 10)) * (((100 - (double)buttonPressed) / 100)), 10.0); // Norm verdi med hørselsvern var normValueWithNoiseProtection = normalizedValue - noiseProtectionDampening; var percentMinutes = actualExposure.TotalMinutes / timeInFullShift; // Eksponering i db => 10 * LOG (Time in minutes / Time in full shift * 10 ^ (Noise - noiseprotection / 10) var exposure = 10 * Math.Log((percentMinutes * Math.Pow(10, (normValueWithNoiseProtection / 10))), 10.0); // % beregning => 10^(exposure/10))/(10^(80/10))*100) var calcPerc = (Math.Pow(10, (exposure / 10))) / (Math.Pow(10, (80 / 10))) * 100; return((decimal)calcPerc); }