chronojump r476 - in trunk: . build/data src src/execute src/gui



Author: xaviblas
Date: Fri Mar 27 15:27:20 2009
New Revision: 476
URL: http://svn.gnome.org/viewvc/chronojump?rev=476&view=rev

Log:
four chronopics can be connected from gui/chronojump.cs
and managed from multiChronopic (only tested with three)
it's a new way to connect chronopic, returning the cp

created src/multiChronopicType


Added:
   trunk/src/multiChronopicType.cs
Modified:
   trunk/Makefile
   trunk/build/data/chronojump.prg
   trunk/build/data/chronojump_mini.prg
   trunk/changelog.txt
   trunk/src/eventType.cs
   trunk/src/execute/multiChronopic.cs
   trunk/src/gui/chronojump.cs

Modified: trunk/Makefile
==============================================================================
--- trunk/Makefile	(original)
+++ trunk/Makefile	Fri Mar 27 15:27:20 2009
@@ -45,7 +45,7 @@
 
 CHRONOJUMP_DEP_SERVER = chronojump_server/ChronojumpServer.cs
 
-CHRONOJUMP_DEP = src/chronojump.cs src/person.cs src/event.cs src/eventType.cs src/jump.cs src/jumpType.cs src/run.cs src/runType.cs src/pulse.cs src/pulseType.cs src/reactionTime.cs src/reactionTimeType.cs src/multiChronopic.cs src/session.cs src/exportSession.cs src/treeViewEvent.cs src/treeViewPerson.cs src/treeViewJump.cs src/treeViewRun.cs src/treeViewPulse.cs src/treeViewReactionTime.cs src/treeViewMultiChronopic.cs src/util.cs src/utilGtk.cs src/constants.cs src/report.cs src/updateProgressBar.cs src/prepareEventGraphObjects.cs src/sport.cs src/log.cs src/serverPing.cs src/serverEvaluator.cs src/server.cs $(CHRONOJUMP_DEP_GUI) $(CHRONOJUMP_DEP_STATS) $(CHRONOJUMP_DEP_GRAPHS) $(CHRONOJUMP_DEP_SQLITE) $(CHRONOJUMP_DEP_REPORT) $(CHRONOJUMP_DEP_EXECUTE) $(CHRONOJUMP_DEP_SERVER)
+CHRONOJUMP_DEP = src/chronojump.cs src/person.cs src/event.cs src/eventType.cs src/jump.cs src/jumpType.cs src/run.cs src/runType.cs src/pulse.cs src/pulseType.cs src/reactionTime.cs src/reactionTimeType.cs src/multiChronopic.cs src/multiChronopicType.cs src/session.cs src/exportSession.cs src/treeViewEvent.cs src/treeViewPerson.cs src/treeViewJump.cs src/treeViewRun.cs src/treeViewPulse.cs src/treeViewReactionTime.cs src/treeViewMultiChronopic.cs src/util.cs src/utilGtk.cs src/constants.cs src/report.cs src/updateProgressBar.cs src/prepareEventGraphObjects.cs src/sport.cs src/log.cs src/serverPing.cs src/serverEvaluator.cs src/server.cs $(CHRONOJUMP_DEP_GUI) $(CHRONOJUMP_DEP_STATS) $(CHRONOJUMP_DEP_GRAPHS) $(CHRONOJUMP_DEP_SQLITE) $(CHRONOJUMP_DEP_REPORT) $(CHRONOJUMP_DEP_EXECUTE) $(CHRONOJUMP_DEP_SERVER)
 
 RESOURCES_GLADE = -resource:glade/chronojump.glade,chronojump.glade
 

Modified: trunk/build/data/chronojump.prg
==============================================================================
Binary files. No diff available.

Modified: trunk/build/data/chronojump_mini.prg
==============================================================================
Binary files. No diff available.

Modified: trunk/changelog.txt
==============================================================================
--- trunk/changelog.txt	(original)
+++ trunk/changelog.txt	Fri Mar 27 15:27:20 2009
@@ -36,8 +36,7 @@
 
 stats all and limit is not updating the treeview stats. 
 
-
-two chronopics in chronojump
+us Util.DetectPortsLinux in gui/help ports
 
 when person weight is updated, description of eg. margaria (with power)
 doesn't change. Should change or use another thing. Recreate all time in
@@ -72,6 +71,14 @@
 7          65       IN           40           50
 8          70           IN           40           50
 
