Exemplo n.º 1
0
        public int GetSetting(string section, string key, int defvalue)
        {
            int res;

            if (!int.TryParse(_settings.GetValue(section, key), out res))
            {
                res = defvalue;
                _settings.SetValue(section, key, defvalue.ToString());
            }
            return(res);
        }
Exemplo n.º 2
0
        public void LoadConfiguration(string settingsFile)
        {
            if (!File.Exists(settingsFile))
            {
                MessageBox.Show("Settings file not found: " + settingsFile, "Settins File Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            Status = WGStatus.UNKNOWN;


            try
            {
                XmlSettings.Settings settings = new XmlSettings.Settings(settingsFile);

                DefaultTraceColorList = new List <Color>();

                LambdaComPortName            = settings.GetValue("MAIN", "LambdaComPortName");
                DBServerName                 = settings.GetValue("MAIN", "DBServerName");
                DBName                       = settings.GetValue("MAIN", "DBName");
                DBUsername                   = settings.GetValue("MAIN", "DBUsername");
                DBPassword                   = settings.GetValue("MAIN", "DBPassword");
                MaxPixelValue                = Convert.ToInt32(settings.GetValue("MAIN", "MaxPixelValue"));
                PixelWidth                   = Convert.ToInt32(settings.GetValue("MAIN", "CameraSensorPixelWidth"));
                PixelHeight                  = Convert.ToInt32(settings.GetValue("MAIN", "CameraSensorPixelHeight"));
                MaxNumberImagesPerExperiment = Convert.ToInt32(settings.GetValue("MAIN", "MaxNumberImagesPerExperiment"));


                switch (settings.GetValue("MAIN", "CompressionAlgorithm"))
                {
                case "GZIP":
                    CompressionAlgorithm = COMPRESSION_ALGORITHM.GZIP;
                    break;

                default:
                    CompressionAlgorithm = COMPRESSION_ALGORITHM.NONE;
                    break;
                }


                CameraTargetTemperature = Convert.ToInt32(settings.GetValue("MAIN", "CameraTargetTemperature"));
                CameraDefaultCycleTime  = Convert.ToInt32(settings.GetValue("MAIN", "CameraDefaultCycleTime"));
                InsideTargetTemperature = Convert.ToInt32(settings.GetValue("MAIN", "InsideTargetTemperature"));
                EventMarkerLatency      = Convert.ToInt32(settings.GetValue("MAIN", "EventMarkerLatency"));
                FilterChangeSpeed       = Convert.ToByte(settings.GetValue("MAIN", "FilterChangeSpeed"));
                ImageFileSaveLocation   = settings.GetValue("MAIN", "ImageFileSaveLocation");
                Color color = (Color)ColorConverter.ConvertFromString(settings.GetValue("MAIN", "Color1"));
                if (color != null)
                {
                    DefaultTraceColorList.Add(color);
                }
                color = (Color)ColorConverter.ConvertFromString(settings.GetValue("MAIN", "Color2"));
                if (color != null)
                {
                    DefaultTraceColorList.Add(color);
                }
                color = (Color)ColorConverter.ConvertFromString(settings.GetValue("MAIN", "Color3"));
                if (color != null)
                {
                    DefaultTraceColorList.Add(color);
                }
                color = (Color)ColorConverter.ConvertFromString(settings.GetValue("MAIN", "Color4"));
                if (color != null)
                {
                    DefaultTraceColorList.Add(color);
                }
                color = (Color)ColorConverter.ConvertFromString(settings.GetValue("MAIN", "Color5"));
                if (color != null)
                {
                    DefaultTraceColorList.Add(color);
                }
                color = (Color)ColorConverter.ConvertFromString(settings.GetValue("MAIN", "Color6"));
                if (color != null)
                {
                    DefaultTraceColorList.Add(color);
                }
                color = (Color)ColorConverter.ConvertFromString(settings.GetValue("MAIN", "Color7"));
                if (color != null)
                {
                    DefaultTraceColorList.Add(color);
                }
                color = (Color)ColorConverter.ConvertFromString(settings.GetValue("MAIN", "Color8"));
                if (color != null)
                {
                    DefaultTraceColorList.Add(color);
                }
                VWorksUsername = settings.GetValue("MAIN", "VWorksUsername");
                VWorksPassword = settings.GetValue("MAIN", "VWorksPassword");
                VWorksProtocolFileDirectory               = settings.GetValue("MAIN", "VWorksProtocolFileDirectory");
                UpSignalOptimizePercentCountThreshold     = Convert.ToInt32(settings.GetValue("MAIN", "UpSignalOptimizePercentCountThreshold"));
                DownSignalOptimizePercentCountThreshold   = Convert.ToInt32(settings.GetValue("MAIN", "DownSignalOptimizePercentCountThreshold"));
                UpDownSignalOptimizePercentCountThreshold = Convert.ToInt32(settings.GetValue("MAIN", "UpDownSignalOptimizePercentCountThreshold"));
                MaxCameraTemperatureThresholdDeviation    = Convert.ToInt32(settings.GetValue("MAIN", "MaxCameraTemperatureThresholdDeviation"));
                MaxInsideTemperatureThresholdDeviation    = Convert.ToInt32(settings.GetValue("MAIN", "MaxInsideTemperatureThresholdDeviation"));
                EnclosureCameraIPAddress            = settings.GetValue("MAIN", "EnclosureCameraIPAddress");
                DefaultExcelReportFileDirectory     = settings.GetValue("MAIN", "DefaultExcelReportFileDirectory");
                DefaultWaveGuideReportFileDirectory = settings.GetValue("MAIN", "DefaultWaveGuideReportFileDirectory");
                DefaultExcelFileNameFormat          = settings.GetValue("MAIN", "DefaultExcelFileNameFormat");
                DefaultWaveGuideFileNameFormat      = settings.GetValue("MAIN", "DefaultWaveGuideFileNameFormat");
                DefaultPixelMaskThresholdPercent    = Convert.ToDouble(settings.GetValue("MAIN", "DefaultPixelMaskThresholdPercent"));
                TempControllerIP        = settings.GetValue("MAIN", "TemperatureController_IP");
                EthernetIOModuleIP      = settings.GetValue("MAIN", "EthernetIOModule_IP");
                Enable_EthernetIOModule = settings.GetValue("MAIN", "Enable_EthernetIOModule").ToUpper() == "TRUE" ? true : false;
                Enable_EnclosureTemperatureController = settings.GetValue("MAIN", "Enable_EnclosureTemperatureController").ToUpper() == "TRUE" ? true : false;
                TCPCommand_Port = Convert.ToInt32(settings.GetValue("MAIN", "TCPCommand_Port"));


                DatabaseConnectionString = "Data Source=" + DBServerName + ";Initial Catalog=" + DBName +
                                           ";User ID=" + DBUsername + ";Password="******"Error reading Settings file: " + settingsFile, "Settins File Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }