[chronojump] uploading changes to git



commit 771139e14ca187642da84fd2e8da8c8d94a58b37
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu Apr 23 15:48:25 2009 +0200

    uploading changes to git
---
 Makefile                                 |    2 +-
 build/data/chronojump.prg                |  Bin 2887168 -> 2898944 bytes
 build/data/chronojump_mini.prg           |  Bin 39936 -> 39936 bytes
 build/data/utils/linux/sqlite-2.8.17.bin |  Bin 312364 -> 312364 bytes
 build/data/utils/linux/sqlite3-3.5.0.bin |  Bin 278820 -> 278820 bytes
 build/data/version.txt                   |    2 +-
 changelog.txt                            |   24 +++
 glade/chronojump.glade                   |   53 +++++--
 src/chronojump.cs                        |   11 ++
 src/constants.cs                         |    5 +-
 src/execute/event.cs                     |   29 ++++
 src/execute/multiChronopic.cs            |  163 +++++++++++++++----
 src/gui/chronojump.cs                    |  270 +++++++++++++++++++++---------
 src/gui/eventExecute.cs                  |    1 -
 src/gui/splash.cs                        |    3 +
 src/multiChronopic.cs                    |  265 +++++++++++++++++++++++++++++-
 src/server.cs                            |    8 +
 src/sqlite/multiChronopic.cs             |   51 ++++--
 src/treeViewEvent.cs                     |    2 +-
 src/treeViewMultiChronopic.cs            |  124 ++++++++++++---
 src/util.cs                              |    9 +-
 version.txt                              |    2 +-
 22 files changed, 862 insertions(+), 162 deletions(-)

diff --git a/Makefile b/Makefile
index 0a571d2..ba7cd44 100644
--- a/Makefile
+++ b/Makefile
@@ -12,7 +12,7 @@ CC = gcc
 CFLAGS = -Wall
 
 #-- C# Compilator
-MCS = gmcs
+MCS = gmcs2
 
 BUILD_DIR = build/data
 
diff --git a/build/data/chronojump.prg b/build/data/chronojump.prg
index 00c4c22..8f21fe0 100755
Binary files a/build/data/chronojump.prg and b/build/data/chronojump.prg differ
diff --git a/build/data/chronojump_mini.prg b/build/data/chronojump_mini.prg
index e48c8dd..1729d0c 100755
Binary files a/build/data/chronojump_mini.prg and b/build/data/chronojump_mini.prg differ
diff --git a/build/data/utils/linux/sqlite-2.8.17.bin b/build/data/utils/linux/sqlite-2.8.17.bin
old mode 100644
new mode 100755
diff --git a/build/data/utils/linux/sqlite3-3.5.0.bin b/build/data/utils/linux/sqlite3-3.5.0.bin
old mode 100644
new mode 100755
diff --git a/build/data/version.txt b/build/data/version.txt
index 29ac2e3..4eb8463 100644
--- a/build/data/version.txt
+++ b/build/data/version.txt
@@ -1 +1 @@
-0.8.2.9
+0.8.3.0
diff --git a/changelog.txt b/changelog.txt
index 5688649..e6228ba 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -1,5 +1,29 @@
 CHANGELOG.txt
 
+23 apr 2009
+	multiChronopic
+	-treeview loads ok the object
+
+22 apr 2009
+	multiChronopic:
+	-synchronozation works
+	-improvement on treeview (still don't work)
+
+21 apr 2009
+	multiChronopic:
+	-done sqlite insertion
+	-table now has starteIn cols
+	-treeview now plots header
+
+	delete a person now reloads all treeviews
+
+20 apr 2009
+	0.8.3.0
+	cancel and finish works ok with multiChronopic, no more crash on ending
+	improvements on multiChronopic graph
+
+	compiled now with gmcs2
+
 16 apr 2009
 	calendar has a new calendar icon
 	
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 2dcc449..05f13a6 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -13406,7 +13406,6 @@ suitable for agility tests)</property>
 							      <property name="padding">0</property>
 							      <property name="expand">False</property>
 							      <property name="fill">False</property>
-							      <property name="pack_type">GTK_PACK_END</property>
 							    </packing>
 							  </child>
 							</widget>
@@ -13469,7 +13468,7 @@ suitable for agility tests)</property>
 						  <property name="yscale">1</property>
 						  <property name="top_padding">0</property>
 						  <property name="bottom_padding">0</property>
-						  <property name="left_padding">12</property>
+						  <property name="left_padding">0</property>
 						  <property name="right_padding">0</property>
 
 						  <child>
@@ -13675,7 +13674,7 @@ suitable for agility tests)</property>
 						  <property name="yscale">1</property>
 						  <property name="top_padding">0</property>
 						  <property name="bottom_padding">0</property>
-						  <property name="left_padding">12</property>
+						  <property name="left_padding">0</property>
 						  <property name="right_padding">0</property>
 
 						  <child>
@@ -13868,7 +13867,7 @@ suitable for agility tests)</property>
 						  <property name="yscale">1</property>
 						  <property name="top_padding">0</property>
 						  <property name="bottom_padding">0</property>
-						  <property name="left_padding">12</property>
+						  <property name="left_padding">0</property>
 						  <property name="right_padding">0</property>
 
 						  <child>
@@ -14054,14 +14053,46 @@ suitable for agility tests)</property>
 				      </child>
 
 				      <child>
-					<widget class="GtkButton" id="button_multi_chronopic_start">
+					<widget class="GtkVBox" id="vbox184">
 					  <property name="visible">True</property>
-					  <property name="can_focus">True</property>
-					  <property name="label" translatable="yes">Start</property>
-					  <property name="use_underline">True</property>
-					  <property name="relief">GTK_RELIEF_NORMAL</property>
-					  <property name="focus_on_click">True</property>
-					  <signal name="clicked" handler="on_button_multi_chronopic_start_clicked" last_modification_time="Tue, 24 Mar 2009 23:07:49 GMT"/>
+					  <property name="homogeneous">False</property>
+					  <property name="spacing">0</property>
+
+					  <child>
+					    <widget class="GtkCheckButton" id="check_multi_sync">
+					      <property name="visible">True</property>
+					      <property name="can_focus">True</property>
+					      <property name="label" translatable="yes">Sychronize Chronopics</property>
+					      <property name="use_underline">True</property>
+					      <property name="relief">GTK_RELIEF_NORMAL</property>
+					      <property name="focus_on_click">True</property>
+					      <property name="active">True</property>
+					      <property name="inconsistent">False</property>
+					      <property name="draw_indicator">True</property>
+					    </widget>
+					    <packing>
+					      <property name="padding">0</property>
+					      <property name="expand">False</property>
+					      <property name="fill">False</property>
+					    </packing>
+					  </child>
+
+					  <child>
+					    <widget class="GtkButton" id="button_multi_chronopic_start">
+					      <property name="visible">True</property>
+					      <property name="can_focus">True</property>
+					      <property name="label" translatable="yes">Start</property>
+					      <property name="use_underline">True</property>
+					      <property name="relief">GTK_RELIEF_NORMAL</property>
+					      <property name="focus_on_click">True</property>
+					      <signal name="clicked" handler="on_button_multi_chronopic_start_clicked" last_modification_time="Tue, 24 Mar 2009 23:07:49 GMT"/>
+					    </widget>
+					    <packing>
+					      <property name="padding">0</property>
+					      <property name="expand">True</property>
+					      <property name="fill">True</property>
+					    </packing>
+					  </child>
 					</widget>
 					<packing>
 					  <property name="padding">0</property>
diff --git a/src/chronojump.cs b/src/chronojump.cs
index aaa5149..d777c19 100644
--- a/src/chronojump.cs
+++ b/src/chronojump.cs
@@ -302,17 +302,28 @@ public class ChronoJump
 	}
 
 	private void findVersion() {
+Console.WriteLine("--1--");
 		pingStart = true;
 		pulseGTKPingShouldEnd = false;
 		splashShowButton = true;
 		
+Console.WriteLine("--2--");
+		if(splashWin.FakeButtonCreated)
+			Console.WriteLine("\n\nCREATED\n\n");
+		else
+			Console.WriteLine("\n\nNOT CREATED, si es bloqueja, posar aquí un while (mentre no estigui creat)\n\n");
+
 		splashWin.FakeButtonCancel.Clicked += new EventHandler(on_find_version_cancelled);
 		
+Console.WriteLine("--3--");
 		versionAvailable = Server.Ping(true, progName, readVersion()); //doInsertion
 		
+Console.WriteLine("--4--");
 		splashShowButton = false;
 		Console.Write(" version:  " + versionAvailable);
+Console.WriteLine("--5--");
 		pingEnd = true;
+Console.WriteLine("--6--");
 	}
 		
 	private void on_find_version_cancelled(object o, EventArgs args) {
diff --git a/src/constants.cs b/src/constants.cs
index bef29c0..6e1e5d4 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -66,6 +66,7 @@ public class Constants
 	public const string PulseTable = "pulse";
 	public const string ReactionTimeTable = "reactionTime";
 	public const string MultiChronopicTable = "multiChronopic";
+	public const string TempMultiChronopicTable = "tempMultiChronopic"; //TODO
 
 	//tests types
 	public const string JumpTypeTable = "jumpType";
@@ -75,7 +76,6 @@ public class Constants
 	public const string PulseTypeTable = "pulseType";
 	public const string ReactionTimeTypeTable = "reactionTimeType";
 
-
 	public const string UndefinedDefault = "Undefined";
 
 	//server	
@@ -376,6 +376,9 @@ public class Constants
 
 	public static string No = Catalog.GetString("No");
 	public static string Yes = Catalog.GetString("Yes");
+
+	public static string In = Catalog.GetString("In");
+	public static string Out = Catalog.GetString("Out");
 	
 	public const string PrefVersionAvailable = "versionAvailable";
 
diff --git a/src/execute/event.cs b/src/execute/event.cs
index 02c7ff0..5e0036a 100644
--- a/src/execute/event.cs
+++ b/src/execute/event.cs
@@ -117,6 +117,17 @@ public class EventExecute
 	protected bool finish;
 	protected bool totallyFinished;
 	
+	// multi Chronopic stuff
+	protected int chronopics; 
+	protected bool totallyFinishedMulti1;
+	protected bool totallyFinishedMulti2;
+	protected bool totallyFinishedMulti3;
+	protected bool totallyFinishedMulti4;
+	protected bool totallyCancelledMulti1;
+	protected bool totallyCancelledMulti2;
+	protected bool totallyCancelledMulti3;
+	protected bool totallyCancelledMulti4;
+	
 
 
 	protected EventExecuteWindow eventExecuteWin;
@@ -430,6 +441,10 @@ public class EventExecute
 		fakeButtonFinished.Click();
 	}
 	
+	public virtual void MultiChronopicWrite(bool tempTable) {
+		Console.WriteLine("at event.cs");
+	}
+			
 	public Gtk.Button FakeButtonFinished
 	{
 		get {
@@ -467,6 +482,20 @@ public class EventExecute
 		get { return eventDone; }
 	}
 	
+	// multi Chronopic stuff
+	public int Chronopics { get { return chronopics; } }
+
+	public bool TotallyFinishedMulti1 { get { return totallyFinishedMulti1; } }
+	public bool TotallyFinishedMulti2 { get { return totallyFinishedMulti2; } }
+	public bool TotallyFinishedMulti3 { get { return totallyFinishedMulti3; } }
+	public bool TotallyFinishedMulti4 { get { return totallyFinishedMulti4; } }
+	
+	public bool TotallyCancelledMulti1 { get { return totallyCancelledMulti1; } }
+	public bool TotallyCancelledMulti2 { get { return totallyCancelledMulti2; } }
+	public bool TotallyCancelledMulti3 { get { return totallyCancelledMulti3; } }
+	public bool TotallyCancelledMulti4 { get { return totallyCancelledMulti4; } }
+
+
 	~EventExecute() {}
 	   
 }
diff --git a/src/execute/multiChronopic.cs b/src/execute/multiChronopic.cs
index 864f069..6bbfc7a 100644
--- a/src/execute/multiChronopic.cs
+++ b/src/execute/multiChronopic.cs
@@ -59,23 +59,26 @@ public class MultiChronopicExecute : EventExecute
 	string cp4InStr;
 	string cp4OutStr;
 	bool cp4StartedIn;
-	
+
+	bool syncFirst;	
+	private enum syncStates { NOTHING, CONTACTED, DONE } //done == released
 
 	static bool firstValue;
-	int chronopics; 
 	
 	public MultiChronopicExecute() {
 	}
 
 	//execution
-	public MultiChronopicExecute(EventExecuteWindow eventExecuteWin, int personID, string personName, int sessionID, 
-			Chronopic cp, Gtk.Statusbar appbar, Gtk.Window app) {
+	public MultiChronopicExecute(EventExecuteWindow eventExecuteWin, int personID, string personName, int sessionID, string type, 
+			Chronopic cp, bool syncFirst, Gtk.Statusbar appbar, Gtk.Window app) {
 		this.eventExecuteWin = eventExecuteWin;
 		this.personID = personID;
 		this.personName = personName;
 		this.sessionID = sessionID;
+		this.type = type;
 		
 		this.cp = cp;
+		this.syncFirst = syncFirst;
 		
 		this.appbar = appbar;
 		this.app = app;
@@ -84,15 +87,17 @@ public class MultiChronopicExecute : EventExecute
 		initValues();	
 	}
 	
-	public MultiChronopicExecute(EventExecuteWindow eventExecuteWin, int personID, string personName, int sessionID, 
-			Chronopic cp, Chronopic cp2, Gtk.Statusbar appbar, Gtk.Window app) {
+	public MultiChronopicExecute(EventExecuteWindow eventExecuteWin, int personID, string personName, int sessionID, string type, 
+			Chronopic cp, Chronopic cp2, bool syncFirst, Gtk.Statusbar appbar, Gtk.Window app) {
 		this.eventExecuteWin = eventExecuteWin;
 		this.personID = personID;
 		this.personName = personName;
 		this.sessionID = sessionID;
+		this.type = type;
 		
 		this.cp = cp;
 		this.cp2 = cp2;
+		this.syncFirst = syncFirst;
 		
 		this.appbar = appbar;
 		this.app = app;
@@ -101,16 +106,18 @@ public class MultiChronopicExecute : EventExecute
 		initValues();	
 	}
 	
-	public MultiChronopicExecute(EventExecuteWindow eventExecuteWin, int personID, string personName, int sessionID, 
-			Chronopic cp, Chronopic cp2, Chronopic cp3, Gtk.Statusbar appbar, Gtk.Window app) {
+	public MultiChronopicExecute(EventExecuteWindow eventExecuteWin, int personID, string personName, int sessionID, string type, 
+			Chronopic cp, Chronopic cp2, Chronopic cp3, bool syncFirst, Gtk.Statusbar appbar, Gtk.Window app) {
 		this.eventExecuteWin = eventExecuteWin;
 		this.personID = personID;
 		this.personName = personName;
 		this.sessionID = sessionID;
+		this.type = type;
 		
 		this.cp = cp;
 		this.cp2 = cp2;
 		this.cp3 = cp3;
+		this.syncFirst = syncFirst;
 		
 		this.appbar = appbar;
 		this.app = app;
@@ -119,17 +126,19 @@ public class MultiChronopicExecute : EventExecute
 		initValues();	
 	}
 
-	public MultiChronopicExecute(EventExecuteWindow eventExecuteWin, int personID, string personName, int sessionID, 
-			Chronopic cp, Chronopic cp2, Chronopic cp3, Chronopic cp4, Gtk.Statusbar appbar, Gtk.Window app) {
+	public MultiChronopicExecute(EventExecuteWindow eventExecuteWin, int personID, string personName, int sessionID, string type,
+			Chronopic cp, Chronopic cp2, Chronopic cp3, Chronopic cp4, bool syncFirst, Gtk.Statusbar appbar, Gtk.Window app) {
 		this.eventExecuteWin = eventExecuteWin;
 		this.personID = personID;
 		this.personName = personName;
 		this.sessionID = sessionID;
+		this.type = type;
 		
 		this.cp = cp;
 		this.cp2 = cp2;
 		this.cp3 = cp3;
 		this.cp4 = cp4;
+		this.syncFirst = syncFirst;
 		
 		this.appbar = appbar;
 		this.app = app;
@@ -172,6 +181,15 @@ public class MultiChronopicExecute : EventExecute
 				cp1StartedIn = false;
 			}
 		
+			//prepare jump for being cancelled if desired
+			cancel = false;
+			totallyCancelledMulti1 = false;
+
+			//prepare jump for being finished earlier if desired
+			finish = false;
+			totallyFinishedMulti1 = false;
+
+		
 			if(chronopics > 1) {
 				platformState2 = chronopicInitialValue(cp2);
 
@@ -182,6 +200,10 @@ public class MultiChronopicExecute : EventExecute
 					loggedState2 = States.OFF;
 					cp2StartedIn = false;
 				}
+			
+				totallyCancelledMulti2 = false;
+				totallyFinishedMulti2 = false;
+
 
 				if(chronopics > 2) {
 					platformState3 = chronopicInitialValue(cp3);
@@ -194,6 +216,9 @@ public class MultiChronopicExecute : EventExecute
 						cp3StartedIn = false;
 					}
 
+					totallyCancelledMulti3 = false;
+					totallyFinishedMulti3 = false;
+
 					if(chronopics > 3) {
 						platformState4 = chronopicInitialValue(cp4);
 
@@ -204,12 +229,16 @@ public class MultiChronopicExecute : EventExecute
 							loggedState4 = States.OFF;
 							cp4StartedIn = false;
 						}
+					
+						totallyCancelledMulti4 = false;
+						totallyFinishedMulti4 = false;
 					}
 				}
 			}
 		}
 
 		firstValue = true;
