コード例 #1
0
        override public void Update(CProgramm mainPrg)
        {
            base.Update(mainPrg);
            MessageInfo mInfo = new MessageInfo(this, 416, MessageTyp.Info, "Update WMFCmd");

            mInfo.xml      = node.OuterXml;
            mInfo.mType    = MessageTyp.Message;
            mInfo.sCommand = this.ToString();
            MessageHandler.Message(mInfo);

            if (coffeeMaschine == null)
            {
                coffeeMaschine = new CWMFCoffeeMaschine();
            }

            try {
                XmlElement xPar;
                mainPrg.SatzNum++;


                xPar = (XmlElement)node.SelectSingleNode("Par[@name='r']");
                if (xPar != null)
                {
                    r = byte.Parse(xPar.InnerText, nfi);
                    xPar.SetAttribute("typ", CommandType.Decimal.ToString());
                }
                xPar = (XmlElement)node.SelectSingleNode("Par[@name='g']");
                if (xPar != null)
                {
                    g = byte.Parse(xPar.InnerText, nfi);
                    xPar.SetAttribute("typ", CommandType.Decimal.ToString());
                }
                xPar = (XmlElement)node.SelectSingleNode("Par[@name='b']");
                if (xPar != null)
                {
                    b = byte.Parse(xPar.InnerText, nfi);
                    xPar.SetAttribute("typ", CommandType.Decimal.ToString());
                }
                xPar = (XmlElement)node.SelectSingleNode("Par[@name='timeout']");
                if (xPar != null)
                {
                    timeout = uint.Parse(xPar.InnerText, nfi);
                    xPar.SetAttribute("typ", CommandType.Decimal.ToString());
                }

                xPar = (XmlElement)node.SelectSingleNode("Par[@name='ip']");
                if (xPar != null)
                {
                    int i = 0;
                    if (coffeeMaschine.ipAdress == null)
                    {
                        coffeeMaschine.ipAdress = new byte[4];
                    }
                    String[] substrings = xPar.InnerText.Split('.');
                    foreach (var substring in substrings)
                    {
                        coffeeMaschine.ipAdress[i++] = Convert.ToByte(substring);
                        Console.Write(Convert.ToByte(substring) + ".");
                    }
                    xPar.SetAttribute("typ", CommandType.Decimal.ToString());
                }

                xPar = (XmlElement)node.SelectSingleNode("Par[@name='BtnNbr']");
                if (xPar != null)
                {
                    if (uint.TryParse(UserDatabase.Evaluate(xPar.InnerText), out iBtnNbr))
                    {
                        // iBtnNbr = UInt16.Parse(xPar.InnerText, nfi);
                        xPar.SetAttribute("typ", CommandType.Decimal.ToString());
                    }
                }

                xPar = (XmlElement)node.SelectSingleNode("Par[@name='Barista']");
                if (xPar != null)
                {
                    iBarista = UInt16.Parse(xPar.InnerText, nfi);
                    xPar.SetAttribute("typ", CommandType.Decimal.ToString());
                }

                xPar = (XmlElement)node.SelectSingleNode("Par[@name='Decaf']");
                if (xPar != null)
                {
                    iDecaf = UInt16.Parse(xPar.InnerText, nfi);
                    xPar.SetAttribute("typ", CommandType.Decimal.ToString());
                }
                xPar = (XmlElement)node.SelectSingleNode("Par[@name='SML']");
                if (xPar != null)
                {
                    iSML = UInt16.Parse(xPar.InnerText, nfi);
                    xPar.SetAttribute("typ", CommandType.Decimal.ToString());
                }

                xPar = (XmlElement)node.SelectSingleNode("Par[@name='MilkType']");
                if (xPar != null)
                {
                    iMilkType = UInt16.Parse(xPar.InnerText, nfi);
                    xPar.SetAttribute("typ", CommandType.Decimal.ToString());
                }
                xPar = (XmlElement)node.SelectSingleNode("Par[@name='simState']");
                if (xPar != null)
                {
                    simState = bool.Parse(xPar.InnerText);
                    xPar.SetAttribute("typ", CommandType.Decimal.ToString());
                }
            }
            catch (Exception ex)
            {
                MessageHandler.Error(this, 41514, "WMFS1500 can't update! ", ex);
            }
            if (!coffeeMaschine.isConnected)
            {
                if (coffeeMaschine.Connect() == 0)
                {
                    MessageHandler.Message(this, 4151, MessageTyp.Info, "WMFS1500 is connected");
                }
            }
        }