コード例 #1
0
ファイル: Scale.xaml.cs プロジェクト: tinman83/Weighr
        private async void AcknowledgeProductSelection(WeighrDAL.Models.Product product)
        {
            var dialog = new MessageDialog(product.Name + " : " + product.TargetWeight + " is the currently selected product");

            dialog.Commands.Clear();
            dialog.Commands.Add(new UICommand {
                Label = "Ok", Id = 0
            });
            var res = await dialog.ShowAsync();
        }
コード例 #2
0
ファイル: Scale.xaml.cs プロジェクト: tinman83/Weighr
        private void ProductsComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            _currentProduct = (WeighrDAL.Models.Product)ProductsComboBox.SelectedItem;

            ProductComponent productComp = new ProductComponent();

            _currentProduct = productComp.SetCurrentProduct(_currentProduct.ProductCode);
            productComp.SetCurrentProduct(_currentProduct.ProductCode);
            _normal_cutoff_weight  = (_currentProduct.TargetWeight) * Convert.ToDecimal(0.8);
            _final_setpoint_weight = _currentProduct.TargetWeight - Convert.ToDecimal(_currentProduct.Inflight);

            ProductNameTextBox.Text = _currentProduct.Name + " : " + _currentProduct.TargetWeight + " Kgs";
        }
コード例 #3
0
ファイル: Scale.xaml.cs プロジェクト: tinman83/Weighr
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            DeviceInfoComponent deviceInfoComp = new DeviceInfoComponent();

            _deviceInfo = deviceInfoComp.GetDeviceInfo();

            if (GetScaleSettings() == false)
            {
                NoSettingsMessage(); return;
            }
            if (GetScaleCalibration() == false)
            {
                NoCalibrationMessage(); return;
            }

            ProductComponent productComp = new ProductComponent();

            _ProductsList = productComp.GetProducts();
            ProductsComboBox.ItemsSource = _ProductsList;

            _currentProduct = productComp.GetCurrentProduct();

            //txtFlyoutMessage.Text = "Confirm. The currently selected product is " + _currentProduct.Name;
            if (_currentProduct != null)
            {
                ProductsComboBox.SelectedValue = _currentProduct.ProductCode;
                //_normal_cutoff_weight = (_currentProduct.TargetWeight) * Convert.ToDecimal(0.8);
                _normal_cutoff_weight = _currentProduct.DribblePoint;
                if (MainPage._inflight_setpoint == 0)
                {
                    _final_setpoint_weight = _currentProduct.TargetWeight - _scaleSetting.Inflight;
                }
                else
                {
                    _final_setpoint_weight = _currentProduct.TargetWeight - MainPage._inflight_setpoint;
                }



                tblWeigherStatus.Text = "Ready To Fill";
                AcknowledgeProductSelection(_currentProduct);

                ProductNameTextBox.Text = _currentProduct.Name + " : " + _currentProduct.TargetWeight + " Kgs";
                BatchNumberTextBox.Text = "Batch No:" + _currentBatch.BatchCode;

                timer          = new DispatcherTimer();
                timer.Interval = new TimeSpan(0, 0, 0, 0, 1); // Interval of the timer
                timer.Tick    += timer_Tick;
                timer.Start();
            }
            else
            {
                //Please configure product
                NoProductMessage();
            }

            BatchComponent batchComp = new BatchComponent();

            _currentBatch = batchComp.GetCurrentBatch();
            if (_currentBatch != null)
            {
                BatchNumberTextBox.Text = _currentBatch.BatchCode;
            }
        }
コード例 #4
0
ファイル: Scale.xaml.cs プロジェクト: tinman83/Weighr
        private void LoadProductByProductCode(string productCode)
        {
            ProductComponent productComp = new ProductComponent();

            _currentProduct = productComp.GetProduct(productCode);
        }
コード例 #5
0
        public void InitialiseTables()
        {
            /*** Initialise Calibration Settings***/
            ScaleConfigComponent ScaleConfigComp = new ScaleConfigComponent();

            var config = ScaleConfigComp.GetScaleConfig();

            ScaleConfig scaleCon = new ScaleConfig()
            {
                Gradient = -0.00000497M, Resolution = 200, YIntercept = -1.15M, offset = 0
            };

            if (config == null)
            {
                ScaleConfigComp.AddScaleConfig(scaleCon);
            }
            else
            {
                scaleCon.ScaleConfigId = 1;
                ScaleConfigComp.UpdateScaleConfig(scaleCon);
            }

            /*** Initialise Scale Settings***/
            ScaleSettingComponent ScaleSettigComp = new ScaleSettingComponent();
            var setting = ScaleSettigComp.GetScaleSetting();

            ScaleSetting scale_setting = new ScaleSetting()
            {
                DisplayUnits          = "Kgs",
                DecimalPointPrecision = 2,
                Density            = 1,
                DisplayUnitsWeight = 1,
                MaximumCapacity    = 100,
                MinimumDivision    = 0.5M,
                PrintMode          = false,
                ZeroRange          = 2,
                UpperLimit         = 2,
                LowerLimit         = 2,
                Inflight           = 0.3M
            };

            if (setting == null)
            {
                ScaleSettigComp.AddScaleSetting(scale_setting);
            }
            else
            {
                scale_setting.ScaleSettingId = 1;
                ScaleSettigComp.UpdateScaleSetting(scale_setting);
            }

            /*** Initialise Product***/
            ProductComponent productComp = new ProductComponent();
            var p = productComp.GetProducts();

            if (p.Count() == 0)
            {
                WeighrDAL.Models.Product productA = new WeighrDAL.Models.Product()
                {
                    ProductCode  = "PROA",
                    Name         = "Product A - 5Kg",
                    Density      = 1,
                    Inflight     = 0.3M,
                    isCurrent    = true,
                    LowerLimit   = 1,
                    UpperLimit   = 1,
                    TargetWeight = 5
                };

                WeighrDAL.Models.Product productB = new WeighrDAL.Models.Product()
                {
                    ProductCode  = "PROB",
                    Name         = "Product B - 20Kg",
                    Density      = 1,
                    Inflight     = 0.3M,
                    isCurrent    = false,
                    LowerLimit   = 2,
                    UpperLimit   = 2,
                    TargetWeight = 20
                };


                WeighrDAL.Models.Product productC = new WeighrDAL.Models.Product()
                {
                    ProductCode  = "PROC",
                    Name         = "Product C - 10Kg",
                    Density      = 0,
                    Inflight     = 0.3M,
                    isCurrent    = false,
                    LowerLimit   = 2,
                    UpperLimit   = 2,
                    TargetWeight = 10
                };

                productComp.AddProduct(productA);
                productComp.AddProduct(productB);
                productComp.AddProduct(productC);
            }
        }