コード例 #1
0
 public void Accept(VisualizeOperation operation)
 {
 }
コード例 #2
0
 void IWirelessDevice.Accept(VisualizeOperation operation)
 {
     // Not applicable for a mediator.
 }
            void IOperationAcceptor.Accept(VisualizeOperation operation)
            {
                Guard.NotNull(operation, nameof(operation));

                foreach (IWirelessDevice targetDevice in GetDevicesWithAddresses(operation.DestinationAddresses))
                {
                    IWirelessDevice snapshot = targetDevice;
                    snapshot.Accept(operation);
                }
            }
コード例 #4
0
        private static IEnumerable<Operation> GetLargestPossibleOperation()
        {
            var destinations = new[]
            {
                //new WirelessNetworkAddress("AAAAAA"),
                //new WirelessNetworkAddress("BBBBBB"),
                new WirelessNetworkAddress("CCCCCC")
            };

            var operation = new VisualizeOperation(destinations)
            {
                CurrentCompetitorNumber = 999,
                NextCompetitorNumber = 999,
                StartTimer = true,
                PrimaryTimerValue = TimeSpan.FromSeconds(999).Add(TimeSpan.FromMilliseconds(987)),
                SecondaryTimerValue = TimeSpan.FromSeconds(999).Add(TimeSpan.FromMilliseconds(987)),
                FaultCount = 99,
                RefusalCount = 99,
                Eliminated = true,
                PreviousPlacement = 999
            };

            byte[] buffer = PacketWriter.Write(operation, true);
            Console.WriteLine($"*** Maximum operation length in bytes: {buffer.Length}\n");
            yield break;
        }
