Exemplo n.º 1
0
        private string StateToNewFormat(TAState item, Route[] routes)
        {
            StringBuilder result = new StringBuilder();

            result.AppendLine("\tstate " + item.GetName());

            if (item.Invariant != string.Empty)
            {
                result.AppendLine("\tinv: " + item.Invariant + ";");
            }

            string label = string.Empty;

            if (item.IsUrgent)
            {
                label += "urgent ";
            }
            if (item.IsCommitted)
            {
                label += "committed";
            }
            if (item.IsError)
            {
                label += "error";
            }
            if (label != string.Empty)
            {
                result.AppendLine("\t" + label + ";");
            }

            foreach (var route in routes)
            {
                if ((route.From as TAState).GetName() == item.GetName())
                {
                    string clockGuard = (route.Transition.ClockGuard == string.Empty) ? string.Empty : "[[" + route.Transition.ClockGuard + "]]";
                    string guard      = (route.Transition.Guard == string.Empty) ? string.Empty : "[" + route.Transition.Guard + "]";

                    string program    = (route.Transition.Program == string.Empty) ? string.Empty : "{" + route.Transition.Program.Replace("\r\n", "") + "}";
                    string clockReset = (route.Transition.ClockReset == string.Empty) ? string.Empty : "<" + route.Transition.ClockReset + ">";



                    result.AppendLine("\ttrans:" + clockGuard + guard + route.Transition.GetEventPart() + program + clockReset + "->" + (route.To as TAState).GetName() + ";");
                }
            }

            result.AppendLine("\tendstate");

            return(result.ToString());
        }
Exemplo n.º 2
0
        public override void LoadFromXml(XmlElement elem)
        {
            Node.Text  = elem.GetAttribute(NAME_PROCESS_NODE_NAME, "");
            Parameters = elem.GetAttribute(PARAMETER_NODE_NAME, "");
            Zoom       = float.Parse(elem.GetAttribute(ZOOM_PROCESS_NODE_NAME, ""));
            try
            {
                StateCounter = int.Parse(elem.GetAttribute(STATE_COUNTER));
            }
            catch
            {
                StateCounter = elem.ChildNodes[0].ChildNodes.Count + 1;
            }

            XmlElement statesElement = (XmlElement)elem.ChildNodes[0];

            foreach (XmlElement element in statesElement.ChildNodes)
            {
                TAState canvasitem = new TAState(false, "");
                canvasitem.LoadFromXml(element);
                this.AddSingleCanvasItem(canvasitem);
                this.AddSingleCanvasItem(canvasitem.labelItems);
            }

            XmlElement linksElement = (XmlElement)elem.ChildNodes[1];

            foreach (XmlElement element in linksElement.ChildNodes)
            {
                Route route = new Route(null, null);
                route.LoadFromXML(element, this);

                this.AddSingleLink(route);
                foreach (NailItem nailItem in route.Nails)
                {
                    this.AddSingleCanvasItem(nailItem);
                }
                //
                this.AddSingleCanvasItem(route.Transition);
            }
        }