Exemple #1
0
        public void ReadProgramFromImport(string programName, string path)
        {
            List <string> config = FileManipulation.ReadFileFirstLine(path + programName + ".prg");

            ConfigureReadProgram(config);
            this.instructionText = FileManipulation.ReadStroopProgramInstructionsFromImport(programName);
        }
Exemple #2
0
        // converts .prg file into a stroopprogram object
        public void readProgramBackUpFile(string programName)
        {
            List <string> config = FileManipulation.ReadStroopProgramFromBackup(programName);

            ConfigureReadProgram(config);
            this.instructionText = FileManipulation.ReadStroopProgramInstructionsFromBackup(programName);
        }
Exemple #3
0
 public static FileManipulation Instance(string path)
 {
     if (instance == null)
     {
         instance = new FileManipulation(path);
     }
     return(instance);
 }
Exemple #4
0
 public static FileManipulation Instance(FormMain globalFormMain)
 {
     if (instance == null)
     {
         instance = new FileManipulation(globalFormMain);
     }
     return(instance);
 }
Exemple #5
0
 public bool AddStroopProgram(string programName)
 {
     try
     {
         if (!FileManipulation.StroopProgramExists(programName))
         {
             throw new MissingMemberException(programName + " (" + LocRM.GetString("stroopTest", currentCulture) + ")");
         }
         StroopProgram newProgram = new StroopProgram();
         newProgram.ProgramName = programName;
         newProgram.readProgramFile(newProgram.ProgramName);
         ProgramList.Add(newProgram);
     }
     catch (FileNotFoundException)
     {
         return(false);
     }
     return(true);
 }
Exemple #6
0
        /* getting information from .prg file and converting to an experiment object */
        public void ReadProgramFile(bool recoverFromBackup = false)
        {
            string filePath;
            bool   isProgramValid = true;

            if (recoverFromBackup)
            {
                filePath = FileManipulation._experimentTestFilesBackupPath + ExperimentName + ".prg";
            }
            else
            {
                filePath = GetProgramsPath() + ExperimentName + ".prg";
            }
            if (File.Exists(filePath))
            {
                string[] fileLines = File.ReadAllLines(filePath);
                string   line      = fileLines[0];
                line = FileManipulation.EncodeLatinText(line);
                List <string> configurationFile = line.Split().ToList();

                ExperimentName = configurationFile[0];
                if (Path.GetFileNameWithoutExtension(filePath) != (this.ExperimentName))
                {
                    throw new Exception(LocRM.GetString("parameter", currentCulture) + this.ExperimentName +
                                        LocRM.GetString("parameterShould", currentCulture) + Path.GetFileNameWithoutExtension(filePath) + "'.prg");
                }
                IntervalTime  = int.Parse(configurationFile[1]);
                IsOrderRandom = bool.Parse(configurationFile[2]);
                if (configurationFile.Count > 3)
                {
                    TrainingProgram = bool.Parse(configurationFile[3]);
                }
                else
                {
                    TrainingProgram = false;
                }

                string listLine = fileLines[1];
                line = FileManipulation.EncodeLatinText(line);
                List <string> listConfiguration = listLine.Split().ToList();
                for (int i = 1; i <= listConfiguration.Count() - 2; i = i + 2)
                {
                    if (listConfiguration[i] == "StroopProgram")
                    {
                        isProgramValid = AddStroopProgram(listConfiguration[i - 1]);
                    }
                    else if (listConfiguration[i] == "ReactionProgram")
                    {
                        isProgramValid = AddReactionProgram(listConfiguration[i - 1]);
                    }
                    else if (listConfiguration[i] == "MatchingProgram")
                    {
                        isProgramValid = AddMatchingProgram(listConfiguration[i - 1]);
                    }
                    if (!isProgramValid && recoverFromBackup)
                    {
                        throw new FileNotFoundException(listConfiguration[i - 1]);
                    }
                }

                if (fileLines.Length > 2) // reads instructions if there are any
                {
                    for (int i = 2; i < fileLines.Length; i++)
                    {
                        this.InstructionText.Add(fileLines[i]);
                    }
                }
                else
                {
                    this.InstructionText = null;
                }
                if (!isProgramValid)
                {
                    this.SaveExperimentFile(GetProgramsPath());
                }
            }
            else
            {
                throw new FileNotFoundException(LocRM.GetString("fileNotFound", currentCulture) + Path.GetDirectoryName(filePath));
            }
        }
