/// <summary>
        /// Creates a new <see cref="MetadataRetriever"/> instance with the specified <paramref name="connectionString"/>.
        /// </summary>
        /// <param name="connectionString">GEP connection string for openHistorian.</param>
        private MetadataRetriever(string connectionString)
        {
            m_subscriber = new DataSubscriber
            {
                ConnectionString = connectionString,
                ReceiveInternalMetadata = true,
                ReceiveExternalMetadata = true
            };

            m_subscriber.OperationalModes |=
                OperationalModes.UseCommonSerializationFormat |
                OperationalModes.CompressMetadata |
                OperationalModes.CompressSignalIndexCache;

            // Attach to needed subscriber events
            m_subscriber.ProcessException += m_subscriber_ProcessException;
            m_subscriber.ConnectionEstablished += m_subscriber_ConnectionEstablished;
            m_subscriber.MetaDataReceived += m_subscriber_MetaDataReceived;

            // Initialize the subscriber
            m_subscriber.Initialize();

            // Create a wait handle to allow time to receive meta-data
            m_waitHandle = new ManualResetEventSlim();

            // Start subscriber connection cycle
            m_subscriber.Start();
        }
예제 #2
0
파일: AudioPlayback.cs 프로젝트: avs009/gsf
        // ------ Data Subscriber Methods ------

        // Creates and starts a data subscriber using the connection information supplied by the user in ConnectionUri.
        // Subscribers created through this method should also be released by the ReleaseDataSubscriber method.
        private DataSubscriber CreateDataSubscriber()
        {
            DataSubscriber subscriber = new DataSubscriber();
            int index = ConnectionUri.IndexOf(URI_SEPARATOR);
            string server = (index >= 0) ? ConnectionUri.Substring(0, index) : ConnectionUri;

            subscriber.StatusMessage += DataSubscriber_StatusMessage;
            subscriber.ProcessException += DataSubscriber_ProcessException;
            subscriber.ConnectionEstablished += DataSubscriber_ConnectionEstablished;
            subscriber.ConnectionTerminated += DataSubscriber_ConnectionTerminated;
            subscriber.MetaDataReceived += DataSubscriber_MetaDataReceived;
            subscriber.DataStartTime += DataSubscriber_DataStartTime;
            subscriber.NewMeasurements += DataSubscriber_NewMeasurements;

            subscriber.ConnectionString = string.Format("server={0}; interface={1};{2} localCertificate={3}; remoteCertificate={4}; validPolicyErrors={5}; validChainFlags={6}", server, IPv6Enabled ? "::0" : "0.0.0.0", UseZeroMQChannel ? " useZeroMQChannel=true;" : "", FilePath.GetAbsolutePath("Local.cer"), FilePath.GetAbsolutePath("Remote.cer"), ~SslPolicyErrors.None, ~X509ChainStatusFlags.NoError);
            subscriber.SecurityMode = EnableEncryption ? SecurityMode.TLS : SecurityMode.None;

            if (!EnableCompression)
                subscriber.OperationalModes = DataSubscriber.DefaultOperationalModes & ~OperationalModes.CompressPayloadData;

            subscriber.ReceiveInternalMetadata = true;
            subscriber.ReceiveExternalMetadata = true;

            subscriber.Initialize();
            subscriber.Start();

            return subscriber;
        }
