[chronojump] disconnected chronopic detected by all events



commit e6377eb55b32a6bcfcd97d186eea56059f1b4591
Author: Xavier de Blas <xaviblas master gnome org>
Date:   Wed Jun 2 17:12:54 2010 +0800

    disconnected chronopic detected by all events

 po/POTFILES.in                |    1 +
 src/execute/event.cs          |   12 +++++++++++-
 src/execute/jump.cs           |   40 +++++++++++++++++++++++++++++++---------
 src/execute/multiChronopic.cs |   23 +++++++++++++++++++----
 src/execute/pulse.cs          |    8 +++++++-
 src/execute/reactionTime.cs   |    8 +++++++-
 src/execute/run.cs            |   22 +++++++++++++++++++++-
 src/gui/chronojump.cs         |   27 ++++++++++++++++++++++++++-
 8 files changed, 123 insertions(+), 18 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 192a3bc..e83e41a 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -3,6 +3,7 @@ src/constants.cs
 glade/chronojump.glade
 src/chronojump.cs
 src/chronojump_mini.cs
+src/execute/event.cs
 src/execute/jump.cs
 src/execute/multiChronopic.cs
 src/execute/pulse.cs
diff --git a/src/execute/event.cs b/src/execute/event.cs
index 0d79821..d74a4e3 100644
--- a/src/execute/event.cs
+++ b/src/execute/event.cs
@@ -24,6 +24,7 @@ using System.Text; //StringBuilder
 
 using System.Threading;
 using System.IO.Ports;
+using Mono.Unix;
 
 
 public class EventExecute 
@@ -452,7 +453,6 @@ public class EventExecute
 	protected virtual void write() {
 	}
 
-
 	protected virtual void goodEvent() {
 		Util.PlaySound(Constants.SoundTypes.GOOD, volumeOn);
 	} 
@@ -472,6 +472,16 @@ public class EventExecute
 		//event will be raised, and managed in chronojump.cs
 		fakeButtonFinished.Click();
 	}
+
+	protected void chronopicHasBeenDisconnected() {
+		chronopicDisconnected = true;
+		ErrorWindow errorWin;		
+		errorWin = ErrorWindow.Show( 
+				Catalog.GetString("Chronopic seems disconnected. Reconnect again on Chronopic Window."));
+
+		Util.PlaySound(Constants.SoundTypes.BAD, volumeOn);
+		errorWin.Button_accept.Clicked += new EventHandler(cancel_event_before_start);
+	}
 	
 	public virtual bool MultiChronopicRunAUsedCP2() {
 		return false;
diff --git a/src/execute/jump.cs b/src/execute/jump.cs
index c5f9cb1..a9ed2d3 100644
--- a/src/execute/jump.cs
+++ b/src/execute/jump.cs
@@ -110,6 +110,9 @@ public class JumpExecute : EventExecute
 	
 	public override void Manage()
 	{
+		//boolean to know if chronopic has been disconnected	
+		chronopicDisconnected = false;
+
 		if (simulated) 
 			platformState = Chronopic.Plataforma.ON;
 		else
@@ -126,9 +129,6 @@ public class JumpExecute : EventExecute
 			cancel = false;
 			totallyCancelled = false;
 	
-			//boolean to know if chronopic has been disconnected	
-			chronopicDisconnected = false;
-
 			//in simulated mode, make the jump start just when we arrive to waitEvent at the first time
 			//mark now that we have leaved platform:
 			if (simulated)
@@ -154,6 +154,8 @@ public class JumpExecute : EventExecute
 			confirmWin.Button_cancel.Clicked += new EventHandler(cancel_event_before_start);
 		}
 		else { //UNKNOW (Chronopic disconnected, port changed, ...)
+			chronopicHasBeenDisconnected();
+/*
 			chronopicDisconnected = true;
 			ErrorWindow errorWin;		
 			errorWin = ErrorWindow.Show( 
@@ -162,11 +164,15 @@ public class JumpExecute : EventExecute
 			Util.PlaySound(Constants.SoundTypes.BAD, volumeOn);
 
 			errorWin.Button_accept.Clicked += new EventHandler(cancel_event_before_start);
+*/
 		}
 	}
 
 	public override void ManageFall()
 	{
+		//boolean to know if chronopic has been disconnected	
+		chronopicDisconnected = false;
+
 		if (simulated) 
 			platformState = Chronopic.Plataforma.OFF;
 		else
@@ -186,10 +192,6 @@ public class JumpExecute : EventExecute
 			cancel = false;
 			totallyCancelled = false;
 
-			//boolean to know if chronopic has been disconnected	
-			chronopicDisconnected = false;
-
-
 			//in simulated mode, make the jump start just when we arrive to waitEvent at the first time
 			//mark now that we have arrived:
 			if (simulated)
@@ -213,6 +215,8 @@ public class JumpExecute : EventExecute
 			confirmWin.Button_cancel.Clicked += new EventHandler(cancel_event_before_start);
 		}
 		else { //UNKNOW (Chronopic disconnected, port changed, ...)
+			chronopicHasBeenDisconnected();
+/*
 			chronopicDisconnected = true;
 			ErrorWindow errorWin;		
 			errorWin = ErrorWindow.Show( 
@@ -221,6 +225,7 @@ public class JumpExecute : EventExecute
 			Util.PlaySound(Constants.SoundTypes.BAD, volumeOn);
 
 			errorWin.Button_accept.Clicked += new EventHandler(cancel_event_before_start);
+*/
 		}
 	}
 	
