Exemple #1
0
 private void initialiseEventComboBox(FSM_STT mySTT)
 {
     // need handle on events in the list
     this.eventListComboBox.Items.Clear();
     this.eventListComboBox.Text = "";
     foreach (string item in mySTT.getEventsList())
     {
         this.eventListComboBox.Items.Add(item);
     }
 }
Exemple #2
0
 private void initialiseSTTsListBox()
 {
     // need handle on events in the list
     foreach (FSM_STT item in FSM_STT.getInstanceList().Values)
     {
         string refClassName = item.getRefClassName();
         this.listOfSTTsListBox.Items.Add(refClassName);
         this.listBox1.Items.Add(refClassName);
         this.listBox2.Items.Add(refClassName);
     }
 }
Exemple #3
0
        private void writeCodeToFileButton_Click(object sender, EventArgs e)
        {
            // get the STTs from the selections list
            // looop over the selection as necessary ...

            foreach (object sel in this.listBox2.SelectedItems)
            {
                FSM_STT mySTT = FSM_STT.findByRefClassName(sel.ToString());
                FSM_CodeBuilder.writeCodeToFile(this.textBox1.Text, mySTT);
            }
        }
Exemple #4
0
        private void loadSTTsButton_Click(object sender, EventArgs e)
        {
            FSM_STT mySTTCD = new FSM_STT("CDPLAYER", "TestFSM.ObjectModel",
                                          "Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");

            STT_State beginState   = mySTTCD.addState("Begin");
            STT_State playState    = mySTTCD.addState("Playing");
            STT_State pauseState   = mySTTCD.addState("Paused");
            STT_State stoppedState = mySTTCD.addState("Stopped");

            // Transitions

            beginState.addTransition("startPlaying", playState);
            beginState.addTransition("stop", stoppedState);
            playState.addTransition("pause", pauseState);
            playState.addTransition("stop", stoppedState);
            pauseState.addTransition("startPlaying", playState);
            pauseState.addTransition("stop", stoppedState);
            stoppedState.addTransition("startPlaying", playState);
            mySTTCD.setInitialState(beginState);

            Debug.WriteLine("FSMSTT create complete " + mySTTCD.getRefClassName());

            // ACTOR

            FSM_STT mySTTACTOR = new FSM_STT("ACTOR", "TestFSM.ObjectModel",
                                             "Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");

            STT_State inWingsState = mySTTACTOR.addState("InWings");
            STT_State onStageState = mySTTACTOR.addState("OnStage");
            STT_State driedState   = mySTTACTOR.addState("Dried");
            STT_State bowingState  = mySTTACTOR.addState("Bowing");
            STT_State endedState   = mySTTACTOR.addState("Ended");

            mySTTACTOR.setInitialState(inWingsState);
            mySTTACTOR.setDeleteWhenEndStateReached();
            mySTTACTOR.setTaskModel(taskAllocation.taskPerInstance);

            // Transitions

            inWingsState.addTransition("receiveCue", onStageState);
            onStageState.addTransition("endOfScene", inWingsState);
            onStageState.addTransition("forgetLine", driedState);
            driedState.addTransition("getPrompt", onStageState);
            driedState.addTransition("endOfScene", inWingsState);
            inWingsState.addTransition("endOfPLay", bowingState);
            bowingState.addTransition("applauseStopped", endedState);
            bowingState.addTransition("applauseStopped", endedState);

            Debug.WriteLine("Form1 - FSMSTT create complete " + mySTTACTOR.getRefClassName());

            this.initialiseSTTsListBox(); // list of STTs loaded in memory
        }
Exemple #5
0
        private void listOfSTTsListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            try {
                FSM_STT mySTT = FSM_STT.findByRefClassName(this.listOfSTTsListBox.SelectedItem.ToString());
                this.initialiseEventComboBox(mySTT); //  populate dropdown list of events in UI
                                                     // using the selected STT

                // we should also populate FSM list as well ?? these would be what we send the events to
                this.initialiseInstancesListBox(mySTT.getRefClassName());
            } catch (Exception ex) {
                Debug.WriteLine(ex.Message);
            }
        }
Exemple #6
0
 private void WriteDifferentOnEntryMethodCode(FSM_STT theSTT, StringBuilder retVal, STT_State state)
 {
     retVal.Append("      // Method for Entry XXXXXX\n\n");
     retVal.Append("      public void ").Append(state.getStateName());
     retVal.Append("__onEntry(FSM_Event evt)\n");
     retVal.Append("      {\n");
     retVal.Append("         Debug.WriteLine( \"");
     retVal.Append(theSTT.getRefClassName()).Append(".").Append(state.getStateName());
     retVal.Append("__onEntry() XXXXXXXXXExecuting in response to event \" + evt.getEventName());\n");
     if (theSTT.getDeleteWhenEndStateReached() && state.getIsFinalState())
     {
         retVal.Append("         //  XXXXXXXXXXXdelete references as this is an end state and the STT demands it\n");
         retVal.Append("         this.derefenceFSM();\n");
     }
     retVal.Append("      }\n\n");
 }
