[chronojump] Status encoder file converted to 5 files, just touch and File.Exist; Should be safer than read and w
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Status encoder file converted to 5 files, just touch and File.Exist; Should be safer than read and w
- Date: Wed, 10 Dec 2014 18:15:42 +0000 (UTC)
commit 3519a1c70707efd0a656634f5ccd532a9b24e000
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed Dec 10 19:14:01 2014 +0100
Status encoder file converted to 5 files, just touch and File.Exist; Should be safer than read and write
from two programs
encoder/call_graph.R | 20 +++++++++++++++--
encoder/graph.R | 13 +++++++++-
src/constants.cs | 19 +++++-----------
src/gui/encoder.cs | 57 ++++++++++++++++++++++++++++++++++++-------------
src/utilEncoder.cs | 5 ++-
5 files changed, 79 insertions(+), 35 deletions(-)
---
diff --git a/encoder/call_graph.R b/encoder/call_graph.R
index 2e3294d..b79f970 100644
--- a/encoder/call_graph.R
+++ b/encoder/call_graph.R
@@ -65,15 +65,29 @@ Translated = unlist(strsplit(options[31], "\\;"))
scriptGraphR = options[32]
+#Note:
+#We just touch this files because in the past we created a unique status file from here
+#and we update it
+#but we read it at the same time from chronojump and this produces some crashes on windows
+#now we just touch here, and in chronojump we just read if exist
+
#write(paste("(1/5)",translate("Starting R")), OutputData2)
-write(paste("(1/5)","Starting R"), OutputData2)
+print("Creating (OutputData2)1.txt with touch method...")
+file.create(paste(OutputData2,"1.txt",sep=""))
+print("Created")
source(scriptGraphR)
-write(paste("(2/5)",translate("Loading libraries")), OutputData2)
+#write(paste("(2/5)",translate("Loading libraries")), OutputData2)
+print("Creating (OutputData2)2.txt with touch method...")
+file.create(paste(OutputData2,"2.txt",sep=""))
+print("Created")
loadLibraries(OperatingSystem)
-write(paste("(3/5)",translate("Starting process")), OutputData2)
+#write(paste("(3/5)",translate("Starting process")), OutputData2)
+print("Creating (OutputData2)3.txt with touch method...")
+file.create(paste(OutputData2,"3.txt",sep=""))
+print("Created")
doProcess(options)
diff --git a/encoder/graph.R b/encoder/graph.R
index daa5433..97f71e9 100644
--- a/encoder/graph.R
+++ b/encoder/graph.R
@@ -2597,7 +2597,12 @@ doProcess <- function(options) {
}
}
- write(paste("(4/5)",translate("Repetitions processed")), OutputData2)
+ #make some check here, because this file is being readed in chronojump
+
+ #write(paste("(4/5)",translate("Repetitions processed")), OutputData2)
+ print("Creating (OutputData2)4.txt with touch method...")
+ file.create(paste(OutputData2,"4.txt",sep=""))
+ print("Created")
if(Analysis=="single") {
if(Jump>0) {
@@ -3113,7 +3118,11 @@ doProcess <- function(options) {
if(Analysis != "exportCSV")
dev.off()
- write(paste("(5/5)",translate("R tasks done")), OutputData2)
+ #make some check here, because this file is being readed in chronojump
+ #write(paste("(5/5)",translate("R tasks done")), OutputData2)
+ print("Creating (OutputData2)5.txt with touch method...")
+ file.create(paste(OutputData2,"5.txt",sep=""))
+ print("Created")
warnings()
}
diff --git a/src/constants.cs b/src/constants.cs
index 801017a..f389e9b 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -678,7 +678,10 @@ public class Constants
public static string EncoderCurvesTemp = "chronojump-last-encoder-curves.txt";
public static string EncoderAnalyzeTableTemp = "chronojump-last-encoder-analyze-table.txt";
public static string EncoderGraphTemp = "chronojump-last-encoder-graph.png";
- public static string EncoderStatusTemp = "chronojump-encoder-status.txt";
+
+ //this file will have a ...1.txt ...2.txt ... we check now the first part of the file
+ public static string EncoderStatusTempBase = "chronojump-encoder-status-";
+
public static string EncoderExportTemp = "chronojump-export.csv";
public static string EncoderSpecialDataTemp = "chronojump-special-data.txt"; //variable;result (eg.
"1RM;82.78")
@@ -800,12 +803,7 @@ public class Constants
"Adapted from",
"Mean speed in concentric propulsive phase",
"Sorry, no repetitions matched your criteria.",
- "Need at least three jumps",
- "Starting R",
- "Loading libraries",
- "Starting process",
- "Repetitions processed",
- "R tasks done"
+ "Need at least three jumps"
};
/*
* written here in order to be translated
@@ -845,11 +843,6 @@ public class Constants
Catalog.GetString("Adapted from"),
Catalog.GetString("Mean speed in concentric propulsive phase"),
Catalog.GetString("Sorry, no repetitions matched your criteria."),
- Catalog.GetString("Need at least three jumps"),
- Catalog.GetString("Starting R"),
- Catalog.GetString("Loading libraries"),
- Catalog.GetString("Starting process"),
- Catalog.GetString("Repetitions processed"),
- Catalog.GetString("R tasks done")
+ Catalog.GetString("Need at least three jumps")
};
}
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 15e713b..11c5d81 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -736,7 +736,7 @@ public partial class ChronoJumpWindow
UtilEncoder.GetEncoderDataTempFileName(),
UtilEncoder.GetEncoderGraphTempFileName(),
UtilEncoder.GetEncoderCurvesTempFileName(),
- UtilEncoder.GetEncoderStatusTempFileName(),
+ UtilEncoder.GetEncoderStatusTempBaseFileName(),
"none", //SpecialData
ep);
@@ -1420,7 +1420,7 @@ public partial class ChronoJumpWindow
dataFileName,
UtilEncoder.GetEncoderGraphTempFileName(),
selectedFileName,
- UtilEncoder.GetEncoderStatusTempFileName(),
+ UtilEncoder.GetEncoderStatusTempBaseFileName(),
"none", //SpecialData
ep);
@@ -2456,7 +2456,7 @@ public partial class ChronoJumpWindow
dataFileName,
UtilEncoder.GetEncoderGraphTempFileName(),
UtilEncoder.GetEncoderAnalyzeTableTempFileName(),
- UtilEncoder.GetEncoderStatusTempFileName(),
+ UtilEncoder.GetEncoderStatusTempBaseFileName(),
UtilEncoder.GetEncoderSpecialDataTempFileName(),
ep);
@@ -4634,6 +4634,7 @@ public partial class ChronoJumpWindow
try {
string contents = Catalog.GetString("Please, wait.");
double fraction = -1;
+ /*
if(Util.FileExists(UtilEncoder.GetEncoderStatusTempFileName())) {
contents = Util.ReadFile(UtilEncoder.GetEncoderStatusTempFileName(), true);
//contents is:
@@ -4645,27 +4646,47 @@ public partial class ChronoJumpWindow
fraction = Util.DivideSafeFraction(
Convert.ToInt32(contents[1]-48),
Convert.ToInt32(contents[3]-48) );
}
+ */
+
+ if(Util.FileExists(UtilEncoder.GetEncoderStatusTempBaseFileName() + "5.txt"))
+ {
+ fraction = 5;
+ contents = Catalog.GetString("R tasks done");
+ } else if(Util.FileExists(UtilEncoder.GetEncoderStatusTempBaseFileName() + "4.txt"))
+ {
+ fraction = 4;
+ contents = Catalog.GetString("Repetitions processed");
+ } else if(Util.FileExists(UtilEncoder.GetEncoderStatusTempBaseFileName() + "3.txt"))
+ {
+ fraction = 3;
+ contents = Catalog.GetString("Starting process");
+ } else if(Util.FileExists(UtilEncoder.GetEncoderStatusTempBaseFileName() + "2.txt"))
+ {
+ fraction = 2;
+ contents = Catalog.GetString("Loading libraries");
+ } else if(Util.FileExists(UtilEncoder.GetEncoderStatusTempBaseFileName() + "1.txt"))
+ {
+ fraction = 1;
+ contents = Catalog.GetString("Starting R");
+ }
if(action == encoderActions.CURVES || action == encoderActions.LOAD) {
- if(fraction == -1) {
+ if(fraction == -1)
encoder_pulsebar_capture.Pulse();
- encoder_pulsebar_capture.Text = contents;
- } else {
+ else
encoder_pulsebar_capture.Fraction = fraction;
- encoder_pulsebar_capture.Text = contents.Substring(6);
- }
+
+ encoder_pulsebar_capture.Text = contents;
} else {
- if(fraction == -1) {
+ if(fraction == -1)
encoder_pulsebar_analyze.Pulse();
- encoder_pulsebar_analyze.Text = contents;
- } else {
+ else
encoder_pulsebar_analyze.Fraction = fraction;
- encoder_pulsebar_analyze.Text = contents.Substring(6);
- }
+ encoder_pulsebar_analyze.Text = contents;
}
} catch {
- //UtilEncoder.GetEncoderStatusTempFileName() is deleted at the end of the process
+ //UtilEncoder.GetEncoderStatusTempBaseFileName() 1,2,3,4,5 is deleted at the end of
the process
//this can make crash updatePulsebar sometimes
}
}
@@ -4872,7 +4893,13 @@ public partial class ChronoJumpWindow
}
treeview_encoder_capture_curves.Sensitive = true;
- Util.FileDelete(UtilEncoder.GetEncoderStatusTempFileName());
+
+ //delete the status filenames
+ Util.FileDelete(UtilEncoder.GetEncoderStatusTempBaseFileName() + "1.txt");
+ Util.FileDelete(UtilEncoder.GetEncoderStatusTempBaseFileName() + "2.txt");
+ Util.FileDelete(UtilEncoder.GetEncoderStatusTempBaseFileName() + "3.txt");
+ Util.FileDelete(UtilEncoder.GetEncoderStatusTempBaseFileName() + "4.txt");
+ Util.FileDelete(UtilEncoder.GetEncoderStatusTempBaseFileName() + "5.txt");
}
private void findAndMarkSavedCurves() {
diff --git a/src/utilEncoder.cs b/src/utilEncoder.cs
index 80b1f12..7d74f27 100644
--- a/src/utilEncoder.cs
+++ b/src/utilEncoder.cs
@@ -107,8 +107,9 @@ public class UtilEncoder
public static string GetEncoderGraphInputMulti() {
return Path.Combine(Path.GetTempPath(), Constants.EncoderGraphInputMulti);
}
- public static string GetEncoderStatusTempFileName() {
- return Path.Combine(Path.GetTempPath(), Constants.EncoderStatusTemp);
+ //this file will have a ...1.txt ...2.txt ... we check now the first part of the file
+ public static string GetEncoderStatusTempBaseFileName() {
+ return Path.Combine(Path.GetTempPath(), Constants.EncoderStatusTempBase);
}
public static string GetEncoderExportTempFileName() {
return Path.Combine(Path.GetTempPath(), Constants.EncoderExportTemp);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]