Ejemplo n.º 1
0
        public void ChangeChannelTest()
        {
            bool         waiting  = true;
            const string channel1 = "channel1";
            const string channel2 = "channel2";
            const string channel3 = "channel3";

            const string          message           = "message";
            ITransmitter <string> stringTransmitter = StringChannel.CreateTransmitter(channel1);
            IReceiver <string>    stringReceiver    = StringChannel.CreateReceiver(channel2);

            stringReceiver.Received += (sender, args) => { waiting = false; };
            stringTransmitter.Send(message);

            Thread.Sleep(200);
            Assert.IsNull(stringReceiver.LastMessage);

            stringTransmitter.SetChannel(channel3);
            stringReceiver.SetChannel(channel3);

            stringTransmitter.Send(message);

            while (waiting)
            {
                Thread.Sleep(200);
            }

            Assert.IsNotNull(stringReceiver.LastMessage);
        }
 internal AzureMonitorLogExporter(AzureMonitorExporterOptions options, ITransmitter transmitter)
 {
     _options = options ?? throw new ArgumentNullException(nameof(options));
     ConnectionString.ConnectionStringParser.GetValues(_options.ConnectionString, out _instrumentationKey, out _);
     _transmitter    = transmitter;
     _resourceParser = new ResourceParser();
 }
Ejemplo n.º 3
0
        public void TransmitterCreationTest()
        {
            const string          channelName       = "channel";
            ITransmitter <string> stringTransmitter = StringChannel.CreateTransmitter(channelName);

            Assert.AreEqual(channelName, stringTransmitter.Channel.ChannelName);
        }
Ejemplo n.º 4
0
        private ITransmitter GetLoggableTransmitter()
        {
            ILogger      logger      = GetLogger();
            ITransmitter transmitter = GetTransmitter();

            return(new LoggableTransmitter(logger, transmitter));
        }
Ejemplo n.º 5
0
        private static void RunMPC(ITransmitter transmitter, IGoalUtilizer utilizer)
        {
            utilizer.Reset();
            var generator = new GoalGenerator();
            IList <Producer> producers = new List <Producer>()
            {
                new Producer(generator, transmitter)
            };
            IList <Consumer> consumers = new List <Consumer>();

            consumers.Add(new Consumer(utilizer, transmitter));
            consumers.Add(new Consumer(utilizer, transmitter));
            consumers.Add(new Consumer(utilizer, transmitter));
            GoalManager manager = new GoalManager(producers, consumers);

            Stopwatch stopWatchBody = new Stopwatch();

            stopWatchBody.Start();

            manager.Run();
            Thread.Sleep(5000);//22 000 000
            manager.Stop();

            stopWatchBody.Stop();
            string    elapsedTimeBody = ConvertTSToString(stopWatchBody.Elapsed);
            Stopwatch stopWatchFinish = new Stopwatch();

            stopWatchFinish.Start();
            var isOk = utilizer.WasUtilizeSuccessful();

            stopWatchFinish.Stop();
            string elapsedTimeFinish = ConvertTSToString(stopWatchFinish.Elapsed);

            Console.WriteLine($"{transmitter.GetType().Name.PadRight(30)} isOk {isOk} nGoals: {generator.Counter} BodyTime: {elapsedTimeBody} FinishTime: {elapsedTimeFinish}");
        }
Ejemplo n.º 6
0
 public Producer(ITransmitter transmitter, long maxValue, int nConsumer)
 {
     _transmitter = transmitter;
     _maxValue    = maxValue;
     _nConsumer   = nConsumer;
     _thread      = new Thread(GenerateGoals);
 }
Ejemplo n.º 7
0
 public aHandControllerForm()
 {
     InitializeComponent();
     this.CommandEncoder     = new Encoder();
     this.CommandTransmitter = new SerialTransmitter();
     this.ContinuousRotationCommandFrequency = 500;
 }
Ejemplo n.º 8
0
        public StockProcessor()
        {
            this._container = UnityHelper.GetContainer();

            this._receiver    = this._container.Resolve <IReceiver <Stock> >();
            this._transmitter = this._container.Resolve <ITransmitter <Stock> >();
        }
        internal AzureMonitorTraceExporter(AzureMonitorExporterOptions options, ITransmitter transmitter)
        {
            this.options = options ?? throw new ArgumentNullException(nameof(options));
            ConnectionString.ConnectionStringParser.GetValues(this.options.ConnectionString, out this.instrumentationKey, out _);

            this.Transmitter = transmitter;
        }
Ejemplo n.º 10
0
        public void TransmitMessageToMultipleReceiverTest()
        {
            bool         rcv1Waiting = true;
            bool         rcv2Waiting = true;
            const string channel     = "channel";
            const string message     = "message";

            ITransmitter <string> stringTransmitter = StringChannel.CreateTransmitter(channel);
            IReceiver <string>    receiver1         = StringChannel.CreateReceiver(channel);
            IReceiver <string>    receiver2         = StringChannel.CreateReceiver(channel);

            receiver1.Received += (sender, args) =>
            {
                Assert.AreEqual(channel, args.Channel.ChannelName);
                rcv1Waiting = false;
            };

            receiver2.Received += (sender, args) =>
            {
                Assert.AreEqual(channel, args.Channel.ChannelName);
                rcv2Waiting = false;
            };

            stringTransmitter.Send(message);

            while (rcv1Waiting && rcv2Waiting)
            {
                Thread.Sleep(200);
            }

            Assert.AreEqual(message, receiver1.LastMessage);
            Assert.AreEqual(message, receiver2.LastMessage);
        }
Ejemplo n.º 11
0
 public Consumer(ITransmitter transmitter, AutoResetEvent waitHandle)
 {
     Goals        = new List <long>();
     _transmitter = transmitter;
     _waitHandle  = waitHandle;
     _thread      = new Thread(ProcessGoals);
 }
Ejemplo n.º 12
0
 private void Connect(Neuron n, ITransmitter input)
 {
     n.AddInput(input, rnd.NextDouble());
     if (input is Neuron)
     {
         ((Neuron)input).AddOutput(n);
     }
 }
Ejemplo n.º 13
0
        public override void Run()
        {
            base.Run();
            Message      message     = GetMessage();
            ITransmitter transmitter = GetLoggableTransmitter();

            transmitter.Send(message.GetStream());
            var stream = transmitter.Recieve();
        }
Ejemplo n.º 14
0
 public bool UpdateWeight(ITransmitter input, double newWeight)
 {
     if (!InputExists(input))
     {
         return(false);
     }
     Weights[input.ID] = newWeight;
     return(true);
 }
Ejemplo n.º 15
0
 public bool AddInput(ITransmitter input, double weight)
 {
     if (InputExists(input))
     {
         return(false);
     }
     Inputs.Add(input);
     return(UpdateWeight(input, weight));
 }
Ejemplo n.º 16
0
 public DefaultTransmissionService(
     TransmissionRequestFactory transmissionRequestFactory,
     ITransmitter transmitter,
     Trace tracer)
     : base(tracer)
 {
     this.transmissionRequestFactory = transmissionRequestFactory;
     this.transmitter = transmitter;
 }
Ejemplo n.º 17
0
 internal void TransmitPermanentAppearance(ITransmitter <IEnumerable <Packet> > transmitter, long oldPAVersion)
 {
     if (Station.paEnumerable == null)
     {
         Station.paEnumerable = new Station.PAEnumerable();
     }
     Station.paEnumerable.Reset(this.paHistory, oldPAVersion);
     transmitter.Transmit(Station.paEnumerable);
 }
Ejemplo n.º 18
0
 public void Receive(ITransmitter t)
 {
     RecieveCounter++;
     Value += t.Value * Weights[t.ID];
     if (RecieveCounter >= Inputs.Count)
     {
         Transmit();
     }
 }
Ejemplo n.º 19
0
 internal void TransmitInstantDisappearance(ITransmitter <IEnumerable <Packet> > transmitter)
 {
     if (Station.paListEnumerable == null)
     {
         Station.paListEnumerable = new Station.PAListEnumerable();
     }
     Station.paListEnumerable.Reset(this.firstElement, false);
     transmitter.Transmit(Station.paListEnumerable);
 }
Ejemplo n.º 20
0
 public ApiController(ITransmitter transmitter, IAppSetting appSetting, IAuthenticateUtil authenticateUtil,
                      ICacheMemory cacheMemory, IAuthenticateUser authenticateService)
 {
     _transmitter         = transmitter;
     _appSetting          = appSetting;
     _authenticateUtil    = authenticateUtil;
     _cacheMemory         = cacheMemory;
     _authenticateService = authenticateService;
 }
        internal AzureMonitorTraceExporter(AzureMonitorExporterOptions options, ITransmitter transmitter)
        {
            _options = options ?? throw new ArgumentNullException(nameof(options));
            ConnectionString.ConnectionStringParser.GetValues(_options.ConnectionString, out _instrumentationKey, out _);
            _transmitter    = transmitter;
            _resourceParser = new ResourceParser();

            // Todo: Add check if offline storage is enabled by user via options
            _storageTransmissionEvaluator = new StorageTransmissionEvaluator(StorageTransmissionEvaluatorSampleSize);
        }
Ejemplo n.º 22
0
        public PayloadProcessorBase(IRadioObject payload, IEnvironment env, ILog log, IEnumerable <MototrboRadio> radios, ITransmitter transmitter, IUIDispatcher uiDispatcher)
        {
            _env          = env;
            _log          = log;
            _radios       = radios;
            _transmitter  = transmitter;
            _uiDispatcher = uiDispatcher;
            rxObject      = payload;

            _radio = GetRadio(payload.Ip);
        }
Ejemplo n.º 23
0
        internal AzureMonitorLogExporter(ITransmitter transmitter)
        {
            _transmitter        = transmitter;
            _instrumentationKey = transmitter.InstrumentationKey;
            _resourceParser     = new ResourceParser();

            if (transmitter is AzureMonitorTransmitter _azureMonitorTransmitter && _azureMonitorTransmitter._storage != null)
            {
                _persistentStorage = new AzureMonitorPersistentStorage(transmitter);
            }
        }
Ejemplo n.º 24
0
        public IDisposable Subscribe(IObserver <Thermometer> transmitter)
        {
            ITransmitter <Thermometer> thermoObserver = transmitter as ITransmitter <Thermometer>;

            if (!transmitters.Contains(thermoObserver))
            {
                transmitters.Add(thermoObserver);
            }

            return(new Unsubscriber(transmitters, thermoObserver));
        }
Ejemplo n.º 25
0
        public RxProcessor(IEnvironment env, ILog log, IEventAggregator aggregator, IEnumerable <MototrboRadio> radios, ITransmitter transmitter, IUIDispatcher uiDispatcher)
        {
            _env          = env;
            _log          = log;
            _aggregator   = aggregator;
            _radios       = radios;
            _transmitter  = transmitter;
            _uiDispatcher = uiDispatcher;

            _receiverQueue = new ConcurrentQueue <RxObject>();
            _rxPoolThread  = new Thread(new ThreadStart(Process));
        }
Ejemplo n.º 26
0
        public Station(
            Constants.StationId stationType,
            ITransmitter transmitter,
            int bufferSize,
            int timeoutInMs,
            bool detectionOnly,
            FileStream inputFileStream,
            FileStream outputFileStream,
            Constants.ShowFrameDelegate sendFrame)
        {
            this.StationId         = stationType;
            this.transmitter       = transmitter;
            this.BufferSize        = bufferSize;
            InputBuffer            = new Dictionary <int, Frame>();
            OutputBuffer           = new Dictionary <int, Frame>();
            this.TimeoutInMs       = timeoutInMs;
            this.CorrectionMode    = detectionOnly ? HammingHelper.Mode.DETECT : HammingHelper.Mode.CORRECT;
            this.inputFileStream   = inputFileStream;
            this.outputFileStream  = outputFileStream;
            this.sendFrameDelegate = sendFrame;
            StopExecution          = false;
            ExecutionStopped       = new ManualResetEvent(false);

            // Initialize constants
            int frameSizeBeforeHamming = HammingHelper.GetDataSize(Constants.FrameSize * 8) / 8;
            int realBitCount           = HammingHelper.GetTotalSize(frameSizeBeforeHamming * 8);

            EncodedFramePadding = Constants.FrameSize * 8 - realBitCount;
            int frameHeaderSize = Frame.HeaderSize();

            DataSizeInFrame = frameSizeBeforeHamming - frameHeaderSize;
            MaxSequence     = (UInt16)(bufferSize * 2 - 1);

            // Initialize fields
            FirstFrameSent = 0;
            NextFrameToSendSequenceNumber = 0;
            NextFrameToReceive            = 0;

            // Since frames cannot use MaxSequence as a sequence number, we use it for LastFrameSequenceNumberForNak.
            // This is meant to ensure that no Frame matches this field if there was no Nak sent.
            LastFrameSequenceNumberForNak = MaxSequence;

            // Initialise ack timer logic
            AckTimer = new System.Timers.Timer(AckTimeout);
            // When the timer ends, we need to inform the program that we need to send an Ack now. Also stop the timer.
            AckTimer.Elapsed += (sender, e) => { sendAck = true; AckTimer.Stop(); Console.WriteLine("ack timer elapsed"); };
            sendAck           = false;

            HighPriorityFrames = new Queue <Frame>();
            TimeoutTimers      = new ConcurrentDictionary <UInt16, System.Timers.Timer>();
        }
Ejemplo n.º 27
0
        /// <summary>
        /// The main program
        /// </summary>
        /// <param name="argv">The command line arguments</param>
        static async Task Run(Service service)
        {
            Console.WriteLine("Login as " + SdkHelper.Splunk.Username);

            await service.LogOnAsync(SdkHelper.Splunk.Username, SdkHelper.Splunk.Password);

            Console.WriteLine("Create an index");

            string indexName = "user-index";
            Index  index     = await service.Indexes.GetOrNullAsync(indexName);

            if (index != null)
            {
                await index.RemoveAsync();
            }

            index = await service.Indexes.CreateAsync(indexName);

            Exception exception = null;

            try
            {
                await index.EnableAsync();

                ITransmitter transmitter = service.Transmitter;
                SearchResult result;

                result = await transmitter.SendAsync("Hello World.", indexName);

                result = await transmitter.SendAsync("Goodbye world.", indexName);

                using (var results = await service.SearchOneShotAsync(string.Format("search index={0}", indexName)))
                {
                    foreach (SearchResult task in results)
                    {
                        Console.WriteLine(task);
                    }
                }
            }
            catch (Exception e)
            {
                exception = e;
            }

            await index.RemoveAsync();

            if (exception != null)
            {
                throw exception;
            }
        }
Ejemplo n.º 28
0
        public ServerManager(IEnvironment env, ILog logger, IEventAggregator aggregator, IEnumerable<MototrboRadio> radios, ILog consoleLog)
        {
            _env = env;
            _log = logger;
            _aggregator = aggregator;
            _radios = radios;
            _consoleLog = consoleLog;

            _transmitter = new Transmiter(_env, _log, _aggregator, _consoleLog);
            _uiDispatcher = new UIDispatcher(_env, _log, _aggregator);
            _rxProcessor = new RxProcessor(_env, _log, _aggregator, _radios, _transmitter, _uiDispatcher);

            _serviceList = new Dictionary<int, IReceiver>();
        }
Ejemplo n.º 29
0
 public void Dispose()
 {
     try
     {
         this.Transmitter.Dispose();
     }
     catch
     {
     }
     finally
     {
         this.Transmitter = null;
     }
 }
Ejemplo n.º 30
0
 public static void SetupCancelHandler(ImuseEngine engine, ITransmitter transmitter)
 {
     // Clean up, even with Ctrl+C
     cancelHandler = new ConsoleCancelEventHandler((sender, e) =>
     {
         logger.Warning("Abrupt exit - trying to clean up...");
         engine.Dispose();
         if (transmitter is IDisposable disposableTransmitter)
         {
             disposableTransmitter.Dispose();
         }
     });
     Console.CancelKeyPress += cancelHandler;
 }
Ejemplo n.º 31
0
        public void disconnectFromTransmitter()
        {
            try
            {
                if (null == getMyDriver())
                    return;
            }
            catch (cantOpenPortException)
            {
                return;
            }

            _mydriver.Dispose();
            _mydriver = null;
            _nodes.Clear();
            lstNodes.Clear();
            clearNodeInfoPanel();
            MessageBox.Show("Port closed.");
            generalToolStripMenuItem.Enabled = true;
        }
Ejemplo n.º 32
0
 public Node(ITransmitter driver, Int16 newid)
 {
     id = newid;
     Mydriver = driver;
     fillProperties();
 }
 //Start OSC transmitter
 private void btnStartOSCTrans_Click(object sender, RoutedEventArgs e)
 {
     //Get the transport type
     if ((string)cmbbOSCTransType.SelectedItem == UDP_STRING)
     {
         transmitter_ipendpoint = new IPEndPoint(IPAddress.Parse(txtOSCTransIP.Text), Convert.ToInt32(txtOSCTransPort.Text));
         osc_transmitter = new UdpTransmitter(transmitter_ipendpoint);
         
     }
     else if ((string)cmbbOSCTransType.SelectedItem == TCP_STRING)
     {
         transmitter_ipendpoint = new IPEndPoint(IPAddress.Parse(txtOSCTransIP.Text), Convert.ToInt32(txtOSCTransPort.Text));
         osc_transmitter = new TcpTransmitter(transmitter_ipendpoint);  
     }
     else
     {
         //Do nothing
         Debug.WriteLine("Transmitter transport type not recognized.");
         return;
     }
     //osc_transmitter.Start(bundle);
     btnStartOSCTrans.IsEnabled = false;
     cmbbOSCTransType.IsEnabled = false;
     txtOSCTransIP.IsEnabled = false;
     txtOSCTransPort.IsEnabled = false;
 }
Ejemplo n.º 34
0
 public void setMyDriver(ITransmitter toThis)
 {
     _mydriver = toThis;
 }
Ejemplo n.º 35
0
        public ITransmitter getMyDriver()
        {
            if ( (null == _mydriver) || (!_mydriver.portOpen()) )
            {
                DialogResult response =
                    MessageBox.Show("To do this, the transmitter must be connected. Connect to transmitter now?",
                                    "Connect to transmitter?", MessageBoxButtons.YesNo);
                if ((response == DialogResult.No) || (response == DialogResult.None))
                    throw new cantOpenPortException();

                _mydriver = new _transmitter(_myOptions.portname, _myOptions.useEncryption, _myOptions.myKey.keyArray);
                generalToolStripMenuItem.Enabled = false;
            }

            return _mydriver;
        }