예제 #1
0
        private void Dispose(bool disposing)
        {
            if (!m_disposed)
            {
                try
                {
                    if (disposing)
                    {
                        if ((object)m_stream != null)
                        {
                            m_stream.Dispose();
                        }

                        if ((object)m_database != null)
                        {
                            m_database.Dispose();
                        }

                        if ((object)m_client != null)
                        {
                            m_client.Dispose();
                        }
                    }
                }
                finally
                {
                    m_disposed = true;  // Prevent duplicate dispose.
                }
            }
        }
예제 #2
0
        public void Dispose()
        {
            if (!m_disposed)
            {
                try
                {
                    foreach (TreeStream <HistorianKey, HistorianValue> stream in m_treeStreams)
                    {
                        stream.Dispose();
                    }

                    if (m_queue.IsValueCreated)
                    {
                        Flush(10);
                        m_queue.Value.Dispose();
                    }

                    m_database.Dispose();
                    m_client.Dispose();
                }
                finally
                {
                    m_disposed = true;
                }
            }
        }
        public void TestReadData()
        {
            HistorianServerDatabaseConfig config1 = new HistorianServerDatabaseConfig("Scada", @"c:\temp\Scada\", true);
            HistorianServerDatabaseConfig config2 = new HistorianServerDatabaseConfig("Synchrophasor", @"c:\temp\Synchrophasor\", true);

            using (HistorianServer server = new HistorianServer(12345))
            {
                server.AddDatabase(config1);
                server.AddDatabase(config2);

                using (HistorianClient client = new HistorianClient("127.0.0.1", 12345))
                {
                    ClientDatabaseBase <HistorianKey, HistorianValue> database = client.GetDatabase <HistorianKey, HistorianValue>("Scada");
                    TreeStream <HistorianKey, HistorianValue>         stream   = database.Read(0, 100);
                    stream.Dispose();
                    database.Dispose();

                    database = client.GetDatabase <HistorianKey, HistorianValue>("Synchrophasor");
                    stream   = database.Read(0, 100);
                    stream.Dispose();
                    database.Dispose();
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Releases the unmanaged resources used by the <see cref="SnapNetworkClient"/> object and optionally releases the managed resources.
        /// </summary>
        /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
        protected override void Dispose(bool disposing)
        {
            if (m_disposed)
            {
                return;
            }

            try
            {
                if (!disposing)
                {
                    return;
                }

                if (m_sortedTreeEngine != null)
                {
                    m_sortedTreeEngine.Dispose();
                }

                m_sortedTreeEngine = null;

                try
                {
                    m_stream.Write((byte)ServerCommand.Disconnect);
                    m_stream.Flush();
                }
                catch (Exception ex)
                {
                    Logger.SwallowException(ex);
                }

                if (m_rawStream != null)
                {
                    m_rawStream.Dispose();
                }

                m_rawStream = null;
            }
            finally
            {
                m_disposed = true;       // Prevent duplicate dispose.
                base.Dispose(disposing); // Call base class Dispose().
            }
        }
예제 #5
0
        private void btnPlot_Click(object sender, EventArgs e)
        {
            List <ulong> keys = new List <ulong>(chkAllPoints.CheckedItems.OfType <ulong>());

            plot.Clear();

            plot.AddInteraction(new PlotSurface2D.Interactions.HorizontalDrag());
            plot.AddInteraction(new PlotSurface2D.Interactions.VerticalDrag());
            plot.AddInteraction(new PlotSurface2D.Interactions.AxisDrag(false));

            if (keys.Count == 0)
            {
                return;
            }
            SnapClient client = SnapClient.Connect(m_archiveFile.Host);
            ClientDatabaseBase <HistorianKey, HistorianValue> db = client.GetDatabase <HistorianKey, HistorianValue>("");

            Dictionary <ulong, SignalDataBase> results = db.GetSignals(0, ulong.MaxValue, keys, TypeSingle.Instance);

            foreach (ulong point in keys)
            {
                List <double>  y    = new List <double>();
                List <double>  x    = new List <double>();
                SignalDataBase data = results[point];

                for (int i = 0; i < data.Count; i++)
                {
                    data.GetData(i, out ulong time, out double value);

                    x.Add(time);
                    y.Add(value);
                }

                LinePlot lines = new LinePlot(y, x);

                plot.Add(lines);
            }

            plot.Refresh();
            db.Dispose();
            client.Dispose();
        }
예제 #6
0
        /// <summary>
        /// Releases the unmanaged resources used by the <see cref="ReportHistorianReader"/> object and optionally releases the managed resources.
        /// </summary>
        /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
        private void Dispose(bool disposing)
        {
            if (m_disposed)
            {
                return;
            }

            try
            {
                if (disposing)
                {
                    m_stream?.Dispose();
                    m_database?.Dispose();
                    m_client?.Dispose();
                }
            }
            finally
            {
                m_disposed = true;  // Prevent duplicate dispose.
            }
        }
예제 #7
0
        private void BuildListOfAllPoints()
        {
            HashSet <ulong> keys   = new HashSet <ulong>();
            SnapClient      client = SnapClient.Connect(m_archiveFile.Host);
            ClientDatabaseBase <HistorianKey, HistorianValue> db      = client.GetDatabase <HistorianKey, HistorianValue>("");
            TreeStream <HistorianKey, HistorianValue>         scanner = db.Read(0, ulong.MaxValue);
            HistorianKey   key   = new HistorianKey();
            HistorianValue value = new HistorianValue();

            while (scanner.Read(key, value))
            {
                keys.Add(key.PointID);
            }
            List <ulong> AllKeys = keys.ToList();

            AllKeys.Sort();

            chkAllPoints.Items.Clear();
            AllKeys.ForEach((x) => chkAllPoints.Items.Add(x));
            db.Dispose();
            client.Dispose();
        }
        /// <summary>
        /// Releases the unmanaged resources used by the <see cref="SnapNetworkClient"/> object and optionally releases the managed resources.
        /// </summary>
        /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
        protected override void Dispose(bool disposing)
        {
            if (!m_disposed)
            {
                try
                {
                    // This will be done regardless of whether the object is finalized or disposed.

                    if (disposing)
                    {
                        if (m_sortedTreeEngine != null)
                        {
                            m_sortedTreeEngine.Dispose();
                        }
                        m_sortedTreeEngine = null;

                        try
                        {
                            m_stream.Write((byte)ServerCommand.Disconnect);
                            m_stream.Flush();
                        }
                        catch (Exception ex)
                        {
                        }

                        if (m_rawStream != null)
                        {
                            m_rawStream.Dispose();
                        }
                        m_rawStream = null;
                    }
                }
                finally
                {
                    m_disposed = true;          // Prevent duplicate dispose.
                    base.Dispose(disposing);    // Call base class Dispose().
                }
            }
        }