Exemple #7
0
 public static string[] GetAllPrograms()
 {
     return(FileManipulation.GetAllFilesInFolder(GetProgramsPath(), ".prg"));
 }
Exemple #8
0
        public void configureReadProgram(string filepath)
        {
            StreamReader tr;
            string       line;

            string[]      linesInstruction;
            List <string> config = new List <string>();


            if (!File.Exists(filepath))
            {
                throw new FileNotFoundException();
            }                                                                  // confere existência do arquivo

            tr     = new StreamReader(filepath, Encoding.Default, true);
            line   = tr.ReadLine();
            line   = FileManipulation.EncodeLatinText(line);
            config = line.Split().ToList();
            tr.Close();

            ProgramName = config[0];
            if (Path.GetFileNameWithoutExtension(filepath) != (this.ProgramName))
            {
                throw new Exception("Parâmetro escrito no arquivo como: '" + this.ProgramName +
                                    "'\ndeveria ser igual ao nome no arquivo: '" + Path.GetFileNameWithoutExtension(filepath) + "'.prg");
            }
            stimuluNumber      = int.Parse(config[1]);
            ExpositionTime     = int.Parse(config[2]);
            expositionRandom   = bool.Parse(config[3]);
            IntervalTime       = int.Parse(config[4]);
            IntervalTimeRandom = bool.Parse(config[5]);
            setWordListFile(config[6]);
            setColorListFile(config[7]);
            BackgroundColor = config[8];
            expositionType  = config[9];
            setImageListFile(config[10]);
            FixPoint = config[11];
            setAudioListFile(config[12]);
            FixPointColor               = config[13];
            intervalTime                = int.Parse(config[14]);
            stimuluSize                 = int.Parse(config[15]);
            randomModelPosition         = bool.Parse(config[16]);
            endExpositionWithClick      = bool.Parse(config[17]);
            modelExpositionTime         = int.Parse(config[18]);
            attemptsIntervalTime        = int.Parse(config[19]);
            DNMTSBackground             = config[20];
            AttemptsNumber              = int.Parse(config[21]);
            numberPositions             = int.Parse(config[22]);
            randomIntervalModelStimulus = bool.Parse(config[23]);
            randomStimuluPosition       = bool.Parse(config[24]);
            wordColor = config[25];
            expositionAudioResponse = Boolean.Parse(config[26]);
            feedbackAudioResponse   = Boolean.Parse(config[27]);
            commissionAudioResponse = Boolean.Parse(config[28]);
            omissionAudioResponse   = Boolean.Parse(config[29]);
            linesInstruction        = File.ReadAllLines(filepath);
            if (linesInstruction.Length > 1) // read instructions if any
            {
                for (int i = 1; i < linesInstruction.Length; i++)
                {
                    this.InstructionText.Add(linesInstruction[i]);
                }
            }
            else
            {
                this.InstructionText = null;
            }
        }
Exemple #9
0
 public static string[] GetAllPrograms()
 {
     return(FileManipulation.GetAllFilesInFolder(GetProgramsPath(), FileManipulation.ProgramExtension));
 }
Exemple #10
0
 public static bool ProgramExists(string programName)
 {
     return(FileManipulation.FileExists(GetProgramsPath() + programName + FileManipulation.ProgramExtension));
 }
Exemple #11
0
 public bool saveProgramFile()
 {
     FileManipulation.SaveProgramFile(FileManipulation.StroopTestFilesPath + FileManipulation._programFolderName + ProgramName, data(), InstructionText);
     return(true);
 }