Пример #1
0
        public FlatMan()
        {
            SessionControl openSession = new SessionControl();

            Port = openSession.FlatManComPort;
            return;
        }
Пример #2
0
        private Flat GetLeastRotatedFlat()
        {
            //Get the current rotation position, if any
            SessionControl openSession = new SessionControl();
            double         nowRotAngle = 0;

            if (openSession.IsRotationEnabled)
            {
                nowRotAngle = Rotator.RealRotatorPA;
            }

            //Get the list of flat requests
            List <Flat> flatSet = GetFlats();

            //Create a return Flat and set to first of the flat set, return null if none
            if (flatSet.Count == 0)
            {
                return(null);
            }
            Flat flatOut = flatSet[0];

            foreach (Flat flt in flatSet)
            {
                if ((Math.Abs(flatOut.RotationPA - nowRotAngle)) > (Math.Abs(flt.RotationPA - nowRotAngle)))
                {
                    flatOut = flt;
                }
            }
            return(flatOut);
        }
Пример #3
0
        private void WeatherCheck_CheckedChanged(object sender, System.EventArgs e)
        {
            //If WeatherCheck is checked, now, then open the file dialog to pick up
            //  the location of the weather data file, then store it
            SessionControl openSession = new SessionControl();

            if (WeatherCheckBox.Checked && (!optionsFormInit))
            {
                DialogResult weatherFilePath = WeatherFileDialog.ShowDialog();
                openSession.WeatherDataFilePath = WeatherFileDialog.FileName;
            }
            //Check to see if the Weather file is valid
            WeatherReader wrf = new WeatherReader(openSession.WeatherDataFilePath);

            if (wrf.IsWeatherValid())
            {
                openSession.IsWeatherEnabled   = WeatherCheckBox.Checked;
                settings.WeatherMonitorEnabled = WeatherCheckBox.Checked;
            }
            else
            {
                MessageBox.Show("Invalid Weather Data File");
                openSession.IsWeatherEnabled   = false;
                settings.WeatherMonitorEnabled = false;
                WeatherCheckBox.Checked        = false;
            }
        }
Пример #4
0
        private void DomeHomeAz_ValueChanged(object sender, EventArgs e)
        {
            SessionControl openSession = new SessionControl();

            openSession.DomeHomeAz = (int)DomeHomeAz.Value;
            return;
        }
Пример #5
0
        public void UpdateFormFromPlan()
        {//Update form fields with the content of a new target plan from the session control file
            SessionControl openSession = new SessionControl();
            TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName);

            if (tPlan.TargetName == "Default")
            {
                TargetBox.Text = "";
            }
            else
            {
                TargetBox.Text = tPlan.TargetName;
            }

            StartTimeBox.Value        = tPlan.SequenceStartTime;
            TargetRABox.Text          = tPlan.TargetRA.ToString();
            TargetDecBox.Text         = tPlan.TargetDec.ToString();
            TargetPABox.Text          = tPlan.TargetPA.ToString();
            AutoDarkCheck.Checked     = tPlan.AutoDarkEnabled;
            MakeFlatsCheckBox.Checked = tPlan.MakeFlatsEnabled;
            ExposureVal.Value         = (decimal)tPlan.ImageExposureTime;
            LoopsVal.Value            = tPlan.Loops;
            LRGBRatioBox.Value        = tPlan.LRGBRatio;
            DelayVal.Value            = (decimal)tPlan.Delay;
            if (tPlan.TargetAdjustEnabled)
            {
                AdjustedTargetLabel.Visible = true;
            }
            else
            {
                AdjustedTargetLabel.Visible = false;
            }
        }
Пример #6
0
        private void AttendedCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            SessionControl openSession = new SessionControl();

            openSession.IsAttended = AttendedCheckBox.Checked;
            return;
        }
