Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Channel" /> class.
        /// </summary>
        /// <param name="channelDriver">The channel driver. Cannot be <c>null</c>.</param>
        /// <param name="applicationIdentifier">The application identifier must follow a reverse domain name format (ex. com.domainname.appname). Application
        /// identifiers can be formed from the set of alphanumeric ASCII characters (a-z, A-Z, 0-9). The hyphen (-) and
        /// underscore (_) characters are permitted if they are not adjacent to a period (.) character  (i.e. not at the
        /// start or end of each segment), but are not permitted in the top-level domain. Application identifiers must have
        /// three or more segments. For example, if a company's domain is example.com and the application is named
        /// hello-world, one could use "com.example.hello-world" as a valid application identifier. The application identifier
        /// can be an empty string. The application identifier cannot be longer than 255 characters.</param>
        /// <param name="autostart">If set to <c>true</c>, the channel will be automatically started.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The exception that is thrown when <paramref name="channelDriver"/> or <paramref name="applicationIdentifier"/> is <c>null</c>.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// The exception that is thrown when <paramref name="applicationIdentifier"/> is invalid.
        /// </exception>
        /// <exception cref="System.InvalidOperationException">
        /// The exception that is thrown when the hub fails to initialize.
        /// </exception>
        private Channel(IChannelDriver channelDriver, string applicationIdentifier, bool autostart)
        {
            _channelDriver = channelDriver;

            _handle = channelDriver.InitializeMyoHub(applicationIdentifier);
            if (_handle == IntPtr.Zero)
            {
                throw new InvalidOperationException("After an attempt to initialize the Myo hub, no pointer was provided.");
            }

            if (autostart)
            {
                StartListening();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Channel" /> class.
        /// </summary>
        /// <param name="channelDriver">The channel driver. Cannot be <c>null</c>.</param>
        /// <param name="applicationIdentifier">The application identifier must follow a reverse domain name format (ex. com.domainname.appname). Application
        /// identifiers can be formed from the set of alphanumeric ASCII characters (a-z, A-Z, 0-9). The hyphen (-) and
        /// underscore (_) characters are permitted if they are not adjacent to a period (.) character  (i.e. not at the
        /// start or end of each segment), but are not permitted in the top-level domain. Application identifiers must have
        /// three or more segments. For example, if a company's domain is example.com and the application is named
        /// hello-world, one could use "com.example.hello-world" as a valid application identifier. The application identifier
        /// can be an empty string. The application identifier cannot be longer than 255 characters.</param>
        /// <param name="autostart">If set to <c>true</c>, the channel will be automatically started.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The exception that is thrown when <paramref name="channelDriver"/> or <paramref name="applicationIdentifier"/> is <c>null</c>.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// The exception that is thrown when <paramref name="applicationIdentifier"/> is invalid.
        /// </exception>
        /// <exception cref="System.InvalidOperationException">
        /// The exception that is thrown when the hub fails to initialize.
        /// </exception>
        private Channel(IChannelDriver channelDriver, string applicationIdentifier, bool autostart)
        {
            ////Contract.Requires<ArgumentNullException>(channelDriver != null, "channelDriver");
            ////Contract.Requires<ArgumentNullException>(applicationIdentifier != null, "applicationIdentifier");
            ////Contract.Requires<ArgumentException>(applicationIdentifier.Length <= 255, "The application identifier cannot be longer than 255 characters.");

            _channelDriver = channelDriver;

            _handle = channelDriver.InitializeMyoHub(applicationIdentifier);
            if (_handle == IntPtr.Zero)
            {
                throw new InvalidOperationException("After an attempt to initialize the Myo hub, no pointer was provided.");
            }

            if (autostart)
            {
                StartListening();
            }
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Channel" /> class.
        /// </summary>
        /// <param name="channelDriver">The channel driver. Cannot be <c>null</c>.</param>
        /// <param name="applicationIdentifier">The application identifier must follow a reverse domain name format (ex. com.domainname.appname). Application
        /// identifiers can be formed from the set of alphanumeric ASCII characters (a-z, A-Z, 0-9). The hyphen (-) and
        /// underscore (_) characters are permitted if they are not adjacent to a period (.) character  (i.e. not at the
        /// start or end of each segment), but are not permitted in the top-level domain. Application identifiers must have
        /// three or more segments. For example, if a company's domain is example.com and the application is named
        /// hello-world, one could use "com.example.hello-world" as a valid application identifier. The application identifier
        /// can be an empty string. The application identifier cannot be longer than 255 characters.</param>
        /// <param name="autostart">If set to <c>true</c>, the channel will be automatically started.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The exception that is thrown when <paramref name="channelDriver"/> or <paramref name="applicationIdentifier"/> is <c>null</c>.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// The exception that is thrown when <paramref name="applicationIdentifier"/> is invalid.
        /// </exception>
        /// <exception cref="System.InvalidOperationException">
        /// The exception that is thrown when the hub fails to initialize.
        /// </exception>
        private Channel(IChannelDriver channelDriver, string applicationIdentifier, bool autostart)
        {
            Contract.Requires<ArgumentNullException>(channelDriver != null, "channelDriver");
            Contract.Requires<ArgumentNullException>(applicationIdentifier != null, "applicationIdentifier");
            Contract.Requires<ArgumentException>(applicationIdentifier.Length <= 255, "The application identifier cannot be longer than 255 characters.");

            _channelDriver = channelDriver;

            _handle = channelDriver.InitializeMyoHub(applicationIdentifier);
            if (_handle == IntPtr.Zero)
            {
                throw new InvalidOperationException("After an attempt to initialize the Myo hub, no pointer was provided.");
            }

            if (autostart)
            {
                StartListening();
            }
        }