Example #1
0
        public static OpenResultsOut St7OpenResults(string fileName, string fileDir, bool getCaseNames = true, bool generateCombinations = false, bool generateEnvelopes = false, bool active = false)
        {
            if (!active)
            {
                return(new OpenResultsOut(false, null, null));
            }
            List <string> caseNames        = new List <string>();
            List <int>    caseIds          = new List <int>();
            int           err              = St7.St7CloseResultFile(1);
            int           primaryCases     = 0;
            int           secondaryCases   = 0;
            int           warningCode      = 0;
            string        spectralFileName = string.Empty;
            int           combinations     = generateCombinations ? St7.kGenerateNewCombinations : St7.kNoCombinations;

            fileDir = fileDir.EndsWith(Path.DirectorySeparatorChar.ToString()) ? fileDir : fileDir + Path.DirectorySeparatorChar;
            err     = St7.St7OpenResultFile(1, string.Concat(fileDir, fileName), spectralFileName, combinations, ref primaryCases, ref secondaryCases);
            if (!St7ErrorCustom(err, "Could not open results file"))
            {
                return(new OpenResultsOut(false, null, null));
            }
            if (generateCombinations)
            {
                err = St7.St7GenerateLSACombinations(1, ref secondaryCases, ref warningCode);
            }
            if (!St7ErrorCustom(err, "Could not generate combinations"))
            {
                return(new OpenResultsOut(false, null, null));
            }
            int numLimitEnvelopes  = 0;
            int numCombEnvelopes   = 0;
            int numFactorEnvelopes = 0;

            if (generateEnvelopes)
            {
                err = St7.St7GenerateEnvelopes(1, ref numLimitEnvelopes, ref numCombEnvelopes, ref numFactorEnvelopes);
            }
            if (!St7ErrorCustom(err, "Could not generate combinations"))
            {
                return(new OpenResultsOut(false, null, null));
            }
            if (getCaseNames)
            {
                for (int i = 1; i <= primaryCases + secondaryCases + numLimitEnvelopes + numCombEnvelopes + numFactorEnvelopes; i++)
                {
                    StringBuilder caseName = new StringBuilder(St7.kMaxStrLen);
                    err = St7.St7GetResultCaseName(1, i, caseName, St7.kMaxStrLen);
                    caseNames.Add(caseName.ToString());
                    caseIds.Add(i);
                }
            }
            return(new OpenResultsOut(St7Error(err), caseNames, caseIds));
        }