+
+27 mar 2009
+	four chronopics can be connected from gui/chronojump.cs
+	and managed from multiChronopic (only tested with three)
+	it's a new way to connect chronopic, returning the cp
+
+	created src/multiChronopicType
+
 26 mar 2009 (2)
 	multiChronopic:
 	-connection of 4 chronopics now is done with the same gui as one

Modified: trunk/src/eventType.cs
==============================================================================
--- trunk/src/eventType.cs	(original)
+++ trunk/src/eventType.cs	Fri Mar 27 15:27:20 2009
@@ -23,7 +23,7 @@
 public partial class EventType 
 {
 	public enum Types {
-		JUMP, RUN, PULSE, REACTIONTIME
+		JUMP, RUN, PULSE, REACTIONTIME, MULTICHRONOPIC
 	}
 
 	protected Types type; //jump, run, reactionTime, pulse

Modified: trunk/src/execute/multiChronopic.cs
==============================================================================
--- trunk/src/execute/multiChronopic.cs	(original)
+++ trunk/src/execute/multiChronopic.cs	Fri Mar 27 15:27:20 2009
@@ -28,53 +28,80 @@
 
 public class MultiChronopicExecute : EventExecute
 {
-	//better as private and don't inherit, don't know why
-	//protected Chronopic cp;
 	private Chronopic cp;
 
 	//2nd Chronopic stuff
 	protected Thread thread2;
-	//SerialPort sp2;
 	private Chronopic cp2;
 	private Chronopic.Plataforma platformState2;
 	protected States loggedState2;
-	//private string port2;
 	
 	//3rd Chronopic stuff
 	protected Thread thread3;
-	//SerialPort sp3;
 	private Chronopic cp3;
 	private Chronopic.Plataforma platformState3;
 	protected States loggedState3;
-	//private string port3;
 	
 	//4th Chronopic stuff
 	protected Thread thread4;
-	//SerialPort sp4;
 	private Chronopic cp4;
 	private Chronopic.Plataforma platformState4;
 	protected States loggedState4;
-	//private string port4;
 	
 
 	static bool firstValue = true;
-
+	int chronopics; 
 	
 
 	public MultiChronopicExecute() {
 	}
 
 	//execution
-	//public MultiChronopicExecute(Chronopic cp, Gtk.Statusbar appbar, Gtk.Window app, string port2)
-	public MultiChronopicExecute(Chronopic cp, Gtk.Statusbar appbar, Gtk.Window app)
-	{
+	public MultiChronopicExecute(Chronopic cp, Gtk.Statusbar appbar, Gtk.Window app) {
 		this.cp = cp;
 		this.appbar = appbar;
 		this.app = app;
-		//this.port2 = port2;
-		
+	
+		chronopics = 1; 
+		initValues();	
+	}
+	
+	public MultiChronopicExecute(Chronopic cp, Chronopic cp2, Gtk.Statusbar appbar, Gtk.Window app) {
+		this.cp = cp;
+		this.cp2 = cp2;
+		this.appbar = appbar;
+		this.app = app;
+	
+		chronopics = 2; 
+		initValues();	
+	}
+	
+	public MultiChronopicExecute(Chronopic cp, Chronopic cp2, Chronopic cp3, Gtk.Statusbar appbar, Gtk.Window app) {
+		this.cp = cp;
+		this.cp2 = cp2;
+		this.cp3 = cp3;
+		this.appbar = appbar;
+		this.app = app;
+	
+		chronopics = 3; 
+		initValues();	
+	}
+
+	public MultiChronopicExecute(Chronopic cp, Chronopic cp2, Chronopic cp3, Chronopic cp4, Gtk.Statusbar appbar, Gtk.Window app) {
+		this.cp = cp;
+		this.cp2 = cp2;
+		this.cp3 = cp3;
+		this.cp4 = cp4;
+		this.appbar = appbar;
+		this.app = app;
+	
+		chronopics = 4; 
+		initValues();	
+	}
+
+
+	private void initValues() {
 		fakeButtonFinished = new Gtk.Button();
-		
 		simulated = false;
 	}
 	
@@ -88,204 +115,120 @@
 	protected override 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
-		 */
-
-		/*
-		//updateTimeProgressBar();
-		if(needEndEvent) {
-			eventExecuteWin.EventEnded();
-			//needEndEvent = false;
-		} else 
-			updateTimeProgressBar();
-		
-		
-		if(simulated) {
-			eventSimulatedShouldChangePlatform();
-		}
-
-		if(needUpdateEventProgressBar) {
-			//update event progressbar
-			eventExecuteWin.ProgressBarEventOrTimePreExecution(
-					updateProgressBar.IsEvent,
-					updateProgressBar.PercentageMode,
-					updateProgressBar.ValueToShow
-					);  
-
-			needUpdateEventProgressBar = false;
-		}
-		
-	
-		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();
-		*/
 	}
 			
-/*
-	//private bool connectChronopic2(string myPort) 
-	private bool connectOtherChronopics(Chronopic myCp, SerialPort mySp, Chronopic.Plataforma myPS, string myPort) 
-	{
-		bool success = false;
-		try {
-			Log.WriteLine(string.Format("chronopic port: {0}", myPort));
-			mySp = new SerialPort(myPort);
-			mySp.Open();
-			//-- Create chronopic object, for accessing chronopic
-			myCp = new Chronopic(mySp);
-
-			//-- Obtener el estado inicial de la plataforma
-			bool ok=false;
-			do
-				ok=myCp.Read_platform(out myPS);
-			while(!ok);
-			if (!ok) {
-				//-- Si hay error terminar
-				Log.WriteLine(string.Format("Error: {0}", myCp.Error));
-				success = false;
-			}
-		} catch {
-			success = false;
-		}
-		return success;
-	}
-*/
 
 	public override void Manage()
 	{
-		/*
-		connectOtherChronopics(cp2, sp2, platformState2, port2);
-		//connectOtherChronopics(cp3, sp3, platformState3, port3);
-		//connectOtherChronopics(cp4, sp4, platformState4, port4);
-		*/
-
-		platformState = chronopicInitialValue(cp);
-		platformState2 = chronopicInitialValue(cp2);
-		//platformState3 = chronopicInitialValue(cp3);
-		//platformState4 = chronopicInitialValue(cp4);
+		if(chronopics > 0) {
+			platformState = chronopicInitialValue(cp);
 		
-		string cpStr = "";
-		string cp2Str = "";
-		//3
-		//4
+			string cpStr = "";
+			if (platformState==Chronopic.Plataforma.ON) {
+				cpStr = "cp1" + " " + "IN";
+				loggedState = States.ON;
+			} else {
+				cpStr = "cp1" + " " + "OUT";
+				loggedState = States.OFF;
+			}
+			appbar.Push( 1, cpStr);
 		
-		if (platformState==Chronopic.Plataforma.ON) {
-			cpStr = "cp1" + " " + "IN";
-			loggedState = States.ON;
-		} else {
-			cpStr = "cp1" + " " + "OUT";
-			loggedState = States.OFF;
-		}
-			
-		if (platformState2==Chronopic.Plataforma.ON) {
-			cp2Str = "cp2" + " " + "IN";
-			loggedState2 = States.ON;
-		} else {
-			cp2Str = "cp2" + " " + "OUT";
-			loggedState2 = States.OFF;
-		}
-		//3
-		//4
-			
-		appbar.Push( 1, cpStr + " / " + cp2Str);
+			if(chronopics > 1) {
+				platformState2 = chronopicInitialValue(cp2);
+		
+				string cp2Str = "";
+				if (platformState2==Chronopic.Plataforma.ON) {
+					cp2Str = "cp2" + " " + "IN";
+					loggedState2 = States.ON;
+				} else {
+					cp2Str = "cp2" + " " + "OUT";
+					loggedState2 = States.OFF;
+				}
+				appbar.Push( 1, cpStr + " / " + cp2Str);
 
-		//start thread
-		//Log.Write("Start thread");
-		thread = new Thread(new ThreadStart(waitEvent));
-		thread2 = new Thread(new ThreadStart(waitEvent2));
-		//3
-		//4
+				if(chronopics > 2) {
+					platformState3 = chronopicInitialValue(cp3);
 
-		GLib.Idle.Add (new GLib.IdleHandler (PulseGTK));
+					string cp3Str = "";
+					if (platformState3==Chronopic.Plataforma.ON) {
+						cp3Str = "cp3" + " " + "IN";
+						loggedState3 = States.ON;
+					} else {
+						cp3Str = "cp3" + " " + "OUT";
+						loggedState3 = States.OFF;
+					}
+					appbar.Push( 1, cpStr + " / " + cp2Str + "/" + cp3Str);
 
-		thread.Start(); 
-		thread2.Start(); 
-		//3
-		//4
-	}
+					if(chronopics > 3) {
+						platformState4 = chronopicInitialValue(cp4);
 
-	
-	protected override void waitEvent ()
-	{
-		double timestamp = 0;
-		bool success = false;
-		bool ok;
-
-		do {
-			ok = cp.Read_event(out timestamp, out platformState);
-			
-			//if chronopic signal is Ok and state has changed
-			if (ok && (
-					(platformState == Chronopic.Plataforma.ON && loggedState == States.OFF) ||
-					(platformState == Chronopic.Plataforma.OFF && loggedState == States.ON) ) 
-						&& !cancel && !finish) {
-				
-				//while no finished time or jumps, continue recording events
-				if ( ! success) {
-					//don't record the time until the first event
-					if (firstValue) {
-						firstValue = false;
+						string cp4Str = "";
+						if (platformState4==Chronopic.Plataforma.ON) {
+							cp4Str = "cp4" + " " + "IN";
+							loggedState4 = States.ON;
+						} else {
+							cp4Str = "cp4" + " " + "OUT";
+							loggedState4 = States.OFF;
+						}
+						appbar.Push( 1, cpStr + " / " + cp2Str + "/" + cp3Str + "/" + cp4Str);
+					}
+				}
+			}
+		}
 
-						//but start timer
-						initializeTimer();
-					} else {
-						if(platformState == Chronopic.Plataforma.ON && loggedState == States.OFF)
-							Log.WriteLine("cp1 landed");
-						else if(platformState == Chronopic.Plataforma.OFF && loggedState == States.ON)
-							Log.WriteLine("cp1 jumped");
-								
-						needSensitiveButtonFinish = true;
+		//start thread
+		if(chronopics > 0) {
+			thread = new Thread(new ThreadStart(waitEventPre));
+			if(chronopics > 1) {
+				thread2 = new Thread(new ThreadStart(waitEventPre2));
+				if(chronopics > 2) {
+					thread3 = new Thread(new ThreadStart(waitEventPre3));
+					if(chronopics > 3) {
+						thread4 = new Thread(new ThreadStart(waitEventPre4));
 					}
 				}
+			}
+		}
 
-				if(platformState == Chronopic.Plataforma.OFF)
-					loggedState = States.OFF;
-				else
-					loggedState = States.ON;
+		GLib.Idle.Add (new GLib.IdleHandler (PulseGTK));
 
+		if(chronopics > 0) {
+			thread.Start(); 
+			if(chronopics > 1) {
+				thread2.Start(); 
+				if(chronopics > 2) {
+					thread3.Start(); 
+					if(chronopics > 4) {
+						thread4.Start(); 
+					}
+				}
 			}
-		} while ( ! success && ! cancel && ! finish );
-	
-		if (finish) {
-			totallyFinished = true;
-		}
-		if(cancel) {
-			//event will be raised, and managed in chronojump.cs
-			fakeButtonFinished.Click();
-			totallyCancelled = true;
 		}
+
 	}
-		
-	private void waitEvent2 ()
+
+	protected void waitEventPre () { waitEvent(cp, platformState, loggedState, "cp1"); }
+	
+	protected void waitEventPre2 () { waitEvent(cp2, platformState2, loggedState2, "cp2"); }
+	
+	protected void waitEventPre3 () { waitEvent(cp3, platformState3, loggedState3, "cp3"); }
+	
+	protected void waitEventPre4 () { waitEvent(cp4, platformState4, loggedState4, "cp4"); }
+	
+	
+	protected void waitEvent (Chronopic myCP, Chronopic.Plataforma myPS, States myLS, string cpStr)
 	{
 		double timestamp = 0;
 		bool success = false;
 		bool ok;
 
 		do {
-			ok = cp2.Read_event(out timestamp, out platformState2);
+			ok = myCP.Read_event(out timestamp, out myPS);
 			
 			//if chronopic signal is Ok and state has changed
 			if (ok && (
-					(platformState2 == Chronopic.Plataforma.ON && loggedState2 == States.OFF) ||
-					(platformState2 == Chronopic.Plataforma.OFF && loggedState2 == States.ON) ) 
+					(myPS == Chronopic.Plataforma.ON && myLS == States.OFF) ||
+					(myPS == Chronopic.Plataforma.OFF && myLS == States.ON) ) 
 						&& !cancel && !finish) {
 				
 				//while no finished time or jumps, continue recording events
@@ -293,23 +236,21 @@
 					//don't record the time until the first event
 					if (firstValue) {
 						firstValue = false;
-
-						//but start timer
 						initializeTimer();
-					} else {
-						if(platformState2 == Chronopic.Plataforma.ON && loggedState2 == States.OFF)
-							Log.WriteLine("cp2 landed");
-						else if(platformState2 == Chronopic.Plataforma.OFF && loggedState2 == States.ON)
-							Log.WriteLine("cp2 jumped");
-								
+					} else 
 						needSensitiveButtonFinish = true;
-					}
+						
+					if(myPS == Chronopic.Plataforma.ON && myLS == States.OFF)
+						Log.WriteLine(cpStr + " landed");
+					else if(myPS == Chronopic.Plataforma.OFF && myLS == States.ON)
+						Log.WriteLine(cpStr + " jumped");
+
 				}
 
-				if(platformState2 == Chronopic.Plataforma.OFF)
-					loggedState2 = States.OFF;
+				if(myPS == Chronopic.Plataforma.OFF)
+					myLS = States.OFF;
 				else
-					loggedState2 = States.ON;
+					myLS = States.ON;
 
 			}
 		} while ( ! success && ! cancel && ! finish );

Modified: trunk/src/gui/chronojump.cs
==============================================================================
--- trunk/src/gui/chronojump.cs	(original)
+++ trunk/src/gui/chronojump.cs	Fri Mar 27 15:27:20 2009
@@ -609,47 +609,43 @@
 	}
 
 	//chronopic init should not touch  gtk, for the threads
-	//private bool chronopicInit (string myPort, out string returnString)
-	private bool chronopicInit (Chronopic myCp, SerialPort mySp, Chronopic.Plataforma myPS, string myPort, out string returnString) 
+	private Chronopic chronopicInit (Chronopic myCp, SerialPort mySp, Chronopic.Plataforma myPS, string myPort, out string returnString, out bool success) 
 	{
 		Log.WriteLine ( Catalog.GetString ("starting connection with chronopic") );
-		if(!Util.IsWindows())
+		if(Util.IsWindows())
 			Log.WriteLine ( Catalog.GetString ("If you have previously used the modem via a serial port (in a GNU/Linux session, and you selected serial port), Chronojump will crash.") );
 
-		bool success = true;
+		success = true;
 		
 		try {
-Log.WriteLine("+++++++++++++++++ 1 ++++++++++++++++");		
+			Log.WriteLine("+++++++++++++++++ 1 ++++++++++++++++");		
 			Log.WriteLine(string.Format("chronopic port: {0}", myPort));
 			mySp = new SerialPort(myPort);
 			mySp.Open();
-Log.WriteLine("+++++++++++++++++ 2 ++++++++++++++++");		
+			Log.WriteLine("+++++++++++++++++ 2 ++++++++++++++++");		
 			//-- Create chronopic object, for accessing chronopic
 			myCp = new Chronopic(mySp);
 
-Log.WriteLine("+++++++++++++++++ 3 ++++++++++++++++");		
+			Log.WriteLine("+++++++++++++++++ 3 ++++++++++++++++");		
 			//on windows, this check make a crash 
 			//i think the problem is: as we don't really know the Timeout on Windows (.NET) and this variable is not defined on chronopic.cs
 			//the Read_platform comes too much soon (when cp is not totally created), and this makes crash
 
-			//not used, now there's no .NET this was .NET related
-			//on mono timeouts work on windows and linux
-			//			if ( ! Util.IsWindows()) {
-				//-- Obtener el estado inicial de la plataforma
-				bool ok=false;
-Log.WriteLine("+++++++++++++++++ 4 ++++++++++++++++");		
-				do {
-Log.WriteLine("+++++++++++++++++ 5 ++++++++++++++++");		
-					ok=myCp.Read_platform(out myPS);
-Log.WriteLine("+++++++++++++++++ 6 ++++++++++++++++");		
-				} while(!ok);
-Log.WriteLine("+++++++++++++++++ 7 ++++++++++++++++");		
-				if (!ok) {
-					//-- Si hay error terminar
-					Log.WriteLine(string.Format("Error: {0}", myCp.Error));
-					success = false;
-				}
-			//}
+			//-- Obtener el estado inicial de la plataforma
+
+			bool ok=false;
+			Log.WriteLine("+++++++++++++++++ 4 ++++++++++++++++");		
+			do {
+				Log.WriteLine("+++++++++++++++++ 5 ++++++++++++++++");		
+				ok=myCp.Read_platform(out myPS);
+				Log.WriteLine("+++++++++++++++++ 6 ++++++++++++++++");		
+			} while(!ok);
+			Log.WriteLine("+++++++++++++++++ 7 ++++++++++++++++");		
+			if (!ok) {
+				//-- Si hay error terminar
+				Log.WriteLine(string.Format("Error: {0}", myCp.Error));
+				success = false;
+			}
 		} catch {
 			success = false;
 		}
@@ -678,7 +674,7 @@
 				cpRunning = false;
 			}
 		}
-		return success;
+		return myCp;
 	}
 	
 	private void loadPreferences () 
@@ -1597,28 +1593,6 @@
 	}
 
 
