protected override void write() { int totalPulsesNum = 0; totalPulsesNum = Util.GetNumberOfJumps(timesString, false); uniqueID = SqlitePulse.Insert(false, Constants.PulseTable, "NULL", personID, sessionID, type, fixedPulse, totalPulsesNum, timesString, "", Util.BoolToNegativeInt(simulated) //description ); //define the created object eventDone = new Pulse(uniqueID, personID, sessionID, type, fixedPulse, totalPulsesNum, timesString, "", Util.BoolToNegativeInt(simulated)); //string myStringPush = Catalog.GetString("Last pulse") + ": " + personName + " " + type ; if (simulated) { feedbackMessage = Catalog.GetString(Constants.SimulatedMessage); } else { feedbackMessage = ""; } needShowFeedbackMessage = true; //app1.PreparePulseGraph(Util.GetLast(timesString), timesString); PrepareEventGraphPulseObject = new PrepareEventGraphPulse(Util.GetLast(timesString), timesString); needUpdateGraphType = eventType.PULSE; needUpdateGraph = true; needEndEvent = true; //used for hiding some buttons on eventWindow, and also for updateTimeProgressBar here }
protected override void write() { int totalPulsesNum = 0; totalPulsesNum = Util.GetNumberOfJumps(timesString, false); uniqueID = SqlitePulse.Insert(false, Constants.PulseTable, "NULL", personID, sessionID, type, fixedPulse, totalPulsesNum, timesString, "", Util.BoolToNegativeInt(simulated) //description ); //define the created object eventDone = new Pulse(uniqueID, personID, sessionID, type, fixedPulse, totalPulsesNum, timesString, "", Util.BoolToNegativeInt(simulated)); //string myStringPush = Catalog.GetString("Last pulse") + ": " + personName + " " + type ; if(simulated) feedbackMessage = Catalog.GetString(Constants.SimulatedMessage); else feedbackMessage = ""; needShowFeedbackMessage = true; //event will be raised, and managed in chronojump.cs fakeButtonFinished.Click(); //app1.PreparePulseGraph(Util.GetLast(timesString), timesString); PrepareEventGraphPulseObject = new PrepareEventGraphPulse(Util.GetLast(timesString), timesString); needUpdateGraphType = eventType.PULSE; needUpdateGraph = true; needEndEvent = true; //used for hiding some buttons on eventWindow, and also for updateTimeProgressBar here }
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; } }
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; } }