Example #1
0
 private async Task fetchMeasurements(PathInformation partPath, string serialNumber)
 {
     SimpleMeasurement[] _Measurements = new SimpleMeasurement[0];
     try
     {
         var sw = System.Diagnostics.Stopwatch.StartNew();
         _Measurements = (await _RestDataServiceClient.GetMeasurements(partPath, new MeasurementFilterAttributes
         {
             SearchCondition = new GenericSearchAttributeCondition
             {
                 Attribute = (ushort)14,
                 Operation = Operation.Equal,
                 Value = serialNumber
             }
         })).ToArray();//
         sw.Stop();
         foreach (var mes in _Measurements)
         {
             if (mes.GetAttribute((ushort)20041).Value == "1")
             {
                 demoType = mes.GetAttribute((ushort)20043).Value;
                 customer = mes.GetAttribute((ushort)1062).Value;
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Example #2
0
 /// <summary>
 /// This method fetches the most recent 100 measurements for the selected part. Please have a look at the other properties inside
 /// the filter class to understand all possibilities of filtering.
 /// </summary>
 private async Task updateMeasurements2CheckDemoReport(PathInformation partPath, string serialNumber)
 {
     SimpleMeasurement[] _Measurements = new SimpleMeasurement[0];
     try
     {
         var sw = System.Diagnostics.Stopwatch.StartNew();
         _Measurements = (await _RestDataServiceClient.GetMeasurements(partPath, new MeasurementFilterAttributes
         {
             SearchCondition = new GenericSearchAttributeCondition
             {
                 Attribute = (ushort)14,
                 Operation = Operation.Equal,
                 Value = serialNumber
             }
         })).ToArray();//
         sw.Stop();
         foreach (var mes in _Measurements)
         {
             mes.SetAttribute((ushort)20057, "已完成");
         }
         if (_Measurements.Count() > 0)
         {
             await _RestDataServiceClient.UpdateMeasurements(_Measurements);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Example #3
0
 private void PublishMeasurements(SimpleMeasurement measurements, int count)
 {
     CommonPINVOKE.PublisherInstance_PublishMeasurements(swigCPtr, SimpleMeasurement.getCPtr(measurements), count);
     if (CommonPINVOKE.SWIGPendingException.Pending)
     {
         throw CommonPINVOKE.SWIGPendingException.Retrieve();
     }
 }
 internal virtual void ReceivedNewMeasurements(SimpleMeasurement measurements, int length)
 {
     if (SwigDerivedClassHasMethod("ReceivedNewMeasurements", swigMethodTypes8))
     {
         CommonPINVOKE.SubscriberInstanceBase_ReceivedNewMeasurementsSwigExplicitSubscriberInstanceBase(swigCPtr, SimpleMeasurement.getCPtr(measurements), length);
     }
     else
     {
         CommonPINVOKE.SubscriberInstanceBase_ReceivedNewMeasurements(swigCPtr, SimpleMeasurement.getCPtr(measurements), length);
     }
     if (CommonPINVOKE.SWIGPendingException.Pending)
     {
         throw CommonPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Example #5
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(SimpleMeasurement obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
Example #6
0
        private static void Main()
        {
            double totalProcessingTime = 0.0D;

            for (int i = 0; i < Repeats; i++)
            {
                DateTime startTime = DateTime.UtcNow;

                for (int j = 0; j < TestTotal; j++)
                {
                    Measurement measurement = new Measurement();

                    measurement.SignalID  = Guid.NewGuid();
                    measurement.ID        = (ulong)j;
                    measurement.Timestamp = startTime.Ticks;
                    measurement.Value     = (1 + 1) * (j + 1);

                    DateTime retrieved = measurement.GetDateTime();
                    Debug.Assert((int)(retrieved - startTime).TotalMilliseconds == 0);
                }

                double processingTime = (DateTime.UtcNow - startTime).TotalSeconds;
                Console.WriteLine($"Native run {i + 1} processing time = {processingTime:N4} seconds.");

                totalProcessingTime += processingTime;
            }

            double nativeAverage = totalProcessingTime / Repeats;

            Console.WriteLine();
            Console.WriteLine($"Native average processing time = {nativeAverage:N4} seconds.");
            Console.WriteLine();

            totalProcessingTime = 0.0D;

            for (int i = 0; i < Repeats; i++)
            {
                DateTime startTime = DateTime.UtcNow;

                for (int j = 0; j < TestTotal; j++)
                {
                    SimpleMeasurement measurement = new SimpleMeasurement();

                    measurement.SignalID  = Guid.NewGuid();
                    measurement.Timestamp = startTime.Ticks;
                    measurement.Value     = (1 + 1) * (j + 1);

                    DateTime retrieved = new DateTime(measurement.Timestamp);
                    Debug.Assert((int)(retrieved - startTime).TotalMilliseconds == 0);
                }

                double processingTime = (DateTime.UtcNow - startTime).TotalSeconds;
                Console.WriteLine($"Wrapped run {i + 1} processing time = {processingTime:N4} seconds.");

                totalProcessingTime += processingTime;
            }

            double wrappedAverage = totalProcessingTime / Repeats;

            Console.WriteLine();
            Console.WriteLine($"Wrapped average processing time = {wrappedAverage:N4} seconds.");
            Console.WriteLine();

            totalProcessingTime = 0.0D;

            for (int i = 0; i < Repeats; i++)
            {
                DateTime startTime = DateTime.UtcNow;

                for (int j = 0; j < TestTotal; j++)
                {
                    sttp.Measurement measurement = new sttp.Measurement();

                    measurement.SetSignalID(Guid.NewGuid());
                    measurement.Timestamp = startTime.Ticks;
                    measurement.Value     = (1 + 1) * (j + 1);

                    DateTime retrieved = measurement.GetDateTime();
                    Debug.Assert((int)(retrieved - startTime).TotalMilliseconds == 0);
                }

                double processingTime = (DateTime.UtcNow - startTime).TotalSeconds;
                Console.WriteLine($"Custom marshaled run {i + 1} processing time = {processingTime:N4} seconds.");

                totalProcessingTime += processingTime;
            }

            double customMarshaledAverage = totalProcessingTime / Repeats;

            Console.WriteLine();
            Console.WriteLine($"Custom marshaled average processing time = {customMarshaledAverage:N4} seconds.");
            Console.WriteLine();

            Console.WriteLine($"Difference between SWIG wrapped and native: {wrappedAverage - nativeAverage:N6} seconds");
            Console.WriteLine($"Difference between custom marshaled and native: {customMarshaledAverage - nativeAverage:N6} seconds");

            Console.ReadKey();
        }
Example #7
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
        }
Example #8
0
 /// <summary>
 /// This method fetches the most recent 100 measurements for the selected part. Please have a look at the other properties inside
 /// the filter class to understand all possibilities of filtering.
 /// </summary>
 private async Task FetchMeasurements4FileServerIP(PathInformation partPath)
 {
     SimpleMeasurement[] _Measurements = new SimpleMeasurement[0];
     try
     {
         var sw = System.Diagnostics.Stopwatch.StartNew();
         _Measurements = (await _RestDataServiceClient.GetMeasurements(partPath, new MeasurementFilterAttributes
         {
             LimitResult = 1000
         })).ToArray();//
         sw.Stop();
         foreach (var mes in _Measurements)
         {
             if (mes.GetAttributeValue((ushort)20028) != null)
             {
                 if (ownerList.FindAll(n => n == mes.GetAttributeValue((ushort)20028)).Count() == 0)
                 {
                     ownerList.Add(mes.GetAttributeValue((ushort)20028));
                     comboBox1.Items.Add(mes.GetAttributeValue((ushort)20028));
                 }
             }
             if (mes.GetAttributeValue((ushort)20004) != null)
             {
                 if (salesList.FindAll(n => n == mes.GetAttributeValue((ushort)20004)).Count() == 0)
                 {
                     salesList.Add(mes.GetAttributeValue((ushort)20004));
                     comboBox2.Items.Add(mes.GetAttributeValue((ushort)20004));
                 }
             }
             if (mes.GetAttributeValue((ushort)20003) != null)
             {
                 if (demoEngineerList.FindAll(n => n == mes.GetAttributeValue((ushort)20003)).Count() == 0)
                 {
                     demoEngineerList.Add(mes.GetAttributeValue((ushort)20003));
                     comboBox3.Items.Add(mes.GetAttributeValue((ushort)20003));
                 }
             }
             if (mes.GetAttributeValue((ushort)1062) != null)
             {
                 if (customerList.FindAll(n => n == mes.GetAttributeValue((ushort)1062)).Count() == 0)
                 {
                     customerList.Add(mes.GetAttributeValue((ushort)1062));
                     comboBox4.Items.Add(mes.GetAttributeValue((ushort)1062));
                     customers.Add(new Customer
                     {
                         name     = mes.GetAttributeValue((ushort)1062),
                         province = mes.GetAttributeValue((ushort)20001),
                         city     = mes.GetAttributeValue((ushort)20002)
                     });
                 }
             }
             if (mes.GetAttributeValue((ushort)20051) != null)
             {
                 if (cmmList.FindAll(n => n == mes.GetAttributeValue((ushort)20051)).Count() == 0)
                 {
                     cmmList.Add(mes.GetAttributeValue((ushort)20051));
                     comboBox7.Items.Add(mes.GetAttributeValue((ushort)20051));
                 }
             }
             if (mes.GetAttributeValue((ushort)20052) != null)
             {
                 if (sensorList.FindAll(n => n == mes.GetAttributeValue((ushort)20052)).Count() == 0)
                 {
                     sensorList.Add(mes.GetAttributeValue((ushort)20052));
                     comboBox8.Items.Add(mes.GetAttributeValue((ushort)20052));
                 }
             }
         }
         listCombobox1 = getComboboxItems(this.comboBox1); //获取Item
         listCombobox2 = getComboboxItems(this.comboBox2); //获取Item
         listCombobox3 = getComboboxItems(this.comboBox3); //获取Item
         listCombobox4 = getComboboxItems(this.comboBox4); //获取Item
         listCombobox7 = getComboboxItems(this.comboBox7); //获取Item
         listCombobox8 = getComboboxItems(this.comboBox8); //获取Item
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }