Beispiel #1
0
 public SensorSample(string sensorId, double sensorValue, string unitOfMeasure, SampleTypes sampleType)
 {
     SampleType = sampleType;
     UnitOfMeasure = unitOfMeasure;
     SensorValue = sensorValue;
     SensorId = sensorId;
 }
        /// <summary>
        /// Executes the specified sample type.
        /// </summary>
        /// <param name="sampleType">Type of the sample.</param>
        /// <param name="args">The arguments.</param>
        public void Execute(SampleTypes sampleType, object[] args = null)
        {
            logger.WriteSeparator();
            ISamples sample = GetSample(sampleType);

            using (var sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["sqlServer"].ConnectionString))
            {
                sample.Execute(sqlConnection, logger, args);
            }
            logger.WriteSeparator();
        }
Beispiel #3
0
        /// <summary>
        /// 根据名称获取样本类型
        /// </summary>
        /// <param name="up"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static SampleTypes GetBy(Fp_Common.UnameAndPwd up, string name)
        {
            List <SampleTypes> list   = GetAll(up);
            SampleTypes        sample = new SampleTypes();

            if (list != null && list.Count > 0)
            {
                sample = list.Where(a => a.name == name).FirstOrDefault();
            }
            return(sample);
        }
Beispiel #4
0
 public override string ToString()
 {
     if (m_toString.Length < 1)
     {
         if (FluidType >= 0 && FluidType <= 15)
         {
             SampleTypes t = (SampleTypes)FluidType;
             m_toString = t.ToString();
         }
         else
         {
             m_toString = "(unknown: " + FluidType.ToString() + ")";
         }
     }
     return(m_toString);
 }
        public SampleGroupViewModel(
            SampleTypes sampleType,
            IEnumerable <ButtonViewModel> samplesList)
        {
            _sampleType  = sampleType;
            _samplesList = samplesList.ToList();

            switch (sampleType)
            {
            case SampleTypes.AwaitableUI:
                this.Caption = "Awaitable UI";
                break;

            case SampleTypes.Controls:
                this.Caption = "Controls";
                break;

            case SampleTypes.Debugging:
                this.Caption = "Debugging";
                break;

            case SampleTypes.Extensions:
                this.Caption = "Control Extensions";
                break;

            case SampleTypes.Imaging:
                this.Caption = "Imaging helpers";
                break;

            case SampleTypes.Miscellaneous:
                this.Caption = "Miscellaneous";
                break;

            default:
                if (Debugger.IsAttached)
                {
                    Debugger.Break();
                }

                this.Caption = _sampleType.ToString();
                break;
            }

            this.Command = new RelayCommand(ToggleIsExpanded);;
        }
        /// <summary>
        /// Gets the sample.
        /// </summary>
        /// <param name="sampleType">Type of the sample.</param>
        /// <returns></returns>
        public static ISamples GetSample(SampleTypes sampleType)
        {
            ISamples sample = null;

            switch (sampleType)
            {
            case SampleTypes.SimpleSelectStatement:
                sample = new SimpleSelectStatement();
                break;

            case SampleTypes.SimpleSelectStatementWithDynamicEntities:
                sample = new SimpleSelectStatementWithDynamicEntities();
                break;

            case SampleTypes.MultiMappingSingleEntity:
                sample = new MultiMappingSelectStatement();
                break;

            case SampleTypes.MultiMappingChildEntities:
                sample = new MultiMappingOneToManyRelationSelectStatement();
                break;

            case SampleTypes.ParameterizedSelectStatement:
                sample = new ParameterizedSelectStatement();
                break;

            case SampleTypes.MultipleQueries:
                sample = new MultipleQueries();
                break;

            case SampleTypes.SimpleStoredProcedure:
                sample = new SimpleStoredProcedure();
                break;

            case SampleTypes.SimpleInsertStatement:
                sample = new SimpleInsertStatement();
                break;

            default:
                break;
            }

            return(sample);
        }
        public SampleGroupViewModel(
            SampleTypes sampleType,
            IEnumerable<ButtonViewModel> samplesList)
        {
            _sampleType = sampleType;
            _samplesList = samplesList.ToList();

            switch (sampleType)
            {
                case SampleTypes.AwaitableUI:
                    this.Caption = "Awaitable UI";
                    break;
                case SampleTypes.Controls:
                    this.Caption = "Controls";
                    break;
                case SampleTypes.Debugging:
                    this.Caption = "Debugging";
                    break;
                case SampleTypes.Extensions:
                    this.Caption = "Control Extensions";
                    break;
                case SampleTypes.Imaging:
                    this.Caption = "Imaging helpers";
                    break;
                case SampleTypes.Miscellaneous:
                    this.Caption = "Miscellaneous";
                    break;
                default:
                    if (Debugger.IsAttached)
                    {
                        Debugger.Break();
                    }

                    this.Caption = _sampleType.ToString();
                    break;
            }
            
            this.Command = new RelayCommand(ToggleIsExpanded);;
        }
