Ejemplo n.º 1
0
        /// <summary>
        /// The command Prompt for Pisces
        /// </summary>
        public void PiscesPrompt()
        {
            var input = new CommandLineInput(m_interval);

            do
            {
                Console.Write(">");
                var s = Console.ReadLine();
                if (s.Trim() == "")
                {
                    continue;
                }
                input.Read(s);

                if (input.Parameters.Length == 0 && input.SiteList.Length == 1) // get all parameters in database
                {
                    input.Parameters = GetAllParametersForSiteID(input.SiteList[0], m_interval, input.Command == Command.GetQ);
                }

                if (input.Command == Command.Exit)
                {
                    break;
                }

                if (!input.Valid)
                {
                    Console.WriteLine("Error: Invalid Input");
                    continue;
                }



                if (input.Command == Command.Help)
                {
                    Help();
                }

                if (input.Command == Command.Get || input.Command == Command.GetQ)
                {
                    if (input.SiteList.Length == 0)
                    {
                        Console.WriteLine("site is required");
                        continue;
                    }
                    Print(input, m_interval);
                }

                if (input.Command == Command.Date)
                {
                    Console.WriteLine(input.T1.ToString("yyyy-MM-dd"));
                }
                //Console.WriteLine("cmd = " + input.Command);
                //Console.WriteLine("sites = " + String.Join(",", input.SiteList));
                //Console.WriteLine("parameters  = " + String.Join(",", input.Parameters));
            } while (true);
        }
Ejemplo n.º 2
0
        public void PiscesPrompt()
        {
            var input = new CommandLineInput();

            do
            {
                Console.Write("pisces>");
                var s = Console.ReadLine();
                if (s.Trim() == "")
                {
                    continue;
                }
                input.Read(s);


                if (!input.Valid)
                {
                    Console.WriteLine("Error: Invalid Input");
                    continue;
                }

                if (input.Command == Command.Exit)
                {
                    break;
                }

                if (input.Command == Command.Help)
                {
                    Help();
                }

                if (input.Command == Command.Get)
                {
                    if (input.SiteList.Length == 0)
                    {
                        Console.WriteLine("site is required");
                        continue;
                    }
                    Print(input, TimeInterval.Irregular);
                }
                Console.WriteLine("cmd = " + input.Command);
                Console.WriteLine("sites = " + String.Join(",", input.SiteList));
                Console.WriteLine("parameters  = " + String.Join(",", input.Parameters));
            } while (true);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="input"></param> command line input
        /// <param name="interval"></param> time interval
        private void Print(CommandLineInput input, TimeInterval interval)
        {
            var list = CreateSeriesList(input, interval);

            //SeriesListDataTable sTable = new SeriesListDataTable(list, interval);

            //int counter = 0;
            list.Read(input.T1, input.T2);// example for read input

            if (interval == TimeInterval.Daily)
            {
                PrintDaily(list);
            }
            else
            {
                PrintInstant(list);
            }
        }
Ejemplo n.º 4
0
        private void Print(CommandLineInput input, TimeInterval interval)
        {
            var list = CreateSeriesList(input, interval);
            //SeriesListDataTable sTable = new SeriesListDataTable(list, interval);

            int counter = 0;

            foreach (var s in list)
            {
                s.Read(input.T1, input.T2);
                if (s.Count <= 0)
                {
                    continue;
                }
                var pt = s[s.Count - 1];
                if (counter == 0)// print header
                {
                    Console.Write(s.SiteID + "  " + pt.DateTime.ToString("MMM dd hh:mm  "));
                }
                Console.Write("# " + pt.Value.ToString("F2"));
                counter++;
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Create a Series List
        /// </summary>
        /// <param name="input"></param> input from the command line
        /// <param name="interval"></param> time interval
        /// <returns></returns>
        private SeriesList CreateSeriesList(CommandLineInput input, TimeInterval interval)
        {
            List <TimeSeriesName> names = new List <TimeSeriesName>();

            foreach (var cbtt in input.SiteList)
            {
                foreach (var pcode in input.Parameters)
                {
                    string         sInterval = TimeSeriesName.GetTimeIntervalForTableName(interval);
                    TimeSeriesName tn        = new TimeSeriesName(cbtt + "_" + pcode, sInterval);
                    names.Add(tn);
                }
            }



            var tableNames = (from n in names select n.GetTableName()).ToArray();

            var sc = m_db.GetSeriesCatalog("tablename in ('" + String.Join("','", tableNames) + "')");

            SeriesList sList = new SeriesList();

            foreach (var tn in names)
            {
                Series s = new Series();

                s.TimeInterval = interval;
                if (sc.Select("tablename = '" + tn.GetTableName() + "'").Length == 1)
                {
                    s = m_db.GetSeriesFromTableName(tn.GetTableName());
                }
                s.Table.TableName = tn.GetTableName();
                sList.Add(s);
            }
            return(sList);
        }