コード例 #5
0
 void IWirelessDevice.Accept(VisualizeOperation operation)
 {
     operationDispatcher.Dispatch(operation);
 }
        public Task VisualizeAsync([NotNull] [ItemNotNull] IEnumerable<WirelessNetworkAddress> destinationAddresses,
            VisualizeFieldSet fieldSet, CancellationToken cancellationToken = default(CancellationToken))
        {
            var operation = new VisualizeOperation(destinationAddresses)
            {
                CurrentCompetitorNumber = fieldSet.CurrentCompetitorNumber,
                NextCompetitorNumber = fieldSet.NextCompetitorNumber,
                StartTimer = fieldSet.StartPrimaryTimer,
                PrimaryTimerValue = fieldSet.PrimaryTimerValue,
                SecondaryTimerValue = fieldSet.SecondaryTimerValue,
                FaultCount = fieldSet.CurrentFaultCount,
                RefusalCount = fieldSet.CurrentRefusalCount,
                Eliminated = fieldSet.CurrentIsEliminated,
                PreviousPlacement = fieldSet.PreviousPlacement
            };

            return sessionGuard.SendAsync(operation, cancellationToken);
        }
 public void Accept(VisualizeOperation operation)
 {
     WarnForUnexpectedOperation(operation);
 }
        public void When_reading_visualize_operation_it_must_be_correct()
        {
            // Arrange
            byte[] buffer =
            {
                2,
                ByteFor('0'),
                ByteFor('7'),
                ByteFor('\t'),
                ByteFor('0'),
                ByteFor('2'),
                ByteFor('8'),
                ByteFor(':'),
                ByteFor('1'),
                ByteFor('2'),
                ByteFor('3'),
                ByteFor('\t'),
                ByteFor('0'),
                ByteFor('2'),
                ByteFor('9'),
                ByteFor(':'),
                ByteFor('1'),
                ByteFor('2'),
                ByteFor('5'),
                ByteFor('\t'),
                ByteFor('0'),
                ByteFor('3'),
                ByteFor('0'),
                ByteFor(':'),
                ByteFor('1'),
                ByteFor('\t'),
                ByteFor('0'),
                ByteFor('3'),
                ByteFor('1'),
                ByteFor(':'),
                ByteFor('2'),
                ByteFor('5'),
                ByteFor('9'),
                ByteFor('4'),
                ByteFor('3'),
                ByteFor('\t'),
                ByteFor('0'),
                ByteFor('3'),
                ByteFor('2'),
                ByteFor(':'),
                ByteFor('5'),
                ByteFor('\t'),
                ByteFor('0'),
                ByteFor('3'),
                ByteFor('3'),
                ByteFor(':'),
                ByteFor('1'),
                ByteFor('0'),
                ByteFor('\t'),
                ByteFor('0'),
                ByteFor('3'),
                ByteFor('4'),
                ByteFor(':'),
                ByteFor('1'),
                ByteFor('\t'),
                ByteFor('0'),
                ByteFor('3'),
                ByteFor('5'),
                ByteFor(':'),
                ByteFor('2'),
                ByteFor('3'),
                ByteFor('\t'),
                ByteFor('0'),
                ByteFor('1'),
                ByteFor('4'),
                ByteFor(':'),
                ByteFor('A'),
                ByteFor('B'),
                ByteFor('C'),
                ByteFor('D'),
                ByteFor('E'),
                ByteFor('F'),
                ByteFor('\t'),
                ByteFor('0'),
                ByteFor('1'),
                ByteFor('4'),
                ByteFor(':'),
                ByteFor('A'),
                ByteFor('A'),
                ByteFor('B'),
                ByteFor('B'),
                ByteFor('C'),
                ByteFor('C'),
                ByteFor('\t'),
                ByteFor('0'),
                ByteFor('3'),
                ByteFor('8'),
                ByteFor(':'),
                ByteFor('1'),
                ByteFor('6'),
                ByteFor('1'),
                ByteFor('2'),
                ByteFor('3'),
                ByteFor('\t'),
                3
            };
            var reader = new PacketReader();

            // Act
            Operation operation = reader.Read(buffer);

            // Assert
            var expected = new VisualizeOperation(new[]
            {
                new WirelessNetworkAddress("ABCDEF"),
                new WirelessNetworkAddress("AABBCC")
            })
            {
                CurrentCompetitorNumber = 123,
                NextCompetitorNumber = 125,
                StartTimer = true,
                PrimaryTimerValue = 25.Seconds().And(943.Milliseconds()),
                SecondaryTimerValue = 16.Seconds().And(123.Milliseconds()),
                FaultCount = 5,
                RefusalCount = 10,
                Eliminated = true,
                PreviousPlacement = 23
            };

            operation.ShouldBeEquivalentTo(expected, options => options.IncludingAllRuntimeProperties());
        }
        public void When_writing_visualize_operation_it_must_be_correct()
        {
            // Arrange
            var operation = new VisualizeOperation(new[]
            {
                new WirelessNetworkAddress("ABCDEF"),
                new WirelessNetworkAddress("AABBCC")
            })
            {
                CurrentCompetitorNumber = 123,
                NextCompetitorNumber = 125,
                StartTimer = true,
                PrimaryTimerValue = 25.Seconds().And(943.Milliseconds()),
                SecondaryTimerValue = 16.Seconds().And(123.Milliseconds()),
                FaultCount = 5,
                RefusalCount = 10,
                Eliminated = true,
                PreviousPlacement = 23
            };

            // Act
            byte[] buffer = PacketWriter.Write(operation, false);

            // Assert
            buffer.ShouldBeEquivalentTo(new byte[]
            {
                2,
                ByteFor('0'),
                ByteFor('7'),
                ByteFor('\t'),
                ByteFor('0'),
                ByteFor('3'),
                ByteFor('4'),
                ByteFor(':'),
                ByteFor('1'),
                ByteFor('\t'),
                ByteFor('0'),
                ByteFor('2'),
                ByteFor('8'),
                ByteFor(':'),
                ByteFor('1'),
                ByteFor('2'),
                ByteFor('3'),
                ByteFor('\t'),
                ByteFor('0'),
                ByteFor('2'),
                ByteFor('9'),
                ByteFor(':'),
                ByteFor('1'),
                ByteFor('2'),
                ByteFor('5'),
                ByteFor('\t'),
                ByteFor('0'),
                ByteFor('3'),
                ByteFor('0'),
                ByteFor(':'),
                ByteFor('1'),
                ByteFor('\t'),
                ByteFor('0'),
                ByteFor('3'),
                ByteFor('1'),
                ByteFor(':'),
                ByteFor('2'),
                ByteFor('5'),
                ByteFor('9'),
                ByteFor('4'),
                ByteFor('3'),
                ByteFor('\t'),
                ByteFor('0'),
                ByteFor('3'),
                ByteFor('8'),
                ByteFor(':'),
                ByteFor('1'),
                ByteFor('6'),
                ByteFor('1'),
                ByteFor('2'),
                ByteFor('3'),
                ByteFor('\t'),
                ByteFor('0'),
                ByteFor('3'),
                ByteFor('2'),
                ByteFor(':'),
                ByteFor('5'),
                ByteFor('\t'),
                ByteFor('0'),
                ByteFor('3'),
                ByteFor('3'),
                ByteFor(':'),
                ByteFor('1'),
                ByteFor('0'),
                ByteFor('\t'),
                ByteFor('0'),
                ByteFor('3'),
                ByteFor('5'),
                ByteFor(':'),
                ByteFor('2'),
                ByteFor('3'),
                ByteFor('\t'),
                ByteFor('0'),
                ByteFor('1'),
                ByteFor('4'),
                ByteFor(':'),
                ByteFor('A'),
                ByteFor('B'),
                ByteFor('C'),
                ByteFor('D'),
                ByteFor('E'),
                ByteFor('F'),
                ByteFor('\t'),
                ByteFor('0'),
                ByteFor('1'),
                ByteFor('4'),
                ByteFor(':'),
                ByteFor('A'),
                ByteFor('A'),
                ByteFor('B'),
                ByteFor('B'),
                ByteFor('C'),
                ByteFor('C'),
                ByteFor('\t'),
                3
            });
        }