[chronojump] All chronopic encoder working with chronopicRegister. TODO: Need to delete commented code
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] All chronopic encoder working with chronopicRegister. TODO: Need to delete commented code
- Date: Sun, 9 Oct 2016 19:59:52 +0000 (UTC)
commit 444fd8d5d7800f2a1cf1f3096990a89d6272ea44
Author: Xavier de Blas <xaviblas gmail com>
Date: Sun Oct 9 21:58:22 2016 +0200
All chronopic encoder working with chronopicRegister. TODO: Need to delete commented code
glade/chronojump.glade | 5 +-
src/chronopicRegister.cs | 20 ++++++
src/encoderCapture.cs | 2 +
src/gui/chronojump.cs | 26 ++++++--
src/gui/chronopic.cs | 6 +-
src/gui/chronopicRegister.cs | 18 ++++-
src/gui/encoder.cs | 137 +++++++++++++++++++++++-------------------
7 files changed, 137 insertions(+), 77 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 81effdf..bfa5c03 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -13851,7 +13851,7 @@ Concentric</property>
<property name="can_focus">False</property>
<child>
<widget class="GtkImage"
id="image_chronopic_encoder_no">
- <property name="visible">True</property>
+ <property name="visible">False</property>
<property name="can_focus">False</property>
<property name="stock">gtk-no</property>
<property name="icon-size">2</property>
@@ -13864,6 +13864,7 @@ Concentric</property>
</child>
<child>
<widget class="GtkImage"
id="image_chronopic_encoder_yes">
+ <property name="visible">False</property>
<property name="can_focus">False</property>
<property name="stock">gtk-yes</property>
<property name="icon-size">3</property>
@@ -13883,7 +13884,7 @@ Concentric</property>
</child>
<child>
<widget class="GtkLabel"
id="label_chronopic_encoder">
- <property name="visible">True</property>
+ <property name="visible">False</property>
<property name="can_focus">False</property>
<property name="xpad">5</property>
<property name="label"
translatable="yes">Encoder disconnected</property>
diff --git a/src/chronopicRegister.cs b/src/chronopicRegister.cs
index efd8b3d..e927f84 100644
--- a/src/chronopicRegister.cs
+++ b/src/chronopicRegister.cs
@@ -227,6 +227,26 @@ public abstract class ChronopicRegister
return crp;
}
+ public int NumConnectedOfType(ChronopicRegisterPort.Types type)
+ {
+ int count = 0;
+ foreach(ChronopicRegisterPort crp in crpl.L)
+ if(crp.Type == type && crp.Port != "")
+ count ++;
+
+ return count;
+ }
+
+ //returns first found (should be only one if called NumConnectedOfType and returned value was 1
+ public string PortConnectedOfType(ChronopicRegisterPort.Types type)
+ {
+ foreach(ChronopicRegisterPort crp in crpl.L)
+ if(crp.Type == type && crp.Port != "")
+ return crp.Port;
+
+ return "";
+ }
+
public ChronopicRegisterPortList Crpl
{
get { return crpl; }
diff --git a/src/encoderCapture.cs b/src/encoderCapture.cs
index e8b1c7c..feb6cc2 100644
--- a/src/encoderCapture.cs
+++ b/src/encoderCapture.cs
@@ -94,6 +94,7 @@ public abstract class EncoderCapture
private bool cancel;
private bool finish;
+ /*
public static bool CheckPort(string port)
{
if(File.Exists(UtilAll.GetECapSimSignalFileName())) { //simulatedEncoder
@@ -118,6 +119,7 @@ public abstract class EncoderCapture
}
return true;
}
+ */
//if cont (continuous mode), then will not end when too much time passed before start
public void InitGlobal (int widthG, int heightG, int time, int timeEnd, bool cont, string eccon,
string port)
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 10c67fe..c1ec057 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -274,9 +274,9 @@ public partial class ChronoJumpWindow
[Widget] Gtk.Button button_chronopic_encoder_detecting_cancel;
[Widget] Gtk.Button button_chronopic_encoder_detecting_info;
[Widget] Gtk.Viewport viewport_chronopic_encoder;
- [Widget] Gtk.Label label_chronopic_encoder;
- [Widget] Gtk.Image image_chronopic_encoder_no;
- [Widget] Gtk.Image image_chronopic_encoder_yes;
+ //[Widget] Gtk.Label label_chronopic_encoder;
+ //[Widget] Gtk.Image image_chronopic_encoder_no;
+ //[Widget] Gtk.Image image_chronopic_encoder_yes;
[Widget] Gtk.HBox hbox_video_capture;
[Widget] Gtk.Label label_video_feedback;
@@ -4812,9 +4812,13 @@ public partial class ChronoJumpWindow
}
private void on_chronopic_encoder_clicked (object o, EventArgs args) {
+ /*
chronopicWin = ChronopicWindow.View(ChronopicWindow.ChronojumpMode.ENCODER,
preferences.volumeOn);
//chronopicWin.FakeWindowReload.Clicked += new EventHandler(chronopicWindowReload);
chronopicWin.FakeWindowDone.Clicked += new
EventHandler(on_chronopic_window_encoder_connected_or_done);
+ */
+
+ chronopicRegisterUpdate(true);
}
@@ -4876,7 +4880,9 @@ public partial class ChronoJumpWindow
chronopicWin.Connected);
}
- private void chronopicEncoderLabels(bool colorize) {
+ private void chronopicEncoderLabels(bool colorize)
+ {
+ /*
LogB.Information("at chronopicEncoderLabels");
string encoderPort = chronopicWin.GetEncoderPort();
LogB.Debug("gui/chronojump.cs encoderPort:", encoderPort);
@@ -4899,6 +4905,7 @@ public partial class ChronoJumpWindow
encoderPort != "");
LogB.Information("at chronopicEncoderLabels end");
+ */
}
@@ -6787,13 +6794,18 @@ LogB.Debug("X");
chronopicWizardWin.HideAndNull();
}
+ ChronopicRegister chronopicRegister;
private void on_button_chronopic_register_clicked (object o, EventArgs args)
{
- //testing ChronopicRegister
+ chronopicRegisterUpdate(true);
+ }
+ private void chronopicRegisterUpdate(bool openWindow)
+ {
ChronopicRegisterSelectOS cros = new ChronopicRegisterSelectOS();
- ChronopicRegister cr = cros.Do();
+ chronopicRegister = cros.Do();
- ChronopicRegisterWindow crw = new ChronopicRegisterWindow(cr.Crpl.L);
+ if(openWindow)
+ new ChronopicRegisterWindow(chronopicRegister.Crpl.L);
}
//start/end auto mode
diff --git a/src/gui/chronopic.cs b/src/gui/chronopic.cs
index ee425a2..5c4cd53 100644
--- a/src/gui/chronopic.cs
+++ b/src/gui/chronopic.cs
@@ -1046,7 +1046,7 @@ public class ChronopicWindow
return ((ChronopicPortData) cpd[0]).Port;
}
- public string GetEncoderPort() {
+ //public string GetEncoderPort() {
/*
if(isWindows)
return UtilGtk.ComboGetActive(combo_windows_encoder);
@@ -1058,8 +1058,8 @@ public class ChronopicWindow
* and readed from the software
* without needing to define the combos (from View)
*/
- return encoderPort;
- }
+ // return encoderPort;
+ //}
public void CreateSPifNeeded(string port)
{
diff --git a/src/gui/chronopicRegister.cs b/src/gui/chronopicRegister.cs
index 7807d67..2387022 100644
--- a/src/gui/chronopicRegister.cs
+++ b/src/gui/chronopicRegister.cs
@@ -119,11 +119,21 @@ public class ChronopicRegisterWindow
treeview.Model = listStoreAll;
- foreach(ChronopicRegisterPort crp in list)
- listStoreAll.AppendValues(crp.SerialNumber, crp.Type.ToString(), crp.Port);
-
+ bool chronopicsFound = false;
+ foreach(ChronopicRegisterPort crp in list) {
+ if(crp.Port != "") {
+ listStoreAll.AppendValues(crp.SerialNumber, crp.Type.ToString(), crp.Port);
+ chronopicsFound = true;
+ }
+ }
- Gtk.Label label = new Gtk.Label("To change values:\nClick on Type and the press Enter");
+ Gtk.Label label;
+ if(chronopicsFound) {
+ label = new Gtk.Label("To change values:\nClick on <b>Type</b> column and the press
Enter.");
+ label.UseMarkup = true;
+ } else {
+ label = new Gtk.Label("Chronopic/s not found:\nConnect and reopen this window.");
+ }
Gtk.VBox vboxTV = new Gtk.VBox(false, 8);
vboxTV.Add(treeview);
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index f641ca2..f2bc067 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -547,6 +547,7 @@ public partial class ChronoJumpWindow
repetitiveConditionsWin.View(Constants.BellModes.ENCODER, preferences.volumeOn);
}
+ /*
private bool encoderCheckPort()
{
if(File.Exists(UtilAll.GetECapSimSignalFileName())) //simulatedEncoder
@@ -571,6 +572,7 @@ public partial class ChronoJumpWindow
return true;
}
+ */
double findMaxPowerIntersession()
{
@@ -598,13 +600,31 @@ public partial class ChronoJumpWindow
return maxPower;
}
+ bool canCaptureEncoder()
+ {
+ chronopicRegisterUpdate(false);
+ int numEncoders = chronopicRegister.NumConnectedOfType(ChronopicRegisterPort.Types.ENCODER);
+ LogB.Information("numEncoders: " + numEncoders);
+ if(numEncoders == 0) {
+ new DialogMessage(Constants.MessageTypes.WARNING, "Encoder is not connected");
+ return false;
+ }
+ if(numEncoders > 1) {
+ new DialogMessage(Constants.MessageTypes.WARNING, "More than 1 encoders are
connected");
+ return false;
+ }
+
+ return true;
+ }
+
double maxPowerIntersessionOnCapture;
void on_button_encoder_capture_clicked (object o, EventArgs args)
{
maxPowerIntersessionOnCapture = findMaxPowerIntersession();
//LogB.Information("maxPower: " + maxPowerIntersessionOnCapture);
- if(! encoderCheckPort())
+ //check if chronopics have changed
+ if(! canCaptureEncoder())
return;
if(encoderConfigurationCurrent.has_inertia)
@@ -634,9 +654,10 @@ public partial class ChronoJumpWindow
void on_button_encoder_capture_calcule_im ()
{
- if(! encoderCheckPort())
+ //check if chronopics have changed
+ if(! canCaptureEncoder())
return;
-
+
encoder_configuration_win.Button_encoder_capture_inertial_do_chronopic_ok();
//tis notebook has capture (signal plotting), and curves (shows R graph)
@@ -2106,7 +2127,7 @@ public partial class ChronoJumpWindow
preferences.encoderCaptureInactivityEndTime,
radio_encoder_capture_cont.Active,
findEccon(true),
- chronopicWin.GetEncoderPort()
+ chronopicRegister.PortConnectedOfType(ChronopicRegisterPort.Types.ENCODER)
);
bool capturedOk = eCapture.Capture(
UtilEncoder.GetEncoderDataTempFileName(),
@@ -2140,7 +2161,7 @@ public partial class ChronoJumpWindow
preferences.encoderCaptureInactivityEndTime,
false,
findEccon(true),
- chronopicWin.GetEncoderPort()
+ chronopicRegister.PortConnectedOfType(ChronopicRegisterPort.Types.ENCODER)
);
bool capturedOk = eCapture.Capture(
UtilEncoder.GetEncoderDataTempFileName(),
@@ -4537,84 +4558,78 @@ public partial class ChronoJumpWindow
/* thread stuff */
- private void encoderThreadStart(encoderActions action) {
+ private void encoderThreadStart(encoderActions action)
+ {
encoderProcessCancel = false;
- if(action == encoderActions.CAPTURE || action == encoderActions.CAPTURE_IM) {
+ if(action == encoderActions.CAPTURE || action == encoderActions.CAPTURE_IM)
+ {
//encoder_pulsebar_capture.Text = Catalog.GetString("Please, wait.");
LogB.Information("encoderThreadStart begins");
- if( EncoderCapture.CheckPort(chronopicWin.GetEncoderPort()) ) {
- if(action == encoderActions.CAPTURE) {
- runEncoderCaptureNoRDotNetInitialize();
- }
- image_encoder_width = UtilGtk.WidgetWidth(viewport_image_encoder_capture)-5;
- image_encoder_height = UtilGtk.WidgetHeight(viewport_image_encoder_capture)-5;
-
- //don't need to be false because ItemToggled is deactivated during capture
- treeview_encoder_capture_curves.Sensitive = true;
+ if(action == encoderActions.CAPTURE) {
+ runEncoderCaptureNoRDotNetInitialize();
+ }
- //on continuous mode do not erase bars at beginning of capture in order to
see last bars
- if(action == encoderActions.CAPTURE && radio_encoder_capture_cont.Active) {
- prepareEncoderGraphs(false, true); //bars, signal
- plotCurvesGraphDoPlotMessage("Previous set");
- } else
- prepareEncoderGraphs(true, true);
+ image_encoder_width = UtilGtk.WidgetWidth(viewport_image_encoder_capture)-5;
+ image_encoder_height = UtilGtk.WidgetHeight(viewport_image_encoder_capture)-5;
- //eccaCreated = false;
+ //don't need to be false because ItemToggled is deactivated during capture
+ treeview_encoder_capture_curves.Sensitive = true;
- if(action == encoderActions.CAPTURE) {
- encoderStartVideoRecord();
+ //on continuous mode do not erase bars at beginning of capture in order to see last
bars
+ if(action == encoderActions.CAPTURE && radio_encoder_capture_cont.Active) {
+ prepareEncoderGraphs(false, true); //bars, signal
+ plotCurvesGraphDoPlotMessage("Previous set");
+ } else
+ prepareEncoderGraphs(true, true);
+
+ //eccaCreated = false;
+
+ if(action == encoderActions.CAPTURE) {
+ encoderStartVideoRecord();
- //remove treeview columns
- if( ! (action == encoderActions.CAPTURE &&
radio_encoder_capture_cont.Active) )
- treeviewEncoderCaptureRemoveColumns();
+ //remove treeview columns
+ if( ! (action == encoderActions.CAPTURE && radio_encoder_capture_cont.Active)
)
+ treeviewEncoderCaptureRemoveColumns();
- encoderCaptureStringR = new List<string>();
- encoderCaptureStringR.Add(
+ encoderCaptureStringR = new List<string>();
+ encoderCaptureStringR.Add(
",series,exercise,mass,start,width,height," +
"meanSpeed,maxSpeed,maxSpeedT," +
"meanPower,peakPower,peakPowerT,pp_ppt," +
"meanForce, maxForce, maxForceT");
- string filename = UtilEncoder.GetEncoderCaptureTempFileName();
- if(File.Exists(filename))
- File.Delete(filename);
+ string filename = UtilEncoder.GetEncoderCaptureTempFileName();
+ if(File.Exists(filename))
+ File.Delete(filename);
- encoderCaptureReadedLines = 0;
- deleteAllCapturedCurveFiles();
+ encoderCaptureReadedLines = 0;
+ deleteAllCapturedCurveFiles();
- capturingCsharp = encoderCaptureProcess.CAPTURING;
- }
+ capturingCsharp = encoderCaptureProcess.CAPTURING;
+ }
- if(action == encoderActions.CAPTURE) {
- captureCurvesBarsData = new ArrayList();
+ if(action == encoderActions.CAPTURE) {
+ captureCurvesBarsData = new ArrayList();
- needToRefreshTreeviewCapture = false;
+ needToRefreshTreeviewCapture = false;
- encoderThread = new Thread(new ThreadStart(encoderDoCaptureCsharp));
- GLib.Idle.Add (new GLib.IdleHandler
(pulseGTKEncoderCaptureAndCurves));
- }
- else { //action == encoderActions.CAPTURE_IM)
- encoderThread = new Thread(new ThreadStart(encoderDoCaptureCsharpIM));
- GLib.Idle.Add (new GLib.IdleHandler (pulseGTKEncoderCaptureIM));
- }
-
- encoderShowCaptureDoingButtons(true);
+ encoderThread = new Thread(new ThreadStart(encoderDoCaptureCsharp));
+ GLib.Idle.Add (new GLib.IdleHandler (pulseGTKEncoderCaptureAndCurves));
+ }
+ else { //action == encoderActions.CAPTURE_IM)
+ encoderThread = new Thread(new ThreadStart(encoderDoCaptureCsharpIM));
+ GLib.Idle.Add (new GLib.IdleHandler (pulseGTKEncoderCaptureIM));
+ }
- LogB.Information("encoderThreadStart middle");
- encoderButtonsSensitive(encoderSensEnum.PROCESSINGCAPTURE);
+ encoderShowCaptureDoingButtons(true);
- LogB.ThreadStart();
- encoderThread.Start();
- } else {
- new DialogMessage(Constants.MessageTypes.WARNING,
- Catalog.GetString("Chronopic port is not configured."));
- LogB.Error("Chronopic port is not configured.");
-
- createChronopicWindow(true, "");
- return;
- }
+ LogB.Information("encoderThreadStart middle");
+ encoderButtonsSensitive(encoderSensEnum.PROCESSINGCAPTURE);
+
+ LogB.ThreadStart();
+ encoderThread.Start();
} else if(
action == encoderActions.CURVES ||
action == encoderActions.LOAD ||
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]