public IActionResult Post([FromBody] ACSchedule schedule) { try { int createdScheduleId; try { createdScheduleId = _scheduleService.AddNewSchedule(schedule); } catch (ArgumentException ex) { return(BadRequest(ex.Message)); } catch (CurrentACDeviceNotSetException ex) { _logger.LogError(ex, "400: Bad request"); return(BadRequest("Current ACDevice not set!")); } catch (ACScheduleNotAddedException ex) { return(StatusCode(StatusCodes.Status409Conflict, ex.Message)); } return(Ok(createdScheduleId)); } catch (Exception ex) { _logger.LogError(ex, "500: Internal Server Error"); return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public void OnButtonSetSchedule() { // Toggles for the Schedule var checkboxBeginAM = GameObject.Find("CheckboxBeginAM"); var beginAMstatus = checkboxBeginAM.GetComponentInChildren<Toggle>().isOn; var checkboxBeginPM = GameObject.Find("CheckboxBeginPM"); var beginPMstatus = checkboxBeginPM.GetComponentInChildren<Toggle>().isOn; var checkboxEndAM = GameObject.Find("CheckboxEndAM"); var endAMstatus = checkboxEndAM.GetComponentInChildren<Toggle>().isOn; var checkboxEndPM = GameObject.Find("CheckboxEndPM"); var endPMstatus = checkboxEndPM.GetComponentInChildren<Toggle>().isOn; var textboxTemp = GameObject.Find("TextboxTemp"); var textboxTempText = textboxTemp.GetComponentInChildren<Text>(); var scheduleTemp = textboxTempText.text; // Access to Cool Toggle var coolToggle = GameObject.Find("CoolBtn"); var coolToggleStatus = coolToggle.GetComponentInChildren<Toggle>().isOn; // Access to Heat Toggle var heatToggle = GameObject.Find("HeatBtn"); var heatToggleStatus = heatToggle.GetComponentInChildren<Toggle>().isOn; var textboxBeginInput = GameObject.Find("TextboxBeginInput"); var textboxBeginText = textboxBeginInput.GetComponentInChildren<Text>(); var beginScheduleText = textboxBeginText.text; var textboxEndInput = GameObject.Find("TextboxEndInput"); var textboxEndText = textboxEndInput.GetComponentInChildren<Text>(); var endScheduleText = textboxEndText.text; TimeSpan eTime; TimeSpan bTime; if (TimeSpan.TryParse(beginScheduleText, out bTime) && TimeSpan.TryParse(endScheduleText, out eTime)) { if (beginPMstatus == true) { bTime = bTime.Add(new TimeSpan(12, 0, 0)); } if (endPMstatus == true) { eTime = eTime.Add(new TimeSpan(12, 0, 0)); } ACSchedule schedule = new ACSchedule(int.Parse(scheduleTemp), true, bTime, eTime); system.SetSchedule(schedule); } }
private static void NormalizeDatesInSchedule(IACSchedule schedule) { DateTime newStartTime, newEndTime; switch (schedule.ScheduleType) { case ScheduleType.EveryHour: if (schedule.StartTime.Minute >= DateTime.Now.Minute) { newStartTime = DateTime.Today.AddHours(DateTime.Now.Hour).AddMinutes(schedule.StartTime.Minute); newEndTime = DateTime.Today.AddHours(DateTime.Now.Hour).AddMinutes(schedule.EndTime.Minute); } else { newStartTime = DateTime.Today.AddHours(DateTime.Now.Hour + 1).AddMinutes(schedule.StartTime.Minute); newEndTime = DateTime.Today.AddHours(DateTime.Now.Hour + 1).AddMinutes(schedule.EndTime.Minute); } break; case ScheduleType.EveryDayOfWeek: case ScheduleType.EveryDay: if (schedule.StartTime.Hour >= DateTime.Now.Hour) { newStartTime = DateTime.Today.AddHours(schedule.StartTime.Hour); newEndTime = DateTime.Today.AddHours(schedule.EndTime.Hour); } else { newStartTime = DateTime.Today.AddDays(1).AddHours(schedule.StartTime.Hour); newEndTime = DateTime.Today.AddDays(1).AddHours(schedule.EndTime.Hour); } break; default: return; } var newSchedule = new ACSchedule(schedule, newStartTime, newEndTime); schedule = newSchedule; }
public void SetSchedule(ACSchedule schedule) { thermostatSchedule = schedule; }
public TemperatureSystem() { thermostats = GameObject.FindObjectsOfType<TemperatureGauge>().ToList() ; thermostatSchedule = new ACSchedule(GetInternalTemperature(), false, new TimeSpan(9, 0, 0), new TimeSpan(16, 0, 0)); }