-	private void on_button_multi_chronopic_start_clicked (object o, EventArgs args) {
-				
-		//TODO: check this is ok: entry_multi_chronopic_cp2);
-		//
-		//
-		//if there are n chronopics, call next function n times
-		//or 
-		//call one time with different parameters (will have 4 different constructors)
-		//
-		//
-		//
-		currentEventExecute = new MultiChronopicExecute(cp, appbar2, app1);
-
-		currentEventExecute.Manage();
-
-		currentEventExecute.FakeButtonFinished.Clicked += new EventHandler(on_multi_chronopic_finished);
-	}
-
-	private void on_multi_chronopic_finished (object o, EventArgs args) {
-		currentEventExecute.FakeButtonFinished.Clicked -= new EventHandler(on_multi_chronopic_finished);
-	}
-		
 
 
 	/* ---------------------------------------------------------
@@ -2282,26 +2256,8 @@
 			return;
 		}
 
-
 		Log.WriteLine("RadioChronopic - ACTIVE");
 	
-		//done also in linux because mono-1.2.3 throws an exception when there's a timeout
-		//http://bugzilla.gnome.org/show_bug.cgi?id=420520
-
-		/*
-		ChronopicConnection chronopicWin = ChronopicConnection.Show();
-		chronopicWin.LabelFeedBackReset();
-
-		chronopicWin.Button_cancel.Clicked += new EventHandler(on_chronopic_cancelled);
-		
-		fakeChronopicButton = new Gtk.Button();
-		fakeChronopicButton.Clicked += new EventHandler(on_chronopic_detection_ended);
-
-		thread = new Thread(new ThreadStart(waitChronopicStart));
-		GLib.Idle.Add (new GLib.IdleHandler (PulseGTK));
-		thread.Start(); 
-		*/
-
 		currentCp = 1;
 		prepareChronopicConnection();
 	}
