コード例 #1
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            DeviceInfoComponent deviceInfoComp = new DeviceInfoComponent();

            _deviceInfo = deviceInfoComp.GetDeviceInfo();

            if (_deviceInfo != null)
            {
                PlantNameTextBox.Text   = _deviceInfo.PlantId;
                MachineNameTextBox.Text = _deviceInfo.MachineName;
            }

            ScaleSettingComponent scaleSettingComp = new ScaleSettingComponent();

            _scaleSetting = scaleSettingComp.GetScaleSettingDefault();

            if (_scaleSetting != null)
            {
                DisplayUnitsComboBox.SelectedIndex = GetUnitIndex(_scaleSetting.DisplayUnits);

                PrecisionTextBox.Text       = _scaleSetting.MinimumDivision.ToString();
                InflightTextBox.Text        = _scaleSetting.Inflight.ToString();
                InflightTimingTextBox.Text  = _scaleSetting.InflightTiming.ToString();
                MaximumCapacityTextBox.Text = _scaleSetting.MaximumCapacity.ToString();
            }
            else
            {
                _scaleSetting = new ScaleSetting();
            }
        }
コード例 #2
0
 public void UpdateScaleSetting(ScaleSetting scaleSetting)
 {
     using (var db = new WeighrContext())
     {
         db.ScaleSettings.Update(scaleSetting);
         db.SaveChanges();
     }
 }
コード例 #3
0
 public void AddScaleSetting(ScaleSetting scaleSetting)
 {
     using (var db = new WeighrContext())
     {
         db.ScaleSettings.Add(scaleSetting);
         db.SaveChanges();
     }
 }
コード例 #4
0
ファイル: Scale.xaml.cs プロジェクト: tinman83/Weighr
        public Boolean GetScaleSettings()
        {
            ScaleSettingComponent ScaleSettingComp = new ScaleSettingComponent();

            _scaleSetting = ScaleSettingComp.GetScaleSetting();

            if (_scaleSetting != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #5
0
 public SettingScaleControl Setup()
 {
     this.ReadLanguageResources();
     this.cbxVendor.SelectedItem = SensorMgr.Instance.Scale.Vendor;
     this.txtPrint.Text          = Machine.Instance.Scale.Scalable.PrintCmd;
     this.txtTare.Text           = Machine.Instance.Scale.Scalable.TareCmd;
     this.txtZero.Text           = Machine.Instance.Scale.Scalable.ZeroCmd;
     this.ckbDTR.Checked         = SensorMgr.Instance.Scale.EasySerialPort.DTR;
     this.ckbRTS.Checked         = SensorMgr.Instance.Scale.EasySerialPort.RTS;
     if (SensorMgr.Instance.Scale != null)
     {
         this.settingBackUp = (ScaleSetting)SensorMgr.Instance.Scale.Clone();
     }
     return(this);
 }
コード例 #6
0
        public Scale LoadSetting(ScaleSetting scaleSetting)
        {
            switch (scaleSetting.Vendor)
            {
            case Vendor.Sartorius:
                this.Scalable = new ScalableSartorius(scaleSetting.EasySerialPort);
                break;

            case Vendor.Mettler:
                this.Scalable = new ScalableMettler(scaleSetting.EasySerialPort);
                break;

            case Vendor.Disable:
                this.Scalable = new ScalebleDisable(scaleSetting.EasySerialPort);
                break;
            }
            return(this);
        }
コード例 #7
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);
            }
        }