Beispiel #1
0
        private void DecodeMsg(object indat)
        {
            lock (m_lock)
            {
                CurrentCnt++;
                eventWait.Set();
                byte[]  tmp     = (byte[])indat;
                EVOData evodata = new EVOData();
                evodata.datainLen = (UInt16)((tmp[2] << 8) + tmp[3]);
                evodata.datainno  = tmp[4];
                evodata.datain    = new byte[evodata.datainLen - 2];
                evodata._cmdType  = (CmdType)tmp[5];
                evodata.CheckSum  = tmp[tmp.Length - 1];
                Array.Copy(tmp, 5, evodata.datain, 0, evodata.datain.Length);
                //TODO:过滤无效的数据包
                if (GetCheckSum(evodata.datain, evodata.datain.Length, evodata.datainno, evodata.CheckSum))
                {
                    if (EVOEvent != null)
                    {
                        EVOEvent(this, evodata);
                    }
                }

                //Console.WriteLine(tmp.Length);
            }
        }
 void comunication_EVOEvent(object sender, EVOData e)
 {
     if (e._cmdType == CmdType.B2M_CMD_DB_SET)
     {
         B2MDbSetting dbset = new B2MDbSetting(e.datain, 0);
         if (dbset.Result == 1)
         {
             MessageBox.Show("Calibration finished!");
         }
         else
         {
             MessageBox.Show("Calibration Failed!");
         }
     }
     if (e._cmdType == CmdType.B2M_CMD_CAL)
     {
         B2MCalibration dbcal = new B2MCalibration(e.datain, 0);
         if (dbcal.Result == 1)
         {
             if (dbcal.calPartNo <=0x8d )
             {
                 System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                 {
                     _crtpbValue = 0;
                     this.grd_Process.Visibility = System.Windows.Visibility.Visible;
                     Tmrpb.Start();
                 }));
             }
         }
     }
 }
Beispiel #3
0
        private void comunication_EVOEvent(object sender, EVOData e)
        {
            Console.WriteLine(e._cmdType.ToString());
            switch (e._cmdType)
            {
                case CmdType.B2M_CMD_CAL:
                    break;
                case CmdType.B2M_CMD_CLEAN:
                    break;
                case CmdType.B2M_CMD_DB_SET:
                    break;
                case CmdType.B2M_CMD_MAINTENCE:
                    break;
                case CmdType.B2M_CMD_MAKE_BERVAGE:
                    break;
                case CmdType.B2M_CMD_MAKE_DRINK:
                    B2MMakeDrink cmd = new B2MMakeDrink(e.datain, 0);
                if (cmd.Result ==1 )
                {
                    System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() => { grd_process.Visibility = System.Windows.Visibility.Visible; }));

                }
                    break;
                case CmdType.B2M_CMD_MAKE_INGREDIENT:
                    break;
                case CmdType.B2M_CMD_MATCH:
                    break;
                case CmdType.B2M_CMD_MODE_REQUEST:
                    break;
                case CmdType.B2M_CMD_QUERY:
                    break;
                case CmdType.B2M_CMD_TEST:
                    break;
                case CmdType.M2B_CMD_CAL:
                    break;
                case CmdType.M2B_CMD_CLEAN:
                    break;
                case CmdType.M2B_CMD_DB_SET:
                    break;
                case CmdType.M2B_CMD_MAINTENCE:
                    break;
                case CmdType.M2B_CMD_MAKE_BERVAGE:
                    break;
                case CmdType.M2B_CMD_MAKE_DRINK:
                    break;
                case CmdType.M2B_CMD_MAKE_INGREDIENT:
                    break;
                case CmdType.M2B_CMD_MATCH:
                    break;
                case CmdType.M2B_CMD_MODE_REQUEST:
                    break;
                case CmdType.M2B_CMD_QUERY:
                    break;
                case CmdType.M2B_CMD_TEST:
                    break;
                default:
                    break;
            }
            
        }
Beispiel #4
0
 private void DecodeMsg(object indat)
 {
     lock (m_lock)
     {
         CurrentCnt++;
         eventWait.Set();
         byte[] tmp = (byte[])indat;
         EVOData evodata = new EVOData();
         evodata.datainLen = tmp[2];
         evodata.datainno = tmp[3];
         evodata.datain = new byte[evodata.datainLen-2];
         evodata._cmdType = (CmdType)tmp[4];
         evodata.CheckSum =tmp[tmp.Length-1];
         Array.Copy(tmp, 4, evodata.datain, 0, evodata.datain.Length);
         //TODO:过滤无效的数据包
         if (GetCheckSum(evodata.datain, evodata.datain.Length, evodata.datainno,evodata.CheckSum))
         {
             if (EVOEvent != null)
             {
                 EVOEvent(this, evodata);
             }
         }
         
         //Console.WriteLine(tmp.Length);
     }
 }
