public void TestPulseHandler()
        {
            DBConnector dBc    = new DBConnector();
            string      result = dBc.connect();

            Assert.AreEqual("Done", result);
            PulseRateHandler prhd = new PulseRateHandler();

            PulseRate pr = new PulseRate();

            Assert.IsInstanceOfType(pr, typeof(object));
            DateTime currentDate = DateTime.Now;
            int      PatientId   = 1001;

            pr.PulseRateValue = 70.0;
            pr.PulseRateDate  = currentDate;
            pr.PulseRateTime  = currentDate;
            int resp1 = prhd.addNewPulseRate(dBc.getConn(), pr, PatientId);

            Assert.AreEqual(1, resp1);


            int resp2 = prhd.getLastIdPulseRate(dBc.getConn(), PatientId);

            Assert.IsNotNull(resp2);


            int    lastId = 101;
            double resp3  = prhd.getLastPulseRate(dBc.getConn(), PatientId, lastId);

            Assert.IsNotNull(resp3);
        }
Beispiel #2
0
        //insert new pulse rate
        public int addNewPulseRate(MySqlConnection conn, PulseRate pulseRate, int patientId)
        {
            string       sql     = "INSERT into pulserate( patient_id, pulseRateValue, pulseRateTime, pulseRateDate)" + "VALUES('" + patientId + "', '" + pulseRate.PulseRateValue + "', '" + pulseRate.PulseRateTime.ToString("HH:mm:ss") + "', '" + pulseRate.PulseRateDate.ToString("yyyy-MM-dd") + "')";
            MySqlCommand sqlComm = new MySqlCommand(sql, conn);

            return(sqlComm.ExecuteNonQuery());
        }
        public void TelescopePulseGuide(GuideDirections direction, PulseRate pulseRate, CallType callType = CallType.Async, Guid? clientId = null, CallbackAction callback = null, Control callbackUIControl = null)
        {
            IsolatedAction((x, y) =>
            {
                try
                {
                    if (m_ConnectedTelescope != null && m_ConnectedTelescope.Connected)
                    {
                        AssertTelescopeEngagement(clientId);

                        m_ConnectedTelescope.PulseGuide(x, y, Settings.Default.TelPulseDuration);

                        TelescopeEquatorialPosition position = m_ConnectedTelescope.GetEquatorialPosition();

                        OnTelescopePosition(position);

                        return position;
                    }

                    return null;
                }
                catch (Exception ex)
                {
                    OnTelescopeErrored();
                    Trace.WriteLine(ex.GetFullStackTrace());

                    return ex;
                }
            },
            direction, pulseRate, callType, callback, callbackUIControl);
        }
        private async void readPulseRateData()
        {
            kayChart dataChart = new kayChart(pulseRateLineGraph, 60);

            dataChart.serieName = "Pulse Rate";
            string path = "../../../Patient-Monitoring-System/data files/pulseRateCSV.csv";
            string line;

            try
            {
                StreamReader sr = new StreamReader(path);
                line = sr.ReadLine();
                while (line != null)
                {
                    string[] columns = line.Split(',');
                    foreach (string column in columns)
                    {
                        if (run)
                        {
                            double value = double.Parse(column);
                            //add each value to database *DONT Delete*
                            DateTime    currentDate = DateTime.Now;
                            DateTime    currentTime = DateTime.Now;
                            DBConnector dBConn      = new DBConnector();
                            dBConn.connect();
                            PulseRate pulseRateData = new PulseRate();
                            pulseRateData.PulseRateValue = value;
                            pulseRateData.PulseRateDate  = currentDate;
                            pulseRateData.PulseRateTime  = currentTime;
                            PulseRateHandler pulseRateHandler = new PulseRateHandler();
                            ReadingHandler   readingHandler   = new ReadingHandler();
                            int result = pulseRateHandler.addNewPulseRate(dBConn.getConn(), pulseRateData, BedsideLoginScreen.bedside_patient_id);

                            if (result != 1)
                            {
                                MessageBox.Show("Insert Data failed");
                            }

                            await Task.Delay(1500);

                            await Task.Factory.StartNew(() =>
                            {
                                dataChart.TriggeredUpdate(value);
                            });

                            if (value == 0)
                            {
                                if (smsTrigger == 1)
                                {
                                    if (!backgroundWorkerSendSMS.IsBusy)
                                    {
                                        backgroundWorkerSendSMS.RunWorkerAsync();
                                    }
                                }
                                pulseRateLineGraph.Series["Pulse Rate"].Color = Color.Red;
                                pulseRateCurrentValue.ForeColor = Color.Red;
                                BedsideHandler bedsideHandler = new BedsideHandler();
                                int            alarmResult    = bedsideHandler.updateAlarmZeroStatus(dBConn.getConn(), BedsideLoginScreen.bedsideIDPass, 1);

                                alarmZeroStatus = true;
                                AlarmHandler alarmHandler = new AlarmHandler();
                                int          specificId   = alarmHandler.getSpecificId(dBConn.getConn(), value, "pulserate");

                                if (specificId > 0)
                                {
                                    bool triggerStatus = alarmHandler.triggerAlarm(dBConn.getConn(), value, BedsideLoginScreen.bedside_patient_id, 0, specificId, "Pulse Rate");
                                    if (triggerStatus)
                                    {
                                        listPulseRate.Add(pulseRateData);
                                    }
                                }
                            }
                            else
                            if (value >= double.Parse(maxPulseRateLabel.Text) || (value <= double.Parse(minPulseRateLabel.Text)))
                            {
                                if (smsTrigger == 1)
                                {
                                    if (!backgroundWorkerSendSMS.IsBusy)
                                    {
                                        backgroundWorkerSendSMS.RunWorkerAsync();
                                    }
                                }
                                pulseRateLineGraph.Series["Pulse Rate"].Color = Color.Yellow;
                                pulseRateCurrentValue.ForeColor = Color.Yellow;
                                BedsideHandler bedsideHandler = new BedsideHandler();
                                int            alarmResult    = bedsideHandler.updateAlarmStatus(dBConn.getConn(), BedsideLoginScreen.bedsideIDPass, 1);


                                alarmReadingStatus = true;
                                int id = readingHandler.getIdAlarmTrigger(dBConn.getConn(), value);

                                if (id > 0)
                                {
                                    AlarmHandler alarmHandler  = new AlarmHandler();
                                    bool         triggerStatus = alarmHandler.triggerAlarm(dBConn.getConn(), value, BedsideLoginScreen.bedside_patient_id, id, 0, "Pulse Rate");

                                    if (triggerStatus)
                                    {
                                        listPulseRate.Add(pulseRateData);
                                    }
                                }
                            }
                            else
                            {
                                pulseRateLineGraph.Series["Pulse Rate"].Color = Color.Green;
                                pulseRateCurrentValue.ForeColor = Color.Green;
                            }

                            pulseRateCurrentValue.Text = value.ToString() + "/min";
                        }
                        else
                        {
                            break;
                        }
                    }

                    line = sr.ReadLine();
                }
            }
            catch (FileNotFoundException e)
            {
                MessageBox.Show(e.ToString());
                Console.WriteLine(e.ToString());
            }
        }