+			
 
 		//start thread
 		if(chronopics > 0) {
@@ -250,7 +279,6 @@ public class MultiChronopicExecute : EventExecute
 	
 	protected void waitEventPre4 () { waitEvent(cp4, platformState4, loggedState4, out cp4InStr, out cp4OutStr, 4); }
 	
-	
 	protected void waitEvent (Chronopic myCP, Chronopic.Plataforma myPS, States myLS, out string inStr, out string outStr, int cpNum)
 	{
 		double timestamp = 0;
@@ -261,6 +289,10 @@ public class MultiChronopicExecute : EventExecute
 		
 		inStr = ""; outStr = "";
 
+		syncStates syncing = syncStates.DONE;
+		if(syncFirst)
+			syncing = syncStates.NOTHING;
+
 		do {
 			ok = myCP.Read_event(out timestamp, out myPS);
 			
@@ -273,10 +305,17 @@ public class MultiChronopicExecute : EventExecute
 				//while no finished time or jumps, continue recording events
 				if ( ! success) {
 					//don't record the time until the first event of the first Chronopic
+					//this is only executed on the first chronopic that receives a change
 					if (firstValue) {
 						firstValue = false;
-						initializeTimer();
-					} else {
+						initializeTimer(); //this is for first Chronopic and only for simulated
+					}
+							
+					if(syncing == syncStates.NOTHING && myPS == Chronopic.Plataforma.ON && myLS == States.OFF) 
+						syncing = syncStates.CONTACTED;
+					else if (syncing == syncStates.CONTACTED && myPS == Chronopic.Plataforma.OFF && myLS == States.ON) 
+						syncing = syncStates.DONE;
+					else {
 						needSensitiveButtonFinish = true;
 
 						if(myPS == Chronopic.Plataforma.ON && myLS == States.OFF) {
@@ -297,15 +336,15 @@ public class MultiChronopicExecute : EventExecute
 								cp1InStr, cp1OutStr, cp2InStr, cp2OutStr, cp3InStr, cp3OutStr, cp4InStr, cp4OutStr);
 						needUpdateGraphType = eventType.MULTICHRONOPIC;
 						needUpdateGraph = true;
-					}
 
-					updateProgressBar = new UpdateProgressBar (
-							true, //isEvent
-							false, //means activity mode
-							-1 //don't show text
-							);
-					needUpdateEventProgressBar = true;
 
+						updateProgressBar = new UpdateProgressBar (
+								true, //isEvent
+								false, //means activity mode
+								-1 //don't show text
+								);
+						needUpdateEventProgressBar = true;
+					}
 				}
 
 				if(myPS == Chronopic.Plataforma.OFF)
@@ -317,16 +356,44 @@ public class MultiChronopicExecute : EventExecute
 		} while ( ! success && ! cancel && ! finish );
 	
 		if (finish) {
-			write();
-			totallyFinished = true;
+			//call write on gui/chronojump.cs, because if done in execute/MultiChronopic, 
+			//will be called n times if n chronopics are working
+			//write(false); //tempTable
+			
+			//event will be raised, and managed in chronojump.cs
+			fakeButtonFinished.Click();
+			finishThisCp(cpNum);
 		}
 		if(cancel) {
 			//event will be raised, and managed in chronojump.cs
 			fakeButtonFinished.Click();
-			totallyCancelled = true;
+			cancelThisCp(cpNum);
 		}
 	}
 	
+	private void finishThisCp (int cp) {
+		if (cp==1)
+			totallyFinishedMulti1 = true;
+		else if (cp==2)
+			totallyFinishedMulti2 = true;
+		else if (cp==3)
+			totallyFinishedMulti3 = true;
+		else // if (cp==4)
+			totallyFinishedMulti4 = true;
+		needEndEvent = true;
+	}
+
+	private void cancelThisCp (int cp) {
+		if (cp==1)
+			totallyCancelledMulti1 = true;
+		else if (cp==2)
+			totallyCancelledMulti2 = true;
+		else if (cp==3)
+			totallyCancelledMulti3 = true;
+		else // if (cp==4)
+			totallyCancelledMulti4 = true;
+	}
+
 	protected override bool shouldFinishByTime() {
 		return false; //this kind of events (simple or Dj jumps) cannot be finished by time
 	}
@@ -342,7 +409,7 @@ public class MultiChronopicExecute : EventExecute
 				*/
 	}
 
-	protected override void write()
+	public override void MultiChronopicWrite(bool tempTable)
 	{
 		Log.WriteLine("----------WRITING----------");
 		Console.WriteLine("cp1 In:" + cp1InStr);
@@ -353,11 +420,49 @@ public class MultiChronopicExecute : EventExecute
 		Console.WriteLine("cp3 Out:" + cp3OutStr + "\n");
 		Console.WriteLine("cp4 In:" + cp4InStr);
 		Console.WriteLine("cp4 Out:" + cp4OutStr + "\n");
-		
-		//event will be raised, and managed in chronojump.cs
-		fakeButtonFinished.Click();
-		
-		needEndEvent = true; //used for hiding some buttons on eventWindow
+	
+
+		if(tempTable) //TODO
+			uniqueID = SqliteMultiChronopic.Insert(false, Constants.TempMultiChronopicTable, "NULL", 
+					personID, sessionID, type,  
+					Util.BoolToInt(cp1StartedIn), Util.BoolToInt(cp2StartedIn), 
+					Util.BoolToInt(cp3StartedIn), Util.BoolToInt(cp4StartedIn),
+					cp1InStr, cp1OutStr, cp2InStr, cp2OutStr,
+					cp3InStr, cp3OutStr, cp4InStr, cp4OutStr,
+					description, Util.BoolToNegativeInt(simulated)
+					);
+		else {
+			uniqueID = SqliteMultiChronopic.Insert(false, Constants.MultiChronopicTable, "NULL", 
+					personID, sessionID, type,  
+					Util.BoolToInt(cp1StartedIn), Util.BoolToInt(cp2StartedIn), 
+					Util.BoolToInt(cp3StartedIn), Util.BoolToInt(cp4StartedIn),
+					cp1InStr, cp1OutStr, cp2InStr, cp2OutStr,
+					cp3InStr, cp3OutStr, cp4InStr, cp4OutStr,
+					description, Util.BoolToNegativeInt(simulated)
+					);
+
+			//define the created object
+			eventDone = new MultiChronopic(uniqueID, personID, sessionID, type, 
+					Util.BoolToInt(cp1StartedIn), Util.BoolToInt(cp2StartedIn), 
+					Util.BoolToInt(cp3StartedIn), Util.BoolToInt(cp4StartedIn),
+					cp1InStr, cp1OutStr, cp2InStr, cp2OutStr,
+					cp3InStr, cp3OutStr, cp4InStr, cp4OutStr,
+					description, Util.BoolToNegativeInt(simulated)); 
+
+
+			/* //TODO
+			//event will be raised, and managed in chronojump.cs
+			string myStringPush =   
+				//Catalog.GetString("Last jump: ") + 
+				personName + " " + 
+				type + " (" + limitString + ") " +
+				" " + Catalog.GetString("AVG TF") + ": " + Util.TrimDecimals( Util.GetAverage (tvString).ToString(), pDN ) +
+				" " + Catalog.GetString("AVG TC") + ": " + Util.TrimDecimals( Util.GetAverage (tcString).ToString(), pDN ) ;
+			appbar.Push( 1,myStringPush );
+			*/
+		}
+
+
 	}
 	
 
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 92734da..1bee321 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -154,6 +154,7 @@ public class ChronoJumpWindow
 	[Widget] Gtk.Image image_cp3_no;
 	[Widget] Gtk.Image image_cp4_yes;
 	[Widget] Gtk.Image image_cp4_no;
+	[Widget] Gtk.CheckButton check_multi_sync;
 	
 	[Widget] Gtk.Button button_last;
 	[Widget] Gtk.Button button_rj_last;
@@ -1149,6 +1150,42 @@ public class ChronoJumpWindow
 		}
 	}
 
