[chronojump] Encoder triggers are saved to tmp. Need tests!
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Encoder triggers are saved to tmp. Need tests!
- Date: Wed, 1 Mar 2017 17:21:04 +0000 (UTC)
commit 82c91af9ccaf72abb18dec954e7ce6fb0d68b914
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed Mar 1 18:20:09 2017 +0100
Encoder triggers are saved to tmp. Need tests!
src/encoderCapture.cs | 50 +++++++++++++++++++++++++++++++++++++++++++++++++
src/util.cs | 4 +++
2 files changed, 54 insertions(+), 0 deletions(-)
---
diff --git a/src/encoderCapture.cs b/src/encoderCapture.cs
index a7666ac..d7dd58f 100644
--- a/src/encoderCapture.cs
+++ b/src/encoderCapture.cs
@@ -52,6 +52,10 @@ public abstract class EncoderCapture
protected static List<int> encoderReaded; //data coming from encoder and converted
protected static List<int> encoderReadedInertialDisc; //data coming from encoder and converted
+
+ private int TRIGGER_ON = 84; //'T' from TRIGGER_ON on encoder firmware
+ private int TRIGGER_OFF = 116; //'t' from TRIGGER_OFF on encoder firmware
+ private List<BoolMs> boolMsList;
/*
* sum: sum ob byteReaded, it's the vertical position
@@ -185,6 +189,10 @@ public abstract class EncoderCapture
initSpecific();
+ //prepare for receiving triggers from encoder
+ boolMsList = new List<BoolMs>();
+ Util.FileDelete(Util.GetEncoderTriggerFileName());
+
cancel = false;
finish = false;
}
@@ -222,6 +230,17 @@ public abstract class EncoderCapture
break;
}
+ if(byteReaded == TRIGGER_ON)
+ {
+ boolMsList.Add(new BoolMs(true, i));
+ continue;
+ }
+ else if(byteReaded == TRIGGER_OFF)
+ {
+ boolMsList.Add(new BoolMs(false, i));
+ continue;
+ }
+
byteReaded = convertByte(byteReaded);
//LogB.Information(" byte: " + byteReaded);
@@ -496,6 +515,20 @@ public abstract class EncoderCapture
saveToFile(outputData1);
+ //save triggers to file (if any)
+ if(boolMsList.Count > 0)
+ {
+ LogB.Debug("runEncoderCaptureCsharp saving triggers");
+ TextWriter writer = File.CreateText(Util.GetEncoderTriggerFileName());
+
+ foreach(BoolMs boolMs in boolMsList)
+ writer.WriteLine(boolMs.ToString());
+
+ writer.Flush();
+ writer.Close();
+ ((IDisposable)writer).Dispose();
+ }
+
LogB.Debug("runEncoderCaptureCsharp ended");
return true;
@@ -894,3 +927,20 @@ public class EncoderCaptureIMCalc : EncoderCapture
}
}
+
+public class BoolMs
+{
+ private bool b;
+ private int ms;
+
+ public BoolMs(bool b, int ms)
+ {
+ this.b = b;
+ this.ms = ms;
+ }
+
+ public override string ToString()
+ {
+ return b.ToString() + ": " + ms.ToString();
+ }
+}
diff --git a/src/util.cs b/src/util.cs
index 29b9a70..39ff420 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -962,6 +962,10 @@ public class Util
return Path.Combine(Path.GetTempPath(), "encoder_set_export.csv");
}
+ public static string GetEncoderTriggerFileName() {
+ return Path.Combine(Path.GetTempPath(), "encoder_trigger.txt");
+ }
+
/********** end of encoder paths ************/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]