Beispiel #8
0
        /// <summary>
        /// Trains the statistical model
        /// </summary>
        /// <param name="samples">training samples</param>
        /// <param name="layout">SampleTypes value</param>
        /// <param name="responses">vector of responses associated with the training samples.</param>
        /// <returns></returns>
        public virtual bool Train(InputArray samples, SampleTypes layout, InputArray responses)
        {
            if (ptr == IntPtr.Zero)
            {
                throw new ObjectDisposedException(GetType().Name);
            }
            if (samples == null)
            {
                throw new ArgumentNullException("samples");
            }
            if (responses == null)
            {
                throw new ArgumentNullException("responses");
            }
            samples.ThrowIfDisposed();
            responses.ThrowIfDisposed();

            int ret = NativeMethods.ml_StatModel_train2(ptr, samples.CvPtr, (int)layout, responses.CvPtr);

            GC.KeepAlive(samples);
            GC.KeepAlive(responses);
            return(ret != 0);
        }
Beispiel #9
0
        /// <summary>
        /// Sets the value of a sample type field.
        /// </summary>
        /// <param name="editableRoot">
        /// The editable root.
        /// </param>
        /// <param name="sampleTypeFieldName">
        /// The sample type field name.
        /// </param>
        /// <param name="sampleType">
        /// The sample type.
        /// </param>
        public static void SetSampleType(this IEditableRoot editableRoot, string sampleTypeFieldName, SampleTypes? sampleType)
        {
            var value = sampleType != null ? sampleType.ToString() : null;

            editableRoot.SetValueByPropertyName(sampleTypeFieldName, value);
        }
Beispiel #10
0
        /// <summary>
        /// Trains the statistical model
        /// </summary>
        /// <param name="samples">training samples</param>
        /// <param name="layout">SampleTypes value</param>
        /// <param name="responses">vector of responses associated with the training samples.</param>
        /// <returns></returns>
        public virtual bool Train(InputArray samples, SampleTypes layout, InputArray responses)
        {
            if (ptr == IntPtr.Zero)
                throw new ObjectDisposedException(GetType().Name);
            if (samples == null) 
                throw new ArgumentNullException("samples");
            if (responses == null)
                throw new ArgumentNullException("responses");
            samples.ThrowIfDisposed();
            responses.ThrowIfDisposed();

            int ret = NativeMethods.ml_StatModel_train2(ptr, samples.CvPtr, (int)layout, responses.CvPtr);
            GC.KeepAlive(samples);
            GC.KeepAlive(responses);
            return ret != 0;
        }
Beispiel #11
0
        private void UpdateSample(ISampleEdit sample, SampleTypes sampleType)
        {
            switch (sampleType)
            {
                case SampleTypes.Number:
                    sample.SampleNumeric = SafeTypeConverter.Convert<double?>(NewValue);
                    break;

                case SampleTypes.Boolean:
                    sample.SampleBoolean = SafeTypeConverter.Convert<bool?>(NewValue);
                    break;

                case SampleTypes.Alphanumeric:
                    sample.SampleAlphanumeric = SafeTypeConverter.Convert<string>(NewValue);
                    break;

                default:
                    throw new NotSupportedException(string.Format(CultureInfo.InvariantCulture, "The sample type {0} is not supported.", sampleType));
            }
        }
