Esempio n. 1
0
        private void DealWithBtnCmd(object obj)
        {
            int i = int.Parse(obj.ToString());
            CommandCmdDef.BtnCmd crtcmd = (CommandCmdDef.BtnCmd)i;
            switch (crtcmd)
            {
                case CommandCmdDef.BtnCmd.UI_UPDATE:
                    _UiData.SetUiVisible(CommandCmdDef.UiIndex.UI_UPDATE);
                    break;
                case CommandCmdDef.BtnCmd.UI_STCHECK:
                    EvoStCheck _EvoStCheck = new EvoStCheck(_MachineInfo);
                    _EvoStCheck.Unloaded += _EvoStCheck_Unloaded;
                    _EvoStCheck.Show();
                    if (!Tmr.IsEnabled)
                    {
                     Tmr.Start();   
                    }
                    
                    break;
                case CommandCmdDef.BtnCmd.UI_DB:
                    _EVOBaseConf = (EVOBaseConf)Function.XmlSerializer.LoadFromXml("EVO.base.xml", typeof(EVOBaseConf));
                    if (_EVOBaseConf == null)
                    {
                        _EVOBaseConf = new EVOBaseConf();
                    }
                    _UiData.SetUiVisible(CommandCmdDef.UiIndex.UI_DB);
                    break;
                case CommandCmdDef.BtnCmd.DB_GET:
                    DBItem dbtmp = _EVOBaseConf.Search(_crtDBItem.DBID);
                    if (dbtmp!=null)
                    {
                        _crtDBItem.DBvalue = dbtmp.DBvalue;
                        _crtDBItem.Description = dbtmp.Description;
                    }
                    break;
                case CommandCmdDef.BtnCmd.DB_SET:
                    _EVOBaseConf.Set(_crtDBItem);
                    Function.XmlSerializer.SaveToXml("EVO.base.xml", _EVOBaseConf, typeof(EVOBaseConf), null);
                    break;
                case CommandCmdDef.BtnCmd.ASSIT_FUN:
                    EVOToolWin  _EVOToolWin= new EVOToolWin();
                    _EVOToolWin.Show();
                    break;
                case CommandCmdDef.BtnCmd.UI_RECIPESYS:
                    _UiData.SetUiVisible(CommandCmdDef.UiIndex.UI_RECIPESYS);
                    break;
                case CommandCmdDef.BtnCmd.UI_MachineTest:
                    _UiData.SetUiVisible(CommandCmdDef.UiIndex.UI_MachineTest);
                    GetLstDeviceUnit();
                    break;
                case CommandCmdDef.BtnCmd.MAIN_SAVE:
                    Function.XmlSerializer.SaveToXml("EVO.conf.xml", _CrtEVOMachine, typeof(EVOMachine), null);
                    MessageBox.Show("Save OK!");
                    //InitDataModel();
                    break;
                case CommandCmdDef.BtnCmd.MAIN_BACK:
                    _UiData.SetUiVisible(CommandCmdDef.UiIndex.UI_MainSelect);
                    break;
                case CommandCmdDef.BtnCmd.VALVE_ADD:
                    //MessageBox.Show(crtcmd.ToString());
                    _CrtEVOMachine._WaterValve.Add(_CrtWaterValve.copy());
                    break;
                case CommandCmdDef.BtnCmd.VALVE_DEL:
                    foreach (var item in _CrtEVOMachine._WaterValve)
                    {
                        if (item.IsSelected)
                        {

                            _CrtEVOMachine._WaterValve.Remove(item);
                            break;
                        }
                    }
                    break;
                case CommandCmdDef.BtnCmd.VALVE_SAVE:
                    foreach (var item in _CrtEVOMachine._WaterValve)
                    {
                        if (item.IsSelected)
                        {
                            item.Name = _CrtWaterValve.Name;
                            item.DeviceIoAdress = _CrtWaterValve.DeviceIoAdress;
                            item.Flow = _CrtWaterValve.Flow;
                            item.DeviceID = _CrtWaterValve.DeviceID;
                            break;
                        }
                    }
                    break;
                case CommandCmdDef.BtnCmd.MIXSER_ADD:
                    _CrtEVOMachine._MixerUnit.Add(_CrtMixerUnit.copy());
                    break;
                case CommandCmdDef.BtnCmd.MIXSER_DEL:
                    foreach (var item in _CrtEVOMachine._MixerUnit)
                    {
                        if (item.IsSelected)
                        {

                            _CrtEVOMachine._MixerUnit.Remove(item);
                            break;
                        }
                    }
                    break;
                case CommandCmdDef.BtnCmd.MIXSER_SAVE:
                    foreach (var item in _CrtEVOMachine._MixerUnit)
                    {
                        if (item.IsSelected)
                        {
                            item.Name = _CrtMixerUnit.Name;
                            item.DeviceIoAdress = _CrtMixerUnit.DeviceIoAdress;
                            item.DeviceID = _CrtMixerUnit.DeviceID;
                            item.Speed = _CrtMixerUnit.Speed;
                            break;
                        }
                    }
                    break;
                case CommandCmdDef.BtnCmd.CANISTER_ADD:
                    _CrtEVOMachine._CanisterUnit.Add(_CrtCanisterUnit);
                    break;
                case CommandCmdDef.BtnCmd.CANISTER_DEL:
                    foreach (var item in _CrtEVOMachine._CanisterUnit)
                    {
                        if (item.IsSelected)
                        {

                            _CrtEVOMachine._CanisterUnit.Remove(item);
                            break;
                        }
                    }
                    break;
                case CommandCmdDef.BtnCmd.CANISTER_SAVE:
                    foreach (var item in _CrtEVOMachine._CanisterUnit)
                    {
                        if (item.IsSelected)
                        {
                            item.Name = _CrtCanisterUnit.Name;
                            item.DeviceIoAdress = _CrtCanisterUnit.DeviceIoAdress;
                            item.Flow = _CrtCanisterUnit.Flow;
                            item.DeviceID = _CrtCanisterUnit.DeviceID;
                            item.Postion = _CrtCanisterUnit.Postion;
                            item.Powdertype = _CrtCanisterUnit.Powdertype;
                            break;
                        }
                    }
                    break;

                case CommandCmdDef.BtnCmd.BEANHOPPER_ADD:
                    _CrtEVOMachine._BeanHopperUint.Add(_CrtBeanHopperUint);
                    break;
                case CommandCmdDef.BtnCmd.BEANHOPPER_DEL:
                    foreach (var item in _CrtEVOMachine._BeanHopperUint)
                    {
                        if (item.IsSelected)
                        {

                            _CrtEVOMachine._BeanHopperUint.Remove(item);
                            break;
                        }
                    }
                    break;
                case CommandCmdDef.BtnCmd.BEANHOPPER_SAVE:
                    foreach (var item in _CrtEVOMachine._BeanHopperUint)
                    {
                        if (item.IsSelected)
                        {
                            item.Name = _CrtBeanHopperUint.Name;
                            item.DeviceIoAdress = _CrtBeanHopperUint.DeviceIoAdress;
                            item.Flow = _CrtBeanHopperUint.Flow;
                            item.DeviceID = _CrtBeanHopperUint.DeviceID;
                            item.Powdertype=_CrtBeanHopperUint.Powdertype;
                            break;
                        }
                    }
                    break;
                case CommandCmdDef.BtnCmd.INGRED_SAVE:
                    foreach (var item in _EvoRecipe._lstIngredientInfo)
                    {
                        if (item.IsSelected)
                        {
                            item.Name = _CrtIngredient.Name;
                            item.ID = _CrtIngredient.ID;
                            item.Type = _CrtIngredient.Type;
                            item.CrtModifyStatus = CommandCmdDef.ModifyType.MODIFY;
                            UInt16 ustm =0;
                            switch (item.Type)
                            {
                                case IngredientType.ESPRESSO:
                                    item._Espresso.WaterVolume = _CrtIngredient._Espresso.WaterVolume;
                                    item._Espresso.Grind1Cnt =   _CrtIngredient._Espresso.Grind1Cnt;
                                    item._Espresso.Grind2Cnt =   _CrtIngredient._Espresso.Grind2Cnt;
                                    item._Espresso.Tm_Infusio =  _CrtIngredient._Espresso.Tm_Infusio;
                                    item._Espresso.Tm_Pause =    _CrtIngredient._Espresso.Tm_Pause;
                                    item._Espresso.Tm_Press =    _CrtIngredient._Espresso.Tm_Press;
                                    item._Espresso.Tm_DelayOpen =_CrtIngredient._Espresso.Tm_DelayOpen;
                                    ustm = _CrtIngredient._Espresso.UsedTime;
                                    
                                    break;
                                case IngredientType.FILTERBREW:
                                    item._FilterBrew.WaterVolume  = _CrtIngredient._FilterBrew.WaterVolume;
                                    item._FilterBrew.Grind1Type = _CrtIngredient._FilterBrew.Grind1Type;
                                    item._FilterBrew.Grind2Type = _CrtIngredient._FilterBrew.Grind2Type;
                                    item._FilterBrew.Grind1Cnt    = _CrtIngredient._FilterBrew.Grind1Cnt;
                                    item._FilterBrew.Grind2Cnt    = _CrtIngredient._FilterBrew.Grind2Cnt;
                                    item._FilterBrew.Tm_DelayOpen = _CrtIngredient._FilterBrew.Tm_DelayOpen;
                                    item._FilterBrew.Tm_Depress   = _CrtIngredient._FilterBrew.Tm_Depress;
                                    item._FilterBrew.Tm_Pre       = _CrtIngredient._FilterBrew.Tm_Pre;
                                    item._FilterBrew.Tm_Press     = _CrtIngredient._FilterBrew.Tm_Press;
                                    item._FilterBrew.ActionDownPostion = _CrtIngredient._FilterBrew.ActionDownPostion;
                                    item._FilterBrew.ActionUpPostion = _CrtIngredient._FilterBrew.ActionUpPostion;
                                    ustm = _CrtIngredient._FilterBrew.UsedTime;

                                    break;
                                case IngredientType.FRESHMILK:
                                    item._FreshMilk.HeaterFlag      = _CrtIngredient._FreshMilk.HeaterFlag;
                                    item._FreshMilk.MilkVolume      = _CrtIngredient._FreshMilk.MilkVolume;
                                    item._FreshMilk.Preflush = _CrtIngredient._FreshMilk.Preflush;
                                    item._FreshMilk.WhipperSpeed    = _CrtIngredient._FreshMilk.WhipperSpeed;
                                    item._FreshMilk.AfterFlush      = _CrtIngredient._FreshMilk.AfterFlush;
                                    ustm = _CrtIngredient._FreshMilk.UsedTime;

                                    break;
                                case IngredientType.INSTANTPOWDER:
                                    item._InstantPowder.MixIndex        = _CrtIngredient._InstantPowder.MixIndex;     
                                    item._InstantPowder.WhipperSpeed    = _CrtIngredient._InstantPowder.WhipperSpeed; 
                                    item._InstantPowder.WaterVolume     = _CrtIngredient._InstantPowder.WaterVolume;  
                                    item._InstantPowder.PackageOneType    = _CrtIngredient._InstantPowder.PackageOneType ;
                                    item._InstantPowder.PackageOneAmt    = _CrtIngredient._InstantPowder.PackageOneAmt; 
                                    item._InstantPowder.PackageTwoType    = _CrtIngredient._InstantPowder.PackageTwoType;
                                    item._InstantPowder.PackageTwoAmt    = _CrtIngredient._InstantPowder.PackageTwoAmt; 
                                    item._InstantPowder.PreFlush        = _CrtIngredient._InstantPowder.PreFlush;
                                    item._InstantPowder.AfterFlush      = _CrtIngredient._InstantPowder.AfterFlush;  
                                    ustm = _CrtIngredient._InstantPowder.UsedTime;
                                    item._InstantPowder.WaterType = _CrtIngredient._InstantPowder.WaterType;
 
                                    break;
                                case IngredientType.Water:
                                    item._Water.WaterType = _CrtIngredient._Water.WaterType;
                                    item._Water.WaterVolume = _CrtIngredient._Water.WaterVolume;
                                    ustm = _CrtIngredient._Water.UsedTime;
                                    break;
                                default:
                                    break;
                            }
                            foreach (var item1 in _EvoRecipe._lstRecipeInfo)
                            {
                                foreach (var itemret in item1._lstIngredientStep)
                                {
                                    if (itemret.ID == item.ID)
                                    {
                                        itemret.UsedTime = ustm;
                                    }
                                }
                            }
                            break;

                            /*更新菜单的used时间 
                             */ 
                            
                        }
                    }
                    
                    SaveIngredientData();
                    break;
                case CommandCmdDef.BtnCmd.INGRED_ADD:
                    /*
                     * 提示配方选择
                     * 选择配方,OK,新增一条配方
                     */
                    _IngredientSelecWin = new IngredientSelecWin();
                    _IngredientSelecWin.Show();
                    _IngredientSelecWin.Closed += _IngredientSelecWin_Closed;
                    break;
                case CommandCmdDef.BtnCmd.INGRED_DEL:
                    foreach (var item in _EvoRecipe._lstIngredientInfo)
                    {
                        if (item.IsSelected)
                        {
                            _IDControl.CGID(item.ID);
                            _EvoRecipe._lstIngredientInfo.Remove(item);
                            break;
                        }
                    }
                    SaveIngredientData();
                    break;


                case CommandCmdDef.BtnCmd.RCP_ADD:
                    RecipeInfo tmprcp = new RecipeInfo();
                    tmprcp.Name = "New Recipe";
                    tmprcp.ID = _IDControl.GetID(1);
                    tmprcp.CrtModifyStatus = CommandCmdDef.ModifyType.NEWONE;
                    _EvoRecipe._lstRecipeInfo.Add(tmprcp);
                    break;
                case CommandCmdDef.BtnCmd.RCP_DEL:
                    foreach (var item in _EvoRecipe._lstRecipeInfo)
                    {
                        if (item.IsSelected)
                        {
                            _IDControl.CGID(item.ID,1);
                            _EvoRecipe._lstRecipeInfo.Remove(item);
                            break;
                        }
                    }
                    SaveIngredientData();
                    break;
                case CommandCmdDef.BtnCmd.RCP_SAVE:
                    foreach (var item in _EvoRecipe._lstRecipeInfo)
                    {
                        if (item.IsSelected)
                        {
                            item.Name = _CrtRecipeInfo.Name;
                            item.ID = _CrtRecipeInfo.ID;
                            item.CrtModifyStatus = _CrtRecipeInfo.CrtModifyStatus;

                            item._publicInfo.CupSensor = _CrtRecipeInfo._publicInfo.CupSensor;
                            item._publicInfo.DispenseType = _CrtRecipeInfo._publicInfo.DispenseType;
                            item._publicInfo.LedColor = _CrtRecipeInfo._publicInfo.LedColor;
                            item._publicInfo.LedIntensity = _CrtRecipeInfo._publicInfo.LedIntensity;
                            item._publicInfo.Ledmode = _CrtRecipeInfo._publicInfo.Ledmode;
                            item._publicInfo.price = _CrtRecipeInfo._publicInfo.price;
                            item._publicInfo.setCups = _CrtRecipeInfo._publicInfo.setCups;
                            item._publicInfo.setMilk = _CrtRecipeInfo._publicInfo.setMilk;
                            item._publicInfo.setStrength = _CrtRecipeInfo._publicInfo.setStrength;
                            item._publicInfo.setSugar = _CrtRecipeInfo._publicInfo.setSugar;
                            item._publicInfo.setVolume = _CrtRecipeInfo._publicInfo.setVolume;
                            item._publicInfo.UseCount = _CrtRecipeInfo._publicInfo.UseCount;
                            item._lstIngredientStep.Clear();
                            foreach (var item1 in _CrtRecipeInfo._lstIngredientStep)
                            {
                                item._lstIngredientStep.Add(item1);
                            }
                        }
                    }
                    SaveIngredientData();
                    break;


                case CommandCmdDef.BtnCmd.RCP_INGRED_ADD:
                    EVO tmp = new EVO();
                    tmp.InitEVO(_EvoRecipe._lstIngredientInfo);
                    tmp.myclick += tmp_myclick;
                    tmp.Show();
                    break;
                case CommandCmdDef.BtnCmd.RCP_INGRED_DEL:
                    foreach (var item in _CrtRecipeInfo._lstIngredientStep)
                    {
                        if (item.IsSelected)
                        {
                            _CrtRecipeInfo._lstIngredientStep.Remove(item);
                            break;
                        }
                    }
                    SaveIngredientData();
                    break;
                case CommandCmdDef.BtnCmd.RCP_INGRED_SAVE:
                   foreach (var item in _EvoRecipe._lstRecipeInfo)
                    {
                        if (item.IsSelected)
                        {
                            item.Name = _CrtRecipeInfo.Name;
                            item.ID = _CrtRecipeInfo.ID;
                            item.CrtModifyStatus = _CrtRecipeInfo.CrtModifyStatus;
                            item._publicInfo.CupSensor = _CrtRecipeInfo._publicInfo.CupSensor;
                            item._publicInfo.DispenseType = _CrtRecipeInfo._publicInfo.DispenseType;
                            item._publicInfo.LedColor = _CrtRecipeInfo._publicInfo.LedColor;
                            item._publicInfo.LedIntensity = _CrtRecipeInfo._publicInfo.LedIntensity;
                            item._publicInfo.Ledmode = _CrtRecipeInfo._publicInfo.Ledmode;
                            item._publicInfo.price = _CrtRecipeInfo._publicInfo.price;
                            item._publicInfo.setCups = _CrtRecipeInfo._publicInfo.setCups;
                            item._publicInfo.setMilk = _CrtRecipeInfo._publicInfo.setMilk;
                            item._publicInfo.setStrength = _CrtRecipeInfo._publicInfo.setStrength;
                            item._publicInfo.setSugar = _CrtRecipeInfo._publicInfo.setSugar;
                            item._publicInfo.setVolume = _CrtRecipeInfo._publicInfo.setVolume;
                            item._publicInfo.UseCount = _CrtRecipeInfo._publicInfo.UseCount;
                            item._lstIngredientStep.Clear();
                            foreach (var item1 in _CrtRecipeInfo._lstIngredientStep)
                            {
                                item._lstIngredientStep.Add(item1);
                            }
                        }
                    }
                    SaveIngredientData();
                    break;
                    /*
                     * 
                     * 
                     * 
                     * 
                     * 
                     * 
                     */
                case CommandCmdDef.BtnCmd.UI_MainSelect:
                    _UiData.SetUiVisible(CommandCmdDef.UiIndex.UI_MainSelect);
                    break;
                case CommandCmdDef.BtnCmd.UI_MachineSet:
                    _UiData.SetUiVisible(CommandCmdDef.UiIndex.UI_MachineSet);
                    break;
                case CommandCmdDef.BtnCmd.UI_CLEANSYS:
                    //MessageBox.Show("This Function is not Complete");
                    

                    //TODO:获取清洁的菜单选项
                    _UiData.SetUiVisible(CommandCmdDef.UiIndex.UI_CLEANSYS);
                    break;
                default:
                    break;
            }
        }
