Ejemplo n.º 1
0
        /// <summary>
        /// parsing the XML
        /// TODO: need to check whether we have bml tag or not
        /// </summary>
        /// <param name="reader"></param> the XMLReader
        private void Parse(XmlReader reader)
        {
            BMLBml currentBml = null;

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:
                    if (blocks.ContainsKey(reader.Name))
                    {
                        Type     t        = blocks[reader.Name];
                        BMLBlock instance = (BMLBlock)Activator.CreateInstance(t);
                        instance.SetOffset(timer);
                        instance.Parse(reader);

                        // TODO: need to accomodate different tag such as constraint, ...
                        if (instance is BMLBml)
                        {
                            BMLBml bml = (BMLBml)instance;

                            if (bml.composition == BMLBml.Composition.REPLACE)
                            {
                                // The new block will completely replace all prior <bml> blocks.
                                // All behavior specified in earlier blocks will be ended and
                                ClearBlocks();

                                // TODO: the ECA will revert to a neutral state before the new block starts.
                            }
                            else if (bml.composition == BMLBml.Composition.APPEND)
                            {
                                // The start time of the new block will be as soon as possible after the end time of all prior blocks.
                                if (currentBml != null)
                                {
                                    bml.SetGlobalStartTrigger(currentBml.id + ":globalEnd");
                                }
                            }
                            else if (bml.composition == BMLBml.Composition.MERGE)
                            {
                                // The behaviors specified in the new <bml> block will be realized together with the behaviors specified in prior <bml> blocks.
                                // TODO: In case of conflict, behaviors in the newly merged <bml> block cannot modify behaviors defined by prior <bml> blocks.
                            }

                            // save this bml for upcomming tag
                            currentBml = bml;

                            // add to scheduled block
                            scheduledBlocks.Add((bml).id, bml);
                        }
                        else
                        {
                            // create a new bml if this xml is started without <bml> tag
                            if (currentBml == null)
                            {
                                currentBml = new BMLBml();
                            }
                            // track this tag belong to a bml tag
                            instance.parentBml = currentBml;

                            // keep tracking the number of tag inside <bml> tag. in order to check whether all bml inside this <bml> tag are already finish or not
                            instance.parentBml.IncreaseChild();

                            if (instance is BMLBehavior)
                            {
                                // add to scheduled block
                                scheduledBlocks.Add(((BMLBehavior)instance).id, (BMLBehavior)instance);
                            }
                        }
                    }
                    break;
                }
            }
        }
Ejemplo n.º 2
0
 public BMLScheduler(BMLBlock bmlBlock)
 {
     _bmlBlock = bmlBlock;
 }