protected override void waitEvent() { double timestamp = 0; double timestampFirstContact = 0; //used when runPhase == runPhases.PLATFORM_INI_YES_TIME; double timestampDCFlightTimes = -1; //sum of the flight times that happen in small time double timestampDCContactTimes = -1;//sum of the contact times that happen in small time double timestampDCn = 0; //number of flight times bool success = false; bool ok; do { if(simulated) ok = true; else ok = cp.Read_event(out timestamp, out platformState); //if (ok) { if (ok && !cancel) { //LogB.Information("timestamp:" + timestamp); if (platformState == Chronopic.Plataforma.ON && loggedState == States.OFF) { //has arrived loggedState = States.ON; if(runPhase == runPhases.PRE_RUNNING) { if(speedStartArrival) { runPhase = runPhases.PLATFORM_INI_YES_TIME; initializeTimer(); //timerCount = 0 } else runPhase = runPhases.PLATFORM_INI_NO_TIME; updateProgressBar = new UpdateProgressBar ( true, //isEvent true, //tracksLimited: percentageMode 1 //just reached platform, phase 1/3 ); needUpdateEventProgressBar = true; } else { //run finished: //if started outside (behind platform) it's the second arrive //if started inside: it's the first arrive if(simulated) timestamp = simulatedTimeLast * 1000; //conversion to milliseconds //prevent double contact stuff if(checkDoubleContactMode != Constants.DoubleContact.NONE) { if(timestamp <= checkDoubleContactTime) { /* when checking double contact first time that timestamp < checkDoubleContactTime and we arrived (it's a flight time) record this time as timestampDCFlightTimes */ timestampDCn ++; timestampDCFlightTimes += timestamp; } else { if(timestampDCn > 0) { if(checkDoubleContactMode == Constants.DoubleContact.FIRST) { /* user want first flight time, then add all DC times*/ timestamp += timestampDCFlightTimes + timestampDCContactTimes; } else if(checkDoubleContactMode == Constants.DoubleContact.LAST) { //user want last flight time, take that // It doesn't change the timestamp so this is the same as: // timestamp = timestamp; } else { /* do the avg of all flights and contacts then add to last timestamp */ timestamp += (timestampDCFlightTimes + timestampDCContactTimes) / timestampDCn; } } success = true; } } if(checkDoubleContactMode == Constants.DoubleContact.NONE) success = true; if(success) { runPhase = runPhases.PLATFORM_END; //add the first contact time if PLATFORM_INI_YES_TIME if(timestampFirstContact > 0) timestamp += timestampFirstContact; time = timestamp / 1000.0; write(); //success = true; updateProgressBar = new UpdateProgressBar ( true, //isEvent true, //percentageMode //percentageToPass 3 ); needUpdateEventProgressBar = true; } } } else if (platformState == Chronopic.Plataforma.OFF && loggedState == States.ON) { //it's out, was inside (= has abandoned platform) //don't record time //change the automata state loggedState = States.OFF; if(checkDoubleContactMode != Constants.DoubleContact.NONE && timestampDCn > 0) timestampDCContactTimes += timestamp; else { if(runPhase == runPhases.PLATFORM_INI_YES_TIME) timestampFirstContact = timestamp; else if(runPhase == runPhases.PLATFORM_INI_NO_TIME) initializeTimer(); //timerCount = 0 //update event progressbar updateProgressBar = new UpdateProgressBar ( true, //isEvent true, //percentageMode 2 //normal run, phase 2/3 ); needUpdateEventProgressBar = true; feedbackMessage = ""; needShowFeedbackMessage = true; runPhase = runPhases.RUNNING; } } } } while ( ! success && ! cancel ); if(cancel) { //event will be raised, and managed in chronojump.cs fakeButtonFinished.Click(); totallyCancelled = true; } }
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(); }
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(); }
protected override void waitEvent() { double timestamp = 0; double timestampFirstContact = 0; //used when runPhase == runPhases.PLATFORM_INI_YES_TIME; double timestampDCFlightTimes = -1; //sum of the flight times that happen in small time double timestampDCContactTimes = -1; //sum of the contact times that happen in small time double timestampDCn = 0; //number of flight times bool success = false; bool ok; do { if (simulated) { ok = true; } else { ok = cp.Read_event(out timestamp, out platformState); } //if (ok) { if (ok && !cancel) { //LogB.Information("timestamp:" + timestamp); if (platformState == Chronopic.Plataforma.ON && loggedState == States.OFF) { //has arrived loggedState = States.ON; if (runPhase == runPhases.PRE_RUNNING) { if (speedStartArrival) { runPhase = runPhases.PLATFORM_INI_YES_TIME; initializeTimer(); //timerCount = 0 } else { runPhase = runPhases.PLATFORM_INI_NO_TIME; } updateProgressBar = new UpdateProgressBar( true, //isEvent true, //tracksLimited: percentageMode 1 //just reached platform, phase 1/3 ); needUpdateEventProgressBar = true; } else { //run finished: //if started outside (behind platform) it's the second arrive //if started inside: it's the first arrive if (simulated) { timestamp = simulatedTimeLast * 1000; //conversion to milliseconds } //prevent double contact stuff if (checkDoubleContactMode != Constants.DoubleContact.NONE) { if (timestamp <= checkDoubleContactTime) { /* * when checking double contact * first time that timestamp < checkDoubleContactTime * and we arrived (it's a flight time) * record this time as timestampDCFlightTimes */ timestampDCn++; timestampDCFlightTimes += timestamp; } else { if (timestampDCn > 0) { if (checkDoubleContactMode == Constants.DoubleContact.FIRST) { /* user want first flight time, * then add all DC times*/ timestamp += timestampDCFlightTimes + timestampDCContactTimes; } else if (checkDoubleContactMode == Constants.DoubleContact.LAST) { //user want last flight time, take that timestamp = timestamp; } else /* do the avg of all flights and contacts * then add to last timestamp */ { timestamp += (timestampDCFlightTimes + timestampDCContactTimes) / timestampDCn; } } success = true; } } if (checkDoubleContactMode == Constants.DoubleContact.NONE) { success = true; } if (success) { runPhase = runPhases.PLATFORM_END; //add the first contact time if PLATFORM_INI_YES_TIME if (timestampFirstContact > 0) { timestamp += timestampFirstContact; } time = timestamp / 1000.0; write(); //success = true; updateProgressBar = new UpdateProgressBar( true, //isEvent true, //percentageMode //percentageToPass 3 ); needUpdateEventProgressBar = true; } } } else if (platformState == Chronopic.Plataforma.OFF && loggedState == States.ON) { //it's out, was inside (= has abandoned platform) //don't record time //change the automata state loggedState = States.OFF; if (checkDoubleContactMode != Constants.DoubleContact.NONE && timestampDCn > 0) { timestampDCContactTimes += timestamp; } else { if (runPhase == runPhases.PLATFORM_INI_YES_TIME) { timestampFirstContact = timestamp; } else if (runPhase == runPhases.PLATFORM_INI_NO_TIME) { initializeTimer(); //timerCount = 0 } //update event progressbar updateProgressBar = new UpdateProgressBar( true, //isEvent true, //percentageMode 2 //normal run, phase 2/3 ); needUpdateEventProgressBar = true; feedbackMessage = ""; needShowFeedbackMessage = true; runPhase = runPhases.RUNNING; } } } } while (!success && !cancel); if (cancel) { //event will be raised, and managed in chronojump.cs fakeButtonFinished.Click(); totallyCancelled = true; } }
protected override void waitEvent() { double timestamp = 0; bool success = false; bool ok; do { if(simulated) ok = true; else ok = cp.Read_event(out timestamp, out platformState); //if (ok) { if (ok && !cancel) { if (platformState == Chronopic.Plataforma.ON && loggedState == States.OFF) { //has arrived loggedState = States.ON; if(runPhase == runPhases.PRE_RUNNING) { runPhase = runPhases.PLATFORM_INI; updateProgressBar = new UpdateProgressBar ( true, //isEvent true, //tracksLimited: percentageMode 1 //just reached platform, phase 1/3 ); needUpdateEventProgressBar = true; } else { //run finished: //if started outside (behind platform) it's the second arrive //if started inside: it's the first arrive if(simulated) timestamp = simulatedTimeLast * 1000; //conversion to milliseconds time = timestamp / 1000.0; write(); success = true; updateProgressBar = new UpdateProgressBar ( true, //isEvent true, //percentageMode //percentageToPass 3 ); needUpdateEventProgressBar = true; runPhase = runPhases.PLATFORM_END; } } else if (platformState == Chronopic.Plataforma.OFF && loggedState == States.ON) { //it's out, was inside (= has abandoned platform) //don't record time initializeTimer(); //update event progressbar updateProgressBar = new UpdateProgressBar ( true, //isEvent true, //percentageMode 2 //normal run, phase 2/3 ); needUpdateEventProgressBar = true; feedbackMessage = ""; needShowFeedbackMessage = true; //change the automata state loggedState = States.OFF; runPhase = runPhases.RUNNING; } } } while ( ! success && ! cancel ); if(cancel) { //event will be raised, and managed in chronojump.cs fakeButtonFinished.Click(); totallyCancelled = true; } }