public MccDeviceReader(Settings _settings)
        {
            settings = _settings;
            ISet<MccDaq.DigitalPortType> portsUsed = settings.getPortsUsed();
            tempBoard = new MccBoard(settings.TempBoardNumber);

            if (settings.TemperatureFormat == TemperatureFormatEnum.Farenheit)
            {
                tempScale = TempScale.Fahrenheit;
            }
            else
            {
                tempScale = TempScale.Celsius;
            }
            dioBoard = new MccBoard(settings.DIOBoardNumber);
            foreach (MccDaq.DigitalPortType portType in settings.getPortsUsed())
            {
                MccDaq.ErrorInfo ulStat = dioBoard.DConfigPort(portType, MccDaq.DigitalPortDirection.DigitalIn);
                if (ulStat.Value != ErrorInfo.ErrorCode.NoErrors)
                {
                    logger.Error("Error while configuring DIO Board : " + ulStat.Message);
                    throw new DeviceException("Error while configuring DIO Board : " + ulStat.Message);
                }
            }

            //    MccDaq.ErrorInfo ULStat = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.PrintAll, MccDaq.ErrorHandling.StopAll);
        }
        /*
         * startRun
         *    start a new sample run
         *
         */
        private void startRun()
        {
            sampleLogger.Info("Run Started");
            // Get a fresh copy of the application settings
            settings = DataObjects.SettingsManager.Instance.ApplicationSettings;
            // Shade unused stations
            colorDisabledStations(sampleGrid);
            // Get a new OvenManager
            try
            {

                ovenManager = new SampleOvenManager(settings);
            }
            catch (Exception e)
            {
                sampleLogger.Info("Run Ended - Error configuring device", e);
                logger.Error("Run Ended - Error configuring device", e);
                return;
            }
            // Add event handler for dispatch timer tick and start the timer
            dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
            dispatcherTimer.Start();
            // Change start/stop button to show stop
            startStopButton.Content = "Stop";
            // Disable the config menu while running
            configMenuItem.IsEnabled = false;
            running = true;
        }
 public void updateProperties(Settings settings)
 {
     if (settings != null)
     {
         settings.clearPortsUsed();
         if (settings.SampleConfigurationDictionary != null)
         {
             foreach (var pair in settings.SampleConfigurationDictionary)
             {
                 string portName = null;
                 if (pair.Value != null)
                 {
                     portName = pair.Value.Name;
                 }
                 Properties.Settings.Default[samplePropertyPrefix + pair.Key] = portName;
             }
         }
         Properties.Settings.Default[tempBoardNumberPropertyName] = settings.TempBoardNumber;
         Properties.Settings.Default[tempPortNumberPropertyName] = settings.TempPortNumber;
         Properties.Settings.Default[dioBoardNumberPropertyName] = settings.DIOBoardNumber;
         if (settings.TemperatureFormat == TemperatureFormatEnum.Farenheit)
         {
             Properties.Settings.Default[tempFormatCelsiusPropertyName] = false;
         }
         else
         {
             Properties.Settings.Default[tempFormatCelsiusPropertyName] = true;
         }
         Properties.Settings.Default[secondsBeforeErrorTimeoutPropertyName] = settings.SecondsBeforeErrorTimeout;
     }
 }
 public SampleOvenManager(Settings _settings)
 {
     settings = _settings;
     deviceReader = new MccDeviceReader(settings);
     startTime = DateTime.Now;
 }
        private void saveButton_Click(object sender, RoutedEventArgs e)
        {
            Settings updatedSettings = new Settings();
            updatedSettings.TempBoardNumber = (int)tcBoardNumberCombo.SelectedItem;
            updatedSettings.TempPortNumber = (byte)tcPortNumberCombo.SelectedItem;
            updatedSettings.DIOBoardNumber = (int)dioBordNumberCombo.SelectedItem;
            if (farenheitRadioButton.IsChecked == true)
            {
                updatedSettings.TemperatureFormat = TemperatureFormatEnum.Farenheit;
            }
            else
            {
                updatedSettings.TemperatureFormat = TemperatureFormatEnum.Celsius;
            }

            IDictionary<byte,MccPortInformation> sampleSettingsDictionary = new Dictionary<byte, MccPortInformation>();
            for (byte i = 1; i <= 30; i++)
            {
                Object tempObject = LogicalTreeHelper.FindLogicalNode(sampleConfigGrid, portConfigComboPrefix + i);
                if (tempObject is ComboBox)
                {
                    ComboBox tempComboBox = tempObject as ComboBox;
                    sampleSettingsDictionary[i] = MccPortInformationAccessor.Instance.portForName( tempComboBox.SelectedItem as String);
                }
            }
            updatedSettings.SampleConfigurationDictionary = sampleSettingsDictionary;
             //   SettingsManager.Instance.updateSampleSettingProperties(sampleSettingsDictionary);
            SettingsManager.Instance.updateProperties(updatedSettings);

            this.Close();
        }