[chronojump] RunEncoder with triggers UNTESTED
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] RunEncoder with triggers UNTESTED
- Date: Mon, 27 Jan 2020 17:54:09 +0000 (UTC)
commit 0944321528f3eccfb649fb16612caa11e4a9af7f
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon Jan 27 18:18:02 2020 +0100
RunEncoder with triggers UNTESTED
glade/app1.glade | 89 +++++++++++++++++++++++++++++++++++++++---
src/gui/runEncoder.cs | 106 ++++++++++++++++++++++++--------------------------
src/gui/trigger.cs | 18 +++++++++
src/trigger.cs | 2 +-
4 files changed, 153 insertions(+), 62 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index a6aeacf3..0128cc43 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -22809,6 +22809,12 @@ Concentric</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
@@ -23175,14 +23181,19 @@ Concentric</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <widget class="GtkScrolledWindow" id="scrolledwindow9">
+ <widget class="GtkNotebook" id="notebook2">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property
name="hscrollbar_policy">automatic</property>
- <property
name="vscrollbar_policy">automatic</property>
- <property name="shadow_type">in</property>
+ <property name="tab_pos">bottom</property>
<child>
- <widget class="GtkViewport"
id="viewport_run_encoder_graph">
+ <widget class="GtkScrolledWindow"
id="scrolledwindow9">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property
name="hscrollbar_policy">automatic</property>
+ <property
name="vscrollbar_policy">automatic</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <widget class="GtkViewport"
id="viewport_run_encoder_graph">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="shadow_type">none</property>
@@ -23204,8 +23215,70 @@ Concentric</property>
</child>
</widget>
</child>
+ </widget>
+ </child>
</widget>
</child>
+ <child>
+ <widget class="GtkLabel" id="label420">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Show
graph</property>
+ </widget>
+ <packing>
+ <property name="tab_fill">False</property>
+ <property name="type">tab</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkVBox" id="vbox165">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">8</property>
+ <property name="spacing">8</property>
+ <child>
+ <widget class="GtkLabel" id="label419">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label"
translatable="yes">Triggers found on this set</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkTextView"
id="textview_run_encoder_triggers">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">False</property>
+ <property name="cursor_visible">False</property>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label421">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Show
triggers</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ <property name="tab_fill">False</property>
+ <property name="type">tab</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="expand">True</property>
@@ -32358,6 +32431,12 @@ then click this button.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
diff --git a/src/gui/runEncoder.cs b/src/gui/runEncoder.cs
index 79981328..bdeac573 100644
--- a/src/gui/runEncoder.cs
+++ b/src/gui/runEncoder.cs
@@ -167,13 +167,13 @@ public partial class ChronoJumpWindow
/*
* return(str.Remove(0,14));
* use a regex because with above line we can find problems like this:
- * init string: ^@;Race_analyzer-0.2
+ * init string: ^@;Race_analyzer-0.3
*/
Match match = Regex.Match(str, @"Race_Analyzer-(\d+\.\d+)");
if(match.Groups.Count == 1)
return str = match.Value;
else
- return "0.2"; //if there is a problem default to 0.2. 0.2 is the first that will be
distributed and will be on binary
+ return "0.3"; //if there is a problem default to 0.3. 0.2 was the first that will be
distributed and will be on binary. 0.3 has the byte of encoderOrRCA
}
@@ -445,10 +445,11 @@ public partial class ChronoJumpWindow
TextWriter writer = File.CreateText(fileName);
writer.WriteLine("Pulses;Time(useconds);Force(N)");
+
+ triggerListRunEncoder = new TriggerList();
str = "";
int firstTime = 0;
- bool readBinary = true;
int rowsCount = 0;
while(! runEncoderProcessFinish && ! runEncoderProcessCancel && ! runEncoderProcessError)
{
@@ -466,45 +467,25 @@ public partial class ChronoJumpWindow
* and then the while above will end with the runEncoderProcessFinish condition
*/
- if(readBinary)
- {
- if (portRE.BytesToRead == 0)
- continue;
+ if (portRE.BytesToRead == 0)
+ continue;
- //time (4 bytes: long at Arduino, uint at c-sharp), force (2 bytes: uint)
- List<uint> binaryReaded = readBinaryRunEncoderValues();
- uint time = binaryReaded[0];
- uint force = binaryReaded[1];
+ //time (4 bytes: long at Arduino, uint at c-sharp), force (2 bytes: uint)
+ List<uint> binaryReaded = readBinaryRunEncoderValues();
+ uint time = binaryReaded[0];
+ uint force = binaryReaded[1];
+ uint encoderOrRCA = binaryReaded[2];
+
+ if(encoderOrRCA == 0)
+ {
writer.WriteLine(string.Format("{0};{1};{2}", pps, time, force));
rowsCount ++;
- } else {
- //LogB.Information(string.Format("finish conditions: {0}-{1}-{2}",
- // runEncoderProcessFinish, runEncoderProcessCancel,
runEncoderProcessError));
-
- str = readFromRunEncoderIfDataArrived();
- if(! checkRunEncoderCaptureLineIsOk(str))
- continue;
-
- /*
- int time = Convert.ToInt32(strFull[0]);
+ } else if(encoderOrRCA == 1)
+ triggerListRunEncoder.Add(new Trigger(Trigger.Modes.ENCODER,
Convert.ToInt32(time), false));
+ else if(encoderOrRCA == 2)
+ triggerListRunEncoder.Add(new Trigger(Trigger.Modes.ENCODER,
Convert.ToInt32(time), true));
- //measurement does not start at 0 time. When we start receiving data, mark
this as firstTime
- if(firstTime == 0)
- firstTime = time;
-
- //use this to have time starting at 0
- time -= firstTime;
-
- double force = Convert.ToDouble(Util.ChangeDecimalSeparator(strFull[1]));
- */
-
- string [] strFull = str.Split(new char[] {';'});
- writer.WriteLine(string.Format("{0};{1};{2}",
- Convert.ToInt32(strFull[0]), //pulse
- Convert.ToInt32(strFull[1]), //time
- Convert.ToInt32(strFull[2]) //force
- ));
- }
+ //TODO: manage spurious like on encoderCapture.cs
}
LogB.Information(string.Format("FINISHED WITH conditions: {0}-{1}-{2}",
@@ -523,23 +504,12 @@ public partial class ChronoJumpWindow
Thread.Sleep(10);
try {
str = portRE.ReadLine();
- if(readBinary)
- {
- //we will discard everything at the moment finish is pressed
- //to read correctly as txt the "Capture ended" string
- //note this can make the rowsCount differ
- } else {
- if(checkRunEncoderCaptureLineIsOk(str))
- {
- LogB.Information("Processing last received line");
- string [] strFull = str.Split(new char[] {';'});
- writer.WriteLine(string.Format("{0};{1};{2}",
- Convert.ToInt32(strFull[0]), //pulse
- Convert.ToInt32(strFull[1]), //time
- Convert.ToInt32(strFull[2]) //force
- ));
- }
- }
+
+ /*
+ * we will discard everything at the moment finish is pressed
+ * to read correctly as txt the "Capture ended" string
+ * note this can make the rowsCount differ
+ */
} catch {
LogB.Information("Catched waiting end_capture feedback");
}
@@ -575,7 +545,7 @@ public partial class ChronoJumpWindow
}
}
- //time (4 bytes: long at Arduino, uint at c-sharp), force (2 bytes: uint)
+ //time (4 bytes: long at Arduino, uint at c-sharp), force (2 bytes: uint), encoder/RCA (1 byte: uint)
private List<uint> readBinaryRunEncoderValues()
{
//LogB.Debug("readed start mark Ok");
@@ -627,6 +597,15 @@ public partial class ChronoJumpWindow
dataRow.Add(readedNum);
+ /*
+ * byte for encoder or RCA
+ * 0 encoder data
+ * 1 RCA down (button is released)
+ * 2 RCA up (button is pressed)
+ */
+ b0 = portRE.ReadByte();
+ dataRow.Add(readedNum);
+
//LogB.Information("bbb----");
return dataRow;
@@ -747,6 +726,14 @@ public partial class ChronoJumpWindow
button_video_play_this_test_contacts.Sensitive = (re.VideoURL != "");
sensitiveLastTestButtons(true);
+ //triggers
+ triggerListRunEncoder = new TriggerList(
+ SqliteTrigger.Select(
+ false, Trigger.Modes.RACEANALYZER,
+ Convert.ToInt32(currentRunEncoder.UniqueID))
+ );
+ showRaceAnalyzerTriggers ();
+
event_execute_label_message.Text = "Loaded: " + Util.GetLastPartOfPath(re.Filename);
}
@@ -1055,6 +1042,8 @@ LogB.Information(" re C finish");
currentRunEncoderExercise.Name);
currentRunEncoder.UniqueID = currentRunEncoder.InsertSQL(false);
+ SaveTriggers(currentRunEncoder.UniqueID);
+ showRaceAnalyzerTriggers ();
//stop camera
if(webcamEnd (Constants.TestTypes.RACEANALYZER,
currentRunEncoder.UniqueID))
@@ -1183,6 +1172,11 @@ LogB.Information(" re R ");
return true;
}
+ public void SaveTriggers(int signalID)
+ {
+ triggerListRunEncoder.SQLInsert(signalID);
+ }
+
void runEncoderButtonsSensitive(bool sensitive)
{
//runEncoder related buttons
diff --git a/src/gui/trigger.cs b/src/gui/trigger.cs
index b852118a..dcd801db 100644
--- a/src/gui/trigger.cs
+++ b/src/gui/trigger.cs
@@ -55,4 +55,22 @@ public partial class ChronoJumpWindow
else
notebook_analyze_results.GetNthPage(2).Hide();
}
+
+ // <--------------- end of encoder
+ // start of race analyzer ------------->
+
+ [Widget] Gtk.TextView textview_run_encoder_triggers;
+ TriggerList triggerListRunEncoder;
+
+ private void showRaceAnalyzerTriggers()
+ {
+ triggerListRunEncoder.Print();
+ if(triggerListRunEncoder.Count() > 0)
+ {
+ //fill textview
+ TextBuffer tb1 = new TextBuffer (new TextTagTable());
+ tb1.Text = triggerListRunEncoder.ToString();
+ textview_run_encoder_triggers.Buffer = tb1;
+ }
+ }
}
diff --git a/src/trigger.cs b/src/trigger.cs
index 873f1987..adc0c3b7 100644
--- a/src/trigger.cs
+++ b/src/trigger.cs
@@ -21,7 +21,7 @@ using System.Collections.Generic; //List<T>
public class Trigger
{
- public enum Modes { ENCODER }
+ public enum Modes { ENCODER, FORCESENSOR, RACEANALYZER }
private int uniqueID;
private Modes mode;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]