Пример #7
0
        //Method for initiating log event as called from form or class that wants to raise it
        public void LogIt(string logline)
        {
            //Gets the current date/time
            //Creates a new log file, if  not created
            //Opens log file and appends date-time, log line and crlf
            //Closes log file
            //Raises a log event for anyone who is listening

            SessionControl openSession = new SessionControl();
            string         logdirpath  = openSession.HumasonDirectoryPath + "\\Logs";

            if (!Directory.Exists(logdirpath))
            {
                Directory.CreateDirectory(logdirpath);
            }
            string logdate     = DateTime.Now.ToString("yyyy-MM-dd");
            string logtime     = DateTime.Now.ToString("HH:mm:ss");
            string logfilepath = logdirpath + "\\" + logdate + ".log";

            if (!File.Exists(logfilepath))
            {
                StreamWriter sfw = File.CreateText(logfilepath);
                sfw.Close();
            }
            File.AppendAllText(logfilepath, (logtime + " " + logline + "\r\n"));
            //LogEntry(logline);
            FormHumason.StatusReportEvent.LogEntry(logline);
            System.Windows.Forms.Application.DoEvents();
            return;
        }
Пример #8
0
        public static bool IsTimeToShutDown()
        {
            // CheckEnd gets the configured end time and returns true
            //   if the datetime exceeds the end time
            // this is intended to be used to periodically check if
            // a photoshoot has lasted past the configured shutdown time
            SessionControl openSession = new SessionControl();

            if (openSession.IsAutoRunEnabled && openSession.IsShutDownEnabled)
            {
                DateTime endTime = openSession.ShutDownTime;
                if (endTime < DateTime.Now)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Пример #9
0
        private void FindStarButton_Click(object sender, EventArgs e)
        {
            NHUtil.ButtonRed(FindStarButton);

            SessionControl openSession = new SessionControl();
            TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName);

            bool fsbresult = AutoGuide.SetAutoGuideStar();

            //if there is an error, then assume that the exposure is just too low
            // reset the guide exposure to maximum and try again
            if (!fsbresult)
            {
                tPlan.GuideExposure        = tPlan.MaximumGuiderExposure;
                GuideExposureTimeBox.Value = (decimal)tPlan.MaximumGuiderExposure;
                fsbresult = AutoGuide.SetAutoGuideStar();
            }
            //If it worked this time then update the guide star position, otherwise just leave it
            if (fsbresult)
            {
                GuideStarXBox.Text = Convert.ToInt32(tPlan.GuideStarX).ToString();
                GuideStarYBox.Text = Convert.ToInt32(tPlan.GuideStarY).ToString();
            }
            NHUtil.ButtonGreen(FindStarButton);
        }
Пример #10
0
        private void AutoGuideOnButton_Click(object sender, EventArgs e)
        {
            //Execute TSX_AutoGuide class
            //  Open and connect to autoguider
            //  if (not calibrated,) { abort
            //  Find guidestar
            //  Turn on Autoguide
            SessionControl openSession = new SessionControl();
            TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName);

            if (NHUtil.IsButtonRed(AutoGuideOnButton))
            {
                AutoGuide.AutoGuideStop();
                AutoGuideOnButton.Text = "Start\r\nAutoguiding";
                NHUtil.ButtonGreen(AutoGuideOnButton);
            }
            else
            {
                //First, save the guider cycle time and anything else in the future that might be hanging around
                tPlan.GuiderCycleTime = (double)GuiderCycleTimeNum.Value;
                if (tPlan.DitherEnabled)
                {
                    AutoGuide.DitherAndStart();
                }
                else
                {
                    AutoGuide.AutoGuideStart();
                }
                AutoGuideOnButton.Text = "Stop\r\nAutoguiding";
                NHUtil.ButtonRed(AutoGuideOnButton);
            }
        }
