[chronojump] cp, sp fixed since last commit. Now there's only one instance



commit d81f486d6b364b109f685f0458604be2ee999643
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Oct 12 01:00:18 2016 +0200

    cp, sp fixed since last commit. Now there's only one instance

 glade/chronojump.glade       |   63 ++++++++++++++++--
 src/Makefile.am              |    1 +
 src/chronopic2016.cs         |  145 ++++++++++++++++++++++++++++++++++++++++++
 src/chronopicRegister.cs     |  106 ++-----------------------------
 src/gui/chronojump.cs        |   66 +++++++++++--------
 src/gui/chronopicRegister.cs |    2 +-
 src/gui/jump.cs              |    2 +-
 src/gui/reactionTime.cs      |    4 +-
 src/gui/run.cs               |    2 +-
 9 files changed, 252 insertions(+), 139 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 3526476..8f71428 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -13837,7 +13837,6 @@ Concentric</property>
                                                             <property name="can_focus">False</property>
                                                             <child>
                                                             <widget class="GtkImage" 
id="image_chronopic_encoder_no">
-                                                            <property name="visible">False</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="stock">gtk-no</property>
                                                             <property name="icon-size">2</property>
@@ -13850,7 +13849,6 @@ Concentric</property>
                                                             </child>
                                                             <child>
                                                             <widget class="GtkImage" 
id="image_chronopic_encoder_yes">
-                                                            <property name="visible">False</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="stock">gtk-yes</property>
                                                             <property name="icon-size">3</property>
@@ -13870,7 +13868,6 @@ Concentric</property>
                                                             </child>
                                                             <child>
                                                             <widget class="GtkLabel" 
id="label_chronopic_encoder">
-                                                            <property name="visible">False</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="xpad">5</property>
                                                             <property name="label" 
translatable="yes">Encoder disconnected</property>
@@ -18395,6 +18392,9 @@ Concentric</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -24231,6 +24231,9 @@ by you</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -25620,6 +25623,9 @@ by you</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -27501,6 +27507,9 @@ by you</property>
               <placeholder/>
             </child>
             <child>
+              <placeholder/>
+            </child>
+            <child>
               <widget class="GtkButton" id="button_video_url">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
@@ -28439,6 +28448,9 @@ by you</property>
             <child>
               <placeholder/>
             </child>
+            <child>
+              <placeholder/>
+            </child>
           </widget>
           <packing>
             <property name="expand">True</property>
@@ -42301,6 +42313,24 @@ options</property>
                             <child>
                               <placeholder/>
                             </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
                           </widget>
                         </child>
                       </widget>
@@ -45820,6 +45850,18 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
@@ -46859,9 +46901,6 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
                                       <placeholder/>
                                     </child>
                                     <child>
-                                      <placeholder/>
-                                    </child>
-                                    <child>
                                       <widget class="GtkLabel" id="label218">
                                         <property name="visible">True</property>
                                         <property name="can_focus">False</property>
@@ -48251,6 +48290,9 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
                                     <child>
                                       <placeholder/>
                                     </child>
+                                    <child>
+                                      <placeholder/>
+                                    </child>
                                   </widget>
                                 </child>
                               </widget>
@@ -53224,6 +53266,9 @@ Other</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                       <packing>
                         <property name="left_attach">2</property>
@@ -54277,6 +54322,9 @@ Other</property>
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
@@ -55345,6 +55393,9 @@ Other</property>
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
diff --git a/src/Makefile.am b/src/Makefile.am
index 3364fe0..0ce5e44 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -181,6 +181,7 @@ SOURCES = \
        server.cs\
        staticClassState.cs\
        chronopic.cs\
+       chronopic2016.cs\
        chronopicDetect.cs\
        chronopicRegister.cs\
        chronojumpImporter.cs\
