示例#1
0
    public static void Main()
    {
        DataRecord.DataRecordGenerator drg = new DataRecord.DataRecordGenerator();
        DataRecord.DataRecordPool drp = new DataRecord.DataRecordPool(drg);

        TCPServer serv = new TCPServer();
        serv.StartServer();

        Patient.Patient patient = new Patient.Patient(serv);
        System.Console.WriteLine("Waiting for patient");
        patient.waitForPatient();
        drg.registerPatient(patient);
        System.Console.WriteLine("Patient acquired.");

        drg.registerDevice(new Device.PulseOx(0));
        drg.registerDevice(new Device.Zigfu(serv));

        drg.registerAlgorithm(new Algorithm.Met());
        drg.registerAlgorithm(new Algorithm.ExerciseAdherence());

        Client.Zigfu client = new Client.Zigfu(serv);
        Client.Indivo ind = new Client.Indivo(serv);

        client.attachToPool(drp);
        ind.attachToPool(drp);

        drg.startGenerating();

        while(Console.ReadKey(true).Key != ConsoleKey.Escape){ }

        drg.stopGenerating();
        drp.destroyPool();
        System.Environment.Exit(0); // Needed to kill TCPServer
    }
示例#2
0
        /// <summary>
        /// fills the comments in the results info array lists
        /// </summary>
        /// <param name="arrList"></param>
        /// <param name="pt"></param>
        /// <param name="testType">lac/lbc/rac/rbc are all valid</param>
        private void fillComments(ref ArrayList arrList, Patient.Patient pt, string testType)
        {
            int actThresh, currFreq;
            Ear earInQuestion = Ear.neither;
            TestResults tr;
            Pathology ptPath = pt.GetPath();

            // function pointer of which function to call
            threshDelegate threshFunc;

            switch (testType)
            {
                case "lac":
                    earInQuestion = Ear.left;
                    threshFunc = new threshDelegate(ptPath.AC_Thresh_Val);
                    break;
                case "lbc":
                    earInQuestion = Ear.left;
                    threshFunc = new threshDelegate(ptPath.BC_Thresh_Val);
                    break;
                case "rac":
                    earInQuestion = Ear.right;
                    threshFunc = new threshDelegate(ptPath.AC_Thresh_Val);
                    break;
                case "rbc":
                    earInQuestion = Ear.right;
                    threshFunc = new threshDelegate(ptPath.BC_Thresh_Val);
                    break;
                default:
                    threshFunc = null;
                    return;
            }

            for (int i = 0; i < arrList.Count; i++)
            {
                tr = (TestResults)arrList[i];
                currFreq = tr.tr_freq;

                actThresh = threshFunc(currFreq, earInQuestion);
                // tested threshhold is too quiet
                if (actThresh - 5 > tr.tr_dB)
                {
                    ((TestResults)arrList[i]).tr_desc = "Student recorded threshold at " +
                        tr.tr_dB + " dB, but patient's actual threshold is " + actThresh + " dB.  " +
                        "Maybe try a louder masking stimuli.";
                }
                else if (tr.tr_dB >= actThresh - 5 && tr.tr_dB <= actThresh + 5)
                {
                    ((TestResults)arrList[i]).tr_desc = "Student recorded threshold at " +
                        tr.tr_dB + " dB, patient's actual threshold is " + actThresh + " dB.  " +
                        "This is within margin of error.";
                }
                else
                {
                    ((TestResults)arrList[i]).tr_desc = "Student recorded threshold at " +
                        tr.tr_dB + " dB, but patient's actual threshold is " + actThresh + " dB.  " +
                        "Maybe the masking noise was too loud.";
                }
            }
        }
