Ejemplo n.º 1
0
        public async void SimpleConnect()
        {
            Context             context             = Application.Context;
            IAttributeSet       attributeSet        = null;
            PSCommSimpleAndroid psCommSimpleAndroid = new PSCommSimpleAndroid(context, attributeSet);

            Device[] devices = await psCommSimpleAndroid.GetConnectedDevices();

            for (int i = 0; i < 10; i++)
            {
                try
                {
                    psCommSimpleAndroid.Connect(devices[i]);
                }
                catch (Exception ex)
                {
                    Crashes.TrackError(ex);
                }
            }

            psCommSimpleAndroid.MeasurementStarted            += PsCommSimpleAndroid_MeasurementStarted;
            psCommSimpleAndroid.MeasurementEnded              += PsCommSimpleAndroid_MeasurementEnded;
            psCommSimpleAndroid.SimpleCurveStartReceivingData += PsCommSimpleAndroid_SimpleCurveStartReceivingData;
            RunScan runScan = await RunScan();

            SimpleMeasurement activeSimpleMeasurement = psCommSimpleAndroid.Measure(runScan);

            /*
             * Method method;
             * using (System.IO.StreamReader file = new System.IO.StreamReader(Assets.Open(asset)))
             *  method = SimpleLoadSaveFunctions.LoadMethod(file);
             */

            SimpleLoadSaveFunctions.SaveMeasurement(activeSimpleMeasurement, null);

            List <SimpleCurve> simpleCurves = activeSimpleMeasurement.SimpleCurveCollection;

            //Load base null curve

            SimpleCurve subtractedCurve = simpleCurves[0].Subtract(simpleCurves[1]);    //Note, replace simpleCurves[1] w/ the standard blank curve

            subtractedCurve.DetectPeaks();
            PeakList peakList   = subtractedCurve.Peaks;
            Peak     mainPeak   = peakList[0];
            double   peakHeight = mainPeak.PeakValue;

            List <ScanDatabase> allDb = await App.Database.GetScanDatabasesAsync();

            ScanDatabase _database = await App.Database.GetScanAsync(allDb.Count);

            if (peakHeight <= -0.001)
            {
                _database.IsInfected = true;
            }
            else
            {
                _database.IsInfected = false;
            }

            //Add equations to calculate the amount of bacteria and concentration based on the peak from either detecting the peak
        }