public static async Task ClassInitializeAsync(TestContext context)
        {
            MeasurementType t1 = new MeasurementType
            {
                MeasurementTypeId = 1,
                Name = "MyMeasurementType1"
            };

            MeasurementType t2 = new MeasurementType
            {
                MeasurementTypeId = 2,
                Name = "MyMeasurementType2"
            };

            MeasurementType t3 = new MeasurementType
            {
                MeasurementTypeId = 3,
                Name = "MyMeasurementType3"
            };

            measurementTypes.Add(t1);
            measurementTypes.Add(t2);
            measurementTypes.Add(t3);


            foreach (MeasurementType t in measurementTypes)
            {
                await measurementTypeDao.InsertAsync(t);
            }
        }
        public async override Task TestFindByIdAsync()
        {
            MeasurementType t = measurementTypes[0];
            MeasurementType s = await measurementTypeDao.FindByIdAsync(t.MeasurementTypeId);

            Assert.AreEqual(t, s);
        }
        public void TestMethodValues()
        {
            Measurement     actutalMeasurement, expectedMeasurement;
            DateTime        timeOfSample  = DateTime.Parse("2017-01-03T10:04:45");
            Double          valueOfSample = 35.79;
            MeasurementType typeOfSample  = MeasurementType.TEMP;

            // Sets values.
            actutalMeasurement = new Measurement()
            {
                MeasurementTime = new Instant()
                {
                    Time = timeOfSample
                },
                MeasurementValue = valueOfSample,
                Type             = typeOfSample
            };
            expectedMeasurement = new Measurement()
            {
                MeasurementTime = new Instant()
                {
                    Time = timeOfSample
                },
                MeasurementValue = valueOfSample,
                Type             = typeOfSample
            };

            // Checks if values are same.
            Assert.AreEqual(expectedMeasurement.MeasurementTime.Time, actutalMeasurement.MeasurementTime.Time);
            Assert.AreEqual(expectedMeasurement.MeasurementValue, actutalMeasurement.MeasurementValue);
            Assert.AreEqual(expectedMeasurement.Type, actutalMeasurement.Type);
        }
        public void TestMethodToString()
        {
            Measurement     actutalMeasurement, expectedMeasurement;
            DateTime        timeOfSample  = DateTime.Parse("2017-01-03T10:04:45");
            Double          valueOfSample = 35.79;
            MeasurementType typeOfSample  = MeasurementType.TEMP;

            // Sets values.
            actutalMeasurement = new Measurement()
            {
                MeasurementTime = new Instant()
                {
                    Time = timeOfSample
                },
                MeasurementValue = valueOfSample,
                Type             = typeOfSample
            };
            expectedMeasurement = new Measurement()
            {
                MeasurementTime = new Instant()
                {
                    Time = timeOfSample
                },
                MeasurementValue = valueOfSample,
                Type             = typeOfSample
            };

            // Checks ToString() method returns same string.
            Assert.AreEqual(expectedMeasurement.ToString(), actutalMeasurement.ToString());
        }
Ejemplo n.º 5
0
 public async Task<bool> UpdateAsync(MeasurementType measurementType)
 {
     return await this.template.ExecuteAsync(
         @"update measurementType set name = @name where measurementTypeId = @measurementTypeId",
         new Parameter("@measurementTypeId", measurementType.MeasurementTypeId),
         new Parameter("@name", measurementType.Name)) == 1;
 }
