Ejemplo n.º 1
0
        public void Execute(MRNetwork NW)
        {
            ExecuteStatus   = true;
            exerciseRunning = true;


            HOHEvent.ProtocolStateUpdated += OnHOHEventUpdate;
            HOHEvent.ExerciseStateUpdated += OnExerciseStateUpdated;

            this.NW = NW;
            for (int i = 0; i < this.Repetitions; i++)
            {
                HOHEventObj.UpdateLogMsg("EXERCISE: START!");
                HOHEventObj.UpdateLogMsg("Executing exercise: " + this.Name);

                if (this.PreState != null && ExecuteStatus)
                {
                    HOHEventObj.UpdateLogMsg("Setting Prestate: " + this.PreState.Name);
                    this.PreState.execute(NW);
                }

                if (this.TargetState != null && ExecuteStatus)
                {
                    HOHEventObj.UpdateLogMsg("Target State: " + this.TargetState.Name);
                    HOHEventObj.UpdateUsrMsg(this.UserMsg);
                    sf = new SFListener(this.TargetState, Int32.Parse(this.SFCode), this.ExerciseTime, this);
                    Thread SFThread = new Thread(() => sf.Execute(NW));
                    SFThread.Start();
                    exerciseRunning = true;
                    while (exerciseRunning)
                    {
                    }
                    // SFThread.Interrupt();
                    //Thread.Sleep(this.ExerciseTime * 1000);
                    sf.InterruptListener(NW);
                    //SFThread.Interrupt();
                    //sf = null;
                }

                if (this.PostState != null && ExecuteStatus)
                {
                    HOHEventObj.UpdateLogMsg("Setting PostState: " + this.PostState.Name);
                    this.PostState.execute(NW);
                }


                HOHEventObj.UpdateLogMsg("EXERCISE: DONE!");
            }
            HOHEvent.ProtocolStateUpdated -= OnHOHEventUpdate;
            HOHEvent.ExerciseStateUpdated -= OnExerciseStateUpdated;
            HOHEventObj.UpdateExerciseState(true);
            HOHEventObj.UpdateExerciseTimer(0);
        }
Ejemplo n.º 2
0
        public void Execute(MRNetwork NW)
        {
            HOHEvent.ProtocolStateUpdated += OnHOHEventUpdate;

            HOHEventObj.UpdateLogMsg("PROTOCOL: START!");
            HOHEventObj.UpdateProtocolState("running");
            foreach (Exercise ex in Exercises)
            {
                if (!ExecuteStatus)
                {
                    break;
                }
                Random rnd = new Random();

                HOHEventObj.UpdateUsrMsg("\r\nPrepare for " + ex.TargetState.UserMsg.ToLower() + "...");
                HOHEventObj.UpdateExerciseName(ex.TargetState.Name);
                //adicionar opção para alterar este valor
                Thread.Sleep(5000);
                if (!ExecuteStatus)
                {
                    break;
                }

                ex.Execute(NW);

                if (!ExecuteStatus)
                {
                    break;
                }
                //HOHEventObj.UpdateUsrMsg(Rewards[rnd.Next(Rewards.Count)]);
                HOHEventObj.RewardLaunch(true);

                //adicionar opção para alterar este valor
                Thread.Sleep(5000);
            }
            HOHEventObj.UpdateProtocolState("stopped");
            HOHEventObj.UpdateUsrMsg("Well done! Protocol complete.");
            HOHEventObj.UpdateLogMsg("PROTOCOL: DONE!");
        }