//Inertia Momentum //TODO: make this work with encoderRProc public static void RunEncoderCalculeIM(double weight, double distance, EncoderRProcAnalyze encoderRProcAnalyze) { encoderRProcAnalyze.CancelRScript = false; ProcessStartInfo pinfo; Process p; //If output file is not given, R will try to write in the running folder //in which we may haven't got permissions string pBin=""; pinfo = new ProcessStartInfo(); string inputData = GetEncoderDataTempFileName(); string outputData = GetEncoderSpecialDataTempFileName(); string scriptUtilR = GetEncoderScriptUtilR(); pBin="Rscript"; if (UtilAll.IsWindows()) { //on Windows we need the \"str\" to call without problems in path with spaces pBin = "\"" + System.IO.Path.Combine(Util.GetPrefixDir(), "bin" + Path.DirectorySeparatorChar + "Rscript.exe") + "\""; LogB.Information("pBin:", pBin); //On win32 R understands backlash as an escape character and //a file path uses Unix-like path separator '/' inputData = inputData.Replace("\\","/"); scriptUtilR = scriptUtilR.Replace("\\","/"); } //--- way A. passing options to a file string scriptOptions = inputData + "\n" + outputData + "\n" + Util.ConvertToPoint(weight) + "\n" + Util.ConvertToPoint(distance) + "\n" + scriptUtilR + "\n"; string optionsFile = Path.GetTempPath() + "Roptions.txt"; TextWriter writer = File.CreateText(optionsFile); writer.Write(scriptOptions); writer.Flush(); writer.Close(); ((IDisposable)writer).Dispose(); if (UtilAll.IsWindows()) { //On win32 R understands backlash as an escape character and //a file path uses Unix-like path separator '/' optionsFile = optionsFile.Replace("\\","/"); } //on Windows we need the \"str\" to call without problems in path with spaces pinfo.Arguments = "\"" + getEncoderScriptInertiaMomentum() + "\" " + optionsFile; LogB.Information("Arguments:", pinfo.Arguments); //Wait until this to update encoder gui (if don't wait then treeview will be outdated) string outputFileCheck = outputData; pinfo.FileName=pBin; pinfo.CreateNoWindow = true; pinfo.UseShellExecute = false; pinfo.RedirectStandardError = true; pinfo.RedirectStandardOutput = true; //delete output file check(s) LogB.Information("Deleting... ", outputFileCheck); if (File.Exists(outputFileCheck)) File.Delete(outputFileCheck); try { p = new Process(); p.StartInfo = pinfo; p.Start(); LogB.Information(p.StandardOutput.ReadToEnd()); LogB.Warning(p.StandardError.ReadToEnd()); p.WaitForExit(); while ( ! ( File.Exists(outputFileCheck) || encoderRProcAnalyze.CancelRScript) ); } catch { } }
//TODO:put zoom,unzoom (at side of delete curve) in capture curves (for every curve) // //TODO: capture also with webcam an attach it to signal or curve // //TODO: peak power in eccentric in absolute values // //TODO: on cross, spline and force speed and power speed should have a spar value higher, like 0.7. On the other hand, the other cross graphs, haveload(mass) in the X lot more discrete, there is good to put 0.5 private void encoderInitializeStuff() { encoder_pulsebar_capture.Fraction = 1; encoder_pulsebar_capture.Text = ""; encoder_pulsebar_analyze.Fraction = 1; encoder_pulsebar_analyze.Text = ""; //read from SQL encoderConfigurationCurrent = SqliteEncoder.LoadEncoderConfiguration(); encoderCaptureListStore = new Gtk.ListStore (typeof (EncoderCurve)); encSelReps = new EncoderSelectRepetitions(); //the glade cursor_changed does not work on mono 1.2.5 windows //treeview_encoder_capture_curves.CursorChanged += on_treeview_encoder_capture_curves_cursor_changed; //changed, now unselectable because there are the checkboxes createEncoderCombos(); encoderConfigurationGUIUpdate(); //on start it's concentric and powerbars. Eccon-together should be unsensitive check_encoder_analyze_eccon_together.Sensitive = false; //spin_encoder_capture_inertial.Value = Convert.ToDouble(Util.ChangeDecimalSeparator( // SqlitePreferences.Select("inertialmomentum"))); //initialize capture and analyze classes encoderRProcCapture = new EncoderRProcCapture(); encoderRProcAnalyze = new EncoderRProcAnalyze(); captureCurvesBarsData = new ArrayList(0); try { playVideoEncoderInitialSetup(); } catch { //it crashes on Raspberry, Banana } capturingCsharp = encoderCaptureProcess.STOPPED; //done here because in Glade we cannot use the TextBuffer.Changed textview_encoder_signal_comment.Buffer.Changed += new EventHandler(on_textview_encoder_signal_comment_key_press_event); configInit(); array1RM = new ArrayList(); }
//Inertia Momentum //TODO: make this work with encoderRProc public static void RunEncoderCalculeIM(double weight, double length, EncoderRProcAnalyze encoderRProcAnalyze) { encoderRProcAnalyze.CancelRScript = false; ProcessStartInfo pinfo; Process p; //If output file is not given, R will try to write in the running folder //in which we may haven't got permissions string pBin = ""; pinfo = new ProcessStartInfo(); string inputData = GetEncoderDataTempFileName(); string outputData = GetEncoderSpecialDataTempFileName(); string operatingSystem = "Linux"; string scriptUtilR = GetEncoderScriptUtilR(); pBin = "Rscript"; if (UtilAll.IsWindows()) { //on Windows we need the \"str\" to call without problems in path with spaces pBin = "\"" + System.IO.Path.Combine(Util.GetPrefixDir(), "bin" + Path.DirectorySeparatorChar + "Rscript.exe") + "\""; LogB.Information("pBin:", pBin); //On win32 R understands backlash as an escape character and //a file path uses Unix-like path separator '/' inputData = inputData.Replace("\\", "/"); scriptUtilR = scriptUtilR.Replace("\\", "/"); operatingSystem = "Windows"; } //--- way A. passing options to a file string scriptOptions = inputData + "\n" + outputData + "\n" + Util.ConvertToPoint(weight) + "\n" + Util.ConvertToPoint(length) + "\n" + scriptUtilR + "\n"; string optionsFile = Path.GetTempPath() + "Roptions.txt"; TextWriter writer = File.CreateText(optionsFile); writer.Write(scriptOptions); writer.Flush(); writer.Close(); ((IDisposable)writer).Dispose(); if (UtilAll.IsWindows()) { //On win32 R understands backlash as an escape character and //a file path uses Unix-like path separator '/' optionsFile = optionsFile.Replace("\\", "/"); } //on Windows we need the \"str\" to call without problems in path with spaces pinfo.Arguments = "\"" + getEncoderScriptInertiaMomentum() + "\" " + optionsFile; LogB.Information("Arguments:", pinfo.Arguments); //Wait until this to update encoder gui (if don't wait then treeview will be outdated) string outputFileCheck = outputData; pinfo.FileName = pBin; pinfo.CreateNoWindow = true; pinfo.UseShellExecute = false; pinfo.RedirectStandardError = true; pinfo.RedirectStandardOutput = true; //delete output file check(s) LogB.Information("Deleting... ", outputFileCheck); if (File.Exists(outputFileCheck)) { File.Delete(outputFileCheck); } try { p = new Process(); p.StartInfo = pinfo; p.Start(); LogB.Information(p.StandardOutput.ReadToEnd()); LogB.Warning(p.StandardError.ReadToEnd()); p.WaitForExit(); while (!(File.Exists(outputFileCheck) || encoderRProcAnalyze.CancelRScript)) { ; } } catch { } }