Beispiel #1
0
        private void edit_Click(object sender, RoutedEventArgs e)
        {
            var tray11_code = this.tray11_code.Text.Trim();
            var tray12_code = this.tray12_code.Text.Trim();
            var tray13_code = this.tray13_code.Text.Trim();
            var tray21_code = this.tray21_code.Text.Trim();
            var tray22_code = this.tray22_code.Text.Trim();
            var tray23_code = this.tray23_code.Text.Trim();

            var jaw_traycode   = this.jaw_traycode.Text.Trim();
            var still_timespan = this.still_timespan.Text.Trim();

            var product_model = this.product_model.Text.Trim();

            tip.Background = new SolidColorBrush(Colors.Red);

            try
            {
                var tray11_id = GetObject.GetByCode <ProcTray>(tray11_code).Id;
                if (tray11_id != Current.Option.Tray11_Id && tray11_id > 0)
                {
                    var result = Current.MainMachine.Commor.Write("D434", (ushort)1);
                    if (!result.IsSucceed)
                    {
                        Running.ShowErrorMsg("手动输入绑盘托盘条码后发送给PLC结果失败,msg:" + result.Msg);
                    }
                }

                Current.Option.Tray11_Id = tray11_id;
                Current.Option.Tray12_Id = GetObject.GetByCode <ProcTray>(tray12_code).Id;
                Current.Option.Tray13_Id = GetObject.GetByCode <ProcTray>(tray13_code).Id;
                Current.Option.Tray21_Id = GetObject.GetByCode <ProcTray>(tray21_code).Id;
                Current.Option.Tray22_Id = GetObject.GetByCode <ProcTray>(tray22_code).Id;
                Current.Option.Tray23_Id = GetObject.GetByCode <ProcTray>(tray23_code).Id;

                Current.Option.JawProcTrayId    = GetObject.GetByCode <ProcTray>(jaw_traycode).Id;
                Current.Option.StillTimeSpan    = Convert.ToInt32(still_timespan);
                Current.Option.TaskPriorityType = GetTaskPriorityType();

                Current.Option.ProductModel = product_model;

                tip.Background = new SolidColorBrush(Colors.Green);
                tip.Text       = "修改信息成功!";
            }
            catch (Exception ex)
            {
                tip.Text = "修改信息失败:" + ex.Message;
            }

            tip.Visibility = Visibility.Visible;
        }
Beispiel #2
0
        private void edit_Click(object sender, RoutedEventArgs e)
        {
            var name      = this.name.Text.Trim();
            var company   = this.company.Text.Trim();
            var traycode  = this.tray_code.Text.Trim();
            var isEnabled = this.isEnabled.IsChecked;

            tip.Background = new SolidColorBrush(Colors.Red);

            if (string.IsNullOrWhiteSpace(name))
            {
                tip.Text = "请填写数据!";
            }
            else
            {
                try
                {
                    this.Storage.Name    = name;
                    this.Storage.Company = company;
                    //确保每层设置一次,且不出现死循环
                    Current.Storages.FirstOrDefault(o => o.Column == Storage.Column && o.Floor == Common.STOR_FLOOR_COUNT).IsEnabled = isEnabled.Value;

                    var procTrayId = GetObject.GetByCode <ProcTray>(traycode).Id;

                    if (procTrayId < 1 && !string.IsNullOrEmpty(traycode))
                    {
                        throw new Exception("系统中不存在托盘:" + traycode);
                    }

                    this.Storage.ProcTrayId = procTrayId;
                    if (procTrayId > 0)
                    {
                        this.Storage.ProcTray.StorageId = this.Storage.Id;
                    }

                    tip.Background = new SolidColorBrush(Colors.Green);
                    tip.Text       = "修改信息成功!";
                }
                catch (Exception ex)
                {
                    tip.Text = "修改信息失败:" + ex.Message;
                }
            }
            tip.Visibility = Visibility.Visible;
        }
 private void Battery_code_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         var code = (sender as TextBox).Text.Trim();
         if (!string.IsNullOrEmpty(code))
         {
             var battery = GetObject.GetByCode <Battery>(code);
             if (battery.Id > 0)
             {
                 this.sortResult          = battery.SortResult;
                 this.sort_result.Content = this.sortResult;
                 packId = battery.PackId;
                 var pack = GetObject.GetById <Pack>(packId);
                 if (pack.Id > 0)
                 {
                     this.pack_code.Content          = pack.Code;
                     this.pack_battery_count.Content = PackManage.GetPackCount(packId);
                     tip.Visibility            = Visibility.Collapsed;
                     this.btnConfirm.IsEnabled = true;
                 }
                 else
                 {
                     tip.Background = new SolidColorBrush(Colors.Red);
                     tip.Text       = "该电池尚未绑定箱体!";
                     tip.Visibility = Visibility.Visible;
                 }
             }
             else
             {
                 tip.Background = new SolidColorBrush(Colors.Red);
                 tip.Text       = "系统中不存在该电池!";
                 tip.Visibility = Visibility.Visible;
             }
         }
     }
     else
     {
         tip.Visibility = Visibility.Collapsed;
     }
 }
