ThreadStart() public static method

public static ThreadStart ( ) : void
return void
Exemplo n.º 1
0
    public override void Manage()
    {
        LogB.Debug("MANAGE!!!!");

        //boolean to know if chronopic has been disconnected
        chronopicDisconnected = false;

        if (simulated)
        {
            platformState = Chronopic.Plataforma.ON;
        }
        else
        {
            platformState = chronopicInitialValue(cp);
        }

        LogB.Debug("MANAGE(b)!!!!");

        //you can start ON or OFF the platform,
        //we record always de TF (or time between we abandonate the platform since we arrive)
        if (platformState == Chronopic.Plataforma.ON)
        {
            feedbackMessage         = Catalog.GetString("You are IN, RUN when prepared!");
            needShowFeedbackMessage = true;
            Util.PlaySound(Constants.SoundTypes.CAN_START, volumeOn);

            loggedState = States.ON;
            startIn     = true;
            runPhase    = runPhases.PLATFORM_INI_NO_TIME;
        }
        else if (platformState == Chronopic.Plataforma.OFF)
        {
            feedbackMessage         = Catalog.GetString("You are OUT, RUN when prepared!");
            needShowFeedbackMessage = true;
            Util.PlaySound(Constants.SoundTypes.CAN_START, volumeOn);

            loggedState = States.OFF;
            startIn     = false;
            runPhase    = runPhases.PRE_RUNNING;
        }
        else           //UNKNOW (Chronopic disconnected, port changed, ...)
        {
            chronopicHasBeenDisconnected();
            return;
        }


        if (simulated)
        {
            if (startIn)
            {
                //values of simulation will be the flightTime (between two platforms)
                //at the first time (and the only)
                //start running being on the platform
                simulatedCurrentTimeIntervalsAreContact = false;

                //in simulated mode, make the run start just when we arrive to waitEvent at the first time
                //mark now that we have abandoned platform:
                platformState = Chronopic.Plataforma.OFF;
            }
            else
            {
                //values of simulation will be the contactTime
                //at the first time, the second will be flightTime (between two platforms)
                //come with previous run ("salida lanzada")
                simulatedCurrentTimeIntervalsAreContact = true;

                //in simulated mode, make the run start just when we arrive to waitEvent at the first time
                //mark now that we have reached the platform:
                platformState = Chronopic.Plataforma.ON;
            }
        }

        //prepare jump for being cancelled if desired
        cancel           = false;
        totallyCancelled = false;

        //start thread
        thread = new Thread(new ThreadStart(waitEvent));
        GLib.Idle.Add(new GLib.IdleHandler(PulseGTK));

        LogB.ThreadStart();
        thread.Start();
    }
Exemplo n.º 2
0
    public override void Manage()
    {
        //boolean to know if chronopic has been disconnected
        chronopicDisconnected = false;

        if (simulated)
        {
            if (hasFall)
            {
                platformState = Chronopic.Plataforma.OFF;
            }
            else
            {
                platformState = Chronopic.Plataforma.ON;
            }
        }
        else
        {
            platformState = chronopicInitialValue(cp);
        }

        if (platformState == Chronopic.Plataforma.OFF)
        {
            loggedState = States.OFF;
        }
        else if (platformState == Chronopic.Plataforma.ON)
        {
            loggedState = States.ON;
        }
        else           //UNKNOW (Chronopic disconnected, port changed, ...)
        {
            chronopicHasBeenDisconnected();
            return;
        }


        bool success = false;

        if (platformState == Chronopic.Plataforma.OFF && hasFall)
        {
            feedbackMessage         = Catalog.GetString("You are OUT, JUMP when prepared!");
            needShowFeedbackMessage = true;
            Util.PlaySound(Constants.SoundTypes.CAN_START, volumeOn, gstreamer);
            success = true;
        }
        else if (platformState == Chronopic.Plataforma.ON && !hasFall)
        {
            feedbackMessage         = Catalog.GetString("You are IN, JUMP when prepared!");
            needShowFeedbackMessage = true;
            Util.PlaySound(Constants.SoundTypes.CAN_START, volumeOn, gstreamer);
            success = true;
        }
        else
        {
            string myMessage = Catalog.GetString("You are IN, please leave the platform, and press the 'accept' button");
            if (platformState == Chronopic.Plataforma.OFF)
            {
                myMessage = Catalog.GetString("You are OUT, please enter the platform, prepare for jump and press the 'accept' button");
            }
            ConfirmWindow confirmWin;
            confirmWin = ConfirmWindow.Show(myMessage, "", "");
            Util.PlaySound(Constants.SoundTypes.BAD, volumeOn, gstreamer);

            //we call again this function
            confirmWin.Button_accept.Clicked += new EventHandler(callAgainManage);
            //if confirmWin.Button_cancel is pressed return
            confirmWin.Button_cancel.Clicked += new EventHandler(cancel_event_before_start);
        }

        if (success)
        {
            //initialize strings of TCs and TFs
            tcString     = "";
            tvString     = "";
            tcCount      = 0;
            tvCount      = 0;
            firstRjValue = true;

            //if jump starts on TF, write a "-1" in TC
            if (!hasFall)
            {
                double myTc = -1;
                tcString = myTc.ToString();
                tcCount  = 1;
            }

            //prepare jump for being cancelled if desired
            cancel = false;

            //prepare jump for being finished earlier if desired
            finish = false;

            jumpPhase = jumpPhases.PRE_OR_DOING;

            //in simulated mode, make the jump start just when we arrive to waitEvent at the first time
            //mark now that the opposite as before:
            if (simulated)
            {
                if (hasFall)
                {
                    platformState = Chronopic.Plataforma.ON;
                }
                else
                {
                    platformState = Chronopic.Plataforma.OFF;
                }
            }

            //start thread
            thread = new Thread(new ThreadStart(waitEvent));
            GLib.Idle.Add(new GLib.IdleHandler(PulseGTK));

            LogB.ThreadStart();
            thread.Start();
        }
    }