Esempio n. 2
0
 private void InitClass()
 {
     _UiData = new UiData();
     _CrtEVOMachine = new EVOMachine(true);
     _CrtWaterValve = new WaterValve();
     _CrtMixerUnit = new MixerUnit();
     _CrtCanisterUnit = new CanisterUnit();
     _CrtDeviceUnit = new DeviceUnit();
     _CrtBeanHopperUint = new BeanHopperUint();
     _CrtIngredient = new IngredientInfo(true);
     _CrtRecipeInfo = new RecipeInfo();
     _LstEVOMachine = new ObservableCollection<EVOMachine>();
     _LstDeviceUnit = new ObservableCollection<DeviceUnit>();
     _lstMaintenceInfo = new ObservableCollection<EvoMaintenceInfo>();
     _EvoRecipe = new EvoRecipe();
     _IDControl = new IDGenrator();
     _crtDBItem = new DBItem();
     _EvoUpdate = new EvoUpdate();
     _MachineInfo = new MachineInfo();
     _CrtEVOCleaning = new EVOCleaning();
     Tmr.Interval = TimeSpan.FromSeconds(5);
     Tmr.Tick += Tmr_Tick;
     _ComSetting = (ComSetting)Function.XmlSerializer.LoadFromXml("EVO.com.xml", typeof(ComSetting));
     comunication.Getinstance().SetComPort(_ComSetting.Port, _ComSetting.BaudRate);
     int ret = comunication.Getinstance().Open();
     comunication.EVOEvent += comunication_EVOEvent;
 }
