GetEncoderStatusTempBaseFileName() public static method

public static GetEncoderStatusTempBaseFileName ( ) : string
return string
示例#1
0
 //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);
 }
示例#2
0
    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);
    }
示例#3
0
    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);
    }