Пример #1
0
        private void analizaATC02()
        {
            String[] fila;
            this.dataGridViewATC02.Rows.Clear();

            fila    = new String[2];
            fila[0] = "Ultima respuesta";
            StringBuilder textoFecha;

            textoFecha = new StringBuilder();


            textoFecha.Append(this.atc02Status.Timestamp.ToLongDateString());
            textoFecha.Append(" ");
            textoFecha.Append(this.atc02Status.Timestamp.ToShortTimeString());

            //Console.WriteLine("timestamp=" + textoFecha.ToString());
            fila[1] = textoFecha.ToString();
            agregaFila(fila);

            fila[0] = "SETFAN";
            fila[1] = this.atc02Status.FanPower.ToString();
            agregaFila(fila);

            fila[0] = "PRITE";
            fila[1] = this.atc02Status.PrimaryTemperature.ToString();
            agregaFila(fila);

            fila[0] = "SECTE";
            fila[1] = this.atc02Status.SecondaryTemperature.ToString();
            agregaFila(fila);

            fila[0] = "BFL";
            fila[1] = this.atc02Status.FocusPosition.ToString();
            agregaFila(fila);

            fila[0] = "FOCSTEP";
            fila[1] = Atc02Xml.BflToFocSetp(this.atc02Status.FocusPosition).ToString();
            agregaFila(fila);

            fila[0] = "AMBTE";
            fila[1] = this.atc02Status.AmbientTemperature.ToString();
            agregaFila(fila);
        }
Пример #2
0
        /// <summary>
        /// Envia el comando "GetXmlStatus" al driver ATC02 de Orbit.
        /// y actualiza la estructura de datos atc02Status
        /// </summary>
        private void refreshATC02XmlStatus()
        {
            String xmlStatus;

            xmlStatus = EnviaMensaje("GetXmlStatus");
            //Console.WriteLine("xmlStatus=");
            //Console.WriteLine(xmlStatus);
            this.atc02Status = new Atc02Xml(xmlStatus);

            if (this.atc02Status.IsFresh())
            {
                this.BackColor = Color.LightGreen;
                this.Text      = "Fits Monitor, ATC02 ok";
            }
            else
            {
                logger.Warn("ATC02 log outdated");
                this.BackColor = Color.Pink;
                this.Text      = "Fits Monitor, check ATC02 (power/driver/log)";
            }
            this.analizaATC02();
        }
Пример #3
0
        /// <summary>
        /// Envia el comando "GetXmlStatus" al driver ATC02 de Orbit.
        /// y actualiza la estructura de datos atc02Status
        /// </summary>
        private void refreshATC02XmlStatus()
        {
            String xmlStatus;

            xmlStatus = this.focuser.AtcStat.ToString();
            Console.WriteLine("xmlStatus=");
            Console.WriteLine(xmlStatus);
            this.atc02Status = new Atc02Xml(xmlStatus);

            if (this.atc02Status.IsFresh())
            {
                this.BackColor = Color.LightGreen;
                this.toolStripStatusLabel1.Text = "ATC02 ok";
            }
            else
            {
                logger.Warn("ATC02 log outdated");
                this.BackColor = Color.Pink;
                this.toolStripStatusLabel1.Text = "Check ATC02 (power/driver/log)";
            }
            this.analizaATC02();
        }