Beispiel #4
0
        public void Comm()
        {
            if (Arthur.App.Current.Option.RemainingMinutes <= 0)
            {
                return;
            }

            if (!Current.MainMachine.IsAlive)
            {
                return;
            }

            if (this == Current.BindTrayScaner && Current.Option.IsBindTrayScanReady && !Current.Option.IsAlreadyBindTrayScan)
            {
                LogHelper.WriteInfo("开始绑盘托盘扫码。。。");
                var ret = this.Commor.Comm(this.ScanCommand, this.ReadTimeout);
                if (ret.IsSucceed)
                {
                    var result = true;
                    var code   = ret.Data.ToString();
                    if (code.StartsWith("NR"))
                    {
                        var ret2 = this.Commor.Comm(this.ScanCommand, this.ReadTimeout);
                        if (ret2.IsSucceed && !ret2.Data.ToString().StartsWith("NR"))
                        {
                            code = ret2.Data.ToString();
                        }
                        else
                        {
                            result = false;
                            LogHelper.WriteError(this.Name + " 扫码失败!");
                            Running.ShowErrorMsg(this.Name + " 扫码失败!");
                        }
                    }

                    if (result)
                    {
                        LogHelper.WriteInfo(this.Name + "扫码OK。。。");
                        this.RealtimeStatus = "+" + code;
                        Current.MainMachine.Commor.Write("D434", (ushort)1);

                        var saveRet = Result.Success;
                        if (Current.Option.Tray11_Id < 1)
                        {
                            //把电池条码保存进数据库
                            saveRet = new Business.ProcTrayManage().Create(new Model.ProcTray()
                            {
                                Code = code
                            }, true);
                            Current.Option.Tray11_Id = (int)saveRet.Data;
                        }

                        if (saveRet.IsSucceed)
                        {
                            var t = new Thread(() =>
                            {
                                //界面交替显示扫码状态
                                Thread.Sleep(2000);
                                this.RealtimeStatus = "等待扫码...";
                            });
                            t.Start();
                        }
                        else
                        {
                            Running.StopRunAndShowMsg(saveRet.Msg);
                        }
                    }
                    else
                    {
                        LogHelper.WriteInfo(this.Name + "扫码NG。。。");
                        Current.MainMachine.Commor.Write("D434", (ushort)2);
                        this.RealtimeStatus = "扫码失败!";
                    }
                    this.IsAlive = true;
                }
                else
                {
                    LogHelper.WriteInfo(this.Name + "扫码NG。。。");

                    Current.MainMachine.Commor.Write("D434", (ushort)2);
                    this.RealtimeStatus = ret.Msg;
                    this.IsAlive        = false;
                }
                Current.Option.IsAlreadyBindTrayScan = true;
            }
            else if (this == Current.UnbindTrayScaner && Current.Option.IsUnbindTrayScanReady && !Current.Option.IsAlreadyUnbindTrayScan)
            {
                LogHelper.WriteInfo("开始解盘托盘扫码。。。");
                var ret = this.Commor.Comm(this.ScanCommand, this.ReadTimeout);
                if (ret.IsSucceed)
                {
                    var result = true;
                    var code   = ret.Data.ToString();
                    if (code.StartsWith("NR"))
                    {
                        var ret2 = this.Commor.Comm(this.ScanCommand, this.ReadTimeout);
                        if (ret2.IsSucceed && !ret2.Data.ToString().StartsWith("NR"))
                        {
                            code = ret2.Data.ToString();
                        }
                        else
                        {
                            result = false;
                            LogHelper.WriteError(this.Name + " 扫码失败!");
                            Running.ShowErrorMsg(this.Name + " 扫码失败!");
                        }
                    }

                    if (result)
                    {
                        LogHelper.WriteInfo(this.Name + "扫码OK。。。");
                        this.RealtimeStatus = "+" + code;
                        Current.MainMachine.Commor.Write("D435", (ushort)1);


                        var saveRet = Result.Success;

                        //逻辑处理
                        var procTrayId = GetObject.GetByCode <ProcTray>(code).Id;
                        if (Current.Option.Tray21_Id < 1 || Current.Option.Tray21_Id != procTrayId)
                        {
                            Current.Option.Tray21_Id = procTrayId;
                        }

                        if (saveRet.IsSucceed)
                        {
                            var t = new Thread(() =>
                            {
                                //界面交替显示扫码状态
                                Thread.Sleep(2000);
                                this.RealtimeStatus = "等待扫码...";
                            });
                            t.Start();
                        }
                        else
                        {
                            Running.StopRunAndShowMsg(saveRet.Msg);
                        }
                    }
                    else
                    {
                        LogHelper.WriteInfo(this.Name + "扫码NG。。。");
                        Current.MainMachine.Commor.Write("D435", (ushort)(Common.PROJ_NO == "0079" ? 2 : 1));
                        this.RealtimeStatus = "扫码失败!";
                    }
                    this.IsAlive = true;
                }
                else
                {
                    LogHelper.WriteInfo(this.Name + "扫码NG。。。");
                    Current.MainMachine.Commor.Write("D435", (ushort)(Common.PROJ_NO == "0079" ? 2 : 1));
                    this.RealtimeStatus = ret.Msg;
                    this.IsAlive        = false;
                }
                Current.Option.IsAlreadyUnbindTrayScan = true;
            }
        }