예제 #1
0
        public void SaveToXML(string filePathName, GQHSM hsm)
        {
            FileStream fs = new FileStream(filePathName, FileMode.Create);
            if (fs == null)
            {
                Logger.Warn("Unable to create {0}", filePathName);
                return;
            }
			
			SaveToXML(fs, hsm);
			
            fs.Close();
        }
예제 #2
0
        public override void PreInit(GQHSM parentHSM)
        {
            base.PreInit(parentHSM);
            if (IsMultiPort)
            {
                _port = (IQPort)_parentHSM.CreateMultiPort(Name);
            }
            else
            {
                _port = _parentHSM.CreatePort(Name);
            }

            _fullName = parentHSM.GetName() + "." + Name;
            parentHSM.RegisterPort(this);
        }
예제 #3
0
        public void UnregisterHsm(GQHSM hsm)
        {
            m_LifeCycleManager.UnregisterHsm((ILQHsm)hsm);
			List<GQHSM> HSMs = m_NameToHSM[hsm.GetName()];
			List<GQHSM> newHSMS = new List<GQHSM>();
			foreach (GQHSM remHSM in HSMs)
			{
				if (remHSM.HandlerClass != hsm.HandlerClass)
				{
					newHSMS.Add(remHSM);
				}
			}
			
			HSMs = newHSMS;
			
        }
예제 #4
0
        public override void PreInit(GQHSM parentHSM)
        {
            base.PreInit(parentHSM);

            if (Component == null)
            {
                Component         = new GQHSMComponentLink[2];
                Component[0]      = new GQHSMComponentLink();
                Component[0].Id   = new Guid();
                Component[0].Name = FromPortName;
                Component[1]      = new GQHSMComponentLink();
                Component[1].Id   = new Guid();
                Component[1].Name = ToPortName;
            }

            GQHSMManager.Instance.RegisterPortLink(this);
        }
예제 #5
0
        public override void PreInit(GQHSM parentHSM)
        {
            base.PreInit(parentHSM);
            _fullName = _parentHSM.RegisterState(this);
            if (ChildStates != null)
            {
                foreach (GQHSMState gs in ChildStates)
                {
                    gs.PreInit(parentHSM);
                    if (gs.IsStartState)
                    {
                        _childStartState = gs;
                    }
                }
            }

            _stateHandler = new QState(this, StateHandler, Name);
        }
예제 #6
0
		public void SaveToXML(Stream fs, GQHSM hsm)
		{
			XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
			ns.Add("","");
			
            // specifies the type of object to be deserialized.
            XmlSerializer serializer = new XmlSerializer(typeof(GQHSMStateMachine));

            // If the XML document has been altered with unknown 
            // nodes or attributes, handles them with the 
            // UnknownNode and UnknownAttribute events.
            serializer.UnknownNode += new XmlNodeEventHandler(serializer_UnknownNode);
            serializer.UnknownAttribute += new XmlAttributeEventHandler(serializer_UnknownAttribute);


            serializer.Serialize(fs, hsm.HSMData, ns);

		}
예제 #7
0
        public GQHSM LoadFromXML(string fileName, string sXML)
        {
            GQHSM theHSM;

            // Creates an instance of the XmlSerializer class;
            // specifies the type of object to be deserialized.
            XmlSerializer serializer = new XmlSerializer(typeof(GQHSMStateMachine));
            // If the XML document has been altered with unknown 
            // nodes or attributes, handles them with the 
            // UnknownNode and UnknownAttribute events.
            serializer.UnknownNode += new XmlNodeEventHandler(serializer_UnknownNode);
            serializer.UnknownAttribute += new XmlAttributeEventHandler(serializer_UnknownAttribute);

			StringReader srXML = new StringReader(sXML);
            theHSM = new GQHSM(fileName);
            theHSM.HSMData = (GQHSMStateMachine)serializer.Deserialize(srXML);
            theHSM.PreInit();

            return theHSM;
        }
예제 #8
0
        public GQHSMAction(GQHSM parent, string actionStr)
        {
            _parentHSM = parent;
            string[] NameAndParams = actionStr.Split(new char[] { '(', ')' }, StringSplitOptions.RemoveEmptyEntries);
            if (NameAndParams.Length > 1)
            {
                _params = new GQHSMParameters(NameAndParams[1]);
            }
            else if (NameAndParams.Length == 1)
            {
                _params = new GQHSMParameters();
            }
            _name = NameAndParams[0];

            _globals = GQHSMManager.Instance.Globals;

            if (!_name.StartsWith("^"))
            {
                _actionHandler = _parentHSM.GetMethod(_name, _params);
            }
        }
예제 #9
0
        public void Init(GQHSM parentHSM, string[] actionStrings)
        {
            _parentHSM = parentHSM;

            if (actionStrings.Length > 0)
            {
                _actions = new GQHSMAction[actionStrings.Length];
                int paramIndex = 0;
                foreach (string actionStr in actionStrings)
                {
                    if (actionStr.Length > 0)
                    {
                        _actions[paramIndex++] = new GQHSMAction(parentHSM, actionStr);
                    }
                    else
                    {
                        throw new Exception("Invalid zero length action string detected!, Discarding");
                    }
                }
            }
        }
예제 #10
0
 public GQHSMActions(GQHSM parentHSM, string actionsStr)
 {
     string[] actionStrings = actionsStr.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
     Init(parentHSM, actionStrings);
 }
예제 #11
0
 public GQHSMActions(GQHSM parentHSM, string[] actionsStr)
 {
     Init(parentHSM, actionsStr);
 }
예제 #12
0
 public override void PreInit(GQHSM parentHSM)
 {
     base.PreInit(parentHSM);
     _parentHSM.RegisterTransition(this);
 }
예제 #13
0
 public virtual void PreInit(GQHSM parentHSM)
 {
     _parentHSM = parentHSM;
 }
예제 #14
0
 public void RegisterHsm(GQHSM hsm)
 {
     m_NameToHSM.Add(hsm.GetName(), hsm);
     m_LifeCycleManager.RegisterHsm((ILQHsm)hsm);
 }