Beispiel #5
0
 public void PulseGuide(GuideDirections direction, PulseRate rate, int durationMilliseconds)
 {
     EnsureRequestedGuideRate(rate);
     PulseGuide(direction, durationMilliseconds);
 }
Beispiel #6
0
        private void EnsureRequestedGuideRate(PulseRate rate)
        {
            Trace.WriteLine(string.Format("EnsureRequestedGuideRate({0})", rate));
            Trace.WriteLine(string.Format("m_PulseSlowestRate:{0}, m_PulseSlowRate:{1}, m_PulseFastRate:{2}", m_PulseSlowestRate, m_PulseSlowRate, m_PulseFastRate));
            Trace.WriteLine(string.Format("m_DefaultGuideRateDeclination:{0}, m_DefaultGuideRateRightAscension:{1}", m_DefaultGuideRateDeclination, m_DefaultGuideRateRightAscension));

            TelescopeGuideRate guideRate = GetGuideRate();

            double declFactor = guideRate.GuideRateDeclination / m_DefaultGuideRateDeclination;
            double requestedFactor = 0;
            if (rate == PulseRate.Slowest)
                requestedFactor = m_PulseSlowestRate;
            else if (rate == PulseRate.Slow)
                requestedFactor = m_PulseSlowRate;
            else if (rate == PulseRate.Fast)
                requestedFactor = m_PulseFastRate;

            Trace.WriteLine(string.Format("declFactor:{0}; requestedFactor:{1}", declFactor, requestedFactor));

            if (Math.Abs(declFactor - requestedFactor) > 0.5)
            {
                double newRateDEC = requestedFactor * m_DefaultGuideRateDeclination;
                SetGuideRateDeclination(newRateDEC);

                double newRateRA = requestedFactor * m_DefaultGuideRateRightAscension;
                SetGuideRateRightAscension(newRateRA);
            }
        }
Beispiel #7
0
        private void ReadPulseRateOrSlewRate(out PulseRate? rate, out double? distanceArcSec)
        {
            distanceArcSec = null;
            rate = null;

            if (rbSlow.Checked || rbSlowest.Checked || rbFast.Checked)
            {
                rate = PulseRate.Slowest;
                if (rbSlow.Checked)
                    rate = PulseRate.Slow;
                else if (rbFast.Checked)
                    rate = PulseRate.Fast;
                return;
            }
            else
            {
                if (rb05MinPerSec.Checked)
                    distanceArcSec = 0.5;
                else if (rb2MinPerSec.Checked)
                    distanceArcSec = 2;
                else if (rb5MinPerSec.Checked)
                    distanceArcSec = 5;
                else if (rb10MinPerSec.Checked)
                    distanceArcSec = 10;
                else if (rb30minPerSec.Checked)
                    distanceArcSec = 30;
            }
        }