Beispiel #12
0
        private static bool IsEmpty(ISampleEdit sample, SampleTypes sampleType)
        {
            switch (sampleType)
            {
                case SampleTypes.Number:
                    return sample.SampleNumeric == null;

                case SampleTypes.Boolean:
                    return sample.SampleBoolean == null;

                case SampleTypes.Alphanumeric:
                    return string.IsNullOrEmpty(sample.SampleAlphanumeric);

                default:
                    throw new NotSupportedException(string.Format(CultureInfo.InvariantCulture, "The sample type {0} is not supported.", sampleType));
            }
        }
        /// <summary>
        /// Creates an example work order.
        /// </summary>
        private static DispensingWorkOrder CreateStubWorkOrder(SampleTypes sampleType)
        {
            Console.WriteLine("\tFile not found. Creating stub work order...");
            DispensingWorkOrder workOrder = new DispensingWorkOrder()
            {
                Header  = CreateStubHeader(),
                Parties = new Parties()
                {
                    ShipTo     = CreateStubParty("Adam's Back 40", "00040", true),
                    Buyer      = CreateStubParty("Adam's Farm", "00041", true),
                    DeliverTo  = CreateStubParty("Adam's Back 40", "00040", true),
                    OtherParty = new List <Party>()
                    {
                        CreateStubParty("Reseller", "09031")
                    },
                },
                WorkOrderType       = WorkOrderTypes.Create,
                WorkOrderIdentifier = new Identifier()
                {
                    Number = (120 + sampleType).ToString().PadLeft(6, '0'), Agency = AgencyTypes.AssignedByOriginator
                },
                WorkOrderCreationDateTime = DateTime.Now,
                Reference = new List <Reference>()
                {
                    new Reference()
                    {
                        ReferenceType = ReferenceTypes.PurchaseOrder, Value = "FF55500123"
                    },
                    new Reference()
                    {
                        ReferenceType = ReferenceTypes.Comment, Value = "This is a sample comment!"
                    },
                },
                PhysicalState = PhysicalStates.Liquid,
                RequestedArea = new ValueUnit()
                {
                    Value = 1000, Uom = "ACR", Agency = AgencyTypes.UN_REC_20
                },
                ProductGroup = new List <OrderProductGroup>()
                {
                    new OrderProductGroup()
                    {
                        Identifier = new List <Identifier>()
                        {
                            new Identifier()
                            {
                                Name = "32%", Number = "00105", Agency = AgencyTypes.AssignedByOriginator
                            }
                        },
                        GuaranteedAnalysis = "32-0-0",
                        Product            = new List <OrderProduct>()
                        {
                            new OrderProduct()
                            {
                                Identifier = new List <Identifier>()
                                {
                                    new Identifier()
                                    {
                                        Name = "32%", Number = "00054", Agency = AgencyTypes.AssignedByOriginator
                                    }
                                },
                                IsCarrier     = true,
                                PhysicalState = PhysicalStates.Liquid,
                                Density       = new ValueUnit()
                                {
                                    Value = 8.34, Uom = "GE", Agency = AgencyTypes.UN_REC_20
                                },
                                RequestedQuantity = new ValueUnit()
                                {
                                    Value = 4375, Uom = "GLL", Agency = AgencyTypes.UN_REC_20
                                },
                            },
                        }
                    }
                }
            };

            if (sampleType == SampleTypes.Blend || sampleType == SampleTypes.Vrt)
            {
                workOrder.ProductGroup[0].Identifier = new List <Identifier>()
                {
                    new Identifier()
                    {
                        Name = "28%", Number = "00133", Agency = AgencyTypes.AssignedByOriginator
                    }
                };
                workOrder.ProductGroup[0].GuaranteedAnalysis = "28-0-0";
                workOrder.ProductGroup[0].Product.Add(new OrderProduct()
                {
                    Identifier = new List <Identifier>()
                    {
                        new Identifier()
                        {
                            Name = "Water", Number = "00023", Agency = AgencyTypes.AssignedByOriginator
                        }
                    },
                    IsCarrier     = true,
                    PhysicalState = PhysicalStates.Liquid,
                    Density       = new ValueUnit()
                    {
                        Value = 8.34, Uom = "GE", Agency = AgencyTypes.UN_REC_20
                    },
                    RequestedQuantity = new ValueUnit()
                    {
                        Value = 625, Uom = "GLL", Agency = AgencyTypes.UN_REC_20
                    },
                });
            }

            if (sampleType == SampleTypes.Vrt)
            {
                workOrder.ProductGroup.Add(new OrderProductGroup()
                {
                    Identifier = new List <Identifier>()
                    {
                        new Identifier()
                        {
                            Name = "Weed Killer 3000", Number = "05573", Agency = AgencyTypes.AssignedByOriginator
                        }
                    },
                    GuaranteedAnalysis = "0-0-0 w/ Weed Killer 3000",
                    Product            = new List <OrderProduct>()
                });
                workOrder.ProductGroup[1].Product.Add(new OrderProduct()
                {
                    Identifier = new List <Identifier>()
                    {
                        new Identifier()
                        {
                            Name = "Weed Killer 3000", Number = "00057", Agency = AgencyTypes.AssignedByOriginator
                        }
                    },
                    IsCarrier     = false,
                    PhysicalState = PhysicalStates.Liquid,
                    Density       = new ValueUnit()
                    {
                        Value = 8.34, Uom = "GE", Agency = AgencyTypes.UN_REC_20
                    },
                    RequestedQuantity = new ValueUnit()
                    {
                        Value = 50, Uom = "GLL", Agency = AgencyTypes.UN_REC_20
                    },
                });
            }

            return(workOrder);
        }
        /// <summary>
        /// Creates an example work record.
        /// </summary>
        private static DispensingWorkRecord CreateStubWorkRecord(SampleTypes sampleType)
        {
            Console.WriteLine("\tFile not found. Creating stub work record...");
            DispensingWorkRecord workRecord = new DispensingWorkRecord()
            {
                Header  = CreateStubHeader(),
                Parties = new RecordParties()
                {
                    ShipTo     = CreateStubParty("Adam's Back 40", "00040", true),
                    Driver     = CreateStubParty("Bob Bobson", "00217"),
                    OtherParty = new List <Party>()
                    {
                        CreateStubParty("Ray's Fertilizer", "03570", true)
                    },
                },
                WorkOrderIdentifier = new Identifier()
                {
                    Number = "000123", Agency = AgencyTypes.AssignedByOriginator
                },
                WorkOrderCreationDateTime = DateTime.Now,
                WorkRecordIdentifier      = new Identifier()
                {
                    Number = "9000524", Agency = AgencyTypes.AssignedByOriginator
                },
                WorkRecordCreationDateTime = DateTime.Now,
                Reference = new List <Reference>()
                {
                    new Reference()
                    {
                        ReferenceType = ReferenceTypes.PurchaseOrder, Value = "FF55500123"
                    },
                    new Reference()
                    {
                        ReferenceType = ReferenceTypes.Comment, Value = "This is a sample comment!"
                    },
                },
                PhysicalState = PhysicalStates.Liquid,
                RequestedArea = new ValueUnit()
                {
                    Value = 1000, Uom = "ACR", Agency = AgencyTypes.UN_REC_20
                },
                ActualArea = new ValueUnit()
                {
                    Value = 1005, Uom = "ACR", Agency = AgencyTypes.UN_REC_20
                },
                BatchNumber  = 1,
                OrderStatus  = OrderStatuses.Complete,
                ProductGroup = new List <RecordProductGroup>()
                {
                    new RecordProductGroup()
                    {
                        Identifier = new List <Identifier>()
                        {
                            new Identifier()
                            {
                                Name = "32%", Number = "00105", Agency = AgencyTypes.AssignedByOriginator
                            }
                        },
                        GuaranteedAnalysis = "32-0-0",
                        Product            = new List <RecordProduct>()
                        {
                            new RecordProduct()
                            {
                                Identifier = new List <Identifier>()
                                {
                                    new Identifier()
                                    {
                                        Name = "32%", Number = "00054", Agency = AgencyTypes.AssignedByOriginator
                                    }
                                },
                                IsCarrier     = true,
                                PhysicalState = PhysicalStates.Liquid,
                                Density       = new ValueUnit()
                                {
                                    Value = 8.34, Uom = "GE", Agency = AgencyTypes.UN_REC_20
                                },
                                RequestedQuantity = new ValueUnit()
                                {
                                    Value = 4375, Uom = "GLL", Agency = AgencyTypes.UN_REC_20
                                },
                                ActualQuantity = new ValueUnit()
                                {
                                    Value = 4405, Uom = "GLL", Agency = AgencyTypes.UN_REC_20
                                },
                            },
                        }
                    }
                },
                TransportInformation = new List <TransportInformation>()
                {
                    new TransportInformation()
                    {
                        Identifier = new List <Identifier>()
                        {
                            new Identifier()
                            {
                                Name = "Bob's Truck", Number = "1", Agency = AgencyTypes.AssignedByOriginator
                            }
                        },
                        GrossWeight = new ValueUnit()
                        {
                            Value = 64000, Uom = "LBR", Agency = AgencyTypes.UN_REC_20
                        },
                        TareWeight = new ValueUnit()
                        {
                            Value = 12000, Uom = "LBR", Agency = AgencyTypes.UN_REC_20
                        },
                    }
                },
            };

            if (sampleType == SampleTypes.Blend || sampleType == SampleTypes.Vrt)
            {
                workRecord.ProductGroup[0].Identifier = new List <Identifier>()
                {
                    new Identifier()
                    {
                        Name = "28%", Number = "00133", Agency = AgencyTypes.AssignedByOriginator
                    }
                };
                workRecord.ProductGroup[0].GuaranteedAnalysis = "28-0-0";
                workRecord.ProductGroup[0].Product.Add(new RecordProduct()
                {
                    Identifier = new List <Identifier>()
                    {
                        new Identifier()
                        {
                            Name = "Water", Number = "00023", Agency = AgencyTypes.AssignedByOriginator
                        }
                    },
                    IsCarrier     = true,
                    PhysicalState = PhysicalStates.Liquid,
                    Density       = new ValueUnit()
                    {
                        Value = 8.34, Uom = "GE", Agency = AgencyTypes.UN_REC_20
                    },
                    RequestedQuantity = new ValueUnit()
                    {
                        Value = 625, Uom = "GLL", Agency = AgencyTypes.UN_REC_20
                    },
                    ActualQuantity = new ValueUnit()
                    {
                        Value = 635, Uom = "GLL", Agency = AgencyTypes.UN_REC_20
                    },
                });
            }

            if (sampleType == SampleTypes.Vrt)
            {
                workRecord.ProductGroup.Add(new RecordProductGroup()
                {
                    Identifier = new List <Identifier>()
                    {
                        new Identifier()
                        {
                            Name = "Weed Killer 3000", Number = "05573", Agency = AgencyTypes.AssignedByOriginator
                        }
                    },
                    GuaranteedAnalysis = "0-0-0 w/ Weed Killer 3000",
                    Product            = new List <RecordProduct>()
                });
                workRecord.ProductGroup[1].Product.Add(new RecordProduct()
                {
                    Identifier = new List <Identifier>()
                    {
                        new Identifier()
                        {
                            Name = "Weed Killer 3000", Number = "00057", Agency = AgencyTypes.AssignedByOriginator
                        }
                    },
                    IsCarrier     = false,
                    PhysicalState = PhysicalStates.Liquid,
                    Density       = new ValueUnit()
                    {
                        Value = 8.34, Uom = "GE", Agency = AgencyTypes.UN_REC_20
                    },
                    RequestedQuantity = new ValueUnit()
                    {
                        Value = 50, Uom = "GLL", Agency = AgencyTypes.UN_REC_20
                    },
                    ActualQuantity = new ValueUnit()
                    {
                        Value = 50, Uom = "GLL", Agency = AgencyTypes.UN_REC_20
                    },
                });
            }

            return(workRecord);
        }
 public SampleButtonViewModel(string caption, Type viewType, SampleTypes sampleType)
     : base(new RelayCommand(async () => await AppShell.Frame.NavigateAsync(typeof(TestPage), caption)), null, caption)
 {
     this.SampleType = sampleType;
     this.ViewType = viewType;
 }
 public SampleButtonViewModel(string caption, Type viewType, SampleTypes sampleType)
     : base(new RelayCommand(async() => await AppShell.Frame.NavigateAsync(typeof(TestPage), caption)), null, caption)
 {
     this.SampleType = sampleType;
     this.ViewType   = viewType;
 }