[chronojump] chronopicRegister working for contacts and encoder
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] chronopicRegister working for contacts and encoder
- Date: Mon, 10 Oct 2016 17:38:26 +0000 (UTC)
commit 354d5503650fcf9110cd60c9d4711c73d66deda6
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon Oct 10 19:37:03 2016 +0200
chronopicRegister working for contacts and encoder
src/chronopicRegister.cs | 107 +++++++++++++-
src/gui/chronojump.cs | 345 +++++++++++++++++++++++++++---------------
src/gui/chronopic.cs | 10 +-
src/gui/chronopicRegister.cs | 251 +++++++++++++++++++++----------
src/gui/encoder.cs | 4 +-
src/gui/jump.cs | 2 +-
src/gui/multiChronopic.cs | 5 +-
src/gui/reactionTime.cs | 4 +-
src/gui/run.cs | 2 +-
9 files changed, 514 insertions(+), 216 deletions(-)
---
diff --git a/src/chronopicRegister.cs b/src/chronopicRegister.cs
index e927f84..064a846 100644
--- a/src/chronopicRegister.cs
+++ b/src/chronopicRegister.cs
@@ -24,6 +24,7 @@
using System;
using System.Collections.Generic; //List<T>
using System.Diagnostics; //for detect OS and for Process
+using System.IO.Ports;
using FTD2XX_NET;
@@ -35,6 +36,8 @@ public class ChronopicRegisterPort
public enum Types { UNKNOWN, CONTACTS, ENCODER }
public Types Type;
+ public bool ConnectedReal; //if connexion has been done by ChronopicInit.Do
+
//constructor when port is known (searching FTDI stuff on a serial port)
public ChronopicRegisterPort (string port)
{
@@ -42,6 +45,7 @@ public class ChronopicRegisterPort
this.FTDI = false;
this.SerialNumber = "";
this.Type = Types.UNKNOWN;
+ ConnectedReal = false;
}
//constructor used on SqliteChronopicRegister.SelectAll()
@@ -238,19 +242,116 @@ public abstract class ChronopicRegister
}
//returns first found (should be only one if called NumConnectedOfType and returned value was 1
- public string PortConnectedOfType(ChronopicRegisterPort.Types type)
+ public ChronopicRegisterPort ConnectedOfType(ChronopicRegisterPort.Types type)
{
foreach(ChronopicRegisterPort crp in crpl.L)
if(crp.Type == type && crp.Port != "")
- return crp.Port;
+ return crp;
- return "";
+ return null;
}
public ChronopicRegisterPortList Crpl
{
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
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index c1ec057..246fef3 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -482,10 +482,10 @@ public partial class ChronoJumpWindow
PersonNotUploadWindow personNotUploadWin;
ExecuteAutoWindow executeAutoWin;
- ChronopicWindow chronopicWin;
- ChronopicWizardWindow chronopicWizardWin;
- string wizardPortContacts;
- string wizardPortEncoder;
+ //ChronopicWindow chronopicWin;
+ //ChronopicWizardWindow chronopicWizardWin;
+ //string wizardPortContacts;
+ //string wizardPortEncoder;
static Thread pingThread;
@@ -622,9 +622,9 @@ public partial class ChronoJumpWindow
repetitiveConditionsWin = RepetitiveConditionsWindow.Create();
repetitiveConditionsWin.FakeButtonClose.Clicked += new
EventHandler(on_repetitive_conditions_closed);
- createChronopicWindow(false, "");
- wizardPortContacts = "";
- wizardPortEncoder = "";
+ //createChronopicWindow(false, "");
+ //wizardPortContacts = "";
+ //wizardPortEncoder = "";
on_extra_window_multichronopic_test_changed(new object(), new EventArgs());
on_extra_window_pulses_test_changed(new object(), new EventArgs());
@@ -677,6 +677,9 @@ public partial class ChronoJumpWindow
ls.Test();
LogB.Information(string.Format("coef = {0} {1} {2}", ls.Coef[0], ls.Coef[1], ls.Coef[2]));
+ //needed to initialize cp, sp, ...
+ chronopicRegisterUpdate(false);
+
/*
* start a ping in other thread
* http://www.mono-project.com/docs/gui/gtksharp/responsive-applications/
@@ -684,7 +687,7 @@ public partial class ChronoJumpWindow
*/
pingThread = new Thread (new ThreadStart (pingAtStart));
pingThread.Start();
-
+
//moveStartTestInitial();
}
@@ -2186,14 +2189,16 @@ public partial class ChronoJumpWindow
* ---------------- DELETE EVENT, QUIT -----------------------
* --------------------------------------------------------
*/
-
+
private void on_delete_event (object o, DeleteEventArgs args) {
args.RetVal = true;
-
+
+ /*
//cannot terminate chronojump untile press 'cancel' if autodetect encoder is working
if(cpDetect != null && cpDetect.Detecting == true)
- return;
-
+ return;
+ */
+
on_quit1_activate (new object(), new EventArgs ());
}
@@ -2216,9 +2221,12 @@ public partial class ChronoJumpWindow
private void on_quit2_activate (object o, EventArgs args) {
LogB.Information("Bye!");
+ /*
if(chronopicWin.Connected == true) {
chronopicWin.SerialPortsCloseIfNeeded();
}
+ */
+ chronopicRegister.SerialPortsCloseIfNeeded();
try {
File.Delete(runningFileName);
@@ -2997,6 +3005,7 @@ public partial class ChronoJumpWindow
main_menu.Visible = true;
+ /*
//if wizard has been used mark Chronopic as connected or disconnected depending if port exists
if(Constants.Menuitem_mode_IsContacts(m) && wizardPortContacts != "")
chronopicWin.Connected =
@@ -3004,22 +3013,24 @@ public partial class ChronoJumpWindow
else if(! Constants.Menuitem_mode_IsContacts(m) && wizardPortEncoder != "")
chronopicWin.Connected =
Util.FoundInStringArray(ChronopicPorts.GetPorts(), wizardPortEncoder);
+ */
//change multitest firmware or autoDetectChronopic
if(Constants.Menuitem_mode_IsContacts(m))
{
- if(chronopicWin.Connected)
+ //if(chronopicWin.Connected)
change_multitest_firmware(m);
- else
- autoDetectChronopic(m); //on contacts will perform change_multitest_firmware
at the end
+ //else
+ // autoDetectChronopic(m); //on contacts will perform change_multitest_firmware
at the end
}
- else if(wizardPortEncoder == "")
- autoDetectChronopic(m);
+ //else if(wizardPortEncoder == "")
+ // autoDetectChronopic(m);
chronojumpWindowTestsNext();
}
-
+
+ /*
ChronopicDetect cpDetect;
private void autoDetectChronopic(Constants.Menuitem_modes m)
{
@@ -3125,6 +3136,7 @@ public partial class ChronoJumpWindow
{
main_menu.Sensitive = true;
}
+ */
private bool previousMultitestFirmwareDefined = false;
private Constants.Menuitem_modes previousMultitestFirmware;
@@ -3132,7 +3144,11 @@ public partial class ChronoJumpWindow
//change debounce time automatically on change menuitem mode (if multitest firmware)
private void change_multitest_firmware(Constants.Menuitem_modes m)
{
+
LogB.Information("change_multitest_firmware");
+ LogB.Information("Disabled temporarily");
+ //TODO: enable again. Active once first connection is done. Problem is cp is not initialized
+ return;
//---- 1 if don't need to change, return
if(previousMultitestFirmwareDefined &&
@@ -3143,71 +3159,78 @@ public partial class ChronoJumpWindow
}
label_chronopics_multitest.Text = "";
-
+
+ if(! canCaptureContacts())
+ return;
+
+ /*
//---- 2 if is not connected, return
-
+
if(! chronopicWin.Connected)
- return;
+ return;
//---- 3 if port does not exists, show cp window and return
//http://www.raspberrypi.org/forums/viewtopic.php?f=66&t=88415
//https://bugzilla.xamarin.com/show_bug.cgi?id=15514
if(! UtilAll.IsWindows ()) {
- if(! File.Exists(chronopicWin.GetContactsFirstPort())) {
- LogB.Information("Chronopic has been disconnected");
- createChronopicWindow(true, "");
- chronopicWin.Connected = false;
- return;
- }
+ if(! File.Exists(chronopicWin.GetContactsFirstPort())) {
+ LogB.Information("Chronopic has been disconnected");
+ createChronopicWindow(true, "");
+ chronopicWin.Connected = false;
+ return;
+ }
}
+ */
LogB.Information("change_multitest_firmware 1");
-
- LogB.Debug("chronopicWin is null? " + (chronopicWin == null).ToString());
- int cps = chronopicWin.NumConnected();
- LogB.Debug("cps: " + cps.ToString());
-
- LogB.Debug("chronopicWin.Connected? " + chronopicWin.Connected.ToString());
-
+ /*
+ LogB.Debug("chronopicWin is null? " + (chronopicWin == null).ToString());
+
+ int cps = chronopicWin.NumConnected();
+ LogB.Debug("cps: " + cps.ToString());
+
+ LogB.Debug("chronopicWin.Connected? " + chronopicWin.Connected.ToString());
+ */
+
Chronopic.Plataforma ps;
- bool ok = (chronopicWin.CP).Read_platform(out ps);
+ bool ok = (chronopicRegister.CP).Read_platform(out ps);
if(!ok) {
LogB.Information("Chronopic has been disconnected");
- createChronopicWindow(true, "");
- chronopicWin.Connected = false;
- return;
+ //createChronopicWindow(true, "");
+ //chronopicWin.Connected = false;
+ return;
}
-
+
LogB.Information("change_multitest_firmware 2");
ChronopicAuto ca;
-
+
/*
- try {
+ try {
ca = new ChronopicAutoCheck();
- //problems with windows using this:
- string chronopicVersion = ca.Read(chronopicWin.SP);
- LogB.Debug("version: " + chronopicVersion);
+ //problems with windows using this:
+ string chronopicVersion = ca.Read(chronopicWin.SP);
+ LogB.Debug("version: " + chronopicVersion);
} catch {
- LogB.Information("Could not read from Chronopic with method 1");
- return;
+ LogB.Information("Could not read from Chronopic with method 1");
+ return;
}
*/
//---- 4 try to communicate with multitest firmware (return if cannot connect)
-
+
LogB.Information("Trying method 2");
bool isChronopicAuto = false;
try {
- string result = chronopicWin.CheckAuto(out isChronopicAuto);
+ string result = chronopicRegister.CheckAuto(out isChronopicAuto);
LogB.Debug("version: " + result);
} catch {
LogB.Information("Could not read from Chronopic with method 2");
return;
}
-
+
//---- 5 change 10 <-> 50 ms
LogB.Information("change_multitest_firmware 3");
@@ -3216,7 +3239,7 @@ public partial class ChronoJumpWindow
if(m == Constants.Menuitem_modes.RUNSSIMPLE || m ==
Constants.Menuitem_modes.RUNSINTERVALLIC)
debounceChange = 10;
- int msChanged = chronopicWin.ChangeMultitestFirmware(debounceChange);
+ int msChanged = chronopicRegister.ChangeMultitestFirmware(debounceChange);
if(msChanged != -1) {
if(msChanged == 50)
label_chronopics_multitest.Text = "[" + Catalog.GetString("Jumps") +
"]";
@@ -3227,7 +3250,7 @@ public partial class ChronoJumpWindow
} else
label_chronopics_multitest.Text = "";
}
-
+
previousMultitestFirmwareDefined = true;
previousMultitestFirmware = m;
}
@@ -3511,7 +3534,7 @@ public partial class ChronoJumpWindow
//this will cancel jumps or runs
currentEventExecute.Cancel = true;
- if(chronopicWin.Connected)
+ if(chronopicRegister.StoredCanCaptureContacts)
checkCancelTotally(o, args);
//let update stats
@@ -3532,7 +3555,7 @@ public partial class ChronoJumpWindow
//this will cancel jumps or runs
currentEventExecute.Cancel = true;
- if(chronopicWin.Connected)
+ if(chronopicRegister.StoredCanCaptureContacts)
checkCancelMultiTotally(o, args);
}
@@ -3604,7 +3627,7 @@ public partial class ChronoJumpWindow
{
currentEventExecute.Finish = true;
- if(chronopicWin.Connected)
+ if(chronopicRegister.StoredCanCaptureContacts)
checkFinishTotally(o, args);
//let update stats
@@ -3628,9 +3651,9 @@ 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 && chronopicWin.Connected) {
+ if(currentMultiChronopicType.Name != Constants.RunAnalysisName &&
chronopicRegister.StoredCanCaptureContacts)
checkFinishMultiTotally(o, args);
- }
+
LogB.Debug("RR2");
//let update stats
@@ -3753,9 +3776,31 @@ public partial class ChronoJumpWindow
}
}
+ bool canCaptureContacts()
+ {
+ chronopicRegisterUpdate(false);
+ int numContacts = chronopicRegister.NumConnectedOfType(ChronopicRegisterPort.Types.CONTACTS);
+ LogB.Information("numContacts: " + numContacts);
+
+ //store a boolean in order to read info faster
+ chronopicRegister.StoredCanCaptureContacts = (numContacts == 1);
+
+ if(numContacts == 0) {
+ new DialogMessage(Constants.MessageTypes.WARNING, "Chronopic jumps/runs is not
connected");
+ return false;
+ }
+ if(numContacts > 1) {
+ new DialogMessage(Constants.MessageTypes.WARNING, "More than 1 Chronopic for
jumps/runs are connected");
+ return false;
+ }
+
+
+ return true;
+ }
void on_button_execute_test_clicked (object o, EventArgs args)
{
+ /*
//http://www.raspberrypi.org/forums/viewtopic.php?f=66&t=88415
//https://bugzilla.xamarin.com/show_bug.cgi?id=15514
if(! UtilAll.IsWindows() && chronopicWin.Connected) {
@@ -3766,38 +3811,59 @@ public partial class ChronoJumpWindow
return;
}
}
+ */
+ //check if chronopics have changed
+ if(canCaptureContacts())
+ {
+ ChronopicRegisterPort crp =
chronopicRegister.ConnectedOfType(ChronopicRegisterPort.Types.CONTACTS);
+ if(crp.ConnectedReal)
+ LogB.Information("Already Connected real!");
+ else {
+ LogB.Information("Connected real (starting connection)");
+ LogB.Information("Press test button on Chronopic");
+ bool connectedReal = chronopicRegister.ConnectContactsReal(crp);
+ if(connectedReal)
+ LogB.Information("Sucess at Connected real!");
+ else {
+ LogB.Information("Failure at Connected real!");
+ return;
+ }
+ }
+ } else {
+ //simulated tests are only allowed on SIMULATED session
+ if(currentSession.Name != Constants.SessionSimulatedName) {
+ new DialogMessage(Constants.MessageTypes.WARNING,
Constants.SimulatedTestsNotAllowed);
+ return;
+ }
+ }
on_button_execute_test_accepted(o, args);
}
void on_button_execute_test_accepted (object o, EventArgs args)
{
- //simulated tests are only allowed on SIMULATED session
- if(currentSession.Name != Constants.SessionSimulatedName && ! chronopicWin.Connected) {
- new DialogMessage(Constants.MessageTypes.WARNING, Constants.SimulatedTestsNotAllowed);
- return;
- }
-
+ bool canCaptureC = chronopicRegister.StoredCanCaptureContacts;
+
if(radio_menuitem_mode_jumps_simple.Active)
{
LogB.Debug("radio_menuitem_mode_jumps_simple");
- on_normal_jump_activate(o, args);
+ on_normal_jump_activate(canCaptureC);
}
else if(radio_menuitem_mode_jumps_reactive.Active)
{
LogB.Debug("radio_menuitem_mode_jumps_reactive");
- on_rj_activate(o, args);
+ on_rj_activate(canCaptureC);
}
else if(radio_menuitem_mode_runs_simple.Active) {
LogB.Debug("radio_menuitem_mode_runs_simple");
extra_window_runs_distance = (double) extra_window_runs_spinbutton_distance.Value;
- on_normal_run_activate(o, args);
+ on_normal_run_activate(canCaptureC);
}
else if(radio_menuitem_mode_runs_intervallic.Active) {
LogB.Debug("radio_mode_runs_i_small");
//RSA runs cannot be simulated because it's complicated to manage the countdown
event...
- if(currentRunIntervalType.IsRSA && !chronopicWin.Connected) {
+ if(currentRunIntervalType.IsRSA && ! canCaptureC) {
new DialogMessage(Constants.MessageTypes.WARNING,
Catalog.GetString("Sorry, RSA tests cannot be simulated."));
return;
@@ -3806,7 +3872,7 @@ public partial class ChronoJumpWindow
extra_window_runs_interval_distance = (double)
extra_window_runs_interval_spinbutton_distance.Value;
extra_window_runs_interval_limit = extra_window_runs_interval_spinbutton_limit.Value;
- on_run_interval_activate(o, args);
+ on_run_interval_activate(canCaptureC);
}
else if(radio_mode_reaction_times_small.Active) {
LogB.Debug("radio_mode_rt");
@@ -3814,15 +3880,15 @@ public partial class ChronoJumpWindow
if(extra_window_radio_reaction_time_discriminative.Active)
reaction_time_discriminative_lights_prepare();
- on_reaction_time_activate (o, args);
+ on_reaction_time_activate (canCaptureC);
}
else if(radio_mode_pulses_small.Active) {
LogB.Debug("radio_mode_pulses");
- on_pulse_activate (o, args);
+ on_pulse_activate (canCaptureC);
}
else if(radio_mode_multi_chronopic_small.Active) {
LogB.Debug("radio_mode_mc");
- on_multi_chronopic_start_clicked(o, args);
+ on_multi_chronopic_start_clicked(canCaptureC);
}
//if a test has been deleted
@@ -3904,7 +3970,7 @@ public partial class ChronoJumpWindow
//suitable for all jumps not repetitive
- private void on_normal_jump_activate (object o, EventArgs args)
+ private void on_normal_jump_activate (bool canCaptureC)
{
if(execute_auto_doing)
sensitiveGuiAutoExecuteOrWait (true);
@@ -3956,7 +4022,7 @@ public partial class ChronoJumpWindow
showUpdateStatsAndHideData(false);
event_execute_initializeVariables(
- ! chronopicWin.Connected, //is simulated
+ ! canCaptureC, //is simulated
currentPerson.UniqueID,
currentPerson.Name,
Catalog.GetString("Phases"), //name of the different moments
@@ -3975,14 +4041,15 @@ 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,
+ //chronopicWin.CP, event_execute_label_message, app1,
preferences.digitsNumber, preferences.volumeOn,
+ chronopicRegister.CP, event_execute_label_message, app1,
preferences.digitsNumber, preferences.volumeOn,
progressbarLimit, egd, description);
- UtilGtk.ChronopicColors(viewport_chronopics, label_chronopics, label_connected_chronopics,
chronopicWin.Connected);
+ //UtilGtk.ChronopicColors(viewport_chronopics, label_chronopics, label_connected_chronopics,
chronopicWin.Connected);
- if (!chronopicWin.Connected)
+ if (! canCaptureC)
currentEventExecute.SimulateInitValues(rand);
if( currentJumpType.StartIn )
@@ -4060,8 +4127,8 @@ public partial class ChronoJumpWindow
private void chronopicDisconnectedWhileExecuting() {
LogB.Error("DISCONNECTED gui/cj");
- createChronopicWindow(true, "");
- chronopicWin.Connected = false;
+ //createChronopicWindow(true, "");
+ //chronopicWin.Connected = false;
}
private void on_test_finished_can_touch_gtk (object o, EventArgs args)
@@ -4083,7 +4150,7 @@ public partial class ChronoJumpWindow
* --------------------------------------------------------
*/
- private void on_rj_activate (object o, EventArgs args)
+ private void on_rj_activate (bool canCaptureC)
{
double progressbarLimit = 0;
@@ -4125,7 +4192,7 @@ public partial class ChronoJumpWindow
//show the event doing window
event_execute_initializeVariables(
- ! chronopicWin.Connected, //is simulated
+ ! canCaptureC, //is simulated
currentPerson.UniqueID,
currentPerson.Name,
Catalog.GetString("Jumps"), //name of the different moments
@@ -4145,7 +4212,7 @@ public partial class ChronoJumpWindow
currentEventExecute = new JumpRjExecute(currentPerson.UniqueID, currentPerson.Name,
currentSession.UniqueID, currentJumpRjType.Name, myFall, jumpWeight,
progressbarLimit, currentJumpRjType.JumpsLimited,
- chronopicWin.CP, event_execute_label_message, app1, preferences.digitsNumber,
+ chronopicRegister.CP, event_execute_label_message, app1,
preferences.digitsNumber,
checkbutton_allow_finish_rj_after_time.Active, preferences.volumeOn,
repetitiveConditionsWin, progressbarLimit, egd
);
@@ -4153,7 +4220,7 @@ public partial class ChronoJumpWindow
//suitable for limited by jump and time
//simulated always simulate limited by jumps
- if(!chronopicWin.Connected)
+ if(! canCaptureC)
currentEventExecute.SimulateInitValues(rand);
currentEventExecute.Manage();
@@ -4227,7 +4294,7 @@ public partial class ChronoJumpWindow
*/
//suitable for all runs not repetitive
- private void on_normal_run_activate (object o, EventArgs args)
+ private void on_normal_run_activate (bool canCaptureC)
{
//if distance can be always different in this run,
//show values selected in runExtraWin
@@ -4254,7 +4321,7 @@ public partial class ChronoJumpWindow
showUpdateStatsAndHideData(false);
event_execute_initializeVariables(
- ! chronopicWin.Connected, //is simulated
+ ! canCaptureC, //is simulated
currentPerson.UniqueID,
currentPerson.Name,
Catalog.GetString("Phases"), //name of the different moments
@@ -4276,7 +4343,7 @@ public partial class ChronoJumpWindow
currentEventExecute = new RunExecute(
currentPerson.UniqueID, currentSession.UniqueID,
currentRunType.Name, myDistance,
- chronopicWin.CP, event_execute_label_message, app1,
+ chronopicRegister.CP, event_execute_label_message, app1,
preferences.digitsNumber, preferences.metersSecondsPreferred,
preferences.volumeOn,
progressbarLimit, egd,
preferences.runDoubleContactsMode,
@@ -4284,7 +4351,7 @@ public partial class ChronoJumpWindow
preferences.runSpeedStartArrival
);
- if (!chronopicWin.Connected)
+ if (! canCaptureC)
currentEventExecute.SimulateInitValues(rand);
currentEventExecute.Manage();
@@ -4341,7 +4408,7 @@ public partial class ChronoJumpWindow
*/
- private void on_run_interval_activate (object o, EventArgs args)
+ private void on_run_interval_activate (bool canCaptureC)
{
LogB.Information("run interval accepted");
@@ -4380,7 +4447,7 @@ public partial class ChronoJumpWindow
//show the event doing window
event_execute_initializeVariables(
- ! chronopicWin.Connected, //is simulated
+ ! canCaptureC, //is simulated
currentPerson.UniqueID,
currentPerson.Name,
Catalog.GetString("Tracks"), //name of the different moments
@@ -4400,7 +4467,7 @@ public partial class ChronoJumpWindow
currentEventExecute = new RunIntervalExecute(
currentPerson.UniqueID, currentSession.UniqueID, currentRunIntervalType.Name,
distanceInterval, progressbarLimit, currentRunIntervalType.TracksLimited,
- chronopicWin.CP, event_execute_label_message, app1,
+ chronopicRegister.CP, event_execute_label_message, app1,
preferences.digitsNumber, preferences.metersSecondsPreferred,
preferences.volumeOn, repetitiveConditionsWin,
progressbarLimit, egd,
preferences.runIDoubleContactsMode,
@@ -4410,7 +4477,7 @@ public partial class ChronoJumpWindow
//suitable for limited by tracks and time
- if(!chronopicWin.Connected)
+ if(! canCaptureC)
currentEventExecute.SimulateInitValues(rand);
currentEventExecute.Manage();
@@ -4484,7 +4551,7 @@ public partial class ChronoJumpWindow
//suitable for reaction times
- private void on_reaction_time_activate (object o, EventArgs args)
+ private void on_reaction_time_activate (bool canCaptureC)
{
//used by cancel and finish
currentEventType = new ReactionTimeType();
@@ -4500,7 +4567,7 @@ public partial class ChronoJumpWindow
showUpdateStatsAndHideData(false);
event_execute_initializeVariables(
- ! chronopicWin.Connected, //is simulated
+ ! canCaptureC, //is simulated
currentPerson.UniqueID,
currentPerson.Name,
Catalog.GetString("Phases"), //name of the different moments
@@ -4542,15 +4609,15 @@ public partial class ChronoJumpWindow
currentEventExecute = new ReactionTimeExecute(currentPerson.UniqueID, currentPerson.Name,
currentSession.UniqueID, currentReactionTimeType.Name,
- chronopicWin.CP, event_execute_label_message, app1, preferences.digitsNumber,
preferences.volumeOn,
+ chronopicRegister.CP, event_execute_label_message, app1,
preferences.digitsNumber, preferences.volumeOn,
progressbarLimit, egd, description
);
- if (!chronopicWin.Connected)
+ if (! canCaptureC)
currentEventExecute.SimulateInitValues(rand);
//not on simulated because results would be always 0
- if( chronopicWin.Connected &&
+ if( canCaptureC &&
(extra_window_radio_reaction_time_discriminative.Active ||
extra_window_radio_reaction_time_animation_lights.Active) )
//TODO: do also for flickr
@@ -4572,23 +4639,24 @@ 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(chronopicWin.Connected) {
+ if(chronopicRegister.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(chronopicWin.SP, 0);
+ cs.Write(chronopicRegister.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(chronopicWin.SP,speed);
+ cs.Write(chronopicRegister.SP,speed);
}
LogB.Information("opening port at gui/chronojump.cs");
- chronopicWin.SP.Open();
+ chronopicRegister.SP.Open();
/*
* some machines needed to flush
@@ -4597,7 +4665,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
- chronopicWin.CP.FlushByTimeOut();
+ chronopicRegister.CP.FlushByTimeOut();
LogB.Information("flushed!");
}
@@ -4642,7 +4710,7 @@ public partial class ChronoJumpWindow
* --------------------------------------------------------
*/
- private void on_pulse_activate (object o, EventArgs args)
+ private void on_pulse_activate (bool canCaptureC)
{
LogB.Information("pulse accepted");
@@ -4674,7 +4742,7 @@ public partial class ChronoJumpWindow
//show the event doing window
event_execute_initializeVariables(
- ! chronopicWin.Connected, //is simulated
+ ! canCaptureC, //is simulated
currentPerson.UniqueID,
currentPerson.Name,
Catalog.GetString("Pulses"), //name of the different moments
@@ -4693,11 +4761,11 @@ public partial class ChronoJumpWindow
currentEventExecute = new PulseExecute(currentPerson.UniqueID, currentPerson.Name,
currentSession.UniqueID, currentPulseType.Name, pulseStep, totalPulses,
- chronopicWin.CP, event_execute_label_message,
+ chronopicRegister.CP, event_execute_label_message,
app1, preferences.digitsNumber, preferences.volumeOn, egd
);
- if(!chronopicWin.Connected)
+ if(! canCaptureC)
currentEventExecute.SimulateInitValues(rand);
currentEventExecute.Manage();
@@ -4769,7 +4837,8 @@ public partial class ChronoJumpWindow
//encoderPort is usually "" and will be Util.GetDefaultPort
//but, since 1.5.1 when selecting encoder option from main menu,
//then encoderPort will be found and send here
-
+
+ /*
//normal call
private void createChronopicWindow(bool recreate, string encoderPort)
{
@@ -4800,8 +4869,11 @@ public partial class ChronoJumpWindow
if(recreate)
label_chronopics_multitest.Text = "";
}
+ */
- private void on_chronopic_contacts_clicked (object o, EventArgs args) {
+ private void on_chronopic_contacts_clicked (object o, EventArgs args)
+ {
+ /*
ChronopicWindow.ChronojumpMode cmode = ChronopicWindow.ChronojumpMode.JUMPORRUN;
if(radio_menuitem_mode_other.Active)
cmode = ChronopicWindow.ChronojumpMode.OTHER;
@@ -4809,6 +4881,8 @@ public partial class ChronoJumpWindow
chronopicWin = ChronopicWindow.View(cmode, preferences.volumeOn);
//chronopicWin.FakeWindowReload.Clicked += new EventHandler(chronopicWindowReload);
chronopicWin.FakeWindowDone.Clicked += new
EventHandler(on_chronopic_window_contacts_connected_or_done);
+ */
+ chronopicRegisterUpdate(true);
}
private void on_chronopic_encoder_clicked (object o, EventArgs args) {
@@ -4844,7 +4918,9 @@ public partial class ChronoJumpWindow
}
*/
- private void on_chronopic_window_contacts_connected_or_done (object o, EventArgs args) {
+ private void on_chronopic_window_contacts_connected_or_done (object o, EventArgs args)
+ {
+ /*
chronopicWin.FakeWindowDone.Clicked -= new
EventHandler(on_chronopic_window_contacts_connected_or_done);
int cps = chronopicWin.NumConnected();
@@ -4857,16 +4933,21 @@ public partial class ChronoJumpWindow
label_chronopics_multitest.Text = "";
chronopicContactsLabels(cps, true);
+ */
}
- private void on_chronopic_window_encoder_connected_or_done (object o, EventArgs args) {
+ private void on_chronopic_window_encoder_connected_or_done (object o, EventArgs args)
+ {
+ /*
chronopicWin.FakeWindowDone.Clicked -= new
EventHandler(on_chronopic_window_encoder_connected_or_done);
chronopicEncoderLabels(true);
+ */
}
private void chronopicContactsLabels(int cps, bool colorize) {
+ /*
//string text = "<b>" + cps.ToString() + "</b>";
string text = cps.ToString();
@@ -4878,6 +4959,7 @@ public partial class ChronoJumpWindow
UtilGtk.ChronopicColors(viewport_chronopics,
label_chronopics, label_connected_chronopics,
chronopicWin.Connected);
+ */
}
private void chronopicEncoderLabels(bool colorize)
@@ -4909,7 +4991,12 @@ public partial class ChronoJumpWindow
}
- private void on_multi_chronopic_start_clicked (object o, EventArgs args) {
+ private void on_multi_chronopic_start_clicked (bool canCaptureC)
+ {
+ new DialogMessage(Constants.MessageTypes.WARNING, "Disabled on version 1.6.3.");
+ return;
+
+ /*
LogB.Information("multi chronopic accepted");
bool syncAvailable = false;
@@ -4947,11 +5034,9 @@ public partial class ChronoJumpWindow
event_execute_ButtonUpdate.Clicked += new EventHandler(on_update_clicked);
- /*
- bool syncAvailable = false;
- if(currentMultiChronopicType.SyncAvailable && extra_window_check_multichronopic_sync.Active)
- syncAvailable = true;
- */
+ //bool syncAvailable = false;
+ //if(currentMultiChronopicType.SyncAvailable && extra_window_check_multichronopic_sync.Active)
+ // syncAvailable = true;
int numConnected = chronopicWin.NumConnected();
@@ -5006,10 +5091,13 @@ public partial class ChronoJumpWindow
// currentEventExecute.FakeButtonRunATouchPlatform.Clicked += new
EventHandler(on_event_execute_RunATouchPlatform);
currentEventExecute.FakeButtonFinished.Clicked += new
EventHandler(on_multi_chronopic_finished);
currentEventExecute.FakeButtonThreadDyed.Clicked += new
EventHandler(on_test_finished_can_touch_gtk);
+ */
}
bool multiFinishing;
- private void on_multi_chronopic_finished (object o, EventArgs args) {
+ private void on_multi_chronopic_finished (object o, EventArgs args)
+ {
+ /*
if(multiFinishing)
return;
else
@@ -5026,12 +5114,11 @@ public partial class ChronoJumpWindow
currentEventExecute.RunANoStrides();
else if ( ! currentEventExecute.Cancel ) {
LogB.Debug("T");
- /*
- on runAnalysis test, when cp1 ends, run ends,
- but cp2 is still waiting event
- with this will ask cp2 to press button
- solves problem with threads at ending
- */
+
+ //on runAnalysis test, when cp1 ends, run ends,
+ //but cp2 is still waiting event
+ //with this will ask cp2 to press button
+ //solves problem with threads at ending
//on_finish_multi_clicked(o, args);
//this produces also a crash:
@@ -5069,6 +5156,7 @@ LogB.Debug("X");
}
else if( currentEventExecute.ChronopicDisconnected )
chronopicDisconnectedWhileExecuting();
+ */
}
@@ -6254,10 +6342,13 @@ LogB.Debug("X");
//if there are persons
if (notebook_execute.CurrentPage == 6) {
+ /*
+ * disabled on 1.6.3
if (chronopicWin.NumConnected() >= 2)
extra_window_multichronopic_can_do(true);
else
extra_window_multichronopic_can_do(false);
+ */
} else {
button_execute_test.Sensitive = myTreeViewPersons.IsThereAnyRecord();
}
@@ -6742,16 +6833,19 @@ LogB.Debug("X");
Catalog.GetString("Auto-detection on hardware is inactive.") + " " +
Catalog.GetString("Use it if you have problems at start or at capture.")
);
}
-
+
private void on_button_chronopic_wizard_clicked (object o, EventArgs args)
{
+ /*
chronopicWizardWin = ChronopicWizardWindow.Show();
chronopicWizardWin.FakeButtonChronopicWizardFinished.Clicked -=
new EventHandler(chronopic_wizard_finished);
chronopicWizardWin.FakeButtonChronopicWizardFinished.Clicked += new
EventHandler(chronopic_wizard_finished);
+ */
}
+ /*
private void chronopic_wizard_finished (object o, EventArgs args)
{
chronopicWizardWin.FakeButtonChronopicWizardFinished.Clicked -=
@@ -6763,10 +6857,10 @@ LogB.Debug("X");
LogB.Information("wizardPortContacts: " + wizardPortContacts);
LogB.Information("wizardPortEncoder: " + wizardPortEncoder);
- /*
- * createChronopicWindow (pass cp,...)
- * recreate is true because it has been created on first ChronojumpWindow call
- */
+ //
+ // createChronopicWindow (pass cp,...)
+ // recreate is true because it has been created on first ChronojumpWindow call
+ //
//contacts and encoder
if(wizardPortContacts != "")
{
@@ -6793,6 +6887,7 @@ LogB.Debug("X");
//all the needed info is take. Can destroy wizard window
chronopicWizardWin.HideAndNull();
}
+ */
ChronopicRegister chronopicRegister;
private void on_button_chronopic_register_clicked (object o, EventArgs args)
diff --git a/src/gui/chronopic.cs b/src/gui/chronopic.cs
index 5c4cd53..a4f96b5 100644
--- a/src/gui/chronopic.cs
+++ b/src/gui/chronopic.cs
@@ -740,7 +740,8 @@ public class ChronopicWindow
"Minimum value will be 50 ms again when user unplugs USB cable.");
}
-
+
+ /*
//called from gui/chronojump.cs
//done here because sending the SP is problematic on windows
public string CheckAuto (out bool isChronopicAuto)
@@ -752,7 +753,9 @@ public class ChronopicWindow
isChronopicAuto = ca.IsChronopicAuto;
return str;
- }
+ }
+ */
+ /*
public int ChangeMultitestFirmware (int debounceChange)
{
LogB.Information("change_multitest_firmware 3 a");
@@ -790,6 +793,7 @@ public class ChronopicWindow
return -1;
}
+ */
// end of Chronopic Automatic Firmware ---------------
@@ -1068,6 +1072,7 @@ public class ChronopicWindow
}
+ /*
public Chronopic CP {
get { return cp; }
}
@@ -1091,6 +1096,7 @@ public class ChronopicWindow
public Chronopic.Plataforma PlatformState { //on (in platform), off (jumping), or unknow
get { return platformState; }
}
+ */
//connected to a Chronopic
diff --git a/src/gui/chronopicRegister.cs b/src/gui/chronopicRegister.cs
index 2387022..5335ab6 100644
--- a/src/gui/chronopicRegister.cs
+++ b/src/gui/chronopicRegister.cs
@@ -22,6 +22,42 @@ using System;
using System.Collections.Generic; //List<T>
using Gtk;
+public class ChronopicRegisterWindowTypes
+{
+ public string SerialNumber;
+ public string Port;
+ public bool Unknown;
+ public bool Contacts;
+ public bool Encoder;
+
+ public ChronopicRegisterWindowTypes (string serialNumber, string port, bool unknown, bool contacts,
bool encoder)
+ {
+ this.SerialNumber = serialNumber;
+ this.Port = port;
+ this.Unknown = unknown;
+ this.Contacts = contacts;
+ this.Encoder = encoder;
+ }
+
+ public ChronopicRegisterWindowTypes (ChronopicRegisterPort crp)
+ {
+ this.SerialNumber = crp.SerialNumber;
+ this.Port = crp.Port;
+
+ Unknown = false;
+ Contacts = false;
+ Encoder = false;
+
+ if(crp.Type == ChronopicRegisterPort.Types.UNKNOWN)
+ Unknown = true;
+ else if(crp.Type == ChronopicRegisterPort.Types.CONTACTS)
+ Contacts = true;
+ else
+ Encoder = true;
+ }
+}
+
+
public class ChronopicRegisterWindow
{
Gtk.Window chronopic_register_win;
@@ -45,6 +81,7 @@ public class ChronopicRegisterWindow
private void createWindow()
{
chronopic_register_win = new Window ("Chronopic register");
+ chronopic_register_win.AllowGrow = false;
chronopic_register_win.DeleteEvent += on_delete_event;
@@ -60,80 +97,86 @@ public class ChronopicRegisterWindow
Gtk.TreeView treeview;
- Gtk.ListStore listStoreTypes;
Gtk.ListStore listStoreAll;
- //based on: http://www.mono-project.com/docs/gui/gtksharp/widgets/treeview-tutorial/
- //and:
http://stackoverflow.com/questions/12679688/updating-treeview-after-changing-cellrenderercombo-gtk
+ //based on: ~/informatica/progs_meus/mono/treemodel.cs
private void createTreeView(List<ChronopicRegisterPort> list)
{
treeview = new Gtk.TreeView();
- // Create column , cell renderer and add the cell to the 1st column
+ // Create column , cell renderer and add the cell to the serialN column
Gtk.TreeViewColumn serialNCol = new Gtk.TreeViewColumn ();
serialNCol.Title = "Serial Number";
Gtk.CellRendererText serialNCell = new Gtk.CellRendererText ();
serialNCol.PackStart (serialNCell, true);
- //--------------------- combo start --------------
- Gtk.TreeViewColumn typeCol = new Gtk.TreeViewColumn ();
- typeCol.Title = "Type";
- Gtk.CellRendererCombo typeCell = new Gtk.CellRendererCombo ();
- typeCell.Editable = true;
-
- listStoreTypes = new Gtk.ListStore(typeof (string));
- int maxChars = 0;
- foreach(string s in Enum.GetNames(typeof(ChronopicRegisterPort.Types))) {
- listStoreTypes.AppendValues (s);
- if(s.Length > maxChars)
- maxChars = s.Length;
- }
-
- typeCell.Model = listStoreTypes;
- typeCell.WidthChars = maxChars + 10; //enough space to show the dropdown list button
- typeCell.TextColumn = 0;
- typeCell.Edited += comboChanged;
-
- typeCol.PackStart (typeCell, false);
- //--------------------- combo end --------------
-
-
- // Create column , cell renderer and add the cell to the 3rd column
+ // Create column , cell renderer and add the cell to the port column
Gtk.TreeViewColumn portCol = new Gtk.TreeViewColumn ();
portCol.Title = "Port";
Gtk.CellRendererText portCell = new Gtk.CellRendererText ();
portCol.PackStart (portCell, true);
- // Add the columns to the TreeView
- treeview.AppendColumn (serialNCol);
- treeview.AppendColumn (typeCol);
- treeview.AppendColumn (portCol);
- //Tell the Cell Renderers which items in the model to display
- serialNCol.AddAttribute (serialNCell, "text", 0);
- typeCol.AddAttribute (typeCell, "text", 1);
- portCol.AddAttribute (portCell, "text", 2);
+ //-- cell renderer toggles
- //listStoreAll = new Gtk.ListStore (typeof (string), typeof(Gtk.ComboBox), typeof(string));
- listStoreAll = new Gtk.ListStore (typeof (string), typeof(string), typeof(string));
+ Gtk.TreeViewColumn unknownCol = new Gtk.TreeViewColumn ();
+ unknownCol.Title = "Unknown";
+ Gtk.CellRendererToggle unknownCell = new Gtk.CellRendererToggle ();
+ unknownCell.Activatable = true;
+ unknownCell.Radio = true; //draw as radiobutton
+ unknownCell.Toggled += new Gtk.ToggledHandler (unknownToggled);
+ unknownCol.PackStart (unknownCell, true);
- treeview.Model = listStoreAll;
+ Gtk.TreeViewColumn contactsCol = new Gtk.TreeViewColumn ();
+ contactsCol.Title = "Contacts";
+ Gtk.CellRendererToggle contactsCell = new Gtk.CellRendererToggle ();
+ contactsCell.Activatable = true;
+ contactsCell.Radio = true; //draw as radiobutton
+ contactsCell.Toggled += new Gtk.ToggledHandler (contactsToggled);
+ contactsCol.PackStart (contactsCell, true);
+
+ Gtk.TreeViewColumn encoderCol = new Gtk.TreeViewColumn ();
+ encoderCol.Title = "Encoder";
+ Gtk.CellRendererToggle encoderCell = new Gtk.CellRendererToggle ();
+ encoderCell.Activatable = true;
+ encoderCell.Radio = true; //draw as radiobutton
+ encoderCell.Toggled += new Gtk.ToggledHandler (encoderToggled);
+ encoderCol.PackStart (encoderCell, true);
+
+ //-- end of cell renderer toggles
+
+
+ listStoreAll = new Gtk.ListStore (typeof (ChronopicRegisterWindowTypes));
bool chronopicsFound = false;
foreach(ChronopicRegisterPort crp in list) {
if(crp.Port != "") {
- listStoreAll.AppendValues(crp.SerialNumber, crp.Type.ToString(), crp.Port);
+ listStoreAll.AppendValues(new ChronopicRegisterWindowTypes(crp));
chronopicsFound = true;
}
}
+ serialNCol.SetCellDataFunc (serialNCell, new Gtk.TreeCellDataFunc (RenderSerialN));
+ portCol.SetCellDataFunc (portCell, new Gtk.TreeCellDataFunc (RenderPort));
+ unknownCol.SetCellDataFunc (unknownCell, new Gtk.TreeCellDataFunc (RenderUnknown));
+ contactsCol.SetCellDataFunc (contactsCell, new Gtk.TreeCellDataFunc (RenderContacts));
+ encoderCol.SetCellDataFunc (encoderCell, new Gtk.TreeCellDataFunc (RenderEncoder));
+
+ treeview.Model = listStoreAll;
+
+ // Add the columns to the TreeView
+ treeview.AppendColumn (serialNCol);
+ treeview.AppendColumn (portCol);
+ treeview.AppendColumn (unknownCol);
+ treeview.AppendColumn (contactsCol);
+ treeview.AppendColumn (encoderCol);
+
+
Gtk.Label label;
- if(chronopicsFound) {
- label = new Gtk.Label("To change values:\nClick on <b>Type</b> column and the press
Enter.");
- label.UseMarkup = true;
- } else {
+ if(chronopicsFound)
+ label = new Gtk.Label("");
+ else
label = new Gtk.Label("Chronopic/s not found:\nConnect and reopen this window.");
- }
Gtk.VBox vboxTV = new Gtk.VBox(false, 8);
vboxTV.Add(treeview);
@@ -142,60 +185,110 @@ public class ChronopicRegisterWindow
vbox_main.Add(vboxTV);
}
- /*
- void comboChangedOld (object o, EditedArgs args)
- {
- TreeSelection selection = treeview.Selection;
- TreeIter iter;
- if (!selection.GetSelected (out iter))
- return;
- listStoreAll.SetValue (iter, 1, args.NewText);
- }
- */
+ private void RenderSerialN (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model,
Gtk.TreeIter iter)
+ {
+ ChronopicRegisterWindowTypes crwt = (ChronopicRegisterWindowTypes) model.GetValue (iter, 0);
+ (cell as Gtk.CellRendererText).Text = crwt.SerialNumber;
+ }
- void comboChanged (object o, EditedArgs args)
+ private void RenderPort (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model,
Gtk.TreeIter iter)
+ {
+ ChronopicRegisterWindowTypes crwt = (ChronopicRegisterWindowTypes) model.GetValue (iter, 0);
+ (cell as Gtk.CellRendererText).Text = crwt.Port;
+ }
+
+ private void RenderUnknown (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model,
Gtk.TreeIter iter)
+ {
+ ChronopicRegisterWindowTypes crwt = (ChronopicRegisterWindowTypes) model.GetValue (iter, 0);
+ (cell as Gtk.CellRendererToggle).Active = crwt.Unknown;
+ }
+
+ private void RenderContacts (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model,
Gtk.TreeIter iter)
+ {
+ ChronopicRegisterWindowTypes crwt = (ChronopicRegisterWindowTypes) model.GetValue (iter, 0);
+ (cell as Gtk.CellRendererToggle).Active = crwt.Contacts;
+ }
+
+ private void RenderEncoder (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.TreeModel model,
Gtk.TreeIter iter)
+ {
+ ChronopicRegisterWindowTypes crwt = (ChronopicRegisterWindowTypes) model.GetValue (iter, 0);
+ (cell as Gtk.CellRendererToggle).Active = crwt.Encoder;
+ }
+
+
+
+ private void unknownToggled (object sender, Gtk.ToggledArgs args)
{
Gtk.TreeIter iter;
listStoreAll.GetIter (out iter, new Gtk.TreePath (args.Path));
- //update value on treeview
- listStoreAll.SetValue (iter, 1, args.NewText);
+ ChronopicRegisterWindowTypes crwt = (ChronopicRegisterWindowTypes) listStoreAll.GetValue
(iter, 0);
+
+ if(! crwt.Unknown) {
+ crwt.Unknown = true;
+ crwt.Contacts = false;
+ crwt.Encoder = false;
+ }
//store on SQL
- string serialNumber = (string) listStoreAll.GetValue (iter, 0);
- ChronopicRegisterPort.Types type = (ChronopicRegisterPort.Types) Enum.Parse(
- typeof(ChronopicRegisterPort.Types), args.NewText);
- string port = (string) listStoreAll.GetValue (iter, 2);
+ SqliteChronopicRegister.Update(false,
+ new ChronopicRegisterPort(crwt.SerialNumber,
ChronopicRegisterPort.Types.UNKNOWN),
+ ChronopicRegisterPort.Types.UNKNOWN);
+ }
- ChronopicRegisterPort crp = new ChronopicRegisterPort(serialNumber, type);
- crp.Port = port;
+ private void contactsToggled (object sender, Gtk.ToggledArgs args)
+ {
+ Gtk.TreeIter iter;
+ listStoreAll.GetIter (out iter, new Gtk.TreePath (args.Path));
- SqliteChronopicRegister.Update(false, crp, type);
+ ChronopicRegisterWindowTypes crwt = (ChronopicRegisterWindowTypes) listStoreAll.GetValue
(iter, 0);
+
+ if(! crwt.Contacts) {
+ crwt.Unknown = false;
+ crwt.Contacts = true;
+ crwt.Encoder = false;
+ }
+
+ //store on SQL
+ SqliteChronopicRegister.Update(false,
+ new ChronopicRegisterPort(crwt.SerialNumber,
ChronopicRegisterPort.Types.CONTACTS),
+ ChronopicRegisterPort.Types.CONTACTS);
+ }
+
+ private void encoderToggled (object sender, Gtk.ToggledArgs args)
+ {
+ Gtk.TreeIter iter;
+ listStoreAll.GetIter (out iter, new Gtk.TreePath (args.Path));
+
+ ChronopicRegisterWindowTypes crwt = (ChronopicRegisterWindowTypes) listStoreAll.GetValue
(iter, 0);
+
+ if(! crwt.Encoder) {
+ crwt.Unknown = false;
+ crwt.Contacts = false;
+ crwt.Encoder = true;
+ }
+
+ //store on SQL
+ SqliteChronopicRegister.Update(false,
+ new ChronopicRegisterPort(crwt.SerialNumber,
ChronopicRegisterPort.Types.ENCODER),
+ ChronopicRegisterPort.Types.ENCODER);
}
private void createButton()
{
Gtk.Button button = new Gtk.Button("Close");
button.Clicked += new EventHandler(on_button_clicked);
- vbox_main.Add(button);
+
+ Gtk.HButtonBox hbox = new Gtk.HButtonBox ();
+ hbox.Add(button);
+
+ vbox_main.Add(hbox);
}
private void on_button_clicked(object o, EventArgs args)
{
- /*
- * TODO:
- * trying to manage if a combobox is changed but focus is still there. "Edited" is not called.
- TreeSelection selection = treeview.Selection;
- TreeIter iter;
- if (selection.GetSelected (out iter)) {
- LogB.Information("SOMETHING SELECTED");
- selection.UnselectIter(iter);
- }
- else
- LogB.Information("NOTHING SELECTED");
- */
-
+ //TODO: be called with Escape (accelerator)
chronopic_register_win.Hide();
chronopic_register_win = null;
}
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index f2bc067..df7a187 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -2127,7 +2127,7 @@ public partial class ChronoJumpWindow
preferences.encoderCaptureInactivityEndTime,
radio_encoder_capture_cont.Active,
findEccon(true),
- chronopicRegister.PortConnectedOfType(ChronopicRegisterPort.Types.ENCODER)
+ chronopicRegister.ConnectedOfType(ChronopicRegisterPort.Types.ENCODER).Port
);
bool capturedOk = eCapture.Capture(
UtilEncoder.GetEncoderDataTempFileName(),
@@ -2161,7 +2161,7 @@ public partial class ChronoJumpWindow
preferences.encoderCaptureInactivityEndTime,
false,
findEccon(true),
- chronopicRegister.PortConnectedOfType(ChronopicRegisterPort.Types.ENCODER)
+ chronopicRegister.ConnectedOfType(ChronopicRegisterPort.Types.ENCODER).Port
);
bool capturedOk = eCapture.Capture(
UtilEncoder.GetEncoderDataTempFileName(),
diff --git a/src/gui/jump.cs b/src/gui/jump.cs
index 0ab8691..b89a922 100644
--- a/src/gui/jump.cs
+++ b/src/gui/jump.cs
@@ -1188,7 +1188,7 @@ partial class ChronoJumpWindow
//intializeVariables if not done before
event_execute_initializeVariables(
- ! chronopicWin.Connected, //is simulated
+ ! chronopicRegister.StoredCanCaptureContacts, //is simulated
currentPerson.UniqueID,
currentPerson.Name,
Catalog.GetString("Phases"), //name of the different moments
diff --git a/src/gui/multiChronopic.cs b/src/gui/multiChronopic.cs
index 593ae87..6690ea1 100644
--- a/src/gui/multiChronopic.cs
+++ b/src/gui/multiChronopic.cs
@@ -54,11 +54,14 @@ public partial class ChronoJumpWindow
currentMultiChronopicType = new MultiChronopicType(Constants.MultiChronopicName);
else if(extra_window_radio_multichronopic_run_analysis.Active)
currentMultiChronopicType = new MultiChronopicType(Constants.RunAnalysisName);
-
+
+ /*
+ * disabled on 1.6.3
if(chronopicWin.NumConnected() < 2)
extra_window_multichronopic_can_do(false);
else
extra_window_multichronopic_can_do(true);
+ */
extra_window_multichronopic_initialize(currentMultiChronopicType);
}
diff --git a/src/gui/reactionTime.cs b/src/gui/reactionTime.cs
index 221049c..2dbd7b5 100644
--- a/src/gui/reactionTime.cs
+++ b/src/gui/reactionTime.cs
@@ -87,7 +87,7 @@ public partial class ChronoJumpWindow
//intializeVariables if not done before
event_execute_initializeVariables(
- ! chronopicWin.Connected, //is simulated
+ ! chronopicRegister.StoredCanCaptureContacts, //is simulated
currentPerson.UniqueID,
currentPerson.Name,
Catalog.GetString("Phases"), //name of the different moments
@@ -197,7 +197,7 @@ public partial class ChronoJumpWindow
int speed = Convert.ToInt32(spinbutton_flicker_lights_speed.Value);
ChronopicAuto cs = new ChronopicStartReactionTimeAnimation();
cs.CharToSend = "f";
- cs.Write(chronopicWin.SP,speed);
+ cs.Write(chronopicRegister.SP,speed);
on_button_execute_test_clicked(o, args);
}
diff --git a/src/gui/run.cs b/src/gui/run.cs
index a82bd19..4c30fb5 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(
- ! chronopicWin.Connected, //is simulated
+ ! chronopicRegister.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]