[chronojump] Trigger on encoder working again
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Trigger on encoder working again
- Date: Mon, 26 Apr 2021 09:57:57 +0000 (UTC)
commit fe2017ea296af5bb107195a6d94a75ecac23e757
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon Apr 26 11:55:30 2021 +0200
Trigger on encoder working again
src/gui/app1/forceSensor.cs | 2 +-
src/gui/app1/runEncoder.cs | 2 +-
src/sqlite/trigger.cs | 4 ++--
src/trigger.cs | 22 ++++++++++++++++------
4 files changed, 20 insertions(+), 10 deletions(-)
---
diff --git a/src/gui/app1/forceSensor.cs b/src/gui/app1/forceSensor.cs
index 31918239..def72a5d 100644
--- a/src/gui/app1/forceSensor.cs
+++ b/src/gui/app1/forceSensor.cs
@@ -1253,7 +1253,7 @@ public partial class ChronoJumpWindow
trigger = new Trigger(Trigger.Modes.FORCESENSOR, time, true);
if(! triggerListForceSensor.NewSameTypeThanBefore(trigger) &&
- ! triggerListForceSensor.IsSpurious(trigger,
TriggerList.Type3.BOTH, 50))
+ ! triggerListForceSensor.IsSpurious(trigger,
TriggerList.Type3.BOTH, 50000))
triggerListForceSensor.Add(trigger);
continue;
diff --git a/src/gui/app1/runEncoder.cs b/src/gui/app1/runEncoder.cs
index fb343dfc..bc0e6b66 100644
--- a/src/gui/app1/runEncoder.cs
+++ b/src/gui/app1/runEncoder.cs
@@ -614,7 +614,7 @@ public partial class ChronoJumpWindow
trigger = new Trigger(Trigger.Modes.RACEANALYZER, reCGSD.Time, true);
if(! triggerListRunEncoder.NewSameTypeThanBefore(trigger) &&
- ! triggerListRunEncoder.IsSpurious(trigger,
TriggerList.Type3.BOTH, 50))
+ ! triggerListRunEncoder.IsSpurious(trigger,
TriggerList.Type3.BOTH, 50000))
triggerListRunEncoder.Add(trigger);
}
}
diff --git a/src/sqlite/trigger.cs b/src/sqlite/trigger.cs
index 18e9de8e..b38c0dde 100644
--- a/src/sqlite/trigger.cs
+++ b/src/sqlite/trigger.cs
@@ -44,7 +44,7 @@ class SqliteTrigger : Sqlite
"uniqueID INTEGER PRIMARY KEY, " +
"mode TEXT, " + //encoder; gauge
"modeID INT, " + //on encoder: uniqueID
- "ms INT, " + //note this are microseconds!!! should have been named us
+ "ms INT, " + //on encoder are milliseconds, on the rest are microseconds!!!
"inOut INT, " + //bool
"name TEXT, " +
"color TEXT, " +
@@ -70,7 +70,7 @@ class SqliteTrigger : Sqlite
(Trigger.Modes) Enum.Parse(
typeof(Trigger.Modes), reader[1].ToString()), //mode
Convert.ToInt32(reader[2]), //modeID
- Convert.ToInt32(reader[3]), //microseconds
+ Convert.ToInt32(reader[3]), //milliseconds or microseconds
Util.IntToBool(Convert.ToInt32(reader[4])), //inOut
reader[5].ToString(), //name
reader[6].ToString(), //color
diff --git a/src/trigger.cs b/src/trigger.cs
index 1fa6506d..3ab377e4 100644
--- a/src/trigger.cs
+++ b/src/trigger.cs
@@ -23,11 +23,12 @@ using System.Collections.Generic; //List<T>
public class Trigger
{
public enum Modes { ENCODER, FORCESENSOR, RACEANALYZER }
+ //note encoder triggers are in milliseconds (ms) and forcesensor and race analyzer in microseconds
(us)
private int uniqueID;
private Modes mode;
private int modeID;
- private int us; //micro seconds
+ private int us; //on encoder is milliseconds, on forceSensor and raceAnalyzer is micro seconds
private bool inOut;
private string name;
private string color;
@@ -58,7 +59,7 @@ public class Trigger
this.color = color;
this.comments = comments;
}
-
+ //us: on encoder is milliseconds, on forceSensor and raceAnalyzer is micro seconds
public void Substract(int usToSubstract)
{
us -= usToSubstract;
@@ -96,7 +97,12 @@ public class Trigger
get { return us; }
}
public double Ms {
- get { return UtilAll.DivideSafe(us, 1000.0); }
+ get {
+ if(mode == Modes.ENCODER)
+ return(us);
+ else
+ return UtilAll.DivideSafe(us, 1000.0);
+ }
}
public bool IsNegative {
@@ -303,8 +309,12 @@ public class TriggerList
* this newTrigger is an On trigger, compare with last
* encoder: type3.ON, 50ms
* runEncoder: type3.BOTH, 50ms
+
+ * note on encoder it works on ms and the rest in us
+ * on encoder threashold its 50 (ms)
+ * rest of instruments its 50000 (us)
*/
- public bool IsSpurious(Trigger newTrigger, Type3 type3, int ms)
+ public bool IsSpurious(Trigger newTrigger, Type3 type3, int threashold)
{
//cannot be spurious if is the first of this type
if(type3 == Type3.ON && countOn() == 0)
@@ -314,9 +324,9 @@ public class TriggerList
! newTrigger.InOut && countOff() == 0) )
return false;
- if(type3 == Type3.BOTH && (newTrigger.Us - last(Type3.BOTH).Us) < ms*1000 )
+ if(type3 == Type3.BOTH && (newTrigger.Us - last(Type3.BOTH).Us) < threashold )
return true;
- else if(type3 == Type3.ON && (newTrigger.Us - last(Type3.ON).Us) < ms*1000 )
+ else if(type3 == Type3.ON && (newTrigger.Us - last(Type3.ON).Us) < threashold )
return true;
return false;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]