protected override void EstablishContext()
        {
            controlDevice = A.Fake <IControlDevice>();
            controlDevice
            .CallsTo(device => device.Control(A <uint> .Ignored, A <SpiTransferControlStructure[]> .Ignored))
            .Returns(IOCTL_PINVOKE_RESULT_CODE);

            connection = new NativeSpiConnection(controlDevice);

            // SPI control structure we expect to see during the P/Invoke call
            controlStructure = new SpiTransferControlStructure {
                BitsPerWord      = BITS_PER_WORD,
                Length           = 5,
                Delay            = DELAY,
                ChipSelectChange = 1,
                Speed            = SPEED_IN_HZ
            };

            buffer = A.Fake <ISpiTransferBuffer>();
            buffer
            .CallsTo(b => b.ControlStructure)
            .Returns(controlStructure);

            // setup fake collection to return our "prepared" fake buffer
            collection = A.Fake <ISpiTransferBufferCollection>();
            collection
            .CallsTo(c => c.Length)
            .Returns(1);
            collection
            .CallsTo(c => c.GetEnumerator())
            .ReturnsLazily(call => new List <ISpiTransferBuffer> {
                buffer
            }.GetEnumerator());
        }
Ejemplo n.º 2
0
 public RelayDecorator(IControlDevice nd)
 {
     if (nd == null || nd == this)
     {
         throw new ArgumentException();
     }
     nextDevice = nd;
 }
Ejemplo n.º 3
0
        public AgvMissionManagerClient(IControlDevice _carryDevice)
        {
            missionContext = new MissionContext(_carryDevice);
            missionContext.SendAgvMissionServiceStateMessageEvent += (obj) => ShowLogEvent?.Invoke(obj);
            missionContext.SendSignalrEvent   += (action, obj) => SendSignalrEvent?.Invoke(action, obj);
            missionContext.SendAgvMissonEvent += (s) => SendAgvMissonEvent?.Invoke(s);

            InitMissionState();
        }
Ejemplo n.º 4
0
        protected RelayDecorator(IControlDevice nd)
        {
            if (nd == this)
            {
                throw new ArgumentException("Cannot decorate itself");
            }

            _decoratee = nd ?? throw new ArgumentNullException(nameof(nd), "Cannot decorate null object");
        }
        protected override void EstablishContext() {
            settings = new SpiConnectionSettings {
                BitsPerWord = BITS_PER_WORD,
                Delay = DELAY,
                Mode = SPI_MODE,
                MaxSpeed = SPEED_IN_HZ
            };

            controlDevice = A.Fake<IControlDevice>();
        }
        protected override void EstablishContext()
        {
            settings = new SpiConnectionSettings {
                BitsPerWord = BITS_PER_WORD,
                Delay       = DELAY,
                Mode        = SPI_MODE,
                MaxSpeed    = SPEED_IN_HZ
            };

            controlDevice = A.Fake <IControlDevice>();
        }
Ejemplo n.º 7
0
        public MissionContext(IControlDevice _carryDevice)
        {
            carryDevice = _carryDevice;

            brotherMissionType = new Dictionary <AgvMissionTypeEnum, AgvMissionTypeEnum>();
            MissionInNodes     = new BlockingCollection <AgvInMissonModel>();
            MissionOutNodes    = new BlockingCollection <AgvOutMissonModel>();
            brotherMissionType.Add(AgvMissionTypeEnum.RAW_IN, AgvMissionTypeEnum.EMPTY_OUT);
            brotherMissionType.Add(AgvMissionTypeEnum.EMPTY_IN, AgvMissionTypeEnum.FIN_OUT);

            //测试用
            //实例化 RightCarryService\AllenBradleyControlDevice


            // carryDevice = new TestControlDevice();
            //  carryDevice = new AllenBradleyControlDevice();
        }
        protected override void EstablishContext()
        {
            // SPI control structure we expect to see during the P/Invoke call
            controlStructure = new SpiTransferControlStructure {
                BitsPerWord      = BITS_PER_WORD,
                Length           = 5,
                Delay            = DELAY,
                ChipSelectChange = 1,
                Speed            = SPEED_IN_HZ
            };

            controlDevice = A.Fake <IControlDevice>();
            controlDevice
            .CallsTo(device => device.Control(A <uint> .Ignored, ref controlStructure))
            .WithAnyArguments()
            .Returns(IOCTL_PINVOKE_RESULT_CODE);

            connection = new NativeSpiConnection(controlDevice);

            buffer = A.Fake <ISpiTransferBuffer>();
            buffer
            .CallsTo(b => b.ControlStructure)
            .Returns(controlStructure);
        }
