[chronojump] Encoder IM calc GUI much improved
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Encoder IM calc GUI much improved
- Date: Mon, 26 Feb 2018 12:28:45 +0000 (UTC)
commit b8321195646dbfd2fd1cd081a14dd90643bf66bd
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon Feb 26 13:28:01 2018 +0100
Encoder IM calc GUI much improved
glade/encoder_configuration.glade | 249 ++++++++++++++++++++++---------------
src/encoderCapture.cs | 19 +++-
src/gui/encoder.cs | 24 +++-
src/gui/encoderConfiguration.cs | 42 ++++++-
4 files changed, 221 insertions(+), 113 deletions(-)
---
diff --git a/glade/encoder_configuration.glade b/glade/encoder_configuration.glade
index 4951bd3..b5999b9 100644
--- a/glade/encoder_configuration.glade
+++ b/glade/encoder_configuration.glade
@@ -1735,134 +1735,73 @@ Eg. value = 2, means person does twice force at half speed.</property>
</packing>
</child>
<child>
- <widget class="GtkVBox" id="vbox4">
+ <widget class="GtkHBox" id="hbox14">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
- <widget class="GtkHBox" id="hbox14">
+ <widget class="GtkButton" id="button_encoder_capture_inertial_do">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">6</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="has_tooltip">True</property>
+ <signal name="clicked" handler="on_button_encoder_capture_inertial_do_clicked"
swapped="no"/>
<child>
- <widget class="GtkButton" id="button_encoder_capture_inertial_do">
+ <widget class="GtkHBox" id="hbox85">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="has_tooltip">True</property>
- <signal name="clicked" handler="on_button_encoder_capture_inertial_do_clicked"
swapped="no"/>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
<child>
- <widget class="GtkHBox" id="hbox85">
+ <widget class="GtkImage" id="image10">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="spacing">6</property>
- <child>
- <widget class="GtkImage" id="image10">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="stock">gtk-apply</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_button_encoder_capture_inertial_do">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Capture</property>
- </widget>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
+ <property name="stock">gtk-apply</property>
</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="position">0</property>
- </packing>
- </child>
- <child>
- <widget class="GtkButton" id="button_encoder_capture_inertial_cancel">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="has_tooltip">True</property>
- <signal name="clicked"
handler="on_button_encoder_capture_inertial_cancel_clicked" swapped="no"/>
<child>
- <widget class="GtkImage" id="image3">
+ <widget class="GtkLabel" id="label_button_encoder_capture_inertial_do">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="stock">gtk-cancel</property>
+ <property name="label" translatable="yes">Capture</property>
</widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
</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">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
- <widget class="GtkTable" id="table_im_machine_result">
- <property name="can_focus">False</property>
- <property name="n_columns">3</property>
- <property name="column_spacing">6</property>
- <property name="row_spacing">6</property>
- <child>
- <widget class="GtkLabel" id="label28">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="tooltip" translatable="yes">Number of weights</property>
- <property name="xalign">0</property>
- <property name="label">IM machine</property>
- </widget>
- <packing>
- <property name="x_options">GTK_FILL</property>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel" id="label30">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="tooltip" translatable="yes">Number of weights</property>
- <property name="xalign">0</property>
- <property name="label">Kg*cm^2</property>
- </widget>
- <packing>
- <property name="left_attach">2</property>
- <property name="right_attach">3</property>
- <property name="x_options">GTK_FILL</property>
- </packing>
- </child>
+ <widget class="GtkButton" id="button_encoder_capture_inertial_cancel">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="has_tooltip">True</property>
+ <signal name="clicked" handler="on_button_encoder_capture_inertial_cancel_clicked"
swapped="no"/>
<child>
- <widget class="GtkLabel" id="label_im_result_disc">
+ <widget class="GtkImage" id="image_cancel">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="stock">gtk-missing-image</property>
</widget>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- </packing>
</child>
</widget>
<packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
@@ -1874,21 +1813,131 @@ Eg. value = 2, means person does twice force at half speed.</property>
</packing>
</child>
<child>
- <widget class="GtkAlignment" id="alignment3">
+ <widget class="GtkLabel" id="label_capture_time">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="wrap">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">5</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkTable" id="table_angle_oscillations">
+ <property name="can_focus">False</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">2</property>
+ <property name="row_spacing">2</property>
+ <child>
+ <widget class="GtkLabel" id="label38">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Angle</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label39">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Oscillations</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label_im_calc_angle">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="width_chars">6</property>
+ </widget>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label_im_calc_oscillations">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">6</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label_im_feedback">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="top_padding">12</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">7</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkTable" id="table_im_machine_result">
+ <property name="can_focus">False</property>
+ <property name="n_columns">3</property>
+ <property name="column_spacing">6</property>
+ <property name="row_spacing">6</property>
<child>
- <widget class="GtkLabel" id="label_im_feedback">
+ <widget class="GtkLabel" id="label28">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="tooltip" translatable="yes">Number of weights</property>
+ <property name="xalign">0</property>
+ <property name="label">IM machine</property>
</widget>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label30">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="tooltip" translatable="yes">Number of weights</property>
+ <property name="xalign">0</property>
+ <property name="label">Kg*cm^2</property>
+ </widget>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label_im_result_disc">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">5</property>
+ <property name="position">8</property>
</packing>
</child>
</widget>
diff --git a/src/encoderCapture.cs b/src/encoderCapture.cs
index 86e9d2f..7b318e0 100644
--- a/src/encoderCapture.cs
+++ b/src/encoderCapture.cs
@@ -67,7 +67,7 @@ public abstract class EncoderCapture
* sumInertialDisc: on inertial this has the sum of the disc, while sum has the position of the body
(always <= 0 (starting position))
* on inertial we need both
*/
- protected double sum;
+ protected int sum;
protected int sumInertialDisc;
protected int i;
@@ -101,6 +101,9 @@ public abstract class EncoderCapture
protected int inertialCalibratedFirstCross0Pos;
protected bool inertialCalibrated;
+ //Only for IMCalc: go and return is a period. Here we count semiperiods
+ public int IMCalcOscillations;
+
//capture is simulated (a signal file is readed)
private bool simulated = false;
//private int [] simulatedInts;
@@ -863,6 +866,12 @@ public abstract class EncoderCapture
public void Finish() {
finish = true;
}
+
+ //used on inertialIM
+ public int Sum {
+ get { return sum; }
+ }
+
}
@@ -1005,6 +1014,8 @@ public class EncoderCaptureInertial : EncoderCapture
public class EncoderCaptureIMCalc : EncoderCapture
{
+ public static int InactivityEndTime = 3; //end at 3 segons of inactivity
+
public EncoderCaptureIMCalc()
{
}
@@ -1012,13 +1023,15 @@ public class EncoderCaptureIMCalc : EncoderCapture
protected override void initSpecific()
{
realHeightG = 2 * 500 ; //.5 meter up / .5 meter down
+ IMCalcOscillations = 0;
}
// on IMCalc we don't need to send data to R and get curves we will call R at the end
- protected override bool shouldSendCurve() {
+ protected override bool shouldSendCurve()
+ {
+ IMCalcOscillations ++;
return false;
}
-
}
/*
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 453568c..2909541 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -923,6 +923,9 @@ public partial class ChronoJumpWindow
return;
encoder_configuration_win.Button_encoder_capture_inertial_do_chronopic_ok();
+ encoder_configuration_win.Label_capture_time(
+ preferences.encoderCaptureTimeIM,
+ EncoderCaptureIMCalc.InactivityEndTime);
//tis notebook has capture (signal plotting), and curves (shows R graph)
if(notebook_encoder_capture.CurrentPage == 1)
@@ -4554,6 +4557,9 @@ public partial class ChronoJumpWindow
if(eCapture.EncoderCapturePoints == null)
return;
+ if(mode == UpdateEncoderPaintModes.CALCULE_IM)
+ encoder_configuration_win.EncoderReaded(eCapture.Sum, eCapture.IMCalcOscillations);
+
//this happens when EncoderCaptureShowOnlyBars=TRUE
if(encoder_capture_signal_drawingarea == null || encoder_capture_signal_pixmap == null)
return;
@@ -5290,7 +5296,7 @@ public partial class ChronoJumpWindow
if( ! (currentSession.Name == Constants.SessionSimulatedName && testsActive))
portName =
chronopicRegister.ConnectedOfType(ChronopicRegisterPort.Types.ENCODER).Port;
- eCapture.InitGlobal(
+ bool success = eCapture.InitGlobal(
encoder_capture_signal_drawingarea.Allocation.Width,
encoder_capture_signal_drawingarea.Allocation.Height,
recordingTime,
@@ -5301,6 +5307,12 @@ public partial class ChronoJumpWindow
(encoderConfigurationCurrent.has_inertia &&
eCaptureInertialBG != null),
configChronojump.EncoderCaptureShowOnlyBars,
currentSession.Name == Constants.SessionSimulatedName &&
testsActive);
+ if(! success)
+ {
+ new DialogMessage(Constants.MessageTypes.WARNING,
+ Catalog.GetString("Sorry, cannot start capture."));
+ return;
+ }
if(encoderConfigurationCurrent.has_inertia && eCaptureInertialBG != null)
{
@@ -5343,8 +5355,8 @@ public partial class ChronoJumpWindow
bool success = eCapture.InitGlobal(
encoder_capture_signal_drawingarea.Allocation.Width,
encoder_capture_signal_drawingarea.Allocation.Height,
- preferences.encoderCaptureTimeIM,
- preferences.encoderCaptureInactivityEndTime,
+ preferences.encoderCaptureTimeIM, //two minutes max capture
+ EncoderCaptureIMCalc.InactivityEndTime, //3 seconds
false,
findEccon(true),
chronopicRegister.ConnectedOfType(ChronopicRegisterPort.Types.ENCODER).Port,
@@ -6293,8 +6305,8 @@ public partial class ChronoJumpWindow
encoder_pulsebar_capture.Text =
Catalog.GetString("Cancelled");
}
}
- else if( (action == encoderActions.CAPTURE || action == encoderActions.CAPTURE_IM)
- && encoderProcessFinish ) {
+ else if(action == encoderActions.CAPTURE && encoderProcessFinish)
+ {
encoder_pulsebar_capture.Text = Catalog.GetString("Finished");
}
else if(action == encoderActions.CURVES || action == encoderActions.CURVES_AC ||
action == encoderActions.LOAD)
@@ -6476,7 +6488,7 @@ public partial class ChronoJumpWindow
else {
//script calculates Kg*m^2 -> GUI needs Kg*cm^2
encoder_configuration_win.Button_encoder_capture_inertial_do_ended (
- Convert.ToDouble(imResultText) * 10000.0, "");
+ Convert.ToDouble(imResultText) * 10000.0,
Catalog.GetString("Finished"));
}
encoderButtonsSensitive(encoderSensEnum.DONENOSIGNAL);
diff --git a/src/gui/encoderConfiguration.cs b/src/gui/encoderConfiguration.cs
index 2450de7..26d854a 100644
--- a/src/gui/encoderConfiguration.cs
+++ b/src/gui/encoderConfiguration.cs
@@ -92,6 +92,7 @@ public class EncoderConfigurationWindow
[Widget] Gtk.Image image_import;
[Widget] Gtk.Image image_export;
[Widget] Gtk.Image image_delete;
+ [Widget] Gtk.Image image_cancel;
[Widget] Gtk.Entry entry_save_name;
[Widget] Gtk.Entry entry_save_description;
@@ -105,6 +106,11 @@ public class EncoderConfigurationWindow
[Widget] Gtk.Button button_encoder_capture_inertial_do;
[Widget] Gtk.Button button_encoder_capture_inertial_cancel;
//[Widget] Gtk.Button button_encoder_capture_inertial_finish;
+ [Widget] Gtk.Label label_capture_time;
+ [Widget] Gtk.Label label_im_calc_angle;
+ [Widget] Gtk.Label label_im_calc_oscillations;
+ [Widget] Gtk.Table table_angle_oscillations;
+ [Widget] Gtk.Table table_im_machine_result;
[Widget] Gtk.Button button_close;
@@ -142,6 +148,9 @@ public class EncoderConfigurationWindow
pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameEncoderCalculeIM);
image_encoder_calcule_im.Pixbuf = pixbuf;
+ pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "image_cancel.png");
+ image_cancel.Pixbuf = pixbuf;
+
//put an icon to window
UtilGtk.IconWindow(encoder_configuration);
}
@@ -894,7 +903,10 @@ public class EncoderConfigurationWindow
//label_button_encoder_capture_inertial_do.Visible = false;
button_encoder_capture_inertial_cancel.Sensitive = true;
//button_encoder_capture_inertial_finish.Sensitive = true;
-
+
+ table_angle_oscillations.Visible = true;
+ table_im_machine_result.Visible = false;
+
label_im_feedback.Text = "<b>" + Catalog.GetString("Capturing") + "</b>";
label_im_feedback.UseMarkup = true;
@@ -903,6 +915,23 @@ public class EncoderConfigurationWindow
capturing = true;
}
+ public void EncoderReaded(int sum, int oscillations)
+ {
+ double angle = 0;
+ if(sum != 0)
+ angle = (sum * 360.0) / 200;
+ label_im_calc_angle.Text = Util.TrimDecimals(angle, 1);
+ label_im_calc_oscillations.Text = oscillations.ToString();
+ }
+
+ public void Label_capture_time(int maxTime, int inactivityTime)
+ {
+ label_capture_time.Text =
+ string.Format(Catalog.GetString("Max time: {0} s."), maxTime.ToString()) + "\n" +
+ string.Format(Catalog.GetString("Ends at inactivity during {0} s."),
inactivityTime.ToString());
+ label_capture_time.Visible = true;
+ }
+
//if error, imResult: 0; message: is error message
//if ok, imResult: inertia moment; message: ""
public void Button_encoder_capture_inertial_do_ended (double imResult, string message)
@@ -915,17 +944,22 @@ public class EncoderConfigurationWindow
button_encoder_capture_inertial_cancel.Sensitive = false;
//button_encoder_capture_inertial_finish.Sensitive = false;
+ label_capture_time.Visible = false;
+
if(imResult == 0) {
- label_im_feedback.Text = "<b>" + message + "</b>";
- label_im_feedback.UseMarkup = true;
spin_inertia_machine.Value = imResult;
} else {
//label_im_result_disc.Text = Util.TrimDecimals(imResult, 2);
//as int now
label_im_result_disc.Text = Convert.ToInt32(imResult).ToString();
spin_inertia_machine.Value = imResult;
- label_im_feedback.Text = "";
+ table_angle_oscillations.Visible = false;
+ table_im_machine_result.Visible = true;
}
+
+ label_im_feedback.Text = "<b>" + message + "</b>";
+ label_im_feedback.UseMarkup = true;
+
capturing = false;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]