Пример #1
0
        /// <summary>
        /// wartet bis die Kaffezubereitung beendet ist
        /// </summary>
        /// <param name="mainPrg"></param>
        public bool WaitBeverage(CProgramm mainPrg)
        {
            int n = 0;

            UserDatabase.SetVar(this, "coffee", "start");
            Thread.Sleep(2500);
            while (coffeeMaschine.isBeverageRunning())
            {
                uint err = coffeeMaschine.cm.isErrorActive();
                UserDatabase.SetVar(this, "coffee", "isRunning");
                Thread.Sleep(500);
                if (mainPrg.prgStopFlag)
                {
                    return(false);
                }
                if (cancelFlag)
                {
                    cancelFlag = false;
                    return(false);
                }
                if (n++ > 2 * timeout)
                {
                    MessageHandler.Error(this, 90, "Timeout Kaffemaschine");
                    UserDatabase.SetVar(this, "coffee", "timeout");
                    return(false);
                }
            }
            UserDatabase.SetVar(this, "coffee", "ready");
            return(true);
        }
Пример #2
0
        override public void Execute(CProgramm mainPrg)
        {
            uint        iret;
            MessageInfo mInfo = new MessageInfo(this, 416, MessageTyp.Info, "Execute WMFCmd");

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



            Name = GetNodeName();
            //mainPrg.lineNr++;
            switch (Name)
            {
            case "SetLight":
                iret = coffeeMaschine.setLightCode(r, g, b);
                NotifyExecute(CStateType.Executed, "SetLight " + coffeeMaschine.setBeverageCode(iret));
                break;

            case "StartBeverage":
                iret = coffeeMaschine.setOrder(iBtnNbr, iBarista, iDecaf, iSML, iMilkType, simState);
                NotifyExecute(CStateType.Executed, "StartBeverage " + coffeeMaschine.setBeverageCode(iret));
                if (timeout == 0)
                {
                    timeout = 90;
                }
                if (WaitBeverage(mainPrg))
                {
                    MessageHandler.Message(this, 90, MessageTyp.Info, "Kaffemaschine fertig!");
                }
                else
                {
                    MessageHandler.Warning(this, 90, "Kaffemaschine aborded!");
                }

                break;

            case "WaitBeverage":
                if (timeout == 0)
                {
                    timeout = 90;
                }
                NotifyExecute(CStateType.Executed, "WaitBeverage ");
                WaitBeverage(mainPrg);


                break;

            case "WMFConnect":     // pCmd = new CommandTemplate(7);
                iret = (uint)coffeeMaschine.Connect();
                NotifyExecute(CStateType.Executed, "WMF Connected " + coffeeMaschine.setBeverageCode(iret));
                break;
            }
        }
Пример #3
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");
                }
            }
        }