Пример #11
0
        public static bool RotateToImagePA(double tgtImagePA)
        {
            //Move the rotator to a position that gives an image position angle of tImagePA
            //  Assumes that a plate solve has been performed, and/or rotator position angle variables
            //  are current
            //Returns false if failure, true if good

            SessionControl openSession = new SessionControl();
            TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName);

            TSXLink.Rotator trot   = new TSXLink.Rotator();
            int             rotDir = Convert.ToInt32(openSession.RotatorDirection);

            //Plate solve for current PA
            if (!PlateSolveIt())
            {
                return(false);
            }
            //target rotation PA = current image PA + current rotator PA - target image PA
            // double tgtRotationPA = ((startImagePA - endImagePA) * rotdir) + rotPA;
            double destRotationPA           = ((ImagePA - tgtImagePA) * -rotDir) + AstroMath.Transform.NormalizeDegreeRange(RealRotatorPA);
            double destRotationPAnormalized = AstroMath.Transform.NormalizeDegreeRange(destRotationPA);

            trot.SetRotatorPositionAngle(destRotationPAnormalized);
            //Plate solve for current PA
            if (!PlateSolveIt())
            {
                return(false);
            }
            return(true);
        }
Пример #12
0
        public void UploadDevicesConfiguration()
        {
            SessionControl openSession = new SessionControl();
            TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName)
            {
                AutoGuideEnabled      = AutoguideCheck.Checked,
                RotatorEnabled        = RotatorCheckBox.Checked,
                DitherEnabled         = DitherCheck.Checked,
                GuiderAutoDarkEnabled = GuiderAutoDarkCheckBox.Checked,
                AutoFocusEnabled      = AutofocusCheck.Checked,
                CalibrateEnabled      = CalibrateCheck.Checked,
                ResyncEnabled         = ResyncCheck.Checked,
                CameraTemperatureSet  = (double)CameraTemperatureSet.Value
            };

            openSession.RefocusAtTemperatureDifference = (double)RefocustTemperatureChangeBox.Value;
            if (AtFocus2RadioButton.Checked)
            {
                tPlan.AtFocusSelect = 2;
            }
            else
            {
                tPlan.AtFocusSelect = 3;
            }
        }
Пример #13
0
        private void ToTSXButton_Click(object sender, EventArgs e)
        {
            //Tries to look up the name in the target box.  If found, then a new target plan is
            //opened.  Disconnect the telescope (in case centering is forced), use the target box to find
            //and and center the star chart and FOV on the target.
            //If not throw a log entry and return;
            //Remove spaces from target name if any
            //PlanTargetBox.Text = PlanTargetBox.Text.Replace(" ", "");
            LogEvent       lg          = new LogEvent();
            SessionControl openSession = new SessionControl();

            NHUtil.ButtonRed(SelectButton);
            TSXLink.Target tgt = TSXLink.StarChart.FindTarget(PlanTargetBox.Text);
            if (tgt != null)
            {
                TSXLink.Connection.DisconnectDevice(TSXLink.Connection.Devices.Mount);
                TargetPlan newtPlan = new TargetPlan(tgt.Name);
                newtPlan.TargetPA            = TSXLink.FOVI.GetFOVPA;
                newtPlan.TargetAdjustEnabled = false;
                PlanTargetBox.Text           = newtPlan.TargetName;
                TSXLink.StarChart.SetFOV(2);
                LoadTargetPlanList();
                openSession.CurrentTargetName = newtPlan.TargetName;
                lg.LogIt("A new target plan has been created for " + newtPlan.TargetName);
            }
            else
            {
                lg.LogIt(PlanTargetBox.Text + ": target not found.");
            }
            NHUtil.ButtonGreen(SelectButton);
            Show();
        }