示例#3
0
        /// <summary>
        /// Parses the students tested thresholds from the audiogram and compares these
        /// to the patient's actual thresholds
        /// </summary>
        /// <param name="adgrm"> the audiogram used in the test</param>
        /// <param name="pt"> the patient tested</param>
        public void storePureToneResults(Audiogram adgrm, Patient.Patient pt)
        {
            // this will go through each point plotted on the audiogram and
            // compare it to the corresponding threshold

            // values returned from audiogram
            string[] adgrm_freq, adgrm_dB, adgrm_cursors;
            string adgrmPts;
            string[] adgrmPtsSplit;

            // Array lists containing the AC and BC information
            ArrayList l_ac_results = new ArrayList();
            ArrayList l_bc_results = new ArrayList();
            ArrayList r_ac_results = new ArrayList();
            ArrayList r_bc_results = new ArrayList();

            // first get the points string and parse it
            adgrmPts = adgrm.GetPlottedPoints(false);
            adgrmPtsSplit = adgrmPts.Split("\n".ToCharArray());

            adgrm_freq = adgrmPtsSplit[0].Split(",".ToCharArray());
            adgrm_dB = adgrmPtsSplit[1].Split(",".ToCharArray());
            adgrm_cursors = adgrmPtsSplit[2].Split(",".ToCharArray());

            // check the empty condition
            if (adgrm_freq[0] == string.Empty) return;

            // sort the pts into AC/BC bins
            int iter = 0;
            foreach (string str in adgrm_cursors)
            {
                // parse out the pt info
                int pt_freq = Convert.ToInt32(adgrm_freq[iter]);
                int pt_dB = Convert.ToInt32(adgrm_dB[iter]);
                int temp_dB, index;

                TestResults tr_temp = new TestResults(pt_freq, pt_dB, string.Empty);

                // grab the corresponding freq and thresh
                switch (str)
                {
                    case "AC_Left":
                    case UNICODE_SQUARE:
                        // left ear AC thresh
                        index = l_ac_results.BinarySearch(tr_temp);
                        if (index < 0)
                        {
                            l_ac_results.Add(tr_temp);
                        }
                        else
                        {
                            // give it the max dB
                            temp_dB = ((TestResults)l_ac_results[index]).tr_dB;
                            ((TestResults)l_ac_results[index]).tr_dB =
                                (temp_dB > tr_temp.tr_dB) ? temp_dB : tr_temp.tr_dB;
                        }
                        break;
                    case "AC_Right":
                    case UNICODE_TRIANGLE:
                        // right ear AC thresh
                        index = r_ac_results.BinarySearch(tr_temp);
                        if (index < 0)
                        {
                            r_ac_results.Add(tr_temp);
                        }
                        else
                        {
                            // give it the max dB
                            temp_dB = ((TestResults)r_ac_results[index]).tr_dB;
                            ((TestResults)r_ac_results[index]).tr_dB =
                                (temp_dB > tr_temp.tr_dB) ? temp_dB : tr_temp.tr_dB;
                        }
                        break;
                    case "BC_Left":
                    case "]":
                        // left ear BC thresh
                        index = l_bc_results.BinarySearch(tr_temp);
                        if (index < 0)
                        {
                            l_bc_results.Add(tr_temp);
                        }
                        else
                        {
                            // give it the max dB
                            temp_dB = ((TestResults)l_bc_results[index]).tr_dB;
                            ((TestResults)l_bc_results[index]).tr_dB =
                                (temp_dB > tr_temp.tr_dB) ? temp_dB : tr_temp.tr_dB;
                        }
                        break;
                    case "BC_Right":
                    case "[":
                        // right ear BC thresh
                        index = r_bc_results.BinarySearch(tr_temp);
                        if (index < 0)
                        {
                            r_bc_results.Add(tr_temp);
                        }
                        else
                        {
                            // give it the max dB
                            temp_dB = ((TestResults)r_bc_results[index]).tr_dB;
                            ((TestResults)r_bc_results[index]).tr_dB =
                                (temp_dB > tr_temp.tr_dB) ? temp_dB : tr_temp.tr_dB;
                        }
                        break;
                    default:
                        Console.WriteLine(str + " Found");
                        break;
                }

                iter++;
            }

            // sort and fill comments
            if (l_ac_results.Count > 0)
            {
                l_ac_results.Sort();
                fillComments(ref l_ac_results, pt, "lac");
            }
            if (l_bc_results.Count > 0)
            {
                l_bc_results.Sort();
                fillComments(ref l_bc_results, pt, "lbc");
            }
            if (r_ac_results.Count > 0)
            {
                r_ac_results.Sort();
                fillComments(ref r_ac_results, pt, "rac");
            }
            if (r_bc_results.Count > 0)
            {
                r_bc_results.Sort();
                fillComments(ref r_bc_results, pt, "rbc");
            }

            // add info to the results string
            pureToneResults = "Pure tone results for " + pt.GetPath().PathType + " pathology.\n";
            // first the Left AC
            pureToneResults += "Left Ear Air Conduction Results:\n";
            for (int i = 0; i < l_ac_results.Count; i++)
            {
                TestResults temp_tr = (TestResults)l_ac_results[i];
                pureToneResults += "At " + temp_tr.tr_freq + ", " + temp_tr.tr_desc + "\n";
            }
            // then the Right AC
            pureToneResults += "Right Ear Air Conduction Results:\n";
            for (int i = 0; i < r_ac_results.Count; i++)
            {
                TestResults temp_tr = (TestResults)r_ac_results[i];
                pureToneResults += "At " + temp_tr.tr_freq + ", " + temp_tr.tr_desc + "\n";
            }
            // then the Left BC
            pureToneResults += "Left Ear Bone Conduction Results:\n";
            for (int i = 0; i < l_bc_results.Count; i++)
            {
                TestResults temp_tr = (TestResults)l_bc_results[i];
                pureToneResults += "At " + temp_tr.tr_freq + ", " + temp_tr.tr_desc + "\n";
            }
            // lastly the Right BC
            pureToneResults += "Right Ear Bone Conduction Results:\n";
            for (int i = 0; i < r_bc_results.Count; i++)
            {
                TestResults temp_tr = (TestResults)r_bc_results[i];
                pureToneResults += "At " + temp_tr.tr_freq + ", " + temp_tr.tr_desc + "\n";
            }
        }