예제 #3
0
파일: AudioPlayback.cs 프로젝트: rmc00/gsf
        // ------ Data Subscriber Methods ------

        // Creates and starts a data subscriber using the connection information supplied by the user in ConnectionUri.
        // Subscribers created through this method should also be released by the ReleaseDataSubscriber method.
        private DataSubscriber CreateDataSubscriber()
        {
            DataSubscriber subscriber = new DataSubscriber();
            int index = ConnectionUri.IndexOf(URI_SEPARATOR, StringComparison.Ordinal);
            string server = (index >= 0) ? ConnectionUri.Substring(0, index) : ConnectionUri;

            subscriber.StatusMessage += DataSubscriber_StatusMessage;
            subscriber.ProcessException += DataSubscriber_ProcessException;
            subscriber.ConnectionEstablished += DataSubscriber_ConnectionEstablished;
            subscriber.ConnectionTerminated += DataSubscriber_ConnectionTerminated;
            subscriber.MetaDataReceived += DataSubscriber_MetaDataReceived;
            subscriber.DataStartTime += DataSubscriber_DataStartTime;
            subscriber.NewMeasurements += DataSubscriber_NewMeasurements;

            subscriber.ConnectionString = $"server={server}; interface={(IPv6Enabled ? "::0" : "0.0.0.0")};{(UseZeroMQChannel ? " useZeroMQChannel=true;" : "")} localCertificate={FilePath.GetAbsolutePath("Local.cer")}; remoteCertificate={FilePath.GetAbsolutePath("Remote.cer")}; validPolicyErrors={~SslPolicyErrors.None}; validChainFlags={~X509ChainStatusFlags.NoError}";
            subscriber.SecurityMode = EnableEncryption ? SecurityMode.TLS : SecurityMode.None;

            subscriber.OperationalModes = DataSubscriber.DefaultOperationalModes;
            subscriber.CompressionModes = CompressionModes.GZip;

            if (EnableCompression)
            {
                subscriber.OperationalModes |= OperationalModes.CompressPayloadData;

                bool usingUDP = false;

                if (index >= 0)
                    usingUDP = ConnectionUri.Substring(index + URI_SEPARATOR.Length).ParseKeyValuePairs('&').ContainsKey("udp");

                if (!usingUDP)
                    subscriber.CompressionModes |= CompressionModes.TSSC; // TSSC mode requires TCP connection
            }

            subscriber.ReceiveInternalMetadata = true;
            subscriber.ReceiveExternalMetadata = true;

            subscriber.Initialize();
            subscriber.Start();

            return subscriber;
        }
 private void InitializeSubscription()
 {
     try
     {
         using (AdoDataConnection database = new AdoDataConnection(CommonFunctions.DefaultSettingsCategory))
         {
             m_subscriber = new DataSubscriber();
             m_subscriber.StatusMessage += m_subscriber_StatusMessage;
             m_subscriber.ProcessException += m_subscriber_ProcessException;
             m_subscriber.ConnectionEstablished += m_subscriber_ConnectionEstablished;
             m_subscriber.NewMeasurements += m_subscriber_NewMeasurements;
             m_subscriber.ConnectionTerminated += m_subscriber_ConnectionTerminated;
             m_subscriber.ProcessingComplete += m_subscriber_ProcessingComplete;
             m_subscriber.ConnectionString = database.DataPublisherConnectionString();
             m_subscriber.Initialize();
             m_subscriber.Start();
         }
     }
     catch
     {
         // TODO: show error in popup window
         //Popup("Failed to initialize subscription." + Environment.NewLine + ex.Message, "Failed to Subscribe", MessageBoxImage.Error);
     }
 }
예제 #5
0
파일: GraphLines.cs 프로젝트: rmc00/gsf
    // Connects or reconnects to a data publisher
    private void InitiateConnection()
    {
        // Shutdown any existing connection
        TerminateConnection();

        // Attempt to extract server name from connection string
        string server = "unknown";

        if (!string.IsNullOrEmpty(m_connectionString))
        {
            Dictionary<string, string> settings = m_connectionString.ParseKeyValuePairs();

            if (!settings.TryGetValue("server", out server))
                server = "unknown";
        }

        UpdateStatus("Attempting connection to \"{0}\"...", server);

        // Create a new data subscriber
        m_subscriber = new DataSubscriber();

        // Attach to subscriber events
        m_subscriber.MetaDataReceived += subscriber_MetaDataReceived;
        m_subscriber.StatusMessage += subscriber_StatusMessage;
        m_subscriber.ProcessException += subscriber_ProcessException;
        m_subscriber.ConnectionEstablished += subscriber_ConnectionEstablished;
        m_subscriber.ConnectionTerminated += subscriber_ConnectionTerminated;
        m_subscriber.NewMeasurements += subscriber_NewMeasurements;
        m_subscriber.ProcessingComplete += subscriber_ProcessingComplete;

        // Initialize subscriber
        m_subscriber.ConnectionString = m_connectionString;
        m_subscriber.OperationalModes |= OperationalModes.UseCommonSerializationFormat | OperationalModes.CompressSignalIndexCache | OperationalModes.CompressMetadata;
        m_subscriber.Initialize();

        // Start subscriber connection cycle
        m_subscriber.Start();
    }
예제 #6
0
 private void InitializeUnsynchronizedSubscription()
 {
     try
     {
         using (AdoDataConnection database = new AdoDataConnection(CommonFunctions.DefaultSettingsCategory))
         {
             m_unsynchronizedSubscriber = new DataSubscriber();
             m_unsynchronizedSubscriber.StatusMessage += m_unsynchronizedSubscriber_StatusMessage;
             m_unsynchronizedSubscriber.ProcessException += m_unsynchronizedSubscriber_ProcessException;
             m_unsynchronizedSubscriber.ConnectionEstablished += m_unsynchronizedSubscriber_ConnectionEstablished;
             m_unsynchronizedSubscriber.NewMeasurements += m_unsynchronizedSubscriber_NewMeasurements;
             m_unsynchronizedSubscriber.ConnectionTerminated += m_unsynchronizedSubscriber_ConnectionTerminated;
             m_unsynchronizedSubscriber.ConnectionString = database.DataPublisherConnectionString();
             m_unsynchronizedSubscriber.Initialize();
             m_unsynchronizedSubscriber.Start();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Failed to initialize subscription." + Environment.NewLine + ex.Message, "Failed to Subscribe", MessageBoxButton.OK);
     }
 }