diff --git a/src/chronopic2016.cs b/src/chronopic2016.cs
new file mode 100644
index 0000000..51f1395
--- /dev/null
+++ b/src/chronopic2016.cs
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2005  Juan Gonzalez Gomez
+ * Copyright (C) 2014-2016  Xavier de Blas <xaviblas gmail com>
+ *
+ * This program 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.
+ *
+ * This program 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.
+ */
+
+using System;
+using System.IO.Ports;
+
+public class Chronopic2016
+{
+       public Chronopic2016()
+       {
+               //this is constructed only one time
+       }
+
+       //used on contacts
+       private Chronopic cp;
+       private SerialPort sp;
+       private Chronopic.Plataforma platformState;
+       
+       private string lastConnectedRealPort = "";
+       private string lastConnectedRealSerialNumber = "";
+       private ChronopicRegisterPort.Types lastConnectedRealType = ChronopicRegisterPort.Types.UNKNOWN;
+
+       public bool IsLastConnectedReal(ChronopicRegisterPort crp)
+       {
+               LogB.Information("lastConnectedRealPort");
+               LogB.Information(lastConnectedRealPort);
+               LogB.Information("lastConnectedRealSerialNumber");
+               LogB.Information(lastConnectedRealSerialNumber);
+               LogB.Information("lastConnectedRealType");
+               LogB.Information(lastConnectedRealType.ToString());
+               crp.ToString();
+
+               if(lastConnectedRealPort != "" && lastConnectedRealSerialNumber != "" && 
+                               lastConnectedRealType == ChronopicRegisterPort.Types.CONTACTS &&
+                               crp.Port == lastConnectedRealPort &&
+                               crp.SerialNumber == lastConnectedRealSerialNumber)
+                       return true;
+
+               return false;
+       }
+       public bool ConnectContactsReal(ChronopicRegisterPort crp)
+       {
+               string message = "";
+               bool success = false;
+
+               sp = new SerialPort(crp.Port);
+               ChronopicInit chronopicInit = new ChronopicInit();
+               bool connected = chronopicInit.Do(1, out cp, out sp, platformState, crp.Port, out message, 
out success);
+
+               if(connected) {
+                       lastConnectedRealPort = crp.Port;
+                       lastConnectedRealSerialNumber = crp.SerialNumber;
+                       lastConnectedRealType = ChronopicRegisterPort.Types.CONTACTS;
+               }
+
+               return connected;
+       }
+
+       //store a boolean in order to read info faster
+       public bool StoredCanCaptureContacts;
+
+       //called from gui/chronojump.cs
+       //done here because sending the SP is problematic on windows
+       public string CheckAuto (out bool isChronopicAuto)
+       {
+               ChronopicAuto ca = new ChronopicAutoCheck();
+
+               string str = ca.Read(sp);
+
+               isChronopicAuto = ca.IsChronopicAuto;
+
+               return str;
+       }
+
+       public int ChangeMultitestFirmware (int debounceChange)
+       {
+               LogB.Information("change_multitest_firmware 3 a");
+               try {
+                       //write change
+                       ChronopicAuto ca = new ChronopicAutoChangeDebounce();
+                       ca.Write(sp, debounceChange);
+
+                       //read if ok
+                       string ms = "";
+                       bool success = false;
+                       int tryNum = 7; //try to connect seven times
+                       do {
+                               ca = new ChronopicAutoCheckDebounce();
+                               ms = ca.Read(sp);
+
+                               if(ms.Length == 0)
+                                       LogB.Error("multitest firmware. ms is null");
+                               else if(ms[0] == '-') //is negative
+                                       LogB.Error("multitest firmware. ms = " + ms);
+                               else
+                                       success = true;
+                               tryNum --;
+                       } while (! success && tryNum > 0);
+
+                       LogB.Debug("multitest firmware. ms = " + ms);
+
+                       if(ms == "50 ms")
+                               return 50;
+                       else if(ms == "10 ms")
+                               return 10;
+               } catch {
+                       LogB.Error("Could not change debounce");
+               }
+
+               return -1;
+       }
+
+       public void SerialPortsCloseIfNeeded() {
+               if(sp != null && sp.IsOpen) {
+                       LogB.Information("Closing sp");
+                       sp.Close();
+               }
+       }
+
+       public Chronopic CP
+       {
+               get { return cp; }
+       }
+
+       public SerialPort SP
+       {
+               get { return sp; }
+       }
+}
diff --git a/src/chronopicRegister.cs b/src/chronopicRegister.cs
index 064a846..e3c5a75 100644
--- a/src/chronopicRegister.cs
+++ b/src/chronopicRegister.cs
@@ -244,9 +244,13 @@ public abstract class ChronopicRegister
        //returns first found (should be only one if called NumConnectedOfType and returned value was 1
        public ChronopicRegisterPort ConnectedOfType(ChronopicRegisterPort.Types type)
        {
-               foreach(ChronopicRegisterPort crp in crpl.L)
-                       if(crp.Type == type && crp.Port != "")
+               foreach (ChronopicRegisterPort crp in crpl.L)
+               {
+                       if (crp.Type == type && crp.Port != "")
+                       {
                                return crp;
+                       }
+               }
 
                return null;
        }
