Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DeviceBase"/> class.
        /// </summary>
        /// <param name="frontendSocket">
        /// A <see cref="NetMQSocket"/> that will pass incoming messages to <paramref name="backendSocket"/>.
        /// </param>
        /// <param name="backendSocket">
        /// A <see cref="NetMQSocket"/> that will receive messages from (and optionally send replies to) <paramref name="frontendSocket"/>.
        /// </param>
        /// <param name="mode">The <see cref="DeviceMode"/> for the current device.</param>
        /// <param name="poller">The <see cref="Poller"/> to use.</param>
        protected DeviceBase(Poller poller, NetMQSocket frontendSocket, NetMQSocket backendSocket, DeviceMode mode)
        {
            if (frontendSocket == null)
            {
                throw new ArgumentNullException("frontendSocket");
            }

            if (backendSocket == null)
            {
                throw new ArgumentNullException("backendSocket");
            }

            FrontendSocket = frontendSocket;
            BackendSocket  = backendSocket;

            FrontendSetup = new DeviceSocketSetup(FrontendSocket);
            BackendSetup  = new DeviceSocketSetup(BackendSocket);

            m_poller = poller;

            FrontendSocket.ReceiveReady += FrontendHandler;
            BackendSocket.ReceiveReady  += BackendHandler;

            m_poller.AddSocket(FrontendSocket);
            m_poller.AddSocket(BackendSocket);

            m_runner = mode == DeviceMode.Blocking
                ? new DeviceRunner(this)
                : new ThreadedDeviceRunner(this);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create a new instance of the <see cref="DeviceBase"/> class.
        /// </summary>
        /// <param name="poller">the <see cref="INetMQPoller"/> to use for detecting when messages are available</param>
        /// <param name="frontendSocket">
        /// A <see cref="NetMQSocket"/> that will pass incoming messages to <paramref name="backendSocket"/>.
        /// </param>
        /// <param name="backendSocket">
        /// A <see cref="NetMQSocket"/> that will receive messages from (and optionally send replies to) <paramref name="frontendSocket"/>.
        /// </param>
        /// <param name="mode">the <see cref="DeviceMode"/> (either Blocking or Threaded) for this device</param>
        /// <exception cref="ArgumentNullException">frontendSocket must not be null.</exception>
        /// <exception cref="ArgumentNullException">backendSocket must not be null.</exception>
        protected DeviceBase(INetMQPoller poller, [NotNull] NetMQSocket frontendSocket, [NotNull] NetMQSocket backendSocket, DeviceMode mode)
        {
            m_isInitialized = false;

            if (frontendSocket == null)
            {
                throw new ArgumentNullException(nameof(frontendSocket));
            }

            if (backendSocket == null)
            {
                throw new ArgumentNullException(nameof(backendSocket));
            }

            FrontendSocket = frontendSocket;
            BackendSocket  = backendSocket;

            FrontendSetup = new DeviceSocketSetup(FrontendSocket);
            BackendSetup  = new DeviceSocketSetup(BackendSocket);

            m_poller = poller;

            FrontendSocket.ReceiveReady += FrontendHandler;
            BackendSocket.ReceiveReady  += BackendHandler;

            m_poller.Add(FrontendSocket);
            m_poller.Add(BackendSocket);

            m_runner = mode == DeviceMode.Blocking
                ? new DeviceRunner(this)
                : new ThreadedDeviceRunner(this);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Create a new instance of the <see cref="DeviceBase"/> class.
        /// </summary>
        /// <param name="poller">the <see cref="INetMQPoller"/> to use for detecting when messages are available</param>
        /// <param name="frontendSocket">
        /// A <see cref="NetMQSocket"/> that will pass incoming messages to <paramref name="backendSocket"/>.
        /// </param>
        /// <param name="backendSocket">
        /// A <see cref="NetMQSocket"/> that will receive messages from (and optionally send replies to) <paramref name="frontendSocket"/>.
        /// </param>
        /// <param name="mode">the <see cref="DeviceMode"/> (either Blocking or Threaded) for this device</param>
        /// <exception cref="ArgumentNullException">frontendSocket must not be null.</exception>
        /// <exception cref="ArgumentNullException">backendSocket must not be null.</exception>
        protected DeviceBase(INetMQPoller poller,  NetMQSocket frontendSocket,  NetMQSocket backendSocket, DeviceMode mode)
        {
            m_isInitialized = false;

            if (frontendSocket == null)
                throw new ArgumentNullException("frontendSocket");

            if (backendSocket == null)
                throw new ArgumentNullException("backendSocket");

            FrontendSocket = frontendSocket;
            BackendSocket = backendSocket;

            FrontendSetup = new DeviceSocketSetup(FrontendSocket);
            BackendSetup = new DeviceSocketSetup(BackendSocket);

            m_poller = poller;

            FrontendSocket.ReceiveReady += FrontendHandler;
            BackendSocket.ReceiveReady += BackendHandler;

            m_poller.Add(FrontendSocket);
            m_poller.Add(BackendSocket);

            m_runner = mode == DeviceMode.Blocking
                ? new DeviceRunner(this)
                : new ThreadedDeviceRunner(this);
        }