当前位置: 首页>>代码示例>>C#>>正文


C# TimeSeries.AddTimeSeries方法代码示例

本文整理汇总了C#中TimeSeries.AddTimeSeries方法的典型用法代码示例。如果您正苦于以下问题:C# TimeSeries.AddTimeSeries方法的具体用法?C# TimeSeries.AddTimeSeries怎么用?C# TimeSeries.AddTimeSeries使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TimeSeries的用法示例。


在下文中一共展示了TimeSeries.AddTimeSeries方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: JoinButton_Click

        private void JoinButton_Click(object sender, EventArgs e)
        {
            try
             {
            if (TimeseriesList.Items.Count <= 0)
               throw new GeneralException("No timeseries to join were defined.", ExceptionType.WARNING);

            if (string.IsNullOrWhiteSpace(OutputTimeseriesTextbox.Text))
               throw new GeneralException("You must define the output timeseries.", ExceptionType.WARNING);
            else
            {
               try
               {
                  output.FullPath = OutputTimeseriesTextbox.Text;

                  if (!System.IO.Directory.Exists(output.Path))
                     throw new GeneralException("The path '" + output.Path + "' doesn't exist.", ExceptionType.WARNING);
                  else if (System.IO.File.Exists(output.FullPath))
                  {
                     if (MessageBox.Show("The file '" + output.FullName + "' exists. Do you want to OVERWRITE it?", "WARNING", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No)
                        return;
                  }
               }
               catch (GeneralException)
               {
                  throw;
               }
               catch (Exception ex)
               {
                  throw new GeneralException(ex.Message, ExceptionType.ERROR);
               }
            }

            FileName file = new FileName();
            List<TimeSeries> timeSeries = new List<TimeSeries>();

            foreach (object ts in TimeseriesList.Items)
            {
               file.FullPath = (string)ts;
               TimeSeries newTS = new TimeSeries();
               newTS.Load(file);
               timeSeries.Add(newTS);
            }

            DateTime start = timeSeries[0].StartInstant;
            for (int i = 1; i < timeSeries.Count; i++)
            {
               if (timeSeries[i].StartInstant < start)
                  start = timeSeries[i].StartInstant;
            }

            TimeSeries outTS = new TimeSeries();
            outTS.StartInstant = start;
            outTS.TimeUnits = (TimeUnits)Enum.Parse(typeof(TimeUnits), (string)TimeUnitsCombobox.SelectedItem, true);

            foreach (Column col in timeSeries[0].Columns)
            {
               Column newCol = new Column(col.ColumnType);
               newCol.Header = col.Header;
               outTS.AddColumn(newCol);
            }

            foreach (TimeSeries toJoin in timeSeries)
               outTS.AddTimeSeries(toJoin);

            output.FullPath = OutputTimeseriesTextbox.Text;

            outTS.Save(output);
            MessageBox.Show("Proccess Completed.");
             }
             catch (GeneralException gex)
             {
            switch (gex.Type)
            {
               case ExceptionType.ERROR:
                  MessageBox.Show(gex.Message, "ERROR", MessageBoxButtons.OK);
                  break;
               case ExceptionType.WARNING:
                  MessageBox.Show(gex.Message, "WARNING", MessageBoxButtons.OK);
                  break;
               default:
                  MessageBox.Show("An unknown error happened. The message returned was: " + gex.Message, "ERROR", MessageBoxButtons.OK);
                  break;
            }
             }
             catch (Exception ex)
             {
            MessageBox.Show("An unknown error happened. The message returned was: " + ex.Message, "ERROR", MessageBoxButtons.OK);
             }
        }
开发者ID:JauchOnGitHub,项目名称:csharptoolbox,代码行数:90,代码来源:JoinTimeseriesByFileForm.cs

示例2: Main

        static void Main(string[] args)
        {
            string stepMessage = "";
             FileName outputFileName;

             try
             {
            stepMessage = "command line arguments loading.";
            CmdArgs cmdArgs = new CmdArgs(args);

            if (cmdArgs.HasParameter("cfg"))
            {
               stepMessage = "configuration file loading.";
               Config conf = new Config(cmdArgs.Parameters["cfg"]);
               conf.Load();

               stepMessage = "configuration file parsing.";
               ConfigNode nodeList = conf.Root.ChildNodes.Find(delegate(ConfigNode node){ return node.Name == "timeseries.to.join"; });
               if (nodeList == null)
                  throw new Exception("Block 'timeseries.to.join' is missing.");
               outputFileName = conf.Root["output.file.name", "output.tsr"].AsFileName();

               TimeUnits timeUnits = (TimeUnits) Enum.Parse(typeof(TimeUnits), conf.Root["time.units", "seconds"].AsString(), true);

               List<FileName> list = new List<FileName>();
               foreach (KeyValuePair<string, KeywordData> item in nodeList.NodeData)
                  list.Add(item.Value.AsFileName());

               if (list.Count <= 1)
                  throw new Exception("Block 'timeseries.to.join' must contain at least 2 entries");

               stepMessage = "loading timeseries.";
               List<TimeSeries> timeSeries = new List<TimeSeries>();

               foreach(FileName ts in list)
               {
                  TimeSeries newTS = new TimeSeries();
                  newTS.Load(ts);
                  timeSeries.Add(newTS);
               }

               DateTime start = timeSeries[0].StartInstant;
               for (int i = 1; i < timeSeries.Count; i++)
               {
                  if (timeSeries[i].StartInstant < start)
                     start = timeSeries[i].StartInstant;
               }

               stepMessage = "creating output timeseries.";
               TimeSeries outTS = new TimeSeries();
               outTS.StartInstant = start;
               outTS.TimeUnits = timeUnits;

               foreach (Column col in timeSeries[0].Columns)
               {
                  Column newCol = new Column(col.ColumnType);
                  newCol.Header = col.Header;
                  outTS.AddColumn(newCol);
               }

               foreach (TimeSeries toJoin in timeSeries)
                  outTS.AddTimeSeries(toJoin);

               stepMessage = "saving output timeseries.";
               outTS.Save(outputFileName);

               Console.WriteLine("Process complete with success.");
            }
            else
            {
               Console.WriteLine("Parameter --cfg is missing.");
               Console.WriteLine("Execution aborted.");
               return;
            }
             }
             catch (Exception ex)
             {
            Console.WriteLine("An exception was raised while {0}", stepMessage);
            Console.WriteLine("Exception message: {0}", ex.Message);
             }
        }
开发者ID:JauchOnGitHub,项目名称:csharptoolbox,代码行数:81,代码来源:Program.cs

示例3: JoinTimeseriesByFolder

        protected void JoinTimeseriesByFolder(FileName output, string filter, List<FilePath> folders_to_search, bool search_sub_folders = true, bool overwrite = true, TimeUnits tu = TimeUnits.SECONDS)
        {
            try
             {
            if (folders_to_search == null || folders_to_search.Count <= 0)
               throw new Exception("No folders to search timeseries were defined.");

            if (string.IsNullOrWhiteSpace(output.FullPath))
               throw new Exception("No timeseries output was defined");

            if (!System.IO.Directory.Exists(output.Path))
               throw new Exception("The path '" + output.Path + "' doesn't exist.");

            if (System.IO.File.Exists(output.FullPath) && !overwrite)
               throw new Exception("The file '" + output.FullName + "' exists and overwrite is set to false.");

            if (string.IsNullOrWhiteSpace(filter))
               throw new Exception("Filter was not set.");

            int found = 0;
            List<FileName> files = new List<FileName>();
            List<TimeSeries> timeSeries = new List<TimeSeries>();
            System.IO.SearchOption so;

            if (search_sub_folders)
               so = System.IO.SearchOption.AllDirectories;
            else
               so = System.IO.SearchOption.TopDirectoryOnly;

            foreach (FilePath path in folders_to_search)
            {
               found = FindFiles(path, files, filter, so);

               foreach (FileName fi in files)
               {
                  TimeSeries newTS = new TimeSeries();
                  newTS.Load(fi);
                  timeSeries.Add(newTS);
               }
            }

            if (timeSeries.Count <= 0)
               return;

            //Finds the Start Date for the output timeseries in the list of loaded timeseries
            DateTime start = timeSeries[0].StartInstant;
            for (int i = 1; i < timeSeries.Count; i++)
            {
               if (timeSeries[i].StartInstant < start)
                  start = timeSeries[i].StartInstant;
            }

            TimeSeries outTS = new TimeSeries();
            outTS.StartInstant = start;
            outTS.TimeUnits = tu;

            foreach (Column col in timeSeries[0].Columns)
            {
               Column newCol = new Column(col.ColumnType);
               newCol.Header = col.Header;
               outTS.AddColumn(newCol);
            }

            foreach (TimeSeries toJoin in timeSeries)
               outTS.AddTimeSeries(toJoin);

            outTS.Save(output);
             }
             catch (Exception ex)
             {
            exception_raised = true;
            exception = new Exception("ScriptV8.JoinTimeseriesByFolder", ex);
            throw exception;
             }
        }
开发者ID:JauchOnGitHub,项目名称:csharptoolbox,代码行数:75,代码来源:Script.v8.cs


注:本文中的TimeSeries.AddTimeSeries方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。