/// <inheritdoc />
        public void Run(IntPtr hubHandle, MyoRunHandler handler, IntPtr userData)
        {
            var command = MyoCommand.Create(
                _myoErrorHandlerDriver,
                () =>
            {
                IntPtr errorHandle;
                var result = PlatformInvocation.Running32Bit
                           ? _channelBridge.Run32(
                    hubHandle,
                    1000 / 20,
                    handler,
                    userData,
                    out errorHandle)
                           : _channelBridge.Run64(
                    hubHandle,
                    1000 / 20,
                    handler,
                    userData,
                    out errorHandle);

                return(MyoCommandResult.Create(result, errorHandle));
            });

            command.Execute();
        }
Пример #2
0
        public void Run_ValidParameters_ExpectedBridgeCalls()
        {
            // Setup
            var myoHandle = new IntPtr(123);
            var userData  = new IntPtr(789);
            var bridge    = new Mock <IChannelBridge>();

            var errorHandlerDriver = new Mock <IMyoErrorHandlerDriver>(MockBehavior.Strict);

            errorHandlerDriver
            .Setup(x => x.FreeMyoError(IntPtr.Zero));

            var           driver  = ChannelDriver.Create(bridge.Object, errorHandlerDriver.Object);
            MyoRunHandler handler = (_, __) => MyoRunHandlerResult.Continue;

            // Execute
            driver.Run(myoHandle, handler, userData);

            // Assert
            IntPtr errorHandle;

            bridge.Verify(x => x.Run32(myoHandle, 50, handler, userData, out errorHandle), PlatformInvocation.Running32Bit ? Times.Once() : Times.Never());
            bridge.Verify(x => x.Run64(myoHandle, 50, handler, userData, out errorHandle), PlatformInvocation.Running32Bit ? Times.Never() : Times.Once());

            errorHandlerDriver.Verify(x => x.FreeMyoError(IntPtr.Zero), Times.Once());
        }
Пример #3
0
        public MyoResult Run64(IntPtr hub, uint durationMs, MyoRunHandler handler, IntPtr userData, out IntPtr error)
        {
            Contract.Requires <ArgumentException>(hub != IntPtr.Zero, "The pointer to the hub must be set.");
            Contract.Requires <ArgumentException>(userData != IntPtr.Zero, "The pointer to user data must be set.");
            Contract.Requires <NullReferenceException>(handler != null, "handler");

            error = default(IntPtr);
            return(default(MyoResult));
        }
Пример #4
0
 private static void Run(IntPtr hubHandle, MyoRunHandler handler, IntPtr userData)
 {
     if (PlatformInvocation.Running32Bit)
     {
         run_32(
             hubHandle,
             1000 / 20,
             handler,
             userData,
             IntPtr.Zero);
     }
     else
     {
         run_64(
             hubHandle,
             1000 / 20,
             handler,
             userData,
             IntPtr.Zero);
     }
 }
Пример #5
0
 private static extern MyoResult run_64(IntPtr hub, uint durationMs, MyoRunHandler handler, IntPtr userData, out IntPtr error);
Пример #6
0
 /// <inheritdoc />
 public MyoResult Run64(IntPtr hub, uint durationMs, MyoRunHandler handler, IntPtr userData, out IntPtr error)
 {
     return run_64(hub, durationMs, handler, userData, out error);
 }
Пример #7
0
 private static extern MyoResult run_64(IntPtr hub, uint durationMs, MyoRunHandler handler, IntPtr userData, IntPtr error);
Пример #8
0
 public void Run(IntPtr hubHandle, MyoRunHandler handler, IntPtr userData)
 {
     Contract.Requires <ArgumentException>(hubHandle != IntPtr.Zero, "The pointer to the hub must be set.");
     Contract.Requires <ArgumentNullException>(handler != null, "handler");
     Contract.Requires <ArgumentException>(userData != IntPtr.Zero, "The pointer to the user data must be set.");
 }
Пример #9
0
        public MyoResult Run64(IntPtr hub, uint durationMs, MyoRunHandler handler, IntPtr userData, out IntPtr error)
        {
            Contract.Requires<ArgumentException>(hub != IntPtr.Zero, "The pointer to the hub must be set.");
            Contract.Requires<ArgumentException>(userData != IntPtr.Zero, "The pointer to user data must be set.");
            Contract.Requires<NullReferenceException>(handler != null, "handler");

            error = default(IntPtr);
            return default(MyoResult);
        }
Пример #10
0
 /// <inheritdoc />
 public MyoResult Run64(IntPtr hub, uint durationMs, MyoRunHandler handler, IntPtr userData, out IntPtr error)
 {
     return(run_64(hub, durationMs, handler, userData, out error));
 }
Пример #11
0
 public void Run(IntPtr hubHandle, MyoRunHandler handler, IntPtr userData)
 {
     Contract.Requires<ArgumentException>(hubHandle != IntPtr.Zero, "The pointer to the hub must be set.");
     Contract.Requires<ArgumentNullException>(handler != null, "handler");
     Contract.Requires<ArgumentException>(userData != IntPtr.Zero, "The pointer to the user data must be set.");
 }
Пример #12
0
        /// <inheritdoc />
        public void Run(IntPtr hubHandle, MyoRunHandler handler, IntPtr userData)
        {
            var command = MyoCommand.Create(
                _myoErrorHandlerDriver,
                () =>
                {
                    IntPtr errorHandle;
                    var result = PlatformInvocation.Running32Bit
                           ? _channelBridge.Run32(
                               hubHandle,
                               1000 / 20,
                               handler,
                               userData,
                               out errorHandle)
                           : _channelBridge.Run64(
                                hubHandle,
                                1000 / 20,
                                handler,
                                userData,
                                out errorHandle);

                    return MyoCommandResult.Create(result, errorHandle);
                });
            command.Execute();
        }