protected override void getData() { ArrayList dataPre = SqlitePersonSession.SelectCurrentSessionPersons(currentSession.UniqueID, false); //means: do not returnPersonAndPSlist data = new ArrayList(); nonSensitiveRows = new ArrayList(); int j = 0; //list of added persons foreach (Person p in dataPre) { ArrayList eSQLarray = SqliteEncoder.Select( false, -1, p.UniqueID, currentSession.UniqueID, encoderGI, exerciseID, "curve", EncoderSQL.Eccons.ALL, false, true); int activeCurves = UtilEncoder.GetActiveCurvesNum(eSQLarray); int allCurves = eSQLarray.Count; string [] s = { p.UniqueID.ToString(), "", p.Name, //activeCurves.ToString(), allCurves.ToString() }; data.Add(s); if (allCurves == 0) { nonSensitiveRows.Add(j); } j++; } }
private void writeOptionsFile(int graphWidth, int graphHeight) { string scriptsPath = UtilEncoder.GetSprintPath(); if (UtilAll.IsWindows()) { scriptsPath = scriptsPath.Replace("\\", "/"); } System.Globalization.NumberFormatInfo localeInfo = new System.Globalization.NumberFormatInfo(); localeInfo = System.Globalization.NumberFormatInfo.CurrentInfo; string scriptOptions = "#scriptsPath\n" + UtilEncoder.GetScriptsPath() + "\n" + "#filename\n" + UtilEncoder.GetRaceAnalyzerCSVFileName() + "\n" + "#mass\n" + Util.ConvertToPoint(mass) + "\n" + "#personHeight\n" + Util.ConvertToPoint(personHeight / 100.0) + "\n" + //send it in meters "#tempC\n" + tempC + "\n" + "#testLength\n" + testLength.ToString() + "\n" + "#os\n" + UtilEncoder.OperatingSystemForRGraphs() + "\n" + "#graphWidth\n" + graphWidth.ToString() + "\n" + "#graphHeight\n" + graphHeight.ToString(); TextWriter writer = File.CreateText(Path.GetTempPath() + "Roptions.txt"); writer.Write(scriptOptions); writer.Flush(); writer.Close(); ((IDisposable)writer).Dispose(); }
public static bool CallR(string script) { string executable = UtilEncoder.RProcessBinURL(); List <string> parameters = new List <string>(); //A) fix script name if (UtilAll.IsWindows()) { script = script.Replace("\\", "/"); } parameters.Insert(0, "\"" + script + "\""); //B) tempPath string tempPath = Path.GetTempPath(); if (UtilAll.IsWindows()) { tempPath = tempPath.Replace("\\", "/"); } parameters.Insert(1, "\"" + tempPath + "\""); LogB.Information("\nCalling R file ----->"); //C) call process //ExecuteProcess.run (executable, parameters); Result execute_result = run(executable, parameters, true, true); //LogB.Information("Result = " + execute_result.stdout); LogB.Information("\n<------ Done calling R file."); return(execute_result.success); }
private void writeOptionsFile(int graphWidth, int graphHeight) { string scriptsPath = UtilEncoder.GetSprintPath(); if (UtilAll.IsWindows()) { scriptsPath = scriptsPath.Replace("\\", "/"); } System.Globalization.NumberFormatInfo localeInfo = new System.Globalization.NumberFormatInfo(); localeInfo = System.Globalization.NumberFormatInfo.CurrentInfo; string scriptOptions = "#os\n" + UtilEncoder.OperatingSystemForRGraphs() + "\n" + "#decimalChar\n" + localeInfo.NumberDecimalSeparator + "\n" + "#graphWidth\n" + graphWidth.ToString() + "\n" + "#graphHeight\n" + graphHeight.ToString() + "\n" + "#averageLength\n" + Util.ConvertToPoint(averageLength) + "\n" + "#percentChange\n" + Util.ConvertToPoint(percentChange) + "\n" + "#vlineT0\n" + Util.BoolToRBool(vlineT0) + "\n" + "#vline50fmax.raw\n" + Util.BoolToRBool(vline50fmax_raw) + "\n" + "#vline50fmax.fitted\n" + Util.BoolToRBool(vline50fmax_fitted) + "\n" + "#hline50fmax.raw\n" + Util.BoolToRBool(hline50fmax_raw) + "\n" + "#hline50fmax.fitted\n" + Util.BoolToRBool(hline50fmax_fitted) + "\n" + "#RFDs"; foreach (ForceSensorRFD rfd in rfdList) { if (rfd.active) { scriptOptions += "\n" + rfd.ToR(); } else { scriptOptions += "\n-1"; } } if (impulse.active) { scriptOptions += "\n" + impulse.ToR(); } else { scriptOptions += "\n-1"; } scriptOptions += "\n#testLength\n" + testLength.ToString() + "\n" + "#title\n" + title + "\n" + "#scriptsPath\n" + UtilEncoder.GetScriptsPath() + "\n"; TextWriter writer = File.CreateText(Path.GetTempPath() + "Roptions.txt"); writer.Write(scriptOptions); writer.Flush(); writer.Close(); ((IDisposable)writer).Dispose(); }
void runEncoderAnalyzeOpenImage() { string imagePath = UtilEncoder.GetSprintEncoderImage(); image_race_encoder_graph = UtilGtk.OpenImageSafe( imagePath, image_race_encoder_graph); }
//copy export from temp file to the file that user has selected private void copyExportedFile() { //wait first this status mark that is created when file is fully exported while (!Util.FileExists(UtilEncoder.GetEncoderStatusTempBaseFileName() + "6.txt")) { ; } //copy the file File.Copy(es.OutputData1, ExportFileName, true); }
private void on_button_runs_sprint_save_image_selected(string destination) { try { File.Copy(UtilEncoder.GetSprintImage(), destination, true); } catch { string myString = string.Format( Catalog.GetString("Cannot save file {0} "), destination); new DialogMessage(Constants.MessageTypes.WARNING, myString); } }
private void initializeList(Constants.EncoderType type, bool inertial, bool rotaryFrictionOnAxis, int position) { check_rotary_friction_inertia_on_axis_is_visible(); list = UtilEncoder.EncoderConfigurationList(type, inertial, rotaryFrictionOnAxis); listCurrent = position; //current item on list buttons_previous_next_sensitive(); selectedModeChanged(); }
//TODO: do all this with an "other" thread like in force sensor to allow connecting messages to be displayed private bool runEncoderCapturePre() { if (!portREOpened) { if (!runEncoderConnect()) { return(false); } } if (File.Exists(UtilEncoder.GetSprintEncoderImage())) { Util.FileDelete(UtilEncoder.GetSprintEncoderImage()); } event_execute_label_message.Text = "Please, wait ..."; captureEndedMessage = ""; capturingRunEncoder = arduinoCaptureStatus.STARTING; button_execute_test.Sensitive = false; event_execute_button_finish.Sensitive = true; event_execute_button_cancel.Sensitive = true; //forceCaptureStartMark = false; runEncoderProcessFinish = false; runEncoderProcessCancel = false; runEncoderProcessError = false; //To know if USB has been disconnected usbDisconnectedCount = 0; usbDisconnectedLastTime = 0; /* * //initialize * forceSensorValues = new ForceSensorValues(); */ event_execute_ButtonFinish.Clicked -= new EventHandler(on_finish_clicked); event_execute_ButtonFinish.Clicked += new EventHandler(on_finish_clicked); event_execute_ButtonCancel.Clicked -= new EventHandler(on_cancel_clicked); event_execute_ButtonCancel.Clicked += new EventHandler(on_cancel_clicked); event_execute_label_message.Text = "Capturing ..."; runEncoderCaptureThread = new Thread(new ThreadStart(runEncoderCaptureDo)); GLib.Idle.Add(new GLib.IdleHandler(pulseGTKRunEncoderCapture)); LogB.ThreadStart(); runEncoderCaptureThread.Start(); return(true); }
private bool on_button_sprint_do() { button_sprint_save_image.Sensitive = false; if (currentPersonSession.Weight == 0) { new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Error, weight of the person cannot be 0")); return(false); } if (currentPersonSession.Height == 0) { new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Error, height of the person cannot be 0")); return(false); } if (!sprint.IsDataOk()) { new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("This data does not seem a sprint.") + "\n\n" + sprint.ErrorMessage); return(false); } Util.FileDelete(UtilEncoder.GetSprintImage()); image_sprint.Sensitive = false; bool success = sprint.CallR( viewport_sprint.Allocation.Width - 5, viewport_sprint.Allocation.Height - 5, currentPerson.Name); if (!success) { new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("This data does not seem a sprint.")); return(false); } while (!Util.FileReadable(UtilEncoder.GetSprintImage())) { ; } image_sprint = UtilGtk.OpenImageSafe( UtilEncoder.GetSprintImage(), image_sprint); image_sprint.Sensitive = true; button_sprint_save_image.Sensitive = true; return(true); }
protected override bool startProcess() { //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 = pBinURL(); pinfo = new ProcessStartInfo(); //on Windows we need the \"str\" to call without problems in path with spaces //pinfo.Arguments = "\"" + "passToR.R" + "\" " + optionsFile; pinfo.Arguments = "\"" + UtilEncoder.GetEncoderScriptCallCaptureNoRdotNet() + "\" " + optionsFile; LogB.Information("Arguments:", pinfo.Arguments); LogB.Information("--- 1 --- " + optionsFile.ToString() + " ---"); LogB.Information("--- 2 --- " + pinfo.Arguments.ToString() + " ---"); pinfo.FileName = pBin; pinfo.CreateNoWindow = true; pinfo.UseShellExecute = false; pinfo.RedirectStandardInput = true; pinfo.RedirectStandardError = true; //pinfo.RedirectStandardOutput = true; try { p = new Process(); p.StartInfo = pinfo; p.ErrorDataReceived += new DataReceivedEventHandler(readingError); p.Start(); // Start asynchronous read of the output. // Caution: This has to be called after Start //p.BeginOutputReadLine(); p.BeginErrorReadLine(); LogB.Debug("D"); LogB.Debug(string.Format("this pid id : {0}", p.Id)); } catch { Console.WriteLine("catched at runEncoderCaptureNoRDotNetStart"); return(false); } return(true); }
protected override void writeOptionsFile() { optionsFile = Path.GetTempPath() + "Roptions.txt"; string scriptOptions = UtilEncoder.PrepareEncoderGraphOptions( "none", //title es, false, //neuromuscularProfile false, //translate (graphs) Debug, false //crossValidate (unactive on capture at the moment) ).ToString(); TextWriter writer = File.CreateText(optionsFile); writer.Write(scriptOptions); writer.Flush(); writer.Close(); ((IDisposable)writer).Dispose(); }
protected override void writeOptionsFile() { optionsFile = Path.GetTempPath() + "Roptions.txt"; string scriptOptions = UtilEncoder.PrepareEncoderGraphOptions( title, es, neuromuscularProfileDo, translate, Debug, CrossValidate ).ToString(); TextWriter writer = File.CreateText(optionsFile); writer.Write(scriptOptions); writer.Flush(); writer.Close(); ((IDisposable)writer).Dispose(); }
protected override void writeOptionsFile() { optionsFile = Path.GetTempPath() + "Roptions.txt"; string scriptOptions = UtilEncoder.PrepareEncoderGraphOptions( "none", //title es, false, //neuromuscularProfile false, //translate (graphs) Debug, false, //crossValidate (unactive on capture at the moment) (CutByTriggers != Preferences.TriggerTypes.NO_TRIGGERS), printTriggers(), false, //separateSessionInDays (false at capture) EncoderGraphROptions.AnalysisModes.CAPTURE).ToString(); TextWriter writer = File.CreateText(optionsFile); writer.Write(scriptOptions); writer.Flush(); writer.Close(); ((IDisposable)writer).Dispose(); }
private void writeOptionsFile(int graphWidth, int graphHeight, string personName) { /* * string scriptOptions = * "#positions\n" + "0;20;40;70" + "\n" + * "#splitTimes\n" + "0;2.73;4.49;6.95" + "\n" + * "#mass\n" + "75" + "\n" + * "#personHeight\n" + "1.65" + "\n" + * "#tempC\n" + "25" + "\n"; */ string scriptsPath = UtilEncoder.GetSprintPath(); if (UtilAll.IsWindows()) { scriptsPath = scriptsPath.Replace("\\", "/"); } string scriptOptions = "#scriptsPath\n" + scriptsPath + "\n" + "#positions\n" + positions + "\n" + "#splitTimes\n" + splitTimes + "\n" + "#mass\n" + Util.ConvertToPoint(mass) + "\n" + "#personHeight\n" + Util.ConvertToPoint(personHeight / 100.0) + "\n" + //send it in meters "#tempC\n" + tempC + "\n" + "#os\n" + UtilEncoder.OperatingSystemForRGraphs() + "\n" + "#graphWidth\n" + graphWidth.ToString() + "\n" + "#graphHeight\n" + graphHeight.ToString() + "\n" + "#personName\n" + personName + "\n"; TextWriter writer = File.CreateText(Path.GetTempPath() + "Roptions.txt"); writer.Write(scriptOptions); writer.Flush(); writer.Close(); ((IDisposable)writer).Dispose(); }
public bool CallR(int graphWidth, int graphHeight) { LogB.Information("\nforceSensor CallR ----->"); writeOptionsFile(graphWidth, graphHeight); return(ExecuteProcess.CallR(UtilEncoder.GetmifScript())); }
public bool Capture(string outputData1, EncoderRProcCapture encoderRProcCapture, bool compujump, Preferences.TriggerTypes cutByTriggers, double restClustersSeconds, bool playSoundsFromFile) { /* * removed at 1.7.0 * if(simulated) { * bool success = initSimulated(); * if(! success) * return false; * } */ lastTriggerOn = 0; inertialCalibratedFirstCross0Pos = 0; //only for cutByTriggers == Preferences.TriggerTypes.START_AT_FIRST_ON bool firstTriggerHappened = false; //playSoundsFromFile DateTime lastTriggeredSound = DateTime.MinValue; if (capturingInertialBG) { /* * reset capture list. If not done here, list will grow at each set * also this fixes the initial 0s after a set */ EncoderCaptureInertialBackgroundStatic.Initialize(); } do { //1 read data try { byteReaded = readByte(); } catch { if (!simulated) { LogB.Error("Maybe encoder cable is disconnected"); cancel = true; } break; } //2 check if readed data is a trigger if (byteReaded == TRIGGER_ON) { if (playSoundsFromFile) { TimeSpan ts = DateTime.Now.Subtract(lastTriggeredSound); if (ts.TotalMilliseconds > 50) { Util.NextSongInList(); lastTriggeredSound = DateTime.Now; } continue; } Trigger trigger = new Trigger(Trigger.Modes.ENCODER, i, true); if (triggerList.IsSpurious(trigger)) { triggerList.RemoveLastOff(); continue; } //TriggerTypes.START_AT_FIRST_ON starts capture at first trigger. So when this happens, reset capture if (cutByTriggers == Preferences.TriggerTypes.START_AT_FIRST_ON && !firstTriggerHappened) { LogB.Information("Cleaning on capture"); startCaptureFromHere(); firstTriggerHappened = true; i = -1; //will be 0 on next loop start continue; } if (cutByTriggers != Preferences.TriggerTypes.NO_TRIGGERS) { ecc = new EncoderCaptureCurve(lastTriggerOn, i); lastTriggerOn = i; double [] curve = new double[ecc.endFrame - ecc.startFrame]; //int mySum = 0; for (int k = 0, j = ecc.startFrame; j < ecc.endFrame; j++) { curve[k] = encoderReaded[j]; k++; //mySum += encoderReaded[j]; } //ecc.up = (mySum >= 0); ecc.up = true; //make all concentric for the swimming application LogB.Debug("curve stuff" + ecc.startFrame + ":" + ecc.endFrame + ":" + encoderReaded.Count); bool success = encoderRProcCapture.SendCurve( ecc.startFrame, UtilEncoder.CompressData(curve, 25) //compressed ); if (!success) { cancel = true; } Ecca.curvesAccepted++; Ecca.ecc.Add(ecc); LogB.Information(ecc.ToString()); } triggerList.Add(trigger); continue; } else if (byteReaded == TRIGGER_OFF) { if (!playSoundsFromFile) { Trigger trigger = new Trigger(Trigger.Modes.ENCODER, i, false); triggerList.Add(trigger); } continue; } //3 if is not trigger: convertByte byteReaded = convertByte(byteReaded); //LogB.Information(" byte: " + byteReaded); i = i + 1; if (i >= 0) { if (cont) { recordedTimeCont++; } if (byteReaded == 0) { consecutiveZeros++; //clean variables when we are on cont and long time elapsed if (cont && Ecca.curvesAccepted == 0 && consecutiveZeros >= consecutiveZerosMax) { LogB.Information("Cleaning on capture"); //remove this time on existing trigger records triggerList.Substract(consecutiveZeros); startCaptureFromHere(); i = -1; //will be 0 on next loop start continue; } } else { consecutiveZeros = -1; } //stop if n seconds of inactivity //but it has to be moved a little bit first, just to give time to the people //if(consecutiveZeros >= consecutiveZerosMax && sum > 0) #Not OK because sum maybe is 0: +1,+1,-1,-1 //if(consecutiveZeros >= consecutiveZerosMax && ecca.ecc.Count > 0) #Not ok because when ecca is created, ecc.Count == 1 /* * process ends * ( * when a curve has been found and then there are n seconds of inactivity, or * when not in cont and a curve has not been found and then there are 2*n seconds of inactivity * ) and if consecutiveZeros > restClustersSeconds * 1.500 * * 1500 is conversion to milliseconds and * 1.5 to have enough time to move after clusters res */ if ( automaticallyEndByTime && ( (Ecca.curvesAccepted > 0 && consecutiveZeros >= consecutiveZerosMax) || (!cont && Ecca.curvesAccepted == 0 && consecutiveZeros >= (2 * consecutiveZerosMax)) ) && (restClustersSeconds == 0 || consecutiveZeros > restClustersSeconds * 1500) ) { finish = true; LogB.Information("SHOULD FINISH"); } //on inertialCalibrated set mark where 0 is crossed for the first time if (inertialCalibrated && inertialCalibratedFirstCross0Pos == 0) { if ((sumInertialDisc <= 0 && sumInertialDisc + byteReaded > 0) || (sumInertialDisc >= 0 && sumInertialDisc + byteReaded < 0)) { inertialCalibratedFirstCross0Pos = i; } } sumInertialDisc += byteReaded; encoderReadedInertialDisc.Add(byteReaded); if (inertialCalibrated && sumInertialDisc > 0) { byteReaded *= -1; } sum += byteReaded; encoderReaded.Add(byteReaded); if (!showOnlyBars) { assignEncoderCapturePoints(); EncoderCapturePointsCaptured = i; } if (!showOnlyBars) { encoderCapturePointsAdaptativeDisplay(); } // ---- prepare to send to R ---- //if string goes up or down, store the direction //direction is only up or down if (byteReaded != 0) { directionNow = (int)byteReaded / (int)Math.Abs(byteReaded); //1 (up) or -1 (down) } //if we don't have changed the direction, store the last non-zero that we can find if (directionChangeCount == 0 && directionNow == directionLastMSecond) { //check which is the last non-zero value //this is suitable to find where starts the only-zeros previous to the change if (byteReaded != 0) { lastNonZero = i; } } bool sendCurveMaybe = false; //if it's different than the last direction, mark the start of change if (directionNow != directionLastMSecond) { directionLastMSecond = directionNow; directionChangeCount = 0; } else if (directionNow != directionCompleted) { //we are in a different direction than the last completed //we cannot add byteReaded because then is difficult to come back n frames to know the max point //directionChangeCount += byteReaded directionChangeCount++; if (directionChangeCount > directionChangePeriod) //count >= than change_period { sendCurveMaybe = true; } } /* * on inertialCalibrated don't send curve until 0 is crossed * this ensures first stored phase will be ecc, that's what the rest of the program is expecting * TODO: maybe this can be problematic with triggers maybe can be desinchronized, just move values */ if (inertialCalibrated && inertialCalibratedFirstCross0Pos == 0) { sendCurveMaybe = false; } //if cutByTriggers, triggers send the curve at the beginning of this method if (cutByTriggers != Preferences.TriggerTypes.NO_TRIGGERS) { sendCurveMaybe = false; } if (sendCurveMaybe) { //int startFrame = previousFrameChange - directionChangeCount; //startFrame /* * at startFrame we do the "-directionChangePeriod" because * we want data a little bit earlier, because we want some zeros * that will be removed by reduceCurveBySpeed * if not done, then the data: * 0 0 0 0 0 0 0 0 0 1 * will start at 10th digit (the 1) * if done, then at speed will be like this: * 0 0 0 0.01 0.04 0.06 0.07 0.08 0.09 1 * and will start at fourth digit */ //this is better, takes a lot of time before, and then reduceCurveBySpeed will cut it //but reduceCurveBySpeed is not implemented on inertial //TODO: implement it int startFrame = previousEnd; //startFrame LogB.Debug("startFrame", startFrame.ToString()); if (startFrame < 0) { startFrame = 0; } //on inertial start when crossing 0 first time if (inertialCalibrated && startFrame < inertialCalibratedFirstCross0Pos) { startFrame = inertialCalibratedFirstCross0Pos; } LogB.Information("TTTT - i," + i.ToString() + "; directionChangeCount: " + directionChangeCount.ToString() + "; lastNonZero: " + lastNonZero.ToString() + "; final: " + ((i - directionChangeCount + lastNonZero) / 2).ToString()); ecc = new EncoderCaptureCurve( startFrame, (i - directionChangeCount + lastNonZero) / 2 //endFrame //to find endFrame, first substract directionChangePeriod from i //then find the middle point between that and lastNonZero //this means that the end is in central point at displacements == 0 ); //since 1.5.0 secundary thread is capturing and sending data to R process //while main thread is reading data coming from R and updating GUI LogB.Debug("curve stuff" + ecc.startFrame + ":" + ecc.endFrame + ":" + encoderReaded.Count); if (ecc.endFrame - ecc.startFrame > 0) { double [] curve = new double[ecc.endFrame - ecc.startFrame]; int mySum = 0; for (int k = 0, j = ecc.startFrame; j < ecc.endFrame; j++) { curve[k] = encoderReaded[j]; k++; mySum += encoderReaded[j]; } ecc.up = (mySum >= 0); previousEnd = ecc.endFrame; //22-may-2015: This is done in R now //1) check heightCurve in a fast way first to discard curves soon // only process curves with height >= min_height //2) if it's concentric, only take the concentric curves, // but if it's concentric and inertial: take both. // // When capturing on inertial, we have the first graph // that will be converted to the second. // we need the eccentric phase in order to detect the Ci2 /* * /\ * / \ * / \ *____ C1 \ ___ * \ / \ / * \ / \ C2 * \/ \/ * * C1, C2: two concentric phases */ /* *____ ___ * \ /\ /\ / * \ Ci1 \ Ci2 \ Ci3 * \/ \ / \/ * \/ * * Ci1, Ci2, Ci3: three concentric phases on inertial * * Since 1.6.1: * on inertial curve is sent when rope is fully extended, * this will allow to see at the moment c or e. Not wait the change of direction to see both */ //store in a boolean to not call shouldSendCurve() two times because it changes some variables bool shouldSendCurveBool = shouldSendCurve(); if (shouldSendCurveBool) { //if compujump, wakeup screen if it's off //do it on the first repetition because it will not be sleeping on the rest of repetitions if (compujump && Ecca.curvesAccepted == 0) { Networks.WakeUpRaspberryIfNeeded(); } bool success = encoderRProcCapture.SendCurve( ecc.startFrame, UtilEncoder.CompressData(curve, 25) //compressed ); if (!success) { cancel = true; } Ecca.curvesAccepted++; Ecca.ecc.Add(ecc); LogB.Information(ecc.ToString()); lastDirectionStoredIsUp = ecc.up; } } //on inertial is different markDirectionChanged(); } //this is for visual feedback of remaining time msCount++; if (msCount >= 1000) { Countdown--; msCount = 1; } } } while ((cont || i < (recordingTime - 1)) && !cancel && !finish); LogB.Debug("runEncoderCaptureCsharp main bucle end"); //leave some time to capture.R be able to paint data, and to create two Roptions.txt file correctly if (simulated) { System.Threading.Thread.Sleep(2000); } else if (!capturingInertialBG) { sp.Close(); } if (cancel) { return(false); } saveToFile(outputData1); LogB.Debug("runEncoderCaptureCsharp ended"); return(true); }
//non GTK on this method private void runEncoderCaptureDo() { LogB.Information("runEncoderCaptureDo 0"); lastChangedTime = 0; if (!runEncoderSendCommand("start_capture:", "", "Catched run encoder capturing")) { runEncoderProcessError = true; return; } string str = ""; LogB.Information("runEncoderCaptureDo 1"); do { Thread.Sleep(100); //sleep to let arduino start reading try { str = portRE.ReadLine(); } catch { runEncoderProcessError = true; return; } LogB.Information("init string: " + str); }while(!str.Contains("Starting capture")); //forceCaptureStartMark = true; capturingRunEncoder = arduinoCaptureStatus.CAPTURING; Util.CreateRaceAnalyzerSessionDirIfNeeded(currentSession.UniqueID); string nameDate = currentPerson.Name + "_" + UtilDate.ToFile(DateTime.Now); //fileName to save the csv string fileName = Util.GetRaceAnalyzerSessionDir(currentSession.UniqueID) + Path.DirectorySeparatorChar + nameDate + ".csv"; //lastRunEncoderFile to save the images lastRunEncoderFile = nameDate; TextWriter writer = File.CreateText(fileName); writer.WriteLine("Pulses;Time(useconds);Force(N)"); str = ""; int firstTime = 0; while (!runEncoderProcessFinish && !runEncoderProcessCancel && !runEncoderProcessError) { //LogB.Information(string.Format("finish conditions: {0}-{1}-{2}", // runEncoderProcessFinish, runEncoderProcessCancel, runEncoderProcessError)); /* * The difference between forceSensor and runEncoder is: * runEncoder is not always returning data * if user press "finish" button, and they don't move the encoder, * this will never end: * //str = portRE.ReadLine(); * so use the following method that allows to return a "" when there no data * and then the while above will end with the runEncoderProcessFinish condition */ str = readFromRunEncoderIfDataArrived(); //LogB.Information("str: " + str); //TODO: remove this log if (str == "") { continue; } //check if there is one and only one ';' //if( ! (str.Contains(";") && str.IndexOf(";") == str.LastIndexOf(";")) ) string [] strFull = str.Split(new char[] { ';' }); LogB.Information("captured str: " + str); if (strFull.Length != 3) { continue; } LogB.Information("pulses: " + strFull[0]); if (!Util.IsNumber(strFull[0], false)) { continue; } LogB.Information("time microseconds: " + strFull[1]); if (!Util.IsNumber(strFull[1], false)) { continue; } LogB.Information("force avg (N): " + strFull[1]); if (!Util.IsNumber(strFull[2], false)) { continue; } /* * int time = Convert.ToInt32(strFull[0]); * * //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])); */ int pulse = Convert.ToInt32(strFull[0]); int time = Convert.ToInt32(strFull[1]); int force = Convert.ToInt32(strFull[2]); writer.WriteLine(pulse.ToString() + ";" + time.ToString() + ";" + force.ToString()); } LogB.Information(string.Format("FINISHED WITH conditions: {0}-{1}-{2}", runEncoderProcessFinish, runEncoderProcessCancel, runEncoderProcessError)); LogB.Information("Calling end_capture"); if (!runEncoderSendCommand("end_capture:", "Ending capture ...", "Catched ending capture")) { runEncoderProcessError = true; capturingRunEncoder = arduinoCaptureStatus.STOP; Util.FileDelete(fileName); return; } LogB.Information("Waiting end_capture"); do { Thread.Sleep(10); try { str = portRE.ReadLine(); } catch { LogB.Information("Catched waiting end_capture feedback"); } LogB.Information("waiting \"Capture ended\" string: " + str); }while(!str.Contains("Capture ended")); LogB.Information("Success: received end_capture"); writer.Flush(); writer.Close(); ((IDisposable)writer).Dispose(); capturingRunEncoder = arduinoCaptureStatus.STOP; //port.Close(); if (runEncoderProcessCancel || runEncoderProcessError) { Util.FileDelete(fileName); } else { //call graph. Prepare data File.Copy(fileName, UtilEncoder.GetRaceAnalyzerCSVFileName(), true); //can be overwritten lastRunEncoderFullPath = fileName; race_analyzer_distance = Convert.ToInt32(race_analyzer_spinbutton_distance.Value); race_analyzer_temperature = Convert.ToInt32(race_analyzer_spinbutton_temperature.Value); //create graph RunEncoderGraph reg = new RunEncoderGraph( race_analyzer_distance, currentPersonSession.Weight, //TODO: can be more if extra weight currentPersonSession.Height, race_analyzer_temperature); reg.CallR(1699, 768); //TODO: hardcoded DateTime runEncoderGraphStarted = DateTime.Now; //TODO: check better if png is saved and have a cancel button while (!File.Exists(UtilEncoder.GetSprintEncoderImage()) && DateTime.Now.Subtract(runEncoderGraphStarted).TotalSeconds < 5) { Thread.Sleep(500); } captureEndedMessage = "Data on raceAnalyzer folder"; if (File.Exists(UtilEncoder.GetSprintEncoderImage())) { LogB.Information("File exists on png, trying to copy"); try { File.Copy(UtilEncoder.GetSprintEncoderImage(), Util.GetRaceAnalyzerSessionDir(currentSession.UniqueID) + Path.DirectorySeparatorChar + lastRunEncoderFile + //nameDate ".png", true); //can be overwritten captureEndedMessage += " (png too)"; } catch { LogB.Information("Couldn't copy the file"); captureEndedMessage += " (Created png but only on tmp folder, could not copy file)"; } } else { LogB.Information("File does not exist on png (after 5 seconds)"); captureEndedMessage += " (png not created, problem doing the graph)"; } capturingRunEncoder = arduinoCaptureStatus.COPIED_TO_TMP; } }
protected void sqliteThings() { configChronojump = new Config(); configChronojump.Read(); bool badExit = checkIfChronojumpExitAbnormally(); if (badExit) { if (chronojumpIsExecutingNTimes()) { messageToShowOnBoot += Catalog.GetString("Chronojump is already running") + "\n\n" + Catalog.GetString("Chronojump will exit now."); chronojumpHasToExit = true; quitNowCjTwoTimes = true; LogB.Error("Chronojump is already running."); return; } else { chronojumpCrashedBefore(); } } //print version of chronojump progVersion = BuildInfo.chronojumpVersion; LogB.Information("Chronojump version: {0}", progVersion); //to store user videos and photos Util.CreateMultimediaDirsIfNeeded(); //to store (encoder, force sensor, run encoder) data and graphs UtilEncoder.CreateEncoderDirIfNeeded(); Util.CreateForceSensorDirIfNeeded(); Util.CreateRaceAnalyzerDirIfNeeded(); //TODO: when a session is deleted, encoder data has to be deleted, also multimedia videos, I suppose. Show message to user warning about it //TODO: encoder weight auto written depending on person loaded, and changes if it changes person or weight //move database to new location if chronojump version is before 0.7 moveDatabaseToNewLocationIfNeeded(); LogB.Information("move? ended"); splashMessageChange(1); //checking database /* * splashMessage = "pre-connect"; * needUpdateSplashMessage = true; * Console.ReadLine(); */ Sqlite.CreateDir(); bool defaultDBLocation = Sqlite.Connect(); LogB.SQL("sqlite connected"); /* * splashMessage = "post-connect" + defaultDBLocation.ToString(); * needUpdateSplashMessage = true; * Console.ReadLine(); */ //Chech if the DB file exists if (!Sqlite.CheckTables(defaultDBLocation)) { LogB.SQL(Catalog.GetString("no tables, creating ...")); creatingDB = true; splashMessageChange(2); //creating database /* * splashMessage = "pre-create"; * needUpdateSplashMessage = true; * Console.ReadLine(); */ Sqlite.CreateDir(); Sqlite.CreateFile(); //Sqlite.CreateFile(defaultDBLocation); /* * splashMessage = "post-create"; * needUpdateSplashMessage = true; * Console.ReadLine(); */ createRunningFileName(runningFileName); Sqlite.CreateTables(false); //not server creatingDB = false; } else { LogB.SQL("doing backup"); //backup the database Util.BackupDirCreateIfNeeded(); splashMessageChange(3); //making db backup Util.BackupDatabase(); LogB.SQL("made a database backup"); //not compressed yet, it seems System.IO.Compression.DeflateStream and //System.IO.Compression.GZipStream are not in mono if (!Sqlite.IsSqlite3()) { bool ok = Sqlite.ConvertFromSqlite2To3(); if (!ok) { LogB.Error("problem with sqlite"); //check (spanish) //http://mail.gnome.org/archives/chronojump-devel-list/2008-March/msg00011.html string errorMessage = Catalog.GetString("Failed database conversion, ensure you have libsqlite3-0 installed. \nIf problems persist ask in chronojump-list"); errorMessage += "\n\n" + string.Format(Catalog.GetString("If you have no data on your database (you just installed Chronojump), you can fix this problem deleting this file: {0}"), Util.GetDatabaseDir() + Path.DirectorySeparatorChar + "chronojump.db") + "\n" + Catalog.GetString("And starting Chronojump again."); LogB.Error(errorMessage); messageToShowOnBoot += errorMessage; chronojumpHasToExit = true; return; } Sqlite.Connect(); } splashMessageChange(4); //updating DB updatingDB = true; if (Sqlite.ChangeDjToDJna()) { messageToShowOnBoot += Catalog.GetString("All DJ jumps have been renamed as 'DJna' (Drop Jumps with No Arms).") + "\n\n" + Catalog.GetString("If your Drop Jumps were executed using the arms, please rename them manually as 'DJa'.") + "\n"; } bool softwareIsNew = Sqlite.ConvertToLastChronojumpDBVersion(); updatingDB = false; if (!softwareIsNew) { //Console.Clear(); string errorMessage = string.Format(Catalog.GetString("Sorry, this Chronojump version ({0}) is too old for your database."), progVersion) + "\n" + Catalog.GetString("Please update Chronojump") + ":\n"; errorMessage += "http://chronojump.org"; //errorMessage += "\n\n" + Catalog.GetString("Press any key"); LogB.Error(errorMessage); messageToShowOnBoot += errorMessage; chronojumpHasToExit = true; } LogB.Information(Catalog.GetString("tables already created")); //check for bad Rjs (activate if program crashes and you use it in the same db before v.0.41) //SqliteJump.FindBadRjs(); createRunningFileName(runningFileName); } //splashMessageChange(5); //check for new version splashMessageChange(5); //connecting to server messageToShowOnBoot += recuperateBrokenEvents(); //connect to server to Ping versionAvailable = ""; versionAvailable = Constants.ServerOffline; //doing ping using json methods /* * temporarily disabled on start * string machineID = SqlitePreferences.Select("machineID", false); * Json js = new Json(); * bool success = js.Ping(UtilAll.GetOS(), progVersion, machineID); * if(success) * LogB.Information(js.ResultMessage); * else * LogB.Error(js.ResultMessage); */ allSQLCallsDoneOnSqliteThingsThread = false; //wait until pinging ends (or it's cancelled) //while(! pingEnd) { //} Sqlite.Open(); //TODO: fix this to the new code string versionAvailableKnown = SqlitePreferences.Select("versionAvailable", true); if (versionAvailable != Constants.ServerOffline && new Version(versionAvailable) > new Version(progVersion)) { //check if available version is higher than known available version Version versionAvailableAsV = new Version(versionAvailable); Version versionAvailableKnownAsV; bool updateKnownVersion = false; if (versionAvailableKnown == "") { updateKnownVersion = true; } else { versionAvailableKnownAsV = new Version(versionAvailableKnown); if (versionAvailableAsV > versionAvailableKnownAsV) { updateKnownVersion = true; } } if (updateKnownVersion) { //is the first time we know about this new version //just write on db and show message to user SqlitePreferences.Update(Constants.PrefVersionAvailable, versionAvailable, true); versionAvailableKnown = versionAvailable; messageToShowOnBoot += string.Format(Catalog.GetString( "\nNew Chronojump version available on website.\nYour Chronojump version is: {1}"), versionAvailable, progVersion) + "\n\n" + Catalog.GetString("Please, update to new version.") + "\n"; } } //if chronojump chrashed before if (badExit) { if (versionAvailableKnown.Length > 0 && new Version(versionAvailableKnown) > new Version(progVersion)) { messageToShowOnBoot += "\n" + Catalog.GetString("Chronojump crashed before.") + "\n" + Catalog.GetString("Please, update to new version: ") + versionAvailableKnown + "\n"; } else { messageToShowOnBoot += messageCrashedBefore; //SqlitePreferences.Update("videoOn", "False", true); } } splashMessageChange(6); //preparing main window //start as "simulated" SqlitePreferences.Update("simulated", "True", true); //dbcon opened Sqlite.Close(); // Chronojump sqlite is in an initialized state, let's keep the Sqlite state here // to be re-used Sqlite.saveClassState(); allSQLCallsDoneOnSqliteThingsThread = true; LogB.SQL("all SQL calls done on sqliteThings thread"); UtilAll.IsWindows(); //only as additional info here //Application.Init(); needEndSplashWin = true; }
public bool Capture(string outputData1, EncoderRProcCapture encoderRProcCapture) { if (simulated) { bool success = initSimulated(); if (!success) { return(false); } } do { try { byteReaded = readByte(); } catch { if (!simulated) { LogB.Error("Maybe encoder cable is disconnected"); cancel = true; } break; } byteReaded = convertByte(byteReaded); i = i + 1; if (i >= 0) { if (cont) { recordedTimeCont++; } if (inertialCaptureDirectionInverted) { byteReaded *= -1; } if (byteReaded == 0) { consecutiveZeros++; } else { consecutiveZeros = -1; } //stop if n seconds of inactivity //but it has to be moved a little bit first, just to give time to the people //if(consecutiveZeros >= consecutiveZerosMax && sum > 0) #Not OK because sum maybe is 0: +1,+1,-1,-1 //if(consecutiveZeros >= consecutiveZerosMax && ecca.ecc.Count > 0) #Not ok because when ecca is created, ecc.Count == 1 // //process ends //when a curve has been found and then there are n seconds of inactivity, or //when a curve has not been found and then there are 2*n seconds of inactivity if ( (Ecca.curvesAccepted > 0 && consecutiveZeros >= consecutiveZerosMax) || (!cont && Ecca.curvesAccepted == 0 && consecutiveZeros >= (2 * consecutiveZerosMax))) { finish = true; LogB.Information("SHOULD FINISH"); } sumInertialDisc += byteReaded; encoderReadedInertialDisc.Add(byteReaded); if (inertialChangedConToEcc()) { byteReaded *= -1; } sum += byteReaded; encoderReaded.Add(byteReaded); assignEncoderCapturePoints(); EncoderCapturePointsCaptured = i; //this only applies to inertial subclass if (inertialShouldCheckStartDirection) { inertialCheckIfInverted(); } encoderCapturePointsAdaptativeDisplay(); // ---- prepare to send to R ---- //if string goes up or down, store the direction //direction is only up or down if (byteReaded != 0) { directionNow = (int)byteReaded / (int)Math.Abs(byteReaded); //1 (up) or -1 (down) } //if we don't have changed the direction, store the last non-zero that we can find if (directionChangeCount == 0 && directionNow == directionLastMSecond) { //check which is the last non-zero value //this is suitable to find where starts the only-zeros previous to the change if (byteReaded != 0) { lastNonZero = i; } } bool sendCurveMaybe = false; //if it's different than the last direction, mark the start of change if (directionNow != directionLastMSecond) { directionLastMSecond = directionNow; directionChangeCount = 0; } else if (directionNow != directionCompleted) { //we are in a different direction than the last completed //we cannot add byteReaded because then is difficult to come back n frames to know the max point //directionChangeCount += byteReaded directionChangeCount++; if (directionChangeCount > directionChangePeriod) //count >= than change_period { sendCurveMaybe = true; } } if (sendCurveMaybe) { //int startFrame = previousFrameChange - directionChangeCount; //startFrame /* * at startFrame we do the "-directionChangePeriod" because * we want data a little bit earlier, because we want some zeros * that will be removed by reduceCurveBySpeed * if not done, then the data: * 0 0 0 0 0 0 0 0 0 1 * will start at 10th digit (the 1) * if done, then at speed will be like this: * 0 0 0 0.01 0.04 0.06 0.07 0.08 0.09 1 * and will start at fourth digit */ //this is better, takes a lot of time before, and then reduceCurveBySpeed will cut it //but reduceCurveBySpeed is not implemented on inertial //TODO: implement it int startFrame = previousEnd; //startFrame LogB.Debug("startFrame", startFrame.ToString()); if (startFrame < 0) { startFrame = 0; } LogB.Information("TTTT - i," + i.ToString() + "; directionChangeCount: " + directionChangeCount.ToString() + "; lastNonZero: " + lastNonZero.ToString() + "; final: " + ((i - directionChangeCount + lastNonZero) / 2).ToString()); ecc = new EncoderCaptureCurve( startFrame, (i - directionChangeCount + lastNonZero) / 2 //endFrame //to find endFrame, first substract directionChangePeriod from i //then find the middle point between that and lastNonZero //this means that the end is in central point at displacements == 0 ); //since 1.5.0 secundary thread is capturing and sending data to R process //while main thread is reading data coming from R and updating GUI LogB.Debug("curve stuff" + ecc.startFrame + ":" + ecc.endFrame + ":" + encoderReaded.Count); if (ecc.endFrame - ecc.startFrame > 0) { double [] curve = new double[ecc.endFrame - ecc.startFrame]; int mySum = 0; for (int k = 0, j = ecc.startFrame; j < ecc.endFrame; j++) { curve[k] = encoderReaded[j]; k++; mySum += encoderReaded[j]; } ecc.up = (mySum >= 0); previousEnd = ecc.endFrame; //22-may-2015: This is done in R now //1) check heightCurve in a fast way first to discard curves soon // only process curves with height >= min_height //2) if it's concentric, only take the concentric curves, // but if it's concentric and inertial: take both. // // When capturing on inertial, we have the first graph // that will be converted to the second. // we need the eccentric phase in order to detect the Ci2 /* * /\ * / \ * / \ *____ C1 \ ___ * \ / \ / * \ / \ C2 * \/ \/ * * C1, C2: two concentric phases */ /* *____ ___ * \ /\ /\ / * \ Ci1 \ Ci2 \ Ci3 * \/ \ / \/ * \/ * * Ci1, Ci2, Ci3: three concentric phases on inertial * * Since 1.6.1: * on inertial curve is sent when rope is fully extended, * this will allow to see at the moment c or e. Not wait the change of direction to see both */ if (shouldSendCurve()) { encoderRProcCapture.SendCurve( UtilEncoder.CompressData(curve, 25) //compressed ); Ecca.curvesAccepted++; Ecca.ecc.Add(ecc); lastDirectionStoredIsUp = ecc.up; } } //on inertial is different markDirectionChanged(); } //this is for visual feedback of remaining time msCount++; if (msCount >= 1000) { Countdown--; msCount = 1; } } } while ((cont || i < (recordingTime - 1)) && !cancel && !finish); LogB.Debug("runEncoderCaptureCsharp main bucle end"); //leave some time to capture.R be able to paint data, and to create two Roptions.txt file correctly if (simulated) { System.Threading.Thread.Sleep(2000); } else { sp.Close(); } if (cancel) { return(false); } saveToFile(outputData1); LogB.Debug("runEncoderCaptureCsharp ended"); return(true); }
public bool CallR(int graphWidth, int graphHeight) { LogB.Information("\nrunEncoder CallR ----->"); writeOptionsFile(graphWidth, graphHeight); return(ExecuteProcess.CallR(UtilEncoder.GetRaceAnalyzerScript())); }
/* * public Sprint(List<double> positions, List<double> splitTimes, * double mass, double personHeight, double tempC) * { * this.positions = positions; * this.splitTimes = splitTimes; * this.mass = mass; * this.personHeight = personHeight; * this.tempC = tempC; * } */ public bool CallR(int graphWidth, int graphHeight, string personName) { LogB.Information("\nsprint CallR ----->"); writeOptionsFile(graphWidth, graphHeight, personName); return(ExecuteProcess.CallR(UtilEncoder.GetSprintPhotocellsScript())); }
protected override bool continueProcess() { CurvesReaded = 0; //TODO: outputFileCheck creation/deletion here and at startProcess, should be unique string outputFileCheck = ""; string outputFileCheck2 = ""; if (es.Ep.Analysis == "exportCSV") { outputFileCheck = es.OutputData1; } else { //outputFileCheck = es.OutputGraph; // //OutputData1 because since Chronojump 1.3.6, //encoder analyze has a treeview that can show the curves //when a graph analysis is done, curves file has to be written outputFileCheck = es.OutputData1; //check also the otuput graph outputFileCheck2 = es.OutputGraph; } //delete output file check(s) deleteFile(outputFileCheck); if (outputFileCheck2 != "") { deleteFile(outputFileCheck2); } //delete status-6 mark used on export csv if (es.Ep.Analysis == "exportCSV") { Util.FileDelete(UtilEncoder.GetEncoderStatusTempBaseFileName() + "6.txt"); } //delete SpecialData if exists string specialData = UtilEncoder.GetEncoderSpecialDataTempFileName(); if (File.Exists(specialData)) { File.Delete(specialData); } LogB.Debug("sending continue process"); //try/catch because sometimes the stdin write gots broken try { p.StandardInput.WriteLine("C"); } catch { LogB.Debug("calling start because continue process was problematic"); return(startProcess()); } LogB.Debug("waiting files"); if (outputFileCheck2 == "") { while (!(Util.FileReadable(outputFileCheck) || CancelRScript)) { ; } } else { while (!((Util.FileReadable(outputFileCheck) && Util.FileReadable(outputFileCheck2)) || CancelRScript)) { ; } } //copy export from temp file to the file that user has selected if (es.Ep.Analysis == "exportCSV" && !CancelRScript) { copyExportedFile(); } LogB.Debug("files written"); return(true); }
protected override bool startProcess() { CurvesReaded = 0; //If output file is not given, R will try to write in the running folder //in which we may haven't got permissions pinfo = new ProcessStartInfo(); string pBin = pBinURL(); 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 = "\"" + getEncoderScriptCallGraph() + "\" " + optionsFile; LogB.Information("Arguments:", pinfo.Arguments); LogB.Information("--- 1 --- " + optionsFile.ToString() + " ---"); //LogB.Information("--- 2 --- " + scriptOptions + " ---"); LogB.Information("--- 3 --- " + pinfo.Arguments.ToString() + " ---"); string outputFileCheck = ""; string outputFileCheck2 = ""; //Wait until this to update encoder gui (if don't wait then treeview will be outdated) //exportCSV is the only one that doesn't have graph. all the rest Analysis have graph and data if (es.Ep.Analysis == "exportCSV") { outputFileCheck = es.OutputData1; } else { //outputFileCheck = es.OutputGraph; // //OutputData1 because since Chronojump 1.3.6, //encoder analyze has a treeview that can show the curves //when a graph analysis is done, curves file has to be written outputFileCheck = es.OutputData1; //check also the otuput graph outputFileCheck2 = es.OutputGraph; } LogB.Information("outputFileChecks"); LogB.Information(outputFileCheck); LogB.Information(outputFileCheck2); pinfo.FileName = pBin; pinfo.CreateNoWindow = true; pinfo.UseShellExecute = false; pinfo.RedirectStandardInput = true; pinfo.RedirectStandardError = true; /* * if redirect this there are problems because the buffers get saturated * pinfo.RedirectStandardOutput = true; * if is not redirected, then prints are shown by console (but not in logB * best solution is make the prints as write("message", stderr()) * and then will be shown in logB by readError */ //delete output file check(s) deleteFile(outputFileCheck); if (outputFileCheck2 != "") { deleteFile(outputFileCheck2); } //delete status-6 mark used on export csv if (es.Ep.Analysis == "exportCSV") { Util.FileDelete(UtilEncoder.GetEncoderStatusTempBaseFileName() + "6.txt"); } //delete SpecialData if exists string specialData = UtilEncoder.GetEncoderSpecialDataTempFileName(); if (File.Exists(specialData)) { File.Delete(specialData); } try { p = new Process(); p.StartInfo = pinfo; //do not redirect ouptut. Read above //p.OutputDataReceived += new DataReceivedEventHandler(readingOutput); p.ErrorDataReceived += new DataReceivedEventHandler(readingError); p.Start(); //don't do this ReadToEnd because then this method never ends //LogB.Information(p.StandardOutput.ReadToEnd()); //LogB.Warning(p.StandardError.ReadToEnd()); // Start asynchronous read of the output. // Caution: This has to be called after Start //p.BeginOutputReadLine(); p.BeginErrorReadLine(); if (outputFileCheck2 == "") { while (!(Util.FileReadable(outputFileCheck) || CancelRScript)) { ; } } else { while (!((Util.FileReadable(outputFileCheck) && Util.FileReadable(outputFileCheck2)) || CancelRScript)) { ; } } //copy export from temp file to the file that user has selected if (es.Ep.Analysis == "exportCSV" && !CancelRScript) { copyExportedFile(); } } catch { LogB.Warning("catched at startProcess"); return(false); } return(true); }
/* * Use this to retrieve values after accept * do not use to know current encoder configuration * because that is stored in gui/encoder as * encoderConfigurationCurrent */ public EncoderConfiguration GetAcceptedValues() { EncoderConfiguration ec = (EncoderConfiguration)list[listCurrent]; ec.d = -1; ec.list_d = new List_d(); ec.D = -1; ec.anglePush = -1; ec.angleWeight = -1; ec.inertiaMachine = -1; ec.gearedDown = 1; ec.inertiaTotal = -1; ec.extraWeightN = 0; ec.extraWeightGrams = 0; ec.extraWeightLength = 1; if (ec.has_d) { if (ec.has_inertia) { ec.list_d = get_list_d(); bool found = false; if (Util.IsNumber(main_gui_anchorage_str, true)) { LogB.Information("main_gui_anchorage = " + main_gui_anchorage_str); double guiAnchorage = Convert.ToDouble(main_gui_anchorage_str); foreach (double d in ec.list_d.L) { LogB.Information("d = " + d.ToString()); if (d == guiAnchorage) { ec.d = guiAnchorage; found = true; break; } } } if (!found) { ec.d = ec.list_d.L[0]; } } else { ec.d = (double)spin_d.Value; } } if (ec.has_D) { ec.D = (double)spin_D.Value; } if (ec.has_angle_push) { ec.anglePush = (int)spin_angle_push.Value; } if (ec.has_angle_weight) { ec.angleWeight = (int)spin_angle_weight.Value; } if (ec.has_inertia) { ec.inertiaMachine = (int)spin_inertia_machine.Value; ec.extraWeightN = main_gui_extraWeightN; ec.extraWeightGrams = (int)spin_inertia_mass.Value; ec.extraWeightLength = (double)spin_inertia_length.Value; ec.inertiaTotal = UtilEncoder.CalculeInertiaTotal(ec); } if (ec.has_gearedDown) { ec.SetGearedDownFromDisplay(UtilGtk.ComboGetActive(combo_gearedUp)); } return(ec); }