Commit 93bf158e authored by Xavier de Blas's avatar Xavier de Blas

Server code started (connects to DB and uses chronojump methods). Fixed bug: 353051

separating events and eventExecutions, for calling event definitions from the server without the need of gtk or chronopic: done event, jump and jumpRj. Rest of events are unusable now.
Added src/execute/event.cs src/execute/jump.cs

Fixed bug: When a event is deleted, if it gets updated on eventWindowGraph, chronojump chrases (chrashed when there are no events of this person).
parent c1b5249b
......@@ -26,7 +26,9 @@ CHRONOJUMP_DEP_GRAPHS = src/stats/graphs/graphData.cs src/stats/graphs/graphSeri
CHRONOJUMP_DEP_SQLITE = src/sqlite/main.cs src/sqlite/preferences.cs src/sqlite/person.cs src/sqlite/session.cs src/sqlite/jump.cs src/sqlite/jumpType.cs src/sqlite/run.cs src/sqlite/runType.cs src/sqlite/personSession.cs src/sqlite/stat.cs src/sqlite/pulse.cs src/sqlite/pulseType.cs
CHRONOJUMP_DEP = src/chronojump.cs src/person.cs src/event.cs src/jump.cs src/jumpType.cs src/run.cs src/runType.cs src/pulse.cs src/pulseType.cs src/session.cs src/exportSession.cs src/treeViewEvent.cs src/treeViewPerson.cs src/treeViewJump.cs src/treeViewRun.cs src/treeViewPulse.cs src/util.cs src/constants.cs src/report.cs src/updateProgressBar.cs src/prepareEventGraphObjects.cs $(CHRONOJUMP_DEP_GUI) $(CHRONOJUMP_DEP_STATS) $(CHRONOJUMP_DEP_GRAPHS) $(CHRONOJUMP_DEP_SQLITE) $(CHRONOJUMP_DEP_REPORT)
CHRONOJUMP_DEP_EXECUTE = src/execute/event.cs src/execute/jump.cs
CHRONOJUMP_DEP = src/chronojump.cs src/person.cs src/event.cs src/jump.cs src/jumpType.cs src/run.cs src/runType.cs src/pulse.cs src/pulseType.cs src/session.cs src/exportSession.cs src/treeViewEvent.cs src/treeViewPerson.cs src/treeViewJump.cs src/treeViewRun.cs src/treeViewPulse.cs src/util.cs src/constants.cs src/report.cs src/updateProgressBar.cs src/prepareEventGraphObjects.cs $(CHRONOJUMP_DEP_GUI) $(CHRONOJUMP_DEP_STATS) $(CHRONOJUMP_DEP_GRAPHS) $(CHRONOJUMP_DEP_SQLITE) $(CHRONOJUMP_DEP_REPORT) $(CHRONOJUMP_DEP_EXECUTE)
RESOURCES = -resource:glade/chronojump.glade,chronojump.glade
CHRONOJUMP_LIB = -pkg:gtk-sharp -pkg:glade-sharp -r:System.Data -r:Mono.Data.SqliteClient
......
CHANGELOG:
20 nov 2006
Server code started (connects to DB and uses chronojump methods).
Fixed bug: 353051
separating events and eventExecutions, for calling event
definitions from the server without the need of gtk or chronopic: done
event, jump and jumpRj. Rest of events are unusable now.
Added src/execute/event.cs src/execute/jump.cs
Fixed bug: When a event is deleted, if it gets updated on eventWindowGraph,
chronojump chrases (chrashed when there are no events of this person).
6 nov 2006
On windows report file has extension "htm" (linux "html")
Fixed tf in rjEvolution graph
......
No preview for this file type
......@@ -207,6 +207,8 @@ public class ChronoJump
private static Run currentRun;
private static RunInterval currentRunInterval;
private static Pulse currentPulse;
private static EventExecute currentEventExecute;
//Used by Cancel and Finish
......@@ -253,6 +255,7 @@ public class ChronoJump
PulseExtraWindow pulseExtraWin;
ConfirmWindowJumpRun confirmWinJumpRun; //for deleting jumps and RJ jumps (and runs)
ErrorWindow errorWin;
StatsWindow statsWin;
ReportWindow reportWin;
......@@ -1590,6 +1593,8 @@ public class ChronoJump
private void on_cancel_clicked (object o, EventArgs args)
{
//this will cancel jumps or runs
currentEventExecute.Cancel = true;
/*
switch (currentEventIs) {
case eventType.JUMP:
if (currentJumpType.IsRepetitive) {
......@@ -1613,6 +1618,7 @@ public class ChronoJump
Console.WriteLine("on_cancel_clicked: default (bug?)");
break;
}
*/
//unhide event buttons for next event
sensitiveGuiEventDone();
......@@ -1620,6 +1626,8 @@ public class ChronoJump
private void on_finish_clicked (object o, EventArgs args)
{
currentEventExecute.Finish = true;
/*
//this will finish jumps or runs
switch (currentEventIs) {
case eventType.JUMP:
......@@ -1637,6 +1645,7 @@ public class ChronoJump
break;
}
*/
//unhide event buttons for next event
sensitiveGuiEventDone();
}
......@@ -1767,6 +1776,7 @@ public class ChronoJump
eventExecuteWin.ButtonUpdate.Clicked -= new EventHandler(on_update_clicked); //if we don't do this, on_update_clicked it's called 'n' times when 'n' events are don
eventExecuteWin.ButtonUpdate.Clicked += new EventHandler(on_update_clicked);
/*
currentJump = new Jump(eventExecuteWin, currentPerson.UniqueID, currentPerson.Name,
currentSession.UniqueID, currentJumpType.Name, myFall, jumpWeight,
cp, appbar2, app1, prefsDigitsNumber);
......@@ -1780,6 +1790,20 @@ public class ChronoJump
currentJump.ManageFall();
currentJump.FakeButtonFinished.Clicked += new EventHandler(on_jump_finished);
*/
currentEventExecute = new JumpExecute(eventExecuteWin, currentPerson.UniqueID, currentPerson.Name,
currentSession.UniqueID, currentJumpType.Name, myFall, jumpWeight,
cp, appbar2, app1, prefsDigitsNumber);
if (simulated)
currentEventExecute.SimulateInitValues(rand);
if( currentJumpType.StartIn )
currentEventExecute.Manage();
else
currentEventExecute.ManageFall();
currentEventExecute.FakeButtonFinished.Clicked += new EventHandler(on_jump_finished);
}
/*
......@@ -1788,25 +1812,30 @@ public class ChronoJump
private void on_update_clicked (object o, EventArgs args) {
Console.WriteLine("--On_update_clicked--");
switch (currentEventIs) {
case eventType.JUMP:
if(currentJumpType.IsRepetitive)
eventExecuteWin.PrepareJumpReactiveGraph(
Util.GetLast(currentJumpRj.TvString), Util.GetLast(currentJumpRj.TcString),
currentJumpRj.TvString, currentJumpRj.TcString);
else
eventExecuteWin.PrepareJumpSimpleGraph(currentJump.Tv, currentJump.Tc);
break;
case eventType.RUN:
if(currentRunType.HasIntervals)
eventExecuteWin.PrepareRunIntervalGraph(currentRunInterval.DistanceInterval,
Util.GetLast(currentRunInterval.IntervalTimesString), currentRunInterval.IntervalTimesString);
else
eventExecuteWin.PrepareRunSimpleGraph(currentRun.Time, currentRun.Speed);
break;
case eventType.PULSE:
try {
switch (currentEventIs) {
case eventType.JUMP:
if(currentJumpType.IsRepetitive)
eventExecuteWin.PrepareJumpReactiveGraph(
Util.GetLast(currentJumpRj.TvString), Util.GetLast(currentJumpRj.TcString),
currentJumpRj.TvString, currentJumpRj.TcString);
else
eventExecuteWin.PrepareJumpSimpleGraph(currentJump.Tv, currentJump.Tc);
break;
case eventType.RUN:
if(currentRunType.HasIntervals)
eventExecuteWin.PrepareRunIntervalGraph(currentRunInterval.DistanceInterval,
Util.GetLast(currentRunInterval.IntervalTimesString), currentRunInterval.IntervalTimesString);
else
eventExecuteWin.PrepareRunSimpleGraph(currentRun.Time, currentRun.Speed);
break;
case eventType.PULSE:
eventExecuteWin.PreparePulseGraph(Util.GetLast(currentPulse.TimesString), currentPulse.TimesString);
break;
break;
}
}
catch {
errorWin = ErrorWindow.Show(app1, Catalog.GetString("Cannot update. Probably this event was deleted."));
}
}
......@@ -1815,12 +1844,17 @@ public class ChronoJump
private void on_jump_finished (object o, EventArgs args)
{
currentJump.FakeButtonFinished.Clicked -= new EventHandler(on_jump_finished);
//currentJump.FakeButtonFinished.Clicked -= new EventHandler(on_jump_finished);
currentEventExecute.FakeButtonFinished.Clicked -= new EventHandler(on_jump_finished);
if ( ! currentJump.Cancel ) {
//if ( ! currentJump.Cancel ) {
if ( ! currentEventExecute.Cancel ) {
lastEventWas = eventType.JUMP;
lastJumpIsReactive = false;
currentJump = (Jump) currentEventExecute.EventDone;
//Console.WriteLine("JF: TV{0}", currentJump.Tv);
//Console.WriteLine("JF: TC{0}", currentJump.Tc);
myTreeViewJumps.Add(currentPerson.Name, currentJump);
if(createdStatsWin) {
......@@ -1899,7 +1933,6 @@ public class ChronoJump
on_rj_accepted(o, args);
}
}
private void on_rj_accepted (object o, EventArgs args)
{
double myLimit = 0;
......@@ -1952,10 +1985,11 @@ public class ChronoJump
eventExecuteWin.ButtonFinish.Clicked += new EventHandler(on_finish_clicked);
//when user clicks on update the eventExecute window
//(for showing with his new confgured values: max, min and guides
//(for showing with his new configured values: max, min and guides
eventExecuteWin.ButtonUpdate.Clicked -= new EventHandler(on_update_clicked); //if we don't do this, on_update_clicked it's called 'n' times when 'n' events are don
eventExecuteWin.ButtonUpdate.Clicked += new EventHandler(on_update_clicked);
/*
currentJumpRj = new JumpRj(eventExecuteWin, currentPerson.UniqueID, currentPerson.Name,
currentSession.UniqueID, currentJumpType.Name, myFall, jumpWeight,
myLimit, currentJumpType.JumpsLimited,
......@@ -1969,20 +2003,38 @@ public class ChronoJump
currentJumpRj.Manage();
currentJumpRj.FakeButtonFinished.Clicked += new EventHandler(on_jump_rj_finished);
*/
currentEventExecute = new JumpRjExecute(eventExecuteWin, currentPerson.UniqueID, currentPerson.Name,
currentSession.UniqueID, currentJumpType.Name, myFall, jumpWeight,
myLimit, currentJumpType.JumpsLimited,
cp, appbar2, app1, prefsDigitsNumber, allowFinishRjAfterTime);
//suitable for limited by jump and time
//simulated always simulate limited by jumps
if(simulated)
currentEventExecute.SimulateInitValues(rand);
currentEventExecute.Manage();
currentEventExecute.FakeButtonFinished.Clicked += new EventHandler(on_jump_rj_finished);
}
private void on_jump_rj_finished (object o, EventArgs args)
{
Console.WriteLine("ON JUMP RJ FINISHED");
currentJumpRj.FakeButtonFinished.Clicked -= new EventHandler(on_jump_rj_finished);
//currentJumpRj.FakeButtonFinished.Clicked -= new EventHandler(on_jump_rj_finished);
currentEventExecute.FakeButtonFinished.Clicked -= new EventHandler(on_jump_rj_finished);
if ( ! currentJumpRj.Cancel ) {
//if ( ! currentJumpRj.Cancel ) {
if ( ! currentEventExecute.Cancel ) {
lastEventWas = eventType.JUMP;
lastJumpIsReactive = true;
currentJumpRj = (JumpRj) currentEventExecute.EventDone;
//if user clicked in finish earlier
if(currentJumpRj.Finish) {
//if(currentJumpRj.Finish) {
if(currentEventExecute.Finish) {
currentJumpRj.Jumps = Util.GetNumberOfJumps(currentJumpRj.TvString, false);
if(currentJumpRj.JumpsLimited) {
currentJumpRj.Limited = currentJumpRj.Jumps.ToString() + "J";
......@@ -2011,7 +2063,6 @@ public class ChronoJump
sensitiveGuiEventDone();
}
/* ---------------------------------------------------------
* ---------------- RUNS EXECUTION (no interval) ----------
* --------------------------------------------------------
......@@ -2076,6 +2127,7 @@ public class ChronoJump
//suitable for all runs not repetitive
private void on_normal_run_activate (object o, EventArgs args)
{
/*
if (o == (object) button_run_20m || o == (object) menuitem_20m) {
currentRunType = new RunType("20m");
} else if (o == (object) button_run_100m || o == (object) menuitem_100m) {
......@@ -2110,11 +2162,13 @@ public class ChronoJump
notebook_change(2);
//show the event doing window
*/
/*
double myLimit = 3; //3 phases for show the Dj
if( currentJumpType.StartIn )
myLimit = 2; //2 for normal jump
*/
/*
double myLimit = 3; //same for startingIn than out (before)
eventExecuteWin = EventExecuteWindow.Show(
......@@ -2146,8 +2200,10 @@ public class ChronoJump
currentRun.Manage();
currentRun.FakeButtonFinished.Clicked += new EventHandler(on_run_finished);
*/
}
/*
private void on_run_finished (object o, EventArgs args)
{
currentRun.FakeButtonFinished.Clicked -= new EventHandler(on_run_finished);
......@@ -2172,7 +2228,7 @@ public class ChronoJump
//unhide buttons that allow jumping, running
sensitiveGuiEventDone();
}
*/
/* ---------------------------------------------------------
* ---------------- RUNS EXECUTION (interval) ----------
......@@ -2234,6 +2290,7 @@ public class ChronoJump
private void on_run_interval_accepted (object o, EventArgs args)
{
/*
Console.WriteLine("run interval accepted");
//if distance can be always different in this run,
......@@ -2297,8 +2354,10 @@ public class ChronoJump
currentRunInterval.Manage();
currentRunInterval.FakeButtonFinished.Clicked += new EventHandler(on_run_interval_finished);
*/
}
/*
private void on_run_interval_finished (object o, EventArgs args)
{
currentRunInterval.FakeButtonFinished.Clicked -= new EventHandler(on_run_interval_finished);
......@@ -2335,6 +2394,7 @@ public class ChronoJump
//unhide buttons that allow jumping, running
sensitiveGuiEventDone();
}
*/
/* ---------------------------------------------------------
* ---------------- PULSES EXECUTION ----------- ----------
......@@ -2400,6 +2460,7 @@ public class ChronoJump
private void on_pulse_accepted (object o, EventArgs args)
{
/*
Console.WriteLine("pulse accepted");
double pulseStep = 0;
......@@ -2450,8 +2511,10 @@ public class ChronoJump
currentPulse.Manage();
currentPulse.FakeButtonFinished.Clicked += new EventHandler(on_pulse_finished);
*/
}
/*
private void on_pulse_finished (object o, EventArgs args)
{
Console.WriteLine("pulse finished");
......@@ -2460,7 +2523,7 @@ public class ChronoJump
if ( ! currentPulse.Cancel ) {
lastEventWas = eventType.PULSE;
*/
/*
* CURRENTLY NOT NEEDED... check
//if user clicked in finish earlier
......@@ -2474,15 +2537,15 @@ public class ChronoJump
}
}
*/
/*
myTreeViewPulses.Add(currentPerson.Name, currentPulse);
*/
/*
if(createdStatsWin) {
statsWin.FillTreeView_stats(false, false);
}
*/
/*
//unhide buttons for delete last jump
sensitiveGuiYesEvent();
......@@ -2493,7 +2556,7 @@ public class ChronoJump
//unhide buttons that allow jumping, running
sensitiveGuiEventDone();
}
*/
/* ---------------------------------------------------------
......@@ -3216,28 +3279,36 @@ public class ChronoJump
switch (currentEventIs) {
case eventType.JUMP:
if(currentJumpType.IsRepetitive) {
/*
if(! currentJumpRj.Cancel) {
button_rj_last.Sensitive = true;
button_last.Sensitive = false;
}
*/
} else {
/*
if(! currentJump.Cancel) {
button_last.Sensitive = true;
button_rj_last.Sensitive = false;
}
*/
}
break;
case eventType.RUN:
if(currentRunType.HasIntervals) {
/*
if(! currentRunInterval.Cancel) {
button_run_interval_last.Sensitive = true;
button_run_last.Sensitive = false;
}
*/
} else {
/*
if(! currentRun.Cancel) {
button_run_last.Sensitive = true;
button_run_interval_last.Sensitive = false;
}
*/
}
break;
case eventType.PULSE:
......
......@@ -24,9 +24,6 @@ using System.Data;
using Mono.Data.SqliteClient;
using System.Text; //StringBuilder
using System.Threading;
using System.IO.Ports;
public class Event
{
......@@ -37,366 +34,11 @@ public class Event
protected string type;
protected string description;
//for finishing earlier from chronojump.cs
protected bool finish;
protected Thread thread;
//platform state variables
protected enum States {
ON,
OFF
}
//don't make the waitEvent update the progressBars, just flag this variable
//and make the PulseGTK do it
protected bool needUpdateEventProgressBar;
protected UpdateProgressBar updateProgressBar; //instance with the info to update
//also for the sensitive of finish button on jumpsReactive, runsInterval and pulses
protected bool needSensitiveButtonFinish;
//also for the graph creation
protected bool needUpdateGraph;
protected enum eventType {
JUMP, JUMPREACTIVE, RUN, RUNINTERVAL, PULSE
}
protected eventType needUpdateGraphType;
protected PrepareEventGraphJumpSimple prepareEventGraphJumpSimple; //instance with the info to create
protected PrepareEventGraphJumpReactive prepareEventGraphJumpReactive; //instance with the info to create
protected PrepareEventGraphRunSimple prepareEventGraphRunSimple; //instance with the info to create
protected PrepareEventGraphRunInterval prepareEventGraphRunInterval; //instance with the info to create
protected PrepareEventGraphPulse prepareEventGraphPulse; //instance with the info to create
protected bool needEndEvent;
//better as private and don't inherit, don't know why
//protected Chronopic cp;
//private Chronopic cp;
//a timer for controlling the time between events and update the progressbar
//timer has a delegate that updates the time progressBar.
//It starts when the first event is detected
//protected System.Timers.Timer timerClock = new System.Timers.Timer();
protected double timerCount; // every 50 milliseconds:
protected Random rand;
protected bool simulated;
protected double simulatedTimeAccumulatedBefore; //the time that passed since we started recording time
protected double simulatedTimeLast; //time in last simulated change
protected double simulatedContactTimeMin; //minimum time we accept for a new wimulated change in platform
protected double simulatedContactTimeMax; //max time we accept for a new wimulated change in platform
protected double simulatedFlightTimeMin; //minimum time we accept for a new wimulated change in platform
protected double simulatedFlightTimeMax; //max time we accept for a new wimulated change in platform
protected bool simulatedCurrentTimeIntervalsAreContact; //boolean that says if we are lloking to contact or to flight
//changes every time changes platformState
protected Chronopic.Plataforma platformState;
protected States loggedState; //log of last state
//protected Gtk.ProgressBar progressBar;
protected Gtk.Statusbar appbar;
protected Gtk.Window app;
protected int pDN;
//for raise a signal and manage it on chronojump.cs
protected Gtk.Button fakeButtonFinished;
//for cancelling from chronojump.cs
protected bool cancel;
protected EventExecuteWindow eventExecuteWin;
public Event() {
simulated = false;
//simulated = false;
}
//public virtual void Simulate(Random randSent)
public virtual void SimulateInitValues(Random randSent)
{
Console.WriteLine("From event.cs");
//look at the override on jump.cs for a sample
rand = randSent; //we send the random, because if we create here, the values will be the same for each nbew instance
simulated = true;
simulatedTimeAccumulatedBefore = 0;
simulatedTimeLast = 0;
simulatedContactTimeMin = 0; //seconds
simulatedContactTimeMax = 0; //seconds
simulatedFlightTimeMin = 0; //seconds
simulatedFlightTimeMax = 0; //seconds
simulatedCurrentTimeIntervalsAreContact = false;
}
protected virtual Chronopic.Plataforma chronopicInitialValue(Chronopic cp)
{
Chronopic.Plataforma myPlatformState = Chronopic.Plataforma.UNKNOW; //on (in platform), off (jumping), or unknow
bool ok = false;
Console.WriteLine("A1");
do {
Console.WriteLine("B");
try {
ok = cp.Read_platform(out myPlatformState);
} catch {
Console.WriteLine("Manage called after finishing constructor, do later");
}
Console.WriteLine("C");
} while (! ok);
return myPlatformState;
}
//public virtual void Manage(object o, EventArgs args)
public virtual void Manage()
{
}
//for calling it again after a confirmWindow says that you have to be in or out the platform
//and press ok button
//This method is for not having problems with the parameters of the delegate
protected void callAgainManage(object o, EventArgs args) {
Manage();
}
protected virtual void waitEvent () {
}
protected bool PulseGTK ()
{
onTimer();
//thread is (in jump, as an example), started in Manage:
//thread = new Thread(new ThreadStart(waitEvent));
//GLib.Idle.Add (new GLib.IdleHandler (PulseGTK));
//thread.Start();
//
//when waitEvent it's done (with success, for example)
//then thread is dead
if ( ! thread.IsAlive || cancel) {
//if(progressBar.Fraction == 1 || cancel) {
Console.Write("dying");
//event will be raised, and managed in chronojump.cs
//fakeButtonFinished.Click();
//Now called on write(), now work in mono1.1.6
return false;
}
Thread.Sleep (50);
Console.Write(thread.ThreadState);
return true;
//}
//return false;
}
protected void initializeTimer () {
//put onTimer count to 0 for moving the time progressBar (activiy mode)
//also in simulated, allows to change platform state
timerCount = 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 void onTimer( )
{
timerCount = timerCount + .05; //0,05 segons == 50 milliseconds, time between each call of onTimer
/* this will be good for not continue counting the time on eventWindow when event has finished
* this will help to sync chronopic data with the timerCount data
* later also, copy the value of the chronopic to the timerCount label
*/
if(needEndEvent) {
eventExecuteWin.EventEnded();
//needEndEvent = false;
} else
updateTimeProgressBar();
if(simulated) {
eventSimulatedShouldChangePlatform();
}
if(needUpdateEventProgressBar) {
Console.Write("wwa ");
//update event progressbar
eventExecuteWin.ProgressBarEventOrTimePreExecution(
updateProgressBar.IsEvent,
updateProgressBar.PercentageMode,
updateProgressBar.ValueToShow
);
needUpdateEventProgressBar = false;
Console.Write("wwb ");
}
if(needUpdateGraph) {
updateGraph();
needUpdateGraph = false;
}
if(needSensitiveButtonFinish) {
eventExecuteWin.ButtonFinishMakeSensitive();
needSensitiveButtonFinish = false;
}
//check if it should finish by time
if(shouldFinishByTime()) {
finish = true;
updateProgressBarForFinish();
}
//else
// updateTimeProgressBar();
}
//check if we should simulate an arriving or leaving the platform depending on random time values
protected virtual void eventSimulatedShouldChangePlatform()
{
double timeMax = 0;
double timeMin = 0;
if(simulatedCurrentTimeIntervalsAreContact) {
timeMax = simulatedContactTimeMax;
timeMin = simulatedContactTimeMin;
} else {
timeMax = simulatedFlightTimeMax;
timeMin = simulatedFlightTimeMin;
}
//if the time is too much, finish
if(timerCount - simulatedTimeAccumulatedBefore > timeMax) {
Console.WriteLine("EXCEEDES MAX!");
simulateChangePlatform();
}
//some random for finishing between timeMin and timeMax
if(timerCount - simulatedTimeAccumulatedBefore >= timeMin)
{
double simulatedRange = timeMax - timeMin;
//rand.NextDouble gives a value between 0 and 1
//if we multiply by the (simulatedRange * 10 +1), then we will have 4 options if the range is ,4
//check if the value is less than 1 (it's one change in four options) and if it's 1, then simulated the change platform
//double dice = 0;
double myRand = rand.NextDouble();
double dice = myRand * (simulatedRange *10 +1);
Console.WriteLine("rand: {0}, dice: {1}", myRand, dice);
if (dice < 1)
{
simulateChangePlatform();
}
}
}
protected void simulateChangePlatform() {
Console.Write("Changing!");
Console.WriteLine("PRE timeLast: {0}, timerCount: {1}, timeAccumulated: {2}", simulatedTimeLast, timerCount, simulatedTimeAccumulatedBefore);
simulatedTimeLast = timerCount - simulatedTimeAccumulatedBefore;
//simulatedTimeAccumulatedBefore = timerCount;
simulatedTimeAccumulatedBefore = Math.Round(timerCount,2);
Console.WriteLine("POST: timeLast: {0}, timerCount: {1}, timeAccumulated: {2}", simulatedTimeLast, timerCount, simulatedTimeAccumulatedBefore);
//change the boolean who points to 'which are the MINs and the MAXs
simulatedCurrentTimeIntervalsAreContact = ! simulatedCurrentTimeIntervalsAreContact;
if(platformState == Chronopic.Plataforma.ON)
platformState = Chronopic.Plataforma.OFF;
else
platformState = Chronopic.Plataforma.ON;
Console.WriteLine("Changed!");
}
private void updateGraph() {
switch(needUpdateGraphType) {
case eventType.JUMP:
Console.Write("update graph: JUMP");
eventExecuteWin.PrepareJumpSimpleGraph(
prepareEventGraphJumpSimple.tv,
prepareEventGraphJumpSimple.tc);
break;
case eventType.JUMPREACTIVE:
Console.Write("update graph: JUMPREACTIVE");
eventExecuteWin.PrepareJumpReactiveGraph(
prepareEventGraphJumpReactive.lastTv,
prepareEventGraphJumpReactive.lastTc,
prepareEventGraphJumpReactive.tvString,
prepareEventGraphJumpReactive.tcString);
break;
case eventType.RUN:
Console.Write("update graph: RUN");
eventExecuteWin.PrepareRunSimpleGraph(
prepareEventGraphRunSimple.time,
prepareEventGraphRunSimple.speed);
break;
case eventType.RUNINTERVAL:
Console.Write("update graph: RUNINTERVAL");
eventExecuteWin.PrepareRunIntervalGraph(
prepareEventGraphRunInterval.distance,
prepareEventGraphRunInterval.lastTime,
prepareEventGraphRunInterval.timesString);
break;
case eventType.PULSE:
Console.Write("update graph: PULSE");
eventExecuteWin.PreparePulseGraph(
prepareEventGraphPulse.lastTime,
prepareEventGraphPulse.timesString);
break;
}
}
protected virtual bool shouldFinishByTime() {
return true;
}
//called by the GTK loop (can call eventExecuteWin directly
protected virtual void updateProgressBarForFinish() {
}
//called by the GTK loop (can call eventExecuteWin directly
protected virtual void updateTimeProgressBar() {
}
protected virtual void write() {
}
//from confirm_window cancel button (thread has not started)
//this is NOT called when a event has started and user click on "Cancel"
protected void cancel_event(object o, EventArgs args)
{
cancel = true;
//event will be raised, and managed in chronojump.cs
fakeButtonFinished.Click();
}
public Gtk.Button FakeButtonFinished
{
get {
return fakeButtonFinished;
}
}