Example #1
0
        public void BasicExecution()
        {
            Event root = new RootEvent()
                         .AddChildEvent(new OutputEvent("A")
                                        .AddChildEvent(new OutputEvent("B"))
                                        .AddRelation(new Condition(new Root().Extend(new Name("A").Extend(new Name("F"))), new Here()))
                                        )
                         .AddChildEvent(new OutputEvent("C", new Marking(false, false, false)))
                         .AddChildEvent(new OutputEvent("A")
                                        .AddChildEvent(new OutputEvent("F"))
                                        .AddChildEvent(new OutputEvent("B"))
                                        );



            //PathExpression p = new Root().Extend(new Name("A").Extend(new All()));

            Assert.AreEqual(root.subProcess.structuredData[0].IsEnabled(), false);
            Assert.AreEqual(root.subProcess.structuredData[0].subProcess.structuredData[0].IsEnabled(), false);
            Assert.AreEqual(root.subProcess.structuredData[1].IsEnabled(), false);
            Assert.AreEqual(root.subProcess.structuredData[2].IsEnabled(), true);

            root.subProcess.structuredData[2].subProcess.structuredData[0].Execute();
            root.subProcess.structuredData[2].subProcess.structuredData[1].Execute();
            root.subProcess.structuredData[0].subProcess.structuredData[0].Execute();

            Assert.AreEqual(root.subProcess.structuredData[0].IsEnabled(), true);
            Assert.AreEqual(root.subProcess.structuredData[0].subProcess.structuredData[0].IsEnabled(), true);
            Assert.AreEqual(root.subProcess.structuredData[1].IsEnabled(), false);
            Assert.AreEqual(root.subProcess.structuredData[2].IsEnabled(), true);
        }
Example #2
0
            public void Handle(IViewContext context, RootEvent domainEvent)
            {
                var aggregateRootId = domainEvent.GetAggregateRootId();

                EventCounts[aggregateRootId] = EventCounts.ContainsKey(aggregateRootId)
                    ? EventCounts[aggregateRootId] + 1
                    : 1;
            }
Example #3
0
        public Event GenerateRoot(ParseTreeNode node)
        {
            var result = new RootEvent();

            //result.subProcess
            AddProcess(result, node);
            return(result);
        }
// ~~ private

// ~ Non-Static

// ~~ public

// ~~ private
    private void Awake()
    {
        if (!InstanceValidation.SingleInstanceExists <EventSystem>())
        {
            RootLog.Log(
                "No event system.",
                Severity.Warning
                );
        }

        gameObject.name = "Root Windows";

        _windowManager = gameObject.AddComponent <WindowManager>();
        Debug.Log("Subscribing WindowManager to RootWindows events.");

        _subjectEvent = new RootEvent <string, ISubject>();

        _registerDataEvent =
            new RootEvent <string, IViewData, string>();
        _registerSelfAbilityEvent =
            new RootEvent <string, Action, Action, string>();
        _registerLocationAbilityEvent =
            new RootEvent <string, Action, Action <Vector3>, string>();
        _registerObjectAbilityEvent =
            new RootEvent <string, Action, Action <GameObject[]>, string>();

        _deregisterDataEvent =
            new RootEvent <string, IViewData, string>();
        _deregisterSelfAbilityEvent =
            new RootEvent <string, Action, Action, string>();
        _deregisterLocationAbilityEvent =
            new RootEvent <string, Action, Action <Vector3>, string>();
        _deregisterObjectAbilityEvent =
            new RootEvent <string, Action, Action <GameObject[]>, string>();

        _setBGColorEvent = new RootEvent <string, Color, string>();

        _subjectEvent.Subscribe(HandleSubject);

        _registerDataEvent.Subscribe(HandleRegisterData);
        _registerSelfAbilityEvent.Subscribe(HandleRegisterSelfAbility);
        _registerLocationAbilityEvent.Subscribe(HandleRegisterLocationAbility);
        _registerObjectAbilityEvent.Subscribe(HandleRegisterObjectAbility);

        _deregisterDataEvent.Subscribe(HandleDeregisterData);
        _deregisterSelfAbilityEvent.Subscribe(HandleDeregisterSelfAbility);
        _deregisterLocationAbilityEvent.Subscribe(HandleDeregisterLocationAbility);
        _deregisterObjectAbilityEvent.Subscribe(HandleDeregisterObjectAbility);

        _setBGColorEvent.Subscribe(HandleSetBGColor);
    }
Example #5
0
 private static void Parse(string s)
 {
     try
     {
         Console.WriteLine("Parsing: " + s);
         Console.WriteLine("AST: " + parser.stringTree(s));
         term = (RootEvent)parser.Generate(s);
     }
     catch (Exception ex)
     {
         Console.WriteLine("Parsing Error:");
         Console.WriteLine(ex.Message);
     }
 }
Example #6
0
        public void Reset()
        {
            if (!IsHappened)
            {
                return;
            }

            IsHappened     = false;
            _coundownTimer = _realSecondsBetweenChecks;

            if (ChainedEvent != null)
            {
                ChainedEvent.Reset();
            }

            if (RootEvent != null)
            {
                RootEvent.Reset();
            }
        }
Example #7
0
        public void Reset()
        {
            if (!IsHappened)
            {
                return;
            }

            IsHappened = false;

            //(_name + " reset");

            if (ChainedEvent != null)
            {
                ChainedEvent.Reset();
            }

            if (RootEvent != null)
            {
                RootEvent.Reset();
            }
        }
