Пример #1
0
 public PortInfo(PortWrapper wraper)
 {
     Id            = wraper.Id;
     Settings      = wraper.Settings;
     RxAcc         = wraper.Port.RxBytes;
     TxAcc         = wraper.Port.TxBytes;
     LastException = wraper.Port.Error.Value;
     Type          = wraper.Port.PortType;
     State         = wraper.Port.State.Value;
 }
Пример #2
0
 private void OnRecv(PortWrapper sender, byte[] data, CancellationToken cancel)
 {
     PortWrapper[] ports;
     lock (_sync)
     {
         ports = _ports.Where(_ => _ != sender).Where(_ => _.Port.IsEnabled.Value).ToArray();
     }
     _onRecv.OnNext(data);
     Task.WaitAll(ports.Select(_ => _.Port.Send(data, data.Length, cancel)).ToArray(), cancel);
 }
Пример #3
0
        private void OnRecv(PortWrapper sender, byte[] data, CancellationToken cancel)
        {
            IEnumerable <PortWrapper> ports;

            lock (_sync)
            {
                // repeat
                ports = _ports
                        // exclude self
                        .Where(_ => _.Id != sender.Id)
                        // exclude disabled
                        .Where(_ => _.Port.IsEnabled.Value)
                        // only connected
                        .Where(_ => _.Port.State.Value == PortState.Connected);
            }
            _onRecv.OnNext(data);
            Task.WaitAll(ports.Select(_ => _.Port.Send(data, data.Length, cancel)).ToArray(), cancel);
        }