Example #1
0
    protected override void waitEvent()
    {
        double timestamp = 0;
        bool   success   = false;
        string equal     = "";

        bool ok;

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

        do
        {
            if (simulated)
            {
                ok = true;
            }
            else
            {
                ok = cp.Read_event(out timestamp, out platformState);
            }


            if (ok && !cancel && !finish)
            {
                if (platformState == Chronopic.Plataforma.ON && loggedState == States.OFF)
                {
                    //has arrived

                    //if we arrive to the platform for the first time, don't record anything
                    if (pulsePhase == pulsePhases.WAIT_FIRST_EVENT)
                    {
                        pulsePhase = pulsePhases.DOING;
                        //pulse starts
                        initializeTimer();

                        feedbackMessage         = "";
                        needShowFeedbackMessage = true;
                    }
                    else
                    {
                        //is not the first pulse
                        if (totalPulsesNum == -1)
                        {
                            //if is "unlimited",
                            //then play with the progress bar until finish button is pressed
                            if (simulated)
                            {
                                timestamp = simulatedTimeLast * 1000;                                         //conversion to milliseconds
                            }
                            if (timesString.Length > 0)
                            {
                                equal = "=";
                            }
                            timesString = timesString + equal + (contactTime / 1000.0 + timestamp / 1000.0).ToString();
                            tracks++;

                            //update event progressbar
                            //progressBarEventOrTimePreExecution(
                            updateProgressBar = new UpdateProgressBar(
                                true,                                                 //isEvent
                                false,                                                //activityMode
                                tracks
                                );

                            needUpdateEventProgressBar = true;

                            //update graph
                            //preparePulseGraph(timestamp/1000.0, timesString);
                            PrepareEventGraphPulseObject = new PrepareEventGraphPulse(timestamp / 1000.0, timesString);
                            needUpdateGraphType          = eventType.PULSE;
                            needUpdateGraph = true;

                            //put button_finish as sensitive when first jump is done (there's something recordable)
                            if (tracks == 1)
                            {
                                needSensitiveButtonFinish = true;
                            }
                        }
                        else
                        {
                            //is not the first pulse, and it's limited by tracks (ticks)
                            tracks++;

                            if (simulated)
                            {
                                timestamp = simulatedTimeLast * 1000;                                         //conversion to milliseconds
                            }
                            if (timesString.Length > 0)
                            {
                                equal = "=";
                            }
                            timesString = timesString + equal + (contactTime / 1000.0 + timestamp / 1000.0).ToString();

                            if (tracks >= totalPulsesNum)
                            {
                                //finished
                                write();
                                success    = true;
                                pulsePhase = pulsePhases.DONE;
                            }

                            //update event progressbar
                            //progressBarEventOrTimePreExecution(
                            updateProgressBar = new UpdateProgressBar(
                                true,                                                 //isEvent
                                true,                                                 //PercentageMode
                                tracks
                                );
                            needUpdateEventProgressBar = true;

                            //update graph
                            //preparePulseGraph(timestamp/1000.0, timesString);
                            PrepareEventGraphPulseObject = new PrepareEventGraphPulse(timestamp / 1000.0, timesString);
                            needUpdateGraphType          = eventType.PULSE;
                            needUpdateGraph = true;

                            //put button_finish as sensitive when first jump is done (there's something recordable)
                            if (tracks == 1)
                            {
                                needSensitiveButtonFinish = true;
                            }
                        }
                    }

                    //change the automata state
                    loggedState = States.ON;
                }
                else if (platformState == Chronopic.Plataforma.OFF && loggedState == States.ON)
                {
                    //it's out, was inside (= has abandoned platform)

                    if (simulated)
                    {
                        timestamp = simulatedTimeLast * 1000;                                 //conversion to milliseconds
                    }
                    contactTime = timestamp;

                    //change the automata state
                    loggedState = States.OFF;
                }
            }
        } while (!success && !cancel && !finish);

        if (finish)
        {
            write();
            pulsePhase = pulsePhases.DONE;
        }
    }