+	private void resetAllTreeViews( bool alsoPersons) {
+		if(alsoPersons) {
+			//load the persons treeview
+			treeview_persons_storeReset();
+			fillTreeView_persons();
+		}
+
+		//load the jumps treeview
+		treeview_jumps_storeReset();
+		fillTreeView_jumps(Constants.AllJumpsName);
+
+		//load the jumps_rj treeview_rj
+		treeview_jumps_rj_storeReset();
+		fillTreeView_jumps_rj(Constants.AllJumpsName);
+
+		//load the runs treeview
+		treeview_runs_storeReset();
+		fillTreeView_runs(Constants.AllRunsName);
+
+		//load the runs_interval treeview
+		treeview_runs_interval_storeReset();
+		fillTreeView_runs_interval(Constants.AllRunsName);
+
+		//load the pulses treeview
+		treeview_pulses_storeReset();
+		fillTreeView_pulses(Constants.AllPulsesName);
+
+		//load the reaction_times treeview
+		treeview_reaction_times_storeReset();
+		fillTreeView_reaction_times();
+
+		//load the multiChronopic treeview
+		treeview_multi_chronopic_storeReset();
+		fillTreeView_multi_chronopic();
+	}
+
 
 	/* ---------------------------------------------------------
 	 * ----------------  TREEVIEW JUMPS ------------------------
@@ -1578,6 +1615,18 @@ public class ChronoJumpWindow
 //		tv.CursorChanged += on_treeview_multi_chronopic_cursor_changed; 
 	}
 	
+	private void fillTreeView_multi_chronopic () {
+		string [] mcs = SqliteMultiChronopic.SelectTests(currentSession.UniqueID, -1);
+		myTreeViewMultiChronopic.Fill(mcs, "");
+		expandOrMinimizeTreeView((TreeViewEvent) myTreeViewMultiChronopic, treeview_multi_chronopic);
+	}
+	
+	private void treeview_multi_chronopic_storeReset() {
+		myTreeViewMultiChronopic.RemoveColumns();
+		myTreeViewMultiChronopic = new TreeViewMultiChronopic( treeview_multi_chronopic, prefsDigitsNumber, 
+				myTreeViewMultiChronopic.ExpandState );
+	}
+
 	private void on_button_connect_cp_clicked (object o, EventArgs args) {
 		if(o == (object) button_connect_cp2) {
 			currentCp = 2;
@@ -1847,7 +1896,6 @@ public class ChronoJumpWindow
 	 * ----------------  SESSION NEW, LOAD, EXPORT, DELETE -----
 	 *  --------------------------------------------------------
 	 */
-	
 
 	private void on_new_activate (object o, EventArgs args) {
 		Log.WriteLine("new session");
@@ -1867,34 +1915,8 @@ public class ChronoJumpWindow
 			if(createdStatsWin) {
 				statsWin.InitializeSession(currentSession);
 			}
-			
-			//load the persons treeview
-			treeview_persons_storeReset();
-			fillTreeView_persons();
-			
-			//load the jumps treeview
-			treeview_jumps_storeReset();
-			fillTreeView_jumps(Constants.AllJumpsName);
-			
-			//load the jumps_rj treeview_rj
-			treeview_jumps_rj_storeReset();
-			fillTreeView_jumps_rj(Constants.AllJumpsName);
-			
-			//load the runs treeview
-			treeview_runs_storeReset();
-			fillTreeView_runs(Constants.AllRunsName);
-			
-			//load the runs_interval treeview
-			treeview_runs_interval_storeReset();
-			fillTreeView_runs_interval(Constants.AllRunsName);
-			
-			//load the pulses treeview
-			treeview_pulses_storeReset();
-			fillTreeView_pulses(Constants.AllPulsesName);
-
-			//load the reaction_times treeview
-			treeview_reaction_times_storeReset();
-			fillTreeView_reaction_times();
+		
+			resetAllTreeViews(true); //boolean means: "also persons"
 
 			//show hidden widgets
 			sensitiveGuiNoSession();
@@ -1954,36 +1976,10 @@ public class ChronoJumpWindow
 			statsWin.InitializeSession(currentSession);
 		}
 		
-		//load the persons treeview (and try to select first)
-		treeview_persons_storeReset();
-		fillTreeView_persons();
+		resetAllTreeViews(true); //boolean means: "also persons"
+
 		bool foundPersons = selectRowTreeView_persons(treeview_persons, treeview_persons_store, 0);
 		
-		//load the treeview_jumps
-		treeview_jumps_storeReset();
-		fillTreeView_jumps(Constants.AllJumpsName);
-		
-		//load the treeview_jumps_rj
-		treeview_jumps_rj_storeReset();
-		fillTreeView_jumps_rj(Constants.AllJumpsName);
-		
-		//load the runs treeview
-		treeview_runs_storeReset();
-		fillTreeView_runs(Constants.AllRunsName);
-		
-		//load the runs_interval treeview
-		treeview_runs_interval_storeReset();
-		fillTreeView_runs_interval(Constants.AllRunsName);
-		
-		//load the pulses treeview
-		treeview_pulses_storeReset();
-		fillTreeView_pulses(Constants.AllPulsesName);
-		
-		//load the reaction_times treeview
-		treeview_reaction_times_storeReset();
-		fillTreeView_reaction_times();
-		
-
 		//show hidden widgets
 		sensitiveGuiNoSession();
 		sensitiveGuiYesSession();
@@ -2187,15 +2183,8 @@ public class ChronoJumpWindow
 		SqlitePersonSession.DeletePersonFromSessionAndTests(
 				currentSession.UniqueID.ToString(), currentPerson.UniqueID.ToString());
 		
-		treeview_persons_storeReset();
-		fillTreeView_persons();
+		resetAllTreeViews(true); //boolean means: "also persons"
 		bool foundPersons = selectRowTreeView_persons(treeview_persons, treeview_persons_store, 0);
-		
-		treeview_jumps_storeReset();
-		fillTreeView_jumps(Constants.AllJumpsName);
-		
-		treeview_jumps_rj_storeReset();
-		fillTreeView_jumps_rj(Constants.AllJumpsName);
 			
 		if(createdStatsWin) {
 			statsWin.FillTreeView_stats(false, true);
@@ -2544,6 +2533,10 @@ Log.WriteLine("all done");
 			//currently no combo_reaction_times
 			treeview_reaction_times_storeReset();
 			fillTreeView_reaction_times();
+
+			//currently no combo_multi_chronopic
+			treeview_multi_chronopic_storeReset();
+			fillTreeView_multi_chronopic();
 		}
 		catch 
 		{
@@ -2552,7 +2545,7 @@ Log.WriteLine("all done");
 	
 	private void on_cancel_clicked (object o, EventArgs args) 
 	{
-		Console.WriteLine("clicked one");
+		Console.WriteLine("cancel clicked one");
 
 		//this will cancel jumps or runs
 		currentEventExecute.Cancel = true;
@@ -2573,6 +2566,21 @@ Log.WriteLine("all done");
 		//if(createdStatsWin)
 		//	statsWin.ShowUpdateStatsButton();
 	}
+	
+	private void on_cancel_multi_clicked (object o, EventArgs args) 
+	{
+		Console.WriteLine("cancel multi clicked one");
+
+		//this will cancel jumps or runs
+		currentEventExecute.Cancel = true;
+
+		//unhide event buttons for next event
+		sensitiveGuiEventDone();
+
+		if(!simulated)
+			checkCancelMultiTotally(o, args);
+	}
+
 
 	//if user doesn't touch the platform after pressing "cancel", sometimes it gets waiting a Read_event
 	//now the event cancels ok, and next will be ok, also	
@@ -2586,6 +2594,50 @@ Log.WriteLine("all done");
 			errorWin.Button_accept.Clicked += new EventHandler(checkCancelTotally);
 		}
 	}
+	
+	private void checkCancelMultiTotally (object o, EventArgs args) 
+	{
+		bool needCancel1 = false;
+		bool needCancel2 = false;
+		bool needCancel3 = false;
+		bool needCancel4 = false;
+			
+		needCancel1 = !currentEventExecute.TotallyCancelledMulti1;
+		if(currentEventExecute.Chronopics > 1) {
+			needCancel2 = !currentEventExecute.TotallyCancelledMulti2;
+			if(currentEventExecute.Chronopics > 2) {
+				needCancel3 = !currentEventExecute.TotallyCancelledMulti3;
+				if(currentEventExecute.Chronopics > 3)
+					needCancel4 = !currentEventExecute.TotallyCancelledMulti4;
+			}
+		}
+
+		if(needCancel1 || needCancel2 || needCancel3 || needCancel4) {
+//			Log.Write("NOT-totallyCancelled ");
+			string cancelStr = "";
+			string sep = "";
+			if(needCancel1) {
+				cancelStr += sep + "1";
+				sep = ", ";
+			}
+			if(needCancel2) {
+				cancelStr += sep + "2";
+				sep = ", ";
+			}
+			if(needCancel3) {
+				cancelStr += sep + "3";
+				sep = ", ";
+			}
+			if(needCancel4) {
+				cancelStr += sep + "4";
+				sep = ", ";
+			}
+
+			errorWin = ErrorWindow.Show(string.Format(Catalog.GetString("Please, touch the contact platform on Chronopic/s [{0}] for full cancelling.\nThen press button\n"), cancelStr));
+			errorWin.Button_accept.Clicked += new EventHandler(checkCancelMultiTotally);
+		}
+	}
+		
 		
 	private void on_finish_clicked (object o, EventArgs args) 
 	{
@@ -2602,8 +2654,25 @@ Log.WriteLine("all done");
 			statsWin.ShowUpdateStatsButton();
 	}
 		
