Example #1
0
 private void logSessionComboBox_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
 {
     if (logSessionComboBox.SelectedIndex != -1)
     {
         foreach (LogSession ls in logDayDisplay.sessionList)
         {
             if ((int)logSessionComboBox.SelectedValue == ls.sessionIndex)
             {
                 logSessionDisplay = ls;
             }
         }
     }
     logNameTextbox.DataContext = logSessionDisplay.sessionName;
     RefreshCatDisplay();
 }
Example #2
0
        private void autoFeedStartButton_Click(object sender, RoutedEventArgs e)
        {
            // Auto-feed UI Initialization
            SaveSettings();
            doingAutoFeed = true;
            autoFeedStartButton.IsEnabled = false;
            preSetStackPanel.IsEnabled    = false;
            autoFeedGrid.IsEnabled        = false;
            deviceParaGrid.IsEnabled      = false;

            // Auto-feed Records Initialization
            logCurrentSession = new LogSession(DateTime.Now, allSets.basicParas, currentOUS.behaviorParas);
            totalTrialNum     = 0;
            currentTrialNum   = 0;

            // Behavior Program Initialization
            if ((bool)seqRadioButton.IsChecked)
            {
                autoFeedThread = new Thread(new ThreadStart(DoSequentialFeed));
                seqPosList     = new ObservableCollection <SeqPosition>();

                int length = currentOUS.posLibrary.Count();
                int index  = 0;

                for (int i = 0; i < length; i++)
                {
                    foreach (LibPos lp in currentOUS.posLibrary)
                    {
                        if (lp.selected && lp.index != 0)
                        {
                            bool find = false;
                            while (!find)
                            {
                                if (index == lp.index)
                                {
                                    seqPosList.Add(new SeqPosition(lp));
                                    find = true;
                                }
                                else
                                {
                                    index++;
                                    if (index > length)
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }

                foreach (SeqPosition sp in seqPosList)
                {
                    totalTrialNum += sp.repeat;
                }
                totalTrialNum *= currentOUS.behaviorParas.cycNum;
            }
            else
            {
                autoFeedThread = new Thread(new ThreadStart(DoRandomFeed));
                randPosList    = new ObservableCollection <RandomPosition>();

                chanceTopVal = 0;
                foreach (LibPos lp in currentOUS.posLibrary)
                {
                    if (lp.selected && lp.chance != 0)
                    {
                        randPosList.Add(new RandomPosition(lp, chanceTopVal));
                        chanceTopVal += lp.chance;
                    }
                }

                totalTrialNum = currentOUS.behaviorParas.trialNum;
            }
            processLabel.Content = "Result of trial " + currentTrialNum + "/" + totalTrialNum + " (last trial) : ";

            autoFeedThread.IsBackground = true;
            autoFeedThread.Start();
        }