Ejemplo n.º 1
0
        private async Task <string> ObtainLastImageCC()
        {
            string retStr = "";

            if (!Directory.Exists(ConcurrentDataXMLfilesBasePath))
            {
                throw new DirectoryNotFoundException("unable to locate directory: " + ConcurrentDataXMLfilesBasePath);
            }

            DirectoryInfo   dir           = new DirectoryInfo(ConcurrentDataXMLfilesBasePath);
            List <FileInfo> lXMLFilesInfo =
                dir.GetFiles(ConventionalTransitions.ImageProcessedAndPredictedDataFileNamesPattern(),
                             SearchOption.AllDirectories).ToList();

            if (lXMLFilesInfo.Count == 0)
            {
                return("No snapshots has been analyzed yet. Please wait for a couple of minutes.");
            }

            lXMLFilesInfo.Sort((finfo1, finfo2) => finfo1.CreationTimeUtc.CompareTo(finfo2.CreationTimeUtc));

            SkyImagesProcessedAndPredictedData data = null;

            try
            {
                data =
                    (SkyImagesProcessedAndPredictedData)
                    ServiceTools.ReadObjectFromXML(lXMLFilesInfo.Last().FullName,
                                                   typeof(SkyImagesProcessedAndPredictedData));
            }
            catch (Exception ex)
            {
                throw ex;
            }

            if (data != null)
            {
                retStr += "Please note that this finction is still in BETA version!" + Environment.NewLine +
                          "date of snapshot analyzed (UTC): " + data.imageShootingDateTimeUTC.ToString("u") +
                          Environment.NewLine +
                          "Sun disk condition: " + data.PredictedSDC.ToString() + Environment.NewLine +
                          "Total cloud cover: " + data.PredictedCC.CloudCoverTotal + " (of 8)";
            }


            return(retStr);
        }
        private async Task <string> ReadCurrentCCinfo()
        {
            string retStr = "";

            if (!Directory.Exists(DataStoreDirectory))
            {
                throw new DirectoryNotFoundException("unable to locate directory: " + DataStoreDirectory);
            }

            DirectoryInfo   dir           = new DirectoryInfo(DataStoreDirectory);
            List <FileInfo> lXMLFilesInfo =
                dir.GetFiles(ConventionalTransitions.ImageProcessedAndPredictedDataFileNamesPattern(),
                             SearchOption.AllDirectories).ToList();

            if (lXMLFilesInfo.Count == 0)
            {
                return("No snapshots has been analyzed yet. Please wait for a couple of minutes.");
            }

            lXMLFilesInfo.Sort((finfo1, finfo2) => finfo1.CreationTimeUtc.CompareTo(finfo2.CreationTimeUtc));

            SkyImagesProcessedAndPredictedData data = null;

            try
            {
                data =
                    (SkyImagesProcessedAndPredictedData)
                    ServiceTools.ReadObjectFromXML(lXMLFilesInfo.Last().FullName,
                                                   typeof(SkyImagesProcessedAndPredictedData));
            }
            catch (Exception ex)
            {
                throw ex;
            }

            if (data != null)
            {
                retStr += "Please note that this finction is still in BETA version!" + Environment.NewLine +
                          "date of snapshot analyzed (UTC): " + data.imageShootingDateTimeUTC.ToString("u") +
                          Environment.NewLine +
                          "Sun disk condition: " + data.PredictedSDC.ToString() + Environment.NewLine +
                          "Total cloud cover: " + data.PredictedCC.CloudCoverTotal + " (of 8)" + Environment.NewLine +
                          Environment.NewLine +
                          "SDC predictions probabilities:" + Environment.NewLine;

                string strToShowSDCs = Environment.NewLine +
                                       "|  NoSun  |  Sun0   |  Sun1   |  Sun2   |" + Environment.NewLine + "" +
                                       "|" +
                                       String.Format("{0,9}",
                                                     (data.sdcDecisionProbabilities.First(
                                                          prob => prob.sdc == SunDiskCondition.NoSun).sdcDecisionProbability * 100.0d)
                                                     .ToString("F2") + "%") + "|" +
                                       String.Format("{0,9}",
                                                     (data.sdcDecisionProbabilities.First(
                                                          prob => prob.sdc == SunDiskCondition.Sun0).sdcDecisionProbability * 100.0d)
                                                     .ToString("F2") + "%") + "|" +
                                       String.Format("{0,9}",
                                                     (data.sdcDecisionProbabilities.First(
                                                          prob => prob.sdc == SunDiskCondition.Sun1).sdcDecisionProbability * 100.0d)
                                                     .ToString("F2") + "%") + "|" +
                                       String.Format("{0,9}",
                                                     (data.sdcDecisionProbabilities.First(
                                                          prob => prob.sdc == SunDiskCondition.Sun2).sdcDecisionProbability * 100.0d)
                                                     .ToString("F2") + "%") + "|";
                retStr += strToShowSDCs;
            }


            return(retStr);
        }