+	private void on_finish_multi_clicked (object o, EventArgs args) 
+	{
+		currentEventExecute.Finish = true;
+		
+		//unhide event buttons for next event
+		sensitiveGuiEventDone();
+
+		if(!simulated)
+			checkFinishMultiTotally(o, args);
+		
+		//let update stats
+		if(createdStatsWin)
+			statsWin.ShowUpdateStatsButton();
+	}
+		
 	//if user doesn't touch the platform after pressing "finish", sometimes it gets waiting a Read_event
 	//now the event finishes ok, and next will be ok, also	
+	//
+	//not for multiChronopic:
 	private void checkFinishTotally (object o, EventArgs args) 
 	{
 		if(currentEventExecute.TotallyFinished) 
@@ -2615,6 +2684,52 @@ Log.WriteLine("all done");
 		}
 	}
 		
+	private void checkFinishMultiTotally (object o, EventArgs args) 
+	{
+		bool needFinish1 = false;
+		bool needFinish2 = false;
+		bool needFinish3 = false;
+		bool needFinish4 = false;
+			
+		needFinish1 = !currentEventExecute.TotallyFinishedMulti1;
+		if(currentEventExecute.Chronopics > 1) {
+			needFinish2 = !currentEventExecute.TotallyFinishedMulti2;
+			if(currentEventExecute.Chronopics > 2) {
+				needFinish3 = !currentEventExecute.TotallyFinishedMulti3;
+				if(currentEventExecute.Chronopics > 3)
+					needFinish4 = !currentEventExecute.TotallyFinishedMulti4;
+			}
+		}
+
+		if(needFinish1 || needFinish2 || needFinish3 || needFinish4) {
+//			Log.Write("NOT-totallyFinishled ");
+			string cancelStr = "";
+			string sep = "";
+			if(needFinish1) {
+				cancelStr += sep + "1";
+				sep = ", ";
+			}
+			if(needFinish2) {
+				cancelStr += sep + "2";
+				sep = ", ";
+			}
+			if(needFinish3) {
+				cancelStr += sep + "3";
+				sep = ", ";
+			}
+			if(needFinish4) {
+				cancelStr += sep + "4";
+				sep = ", ";
+			}
+
+			errorWin = ErrorWindow.Show(string.Format(Catalog.GetString("Please, touch the contact platform on Chronopic/s [{0}] for full finishing.\nThen press button\n"), cancelStr));
+			errorWin.Button_accept.Clicked += new EventHandler(checkFinishMultiTotally);
+		} else {
+			//call write here, because if done in execute/MultiChronopic, will be called n times if n chronopics are working
+			currentEventExecute.MultiChronopicWrite(false);
+		}
+	}
+		
 	
 	private void on_show_report_activate (object o, EventArgs args) {
 		Log.WriteLine("open report window");
@@ -3884,10 +3999,11 @@ Log.WriteLine("all done");
 			Constants.MultiChronopicTable, //tableName
 			//currentPulseType.Name, 
 			"", 
-			prefsDigitsNumber, -1, simulated); //-1: unlimited pulses (or changes)
+			prefsDigitsNumber, -1, simulated
+			); //-1: unlimited pulses (or changes)
 
-		eventExecuteWin.ButtonCancel.Clicked += new EventHandler(on_cancel_clicked);
-		eventExecuteWin.ButtonFinish.Clicked += new EventHandler(on_finish_clicked);
+		eventExecuteWin.ButtonCancel.Clicked += new EventHandler(on_cancel_multi_clicked);
+		eventExecuteWin.ButtonFinish.Clicked += new EventHandler(on_finish_multi_clicked);
 		
 		//when user clicks on update the eventExecute window 
 		//(for showing with his new confgured values: max, min and guides
@@ -3903,20 +4019,20 @@ Log.WriteLine("all done");
 
 		if(image_cp2_no.Visible)
 			currentEventExecute = new MultiChronopicExecute(
-					eventExecuteWin, currentPerson.UniqueID, currentPerson.Name, currentSession.UniqueID, 
-					cp, appbar2, app1);
+					eventExecuteWin, currentPerson.UniqueID, currentPerson.Name, currentSession.UniqueID, "", 
+					cp, check_multi_sync.Active, appbar2, app1);
 		else if(image_cp2_yes.Visible && image_cp3_no.Visible)
 			currentEventExecute = new MultiChronopicExecute(
-					eventExecuteWin, currentPerson.UniqueID, currentPerson.Name, currentSession.UniqueID, 
-					cp, cp2, appbar2, app1);
+					eventExecuteWin, currentPerson.UniqueID, currentPerson.Name, currentSession.UniqueID, "",  
+					cp, cp2, check_multi_sync.Active, appbar2, app1);
 		else if(image_cp3_yes.Visible && image_cp4_no.Visible)
 			currentEventExecute = new MultiChronopicExecute(
-					eventExecuteWin, currentPerson.UniqueID, currentPerson.Name, currentSession.UniqueID, 
-					cp, cp2, cp3, appbar2, app1);
+					eventExecuteWin, currentPerson.UniqueID, currentPerson.Name, currentSession.UniqueID, "",
+					cp, cp2, cp3, check_multi_sync.Active, appbar2, app1);
 		else if(image_cp4_yes.Visible)
 			currentEventExecute = new MultiChronopicExecute(
-					eventExecuteWin, currentPerson.UniqueID, currentPerson.Name, currentSession.UniqueID, 
-					cp, cp2, cp3, cp4, appbar2, app1);
+					eventExecuteWin, currentPerson.UniqueID, currentPerson.Name, currentSession.UniqueID, "",
+					cp, cp2, cp3, cp4, check_multi_sync.Active, appbar2, app1);
 
 		//if(simulated)	
 		//	currentEventExecute.SimulateInitValues(rand);