Esempio n. 3
0
        private void InitpreUi(RecipeInfo a)
        {
            _preVolume = 0x80;
            _preStrength = 0x80;
            _preMilk = 0x80;
            _preSugar = 0x80;
            grd_fun.Children.Clear();
            grd_fun.RowDefinitions.Clear();
            EvoPreselection tmp;
            tb_cups.Text = _cupcnt.ToString();
            int grdrowindex = 0;
            if (a._publicInfo.setCups == 1)
            {
                grd_cup.Visibility = System.Windows.Visibility.Visible;

            }
            else
            {
                grd_cup.Visibility = System.Windows.Visibility.Hidden;

            }
            if (a._publicInfo.setVolume ==1)
            {
                grd_fun.RowDefinitions.Add(new RowDefinition());
                tmp = new EvoPreselection();
                tmp.SetValue(Grid.RowProperty, grdrowindex);
                tmp.Margin = new Thickness(0, 5, 0, 5);
                tmp.Text = "Volume.";
                tmp.ValueChanged += tmp_ValueChanged;

                grd_fun.Children.Add(tmp);
                grdrowindex++;
            }
            if (a._publicInfo.setStrength == 1)
            {
                grd_fun.RowDefinitions.Add(new RowDefinition());
                tmp = new EvoPreselection();
                tmp.SetValue(Grid.RowProperty, grdrowindex);
                tmp.Margin = new Thickness(0, 5,0,5);
                tmp.Text = "Strength.";
                tmp.ValueChanged += tmp_ValueChanged;
                grd_fun.Children.Add(tmp);
                grdrowindex++;
            }
            if (a._publicInfo.setMilk == 1)
            {
                grd_fun.RowDefinitions.Add(new RowDefinition());
                tmp = new EvoPreselection();
                tmp.SetValue(Grid.RowProperty, grdrowindex);
                tmp.Margin = new Thickness(0, 5, 0, 5);
                tmp.Text = "Milk.";
                tmp.ValueChanged += tmp_ValueChanged;

                grd_fun.Children.Add(tmp);
                grdrowindex++;
            }
            if (a._publicInfo.setSugar == 1)
            {
                grd_fun.RowDefinitions.Add(new RowDefinition());
                tmp = new EvoPreselection();
                tmp.SetValue(Grid.RowProperty, grdrowindex);
                tmp.Margin = new Thickness(0, 5, 0, 5);
                tmp.Text = "Sugar.";
                tmp.ValueChanged += tmp_ValueChanged;

                grd_fun.Children.Add(tmp);
                grdrowindex++;
            }
        }