コード例 #1
0
        /*
         * SCENARION XML FILE HELP
         * 1. Нужно создать секцию с именем сценария <scenarioMain></scenarioMain>
         * 2. Внутри могут размещаться команды или глобальные параметры
         *  Примеры:
         *  <CDC_CONNECT_PAUSE type="parameter" value="2000" />
         *  <WAIT run="true" argument="2000" />
         *  Формат
         *      TYPE:
         *      "command" or omitted    - this is command(will try to run)
         *      type="parameter"        - this is parameter
         *
         *      RUN:
         *      "true" or omitted = run command
         *      "false" = not run
         *
         *      ARGUMENT:
         *      parameter to be passed to command
         * 4. Команды будут выполняться последовательно, если они не параметры и если у них RUN не false
         */

        /// <summary>
        /// Init command interpretator
        /// </summary>
        public void InitComandInterpretator()
        {
            //Internal commands
            CommandParser.Commands.Add("VERSION", new Command((a) => VersionData.getVersionString(), "Get current program version"));            //Pring version
            CommandParser.Commands.Add("HELP", new Command((a) => this.CommandParser.ListCommandsFormated2(), "List all available commands"));   //list of commands
            CommandParser.Commands.Add("WAIT", new Command((a) => this.pauseScenarioExecution(a), "Pause execution for <N> milliseconds", "N")); //Pause execution for ... milliseconds

            //Self control commands
            CommandParser.Commands.Add("OBS_TELESCOPE_CONNECT", new Command((a) => this.OBS_connectTelescope(), "Connect telescope in Observatory control software"));
            CommandParser.Commands.Add("OBS_MINIMIZE", new Command((a) => this.OBS_FormSwitchToShort(), "Switch main form of Observatory control software to minimum mode"));
            CommandParser.Commands.Add("OBS_MAXIMIZE", new Command((a) => this.OBS_FormSwitchToMax(), "Switch main form of Observatory control software to usual (maximum) mode"));

            //Power commands
            CommandParser.Commands.Add("POWER_ON", new Command((a) => this.ASCOMSwitch.PowerMainRelaysOn(), "Power on all switch channels")); //Power Mount, Camera, Focuser
            CommandParser.Commands.Add("POWER_MOUNT_ON", new Command((a) => this.ASCOMSwitch.PowerMountOn(), "Power on mount switch channel"));
            CommandParser.Commands.Add("POWER_MOUNT_OFF", new Command((a) => this.ASCOMSwitch.PowerMountOff(), "Power off mount switch channel"));
            CommandParser.Commands.Add("POWER_CAMERA_ON", new Command((a) => this.ASCOMSwitch.PowerCameraOn(), "Power on camera switch channel"));
            CommandParser.Commands.Add("POWER_CAMERA_OFF", new Command((a) => this.ASCOMSwitch.PowerCameraOff(), "Power off camera switch channel"));
            CommandParser.Commands.Add("POWER_OFF", new Command((a) => this.ASCOMSwitch.PowerMainRelaysOff(), "Power off all switch channel")); //Power Mount, Camera, Focuser


            //MaimDL
            CommandParser.Commands.Add("MAXIM_RUN", new Command((a) => this.startMaximDL(), "Run Maxim DL"));
            CommandParser.Commands.Add("MAXIM_CAMERA_CONNECT", new Command((a) => objMaxim.ConnectCamera(), "Connect camera in Maxim DL"));
            CommandParser.Commands.Add("MAXIM_TELESCOPE_CONNECT", new Command((a) => objMaxim.ConnectTelescope(), "Connect telescope in Maxim DL"));
            CommandParser.Commands.Add("MAXIM_FOCUSER_CONNECT", new Command((a) => objMaxim.ConnectFocuser(), "Connect focuser in Maxim DL"));

            CommandParser.Commands.Add("MAXIM_CAMERA_SETCOOLING", new Command((a) => objMaxim.CameraCoolingOn(), "Switch cooling on and set to def temp"));                                   //switch cooling on and set to def temp
            CommandParser.Commands.Add("CAMERA_SET_COOLER_TEMP", new Command((a) => objMaxim.CameraCoolingChangeSetTemp(a), "switch cooling on and set to specified double <TEMP>", "TEMP")); //switch cooling on and set to specified temp
            CommandParser.Commands.Add("CAMERA_WARMPUP", new Command((a) => objMaxim.CameraCoolingOff(true), "Camera warmp up"));                                                             //warmup


            //FocusMax
            CommandParser.Commands.Add("FOCUSMAX_RUN", new Command((a) => this.startFocusMax(), "Run FocusMax"));

            //Cartes du Ciel
            CommandParser.Commands.Add("CdC_RUN", new Command((a) => this.startPlanetarium(), "Run Cartes du Ciel"));
            CommandParser.Commands.Add("CdC_RUNONLY", new Command((a) => this.startPlanetarium2(), "Run Cartes du Ciel, but don't connect Telescope"));
            CommandParser.Commands.Add("CdC_TELESCOPE_CONNECT", new Command((a) => this.objCdCApp.ConnectTelescope(), "Connect telescope in Cartes du Ciel current chart"));
            CommandParser.Commands.Add("CdC_TELESCOPE_CONNECT1", new Command((a) => this.objCdCApp.ConnectTelescopeInChart1(), "Connect telescope in Cartes du Ciel Chart_1"));
            CommandParser.Commands.Add("CdC_TELESCOPE_CONNECT2", new Command((a) => this.objCdCApp.ConnectTelescopeInChart2(), "Connect telescope in Cartes du Ciel Chart_2"));

            //CCDAP
            CommandParser.Commands.Add("CCDAP_RUN", new Command((a) => this.startCCDAP(), "Run CCDAutopilot"));

            //CCDC
            CommandParser.Commands.Add("CCDC_RUN", new Command((a) => this.startCCDC(), "Run CCDCommander"));

            //PHD2 related commands
            CommandParser.Commands.Add("PHD2_RUN", new Command((a) => this.startPHD2(), "Run PHD2"));
            CommandParser.Commands.Add("PHD2_CONNECT", new Command((a) => this.objPHD2App.CMD_ConnectEquipment2(), "Connect equipment in PHD2"));
            CommandParser.Commands.Add("PHDBROKER_RUN", new Command((a) => this.startPHDBroker(), "Run PHD Broker"));

            //IQP commands
            CommandParser.Commands.Add("IQP_START", new Command((a) => this.startIQP(), "Start built-in IQP monitoring"));

            //SOLVER
            CommandParser.Commands.Add("ASPS_SOLVE", new Command((a) => this.startASPS_Solve(), "Run All Sky Plate Solver and try to solve&sync current telescope position"));


            //WS commands
            CommandParser.Commands.Add("WS_RUN", new Command((a) => this.startWS(), "Run WeatherStation monitor"));

            //TTC commands
            CommandParser.Commands.Add("TTC_RUN", new Command((a) => this.startTTC(), "Run TelescopeTempControl"));
            CommandParser.Commands.Add("TTC_GETDATA", new Command((a) => this.objTTCApp.CMD_GetJSONData().ToString(), "Query data from TTC"));
            CommandParser.Commands.Add("TTC_FANAUTO_ON", new Command((a) => this.objTTCApp.CMD_SetFANControl_ON(), "Switch main mirror cooling fan on and set control to auto"));
            CommandParser.Commands.Add("TTC_FANAUTO_OFF", new Command((a) => this.objTTCApp.CMD_SetFANControl_OFF(), "Switch main mirror cooling fan off"));
            CommandParser.Commands.Add("TTC_HEATERAUTO_ON", new Command((a) => this.objTTCApp.CMD_SetHeaterControl_ON(), "Switch secondary mirror heater on and set control to auto"));
            CommandParser.Commands.Add("TTC_HEATERAUTO_OFF", new Command((a) => this.objTTCApp.CMD_SetHeaterControl_OFF(), "Switch secondary mirror heater off"));
            CommandParser.Commands.Add("TTC_SETFANPWR", new Command((a) => this.objTTCApp.CMD_SetFanPWR(a), "Switch main mirror cooling fan speed to N", "N [0..255]"));
            CommandParser.Commands.Add("TTC_SETHEATERPWR", new Command((a) => this.objTTCApp.CMD_SetHeaterPWR(a), "Switch secondary mirror heater power to N", "N [0..255]"));

            //Complex commmands
            CommandParser.Commands.Add("IMAGING_RUN_PAUSE", new Command((a) => this.ImagingRun_Pause(), "Pause current imaging run, i.e. send pause command to CCDC through boltwood interface"));
            CommandParser.Commands.Add("IMAGING_RUN_RESUME", new Command((a) => this.ImagingRun_Resume(), "Resume current imaging run, i.e. release pause through boltwood interface"));
            CommandParser.Commands.Add("IMAGING_RUN_ABORT", new Command((a) => this.ImagingRun_Abort(), "Abort current image run. i.e. send pause command to CCDC through boltwood interface and engage camera warmup"));
            CommandParser.Commands.Add("IMAGING_RUN_ABORT_CANCEL", new Command((a) => this.ImagingRun_CancelAbort(), "Cancel aborting current image run. i.e. send resume command to CCDC through boltwood interface and set camera cooling"));

            //CommandParser.Commands.Add("IMAGING_RUN_ABORT_ASYNC", (a) => this.ImagingRun_Abort_async());
            //CommandParser.Commands2.Add("IMAGING_RUN_ABORT_ASYNC", new Command((a) => this.ImagingRun_Abort_async(), "Abort current image run (async mode). i.e. send pause command to CCDC through boltwood interface and engage camera warmup"));
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: dingxu6207/xingtuan
        /// <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();
            }
        }