PageRenderTime 25ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/Alpha/Source/Libraries/openHistorian.Core/Data/Query/HistorianQuery.cs

#
C# | 72 lines | 37 code | 7 blank | 28 comment | 0 complexity | f4b4306f37f71e0ac136ce6e2bca4e2e MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, EPL-1.0
  1. //******************************************************************************************************
  2. // HistorianQuery.cs - Gbtc
  3. //
  4. // Copyright © 2013, Grid Protection Alliance. All Rights Reserved.
  5. //
  6. // Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
  7. // the NOTICE file distributed with this work for additional information regarding copyright ownership.
  8. // The GPA licenses this file to you under the Eclipse Public License -v 1.0 (the "License"); you may
  9. // not use this file except in compliance with the License. You may obtain a copy of the License at:
  10. //
  11. // http://www.opensource.org/licenses/eclipse-1.0.php
  12. //
  13. // Unless agreed to in writing, the subject software distributed under the License is distributed on an
  14. // "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
  15. // License for the specific language governing permissions and limitations.
  16. //
  17. // Code Modification History:
  18. // ----------------------------------------------------------------------------------------------------
  19. // 12/12/2012 - Steven E. Chisholm
  20. // Generated original version of source code.
  21. //
  22. //******************************************************************************************************
  23. using System;
  24. using System.Collections.Generic;
  25. using System.Net;
  26. using GSF.SortedTreeStore.Engine;
  27. using GSF.SortedTreeStore.Engine.Reader;
  28. using GSF.SortedTreeStore.Net;
  29. using openHistorian.Collections;
  30. namespace openHistorian.Data.Query
  31. {
  32. public class HistorianQuery
  33. {
  34. private readonly SortedTreeStoreClient<HistorianKey, HistorianValue> m_historian;
  35. private int m_samplesPerSecond = 30;
  36. public HistorianQuery(string server, int port)
  37. {
  38. //IPAddress ip = Dns.GetHostAddresses(server)[0];
  39. //m_historian = new RemoteHistorian<HistorianKey, HistorianValue>(new IPEndPoint(ip, port));
  40. }
  41. public HistorianQuery(SortedTreeStoreClient<HistorianKey, HistorianValue> historian)
  42. {
  43. m_historian = historian;
  44. }
  45. public IDictionary<Guid, SignalDataBase> GetQueryResult(DateTime startTime, DateTime endTime, int zoomLevel, IEnumerable<ISignalCalculation> signals)
  46. {
  47. //ToDo: Modify the query base on the zoom level
  48. SortedTreeEngineBase<HistorianKey, HistorianValue> db = null;
  49. try
  50. {
  51. db = m_historian.GetDefaultDatabase();
  52. //var db = m_historian.ConnectToDatabase("Full Resolution Synchrophasor");
  53. PeriodicScanner scanner = new PeriodicScanner(m_samplesPerSecond);
  54. var timestamps = scanner.GetParser(startTime, endTime, 1500u);
  55. SortedTreeEngineReaderOptions options = new SortedTreeEngineReaderOptions(TimeSpan.FromSeconds(1));
  56. return db.GetSignalsWithCalculations(timestamps, signals, options);
  57. }
  58. finally
  59. {
  60. //if (db != null)
  61. // db.Disconnect();
  62. }
  63. }
  64. }
  65. }