[chronojump] Chronopic big 3 improvements: Fixed crash on Linux/Mac when chronopic disconnect. Auto change deboun
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Chronopic big 3 improvements: Fixed crash on Linux/Mac when chronopic disconnect. Auto change deboun
- Date: Sat, 1 Nov 2014 20:06:39 +0000 (UTC)
commit 7504c92079690423a6972932832df2eaa93b67c1
Author: Xavier de Blas <xaviblas gmail com>
Date: Sat Nov 1 21:03:48 2014 +0100
Chronopic big 3 improvements: Fixed crash on Linux/Mac when chronopic disconnect. Auto change debounce on
multitest. Chronopic port lot safer
glade/chronojump.glade | 182 +++++++++++++++++++++++++++++++----------------
src/chronopic.cs | 5 +-
src/gui/chronojump.cs | 94 ++++++++++++++++++++++++-
src/gui/chronopic.cs | 75 ++++++++++++++------
4 files changed, 268 insertions(+), 88 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index ff41a9f..ab5ef02 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -1838,56 +1838,28 @@
</packing>
</child>
<child>
- <widget class="GtkVBox" id="vbox14">
+ <widget class="GtkViewport" id="viewport_chronopics">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="spacing">20</property>
+ <property name="shadow_type">none</property>
<child>
- <widget class="GtkViewport" id="viewport_chronopics">
+ <widget class="GtkHBox" id="hbox_chronopics">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="shadow_type">none</property>
+ <property name="app_paintable">True</property>
+ <property name="can_focus">True</property>
+ <property name="spacing">8</property>
<child>
- <widget class="GtkHBox" id="hbox_chronopics">
+ <widget class="GtkHBox" id="hbox91">
<property name="visible">True</property>
- <property name="app_paintable">True</property>
- <property name="can_focus">True</property>
- <property name="spacing">8</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">4</property>
<child>
- <widget class="GtkHBox" id="hbox91">
+ <widget class="GtkLabel" id="label_chronopics">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="spacing">4</property>
- <child>
- <widget class="GtkLabel" id="label_chronopics">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xpad">5</property>
- <property name="label"
translatable="yes">Chronopics</property>
- <property name="use_markup">True</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel"
id="label_connected_chronopics">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label"
translatable="yes">0</property>
- <property name="use_markup">True</property>
- <property name="ellipsize">end</property>
- <property name="max_width_chars">25</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
+ <property name="xpad">5</property>
+ <property name="label"
translatable="yes">Chronopics</property>
+ <property name="use_markup">True</property>
</widget>
<packing>
<property name="expand">False</property>
@@ -1896,23 +1868,13 @@
</packing>
</child>
<child>
- <widget class="GtkButton"
id="button_activate_chronopics">
+ <widget class="GtkLabel"
id="label_connected_chronopics">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">True</property>
- <property name="has_tooltip">True</property>
- <property name="tooltip" translatable="yes">Connect
Chronopics</property>
- <property name="relief">half</property>
- <signal name="clicked"
handler="on_chronopic_contacts_clicked" swapped="no"/>
- <child>
- <widget class="GtkImage" id="image5">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="stock">gtk-connect</property>
- <property name="icon-size">2</property>
- </widget>
- </child>
+ <property name="can_focus">False</property>
+ <property name="label"
translatable="yes">0</property>
+ <property name="use_markup">True</property>
+ <property name="ellipsize">end</property>
+ <property name="max_width_chars">25</property>
</widget>
<packing>
<property name="expand">False</property>
@@ -1920,19 +1882,57 @@
<property name="position">1</property>
</packing>
</child>
+ <child>
+ <widget class="GtkLabel"
id="label_chronopics_multitest">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
</widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="button_activate_chronopics">
+ <property name="width_request">50</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">True</property>
+ <property name="has_tooltip">True</property>
+ <property name="tooltip" translatable="yes">Connect
Chronopics</property>
+ <property name="relief">half</property>
+ <signal name="clicked"
handler="on_chronopic_contacts_clicked" swapped="no"/>
+ <child>
+ <widget class="GtkImage" id="image5">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-connect</property>
+ <property name="icon-size">2</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
</child>
</widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
+ <property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
@@ -6318,6 +6318,9 @@ Second Chronopic to platforms.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">True</property>
@@ -7027,6 +7030,9 @@ Second Chronopic to platforms.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
<child>
@@ -7870,6 +7876,9 @@ Second Chronopic to platforms.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="position">2</property>
@@ -8472,6 +8481,9 @@ Second Chronopic to platforms.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="position">4</property>
@@ -12310,6 +12322,7 @@ on current Chronojump version.</property>
</child>
<child>
<widget class="GtkButton"
id="button_activate_chronopics_encoder">
+ <property name="width_request">50</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
@@ -18200,6 +18213,9 @@ by you</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -18710,6 +18726,9 @@ by you</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -19712,6 +19731,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>
@@ -19771,6 +19793,9 @@ by you</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">True</property>
@@ -28496,6 +28521,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>
@@ -30386,6 +30429,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>
@@ -30934,6 +30980,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>
@@ -33476,6 +33525,9 @@ show elevation as:</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="left_attach">2</property>
@@ -33650,6 +33702,9 @@ show elevation as:</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -33839,6 +33894,9 @@ show elevation as:</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
diff --git a/src/chronopic.cs b/src/chronopic.cs
index bf8dd29..5167397 100644
--- a/src/chronopic.cs
+++ b/src/chronopic.cs
@@ -420,6 +420,7 @@ public abstract class ChronopicAuto
{
protected SerialPort sp;
protected int sendNum;
+ public bool IsChronopicAuto;
protected internal abstract string Communicate();
private string str;
@@ -482,8 +483,8 @@ public class ChronopicAutoCheck : ChronopicAuto
protected internal override string Communicate()
{
sp.Write("J");
- bool isChronopicAuto = ( (char) sp.ReadByte() == 'J');
- if (isChronopicAuto) {
+ IsChronopicAuto = ( (char) sp.ReadByte() == 'J');
+ if (IsChronopicAuto) {
sp.Write("V");
int major = (char) sp.ReadByte() - '0';
sp.ReadByte(); //.
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 273227c..99106a6 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -200,6 +200,7 @@ public partial class ChronoJumpWindow
[Widget] Gtk.Box hbox_chronopics;
[Widget] Gtk.Label label_chronopics;
[Widget] Gtk.Label label_connected_chronopics;
+ [Widget] Gtk.Label label_chronopics_multitest;
[Widget] Gtk.Image image_simulated_warning;
//[Widget] Gtk.TextView textview_message_connected_chronopics;
//[Widget] Gtk.Image image_connected_chronopics;
@@ -2850,6 +2851,70 @@ public partial class ChronoJumpWindow
//it's not visible at startup
session_menuitem.Visible = true;
menuitem_mode.Visible = true;
+
+ change_multitest_firmware(m);
+ }
+
+ //change debounce time automatically on change menuitem mode (if multitest firmware)
+ private void change_multitest_firmware(menuitem_modes m) {
+ label_chronopics_multitest.Text = "";
+
+ if(! chronopicWin.Connected)
+ return;
+ if(m == menuitem_modes.POWER)
+ 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())) {
+ Log.WriteLine("Chronopic has been disconnected");
+ createChronopicWindow(true);
+ chronopicWin.Connected = false;
+ return;
+ }
+ }
+
+ Chronopic.Plataforma ps;
+ bool ok = (chronopicWin.CP).Read_platform(out ps);
+ if(!ok) {
+ Log.WriteLine("Chronopic has been disconnected");
+ createChronopicWindow(true);
+ chronopicWin.Connected = false;
+ return;
+ }
+
+
+ ChronopicAuto ca;
+ try {
+ ca = new ChronopicAutoCheck();
+ string chronopicVersion = ca.Read(chronopicWin.SP);
+ } catch {
+ Log.WriteLine("Could not read from Chronopic");
+ return;
+ }
+
+ if(ca.IsChronopicAuto) {
+ try {
+ int debounceChange = 50;
+ if(m == menuitem_modes.RUNS)
+ debounceChange = 10;
+
+ //write change
+ ca = new ChronopicAutoChangeDebounce();
+ ca.Write(chronopicWin.SP, debounceChange);
+
+ //read if ok
+ ca = new ChronopicAutoCheckDebounce();
+ string ms = ca.Read(chronopicWin.SP);
+ if(ms == "50 ms")
+ label_chronopics_multitest.Text = "[" + Catalog.GetString("Jumps") +
"]";
+ else if(ms == "10 ms")
+ label_chronopics_multitest.Text = "[" + Catalog.GetString("Runs") +
"]";
+ } catch {
+ Log.WriteLine("Could not change debounce");
+ }
+ }
}
private void on_radio_menuitem_mode_toggled(object o, EventArgs args)
@@ -3310,7 +3375,25 @@ Console.WriteLine("X");
}
- void on_button_execute_test_clicked (object o, EventArgs args) {
+ 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) {
+ if(! File.Exists(chronopicWin.GetContactsFirstPort())) {
+ Log.WriteLine("Chronopic has been disconnected");
+ createChronopicWindow(true);
+ chronopicWin.Connected = false;
+ return;
+ }
+ }
+
+ on_button_execute_test_accepted(o, args);
+ }
+
+ void on_button_execute_test_accepted (object o, EventArgs args)
+ {
+
if(radio_mode_jumps_small.Active)
{
on_normal_jump_activate(o, args);
@@ -4301,6 +4384,9 @@ Log.WriteLine("DDD 2");
chronopicContactsLabels(0, recreate);
else //(notebook_sup.CurrentPage == 1)
chronopicEncoderLabels(recreate);
+
+ if(recreate)
+ label_chronopics_multitest.Text = "";
}
private void on_chronopic_contacts_clicked (object o, EventArgs args) {
@@ -4345,6 +4431,12 @@ Log.WriteLine("DDD 2");
if(radio_mode_multi_chronopic_small.Active)
on_extra_window_multichronopic_test_changed(new object(), new EventArgs());
+ //this performs a: change_multitest_firmware(m);
+ if(cps > 0)
+ on_radio_menuitem_mode_toggled(new object(), new EventArgs ());
+ else
+ label_chronopics_multitest.Text = "";
+
chronopicContactsLabels(cps, true);
}
diff --git a/src/gui/chronopic.cs b/src/gui/chronopic.cs
index 7f254a7..52b9e47 100644
--- a/src/gui/chronopic.cs
+++ b/src/gui/chronopic.cs
@@ -295,7 +295,10 @@ Log.WriteLine("bbb");
}
//check if user has disconnected chronopic or port has changed
- private void checkChronopicDisconnected() {
+ private void checkChronopicDisconnected()
+ {
+ bool errorFound = false;
+
foreach(ChronopicPortData a in cpd) {
Chronopic myCP;
Chronopic.Plataforma myPS;
@@ -308,38 +311,51 @@ Log.WriteLine("bbb");
} else if(a.Num == 3) {
myCP = cp3;
myPS = platformState3;
- } else { //if(a.Num == 4) {
+ } else {
myCP = cp4;
myPS = platformState4;
}
- int errorCount = 0;
bool ok = false;
if(a.Connected) {
- //try {
+ string myPort = a.Port;
+
+ //http://www.raspberrypi.org/forums/viewtopic.php?f=66&t=88415
+ //https://bugzilla.xamarin.com/show_bug.cgi?id=15514
+ if(! isWindows) {
+ if(! File.Exists(myPort)) {
+ Log.WriteLine("port does not exists: " + myPort);
+ errorFound = true;
+ }
+ }
+
+ if(! errorFound) {
+ //try {
ok = myCP.Read_platform(out myPS);
- //} catch {
- // Log.WriteLine("catch at 1");
- //}
- if(!ok) {
- Log.WriteLine("false at 1");
- errorCount ++;
+ //} catch {
+ // Log.WriteLine("catch at 1");
+ //}
+ if(!ok) {
+ Log.WriteLine("false at 1");
+ errorFound = true;
+ }
}
}
- if(errorCount > 0) {
- ArrayList myCPD = new ArrayList();
- for(int i=1; i<=4;i++) {
- ChronopicPortData b = new ChronopicPortData(i,"",false);
- myCPD.Add(b);
- }
- Create (myCPD, encoderPort, true, volumeOn);
-
- connected = false;
-
- new DialogMessage(Constants.MessageTypes.WARNING,
- Catalog.GetString("One or more Chronopics have been
disconnected.") + "\n" +
- Catalog.GetString("Please connect again, and configure on
Chronopic window."));
+ }
+
+ if(errorFound) {
+ ArrayList myCPD = new ArrayList();
+ for(int i=1; i<=4; i++) {
+ ChronopicPortData b = new ChronopicPortData(i,"",false);
+ myCPD.Add(b);
}
+ Create (myCPD, encoderPort, true, volumeOn);
+
+ connected = false;
+
+ new DialogMessage(Constants.MessageTypes.WARNING,
+ Catalog.GetString("One or more Chronopics have been disconnected.") +
"\n" +
+ Catalog.GetString("Please connect again, and configure on Chronopic
window."));
}
}
@@ -966,6 +982,10 @@ Log.WriteLine("bbb");
return count;
}
+ public string GetContactsFirstPort() {
+ return ((ChronopicPortData) cpd[0]).Port;
+ }
+
public string GetEncoderPort() {
if(isWindows)
return UtilGtk.ComboGetActive(combo_windows_encoder);
@@ -989,6 +1009,15 @@ Log.WriteLine("bbb");
public Chronopic CP4 {
get { return cp4; }
}
+
+ public SerialPort SP {
+ get { return sp; }
+ }
+
+ public Chronopic.Plataforma PlatformState { //on (in platform), off (jumping), or unknow
+ get { return platformState; }
+ }
+
//connected to a Chronopic
public bool Connected {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]