Example #8
0
        public void Reset()
        {
            if (!IsHappened && !IsEnded)
            {
                return;
            }

            IsHappened = false;
            IsEnded    = false;

            _previousWorldTime            = default(DateTime);
            _gameSecondsSinceEventStarted = 0f;
            _coundownTimer = _realSecondsBetweenChecks;

            if (ChainedEvent != null)
            {
                ChainedEvent.Reset();
            }

            if (RootEvent != null)
            {
                RootEvent.Reset();
            }
        }
Example #9
0
        public void BasicTerm()
        {
            Event root = new RootEvent()
                         .AddChildEvent(new OutputEvent("A")
                                        .AddChildEvent(new OutputEvent("B")))
                         .AddChildEvent(new OutputEvent("C"))
                         .AddChildEvent(new OutputEvent("A")
                                        .AddChildEvent(new OutputEvent("F"))
                                        .AddChildEvent(new OutputEvent("B"))
                                        );

            PathExpression p = new Root().Extend(new Name("A").Extend(new All()));


            String expected = @"/
/A/
/A/B/
/C/
/A/
/A/F/
/A/B/
";

            Assert.AreEqual(expected, root.PrintTree());

            //int i = 0;
            Assert.AreEqual("/A/*", p.ToString());

            String s = "";

            foreach (Event e in p.Eval(root, root))
            {
                s += e.name;
            }
            Assert.AreEqual("BFB", s);
        }
Example #10
0
        /// <summary>
        /// Implementation of the RDF/XML Grammar Production 'doc'
        /// </summary>
        /// <param name="context">Parser Context</param>
        /// <param name="root">Root Event to start applying Productions from</param>
        private void GrammarProductionDoc(RdfXmlParserContext context, RootEvent root)
        {
            //Tracing
            if (this._traceparsing)
            {
                this.ProductionTrace("Doc");
            }

            //Call the RDF Production on the first child if it's an rdf:RDF element
            //if (root.Children[0].QName.Equals("rdf:RDF") || root.Children[0].QName.Equals(":RDF"))
            String localName = root.Children[0].LocalName;
            String prefix = root.Children[0].Namespace;
            if (localName.Equals("RDF") &&
                ((context.Namespaces.HasNamespace(prefix) && context.Namespaces.GetNamespaceUri(prefix).ToString().Equals(NamespaceMapper.RDF))
                 || root.DocumentElement.NamespaceAttributes.Any(ns => ns.Prefix.Equals(prefix) && ns.Uri.Equals(NamespaceMapper.RDF))))
            {
                this.GrammarProductionRDF(context, root.Children[0]);
            }
            else
            {
                //No rdf:RDF element
                //Drop first element from Queue (which will be a RootEvent)
                //Skip straight to NodeElementList production
                //context.Events.Dequeue();
                this.GrammarProductionNodeElementList(context, context.Events);
            }
        }
Example #11
0
        /// <summary>
        /// Implementation of the RDF/XML Grammar Production 'doc'
        /// </summary>
        /// <param name="context">Parser Context</param>
        /// <param name="root">Root Event to start applying Productions from</param>
        private void GrammarProductionDoc(RdfXmlParserContext context, RootEvent root)
        {
            //Tracing
            if (this._traceparsing)
            {
                this.ProductionTrace("Doc");
            }

            //Call the RDF Production on the first child if it's an rdf:RDF element
            if (root.Children[0].QName.Equals("rdf:RDF") || root.Children[0].QName.Equals(":RDF"))
            {
                this.GrammarProductionRDF(context, root.Children[0]);
            }
            else
            {
                //No rdf:RDF element
                //Drop first element from Queue (which will be a RootEvent)
                //Skip straight to NodeElementList production
                //context.Events.Dequeue();
                this.GrammarProductionNodeElementList(context, context.Events);
            }
        }
Example #12
0
        static void Main(string[] args)
        {
            parser = new ResedaParser();
            var exit = false;

            while (exit == false)
            {
                Console.WriteLine();
                Console.WriteLine("Enter command (help to display help): ");
                var commandParts = Console.ReadLine().Split(' ').ToList();
                var commandName  = commandParts[0];
                var commandArgs  = commandParts.Skip(1).ToList(); // the arguments is after the command
                try
                {
                    switch (commandName)
                    {
                    // Create command based on CommandName (and maybe arguments)
                    case "exit": exit = true; break;

                    case "parse":
                        String s = "";
                        foreach (var i in commandArgs)
                        {
                            s += i + " ";
                        }
                        Parse(s);
                        break;

                    case "load":
                        Load(commandArgs[0]);
                        break;

                    case "term": Console.WriteLine(term.ToSource()); break;

                    case "auto": autoCompute = !autoCompute;  Console.WriteLine(autoCompute); break;

                    case "tree": Console.WriteLine(term.PrintTree(true)); break;

                    case "live": Console.WriteLine(term.ProcessIsLive()); break;

                    case "inseq": term = term.MakeInSeq(); break;

                    case "glitchfree": term = term.MakeGlitchFree(); break;

                    case "list":
                        foreach (var pe in term.GetAllEnabledEvents())
                        {
                            Console.WriteLine(pe.ToSource());
                        }
                        break;

                    case "execute":
                        if (commandArgs.Count > 1)
                        {
                            Execute(commandArgs[0], commandArgs[1]);
                        }
                        else
                        {
                            Execute(commandArgs[0]);
                        }
                        break;

                    default:
                        if (commandArgs.Count > 0)
                        {
                            Execute(commandName, commandArgs[0]);
                        }
                        else
                        {
                            Execute(commandName);
                        }

                        break;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Command " + commandName + "failed, because:");
                    Console.WriteLine(e.Message);
                }
            }
        }