Ejemplo n.º 6
0
 public async Task <bool> DeleteMeasurementTypeAsync(MeasurementType measurementType)
 {
     return(await _template.ExecuteAsync(
                "delete from measurement_type where id = @id",
                new[] { new QueryParameter("@id", measurementType.Id) }
                ) == 1);
 }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View view = inflater.Inflate(Resource.Layout.ListMeasurements, container, false);

            measurementRecyclerView = view.FindViewById <RecyclerView>(Resource.Id.recyclerViewMeasurements);
            measurementRecyclerView.SetLayoutManager(new LinearLayoutManager(this.Activity));
            measurementRecyclerView.HasFixedSize = true;

            //measurement type spinner
            spinner = view.FindViewById <Spinner>(Resource.Id.measurementsListSpinner);
            spinner.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinner_ItemSelected);
            var adapter = ArrayAdapter.CreateFromResource(this.Activity, Resource.Array.measurements_array, Android.Resource.Layout.SimpleSpinnerItem);

            adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            spinner.Adapter = adapter;

            selected        = spinner.SelectedItemPosition;
            measurementType = (MeasurementType)selected;
            loadData(measurementType);

            var fabAdd = view.FindViewById <FloatingActionButton>(Resource.Id.fab_add);

            fabAdd.Click += (s, e) =>
            {
                var    trans  = FragmentManager.BeginTransaction();
                Bundle bundle = new Bundle();
                bundle.PutInt("type", selected);
                addMeasurementFragment.Arguments = bundle;
                trans.Replace(Resource.Id.fragmentContainer, addMeasurementFragment);
                //trans.AddToBackStack(null);
                trans.Commit();
            };

            return(view);
        }
Ejemplo n.º 8
0
 public async Task<bool> InsertAsync(MeasurementType measurementType)
 {
     return await this.template.ExecuteAsync(
         @"insert into measurementType (measurementTypeId, name) VALUES (@measurementTypeId, @name)",
         new Parameter("@measurementTypeId", measurementType.MeasurementTypeId),
         new Parameter("@name", measurementType.Name)) == 1;
 }
Ejemplo n.º 9
0
        public DataTable PrepareDataContainer(int electrodes, MeasurementType type)
        {
            if (this.dataGridView1.DataSource != null)
            {
                this.dataGridView1.DataSource = null;
            }
            this.data = new DataTable();
            for (int i = 0; i < electrodes; i++)
            {
                this.data.Columns.Add((i + 1).ToString(), typeof(Complex));
            }

            object[] r = new object[electrodes];
            for (int i = 0; i < electrodes; i++)
            {
                r[i] = Complex.Zero;
            }
            for (int i = 0; i < electrodes; i++)
            {
                this.data.Rows.Add(r);
            }

            this.MeasurementType                  = type;
            this.dataGridView1.DataSource         = this.data;
            this.dataGridView1.Columns[0].Visible = false;

            this.data.RowChanged += Data_RowChanged;

            this.RecalculateColors();

            return(this.data);
        }
Ejemplo n.º 10
0
        public short this[MeasurementType mt]
        {
            get
            {
                int index = _List.IndexOfKey((int)mt);

                return(index >= 0 ? (short)_List.GetByIndex(index) : NoValue);
            }
            set
            {
                int index = _List.IndexOfKey((int)mt);

                if (value == NoValue)
                {
                    if (index >= 0)
                    {
                        _List.RemoveAt(index);
                    }
                }
                else
                {
                    if (index >= 0)
                    {
                        _List.SetByIndex(index, value);
                    }
                    else
                    {
                        _List.Add((int)mt, value);
                    }
                }
            }
        }
Ejemplo n.º 11
0
        public void Units(MeasurementType type, Type unitType)
        {
            using TestForm tf = new TestForm();
            var util    = MeasurementTools.Instance.GetUtility(type);
            var control = tf.AddControl <MeasurementControl.MeasurementControl>(13, 13, 300, 28);

            if (control.MeasurementType != type)
            {
                control.MeasurementType = type;
            }

            control.Unit.Should().BeOfType(unitType);
            if (control.MeasurementType == MeasurementType.BallisticCoefficient)
            {
                control.Value.Should().BeOfType(typeof(BallisticCoefficient));
            }
            else
            {
                control.Value.Should().BeOfType(typeof(Measurement <>).MakeGenericType(new Type[] { unitType }));
            }

            var unitPart = control.ComboBox("UnitPart");

            unitPart.Should()
            .HaveItemsCount(util.Units.Count)
            .And
            .HaveItemsCount(Enum.GetValues(unitType).Length);

            foreach (MeasurementUtility.Unit unit in util.Units)
            {
                unitPart.Should().HaveItemMatching <MeasurementUtility.Unit>(u => u.Equals(unit));
            }
        }