Exemple #7
0
        private static void WriteDifferentClassCode(FSM_STT theSTT, StringBuilder retVal)
        {
            // TODO want code gen to provide a switch on the type sync/async passed in as a parameter
            // to the constructor.  Maybe a second constructor for initialising with an event  ?

            string className = theSTT.getRefClassName();

            retVal.Append("\n\n   // ADD CLASS\n");
            retVal.Append("   public class ").Append(className).Append("\n");
            retVal.Append("   {\n\n");
            string instNameName = className.ToLower() + "Name";

            retVal.Append("      protected string ").Append(instNameName).Append(";\n");
            retVal.Append("      protected FSM fsm;\n\n");
            retVal.Append("      public ").Append(className).Append("( string ")
            .Append(instNameName).Append(", FSM_STT stt, FSMType fsmType )\n");
            retVal.Append("      {\n");
            retVal.Append("         this.").Append(instNameName).Append(" = ").Append(instNameName).Append(";\n");
            retVal.Append("         this.fsm = FSM.createFSM(this.").Append(instNameName).
            Append(", stt, this, fsmType);\n");
            retVal.Append("         this.fsm.setInitialState();\n");
            retVal.Append("      }\n\n");
            retVal.Append("      public FSM getFSM()\n");
            retVal.Append("      {\n");
            retVal.Append("         return this.fsm;\n");
            retVal.Append("      }\n\n");
            retVal.Append("      public STT_State getCurrentState()\n");
            retVal.Append("      {\n");
            retVal.Append("         return this.fsm.getCurrentState();\n");
            retVal.Append("      }\n\n");
            retVal.Append("      // Use this in the body of your StateName__XXXX() methods when\n");
            retVal.Append("      // you want to 'delete the FSM' ( remember you can't delete in c# )\n");
            retVal.Append("      // So instead we remove references to tidy stuff up.\n");
            retVal.Append("      protected void dereferenceFSM()\n");
            retVal.Append("      {\n");
            retVal.Append("         FSM.removeFromInstanceList(this.fsm);\n");
            retVal.Append("         this.fsm = null;\n");
            retVal.Append("      }\n\n");
            retVal.Append("      // Processes an event.  Passes it on to the FSM\n");
            retVal.Append("      public void takeEvent( FSM_Event evt)\n");
            retVal.Append("      {\n");
            retVal.Append("         this.fsm.takeEvent( evt);\n");
            retVal.Append("      }\n\n");
        }
Exemple #8
0
        private void createOMInstancesButton_Click(object sender, EventArgs e)
        {
            //create 3 CDPLayers and 4 ACTORS

            try {
                FSM_STT mySTTCD = FSM_STT.findByRefClassName("CDPLAYER");
                new CDPLAYER("cdplayer1", mySTTCD, FSMType.synch);
                new CDPLAYER("cdplayer2", mySTTCD, FSMType.synch);
                CDPLAYER  c3    = new CDPLAYER("cdplayer3", mySTTCD, FSMType.synch);
                FSM_Event newEv = new FSM_Event(this, CDPLAYER.Events.startPlaying, c3.getFSM());
                CDPLAYER.postEvent(newEv);

                FSM_STT mySTTACTOR = FSM_STT.findByRefClassName("ACTOR");
                ACTOR   a1         = new ACTOR("actor1", mySTTACTOR, FSMType.asynch);
                ACTOR   a2         = new ACTOR("actor2", mySTTACTOR, FSMType.asynch);
                ACTOR   a3         = new ACTOR("actor3", mySTTACTOR, FSMType.asynch);
                ACTOR   a4         = new ACTOR("actor4", mySTTACTOR, FSMType.asynch);
            } catch (Exception ex) {
                Debug.WriteLine(ex.Message);
            }
        }
Exemple #9
0
 public CDPLAYER(string cdplayerName, FSM_STT stt, FSMType fsmType)
 {
     this.cdplayerName = cdplayerName;
     this.fsm          = FSM.createFSM(this.cdplayerName, stt, this, fsmType);
     this.fsm.setInitialState();
 }
Exemple #10
0
 public ACTOR(string actorName, FSM_STT stt, FSMType fsmType)
 {
     this.actorName = actorName;
     this.fsm       = FSM.createFSM(this.actorName, stt, this, fsmType);
     this.fsm.setInitialState();
 }