Exemplo n.º 3
0
    public override void ManageFall()
    {
        //boolean to know if chronopic has been disconnected
        chronopicDisconnected = false;

        if (simulated)
        {
            if (fall != -1)
            {
                platformState = Chronopic.Plataforma.OFF;
            }
            else
            {
                platformState = Chronopic.Plataforma.ON;
            }
        }
        else
        {
            platformState = chronopicInitialValue(cp);
        }



        if (platformState != Chronopic.Plataforma.OFF &&
            platformState != Chronopic.Plataforma.ON)
        {
            //UNKNOW (Chronopic disconnected, port changed, ...)
            chronopicHasBeenDisconnected();
            return;
        }

        //if we are outside
        //or we are inside, but with fall == -1 (calculate fall using a previous jump (start inside))
        if (
            (platformState == Chronopic.Plataforma.OFF && fall != -1) ||
            (platformState == Chronopic.Plataforma.ON && fall == -1)
            )
        {
            if (fall != -1)
            {
                feedbackMessage = Catalog.GetString("You are OUT, JUMP when prepared!");
                loggedState     = States.OFF;
            }
            else
            {
                feedbackMessage = Catalog.GetString("You are IN, JUMP when prepared!");
                loggedState     = States.ON;
            }

            needShowFeedbackMessage = true;
            Util.PlaySound(Constants.SoundTypes.CAN_START, volumeOn, gstreamer);


            //useful also for tracking the jump phases
            tc = 0;

            //prepare jump for being cancelled if desired
            cancel = false;

            jumpPhase = jumpPhases.PRE_OR_DOING;

            //in simulated mode, make the jump start just when we arrive to waitEvent at the first time
            if (simulated)
            {
                if (fall != -1)
                {
                    platformState = Chronopic.Plataforma.ON;                     //mark now that we have arrived:
                }
                else
                {
                    platformState = Chronopic.Plataforma.OFF;                     //mark now that we have jumped
                }
            }

            //start thread
            thread = new Thread(new ThreadStart(waitEvent));
            GLib.Idle.Add(new GLib.IdleHandler(PulseGTK));

            LogB.ThreadStart();
            thread.Start();
        }
        else
        {
            ConfirmWindow confirmWin;

            string message = Catalog.GetString("You are IN, please leave the platform, and press the 'accept' button");
            if (fall == -1)
            {
                message = Catalog.GetString("You are OUT, please enter the platform, prepare for jump and press the 'accept' button");
            }

            confirmWin = ConfirmWindow.Show(message, "", "");

            Util.PlaySound(Constants.SoundTypes.BAD, volumeOn, gstreamer);

            //we call again this function
            confirmWin.Button_accept.Clicked += new EventHandler(callAgainManageFall);

            //if confirmWin.Button_cancel is pressed return
            confirmWin.Button_cancel.Clicked += new EventHandler(cancel_event_before_start);
        }
    }