diff --git a/src/gui/eventExecute.cs b/src/gui/eventExecute.cs
index 671268f..a490a86 100644
--- a/src/gui/eventExecute.cs
+++ b/src/gui/eventExecute.cs
@@ -1474,7 +1474,6 @@ public class EventExecuteWindow
 			string cp3InStr, string cp3OutStr, string cp4InStr, string cp4OutStr, 
 			double maxValue, double minValue, int topMargin, int bottomMargin)
 	{
-
 		double timeTotal1 = Util.GetTotalTime(cp1InStr + "=" + cp1OutStr);
 		double timeTotal2 = Util.GetTotalTime(cp2InStr + "=" + cp2OutStr);
 		double timeTotal3 = Util.GetTotalTime(cp3InStr + "=" + cp3OutStr);
diff --git a/src/gui/splash.cs b/src/gui/splash.cs
index 086e567..93adaca 100644
--- a/src/gui/splash.cs
+++ b/src/gui/splash.cs
@@ -35,6 +35,7 @@ public class SplashWindow
 
 	
 	public Gtk.Button fakeButtonCancel;
+	public bool FakeButtonCreated = false;
 	
 	static SplashWindow SplashWindowBox;
 
@@ -48,6 +49,8 @@ public class SplashWindow
 		UtilGtk.IconWindow(splash_window);
 
 		fakeButtonCancel = new Gtk.Button();
+		FakeButtonCreated = true;
+
 		CancelButtonShow(false);
 		hideAllProgressbars();
 
diff --git a/src/multiChronopic.cs b/src/multiChronopic.cs
index 6ab6743..86c759a 100644
--- a/src/multiChronopic.cs
+++ b/src/multiChronopic.cs
@@ -20,9 +20,14 @@
 
 using System;
 using System.Data;
+using System.Collections; //ArrayList
 
 public class MultiChronopic : Event 
 {
+	private int cp1StartedIn;
+	private int cp2StartedIn;
+	private int cp3StartedIn;
+	private int cp4StartedIn;
 	private string cp1InStr;
 	private string cp1OutStr;
 	private string cp2InStr;
@@ -32,11 +37,15 @@ public class MultiChronopic : Event
 	private string cp4InStr;
 	private string cp4OutStr;
 
+	private ArrayList array;
+	private bool arrayDone;
+
 	public MultiChronopic() {
 	}
 
 	//after inserting database (SQL)
-	public MultiChronopic(int uniqueID, int personID, int sessionID, 
+	public MultiChronopic(int uniqueID, int personID, int sessionID, string type, 
+			int cp1StartedIn, int cp2StartedIn, int cp3StartedIn, int cp4StartedIn,
 			string cp1InStr, string cp1OutStr,
 			string cp2InStr, string cp2OutStr,
 			string cp3InStr, string cp3OutStr,
@@ -46,6 +55,11 @@ public class MultiChronopic : Event
 		this.uniqueID = uniqueID;
 		this.personID = personID;
 		this.sessionID = sessionID;
+		this.type = type;
+		this.cp1StartedIn = cp1StartedIn;
+		this.cp2StartedIn = cp2StartedIn;
+		this.cp3StartedIn = cp3StartedIn;
+		this.cp4StartedIn = cp4StartedIn;
 		this.cp1InStr = cp1InStr;
 		this.cp1OutStr = cp1OutStr;
 		this.cp2InStr = cp2InStr;
@@ -56,6 +70,8 @@ public class MultiChronopic : Event
 		this.cp4OutStr = cp4OutStr;
 		this.description = description;
 		this.simulated = simulated;
+	
+		arrayDone = false;
 	}
 
 	/*
@@ -75,7 +91,8 @@ public class MultiChronopic : Event
 		return SqliteMultiChronopic.Insert(dbconOpened, tableName, 
 				uniqueID.ToString(), 
 				personID, sessionID, 
-				"default", //type
+				"", //type
+				cp1StartedIn, cp2StartedIn, cp3StartedIn, cp4StartedIn,
 				cp1InStr, cp1OutStr,
 				cp2InStr, cp2OutStr,
 				cp3InStr, cp3OutStr,
@@ -83,5 +100,249 @@ public class MultiChronopic : Event
 				description, simulated);
 	}
 
+	public ArrayList AsArrayList() 
+	{
+		if(arrayDone)
+			return array;
+		
+		//write line for treeview
+		//string [] myData = new String [getColsNum()];
+		ArrayList returnArray = new ArrayList(1);
+		string [] returnLine = new String[20];
+
+		string [] cp1InFull = this.Cp1InStr.Split(new char[] {'='});
+		string [] cp1OutFull = this.Cp1OutStr.Split(new char[] {'='});
+		string [] cp2InFull = this.Cp2InStr.Split(new char[] {'='});
+		string [] cp2OutFull = this.Cp2OutStr.Split(new char[] {'='});
+		string [] cp3InFull = this.Cp3InStr.Split(new char[] {'='});
+		string [] cp3OutFull = this.Cp3OutStr.Split(new char[] {'='});
+		string [] cp4InFull = this.Cp4InStr.Split(new char[] {'='});
+		string [] cp4OutFull = this.Cp4OutStr.Split(new char[] {'='});
+
+		bool ended = false;
+		bool cp1NextIn = Util.IntToBool(this.Cp1StartedIn);
+		bool cp2NextIn = Util.IntToBool(this.Cp2StartedIn);
+		bool cp3NextIn = Util.IntToBool(this.Cp3StartedIn);
+		bool cp4NextIn = Util.IntToBool(this.Cp4StartedIn);
+		double cp1NextTime;
+		double cp2NextTime;
+		double cp3NextTime;
+		double cp4NextTime;
+		double runningTime = 0;
+
+		int cp1InCount = 0;
+		int cp1OutCount = 0;
+		int cp2InCount = 0;
+		int cp2OutCount = 0;
+		int cp3InCount = 0;
+		int cp3OutCount = 0;
+		int cp4InCount = 0;
+		int cp4OutCount = 0;
+		double cp1Sum = 0;
+		double cp2Sum = 0;
+		double cp3Sum = 0;
+		double cp4Sum = 0;
+
+		int lineCount = 0;
+		while(! ended) {
+			int nextCp = -1;
+
+			/*
+			   need the last && mcCp1InStr.Length>0
+			   because if string it's empty cp1InFull will be created with lenght 1
+			 */ 
+			if(cp1NextIn && cp1InFull.Length > cp1InCount && this.Cp1InStr.Length>0)  
+				cp1NextTime = Convert.ToDouble(cp1InFull[cp1InCount]) + cp1Sum;
+			else if(! cp1NextIn && cp1OutFull.Length > cp1OutCount && this.Cp1OutStr.Length>0) 
+				cp1NextTime = Convert.ToDouble(cp1OutFull[cp1OutCount]) + cp1Sum;
+			else 
+				cp1NextTime = 99999;
+
+
+			if(cp2NextIn && cp2InFull.Length > cp2InCount && this.Cp2InStr.Length>0) 
+				cp2NextTime = Convert.ToDouble(cp2InFull[cp2InCount]) + cp2Sum;
+			else if(! cp2NextIn && cp2OutFull.Length > cp2OutCount && this.Cp2OutStr.Length>0) 
+				cp2NextTime = Convert.ToDouble(cp2OutFull[cp2OutCount]) + cp2Sum;
+			else
+				cp2NextTime = 99999;
+
+			if(cp3NextIn && cp3InFull.Length > cp3InCount && this.Cp3InStr.Length>0) 
+				cp3NextTime = Convert.ToDouble(cp3InFull[cp3InCount]) + cp3Sum;
+			else if(! cp3NextIn && cp3OutFull.Length > cp3OutCount && this.Cp3OutStr.Length>0) 
+				cp3NextTime = Convert.ToDouble(cp3OutFull[cp3OutCount]) + cp3Sum;
+			else
+				cp3NextTime = 99999;
+
+			if(cp4NextIn && cp4InFull.Length > cp4InCount && this.Cp4InStr.Length>0) 
+				cp4NextTime = Convert.ToDouble(cp4InFull[cp4InCount]) + cp4Sum;
+			else if(! cp4NextIn && cp4OutFull.Length > cp4OutCount && this.Cp4OutStr.Length>0) 
+				cp4NextTime = Convert.ToDouble(cp4OutFull[cp4OutCount]) + cp4Sum;
+			else
+				cp4NextTime = 99999;
+
+
+			if(cp1NextTime == 99999 && cp2NextTime == 99999 && cp3NextTime == 99999 && cp4NextTime == 99999)
+				ended = true;
+			else {
+				if(cp1NextTime <= cp2NextTime) {
+					if(cp1NextTime <= cp3NextTime) {
+						if(cp1NextTime <= cp4NextTime) 
+							nextCp = 1;
+						else 
+							nextCp = 4;
+					} else {
+						if(cp3NextTime <= cp4NextTime) 
+							nextCp = 3;
+						else 
+							nextCp = 4;
+					}
+				} else {
+					if(cp2NextTime <= cp3NextTime) {
+						if(cp2NextTime <= cp4NextTime) 
+							nextCp = 2;
+						else 
+							nextCp = 4;
+					} else {
+						if(cp3NextTime <= cp4NextTime) 
+							nextCp = 3;
+						else 
+							nextCp = 4;
+					}
+				}
+
+				Console.WriteLine("NEXTCP: " + nextCp);
+
+				int pos=0;
+				double thisTime = 0;
+				string thisState = Constants.Out;
+				if(nextCp == 1) {
+					pos = 0;
+					if(cp1NextIn)
+						cp1InCount ++;
+					else
+						cp1OutCount ++;
+					cp1NextIn = ! cp1NextIn;
+					thisTime = cp1NextTime - cp1Sum;;
+					cp1Sum += thisTime;
+					runningTime = cp1Sum;
+					thisState = Util.BoolToInOut(cp1NextIn);
+				} else if(nextCp == 2) {
+					pos = 1;
+					if(cp2NextIn)
+						cp2InCount ++;
+					else
+						cp2OutCount ++;
+					cp2NextIn = ! cp2NextIn;
+					thisTime = cp2NextTime - cp2Sum;
+					cp2Sum += thisTime;
+					runningTime = cp2Sum;
+					thisState = Util.BoolToInOut(cp2NextIn);
+				} else if(nextCp == 3) {
+					pos = 2;
+					if(cp3NextIn)
+						cp3InCount ++;
+					else
+						cp3OutCount ++;
+					cp3NextIn = ! cp3NextIn;
+					thisTime = cp3NextTime - cp3Sum;
+					cp3Sum += thisTime;
+					runningTime = cp3Sum;
+					thisState = Util.BoolToInOut(cp3NextIn);
+				} else if(nextCp == 4) {
+					pos = 3;
+					if(cp4NextIn)
+						cp4InCount ++;
+					else
+						cp4OutCount ++;
+					cp4NextIn = ! cp4NextIn;
+					thisTime = cp4NextTime - cp4Sum;
+					cp4Sum += thisTime;
+					runningTime = cp4Sum;
+					thisState = Util.BoolToInOut(cp4NextIn);
+				}
+
+
+				int count=0;
+				returnLine[count++] = (lineCount++).ToString();
+				returnLine[count++] = runningTime.ToString();
+
+				for(int i=0; i<8; i++) {
+					if(i==pos)
+						returnLine[count++] = thisState;
+					else if(i == (pos +4))
+						returnLine[count++] = thisTime.ToString();
+					else
+						returnLine[count++] = "";
+				}
+
+
+				for(int i=0; i<8;i++)
+					returnLine[count++] = "";
+
+				returnLine[count++] = ""; //description column
+				returnLine[count++] = "-1"; //mark to non select here, select first line 
+				returnArray.Add(Util.StringArrayToString(returnLine, ":"));
+			}
+		}
+		array = returnArray;
+		arrayDone = true;
+		return array;
+	}
+	
+	public int Cp1StartedIn {
+		get { return cp1StartedIn; }
+		set { cp1StartedIn = value; }
+	}
+	public int Cp2StartedIn {
+		get { return cp2StartedIn; }
+		set { cp2StartedIn = value; }
+	}
+	public int Cp3StartedIn {
+		get { return cp3StartedIn; }
+		set { cp3StartedIn = value; }
+	}
+	public int Cp4StartedIn {
+		get { return cp4StartedIn; }
+		set { cp4StartedIn = value; }
+	}
+	
+	public string Cp1InStr {
+		get { return cp1InStr; }
+		set { cp1InStr = value; }
+	}
+	public string Cp1OutStr {
+		get { return cp1OutStr; }
+		set { cp1OutStr = value; }
+	}
+	
+	public string Cp2InStr {
+		get { return cp2InStr; }
+		set { cp2InStr = value; }
+	}
+	public string Cp2OutStr {
+		get { return cp2OutStr; }
+		set { cp2OutStr = value; }
+	}
+
+	public string Cp3InStr {
+		get { return cp3InStr; }
+		set { cp3InStr = value; }
+	}
+	public string Cp3OutStr {
+		get { return cp3OutStr; }
+		set { cp3OutStr = value; }
+	}
+	
+	public string Cp4InStr {
+		get { return cp4InStr; }
+		set { cp4InStr = value; }
+	}
+	public string Cp4OutStr {
+		get { return cp4OutStr; }
+		set { cp4OutStr = value; }
+	}
+	
+	
+
 	~MultiChronopic() {}
 }