Example #2
0
    protected override void waitEvent()
    {
        double timestamp = 0;
            bool success = false;
            string equal = "";

            bool ok;

            do {
                if(simulated)
                    ok = true;
                else
                    ok = cp.Read_event(out timestamp, out platformState);

                if (ok && !cancel && !finish) {
                    if (platformState == Chronopic.Plataforma.ON && loggedState == States.OFF) {
                        //has arrived

                        //if we arrive to the platform for the first time, don't record anything
                        if(pulsePhase == pulsePhases.WAIT_FIRST_EVENT) {
                            pulsePhase = pulsePhases.DOING;
                            //pulse starts
                            initializeTimer();

                            feedbackMessage = "";
                            needShowFeedbackMessage = true;
                        } else {
                            //is not the first pulse
                            if(totalPulsesNum == -1) {
                                //if is "unlimited",
                                //then play with the progress bar until finish button is pressed
                                if(simulated)
                                    timestamp = simulatedTimeLast * 1000; //conversion to milliseconds
                                if(timesString.Length > 0) { equal = "="; }
                                timesString = timesString + equal + (contactTime/1000.0 + timestamp/1000.0).ToString();
                                tracks ++;

                                //update event progressbar
                                //progressBarEventOrTimePreExecution(
                                updateProgressBar= new UpdateProgressBar (
                                        true, //isEvent
                                        false, //activityMode
                                        tracks
                                        );

                                needUpdateEventProgressBar = true;

                                //update graph
                                //preparePulseGraph(timestamp/1000.0, timesString);
                                PrepareEventGraphPulseObject = new PrepareEventGraphPulse(timestamp/1000.0, timesString);
                                needUpdateGraphType = eventType.PULSE;
                                needUpdateGraph = true;

                                //put button_finish as sensitive when first jump is done (there's something recordable)
                                if(tracks == 1)
                                    needSensitiveButtonFinish = true;
                            }
                            else {
                                //is not the first pulse, and it's limited by tracks (ticks)
                                tracks ++;

                                if(simulated)
                                    timestamp = simulatedTimeLast * 1000; //conversion to milliseconds
                                if(timesString.Length > 0) { equal = "="; }
                                timesString = timesString + equal + (contactTime/1000.0 + timestamp/1000.0).ToString();

                                if(tracks >= totalPulsesNum)
                                {
                                    //finished
                                    write();
                                    success = true;
                                    pulsePhase = pulsePhases.DONE;
                                }

                                //update event progressbar
                                //progressBarEventOrTimePreExecution(
                                updateProgressBar= new UpdateProgressBar (
                                        true, //isEvent
                                        true, //PercentageMode
                                        tracks
                                        );
                                needUpdateEventProgressBar = true;

                                //update graph
                                //preparePulseGraph(timestamp/1000.0, timesString);
                                PrepareEventGraphPulseObject = new PrepareEventGraphPulse(timestamp/1000.0, timesString);
                                needUpdateGraphType = eventType.PULSE;
                                needUpdateGraph = true;

                                //put button_finish as sensitive when first jump is done (there's something recordable)
                                if(tracks == 1)
                                    needSensitiveButtonFinish = true;
                            }
                        }

                        //change the automata state
                        loggedState = States.ON;
                    }
                    else if (platformState == Chronopic.Plataforma.OFF && loggedState == States.ON) {
                        //it's out, was inside (= has abandoned platform)

                        if(simulated)
                            timestamp = simulatedTimeLast * 1000; //conversion to milliseconds
                        contactTime = timestamp;

                        //change the automata state
                        loggedState = States.OFF;
                    }
                }
            } while ( ! success && ! cancel && ! finish );

            if (finish) {
                write();
                pulsePhase = pulsePhases.DONE;
                totallyFinished= true;
            }
            if(cancel || finish) {
                //event will be raised, and managed in chronojump.cs
                fakeButtonFinished.Click();

                totallyCancelled = true;
            }
    }
Example #3
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, gstreamer);

            //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, gstreamer);

            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();
        }
    }
Example #4
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;
            totallyCancelled = false;

            //prepare jump for being finished earlier if desired
            finish = false;
            totallyFinished= 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));
            thread.Start();
        }
    }