@@ -2336,7 +2292,7 @@
 		bool success = false;
 
 		if(currentCp == 1) {
-			success	= chronopicInit(cp, sp, platformState, chronopicPort, out message);
+			cp = chronopicInit(cp, sp, platformState, chronopicPort, out message, out success);
 			if(success) {
 				vbox_multi_chronopic_selectors.Sensitive = true;
 				frame_chronopic2.Sensitive = true;
@@ -2350,7 +2306,7 @@
 				myPort = UtilGtk.ComboGetActive(combo_port_windows2);
 			else
 				myPort = UtilGtk.ComboGetActive(combo_port_linux2);
-			success	= chronopicInit(cp2, sp2, platformState2, myPort, out message);
+			cp2 = chronopicInit(cp2, sp2, platformState2, myPort, out message, out success);
 			if(success) {
 				image_cp2_no.Hide();
 				image_cp2_yes.Show();
@@ -2365,7 +2321,7 @@
 				myPort = UtilGtk.ComboGetActive(combo_port_windows3);
 			else
 				myPort = UtilGtk.ComboGetActive(combo_port_linux3);
-			success	= chronopicInit(cp3, sp3, platformState3, myPort, out message);
+			cp3 = chronopicInit(cp3, sp3, platformState3, myPort, out message, out success);
 			if(success) {
 				image_cp3_no.Hide();
 				image_cp3_yes.Show();
@@ -2380,7 +2336,7 @@
 				myPort = UtilGtk.ComboGetActive(combo_port_windows4);
 			else
 				myPort = UtilGtk.ComboGetActive(combo_port_linux4);
-			success	= chronopicInit(cp4, sp4, platformState4, myPort, out message);
+			cp4 = chronopicInit(cp4, sp4, platformState4, myPort, out message, out success);
 			if(success) {
 				image_cp4_no.Hide();
 				image_cp4_yes.Show();
@@ -3702,7 +3658,7 @@
 
 
 	/* ---------------------------------------------------------
-	 * ----------------  PULSES EXECUTION ----------- ----------
+	 * ----------------  PULSES EXECUTION ----------------------
 	 *  --------------------------------------------------------
 	 */
 
@@ -3860,6 +3816,76 @@
 		sensitiveGuiEventDone();
 	}
 
+	/* ---------------------------------------------------------
+	 * ----------------  MULTI CHRONOPIC EXECUTION -------------
+	 *  --------------------------------------------------------
+	 */
+
+
+	private void on_button_multi_chronopic_start_clicked (object o, EventArgs args) {
+		Log.WriteLine("multi chronopic accepted");
+
+		//used by cancel and finish
+		currentEventType = new MultiChronopicType();
+			
+		//hide pulse buttons
+		sensitiveGuiEventDoing();
+		
+		//change to page 6 of notebook if were in other
+		notebook_change(6);
+		
+		//don't let update until test finishes
+		if(createdStatsWin)
+			statsWin.HideUpdateStatsButton();
+
+		//show the event doing window
+		eventExecuteWin = EventExecuteWindow.Show(
+			Catalog.GetString("Execute Multi Chronopic"), //windowTitle
+			Catalog.GetString("Changes"),  	  //name of the different moments
+			currentPerson.UniqueID, currentPerson.Name, 
+			currentSession.UniqueID, 
+			Constants.MultiChronopicTable, //tableName
+			//currentPulseType.Name, 
+			"", 
+			prefsDigitsNumber, -1, simulated); //-1: unlimited pulses (or changes)
+
+		eventExecuteWin.ButtonCancel.Clicked += new EventHandler(on_cancel_clicked);
+		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
+		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);
+
+
+		/*
+		currentEventExecute = new MultiChronopicExecute(eventExecuteWin, currentPerson.UniqueID, currentPerson.Name, 
+				currentSession.UniqueID, currentPulseType.Name, pulseStep, totalPulses, 
+				cp, appbar2, app1, prefsDigitsNumber, volumeOn);
+				*/
+
+		if(image_cp2_yes.Visible && image_cp3_no.Visible)
+			currentEventExecute = new MultiChronopicExecute(cp, cp2, appbar2, app1);
+		else if(image_cp3_yes.Visible && image_cp4_no.Visible)
+			currentEventExecute = new MultiChronopicExecute(cp, cp2, cp3, appbar2, app1);
+		else if(image_cp4_yes.Visible)
+			currentEventExecute = new MultiChronopicExecute(cp, cp2, cp3, cp4, appbar2, app1);
+
+		//if(simulated)	
+		//	currentEventExecute.SimulateInitValues(rand);
+
+
+		currentEventExecute.Manage();
+
+		currentEventExecute.FakeButtonFinished.Clicked += new EventHandler(on_multi_chronopic_finished);
+	}
+
+	private void on_multi_chronopic_finished (object o, EventArgs args) {
+		currentEventExecute.FakeButtonFinished.Clicked -= new EventHandler(on_multi_chronopic_finished);
+	}
+		
+
+
 
 	/*
 	 * update button is clicked on eventWindow, chronojump.cs delegate points here

Added: trunk/src/multiChronopicType.cs
==============================================================================
--- (empty file)
+++ trunk/src/multiChronopicType.cs	Fri Mar 27 15:27:20 2009
@@ -0,0 +1,31 @@
+/*
+ * This file is part of ChronoJump
+ *
+ * ChronoJump is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or   
+ *    (at your option) any later version.
+ *    
+ * ChronoJump is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *    GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Xavier de Blas: 
+ */
+
+using System;
+using System.Data;
+
+public class MultiChronopicType : EventType 
+{
+	public MultiChronopicType() {
+		type = Types.MULTICHRONOPIC;
+	}
+	
+}
+



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