diff --git a/src/server.cs b/src/server.cs
index ede3262..f2590a1 100644
--- a/src/server.cs
+++ b/src/server.cs
@@ -50,22 +50,30 @@ public class Server
 
 	public static string Ping(bool doInsertion, string progName, string progVersion) {
 		try {
+			Console.WriteLine("--a--");
 			ChronojumpServer myServer = new ChronojumpServer();
+			Console.WriteLine("--b--");
 			Log.WriteLine(myServer.ConnectDatabase());
 		
+			Console.WriteLine("--c--");
 			int evalSID = Convert.ToInt32(SqlitePreferences.Select("evaluatorServerID"));
 
+			Console.WriteLine("--d--");
 			ServerPing myPing = new ServerPing(evalSID, progName + " " + progVersion, Util.GetOS(), 
 					//Constants.IPUnknown, Util.DateParse(DateTime.Now.ToString())); //evaluator, ip, date
 					getIP(), Util.DateParse(DateTime.Now.ToString())); //evaluator, ip, date
 			//if !doIsertion nothing will be uploaded,
 			//is ok for uploadPerson to know if server is online
+			Console.WriteLine("--e--");
 			string versionAvailable = myServer.UploadPing(myPing, doInsertion);
 			
+			Console.WriteLine("--f--");
 			Log.WriteLine(myServer.DisConnectDatabase());
 
+			Console.WriteLine("--g--");
 			return versionAvailable;
 		} catch {
+			Console.WriteLine("--h--");
 			return Constants.ServerOffline;
 		}
 	}
diff --git a/src/sqlite/multiChronopic.cs b/src/sqlite/multiChronopic.cs
index 18da218..73b6eff 100644
--- a/src/sqlite/multiChronopic.cs
+++ b/src/sqlite/multiChronopic.cs
@@ -44,6 +44,10 @@ class SqliteMultiChronopic : Sqlite
 			"personID INT, " +
 			"sessionID INT, " +
 			"type TEXT, " + //now all as "default", but in the future...
+			"cp1StartedIn INT, " +
+			"cp2StartedIn INT, " +
+			"cp3StartedIn INT, " +
+			"cp4StartedIn INT, " +
 			"cp1InStr TEXT, " +
 			"cp1OutStr TEXT, " +
 			"cp2InStr TEXT, " +
@@ -63,6 +67,7 @@ class SqliteMultiChronopic : Sqlite
 	 */
 
 	public static int Insert(bool dbconOpened, string tableName, string uniqueID, int personID, int sessionID, string type, 
+			int cp1StartedIn, int cp2StartedIn, int cp3StartedIn, int cp4StartedIn,
 			string cp1InStr, string cp1OutStr,
 			string cp2InStr, string cp2OutStr,
 			string cp3InStr, string cp3OutStr,
@@ -76,11 +81,14 @@ class SqliteMultiChronopic : Sqlite
 			uniqueID = "NULL";
 
 		dbcmd.CommandText = "INSERT INTO " + tableName +  
-			" (uniqueID, personID, sessionID, type, " + 
+			" (uniqueID, personID, sessionID, type, " +
+		       	" cp1StartedIn, cp2StartedIn, cp3StartedIn, cp4StartedIn, " +	
 			" cp1InStr, cp1OutStr, cp2InStr, cp2OutStr, cp3InStr, cp3OutStr, cp4InStr, cp4OutStr, " +
 			" description, simulated)" +
 			" VALUES (" + uniqueID + ", " +
-			personID + ", " + sessionID + ", '" + type + "', '" +
+			personID + ", " + sessionID + ", '" + type + "', " +
+			cp1StartedIn + ", " + cp2StartedIn + ", " +
+			cp3StartedIn + ", " + cp4StartedIn + ", '" +
 			cp1InStr + "', '" + cp1OutStr + "', '" +
 			cp2InStr + "', '" + cp2OutStr + "', '" +
 			cp3InStr + "', '" + cp3OutStr + "', '" +
@@ -96,21 +104,20 @@ class SqliteMultiChronopic : Sqlite
 		return myLast;
 	}
 