Пример #4
0
        /// <summary>
        /// Modifica el header de un archivo .fits, previo al envio
        /// del archivo a otro servidor.        /// </summary>
        /// <param name="fitsFullPath"></param>
        /// <returns>True si consigue modificar el header del archivo</returns>
        public Boolean CompletaFitsHeader(String fitsFullPath)
        {
            this.refreshATC02XmlStatus();
            if (!this.atc02Status.IsFresh())
            {
                logger.Info("ATC02 sin datos recientes, no se actualizara Archivo fits '" + fitsFullPath + "'");
                return(false);
            }
            FileInfo archivoFitsNuevo;
            int      test;
            int      testLimit;

            test      = 1;
            testLimit = 4;

            archivoFitsNuevo = new FileInfo(fitsFullPath);
            do
            {
                test++;
                if (archivoFitsNuevo.Exists)
                {
                    break;
                }
                else
                {
                    logger.Warn(String.Format("Archivo '{0}'no existe, intento {1} de {2}, esperando 1 segundo.", fitsFullPath, test, testLimit));
                    System.Threading.Thread.Sleep(1000);
                }
            } while (test <= testLimit);
            if (!archivoFitsNuevo.Exists)
            {
                logger.Error(String.Format("Archivo '{0}'no existe.", fitsFullPath));
                return(false);
            }
            Boolean respuesta;

            respuesta = true; // Solo si ocurre alguna excepcion esta variable sera False
            DateTime Ahora;

            Ahora = DateTime.Now;
            Fits fitsFile;

            System.Threading.Thread.Sleep(1000);
            fitsFile = new Fits(fitsFullPath);

            BasicHDU hdu;

            hdu = fitsFile.ReadHDU();
            HeaderCard hcDATE_OBS; // [ISO 8601] UTC date/time of exposure start
            HeaderCard hcEXPOSURE; // [sec] Duration of exposure

            hcDATE_OBS = hdu.Header.FindCard("DATE-OBS");
            hcEXPOSURE = hdu.Header.FindCard("EXPOSURE");
            DateTime dateObs;

            dateObs = DateTime.Parse(hcDATE_OBS.Value); //// [ISO 8601] UTC date/time of exposure start
            Double exposure;                            // [sec] Duration of exposure

            exposure = Double.Parse(hcEXPOSURE.Value);

            TimeSpan vejezFits; // Tiempo Transcurrido entre termino de exposición y el presente

            vejezFits = Ahora.Subtract(dateObs);
            double vejezSegundos;

            vejezSegundos = ((vejezFits.TotalSeconds) - exposure);
            logger.Info("Vejez archivo FITS=" + vejezSegundos + "[segundos].");
            // Si la vejez del archiv Fits es menor a veinte segundos
            // entonces se modifica el encabezado del fits
            // con la información del ATC02
            if (vejezSegundos < 20)
            {
                HeaderCard hcFocStep;
                HeaderCard hcPriTemp;
                HeaderCard hcSecTemp;
                HeaderCard hcAmbTemp;
                HeaderCard hcSetFan;
                logger.Info("Actualizando archivo FITS:" + fitsFullPath);
                hcFocStep = hdu.Header.FindCard("FOCSTEP");
                hcPriTemp = hdu.Header.FindCard("PRITEMP");
                hcSecTemp = hdu.Header.FindCard("SECTEMP");
                hcAmbTemp = hdu.Header.FindCard("AMBTEMP");
                hcSetFan  = hdu.Header.FindCard("SETFAN");
                if (hcFocStep == null)
                {
                    hcFocStep = new HeaderCard("FOCSTEP");
                    hdu.Header.AddCard(hcFocStep);
                }
                if (hcPriTemp == null)
                {
                    hcPriTemp = new HeaderCard("PRITEMP");
                    hdu.Header.AddCard(hcPriTemp);
                }
                if (hcSecTemp == null)
                {
                    hcSecTemp = new HeaderCard("SECTEMP");
                    hdu.Header.AddCard(hcSecTemp);
                }
                if (hcAmbTemp == null)
                {
                    hcAmbTemp = new HeaderCard("AMBTEMP");
                    hdu.Header.AddCard(hcAmbTemp);
                }
                if (hcSetFan == null)
                {
                    hcSetFan = new HeaderCard("SETFAN");
                    hdu.Header.AddCard(hcSetFan);
                }

                hcFocStep.Value = ("" + Atc02Xml.BflToFocSetp(this.atc02Status.FocusPosition));
                hcPriTemp.Value = ("" + this.atc02Status.PrimaryTemperature);
                hcSecTemp.Value = ("" + this.atc02Status.SecondaryTemperature);
                hcAmbTemp.Value = ("" + this.atc02Status.AmbientTemperature);
                hcSetFan.Value  = ("" + this.atc02Status.FanPower);
                System.Threading.Thread.Sleep(4000);
                try
                {
                    hdu.Header.Rewrite();
                }
                catch (Exception)
                {
                    respuesta = false;
                    logger.Error("Error en: hdu.Header.Rewrite();");
                }
            }
            fitsFile.Close();
            // Permitimos al sistema que guarde los cambios en el archivo fits.
            System.Threading.Thread.Sleep(1000);
            return(respuesta);
        }