/// <summary> /// Check if log folder exits, and if not - create it /// </summary> /// <returns>Current log file path</returns> private static string GetLogDirectory() { if (LogFilePath == "") { string st = ""; //Check if root folder exists. If not - create it if (!Directory.Exists(ConfigManagement.ProgDocumentsPath)) { ConfigManagement.CreateDocumentsDirStructure(); } //Log folder exists (Creation succeeds)? if (Directory.Exists(Path.Combine(ConfigManagement.ProgDocumentsPath, LOG_FOLDER_NAME) + "\\")) { //use default folder st = Path.Combine(ConfigManagement.ProgDocumentsPath, LOG_FOLDER_NAME) + "\\"; } else { //if not - use app folder st = Application.StartupPath; } return(st); } else { return(LogFilePath); } }
/// <summary> /// Test PHD CONNECT /// </summary> /// <returns></returns> internal TestResultClass TestPHD2Connect() { TestResultClass TestResult = new TestResultClass(); TestResult.res = false; TestResult.AddStr("TestEquipment: PHD2 connect test started"); //run test Thread.Sleep(ConfigManagement.getInt("scenarioMainParams", "PHD_CONNECT_PAUSE") ?? 300); //wait a bit string stout = ""; string res = ObsControl.objPHD2App.CMD_GetCurrentProfile(); //check result try { if (res != String.Empty) { TestResult.AddStr("TestEquipment: phd2 equipment list: " + res + ""); TestResult.res = true; TestResult.AddStr("TestEquipment: PHD2 connect test passed"); } else { TestResult.AddStr("TestEquipment: PHD2 connect failed"); } } catch (Exception Ex) { TestResult.AddStr("TestEquipment: PHD2 connect test failed"); } return(TestResult); }
/// <summary> /// Run scenario by parsing special CONFIG section /// </summary> /// <param name="ScenarioName">Scenario name</param> public void ParseXMLScenario(string ScenarioName) { XmlNode scenarioSet = ConfigManagement.getXMLNode(ScenarioName); foreach (XmlElement ScenarioElem in scenarioSet) { //Имя команды string name = ScenarioElem.Name; //Флаг RUN string runflag_st = ScenarioElem.GetAttribute("run"); bool runflag; if (!Boolean.TryParse(runflag_st, out runflag)) { runflag = true; } //Тип командры string eltype = ScenarioElem.GetAttribute("type"); //Параметры команды string argument = ScenarioElem.GetAttribute("argument"); if (runflag && eltype != "parameter") { //RUN this command CommandParser.ParseSingleCommand2(name + (argument != "" ? " " + argument : "")); } } }
/// <summary> /// Updates all dir lists from combobox list /// Из элемента формы обновляются данные в XML и в переменных /// </summary> private void IQP_SaveDirList() { //1. Empty current lists //Monitoring list IQP_FileMonitorPath.Clear(); //Config //ConfigManagement.ClearSection("monitorPath"); //clear entire section //2. Make new lists for (int i = 0; i < cmbIQPMonitorPath.Items.Count; i++) { string curDir = cmbIQPMonitorPath.GetItemText(cmbIQPMonitorPath.Items[i]); //Add to monitor list IQP_FileMonitorPath.Add(curDir); //Add to config list ConfigManagement.UpdateConfigValue("monitorPath", "Dir" + (i + 1), curDir); } //3. Save config ConfigManagement.Save(); //4. Обновить инфо о количестве подакаталогов lblDirsMonitoringCount.Text = cmbIQPMonitorPath.Items.Count.ToString(); }
private void linkPHD2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { ObsControl.CommandParser.ParseSingleCommand2("PHD2_RUN"); Thread.Sleep(ConfigManagement.getInt("scenarioMainParams", "PHD_CONNECT_PAUSE") ?? 0); ObsControl.CommandParser.ParseSingleCommand2("PHD2_CONNECT"); }
private void IQP_LoadParamsFromXML() { try { List <string> dirNodesList = ConfigManagement.getAllSectionNamesList("monitorPath"); foreach (string curDirNode in dirNodesList) { IQP_FileMonitorPath.Add(ConfigManagement.getString("monitorPath", curDirNode)); } ObsControl.objIQPEngine.MonitorObj.settingsScanSubdirs = ConfigManagement.getBool("IQP_options", "ScanSubDirs") ?? false; settingsAutoStartMonitoring = ConfigManagement.getBool("IQP_options", "AUTOSTARTMONITORING") ?? false; ObsControl.objIQPEngine.ProcessingObj.settingsDSSCLPath = ConfigManagement.getString("IQP_options", "DSS_PATH") ?? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), @"\DeepSkyStacker\DeepSkyStackerCL.exe"); ObsControl.objIQPEngine.ProcessingObj.settingsPublishToGroup = ConfigManagement.getBool("IQP_options", "PUBLISHTOGROUP") ?? true; ObsControl.objIQPEngine.WebPublishObj.SetURL(ConfigManagement.getString("publishURL", "url1") ?? "http://localhost"); ObsControl.objIQPEngine.WebPublishObj.ServerKey = ConfigManagement.getString("publishURL", "key1") ?? ""; ObsControl.objIQPEngine.ProcessingObj.settingsPublishToPrivate = ConfigManagement.getBool("IQP_options", "PUBLISHTOPRIVATE") ?? true; ObsControl.objIQPEngine.WebPublishObj2.SetURL(ConfigManagement.getString("publishURL", "url2") ?? "http://localhost"); ObsControl.objIQPEngine.WebPublishObj2.ServerKey = ConfigManagement.getString("publishURL", "key2") ?? ""; //hidden settings ObsControl.objIQPEngine.MonitorObj.settingsExtensionToSearch = ConfigManagement.getString("IQP_options", "extensionsToSearch") ?? "*.fit*"; ObsControl.objIQPEngine.ProcessingObj.settingsMaxThreads = (uint)(ConfigManagement.getInt("IQP_options", "checkThreads_max") ?? 1); ObsControl.objIQPEngine.ProcessingObj.settingsSkipIMSfiles = ConfigManagement.getBool("IQP_options", "checkDirIMS") ?? true; ObsControl.objIQPEngine.ProcessingObj.settingsDSSForceRecheck = ConfigManagement.getBool("IQP_options", "alwaysRebuildDSSInfoFile") ?? false; ObsControl.objIQPEngine.ProcessingObj.settingsDSSForceRunHidden = ConfigManagement.getBool("IQP_options", "RunDSSHidden") ?? false; ObsControl.objIQPEngine.ProcessingObj.settingsPublishLightFramesOnly = ConfigManagement.getBool("IQP_options", "publishLightFramesOnly") ?? true; ObsControl.objIQPEngine.ProcessingObj.settingsDSSInfoFileAutoDelete = ConfigManagement.getBool("IQP_options", "autoDeleteDSSInfoFile") ?? false; //Filter settings string st = ConfigManagement.getString("IQP_filters", "excludedirs") ?? ""; ObsControl.objIQPEngine.MonitorObj.settingsFilterDirName_ExcludeSt = new List <string>(st.Split(';')); st = ConfigManagement.getString("IQP_filters", "excludefiles") ?? ""; ObsControl.objIQPEngine.MonitorObj.settingsFilterFileName_ExcludeSt = new List <string>(st.Split(';')); ObsControl.objIQPEngine.ProcessingObj.settingsFilterObserverTag_Contains = ConfigManagement.getString("IQP_filters", "observer") ?? ""; ObsControl.objIQPEngine.ProcessingObj.settingsFilterTelescopTag_Contains = ConfigManagement.getString("IQP_filters", "telescop") ?? ""; ObsControl.objIQPEngine.ProcessingObj.settingsFilterInstrumeTag_Contains = ConfigManagement.getString("IQP_filters", "instrume") ?? ""; //Filter settings: quality ObsControl.objIQPEngine.ProcessingObj.settingsFilterHistoryTag_MaxCount = (UInt16)(ConfigManagement.getInt("IQP_filters", "historycount") ?? 1); ObsControl.objIQPEngine.ProcessingObj.settingsFilterStarsNum_MinCount = (UInt16)(ConfigManagement.getInt("IQP_filters", "minstars") ?? 1); ObsControl.objIQPEngine.ProcessingObj.settingsFilterFWHM_MaxVal = ConfigManagement.getDouble("IQP_filters", "maxfwhm") ?? 10.0; ObsControl.objIQPEngine.ProcessingObj.settingsFilterMinAltitude_MinVal = ConfigManagement.getDouble("IQP_filters", "minaltitude") ?? 19.0; ObsControl.objIQPEngine.ProcessingObj.settingsFilterBackground_MaxVal = ConfigManagement.getDouble("IQP_filters", "maxbackground") ?? 0.30; Logging.AddLog("IQP parameters were set according to configuration file", LogLevel.Activity); } catch (Exception ex) { Logging.AddLog("Couldn't load options" + ex.Message, LogLevel.Important, Highlight.Error); Logging.AddLog("Exception details: " + ex.ToString(), LogLevel.Debug, Highlight.Error); } }
private void btnRestoreDefaults_Click(object sender, EventArgs e) { if (MessageBox.Show("Do you want to reset all settings to their default values (this can't be undone)?", "Reset to default values", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { //for classic settings, at least до тех пор, пока полностью не перейдем на CUSTOM XML Properties.Settings.Default.Reset(); //Загрузить из файла ConfigManagement.Load(); //Перерисовать LoadDataIntoGrids("All"); } }
private void IQP_SaveSettingsToConfigFile() { //1. Update ConfigXML //Save dirlist ConfigManagement.ClearSection("monitorPath"); //clear entire section for (int i = 0; i < cmbIQPMonitorPath.Items.Count; i++) { string curDir = cmbIQPMonitorPath.GetItemText(cmbIQPMonitorPath.Items[i]); ConfigManagement.UpdateConfigValue("monitorPath", "Dir" + (i + 1), curDir); } ConfigManagement.UpdateConfigValue("IQP_options", "ScanSubDirs", chkSearchSubdirs.Checked.ToString()); //ConfigManagement.UpdateConfigValue("IQP_options", "AUTOSTARTMONITORING", chkSettings_Autostart.Checked.ToString()); //ConfigManagement.UpdateConfigValue("IQP_options", "DSS_PATH", txtSettings_DSS.Text); //ConfigManagement.UpdateConfigValue("IQP_options", "Language", cmbLang.SelectedValue.ToString()); //ConfigManagement.UpdateConfigValue("IQP_options", "PUBLISHTOGROUP", chkSettings_publishgroup.Checked.ToString()); //ConfigManagement.UpdateConfigValue("publishURL", "url1", txtSettings_urlgorup.Text); //ConfigManagement.UpdateConfigValue("publishURL", "key1", txtServerKey_Group.Text); //ConfigManagement.UpdateConfigValue("IQP_options", "PUBLISHTOPRIVATE", chkSettings_publishprivate.Checked.ToString()); //ConfigManagement.UpdateConfigValue("publishURL", "url2", txtSettings_urlprivate.Text); //ConfigManagement.UpdateConfigValue("publishURL", "key2", txtServerKey_Private.Text); //hidden settings ConfigManagement.UpdateConfigValue("IQP_options", "extensionsToSearch", ObsControl.objIQPEngine.MonitorObj.settingsExtensionToSearch); ConfigManagement.UpdateConfigValue("IQP_options", "checkThreads_max", ObsControl.objIQPEngine.ProcessingObj.settingsMaxThreads.ToString()); ConfigManagement.UpdateConfigValue("IQP_options", "checkDirIMS", ObsControl.objIQPEngine.ProcessingObj.settingsSkipIMSfiles.ToString()); ConfigManagement.UpdateConfigValue("IQP_options", "alwaysRebuildDSSInfoFile", ObsControl.objIQPEngine.ProcessingObj.settingsDSSForceRecheck.ToString()); ConfigManagement.UpdateConfigValue("IQP_options", "RunDSSHidden", ObsControl.objIQPEngine.ProcessingObj.settingsDSSForceRunHidden.ToString()); ConfigManagement.UpdateConfigValue("IQP_options", "autoDeleteDSSInfoFile", ObsControl.objIQPEngine.ProcessingObj.settingsDSSInfoFileAutoDelete.ToString()); ConfigManagement.UpdateConfigValue("IQP_options", "publishLightFramesOnly", ObsControl.objIQPEngine.ProcessingObj.settingsPublishLightFramesOnly.ToString()); //Filter settings ConfigManagement.UpdateConfigValue("IQP_filters", "excludedirs", String.Join(";", ObsControl.objIQPEngine.MonitorObj.settingsFilterDirName_ExcludeSt.ToArray())); ConfigManagement.UpdateConfigValue("IQP_filters", "excludefiles", string.Join(";", ObsControl.objIQPEngine.MonitorObj.settingsFilterFileName_ExcludeSt.ToArray())); ConfigManagement.UpdateConfigValue("IQP_filters", "observer", ObsControl.objIQPEngine.ProcessingObj.settingsFilterObserverTag_Contains); ConfigManagement.UpdateConfigValue("IQP_filters", "telescop", ObsControl.objIQPEngine.ProcessingObj.settingsFilterTelescopTag_Contains); ConfigManagement.UpdateConfigValue("IQP_filters", "instrume", ObsControl.objIQPEngine.ProcessingObj.settingsFilterInstrumeTag_Contains); ConfigManagement.UpdateConfigValue("IQP_filters", "historycount", ObsControl.objIQPEngine.ProcessingObj.settingsFilterHistoryTag_MaxCount.ToString()); ConfigManagement.UpdateConfigValue("IQP_filters", "minstars", ObsControl.objIQPEngine.ProcessingObj.settingsFilterStarsNum_MinCount.ToString()); ConfigManagement.UpdateConfigValue("IQP_filters", "maxfwhm", ObsControl.objIQPEngine.ProcessingObj.settingsFilterFWHM_MaxVal.ToString()); ConfigManagement.UpdateConfigValue("IQP_filters", "minaltitude", ObsControl.objIQPEngine.ProcessingObj.settingsFilterMinAltitude_MinVal.ToString()); ConfigManagement.UpdateConfigValue("IQP_filters", "maxbackground", ObsControl.objIQPEngine.ProcessingObj.settingsFilterBackground_MaxVal.ToString()); }
private void SaveXMLSettingsToConfigFile() { //1. Update ConfigXML ConfigManagement.UpdateConfigValue("Options", "lastsettemp", ObsControl.objMaxim.CameraSetPoint.ToString()); ConfigManagement.UpdateConfigValue("Devices", "FocuserDriverName", ObsControl.ASCOMFocuser.DRIVER_NAME); //focuser driver name ConfigManagement.UpdateConfigValue("Devices", "FocuserAutoConnect", ObsControl.ASCOMFocuser.Enabled.ToString()); //auto connect focuser //IQP_SaveSettingsToConfigFile(); //2. Save ConfigXML to disk ConfigManagement.Save(); //3. Load config from disk ConfigManagement.Load(); LoadOtherParamsFromXML(); //4. Side settings }
private void LoadOtherParamsFromXML() { try { //Filter settings ObsControl.objMaxim.TargetCameraSetTemp = ConfigManagement.getDouble("Options", "lastsettemp") ?? Maxim_ExternalApplication.DefaultCameraSetTemp; //Devices ObsControl.ASCOMFocuser.DRIVER_NAME = ConfigManagement.getString("Devices", "FocuserDriverName") ?? ""; ObsControl.ASCOMFocuser.Enabled = ConfigManagement.getBool("Devices", "FocuserAutoConnect") ?? false; Logging.AddLog("Program parameters were set according to XML configuration file", LogLevel.Activity); //IQP_LoadParamsFromXML(); } catch (Exception ex) { Logging.AddLog("Couldn't load XML options" + ex.Message, LogLevel.Important, Highlight.Error); Logging.AddLog("Exception details: " + ex.ToString(), LogLevel.Debug, Highlight.Error); } }
/// <summary> /// Constructor /// </summary> public MainForm() { InitializeComponent(); //Name settings string ProgDocumentFullPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "ObservatoryControl"); ConfigManagement.InitConfig(ProgDocumentFullPath, "ObservatoryControl.config", "Docs//ObservatoryControl.defaultconfig.txt"); Logging.InitLogging(ProgDocumentFullPath, "observatory_", false); //set log folder and log file name Logging.AddLog("****************************************************************************************", LogLevel.Activity); Logging.AddLog("Observatory Center started", LogLevel.Activity); Logging.AddLog("****************************************************************************************", LogLevel.Activity); ObsControl = new ObservatoryControls(this); SetForm = new SettingsForm(this); TestForm = new TestEquipmentForm(this); //Prepare separate thread obj (just dummy init, because it couldn't be null) //CheckPowerStatusThread_ref = new ThreadStart(ObsControl.CheckPowerDeviceStatus); //CheckPowerStatusThread = new Thread(CheckPowerStatusThread_ref); //SetPowerStatusThread = new Thread(ObsControl.SetDeviceStatus(null,null,null,null)); }
/// <summary> /// Init observatory activity. OBSOLETE /// </summary> public void StartUpObservatory_old() { //1. Switch on power if (ConfigManagement.getBool("scenarioMainParams", "POWER_ON") ?? false) { Logging.AddLog("StartUp run: Switching power on", LogLevel.Debug); CommandParser.ParseSingleCommand2("POWER_MOUNT_ON"); CommandParser.ParseSingleCommand2("POWER_CAMERA_ON"); CommandParser.ParseSingleCommand2("POWER_FOCUSER_ON"); } //2.1 Run PHD2 if (ConfigManagement.getBool("scenarioMainParams", "PHD2_RUN") ?? false) { Logging.AddLog("StartUp run: Start PHD2", LogLevel.Debug); CommandParser.ParseSingleCommand2("PHD2_RUN"); } Thread.Sleep(ConfigManagement.getInt("scenarioMainParams", "PHD_CONNECT_PAUSE") ?? 300); //2.2 PHD2 Connect equipment if (ConfigManagement.getBool("scenarioMainParams", "PHD2_CONNECT") ?? false) { Logging.AddLog("StartUp run: connect equipment in PHD2", LogLevel.Debug); CommandParser.ParseSingleCommand2("PHD2_CONNECT"); } //2.3 Rub broker app if (ConfigManagement.getBool("scenarioMainParams", "PHDBROKER_RUN") ?? false) { Logging.AddLog("StartUp run: run PHD Broker", LogLevel.Debug); CommandParser.ParseSingleCommand2("PHDBROKER_RUN"); } //3. Run MaximDL if (ConfigManagement.getBool("scenarioMainParams", "MAXIM_RUN") ?? false) { Logging.AddLog("StartUp run: Start Maxim DL", LogLevel.Debug); CommandParser.ParseSingleCommand2("MAXIM_RUN"); } //3.1. CameraConnect if (ConfigManagement.getBool("scenarioMainParams", "MAXIM_CAMERA_CONNECT") ?? false) { Logging.AddLog("StartUp run: Maxim Camera connect", LogLevel.Debug); CommandParser.ParseSingleCommand2("MAXIM_CAMERA_CONNECT"); //ParentMainForm.AppendLogText("Camera connected"); } //3.2. Set camera cooler if (ConfigManagement.getBool("scenarioMainParams", "MAXIM_CAMERA_SETCOOLING") ?? false) { CommandParser.ParseSingleCommand2("MAXIM_CAMERA_SETCOOLING"); } //3.3. Connect telescope to Maxim if (ConfigManagement.getBool("scenarioMainParams", "MAXIM_TELESCOPE_CONNECT") ?? false) { CommandParser.ParseSingleCommand2("MAXIM_TELESCOPE_CONNECT"); } //4. Run FocusMax if (ConfigManagement.getBool("scenarioMainParams", "FOCUSMAX_RUN") ?? false) { Logging.AddLog("StartUp run: Start Focus Max", LogLevel.Debug); CommandParser.ParseSingleCommand2("FOCUSMAX_RUN"); //ParentMainForm.AppendLogText("FocusMax started"); } //5. Connect focuser in Maxim to FocusMax if (ConfigManagement.getBool("scenarioMainParams", "MAXIM_FOCUSER_CONNECT") ?? false) { CommandParser.ParseSingleCommand2("MAXIM_FOCUSER_CONNECT"); } //Thread.Sleep(2000); //6. Run Cartes du Ciel if (ConfigManagement.getBool("scenarioMainParams", "CdC_RUN") ?? false) { CommandParser.ParseSingleCommand2("CdC_RUN"); } //8. Start CCDAP if (ConfigManagement.getBool("scenarioMainParams", "CCDAP_RUN") ?? false) { CommandParser.ParseSingleCommand2("CCDAP_RUN"); } //8. Start CCDC if (ConfigManagement.getBool("scenarioMainParams", "CCDC_RUN") ?? false) { CommandParser.ParseSingleCommand2("CCDC_RUN"); } //7. Connect telescope in Program if (ConfigManagement.getBool("scenarioMainParams", "OBS_TELESCOPE_CONNECT") ?? false) { CommandParser.ParseSingleCommand2("OBS_TELESCOPE_CONNECT"); } Thread.Sleep(ConfigManagement.getInt("scenarioMainParams", "CDC_CONNECT_PAUSE") ?? 0); //6.1. Connect telescope in Cartes du Ciel (to give time for CdC to run) if (ConfigManagement.getBool("scenarioMainParams", "CdC_TELESCOPE_CONNECT") ?? false) { CommandParser.ParseSingleCommand2("CdC_TELESCOPE_CONNECT"); } }
//public Process MaximDL_Process = new Process(); public void InitProgramsObj() { //Cartes du Ciel objCdCApp = new CdC_ExternatApplication(); objCdCApp.Name = "skychart"; objCdCApp.FullName = ConfigManagement.getString("programsPath", "CdC") ?? @"c:\Program Files (x86)\Ciel\skychart.exe"; objCdCApp.ParameterString = "--unique"; //PHD2 objPHD2App = new PHD_ExternatApplication(); objPHD2App.Name = "phd2"; objPHD2App.FullName = ConfigManagement.getString("programsPath", "PHD2") ?? @"c:\Program Files (x86)\PHDGuiding2\phd2.exe"; //PHDBroker objPHDBrokerApp = new PHDBroker_ExternatApplication(); objPHDBrokerApp.Name = "PHDBroker_Server"; //objPHDBrokerApp.FullName = PHDBrokerPath; objPHDBrokerApp.FullName = ConfigManagement.getString("programsPath", "PHDBROKER") ?? @"c:\Users\Emchenko Boris\Documents\CCDWare\CCDAutoPilot5\Scripts\PHDBroker_Server.exe"; //CCDAP objCCDAPApp = new CCDAP_ExternatApplication(); objCCDAPApp.Name = "CCDAutoPilot5"; objCCDAPApp.FullName = ConfigManagement.getString("programsPath", "CCDAP") ?? @"c:\Program Files (x86)\CCDWare\CCDAutoPilot5\CCDAutoPilot5.exe"; objCCDAPApp.LogPath = ConfigManagement.getString("programsPath", "CCDAP_Logs") ?? @"c:\Users\Emchenko Boris\Documents\CCDWare\CCDAutoPilot5\Images\CCDAutoPilot_Logs"; //CCDC objCCDCApp = new CCDC_ExternatApplication(this); objCCDCApp.Name = "CCDCommander"; objCCDCApp.FullName = ConfigManagement.getString("programsPath", "CCDC") ?? @"c:\CCD Commander\CCDCommander.exe"; objCCDCApp.LogPath = ConfigManagement.getString("programsPath", "CCDC_Logs") ?? @"c:\CCD Commander\Logs"; objCCDCApp.ActionsPath = ConfigManagement.getString("programsPath", "CCDC_Actions") ?? @"c:\CCD Commander\Actions"; objCCDCApp.ParameterString = objCCDCApp.GetLastActionFile().FullName; objCCDCApp.StartGuideScript = ConfigManagement.getString("programsPath", "PHDBrokerGuideStart") ?? @"c:\CCD Commander\auto.vbs"; //FocusMax //objFocusMaxApp = new FocusMax_ExternalApplication(this); //objFocusMaxApp.Name = "FocusMax"; //objFocusMaxApp.FullName = ConfigManagement.getString("programsPath", "FOCUSMAX") ?? @"c:\Program Files (x86)\FocusMax\FocusMax.exe"; //MaxIm_DL objMaxim = new Maxim_ExternalApplication(this); objMaxim.Name = "MaxIm_DL"; objMaxim.FullName = ConfigManagement.getString("programsPath", "MAXIMDL") ?? @"c:\Program Files (x86)\Diffraction Limited\MaxIm DL V5\MaxIm_DL.exe"; //WeatherStation objWSApp = new WeatherStation(); objWSApp.Name = "WeatherStation"; objWSApp.FullName = ConfigManagement.getString("programsPath", "WS") ?? @"C:\Users\Emchenko\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Astromania.info\WeatherStation Monitor.appref-ms"; //TelescopeTempControl objTTCApp = new TelescopeTempControl(); objTTCApp.Name = "TelescopeTempControl"; objTTCApp.FullName = ConfigManagement.getString("programsPath", "TTC") ?? @"C:\Users\Emchenko\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Astromania.info\TelescopeTempControl.appref-ms"; //Astrotortilla objAstroTortilla = new AstroTortilla(); objAstroTortilla.Name = "Astrotortilla"; objAstroTortilla.FullName = ConfigManagement.getString("programsPath", "ASTROTORTILLA") ?? @"c:\Program Files (x86)\AstroTortilla\AstroTortilla.exe"; objAstroTortilla.FullNameAutoIt = ConfigManagement.getString("programsPath", "ASTROTORTILLA_AUTOIT") ?? @"c:\Program Files (x86)\AstroTortilla\astrotortilla_solve.exe"; }
private void btnOk_Click(object sender, EventArgs e) { try { /* * ParentMainForm.ObsControl.MaximDLPath = Properties.Settings.Default.MaximDLPath; * ParentMainForm.ObsControl.CCDAPPath = Properties.Settings.Default.CCDAPPath; * ParentMainForm.ObsControl.PlanetariumPath = Properties.Settings.Default.CartesPath; * * //driver id * ParentMainForm.ObsControl.DOME_DRIVER_NAME = Properties.Settings.Default.DomeDriverId; * ParentMainForm.ObsControl.TELESCOPE_DRIVER_NAME = Properties.Settings.Default.TelescopeDriverId; * ParentMainForm.ObsControl.SWITCH_DRIVER_NAME = Properties.Settings.Default.SwitchDriverId; * * //switch settings * ParentMainForm.ObsControl.POWER_MOUNT_PORT = Convert.ToByte(Properties.Settings.Default.SwitchMountPort); * ParentMainForm.ObsControl.POWER_CAMERA_PORT = Convert.ToByte(Properties.Settings.Default.SwitchCameraPort); * ParentMainForm.ObsControl.POWER_FOCUSER_PORT = Convert.ToByte(Properties.Settings.Default.SwitchFocuserPort); * ParentMainForm.ObsControl.POWER_ROOFPOWER_PORT = Convert.ToByte(Properties.Settings.Default.SwitchRoofPowerPort); * ParentMainForm.ObsControl.POWER_ROOFSWITCH_PORT = Convert.ToByte(Properties.Settings.Default.SwitchRoofSwitchPort); * * ParentMainForm.RoofDuration = Convert.ToInt16(Properties.Settings.Default.RoofDuration); */ if (txtSwitchDriverId.Text != ParentMainForm.ObsControl.ASCOMSwitch.DRIVER_NAME) { ParentMainForm.ObsControl.ASCOMSwitch.DRIVER_NAME = txtSwitchDriverId.Text; ParentMainForm.ObsControl.ASCOMSwitch.Reset(); } if (txtDomeDriverId.Text != ParentMainForm.ObsControl.ASCOMDome.DRIVER_NAME) { ParentMainForm.ObsControl.ASCOMDome.DRIVER_NAME = txtDomeDriverId.Text; ParentMainForm.ObsControl.ASCOMDome.Reset(); } if (txtTelescopeDriverId.Text != ParentMainForm.ObsControl.ASCOMTelescope.DRIVER_NAME) { ParentMainForm.ObsControl.ASCOMTelescope.DRIVER_NAME = txtTelescopeDriverId.Text; ParentMainForm.ObsControl.ASCOMTelescope.Reset(); } //reset automatic duration count if duration was manually changed if (TempRoofDuration != ParentMainForm.RoofDuration) { Properties.Settings.Default.RoofDurationMeasurementsCount = 1; } //Commit changes Properties.Settings.Default.Save(); //Load params into vars ParentMainForm.LoadParams(); //Update XML SaveDataFromGrid(); //Write config file to disk ConfigManagement.Save(); this.Close(); } catch (FormatException ex) { StackTrace st = new StackTrace(ex, true); StackFrame[] frames = st.GetFrames(); string messstr = ""; // Iterate over the frames extracting the information you need foreach (StackFrame frame in frames) { messstr += String.Format("{0}:{1}({2},{3})", frame.GetFileName(), frame.GetMethod().Name, frame.GetFileLineNumber(), frame.GetFileColumnNumber()); } string FullMessage = "Some of the fields has invalid values" + Environment.NewLine; FullMessage += Environment.NewLine + "Hint: look for incorrect decimal point ( \".\" instead of \",\" ) or a accidential letter in textbox"; FullMessage += Environment.NewLine + "Hint 2: clicking in every field could help"; FullMessage += Environment.NewLine + Environment.NewLine + "Debug information:" + Environment.NewLine + "IOException source: " + ex.Data + " " + ex.Message + Environment.NewLine + Environment.NewLine + messstr; MessageBox.Show(this, FullMessage, "Invalid value", MessageBoxButtons.OK); Logging.AddLog(FullMessage, LogLevel.Important, Highlight.Error); } }
/// <summary> /// Main form load event - startup actions take place here /// </summary> private void Form1_Load(object sender, EventArgs e) { //DefBackColor DefBackColor = chkMaxim.BackColor; DefBackColorTextBoxes = txtShortAlt.BackColor; //Load config ConfigManagement.Load(); //Load parameters LoadParams(); //Update interface for current Settings values //IQP_UpdateSettingsDialogFields(); //Init programs objects using loaded settings ObsControl.InitProgramsObj(); //Load parameters after all objects was initialized LoadOtherParamsFromXML(); //Dump log, because interface may hang wating for connection Logging.DumpToFile(); //Connect Devices, which are general adapters (no need to power or control something) try { ObsControl.ASCOMSwitch.Connect = true; ObsControl.ASCOMSwitch.CheckPowerDeviceStatus_async(); } catch (Exception ex) { Logging.AddLog("Error connecting Switch on startup [" + ex.Message + "]", LogLevel.Important, Highlight.Error); Logging.AddLog("Exception details: " + ex.ToString(), LogLevel.Debug, Highlight.Error); } try { ObsControl.ASCOMDome.Connect = true; } catch (Exception ex) { Logging.AddLog("Error connecting Dome on startup [" + ex.Message + "]", LogLevel.Important, Highlight.Error); Logging.AddLog("Exception details: " + ex.ToString(), LogLevel.Debug, Highlight.Error); } //Update visual interface statuses UpdateStatusbarASCOMStatus(); UpdatePowerButtonsStatus(); //init graphic elements ROOF_startPos = rectRoof.Location; //Update visual Roof Status UpdateRoofStatus(); //Start tcp server SocketServer = new SocketServerClass(this); toolStripStatus_Connection.Text = "CONNECTIONS: 0"; if (true) { backgroundWorker_SocketServer.RunWorkerAsync(); toolStripStatus_Connection.ForeColor = Color.Black; } else { toolStripStatus_Connection.ForeColor = Color.Gray; } //init vars //DrawTelescopeV(panelTelescope); //Init versiondata static class //Display about information VersionData.initVersionData(); LoadAboutData(); //Init Log DropDown box foreach (LogLevel C in Enum.GetValues(typeof(LogLevel))) { toolStripDropDownLogLevel.DropDownItems.Add(Enum.GetName(typeof(LogLevel), C)); } toolStripDropDownLogLevel.Text = Enum.GetName(typeof(LogLevel), LogLevel.Activity); //Fill in Combobox Boltwood comboBoxRainFlag.DataSource = Enum.GetNames(typeof(Enum_RainFlag)); comboBoxWetFlag.DataSource = Enum.GetNames(typeof(Enum_WetFlag)); comboBoxCloudCond.DataSource = Enum.GetNames(typeof(Enum_CloudCond)); comboBoxWindCond.DataSource = Enum.GetNames(typeof(Enum_WindCond)); comboBoxRainCond.DataSource = Enum.GetNames(typeof(Enum_RainCond)); comboBoxDaylightCond.DataSource = Enum.GetNames(typeof(Enum_DayCond)); comboBoxRoofCloseFlag.DataSource = Enum.GetNames(typeof(Enum_RoofFlag)); comboBoxAlertFlag.DataSource = Enum.GetNames(typeof(Enum_AlertFlag)); //Run all timers at the end mainTimer_Short.Enabled = true; mainTimer_Long.Enabled = true; mainTimer_VeryLong.Enabled = true; logRefreshTimer.Enabled = true; weatherSmallChart.Series[0].XValueType = ChartValueType.DateTime; weatherSmallChart.ChartAreas["ChartArea1"].AxisX.LabelStyle.Format = "HH:mm"; foreach (Series Sr in chartWT.Series) { Sr.XValueType = ChartValueType.DateTime; } foreach (ChartArea CA in chartWT.ChartAreas) { CA.AxisX.LabelStyle.Format = "HH:mm"; } //FORM APPEARENCE Form_Normal_Width = this.Width; borderWidth = (this.Width - this.ClientSize.Width) / 2; titleBarHeight = this.Height - this.ClientSize.Height - 2 * borderWidth; statusBarHeight = statusBar.Height; prevX = this.Location.X; prevY = this.Location.Y; Form_SwitchTo_Maximum_Mode(); // TEST COMMAND LINE PARAMETERS bool autostart = false; string comport_over = string.Empty; AuxilaryProc.CheckStartParams(out autostart, out comport_over); if (autostart) { this.btnStartAll.PerformClick(); } }