@@ -255,103 +259,6 @@ public abstract class ChronopicRegister
        {
                get { return crpl; }
        }
-
-       //used on contacts
-       private Chronopic cp;
-       private SerialPort sp;
-       private Chronopic.Plataforma platformState;
-
-       public bool ConnectContactsReal(ChronopicRegisterPort crp)
-       {
-               string message = "";
-               bool success = false;
-
-               sp = new SerialPort(crp.Port);
-               ChronopicInit chronopicInit = new ChronopicInit();
-               bool connected = chronopicInit.Do(1, out cp, out sp, platformState, crp.Port, out message, 
out success);
-
-               //only one crp can be connectedReal
-               if(connected) {
-                       foreach(ChronopicRegisterPort cr in crpl.L)
-                               crp.ConnectedReal = (cr == crp);
-               } else {
-                       crp.ConnectedReal = false;
-               }
-
-               return connected;
-       }
-
-       //store a boolean in order to read info faster
-       public bool StoredCanCaptureContacts;
-
-       //called from gui/chronojump.cs
-       //done here because sending the SP is problematic on windows
-       public string CheckAuto (out bool isChronopicAuto)
-       {
-               ChronopicAuto ca = new ChronopicAutoCheck();
-
-               string str = ca.Read(sp);
-
-               isChronopicAuto = ca.IsChronopicAuto;
-
-               return str;
-       }
-
-       public int ChangeMultitestFirmware (int debounceChange)
-       {
-               LogB.Information("change_multitest_firmware 3 a");
-               try {
-                       //write change
-                       ChronopicAuto ca = new ChronopicAutoChangeDebounce();
-                       ca.Write(sp, debounceChange);
-
-                       //read if ok
-                       string ms = "";
-                       bool success = false;
-                       int tryNum = 7; //try to connect seven times
-                       do {
-                               ca = new ChronopicAutoCheckDebounce();
-                               ms = ca.Read(sp);
-
-                               if(ms.Length == 0)
-                                       LogB.Error("multitest firmware. ms is null");
-                               else if(ms[0] == '-') //is negative
-                                       LogB.Error("multitest firmware. ms = " + ms);
-                               else
-                                       success = true;
-                               tryNum --;
-                       } while (! success && tryNum > 0);
-
-                       LogB.Debug("multitest firmware. ms = " + ms);
-
-                       if(ms == "50 ms")
-                               return 50;
-                       else if(ms == "10 ms")
-                               return 10;
-               } catch {
-                       LogB.Error("Could not change debounce");
-               }
-
-               return -1;
-       }
-
-       public void SerialPortsCloseIfNeeded() {
-               if(sp != null && sp.IsOpen) {
-                       LogB.Information("Closing sp");
-                       sp.Close();
-               }
-       }
-
-       public Chronopic CP
-       {
-               get { return cp; }
-       }
-
-       public SerialPort SP
-       {
-               get { return sp; }
-       }
-
 }
 
 public class ChronopicRegisterLinux : ChronopicRegister
@@ -521,4 +428,3 @@ public class ChronopicRegisterWindows : ChronopicRegister
                return comport;
        }
 }
-
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index daf1f84..d9f964e 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -453,6 +453,10 @@ public partial class ChronoJumpWindow
 
        //int chronopicCancelledTimes = 0;
 
+       ChronopicRegister chronopicRegister;
+       Chronopic2016 cp2016;
+
+
        //only called the first time the software runs
        //and only on windows
        private void on_language_clicked(object o, EventArgs args) {
@@ -610,6 +614,9 @@ public partial class ChronoJumpWindow
                ls.Test();
                LogB.Information(string.Format("coef = {0} {1} {2}", ls.Coef[0], ls.Coef[1], ls.Coef[2]));
 
+               //this is constructed only one time
+               cp2016 = new Chronopic2016();
+
                //needed to initialize cp, sp, ...
                chronopicRegisterUpdate(false);
 
@@ -2159,7 +2166,7 @@ public partial class ChronoJumpWindow
                        chronopicWin.SerialPortsCloseIfNeeded();
                }
                */
-               chronopicRegister.SerialPortsCloseIfNeeded();
+               cp2016.SerialPortsCloseIfNeeded();
        
                try {   
                        File.Delete(runningFileName);
@@ -3128,7 +3135,7 @@ public partial class ChronoJumpWindow
                        */
 
                Chronopic.Plataforma ps;
-               bool ok = (chronopicRegister.CP).Read_platform(out ps);
+               bool ok = (cp2016.CP).Read_platform(out ps);
                if(!ok) {
                        LogB.Information("Chronopic has been disconnected");
                        //createChronopicWindow(true, "");
@@ -3157,7 +3164,7 @@ public partial class ChronoJumpWindow
                LogB.Information("Trying method 2");
                bool isChronopicAuto = false;
                try {
-                       string result = chronopicRegister.CheckAuto(out isChronopicAuto);
+                       string result = cp2016.CheckAuto(out isChronopicAuto);
                        LogB.Debug("version: " + result);
                } catch {
                        LogB.Information("Could not read from Chronopic with method 2");
@@ -3172,7 +3179,7 @@ public partial class ChronoJumpWindow
                        if(m == Constants.Menuitem_modes.RUNSSIMPLE || m == 
Constants.Menuitem_modes.RUNSINTERVALLIC)
                                debounceChange = 10;
 
-                       int msChanged = chronopicRegister.ChangeMultitestFirmware(debounceChange);
+                       int msChanged = cp2016.ChangeMultitestFirmware(debounceChange);
                        if(msChanged != -1) {
                                if(msChanged == 50)
                                        label_chronopics_multitest.Text = "[" + Catalog.GetString("Jumps") + 
"]";
@@ -3467,7 +3474,7 @@ public partial class ChronoJumpWindow
                //this will cancel jumps or runs
                currentEventExecute.Cancel = true;
 
-               if(chronopicRegister.StoredCanCaptureContacts)
+               if(cp2016.StoredCanCaptureContacts)
                        checkCancelTotally(o, args);
 
                //let update stats
@@ -3488,7 +3495,7 @@ public partial class ChronoJumpWindow
                //this will cancel jumps or runs
                currentEventExecute.Cancel = true;
 
-               if(chronopicRegister.StoredCanCaptureContacts)
+               if(cp2016.StoredCanCaptureContacts)
                        checkCancelMultiTotally(o, args);
        }
 
@@ -3560,7 +3567,7 @@ public partial class ChronoJumpWindow
        {
                currentEventExecute.Finish = true;
        
-               if(chronopicRegister.StoredCanCaptureContacts)
+               if(cp2016.StoredCanCaptureContacts)
                        checkFinishTotally(o, args);
                
                //let update stats
@@ -3584,7 +3591,7 @@ public partial class ChronoJumpWindow
                //runA is not called for this, because it ends different
                //and there's a message on gui/eventExecute.cs for runA 
                LogB.Debug("RR1");
-               if(currentMultiChronopicType.Name != Constants.RunAnalysisName && 
chronopicRegister.StoredCanCaptureContacts)
+               if(currentMultiChronopicType.Name != Constants.RunAnalysisName && 
cp2016.StoredCanCaptureContacts)
                        checkFinishMultiTotally(o, args);
 
                LogB.Debug("RR2");
@@ -3716,7 +3723,7 @@ public partial class ChronoJumpWindow
                LogB.Information("numContacts: " + numContacts);
 
                //store a boolean in order to read info faster
-               chronopicRegister.StoredCanCaptureContacts = (numContacts == 1);
+               cp2016.StoredCanCaptureContacts = (numContacts == 1);
 
                if(numContacts == 0) {
                        new DialogMessage(Constants.MessageTypes.WARNING, "Chronopic jumps/runs is not 
connected");
@@ -3749,16 +3756,17 @@ public partial class ChronoJumpWindow
                if(canCaptureContacts())
                {
                        ChronopicRegisterPort crp = 
chronopicRegister.ConnectedOfType(ChronopicRegisterPort.Types.CONTACTS);
-                       if(crp.ConnectedReal)
+                       LogB.Information("Checking if Connected real!");
+                       if(cp2016.IsLastConnectedReal(crp))
                                LogB.Information("Already Connected real!");
                        else {
-                               LogB.Information("Connected real (starting connection)");
+                               LogB.Information("Connecting real (starting connection)");
                                LogB.Information("Press test button on Chronopic");
-                               bool connectedReal = chronopicRegister.ConnectContactsReal(crp);
+                               bool connectedReal = cp2016.ConnectContactsReal(crp);
                                if(connectedReal)
-                                       LogB.Information("Sucess at Connected real!");
+                                       LogB.Information("Sucess at Connecting real!");
                                else {
-                                       LogB.Information("Failure at Connected real!");
+                                       LogB.Information("Failure at Connecting real!");
                                        return;
                                }
                        }
@@ -3775,7 +3783,7 @@ public partial class ChronoJumpWindow
        
        void on_button_execute_test_accepted (object o, EventArgs args) 
        {
-               bool canCaptureC = chronopicRegister.StoredCanCaptureContacts;
+               bool canCaptureC = cp2016.StoredCanCaptureContacts;
 
                if(radio_menuitem_mode_jumps_simple.Active) 
                {
@@ -3975,7 +3983,7 @@ public partial class ChronoJumpWindow
                currentEventExecute = new JumpExecute(currentPerson.UniqueID, currentPerson.Name, 
                                currentSession.UniqueID, currentJumpType.Name, myFall, jumpWeight,
                                //chronopicWin.CP, event_execute_label_message, app1, 
preferences.digitsNumber, preferences.volumeOn,
-                               chronopicRegister.CP, event_execute_label_message, app1, 
preferences.digitsNumber, preferences.volumeOn,
+                               cp2016.CP, event_execute_label_message, app1, preferences.digitsNumber, 
preferences.volumeOn,
                                progressbarLimit, egd, description);
 
 
@@ -4145,7 +4153,7 @@ public partial class ChronoJumpWindow
                currentEventExecute = new JumpRjExecute(currentPerson.UniqueID, currentPerson.Name, 
                                currentSession.UniqueID, currentJumpRjType.Name, myFall, jumpWeight, 
                                progressbarLimit, currentJumpRjType.JumpsLimited, 
-                               chronopicRegister.CP, event_execute_label_message, app1, 
preferences.digitsNumber,
+                               cp2016.CP, event_execute_label_message, app1, preferences.digitsNumber,
                                checkbutton_allow_finish_rj_after_time.Active, preferences.volumeOn, 
                                repetitiveConditionsWin, progressbarLimit, egd
                                );
@@ -4276,7 +4284,7 @@ public partial class ChronoJumpWindow
                currentEventExecute = new RunExecute(
                                currentPerson.UniqueID, currentSession.UniqueID, 
                                currentRunType.Name, myDistance, 
-                               chronopicRegister.CP, event_execute_label_message, app1,
+                               cp2016.CP, event_execute_label_message, app1,
                                preferences.digitsNumber, preferences.metersSecondsPreferred, 
preferences.volumeOn, 
                                progressbarLimit, egd,
                                preferences.runDoubleContactsMode,
@@ -4400,7 +4408,7 @@ public partial class ChronoJumpWindow
                currentEventExecute = new RunIntervalExecute(
                                currentPerson.UniqueID, currentSession.UniqueID, currentRunIntervalType.Name, 
                                distanceInterval, progressbarLimit, currentRunIntervalType.TracksLimited, 
-                               chronopicRegister.CP, event_execute_label_message, app1,
+                               cp2016.CP, event_execute_label_message, app1,
                                preferences.digitsNumber, preferences.metersSecondsPreferred, 
preferences.volumeOn, repetitiveConditionsWin, 
                                progressbarLimit, egd,
                                preferences.runIDoubleContactsMode,
@@ -4542,7 +4550,7 @@ public partial class ChronoJumpWindow
 
                currentEventExecute = new ReactionTimeExecute(currentPerson.UniqueID, currentPerson.Name, 
                                currentSession.UniqueID, currentReactionTimeType.Name, 
-                               chronopicRegister.CP, event_execute_label_message, app1, 
preferences.digitsNumber, preferences.volumeOn,
+                               cp2016.CP, event_execute_label_message, app1, preferences.digitsNumber, 
preferences.volumeOn,
                                progressbarLimit, egd, description
                                );
 
@@ -4572,24 +4580,27 @@ public partial class ChronoJumpWindow
                currentEventExecute.FakeButtonReactionTimeStart.Clicked -= new 
EventHandler(on_event_execute_reaction_time_start);
 
                //Fire leds or buzzer on discriminative (if not simulated)
-               if(chronopicRegister.StoredCanCaptureContacts)
+               if(cp2016.StoredCanCaptureContacts)
                {
                        if(extra_window_radio_reaction_time_discriminative.Active) {
                                Thread.Sleep(Convert.ToInt32(discriminativeStartTime * 1000)); //in ms
 
                                ChronopicAuto cs = new ChronopicStartReactionTimeAnimation();
                                cs.CharToSend = discriminativeCharToSend;
-                               cs.Write(chronopicRegister.SP, 0);
+                               cs.Write(cp2016.SP, 0);
                        }
                        else if(extra_window_radio_reaction_time_animation_lights.Active) {
                                int speed = Convert.ToInt32(spinbutton_animation_lights_speed.Value);
                                ChronopicAuto cs = new ChronopicStartReactionTimeAnimation();
                                cs.CharToSend = "l";
-                               cs.Write(chronopicRegister.SP,speed);
+                               cs.Write(cp2016.SP,speed);
                        }
 
-                       LogB.Information("opening port at gui/chronojump.cs");  
-                       chronopicRegister.SP.Open();
+                       LogB.Information("on_event_execute_reaction_time_start check if need to open SP");
+                       if(! cp2016.SP.IsOpen) {
+                               LogB.Information("opening SP...");
+                               cp2016.SP.Open();
+                       }
 
                        /*
                         * some machines needed to flush
@@ -4598,7 +4609,7 @@ public partial class ChronoJumpWindow
                         * Note this will not allow reaction time be lower than 100 ms (DefaultTimeout on 
chronopic.cs)
                         */
                        LogB.Information("Going to flush by time out"); //needed on some machines
-                       chronopicRegister.CP.FlushByTimeOut();
+                       cp2016.CP.FlushByTimeOut();
                        LogB.Information("flushed!");   
                }
 
@@ -4694,7 +4705,7 @@ public partial class ChronoJumpWindow
 
                currentEventExecute = new PulseExecute(currentPerson.UniqueID, currentPerson.Name, 
                                currentSession.UniqueID, currentPulseType.Name, pulseStep, totalPulses, 
-                               chronopicRegister.CP, event_execute_label_message,
+                               cp2016.CP, event_execute_label_message,
                                app1, preferences.digitsNumber, preferences.volumeOn, egd
                                );
                
@@ -6821,7 +6832,6 @@ LogB.Debug("X");
        }
        */
 
-       ChronopicRegister chronopicRegister;
        private void on_button_chronopic_register_clicked (object o, EventArgs args)
        {
                chronopicRegisterUpdate(true);
diff --git a/src/gui/chronopicRegister.cs b/src/gui/chronopicRegister.cs
index 15257e4..f69837f 100644
--- a/src/gui/chronopicRegister.cs
+++ b/src/gui/chronopicRegister.cs
@@ -119,7 +119,7 @@ public class ChronopicRegisterWindow
                //-- cell renderer toggles
 
                Gtk.TreeViewColumn unknownCol = new Gtk.TreeViewColumn ();
-               unknownCol.Title = "Unknown";
+               unknownCol.Title = "Not configured";
                Gtk.CellRendererToggle unknownCell = new Gtk.CellRendererToggle ();
                unknownCell.Activatable = true;
                unknownCell.Radio = true;       //draw as radiobutton
diff --git a/src/gui/jump.cs b/src/gui/jump.cs
index e11a1bf..2dafa11 100644
--- a/src/gui/jump.cs
+++ b/src/gui/jump.cs
@@ -1184,7 +1184,7 @@ partial class ChronoJumpWindow
                
                //intializeVariables if not done before
                event_execute_initializeVariables(
-                       ! chronopicRegister.StoredCanCaptureContacts, //is simulated
+                       ! cp2016.StoredCanCaptureContacts, //is simulated
                        currentPerson.UniqueID, 
                        currentPerson.Name, 
                        Catalog.GetString("Phases"),      //name of the different moments
diff --git a/src/gui/reactionTime.cs b/src/gui/reactionTime.cs
index aac6e7e..eaf8cce 100644
--- a/src/gui/reactionTime.cs
+++ b/src/gui/reactionTime.cs
@@ -83,7 +83,7 @@ public partial class ChronoJumpWindow
 
                //intializeVariables if not done before
                event_execute_initializeVariables(
-                       ! chronopicRegister.StoredCanCaptureContacts, //is simulated
+                       ! cp2016.StoredCanCaptureContacts, //is simulated
                        currentPerson.UniqueID, 
                        currentPerson.Name, 
                        Catalog.GetString("Phases"),      //name of the different moments
@@ -193,7 +193,7 @@ public partial class ChronoJumpWindow
                int speed = Convert.ToInt32(spinbutton_flicker_lights_speed.Value);
                ChronopicAuto cs = new ChronopicStartReactionTimeAnimation();
                cs.CharToSend = "f";
-               cs.Write(chronopicRegister.SP,speed);
+               cs.Write(cp2016.SP,speed);
 
                on_button_execute_test_clicked(o, args);
        }
diff --git a/src/gui/run.cs b/src/gui/run.cs
index 4c30fb5..76edb72 100644
--- a/src/gui/run.cs
+++ b/src/gui/run.cs
@@ -995,7 +995,7 @@ partial class ChronoJumpWindow
 
                //intializeVariables if not done before
                event_execute_initializeVariables(
-                       ! chronopicRegister.StoredCanCaptureContacts, //is simulated
+                       ! cp2016.StoredCanCaptureContacts, //is simulated
                        currentPerson.UniqueID, 
                        currentPerson.Name, 
                        Catalog.GetString("Phases"),      //name of the different moments


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