Ejemplo n.º 9
0
 public Radio(IControlDevice nd) : base(nd)
 {
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Creates a new instance of the <see cref="NativeSpiConnection"/> class and initializes it.
 /// </summary>
 /// <param name="deviceFile">A control device (IOCTL) to the device file (e.g. /dev/spidev0.0).</param>
 /// <param name="settings">Connection settings</param>
 public NativeSpiConnection(IControlDevice deviceFile, SpiConnectionSettings settings)
     : this(deviceFile)
 {
     Init(settings);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Creates a new instance of the <see cref="NativeSpiConnection"/> class.
 /// </summary>
 /// <param name="deviceFile">A control device (IOCTL) to the device file (e.g. /dev/spidev0.0).</param>
 public NativeSpiConnection(IControlDevice deviceFile)
 {
     this.deviceFile = deviceFile;
 }
Ejemplo n.º 12
0
 public ExtendLight(IControlDevice nd) : base(nd)
 {
 }
 /// <summary>
 /// Creates a new instance of the <see cref="NativeSpiConnection"/> class and initializes it.
 /// </summary>
 /// <param name="deviceFile">A control device (IOCTL) to the device file (e.g. /dev/spidev0.0).</param>
 /// <param name="settings">Connection settings</param>
 public NativeSpiConnection(IControlDevice deviceFile, SpiConnectionSettings settings)
     : this(deviceFile)
 {
     Init(settings);
 }
 /// <summary>
 /// Creates a new instance of the <see cref="NativeSpiConnection"/> class.
 /// </summary>
 /// <param name="deviceFile">A control device (IOCTL) to the device file (e.g. /dev/spidev0.0).</param>
 public NativeSpiConnection(IControlDevice deviceFile) {
     this.deviceFile = deviceFile;
 }
        protected override void EstablishContext() {
            controlDevice = A.Fake<IControlDevice>();
            controlDevice
                .CallsTo(device => device.Control(A<uint>.Ignored, A<SpiTransferControlStructure[]>.Ignored))
                .Returns(IOCTL_PINVOKE_RESULT_CODE);

            connection = new NativeSpiConnection(controlDevice);

            // SPI control structure we expect to see during the P/Invoke call
            controlStructure = new SpiTransferControlStructure {
                BitsPerWord = BITS_PER_WORD,
                Length = 5,
                Delay = DELAY,
                ChipSelectChange = 1,
                Speed = SPEED_IN_HZ
            };

            buffer = A.Fake<ISpiTransferBuffer>();
            buffer
                .CallsTo(b => b.ControlStructure)
                .Returns(controlStructure);
            
            // setup fake collection to return our "prepared" fake buffer
            collection = A.Fake<ISpiTransferBufferCollection>();
            collection
                .CallsTo(c => c.Length)
                .Returns(1);
            collection
                .CallsTo(c => c.GetEnumerator())
                .ReturnsLazily(call => new List<ISpiTransferBuffer>{buffer}.GetEnumerator());
        }
        protected override void EstablishContext() {
            // SPI control structure we expect to see during the P/Invoke call
            controlStructure = new SpiTransferControlStructure {
                BitsPerWord = BITS_PER_WORD,
                Length = 5,
                Delay = DELAY,
                ChipSelectChange = 1,
                Speed = SPEED_IN_HZ
            };
            
            controlDevice = A.Fake<IControlDevice>();
            controlDevice
                .CallsTo(device => device.Control(A<uint>.Ignored, ref controlStructure))
                .WithAnyArguments()
                .Returns(IOCTL_PINVOKE_RESULT_CODE);

            connection = new NativeSpiConnection(controlDevice);

            buffer = A.Fake<ISpiTransferBuffer>();
            buffer
                .CallsTo(b => b.ControlStructure)
                .Returns(controlStructure);
        }