private void btnUpdateAcc_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("Are you sure you want to update accessory?", "Verify", MessageBoxButtons.YesNo); if (result == DialogResult.No) { return; } AquaControllerCmd cmd = (AquaControllerCmd)cbContrAccUpdate.SelectedItem; var runDataList = AquaController.GetAllRunData(); bool cmdExists = runDataList.Exists(x => x.accType == cmd.AccTypeMap); if (!cmdExists) { return; } RunData data = runDataList.Find(x => x.accType == cmd.AccTypeMap); data.enabled = cbEnabled.Checked; data.runDurration = int.Parse(cbRunDuration.Text); data.SetNextRun(dtpNextRun.Value); var re = (NameValue <string, int>)cbRunEvery.SelectedItem; data.runEvery = re.Value; AquaController.SaveRunData(); SendControllerData(data, true); }
private void DataBindUIAccInfoData() { lblAccRunInfo.Text = ""; AquaControllerCmd cmd = (AquaControllerCmd)cbContrAccInfo.SelectedItem; var runDataList = AquaController.GetAllRunData(); bool cmdExists = runDataList.Exists(x => x.accType == cmd.AccTypeMap); if (!cmdExists) { lblAccRunInfo.Text = "diabled"; return; } RunData data = runDataList.Find(x => x.accType == cmd.AccTypeMap); if (!data.enabled) { lblAccRunInfo.Text = "diabled"; return; } lblAccRunInfo.Text = string.Format("Next Run: {0:MM/dd/yyyy h:mm tt}{1}Last Run: {2:MM/dd/yyyy h:mm tt}", data.GetNextRun(), Environment.NewLine, data.GetLastRun()); }
private void SetUIControllerData() { AquaControllerCmd cmd = (AquaControllerCmd)cbContrAccUpdate.SelectedItem; var runDataList = AquaController.GetAllRunData(); bool cmdExists = runDataList.Exists(x => x.accType == cmd.AccTypeMap); if (!cmdExists) { return; } RunData data = runDataList.Find(x => x.accType == cmd.AccTypeMap); cbEnabled.Checked = data.enabled; dtpNextRun.Value = data.GetNextRun(); if (cmd.TheAccType == AquaControllerCmd.AccType.WaterPump || cmd.TheAccType == AquaControllerCmd.AccType.DryDoser) //putting dry doser here for now, not sure how run ever works on arduino for dry doser. { //var runEvery = AquaControllerCmd.PumpRunEveryInHrs.Find(x => x.Value == data.GetRunEvery().TotalHours); var runEvery = AquaControllerCmd.PumpRunEveryInHrs.FindClosest(data.GetRunEvery().TotalSeconds); cbRunEvery.Text = runEvery.Name; var dur = AquaControllerCmd.PumpRunDur.FindClosest(data.runDurration); cbRunDuration.Text = dur; } else { var runEvery = AquaControllerCmd.MicrosMacrosRunEveryInHrs.FindClosest(data.GetRunEvery().TotalSeconds); if (runEvery != null) { cbRunEvery.Text = runEvery.Name; } var dur = AquaControllerCmd.MicrosMacrosRunDur.FindClosest(data.runDurration); cbRunDuration.Text = dur; } }
private void btnRunNow_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("Are you sure you want to run now?", "Verify", MessageBoxButtons.YesNo); if (result == DialogResult.No) { return; } AquaControllerCmd cmd = (AquaControllerCmd)cbContrAccUpdate.SelectedItem; var runDataList = AquaController.GetAllRunData(); bool cmdExists = runDataList.Exists(x => x.accType == cmd.AccTypeMap); if (!cmdExists) { return; } RunData data = runDataList.Find(x => x.accType == cmd.AccTypeMap); SendControllerData(data, true); }