Пример #14
0
        public void LoadNewTargetPlan(string tname)
        {
            //sets up a target plan for the session.
            //If that target plan file does not have enough entries (e.g. from Image Planner)
            //then merge the default target file into it.  Update the other forms with the new
            //target plan fields.  lthen reload the target plan list.

            SessionControl openSession = new SessionControl();

            openSession.CurrentTargetName = tname;
            TargetPlan tPlan = new TargetPlan(tname);

            if (tPlan.IsSparsePlan())
            {
                tPlan.FlushOutFromDefaultPlan();
            }

            UpdateHumasonSequencer();
            try //If there are problems in the target plan file, this is where they show up
            {
                FormHumason.fDeviceForm.ResetConfiguration();
                FormHumason.fFocusForm.ResetConfiguration();
                FormHumason.fGuideForm.ResetConfiguration();
            }
            catch { } //ignore them
            PlanTargetBox.Text = tname;
            //Update the small solar system enabled field, if any
            SolarSystemBodyCheckBox.Checked = tPlan.SmallSolarSystemBodyEnabled;
            //Reload the target plan list
            LoadTargetPlanList();
        }
Пример #15
0
        public static void SaveFlatImage(string targetName, string filterName, string targetPA, string sidePoint)
        {
            //The NH image directory originates from the SetUp form and stored in the
            //Configuration file.
            LogEvent       lg          = new LogEvent();
            SessionControl openSession = new SessionControl();
            TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName);
            //Get Humason directory name, create image directory if it doesn't exist yet
            string nhDirName      = openSession.HumasonDirectoryPath;
            string nhImageDirName = nhDirName + "\\Images";

            if (!Directory.Exists(nhImageDirName))
            {
                Directory.CreateDirectory(nhImageDirName);
            }
            //Create date name for image sub-directory, create if it doesn't exist yet
            DateTime sequenceStartDate = tPlan.SequenceStartTime;
            string   targetImageDir    = nhImageDirName + "\\" + sequenceStartDate.ToString("yyyyMMdd");

            if (!Directory.Exists(targetImageDir))
            {
                Directory.CreateDirectory(targetImageDir);
            }
            //Create Data Files directory if it doesn't exit yet
            string targetImageDataDir = targetImageDir + "\\Calibration Files";

            if (!Directory.Exists(targetImageDataDir))
            {
                Directory.CreateDirectory(targetImageDataDir);
            }

            //Reduce target PA to integer string, i.e. scrape off the decimal
            targetPA = (Convert.ToDouble(targetPA)).ToString("0");
            string targetImageDataPath = targetImageDataDir + "\\" +
                                         filterName +
                                         targetName +
                                         "_" +
                                         targetPA +
                                         "PA" +
                                         sidePoint +
                                         "." +
                                         openSession.SequentialFileNumber.ToString() +
                                         ".fit";
            //open TSX camera and get the last image
            ccdsoftImage tsxi      = new ccdsoftImage();
            int          camStatus = tsxi.AttachToActiveImager();

            //save handling an exception here until some future date
            tsxi.setFITSKeyword("OBJECT", "Humason Flat Field");
            AstroImage tsxc = new AstroImage();

            if (tPlan.RotatorEnabled)
            {
                tsxi.setFITSKeyword("ROTATOR", Rotator.RealRotatorPA.ToString());
            }
            //Set save path and save
            tsxi.Path = targetImageDataPath;
            tsxi.Save();
            lg.LogIt("Flat saved: " + targetImageDataPath);
        }
Пример #16
0
        public static void RunShutDownApp()
        {
            //If ShutDownOn is set, then RunShutDown gets the postscan filepath from the Humason config file, if any
            //  then launches it and waits for completion.

            SessionControl openSession = new SessionControl();
            Process        pSystemExe  = new Process();

            if (openSession.ShutDownFilePath != null)
            {
                LogEvent lg = new LogEvent();
                lg.LogIt("Running Shut Down Process");
                pSystemExe.StartInfo.FileName = openSession.ShutDownFilePath;
                try
                {
                    pSystemExe.Start();
                    if (openSession.IsShutDownWaitEnabled)
                    {
                        pSystemExe.WaitForExit();
                    }
                }
                catch { }
                lg.LogIt("Shut Down Process Complete");
            }
            return;
        }
Пример #17
0
 private void ClearFilterNum_ValueChanged(object sender, EventArgs e)
 {
     SessionControl openSession = new SessionControl();
     TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName)
     {
         ClearFilter = (int)ClearFilterNum.Value
     };
 }
