[chronojump] Fixing Auto detect on Windows
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Fixing Auto detect on Windows
- Date: Fri, 8 May 2015 15:29:39 +0000 (UTC)
commit 66faee3b58695fbbd92d4a408aae098ccdc01394
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri May 8 17:28:12 2015 +0200
Fixing Auto detect on Windows
src/gui/chronojump.cs | 68 +++++++++++++++++++++---------------------------
src/gui/chronopic.cs | 52 +++++++++++++++++++++++++++++++++++++
2 files changed, 82 insertions(+), 38 deletions(-)
---
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index ffa8d80..a1216a8 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -3045,54 +3045,46 @@ public partial class ChronoJumpWindow
LogB.Information("change_multitest_firmware 2");
- ChronopicAuto ca;
+ ChronopicAuto ca;
+
+ /*
try {
ca = new ChronopicAutoCheck();
+ //problems with windows using this:
string chronopicVersion = ca.Read(chronopicWin.SP);
LogB.Debug("version: " + chronopicVersion);
} catch {
- LogB.Information("Could not read from Chronopic");
+ LogB.Information("Could not read from Chronopic with method 1");
return;
}
-
- LogB.Information("change_multitest_firmware 3");
- if(ca.IsChronopicAuto) {
- LogB.Information("change_multitest_firmware 3 a");
- try {
- int debounceChange = 50;
- if(m == menuitem_modes.RUNS)
- debounceChange = 10;
+ */
- //write change
- ca = new ChronopicAutoChangeDebounce();
- ca.Write(chronopicWin.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(chronopicWin.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);
+ LogB.Information("Trying method 2");
+ bool isChronopicAuto = false;
+ try {
+ string result = chronopicWin.CheckAuto(out isChronopicAuto);
+ LogB.Debug("version: " + result);
+ } catch {
+ LogB.Information("Could not read from Chronopic with method 2");
+ return;
+ }
- if(ms == "50 ms")
+ LogB.Information("change_multitest_firmware 3");
+ if(isChronopicAuto) {
+ int debounceChange = 50;
+ if(m == menuitem_modes.RUNS)
+ debounceChange = 10;
+
+ int msChanged = chronopicWin.ChangeMultitestFirmware(debounceChange);
+ if(msChanged != -1) {
+ if(msChanged == 50)
label_chronopics_multitest.Text = "[" + Catalog.GetString("Jumps") +
"]";
- else if(ms == "10 ms")
+ else if(msChanged == 10)
label_chronopics_multitest.Text = "[" + Catalog.GetString("Runs") +
"]";
- } catch {
- LogB.Error("Could not change debounce");
- }
+ else
+ label_chronopics_multitest.Text = "";
+ } else
+ label_chronopics_multitest.Text = "";
}
}
diff --git a/src/gui/chronopic.cs b/src/gui/chronopic.cs
index a26670e..4742630 100644
--- a/src/gui/chronopic.cs
+++ b/src/gui/chronopic.cs
@@ -726,6 +726,58 @@ public class ChronopicWindow
new DialogMessage(Constants.MessageTypes.INFO,
"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)
+ {
+ 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;
+ }
+
// end of Chronopic Automatic Firmware ---------------
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]