private void startPumping(PacientCodeEnum patCodeEnum, int periodSecounds) { if (dictPacientPump.ContainsKey(patCodeEnum)) { MessageBox.Show("The selecteed pacient has the pump already started"); return; } PumpSensorValues sensorValuesPump = new PumpSensorValues(patCodeEnum.ToString(), periodSecounds); sensorValuesPump.StartPumping(); sensorValuesPump.newSensorValueEvent += new OnNewSensorValue(OnNewSensorValueHandler); dictPacientPump.Add(patCodeEnum, sensorValuesPump); }
private void bStopPumping_Click(object sender, EventArgs e) { PacientCodeEnum currPacientStop = (PacientCodeEnum)cbPacientCodeStart.SelectedItem; if (dictPacientPump.ContainsKey(currPacientStop)) { PumpSensorValues pumpToBeStoped = dictPacientPump[currPacientStop]; pumpToBeStoped.StopPumping(); dictPacientPump.Remove(currPacientStop); } else { MessageBox.Show("The selected pacient has no pump values started"); } }
private void bStartPumping_Click(object sender, EventArgs e) { int timePeriodSecounds = 1; if (cbPacientCodeStart.SelectedItem != null && tbTimePeriod.Text != string.Empty) { try { timePeriodSecounds = Convert.ToInt32(tbTimePeriod.Text); } catch (Exception ex) { MessageBox.Show("Error: Time period input cannot be converted to int ->" + ex.Message); } PacientCodeEnum currPacient = (PacientCodeEnum)cbPacientCodeStart.SelectedItem; startPumping(currPacient, timePeriodSecounds); } }