Пример #18
0
        private void DomeAddOnCheckBox_CheckedChanged(object sender, System.EventArgs e)
        {
            SessionControl openSession = new SessionControl();

            openSession.IsDomeAddOnEnabled = DomeAddOnCheckBox.Checked;
            settings.HasDomeAddOn          = DomeAddOnCheckBox.Checked;
            return;
        }
Пример #19
0
 private void GuiderAutoDarkCheckBox_CheckedChanged(object sender, EventArgs e)
 {
     SessionControl openSession = new SessionControl();
     TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName)
     {
         GuiderAutoDarkEnabled = GuiderAutoDarkCheckBox.Checked
     };
 }
Пример #20
0
 private void SubframeCheckBox_CheckedChanged_1(object sender, EventArgs e)
 {
     SessionControl openSession = new SessionControl();
     TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName)
     {
         GuiderSubframeEnabled = SubframeCheckBox.Checked
     };
 }
Пример #21
0
        private void StartTimeBox_ValueChanged(object sender, EventArgs e)
        {
            //Save to Session
            SessionControl openSession = new SessionControl();
            TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName);

            tPlan.SequenceStartTime = StartTimeBox.Value;
        }
Пример #22
0
 private void YAxisMoveTime_ValueChanged(object sender, EventArgs e)
 {
     SessionControl openSession = new SessionControl();
     TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName)
     {
         YAxisMoveTime = (double)YAxisMoveTime.Value
     };
 }
Пример #23
0
 private void GuideStarADUNum_ValueChanged(object sender, EventArgs e)
 {
     SessionControl openSession = new SessionControl();
     TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName)
     {
         GuideStarADU = (Int32)GuideStarADUNum.Value
     };
 }
Пример #24
0
 private void Binning2x2RadioButton_CheckedChanged(object sender, EventArgs e)
 {
     SessionControl openSession = new SessionControl();
     TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName)
     {
         GuiderBinning = 2
     };
 }
Пример #25
0
 private void MinimumGuideExposureTimeBox_ValueChanged(object sender, EventArgs e)
 {
     SessionControl openSession = new SessionControl();
     TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName)
     {
         MinimumGuiderExposure = (double)MinimumGuideExposureTimeBox.Value
     };
 }
Пример #26
0
 private void AOCheck_CheckedChanged(object sender, EventArgs e)
 {
     SessionControl openSession = new SessionControl();
     TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName)
     {
         AOEnabled = AOCheckBox.Checked
     };
 }
Пример #27
0
        private void Rotator_CheckedChanged(object sender, System.EventArgs e)
        {
            //Record the rotator device control selection in the session control file
            //  and to the settings
            SessionControl openSession = new SessionControl();

            openSession.IsRotationEnabled = RotatorCheckBox.Checked;
            settings.RotatorDeviceEnabled = RotatorCheckBox.Checked;
        }
Пример #28
0
 private void CameraTemperatureSet_ValueChanged(object sender, EventArgs e)
 {
     //Store it in the configuration and move on
     SessionControl openSession = new SessionControl();
     TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName)
     {
         CameraTemperatureSet = (double)CameraTemperatureSet.Value
     };
 }
Пример #29
0
 private void ResyncCheck_CheckedChanged(object sender, EventArgs e)
 {
     //Store it in the configuration and move on
     SessionControl openSession = new SessionControl();
     TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName)
     {
         ResyncEnabled = ResyncCheck.Checked
     };
 }
Пример #30
0
        public FlatManager()
        {
            //Create the folder path for the base folder.
            SessionControl openSession = new SessionControl();

            nhDir = openSession.HumasonDirectoryPath;
            //Create the flats request xml file, if it doesn't exist
            fReq = new Axess(nhDir + "\\" + HumasonFlatStackFilename, HumasonFlatsXCName);
        }