Exemplo n.º 4
0
    public override void Manage()
    {
        //boolean to know if chronopic has been disconnected
        chronopicDisconnected = false;

        if (simulated)
        {
            platformState = Chronopic.Plataforma.ON;
        }
        else
        {
            platformState = chronopicInitialValue(cp);
        }


        if (platformState == Chronopic.Plataforma.ON)
        {
            feedbackMessage         = Catalog.GetString("You are IN, JUMP when prepared!");
            needShowFeedbackMessage = true;
            Util.PlaySound(Constants.SoundTypes.CAN_START, volumeOn, gstreamer);

            loggedState = States.ON;

            //prepare jump for being cancelled if desired
            cancel = false;

            jumpPhase = jumpPhases.PRE_OR_DOING;

            //in simulated mode, make the jump start just when we arrive to waitEvent at the first time
            //mark now that we have leaved platform:
            if (simulated)
            {
                platformState = Chronopic.Plataforma.OFF;
            }

            //start thread
            thread = new Thread(new ThreadStart(waitEvent));
            GLib.Idle.Add(new GLib.IdleHandler(PulseGTK));

            LogB.ThreadStart();
            thread.Start();
        }
        else if (platformState == Chronopic.Plataforma.OFF)
        {
            ConfirmWindow confirmWin;
            confirmWin = ConfirmWindow.Show(Catalog.GetString(
                                                "You are OUT, please enter the platform, prepare for jump and press the 'accept' button"), "", "");

            Util.PlaySound(Constants.SoundTypes.BAD, volumeOn, gstreamer);

            //we call again this function
            confirmWin.Button_accept.Clicked += new EventHandler(callAgainManage);

            //if confirmWin.Button_cancel is pressed return
            confirmWin.Button_cancel.Clicked += new EventHandler(cancel_event_before_start);
        }
        else           //UNKNOW (Chronopic disconnected, port changed, ...)
        {
            chronopicHasBeenDisconnected();
        }
    }
Exemplo n.º 5
0
    public override void Manage()
    {
        bool success = false;

        //boolean to know if chronopic has been disconnected
        chronopicDisconnected = false;

        if (simulated)
        {
            platformState = Chronopic.Plataforma.OFF;
        }
        else
        {
            platformState = chronopicInitialValue(cp);
        }


        //you should start OFF (outside) the platform
        //we record always de TC+TF (or time between we pulse platform and we pulse again)
        //we don't care about the time between the get in and the get out the platform
        if (platformState == Chronopic.Plataforma.ON)
        {
            string myMessage = Catalog.GetString("You are IN, please leave the platform, prepare for start, and press the 'accept' button!");

            ConfirmWindow confirmWin;
            confirmWin = ConfirmWindow.Show(myMessage, "", "");
            Util.PlaySound(Constants.SoundTypes.BAD, volumeOn);

            //we call again this function
            confirmWin.Button_accept.Clicked += new EventHandler(callAgainManage);

            //if confirmWin.Button_cancel is pressed retuen
            confirmWin.Button_cancel.Clicked += new EventHandler(cancel_event_before_start);
        }
        else if (platformState == Chronopic.Plataforma.OFF)
        {
            feedbackMessage         = Catalog.GetString("You are OUT, start when prepared!");
            needShowFeedbackMessage = true;
            Util.PlaySound(Constants.SoundTypes.CAN_START, volumeOn);

            loggedState = States.OFF;

            success = true;
        }
        else           //UNKNOW (Chronopic disconnected, port changed, ...)
        {
            chronopicHasBeenDisconnected();
            return;
        }

        if (success)
        {
            //initialize variables
            timesString = "";
            tracks      = 0;

            //prepare jump for being cancelled if desired
            cancel = false;

            //prepare jump for being finished earlier if desired
            finish = false;

            //mark we haven't started
            pulsePhase = pulsePhases.WAIT_FIRST_EVENT;

            //in simulated mode, make the event start just when we arrive to waitEvent at the first time
            //mark now that we have landed:
            if (simulated)
            {
                platformState = Chronopic.Plataforma.ON;
            }

            //start thread
            thread = new Thread(new ThreadStart(waitEvent));
            GLib.Idle.Add(new GLib.IdleHandler(PulseGTK));

            LogB.ThreadStart();
            thread.Start();
        }
    }
Exemplo n.º 6
0
    /*
     * //onTimer allow to update progressbar_time every 50 milliseconds
     * //also can change platform state in simulated mode
     * //protected void onTimer( Object source, ElapsedEventArgs e )
     * protected override void onTimer( )
     * {
     *      timerCount = timerCount + .05; //0,05 segons == 50 milliseconds, time between each call of onTimer
     * }
     */


    public override void Manage()
    {
        //boolean to know if chronopic has been disconnected
        chronopicDisconnected = false;

        if (chronopics > 0)
        {
            platformState = chronopicInitialValue(cp);

            if (platformState == Chronopic.Plataforma.ON)
            {
                loggedState  = States.ON;
                cp1StartedIn = true;
            }
            else if (platformState == Chronopic.Plataforma.OFF)
            {
                loggedState  = States.OFF;
                cp1StartedIn = false;
            }
            else                 //UNKNOW (Chronopic disconnected, port changed, ...)
            {
                chronopicHasBeenDisconnected();
                return;
            }

            //prepare jump for being cancelled if desired
            cancel = false;

            //prepare jump for being finished earlier if desired
            finish = false;

            if (chronopics > 1)
            {
                platformState2 = chronopicInitialValue(cp2);

                if (platformState2 == Chronopic.Plataforma.ON)
                {
                    loggedState2 = States.ON;
                    cp2StartedIn = true;
                }
                else if (platformState2 == Chronopic.Plataforma.OFF)
                {
                    loggedState2 = States.OFF;
                    cp2StartedIn = false;
                }
                else                     //UNKNOW (Chronopic disconnected, port changed, ...)
                {
                    chronopicHasBeenDisconnected();
                    return;
                }

                if (chronopics > 2)
                {
                    platformState3 = chronopicInitialValue(cp3);

                    if (platformState3 == Chronopic.Plataforma.ON)
                    {
                        loggedState3 = States.ON;
                        cp3StartedIn = true;
                    }
                    else if (platformState3 == Chronopic.Plataforma.OFF)
                    {
                        loggedState3 = States.OFF;
                        cp3StartedIn = false;
                    }
                    else                         //UNKNOW (Chronopic disconnected, port changed, ...)
                    {
                        chronopicHasBeenDisconnected();
                        return;
                    }

                    if (chronopics > 3)
                    {
                        platformState4 = chronopicInitialValue(cp4);

                        if (platformState4 == Chronopic.Plataforma.ON)
                        {
                            loggedState4 = States.ON;
                            cp4StartedIn = true;
                        }
                        else if (platformState4 == Chronopic.Plataforma.OFF)
                        {
                            loggedState4 = States.OFF;
                            cp4StartedIn = false;
                        }
                        else                             //UNKNOW (Chronopic disconnected, port changed, ...)
                        {
                            chronopicHasBeenDisconnected();
                            return;
                        }
                    }
                }
            }
        }

        string platformsProblems = "";

        if (type == Constants.RunAnalysisName)
        {
            string sep = "";
            if (platformState == Chronopic.Plataforma.ON)
            {
                platformsProblems = Catalog.GetString("Photocells");
                sep = ", ";
            }
            if (platformState2 == Chronopic.Plataforma.ON)
            {
                platformsProblems += sep + Catalog.GetString("Platform");
            }
        }


        if (platformsProblems.Length > 0)
        {
            ConfirmWindow confirmWin;
            confirmWin = ConfirmWindow.Show(
                string.Format(Catalog.GetString("There's contact in {0}. Please leave."), platformsProblems), "", "");

            Util.PlaySound(Constants.SoundTypes.BAD, volumeOn);

            //we call again this function
            confirmWin.Button_accept.Clicked += new EventHandler(callAgainManage);

            //if confirmWin.Button_cancel is pressed retuen
            confirmWin.Button_cancel.Clicked += new EventHandler(cancel_event_before_start);
        }
        else
        {
            firstValue = true;
            //writingStarted = false;

            //start thread
            if (chronopics > 0)
            {
                //prepare variables to allow being cancelled or finished
                if (!simulated)
                {
                    Chronopic.InitCancelAndFinish();
                }

                thread = new Thread(new ThreadStart(waitEventPre));
                if (chronopics > 1)
                {
                    thread2 = new Thread(new ThreadStart(waitEventPre2));
                    if (chronopics > 2)
                    {
                        thread3 = new Thread(new ThreadStart(waitEventPre3));
                        if (chronopics > 3)
                        {
                            thread4 = new Thread(new ThreadStart(waitEventPre4));
                        }
                    }
                }
            }

            GLib.Idle.Add(new GLib.IdleHandler(PulseGTK));

            if (chronopics > 0)
            {
                LogB.ThreadStart();
                thread.Start();

                if (chronopics > 1)
                {
                    thread2.Start();
                    if (chronopics > 2)
                    {
                        thread3.Start();
                        if (chronopics > 4)
                        {
                            thread4.Start();
                        }
                    }
                }
            }
        }
    }