Ejemplo n.º 1
0
        public void TestTemperatureHandler()
        {
            //connect database
            DBConnector dbC  = new DBConnector();
            string      resp = dbC.connect();

            Assert.AreEqual("Done", resp);
            TemperatureHandler thd  = new TemperatureHandler();
            Temperature        temp = new Temperature();

            Assert.IsInstanceOfType(temp, typeof(object));
            DateTime currentDate = DateTime.Now;
            int      patientId   = 1001;

            temp.TemperatureValue = 37;
            temp.TemperatureDate  = currentDate;
            temp.TemperatureTime  = currentDate;
            int resp1 = thd.addNewTemperature(dbC.getConn(), temp, patientId);

            Assert.AreEqual(1, resp1);


            int resp2 = thd.getLastIdTemperature(dbC.getConn(), patientId);

            Assert.IsNotNull(resp2);

            int    tempId = 321;
            double resp3  = thd.getLastTemperature(dbC.getConn(), patientId, tempId);

            Assert.IsNotNull(resp3);
        }
Ejemplo n.º 2
0
        public MainViewModel() : base()
        {
            TempHandler = new TemperatureHandler();
            XmlHandler  = new XmlHandler();
            CoefHandler = new TrackDegrCoefHandler();

            GetAndSortTyres();
            GetDegradationData();
        }
Ejemplo n.º 3
0
 public void AddHandler(TemperatureHandler handler)
 {
     if (handlers == null)
     {
         handlers = handler;
     }
     else
     {
         handlers += handler;
     }
 }
Ejemplo n.º 4
0
    private void Start()
    {
        INSTANCE = this;

        _temperatureRadius = 10;
        _maxDebuff         = 5;
        _minDebuff         = -5;
        _debuffIncrements  = 2;

        //Function is for testing purposes only
        foreach (var player in FindObjectsOfType <Player>().ToList())
        {
            AddPlayer(player);
        }
    }
Ejemplo n.º 5
0
        public async Task <bool> LoadData()
        {
            var temperatureHandler = new TemperatureHandler();

            var result = await temperatureHandler.GetDashboard();

            if (result == default(DashboardResponseItem))
            {
                return(false);
            }

            RecordedTime    = $"As of {result.Latest_RecordedTime.AddHours(-4)}";
            Temperature     = $"{Math.Round(result.Latest_Temperature, 2)}'F";
            HighTemperature = result.CurrentDay_HighTemperature;
            LowTemperature  = result.CurrentDay_LowTemperature;
            Humidity        = result.Latest_HumidityPercentage;

            return(true);
        }
Ejemplo n.º 6
0
        private async void ReadTemperature()
        {
            var tempHandler = new TemperatureHandler();

            var temperatureSensor = new DHT11Sensor();

            var _deviceClient = DeviceClient.CreateFromConnectionString("iottemp.azure-devices.net", TransportType.Http1);

            while (true)
            {
                var receivedMessage = await _deviceClient.ReceiveAsync();

                if (receivedMessage != null)
                {
                    await _deviceClient.CompleteAsync(receivedMessage);
                }

                tempHandler.RecordTemperature(temperatureSensor.GetTemperature(false));

                await System.Threading.Tasks.Task.Delay(5000);
            }
        }
        private async void readTemperatureData()
        {
            kayChart dataChart = new kayChart(temperatureLineGraph, 60);

            dataChart.serieName = "Temperature";
            string path = "../../../Patient-Monitoring-System/data files/temperatureCSV.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();
                            Temperature newTemperature = new Temperature();
                            newTemperature.TemperatureValue = value;
                            newTemperature.TemperatureDate  = currentDate;
                            newTemperature.TemperatureTime  = currentTime;
                            TemperatureHandler temperatureHandler = new TemperatureHandler();
                            ReadingHandler     readingHandler     = new ReadingHandler();
                            int result = temperatureHandler.addNewTemperature(dBConn.getConn(), newTemperature, 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();
                                    }
                                }
                                temperatureLineGraph.Series["Temperature"].Color = Color.Red;
                                temperatureCurrentValue.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, "temperature");

                                if (specificId > 0)
                                {
                                    bool triggerStatus = alarmHandler.triggerAlarm(dBConn.getConn(), value, BedsideLoginScreen.bedside_patient_id, 0, specificId, "Temperature");
                                    if (triggerStatus)
                                    {
                                        listTemperature.Add(newTemperature);
                                    }
                                }
                            }
                            else
                            if (value >= double.Parse(maxTemperatureLabel.Text) || value <= double.Parse(minTemperatureLabel.Text))
                            {
                                if (smsTrigger == 1)
                                {
                                    if (!backgroundWorkerSendSMS.IsBusy)
                                    {
                                        backgroundWorkerSendSMS.RunWorkerAsync();
                                    }
                                }
                                temperatureLineGraph.Series["Temperature"].Color = Color.Yellow;
                                temperatureCurrentValue.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, "Temperature");
                                    if (triggerStatus)
                                    {
                                        listTemperature.Add(newTemperature);
                                    }
                                }
                            }
                            else
                            {
                                temperatureLineGraph.Series["Temperature"].Color = Color.Green;
                                temperatureCurrentValue.ForeColor = Color.Green;
                            }
                            temperatureCurrentValue.Text = value.ToString() + "°C";
                        }
                        else
                        {
                            break;
                        }
                    }

                    line = sr.ReadLine();
                }
            }
            catch (FileNotFoundException e)
            {
                MessageBox.Show(e.ToString());
                Console.WriteLine(e.ToString());
            }
        }
Ejemplo n.º 8
0
        public void RemoveHandler(TemperatureHandler handler)
        {
            var newHandlers = Delegate.Remove(handlers, handler);

            handlers = newHandlers as TemperatureHandler ?? handlers;
        }