Ejemplo n.º 1
0
        public override void Init(int experiment_record_ID, int trial_training_count, int trial_test_count, bool judgement_type)
        {
            // New TrialData
            TrialCount = 0;
            CurrentTrialState = TrialState.Ready;
            this.TrialEvent(this, new TrialEventArgs(TrialState.Ready, TrialCount));
            TrialData = new ExperimentData();
            TrialData.ExperimentRecordID = experiment_record_ID;

            // Init parameters            
            TrialTrainingCount = trial_training_count;
            TrialTestCount = trial_test_count;
            TrialTotalCount = trial_training_count + trial_test_count;

            // 指导语
            if (judgement_type == true)
                StackPanelGuideWords.Children.Remove(TextBlockGuideWordsType2);
            else
                StackPanelGuideWords.Children.Remove(TextBlockGuideWordsType1);

            Dispatcher.BeginInvoke(new Action(() =>
            {
                StackPanelGuideWords.Visibility = Visibility.Visible;
                GridSceneImage.Visibility = Visibility.Hidden;
                StackPanelTips.Visibility = Visibility.Hidden;
            }), null);

            // 初始化图像库路径
            //if (!ImageDirectory.IsInitialized)
            //    ImageDirectory.Init();
        }
Ejemplo n.º 2
0
        public static bool GetExperimentData(int experiment_record_ID, out ExperimentData[] experiment_data)
        {
            experiment_data = new ExperimentData[0];
            string[] experiment_table_names = Enum.GetNames(typeof(ExperimentType));

            if (_DatabaseInUse == DatabaseType.MySql)
            {
                foreach (string experiment_type in experiment_table_names)
                {
                    string string_of_select_experiment_data = "select `Time`,`GroupIndex`,`SceneNature`,`SceneName`,`FaceNature`,`FaceName`, `FacePos`," +
                    "`Judgement`,`TrialTime` from `" + experiment_type + "` where `ExperimentRecordID`='" + experiment_record_ID.ToString() + "';";


                    DataSet dataset = MySql.MySqlHelper.ExecuteQuery(string_of_select_experiment_data);
                    if (dataset.Tables[0].Rows.Count == 0)
                        continue;

                    experiment_data = new ExperimentData[dataset.Tables[0].Rows.Count];
                    for (int i = 0; i < dataset.Tables[0].Rows.Count; i++)
                    {
                        DataRow row = dataset.Tables[0].Rows[i];
                        DataColumnCollection colums = dataset.Tables[0].Columns;

                        experiment_data[i].ExperimentRecordID = experiment_record_ID;
                        experiment_data[i].Time = DateTime.Parse(row[colums[0]].ToString());
                        experiment_data[i].GroupIndex = Convert.ToInt32(row[colums[1]].ToString());
                        experiment_data[i].SceneNature = (NatureType)(Convert.ToInt32(row[colums[2]].ToString()));
                        experiment_data[i].SceneName = row[colums[3]].ToString();
                        experiment_data[i].FaceNature = (NatureType)(Convert.ToInt32(row[colums[4]].ToString()));
                        experiment_data[i].FaceName = row[colums[5]].ToString();
                        experiment_data[i].FacePos = (PositionType)(Convert.ToInt32(row[colums[6]].ToString()));
                        experiment_data[i].Judgement = Convert.ToBoolean(Convert.ToInt32(row[colums[7]].ToString()));
                        experiment_data[i].TrialTime = Convert.ToDouble(row[colums[8]].ToString());
                    }
                    
                    return true;                
                }
                return false;
            }
            else
            {
                return false;
            }
        }
Ejemplo n.º 3
0
 public static bool SaveExperimentData(ExperimentType experiment_name, ExperimentData experiment_data)
 {
     string string_of_save_experiment_data = string.Format("insert into `" + experiment_name.ToString() + "` (`ExperimentRecordID`,`Time`,`MilliSecond`,`GroupIndex`," +
         "`SceneNature`,`SceneName`,`FaceNature`,`FaceName`, `FacePos`, `Judgement`,`TrialTime`) values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}');",
         experiment_data.ExperimentRecordID.ToString(), experiment_data.Time.ToString(), experiment_data.MilliSecond.ToString(), experiment_data.GroupIndex.ToString(),
         Convert.ToInt32(experiment_data.SceneNature).ToString(), experiment_data.SceneName,
         Convert.ToInt32(experiment_data.FaceNature).ToString(), experiment_data.FaceName,
         Convert.ToInt32(experiment_data.FacePos).ToString(), Convert.ToInt32(experiment_data.Judgement).ToString(),
         experiment_data.TrialTime.ToString());
     if (_DatabaseInUse == DatabaseType.MySql)
     {
         if (MySql.MySqlHelper.ExecuteCommand(string_of_save_experiment_data) != 1)
             return false;
         return true;
     }
     else
     {
         return false;
     }
 }