Beispiel #5
0
        void comunication_EVOEvent(object sender, EVOData e)
        {
            switch (e._cmdType)
            {
                case CmdType.B2M_CMD_MAINTENCE:
                    B2MMaintenance maintencedata = new B2MMaintenance(e.datain, 0);
                    System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() => { _lstMaintenceInfo.Clear(); }));
                    if (maintencedata.Result == 1)//数据有效
                    {
                        Maintence_T tmp;
                        foreach (var item in maintencedata._table)
                        {
                            tmp = new Maintence_T(item.id, (UInt32)item.value);
                            System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() => { _lstMaintenceInfo.Add(new EvoMaintenceInfo(tmp.ToDescription(), tmp.ToValue())); }));
                        }

                    }
                    //TODO:chu li shuju 
                    break;
                case CmdType.B2M_CMD_CLEAN:
                    break;
                case CmdType.B2M_CMD_MAKE_BERVAGE:
                    B2MMakeBeverage makebeverage = new B2MMakeBeverage(e.datain, 0);
                    Console.WriteLine("ID="+makebeverage.ID);
                    Console.WriteLine("operatetype=" + makebeverage.operatetype);
                    Console.WriteLine("Result=" + makebeverage.Result);
                    if (makebeverage.Result == 1)
                    {
                        MessageBox.Show("MAKE_BERVAGE Successed!");
                    }
                    else
                    {
                        MessageBox.Show("MAKE_BERVAGE Failed!");
                    }
                    break;
                case CmdType.B2M_CMD_MAKE_DRINK:
                    break;
                case CmdType.B2M_CMD_MAKE_INGREDIENT:
                    B2MMakeIngredient makeingredient = new B2MMakeIngredient(e.datain, 0);
                    Console.WriteLine("ID=" + makeingredient.ID);
                    Console.WriteLine("operatetype=" + makeingredient.operatetype);
                    Console.WriteLine("Result=" + makeingredient.Result);
                    if (makeingredient.Result == 1)
                    {
                        MessageBox.Show("MAKE_INGREDIENT Successed!");
                    }
                    else
                    {
                        MessageBox.Show("MAKE_INGREDIENT Failed!");

                    }
                    break;
                case CmdType.B2M_CMD_MATCH:
                    break;
                case CmdType.B2M_CMD_MODE_REQUEST:
                    break;
                case CmdType.B2M_CMD_QUERY:
                    //TODO:状态查询数据包
                    B2MStateQuery evost = new B2MStateQuery(e.datain, 0);
                    _MachineInfo.Err_clean = evost.modulestate.IsCleanErr;
                    _MachineInfo.Err_cooling = evost.modulestate.IsCoolingErr;
                    _MachineInfo.Err_heating = evost.modulestate.IsHeatingErr;
                    _MachineInfo.Err_soldout = evost.modulestate.IsSoldoutErr;
                    _MachineInfo.Err_water = evost.modulestate.IsWaterErr;
                    _MachineInfo.Exist_cup1 = evost.sensorstate.cup1;
                    _MachineInfo.Exist_cup2 = evost.sensorstate.cup2;
                    _MachineInfo.Exist_door = evost.sensorstate.door;
                    _MachineInfo.Exist_driplevel = evost.sensorstate.driptraylevel;
                    _MachineInfo.Exist_dripswitch = evost.sensorstate.driptrayswitch;
                    _MachineInfo.machinestate = evost.machinestate;
                    _MachineInfo.Temp_fan = evost.temperatureinfo.Fan;
                    _MachineInfo.Temp_fridge = evost.temperatureinfo.Fridge;
                    _MachineInfo.Temp_water = evost.temperatureinfo.Water;
                    break;
                case CmdType.B2M_CMD_TEST:
                    B2MTest test = new B2MTest(e.datain, 0);
                    Console.WriteLine("TEST ID ="+test.ID);
                    Console.WriteLine("TEST Type =" + test.operatetype);
                    Console.WriteLine("TEST Result =" + test.Result);
                    if (test.Result == 1)
                    {
                        MessageBox.Show("TEST Successed!");
                    }
                    else
                    {
                        MessageBox.Show("TEST Failed!");

                    }
                    break;
             /*   
              * case CmdType.M2B_CMD_CLEAN:
                    break;
                case CmdType.M2B_CMD_MAKE_BERVAGE:
                    break;
                case CmdType.M2B_CMD_MAKE_DRINK:
                    break;
                case CmdType.M2B_CMD_MAKE_INGREDIENT:
                    break;
                case CmdType.M2B_CMD_MATCH:
                    break;
                case CmdType.M2B_CMD_MODE_REQUEST:
                    break;
                case CmdType.M2B_CMD_QUERY:
                    break;
                case CmdType.M2B_CMD_TEST:
                    break;
              * 
              */
                default:
                    break;
            }
        }