@@ -525,6 +530,9 @@ public class JumpRjExecute : JumpExecute
 
 	public override void Manage()
 	{
+		//boolean to know if chronopic has been disconnected	
+		chronopicDisconnected = false;
+
 		if (simulated)
 			if(hasFall) 
 				platformState = Chronopic.Plataforma.OFF;
@@ -535,8 +543,22 @@ public class JumpRjExecute : JumpExecute
 
 		if(platformState == Chronopic.Plataforma.OFF)
 			loggedState = States.OFF;
-		else
+		else if(platformState == Chronopic.Plataforma.OFF)
 			loggedState = States.ON;
+		else { //UNKNOW (Chronopic disconnected, port changed, ...)
+/*
+			chronopicDisconnected = true;
+			ErrorWindow errorWin;		
+			errorWin = ErrorWindow.Show( 
+					Catalog.GetString("Chronopic seems disconnected. Reconnect again on Chronopic Window."));
+			Util.PlaySound(Constants.SoundTypes.BAD, volumeOn);
+
+			errorWin.Button_accept.Clicked += new EventHandler(cancel_event_before_start);
+*/
+			
+			chronopicHasBeenDisconnected();
+			return;
+		}
 
 		
 		bool success = false;
@@ -586,7 +608,7 @@ public class JumpRjExecute : JumpExecute
 			//prepare jump for being finished earlier if desired
 			finish = false;
 			totallyFinished = false;
-
+			
 			//in simulated mode, make the jump start just when we arrive to waitEvent at the first time
 			//mark now that the opposite as before:
 			if (simulated) {
diff --git a/src/execute/multiChronopic.cs b/src/execute/multiChronopic.cs
index 6b975b7..77eac94 100644
--- a/src/execute/multiChronopic.cs
+++ b/src/execute/multiChronopic.cs
@@ -203,15 +203,21 @@ public class MultiChronopicExecute : EventExecute
 
 	public override void Manage()
 	{
+		//boolean to know if chronopic has been disconnected	
+		chronopicDisconnected = false;
+		
 		if(chronopics > 0) {
 			platformState = chronopicInitialValue(cp);
 		
 			if (platformState==Chronopic.Plataforma.ON) {
 				loggedState = States.ON;
 				cp1StartedIn = true;
-			} else {
+			} else if (platformState==Chronopic.Plataforma.OFF) {
 				loggedState = States.OFF;
 				cp1StartedIn = false;
+			} else { //UNKNOW (Chronopic disconnected, port changed, ...)
+				chronopicHasBeenDisconnected();
+				return;
 			}
 		
 			//prepare jump for being cancelled if desired
@@ -229,9 +235,12 @@ public class MultiChronopicExecute : EventExecute
 				if (platformState2==Chronopic.Plataforma.ON) {
 					loggedState2 = States.ON;
 					cp2StartedIn = true;
-				} else {
+				} else if (platformState==Chronopic.Plataforma.OFF) {
 					loggedState2 = States.OFF;
 					cp2StartedIn = false;
+				} else { //UNKNOW (Chronopic disconnected, port changed, ...)
+					chronopicHasBeenDisconnected();
+					return;
 				}
 			
 				totallyCancelledMulti2 = false;
@@ -244,9 +253,12 @@ public class MultiChronopicExecute : EventExecute
 					if (platformState3==Chronopic.Plataforma.ON) {
 						loggedState3 = States.ON;
 						cp3StartedIn = true;
-					} else {
+					} else if (platformState==Chronopic.Plataforma.OFF) {
 						loggedState3 = States.OFF;
 						cp3StartedIn = false;
+					} else { //UNKNOW (Chronopic disconnected, port changed, ...)
+						chronopicHasBeenDisconnected();
+						return;
 					}
 
 					totallyCancelledMulti3 = false;
@@ -258,9 +270,12 @@ public class MultiChronopicExecute : EventExecute
 						if (platformState4==Chronopic.Plataforma.ON) {
 							loggedState4 = States.ON;
 							cp4StartedIn = true;
-						} else {
+						} else if (platformState==Chronopic.Plataforma.OFF) {
 							loggedState4 = States.OFF;
 							cp4StartedIn = false;
+						} else { //UNKNOW (Chronopic disconnected, port changed, ...)
+							chronopicHasBeenDisconnected();
+							return;
 						}
 					
 						totallyCancelledMulti4 = false;
diff --git a/src/execute/pulse.cs b/src/execute/pulse.cs
index cbb9741..1d26833 100644
--- a/src/execute/pulse.cs
+++ b/src/execute/pulse.cs
@@ -106,6 +106,8 @@ public class PulseExecute : EventExecute
 	{
 		bool success = false;
 		
+		//boolean to know if chronopic has been disconnected	
+		chronopicDisconnected = false;
 		
 		if (simulated) 
 			platformState = Chronopic.Plataforma.OFF;
@@ -125,7 +127,7 @@ public class PulseExecute : EventExecute
 
 			//we call again this function
 			confirmWin.Button_accept.Clicked += new EventHandler(callAgainManage);
-		} else {
+		} else if (platformState==Chronopic.Plataforma.OFF) {
 			appbar.Push( 1, Catalog.GetString("You are OUT, start when prepared!!") );
 			Util.PlaySound(Constants.SoundTypes.CAN_START, volumeOn);
 
@@ -133,6 +135,10 @@ public class PulseExecute : EventExecute
 
 			success = true;
 		}
+		else { //UNKNOW (Chronopic disconnected, port changed, ...)
+			chronopicHasBeenDisconnected();
+			return;
+		}
 
 		if(success) {
 			//initialize variables
diff --git a/src/execute/reactionTime.cs b/src/execute/reactionTime.cs
index 8cd2e7d..34f14e2 100644
--- a/src/execute/reactionTime.cs
+++ b/src/execute/reactionTime.cs
@@ -87,6 +87,9 @@ public class ReactionTimeExecute : EventExecute
 	
 	public override void Manage()
 	{
+		//boolean to know if chronopic has been disconnected	
+		chronopicDisconnected = false;
+
 		if (simulated) 
 			platformState = Chronopic.Plataforma.ON;
 		else
@@ -115,7 +118,7 @@ public class ReactionTimeExecute : EventExecute
 			GLib.Idle.Add (new GLib.IdleHandler (PulseGTK));
 			thread.Start(); 
 		} 
-		else {
+		else if (platformState==Chronopic.Plataforma.OFF) {
 			ConfirmWindow confirmWin;		
 			confirmWin = ConfirmWindow.Show( 
 					Catalog.GetString("You are OUT, come inside and press the 'accept' button"), "", "");
@@ -128,6 +131,9 @@ public class ReactionTimeExecute : EventExecute
 			//if confirmWin.Button_cancel is pressed retuen
 			confirmWin.Button_cancel.Clicked += new EventHandler(cancel_event_before_start);
 		}
+		else { //UNKNOW (Chronopic disconnected, port changed, ...)
+			chronopicHasBeenDisconnected();
+		}
 	}
 
 	
diff --git a/src/execute/run.cs b/src/execute/run.cs
index 029c444..05ac4be 100644
--- a/src/execute/run.cs
+++ b/src/execute/run.cs
@@ -98,6 +98,10 @@ public class RunExecute : EventExecute
 	public override void Manage()
 	{
 Log.WriteLine("MANAGE!!!!");
+			
+		//boolean to know if chronopic has been disconnected	
+		chronopicDisconnected = false;
+
 		if (simulated) 
 			platformState = Chronopic.Plataforma.ON;
 		else
@@ -114,7 +118,7 @@ Log.WriteLine("MANAGE(b)!!!!");
 			loggedState = States.ON;
 			startIn = true;
 			runPhase = runPhases.PLATFORM_INI;
-		} else {
+		} else if (platformState==Chronopic.Plataforma.OFF) {
 			appbar.Push( 1,Catalog.GetString("You are OUT, RUN when prepared!!") );
 			Util.PlaySound(Constants.SoundTypes.CAN_START, volumeOn);
 
@@ -122,6 +126,21 @@ Log.WriteLine("MANAGE(b)!!!!");
 			startIn = false;
 			runPhase = runPhases.PRE_RUNNING;
 		}
+		else { //UNKNOW (Chronopic disconnected, port changed, ...)
+			chronopicHasBeenDisconnected();
+			return;
+/*
+			chronopicDisconnected = true;
+			ErrorWindow errorWin;		
+			errorWin = ErrorWindow.Show( 
+					Catalog.GetString("Chronopic seems disconnected. Reconnect again on Chronopic Window."));
+
+			Util.PlaySound(Constants.SoundTypes.BAD, volumeOn);
+
+			errorWin.Button_accept.Clicked += new EventHandler(cancel_event_before_start);
+*/
+		}
+
 	
 		if (simulated) {
 			if(startIn) {
@@ -149,6 +168,7 @@ Log.WriteLine("MANAGE(b)!!!!");
 		cancel = false;
 		totallyCancelled = false;
 
+
 Log.WriteLine("MANAGE(2)!!!!");
 		//start thread
 		thread = new Thread(new ThreadStart(waitEvent));
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 00ba339..b7fe0df 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -2913,7 +2913,8 @@ Console.WriteLine("X");
 		
 			//unhide buttons for delete last jump
 			sensitiveGuiYesEvent();
-		} else if( currentEventExecute.ChronopicDisconnected ) {
+		} 
+		else if( currentEventExecute.ChronopicDisconnected ) {
 			Log.WriteLine("DISCONNECTED gui/cj");
 			createChronopicWindow(true);
 		}
@@ -3128,6 +3129,10 @@ Console.WriteLine("X");
 			eventExecuteWin.LabelTimeValue = Util.GetTotalTime(currentJumpRj.TcString, currentJumpRj.TvString);
 			//possible deletion of last jump can make the jumps on event window be false
 			eventExecuteWin.LabelEventValue = currentJumpRj.Jumps;
+		} 
+		else if( currentEventExecute.ChronopicDisconnected ) {
+			Log.WriteLine("DISCONNECTED gui/cj");
+			createChronopicWindow(true);
 		}
 		
 		//delete the temp tables if exists
@@ -3330,6 +3335,10 @@ Console.WriteLine("X");
 			//put correct time value in eventWindow (put the time from chronopic and not onTimer soft chronometer)
 			eventExecuteWin.LabelTimeValue = currentRun.Time;
 		}
+		else if( currentEventExecute.ChronopicDisconnected ) {
+			Log.WriteLine("DISCONNECTED gui/cj");
+			createChronopicWindow(true);
+		}
 		
 		//unhide buttons that allow jumping, running
 		sensitiveGuiEventDone();
@@ -3536,6 +3545,10 @@ Console.WriteLine("X");
 			//possible deletion of last run can make the runs on event window be false
 			eventExecuteWin.LabelEventValue = currentRunInterval.Tracks;
 		}
+		else if( currentEventExecute.ChronopicDisconnected ) {
+			Log.WriteLine("DISCONNECTED gui/cj");
+			createChronopicWindow(true);
+		}
 		
 		//delete the temp tables if exists
 		Sqlite.DeleteTempEvents("tempRunInterval");
@@ -3638,6 +3651,10 @@ Console.WriteLine("X");
 			//unhide buttons for delete last reaction time
 			sensitiveGuiYesEvent();
 		}
+		else if( currentEventExecute.ChronopicDisconnected ) {
+			Log.WriteLine("DISCONNECTED gui/cj");
+			createChronopicWindow(true);
+		}
 		
 		//unhide buttons that allow jumping
 		sensitiveGuiEventDone();
@@ -3799,6 +3816,10 @@ Console.WriteLine("X");
 			//put correct time value in eventWindow (put the time from chronopic and not onTimer soft chronometer)
 			eventExecuteWin.LabelTimeValue = Util.GetTotalTime(currentPulse.TimesString);
 		}
+		else if( currentEventExecute.ChronopicDisconnected ) {
+			Log.WriteLine("DISCONNECTED gui/cj");
+			createChronopicWindow(true);
+		}
 		
 		//unhide buttons that allow jumping, running
 		sensitiveGuiEventDone();
@@ -3984,6 +4005,10 @@ Console.WriteLine("X");
 			//unhide buttons for delete last test
 			sensitiveGuiYesEvent();
 		}
+		else if( currentEventExecute.ChronopicDisconnected ) {
+			Log.WriteLine("DISCONNECTED gui/cj");
+			createChronopicWindow(true);
+		}
 		
 		//unhide buttons that allow doing another test
 		Console.WriteLine("RR3");



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