コード例 #1
0
        public static DeviceLayer GetDeviceLayer()
        {
            Log.Info("Composing device layer from connection string: {0}", Settings.Default.ConnectionString);
            var endpoint = DeviceEndpoint.FromConnectionString(Settings.Default.ConnectionString);
            var channel  = GetChannelFromEndpoint(endpoint);
            var device   = new DeviceLayer(channel);

            return(device);
        }
 /// <summary>
 ///     Creates the transaction processor ready for use. Also creates and initialises the
 ///     device endpoint and the communications channel and opens the channel.
 /// </summary>
 /// <returns>ITransactionProcessor.</returns>
 public ITransactionProcessor CreateTransactionProcessor()
 {
     Endpoint  = DeviceEndpoint.FromConnectionString(ConnectionString);
     Channel   = CommunicationsStackBuilder.BuildChannel(Endpoint);
     observer  = new TransactionObserver(Channel);
     processor = new ReactiveTransactionProcessor();
     processor.SubscribeTransactionObserver(observer, TimeSpan.FromMilliseconds(100));
     Channel.Open();
     //Task.Delay(TimeSpan.FromSeconds(2)).Wait(); // Arduino needs 2 seconds to initialize
     Thread.Sleep(TimeSpan.FromSeconds(3));
     return(processor);
 }
 public ReactiveTransactionProcessorFactory(string connectionString)
 {
     this.ConnectionString = connectionString;
     // Endpoint will be InvalidEndpoint if the connection string is invalid.
     Endpoint = DeviceEndpoint.FromConnectionString(connectionString);
 }