-	/*
 	//if all persons, put -1 in personID
-	public static string[] SelectAllReactionTimes(int sessionID, int personID) 
+	public static string[] SelectTests(int sessionID, int personID) 
 	{
 		string filterPersonString = "";
 		if(personID != -1)
 			filterPersonString = " AND person.uniqueID == " + personID;
 
 		dbcon.Open();
-		dbcmd.CommandText = "SELECT person.name, reactionTime.* " +
-			" FROM person, reactionTime " +
-			" WHERE person.uniqueID == reactionTime.personID" + 
-			" AND reactionTime.sessionID == " + sessionID + 
+		dbcmd.CommandText = "SELECT person.name, multiChronopic.* " +
+			" FROM person, multiChronopic " +
+			" WHERE person.uniqueID == multiChronopic.personID" + 
+			" AND multiChronopic.sessionID == " + sessionID + 
 			filterPersonString +
-			" ORDER BY upper(person.name), reactionTime.uniqueID";
+			" ORDER BY upper(person.name), multiChronopic.uniqueID";
 		
 		Log.WriteLine(dbcmd.CommandText.ToString());
 		dbcmd.ExecuteNonQuery();
@@ -127,13 +134,24 @@ class SqliteMultiChronopic : Sqlite
 		while(reader.Read()) {
 
 			myArray.Add (reader[0].ToString() + ":" +	//person.name
-					reader[1].ToString() + ":" +	//jump.uniqueID
-					reader[2].ToString() + ":" + 	//jump.personID
-					reader[3].ToString() + ":" + 	//jump.sessionID
-					reader[4].ToString() + ":" + 	//jump.type
-					Util.ChangeDecimalSeparator(reader[5].ToString()) + ":" + 	//jump.time
-					reader[6].ToString() + ":" + 	//description
-					reader[7].ToString()		//simulated
+					reader[1].ToString() + ":" +	//mc.uniqueID
+					reader[2].ToString() + ":" + 	//mc.personID
+					reader[3].ToString() + ":" + 	//mc.sessionID
+					reader[4].ToString() + ":" + 	//mc.type
+					reader[5].ToString() + ":" + 	//mc.cp1StartedIn
+					reader[6].ToString() + ":" + 	//mc.cp2StartedIn
+					reader[7].ToString() + ":" + 	//mc.cp3StartedIn
+					reader[8].ToString() + ":" + 	//mc.cp4StartedIn
+					reader[9].ToString() + ":" + 	//mc.cp1InStr
+					reader[10].ToString() + ":" + 	//mc.cp1OutStr
+					reader[11].ToString() + ":" + 	//mc.cp2InStr
+					reader[12].ToString() + ":" + 	//mc.cp2OutStr
+					reader[13].ToString() + ":" + 	//mc.cp3InStr
+					reader[14].ToString() + ":" + 	//mc.cp3OutStr
+					reader[15].ToString() + ":" + 	//mc.cp4InStr
+					reader[16].ToString() + ":" + 	//mc.cp4OutStr
+					reader[17].ToString() + ":" + 	//description
+					reader[18].ToString()		//simulated
 					);
 			count ++;
 		}
@@ -150,6 +168,7 @@ class SqliteMultiChronopic : Sqlite
 		return myEvents;
 	}
 
+	/*
 	public static ReactionTime SelectReactionTimeData(int uniqueID)
 	{
 		dbcon.Open();
diff --git a/src/treeViewEvent.cs b/src/treeViewEvent.cs
index d4e4748..5c81671 100644
--- a/src/treeViewEvent.cs
+++ b/src/treeViewEvent.cs
@@ -137,7 +137,7 @@ public class TreeViewEvent
 		return columnsString.Length +1;
 	}
 	
-	protected void addStatisticInfo(TreeIter iterDeep, System.Object myObject) {
+	protected virtual void addStatisticInfo(TreeIter iterDeep, System.Object myObject) {
 		store.AppendValues(iterDeep, printTotal(myObject, getColsNum()));
 		store.AppendValues(iterDeep, printAVG(myObject, getColsNum()));
 		store.AppendValues(iterDeep, printSD(myObject, getColsNum()));
diff --git a/src/treeViewMultiChronopic.cs b/src/treeViewMultiChronopic.cs
index e8d674b..fd3f0cb 100644
--- a/src/treeViewMultiChronopic.cs
+++ b/src/treeViewMultiChronopic.cs
@@ -62,36 +62,120 @@ public class TreeViewMultiChronopic : TreeViewEvent
 		prepareHeaders(columnsString);
 	}
 
-
-	/*	
 	protected override System.Object getObjectFromString(string [] myStringOfData) {
-		ReactionTime myReactionTime = new ReactionTime();
-		myReactionTime.UniqueID = Convert.ToInt32(myStringOfData[1].ToString()); 
-		myReactionTime.Time = Convert.ToDouble(myStringOfData[5].ToString());
-		myReactionTime.Description = myStringOfData[6].ToString();
-		myReactionTime.Simulated = Convert.ToInt32(myStringOfData[7].ToString());
-
-		return myReactionTime;
+		MultiChronopic mc = new MultiChronopic();
+		mc.UniqueID = Convert.ToInt32(myStringOfData[1].ToString()); 
+		mc.Type = myStringOfData[4].ToString(); 
+		mc.Cp1StartedIn = Convert.ToInt32(myStringOfData[5].ToString()); 
+		mc.Cp2StartedIn = Convert.ToInt32(myStringOfData[6].ToString()); 
+		mc.Cp3StartedIn = Convert.ToInt32(myStringOfData[7].ToString()); 
+		mc.Cp4StartedIn = Convert.ToInt32(myStringOfData[8].ToString()); 
+		mc.Cp1InStr = myStringOfData[9].ToString(); 
+		mc.Cp1OutStr = myStringOfData[10].ToString(); 
+		mc.Cp2InStr = myStringOfData[11].ToString(); 
+		mc.Cp2OutStr = myStringOfData[12].ToString(); 
+		mc.Cp3InStr = myStringOfData[13].ToString(); 
+		mc.Cp3OutStr = myStringOfData[14].ToString(); 
+		mc.Cp4InStr = myStringOfData[15].ToString(); 
+		mc.Cp4OutStr = myStringOfData[16].ToString(); 
+		mc.Description = myStringOfData[17].ToString(); 
+		mc.Simulated = Convert.ToInt32(myStringOfData[18].ToString()); 
+		
+		return mc;
 	}
-
+	
 	protected override string [] getLineToStore(System.Object myObject)
 	{
-		ReactionTime newReactionTime = (ReactionTime)myObject;
-
-		string title = "";
-		if(newReactionTime.Simulated == Constants.Simulated)
+		MultiChronopic mc = (MultiChronopic)myObject;
+		
+		string title = mc.Type;
+		if(mc.Simulated == Constants.Simulated)
 			title += " (s) ";
 
+		//string myTypeComplet = title + "(" + newRunI.DistanceInterval + "x" + Util.GetLimitedRounded(newRunI.Limited, pDN) + ")";
+		
 		string [] myData = new String [getColsNum()];
 		int count = 0;
-		//myData[count++] = newReactionTime.Type;
+		//myData[count++] = myTypeComplet;
 		myData[count++] = title;
-		myData[count++] = Util.TrimDecimals(newReactionTime.Time.ToString(), pDN);
-		
-		myData[count++] = newReactionTime.Description;
-		myData[count++] = newReactionTime.UniqueID.ToString();
+		myData[count++] = ""; //time
+		myData[count++] = ""; //state
+		myData[count++] = "";
+		myData[count++] = "";
+		myData[count++] = "";
+		myData[count++] = "";//change
+		myData[count++] = "";
+		myData[count++] = "";
+		myData[count++] = "";
+		myData[count++] = "";//in-in
+		myData[count++] = "";
+		myData[count++] = "";
+		myData[count++] = "";
+		myData[count++] = "";//out-out
+		myData[count++] = "";
+		myData[count++] = "";
+		myData[count++] = "";
+		myData[count++] = mc.Description;
+		myData[count++] = mc.UniqueID.ToString();
 		return myData;
 	}
-	*/
+
+	protected override int getNumOfSubEvents(System.Object myObject)
+	{
+		MultiChronopic mc = (MultiChronopic)myObject;
+
+		int cp1 = Util.GetNumberOfJumps(mc.Cp1InStr,false) + Util.GetNumberOfJumps(mc.Cp1OutStr,false);
+		int cp2 = Util.GetNumberOfJumps(mc.Cp2InStr,false) + Util.GetNumberOfJumps(mc.Cp2OutStr,false);
+		int cp3 = Util.GetNumberOfJumps(mc.Cp3InStr,false) + Util.GetNumberOfJumps(mc.Cp3OutStr,false);
+		int cp4 = Util.GetNumberOfJumps(mc.Cp4InStr,false) + Util.GetNumberOfJumps(mc.Cp4OutStr,false);
+
+		return 1 + cp1 + cp2 + cp3 +cp4; //first "1+" is for the row with the initial data
+	} 
+	
+	//no statistic here (currently)
+	protected override void addStatisticInfo(TreeIter iterDeep, System.Object myObject) {
+	}
+			
+	protected override string [] getSubLineToStore(System.Object myObject, int lineCount)
+	{
+		MultiChronopic mc = (MultiChronopic)myObject;
+
+		//check the time
+//		string [] myStringFull = newRunI.IntervalTimesString.Split(new char[] {'='});
+//		string timeInterval = myStringFull[lineCount];
+		
+		//write line for treeview
+		string [] myData = new String [getColsNum()];
+
+		string [] cp1InFull = mc.Cp1InStr.Split(new char[] {'='});
+		string [] cp1OutFull = mc.Cp1OutStr.Split(new char[] {'='});
+		string [] cp2InFull = mc.Cp2InStr.Split(new char[] {'='});
+		string [] cp2OutFull = mc.Cp2OutStr.Split(new char[] {'='});
+		string [] cp3InFull = mc.Cp3InStr.Split(new char[] {'='});
+		string [] cp3OutFull = mc.Cp3OutStr.Split(new char[] {'='});
+		string [] cp4InFull = mc.Cp4InStr.Split(new char[] {'='});
+		string [] cp4OutFull = mc.Cp4OutStr.Split(new char[] {'='});
+
+
+		if(lineCount == 0) {
+			int count=0;
+			myData[count++] = "0";
+			myData[count++] = "0";
+			myData[count++] = Util.BoolToInOut(Util.IntToBool(mc.Cp1StartedIn));
+			myData[count++] = Util.BoolToInOut(Util.IntToBool(mc.Cp2StartedIn));
+			myData[count++] = Util.BoolToInOut(Util.IntToBool(mc.Cp3StartedIn));
+			myData[count++] = Util.BoolToInOut(Util.IntToBool(mc.Cp4StartedIn));
+			for(int i=0; i<12;i++)
+				myData[count++] = "";
+				
+			myData[count++] = ""; //description column
+			myData[count++] = "-1"; //mark to non select here, select first line 
+			return myData;
+		} else {
+			ArrayList array = mc.AsArrayList();
+			return array[lineCount-1].ToString().Split(new char[] {':'});
+		}
+
+	}
 	
 }
diff --git a/src/util.cs b/src/util.cs
index 08d5b19..47c9f39 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -276,7 +276,7 @@ public class Util
 		myStringBuilder.Replace("\n", " ");
 		return myStringBuilder.ToString();
 	}
-	
+
 	public static string ChangeEqualForColon(string myString) 
 	{
 		StringBuilder myStringBuilder = new StringBuilder(myString);
@@ -906,6 +906,13 @@ public class Util
 			return false;
 	}
 
+	public static string BoolToInOut (bool areWeIn) {
+		if(areWeIn)
+			return Constants.In;
+		else
+			return Constants.Out;
+	}
+
 	public static int BoolToInt (bool myBool) {
 		if(myBool)
 			return 1;
diff --git a/version.txt b/version.txt
index 29ac2e3..4eb8463 100644
--- a/version.txt
+++ b/version.txt
@@ -1 +1 @@
-0.8.2.9
+0.8.3.0



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]