Ejemplo n.º 12
0
        public static MeasurementType GetMeasurementType(int measurementId)
        {
            MeasurementType result = new MeasurementType();

            switch (measurementId)
            {
            case (int)MeasurementType.Gram:
                result = MeasurementType.Gram;
                break;

            case (int)MeasurementType.Dekagram:
                result = MeasurementType.Dekagram;
                break;

            case (int)MeasurementType.Hectogram:
                result = MeasurementType.Hectogram;
                break;

            case (int)MeasurementType.Kilogram:
                result = MeasurementType.Kilogram;
                break;

            case (int)MeasurementType.Ton:
                result = MeasurementType.Ton;
                break;

            default:
                break;
            }

            return(result);
        }
Ejemplo n.º 13
0
        public static void Main(string[] args)
        {
            notificationList = Notification.GetNotifications();
            InitNotificationSendDateDictionary();

            while (true)
            {
                foreach (Notification notification in notificationList)
                {
                    double currentValue = Measurement.GetCurrentValue(MeasurementType.GetMeasurementTypes()
                                                                      .Find(x => x.name == notification.measurement_type).id, notification.tunnel.id);

                    DateTime currentDateTime = DateTime.Now;

                    if (notification.condition == "<")
                    {
                        if (currentValue < notification.value)
                        {
                            if ((currentDateTime - notificationSendDate[notification.id]).TotalMinutes > notification.repeat_after)
                            {
                                string messageText = $"W tunelu {notification.tunnel.name} wartość" +
                                                     $" {notification.measurement_type} " +
                                                     $"nie może byc mniejsze od {notification.value} a jest równe = {currentValue}";

                                try {
                                    new MailSending(notification.receivers).SendMessage(messageText);
                                } catch (Exception e) {
                                    Console.WriteLine(e);
                                }


                                notificationSendDate[notification.id] = currentDateTime;
                            }
                        }
                    }
                    else if (notification.condition == ">")
                    {
                        if (currentValue > notification.value)
                        {
                            if ((currentDateTime - notificationSendDate[notification.id]).TotalMinutes > notification.repeat_after)
                            {
                                string messageText = $"W tunelu {notification.tunnel.name} wartość" +
                                                     $" {notification.measurement_type} " +
                                                     $"nie może byc większe od {notification.value} a jest równe = {currentValue}";

                                try {
                                    new MailSending(notification.receivers).SendMessage(messageText);
                                } catch (Exception e) {
                                    Console.WriteLine(e);
                                }

                                notificationSendDate[notification.id] = currentDateTime;
                            }
                        }
                    }
                }

                Thread.Sleep(30000);
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Begins the measurement using the specified measuremet annotation.
        /// </summary>
        /// <param name="type">The measurement annotation type.</param>
        private void BeginMeasurement(MeasurementType type)
        {
            ImageMeasureTool tool = (ImageMeasureTool)VisualTool;

            switch (type)
            {
            case MeasurementType.Line:
                tool.BeginLineMeasurement();
                break;

            case MeasurementType.Lines:
                tool.BeginLinesMeasurement();
                break;

            case MeasurementType.Ellipse:
                tool.BeginEllipseMeasurement();
                break;

            case MeasurementType.Angle:
                tool.BeginAngleMeasurement();
                break;

            default:
                throw new NotImplementedException();
            }
        }
Ejemplo n.º 15
0
        public async Task <List <WsreComponentTab> > GetComponentTabData(int wsreId, MeasurementType uom)
        {
            var w = await _context.WSRE.FindAsync(wsreId);

            if (w == null)
            {
                return(null);
            }

            return(w.ComponentRecords.Select(c => new WsreComponentTab()
            {
                Id = c.Id,
                Brand = c.Component.Make == null ? "Unknown" : c.Component.Make.makedesc,
                Cmu = c.Cmu,
                Comment = c.Comment,
                Component = c.Component.LU_COMPART.LU_COMPART_TYPE.comparttype + " - " + c.Component.LU_COMPART.compartid,
                Measurement = uom == MeasurementType.Milimeter ? c.Measurement : c.Measurement.MilimeterToInch(),
                Photos = c.Photos.Where(p => p.Deleted == false).Select(p => new WsreComponentPhoto()
                {
                    Id = p.Id,
                    ImageData = Convert.ToBase64String(p.Data),
                    Title = p.Title
                }).ToList(),
                Recommendations = c.Recommendations.Select(r => r.Recommendation.Description).ToList(),
                RemainingLife = c.RemainingLife,
                WornPercentage = c.WornPercentage
            }).ToList());
        }
 protected override void Initialize(IServiceProvider provider)
 {
     if (ParentWorkflow.Parameters.ContainsKey("TimeMeasurement"))
     {
         _timeMeasurement = FromTimeParameter(ParentWorkflow.Parameters["TimeMeasurement"]);
     }
     else
     {
         _timeMeasurement = TimeMeasurement.Relative; //Assume relative.
     }
     if (ParentWorkflow.Parameters.ContainsKey("MeasurementType"))
     {
         _measurementType = FromMeasurementParameter(ParentWorkflow.Parameters["MeasurementType"]);
     }
     else
     {
         _measurementType = MeasurementType.Relative; //Assume relative.
     }
     if (ParentWorkflow.Parameters.ContainsKey("AlertType"))
     {
         if (ParentWorkflow.Parameters["AlertType"].ToString().ToLower() == "period")
         {
             _alertType = AlertType.Period;
         }
         else
         {
             _alertType = AlertType.Daily;
         }
     }
     else
     {
         _alertType = AlertType.Daily; //Assume daily.
     }
 }
Ejemplo n.º 17
0
        public MeasurementTimeByType Calculate(MeasurementType type, ReleaseWindow releaseWindow, IEnumerable<Metric> metrics)
        {
            if (releaseWindow == null)
                throw new ArgumentNullException("releaseWindow");

            switch (type)
            {
                case MeasurementType.OverallTime:
                    return CalculateOverallTime(releaseWindow);

                case MeasurementType.DownTime:
                    return CalculateTimeBetweenMetrics(releaseWindow, metrics, type, MetricType.SiteDown, MetricType.SiteUp);

                case MeasurementType.DeployTime:
                    return CalculateTimeBetweenMetrics(releaseWindow, metrics, type, MetricType.StartDeploy, MetricType.FinishDeploy);

                case MeasurementType.PreDownTime:
                    return CalculatePreDownTime(releaseWindow, metrics);

                case MeasurementType.PostDownTime:
                    return CalculatePostDownTime(releaseWindow, metrics);

                case MeasurementType.RunTime:
                    return CalculateTimeBetweenMetrics(releaseWindow, metrics, type, MetricType.StartRun, MetricType.FinishRun);
                default: return null;
            }
        }
Ejemplo n.º 18
0
    /**
     * Get measurement corresponding to the input DateTime and MeasurementType.
     *  If no key/value pair exists for this DateTime, return null.
     */
    public GrowthMeasurement GetMeasurementForDateAndType(DateTime date, MeasurementType measurementType)
    {
        // TODO: [Stefan 09/25/2017] Make measurement retrieval convert values to given units.
        // Check if measurement exists for date/type and update value of "measurement".

        /*
         * Boolean measurement_exists_for_date = measurementTypeMap[measurementType].TryGetValue(date, out GrowthMeasurement measurement);
         * if (measurement_exists_for_date)
         * {
         *  return measurement;
         * }
         * else
         * {
         *  return null;
         * }
         */

        switch (measurementType)
        {
        case MeasurementType.HEIGHT:
            heightData.TryGetValue(date, out HeightMeasurement heightMeasurement);
            return(heightMeasurement);

        case MeasurementType.WEIGHT:
            weightData.TryGetValue(date, out WeightMeasurement weightMeasurement);
            return(weightMeasurement);

        case MeasurementType.HEAD_CIRCUMFERENCE:
            headCircumferenceData.TryGetValue(date, out HeadCircumferenceMeasurement headCircumferenceMeasurement);
            return(headCircumferenceMeasurement);
        }
        return(null);
    }
Ejemplo n.º 19
0
    void ChangeAlgorithm(int ID)
    {
        switch (ID)
        {
        case 0:
            nowAlogrithm       = AlgorithmPattern.CrossSpectrum;
            nowMeasurementType = MeasurementType.Standard;
            break;

        case 1:
            nowAlogrithm       = AlgorithmPattern.instantaneous;
            nowMeasurementType = MeasurementType.Transient;
            break;

        case 2:
            nowAlogrithm       = AlgorithmPattern.STFT;
            nowMeasurementType = MeasurementType.Transient;
            break;

        case 3:
            nowAlogrithm       = AlgorithmPattern.AmbisonicsT;
            nowMeasurementType = MeasurementType.Transient;
            break;

        case 4:
            nowAlogrithm       = AlgorithmPattern.AmbisonicsTF;
            nowMeasurementType = MeasurementType.Transient;
            break;
        }
        UpdateSTFTParam();
    }
Ejemplo n.º 20
0
        public async Task Update()
        {
            IMeasurementTypeDao measurementTypeDao = new AdoMeasurementTypeDao(DefaultConnectionFactory.FromConfiguration(configName));

            MeasurementType measurementType = await measurementTypeDao.FindByIdAsync(1);

            string originalName = measurementType.Name;

            measurementType.Name = "New name";
            bool update1 = await measurementTypeDao.UpdateMeasurementTypeAsync(measurementType);

            Assert.IsTrue(update1);

            measurementType = await measurementTypeDao.FindByIdAsync(1);

            Assert.AreEqual(measurementType.Name, "New name");

            measurementType.Name = originalName;
            bool update2 = await measurementTypeDao.UpdateMeasurementTypeAsync(measurementType);

            Assert.IsTrue(update2);

            measurementType = await measurementTypeDao.FindByIdAsync(1);

            Assert.AreEqual(measurementType.Name, originalName);
        }
Ejemplo n.º 21
0
    /**
     * Retrieve sorted list of data corresponding to a given measurementType.
     *  Return null if no data.
     *  TODO: [Stefan 10/03/2017] Return measurements converted to proper units.
     */
    public List <GrowthMeasurement> GetSortedMeasurementList(MeasurementType measurementType)
    {
        //Dictionary<DateTime, GrowthMeasurement> measurementDictionary = measurementTypeMap[measurementType];
        List <GrowthMeasurement> measurements = new List <GrowthMeasurement>();

        switch (measurementType)
        {
        case MeasurementType.HEIGHT:
            measurements.AddRange(heightData?.Values);
            break;

        case MeasurementType.WEIGHT:
            measurements.AddRange(weightData?.Values);
            break;

        case MeasurementType.HEAD_CIRCUMFERENCE:
            measurements.AddRange(headCircumferenceData?.Values);
            break;
        }
        if (EMPTY == measurements.Count)
        {
            return(null);
        }
        if (measurements.Count > 1)
        {
            measurements.Sort((x, y) => x.DateRecorded.CompareTo(y.DateRecorded));
        }
        return(measurements);
    }
        public void MeasurementUtil_Types(MeasurementType type, Type unit, Type value)
        {
            var util = MeasurementTools.Instance.GetUtility(type);

            util.MeasurementUnit.Should().Be(unit);
            util.MeasurementType.Should().Be(value);
        }
Ejemplo n.º 23
0
            public double Measure(MeasurementType measurementType)
            {
                double measurement = double.NaN;

                Adapter.ViSessionStatusCheck(IviDCPwrInterop.Measure(Adapter.Session, ChannelName, DCPwrMeasurementType.getC_Value(measurementType), ref measurement));
                return(measurement);
            }
Ejemplo n.º 24
0
 public Mapping(string propertyName, MeasurementType measurementType, Func <double, double> convertFunction)
 {
     PropertyName    = propertyName;
     MeasurementType = measurementType;
     convertFunction ??= d => d;
     ConvertFunction = convertFunction;
 }
Ejemplo n.º 25
0
    public static String MeasurementTypeAsString(MeasurementType measurementType, Language language)
    {
        if (language == null || language == Language.ENGLISH)
        {
            switch (measurementType)
            {
            case MeasurementType.HEIGHT:
                return(HEIGHT_STRING_ENG);

            case MeasurementType.WEIGHT:
                return(WEIGHT_STRING_ENG);

            case MeasurementType.HEAD_CIRCUMFERENCE:
                return(HEAD_CIRCUMFERENCE_STRING_ENG);

            default:
                return("");
            }
        }
        // Spanish language settings.
        switch (measurementType)
        {
        case MeasurementType.HEIGHT:
            return(HEIGHT_STRING_SPANISH);

        case MeasurementType.WEIGHT:
            return(WEIGHT_STRING_SPANISH);

        case MeasurementType.HEAD_CIRCUMFERENCE:
            return(HEAD_CIRCUMFERENCE_STRING_SPANISH);

        default:
            return("");
        }
    }
Ejemplo n.º 26
0
        public ActionResult DeleteConfirmed(int id)
        {
            MeasurementType measurementType = _measurementTypeService.GetById(id);

            _measurementTypeService.Delete(measurementType);
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 27
0
        public static Dictionary<string, string> CreateGetMeasureHttpContent(string deviceId, Scale scale, MeasurementType[] measurementTypes, string moduleId = null, bool onlyLastMeasurement = false, DateTime? begin = null, DateTime? end = null, bool optimize = true, int limit = 1024, bool realtime = false)
        {
            var content = new Dictionary<string, string>
            {
                {"device_id", deviceId },
                {"scale",  scale.GetScaleName()},
                {"type", measurementTypes.ToMeasurementTypesString() },
                {"optimize", optimize.ToString() },
            };

            if (!string.IsNullOrEmpty(moduleId))
                content.Add("module_id", moduleId);
            if (onlyLastMeasurement)
            {
                content.Add("date_end", "last");
            }
            else
            {
                if (begin.HasValue)
                    content.Add("date_begin", begin.Value.ToUtcTimestamp().ToString());
                if (end.HasValue)
                    content.Add("date_end", end.Value.ToUtcTimestamp().ToString());
            }

            if (limit != 1024)
                content.Add("limit", limit > 1024 || limit < 1 ? "1024" : limit.ToString());
            if (realtime)
                content.Add("realtime", "true");

            return content;
        }
Ejemplo n.º 28
0
        private void btnSendParametersToRLC_Click(object sender, EventArgs e)
        {
            MeasurementType mt = MeasurementType.Unknown;

            if (this.rbParallelCapacitance.Checked)
            {
                mt = MeasurementType.Capacitance_Parallel;
            }
            if (this.rbSerialCapacitance.Checked)
            {
                mt = MeasurementType.Capacitance_Serial;
            }
            if (this.rbImpedance.Checked)
            {
                mt = MeasurementType.Resistance_Reactance;
            }

            int    freq    = (int)this.edtMeasurementFrequency.Value;
            double voltage = (double)this.edtVoltage.Value;
            double delay   = (double)this.edtTriggerDelay.Value;
            int    average = (int)this.edtAverage.Value;

            Debug.Assert(mt != MeasurementType.Unknown);

            try
            {
                Program.a.SendConfiguration(mt, freq, voltage, delay, 0, average);
                MessageBox.Show("Konfiguracja wysłana do mostka.\nTryb pomiarowy=" + mt.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Wyjątek podczas komunikacji z mostkiem:\n" + ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Program.a.SafeDisconnect();
            }
        }
        public async Task <IActionResult> Edit(int id, [Bind("MeasurementTypeId,Type")] MeasurementType measurementType)
        {
            if (id != measurementType.MeasurementTypeId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(measurementType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MeasurementTypeExists(measurementType.MeasurementTypeId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(measurementType));
        }
Ejemplo n.º 30
0
 private void PrintMeasurements(MeasurementType measurementType, IEnumerable <Measurement> sampledMeasurements)
 {
     Print($"Measurement Type: {measurementType.GetDescription()}");
     foreach (var measurement in sampledMeasurements)
     {
         Print($"\t{measurement}");
     }
 }
        public static Attribute[] GetAttributes(this MeasurementType measType)
        {
            var fi = measType.GetType().GetField(measType.ToString());

            Attribute[] attributes = (Attribute[])fi.GetCustomAttributes(typeof(Attribute), false);

            return(attributes);
        }
Ejemplo n.º 32
0
 public static decimal ConvertFrom(this decimal reading, MeasurementType from)
 {
     if (from == MeasurementType.Milimeter)
     {
         return(reading * (decimal)(0.0393701));
     }
     return(reading * (decimal)25.4);
 }
Ejemplo n.º 33
0
        public void CreateMeasurementData(bool optimized, MeasurementType[] measurementTypes)
        {
            Measurements = new List<Measurement>();

            if (optimized)
            {
                var array = Data as JArray;
                if (array == null)
                    throw new Exception("Unexpected JSON format");

                foreach (var a in array)
                {
                    var begintime = (long)JsonConvert.DeserializeObject(a["beg_time"].ToString(), typeof(long));
                    long stepTime = 0;

                    if (a["step_time"] != null) //contains does somehow not seem to work here
                    {
                        stepTime = (long)JsonConvert.DeserializeObject(a["step_time"].ToString(), typeof(long));
                    }

                    var valueSteps = a["value"] as JArray;
                    for (var i = 0; i < valueSteps.Count; i++)
                    {
                        var valueArray = (double?[])JsonConvert.DeserializeObject(valueSteps[i].ToString(), typeof(double?[]));
                        var measurementValues = new List<MeasurementValue>();

                        for (var j = 0; j < measurementTypes.Count(); j++)
                        {
                            var value = new MeasurementValue {Type = measurementTypes[j], Value = valueArray[j]};
                            measurementValues.Add(value);
                        }

                        var measurement = new Measurement(begintime + (stepTime * i), measurementValues);
                        Measurements.Add(measurement);
                    }
                }
            }
            else
            {
                var dict = (Dictionary<long, double?[]>)JsonConvert.DeserializeObject(Data.ToString(), typeof(Dictionary<long, double?[]>));
                foreach (var entry in dict)
                {
                    var measurementValues = new List<MeasurementValue>();

                    for (var j = 0; j < measurementTypes.Count(); j++)
                    {
                        var value = new MeasurementValue { Type = measurementTypes[j], Value = entry.Value[j] };
                        measurementValues.Add(value);
                    }

                    var measurement = new Measurement(entry.Key, measurementValues);
                    Measurements.Add(measurement);
                }
            }
        }
Ejemplo n.º 34
0
 void AddMeasureType(string name, string id)
 {
     MeasurementType mt = new MeasurementType();
     mt.ID = id;
     mt.Name = name;
     mt.Category = "LMI";
     mt.Unit = "people";
     mt.Frequency = "monthly";
     mt.RelatedEntityTypeId = reid;
     m.Add(name, mt);
 }
Ejemplo n.º 35
0
 public static extern IntPtr imaqMeasureParticles(IntPtr image, MeasureParticlesCalibrationMode calibrationMode, ref MeasurementType measurements, int numMeasurements);
Ejemplo n.º 36
0
 public static extern int imaqMeasureParticle(IntPtr image, int particleNumber, int calibrated, MeasurementType measurement, ref double value);
Ejemplo n.º 37
0
 public Measurement(MeasurementType type, string value)
 {
     Type = type;
     Value = value;
 }
Ejemplo n.º 38
0
 public MeasurementObject(MeasurementType type, string name, double value)
 {
     this.Type = type;
     this.Name = name;
     this.Value = value;
 }
Ejemplo n.º 39
0
        private static MeasurementTimeByType CalculateTimeBetweenMetrics(ReleaseWindow releaseWindow, IEnumerable<Metric> metrics,
            MeasurementType measurementType, MetricType startMetricType, MetricType finishMetricType)
        {
            var metricDict = GetMetricTimes(new[] { startMetricType, finishMetricType }, metrics);
            if (metricDict == null)
            {
                Log.WarnFormat("Some metrics are absent. ReleaseId={0}, Metrics={1}", releaseWindow.ExternalId, new[] { startMetricType, finishMetricType }.FormatElements());
                return null;
            }

            var startMetricTime = metricDict[startMetricType];
            var finishMetricTime = metricDict[finishMetricType];

            if (finishMetricTime < startMetricTime)
                throw new ArgumentException(string.Format("{1} time less then {0} time", startMetricType, finishMetricType));

            return new MeasurementTimeByType
            {
                Type = measurementType,
                Value = ConvertToMinutes(
                    finishMetricTime.Subtract(startMetricTime).TotalMinutes
                )
            };
        }