Welcome to mirror list, hosted at ThFree Co, Russian Federation.

UsbLockStyle.cs « Main « LibWinUsb - github.com/ClusterM/clovershell-client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5f905980385bac586b4e9eab11106ba896da69f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// Copyright © 2006-2009 Travis Robinson. All rights reserved.
// 
// website: sourceforge.net/projects/libusbdotnet/
// e-mail:  libusbdotnet@gmail.com
// 
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2 of the License, or 
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful, but 
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// for more details.
// 
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. or 
// visit www.gnu.org.
// 
// 
namespace LibUsbDotNet.Main
{
    /// <summary>Contains the locking strategy for a <see cref="UsbDevice"/> and it's associated endpoints.</summary>
    /// <remarks>Locking styles are use to change the way proccess/threads are allowed to communcate with a USB device and/or endpoints.
    /// See the <see cref="DeviceLockType"/>, <see cref="ControlEpLockType"/>, and <see cref="DataEpLockType"/> enumerations for a description of the various locking styles.
    /// </remarks> 
    public class UsbLockStyle
    {
        private ControlEpLockType mControlEpLock;
        private DataEpLockType mDataEpLock;
        private DeviceLockType mDeviceLockType;
        private int mEndpointControlTimeout;
        private int mEndpointLockTimeout;

        /// <summary>
        /// Create a device lock style class.
        /// </summary>
        /// <param name="deviceLockType">See <see cref="DeviceLockType"/>.</param>
        /// <param name="controlEpLockType">See <see cref="ControlEpLock"/>.</param>
        /// <param name="dataEpLockType">See <see cref="DataEpLock"/>.</param>
        public UsbLockStyle(DeviceLockType deviceLockType, ControlEpLockType controlEpLockType, DataEpLockType dataEpLockType)
            : this(deviceLockType, controlEpLockType, dataEpLockType, 1000, 1000)
        {
        }

        /// <summary>
        /// Create a device lock style class.
        /// </summary>
        /// <param name="deviceLockType">See <see cref="DeviceLockType"/>.</param>
        /// <param name="controlEpLockType">See <see cref="ControlEpLock"/>.</param>
        /// <param name="dataEpLockType">See <see cref="DataEpLock"/>.</param>
        /// <param name="endpoint0Timeout">Number of milliseconds to wait for an endpoint 0 lock before returning a timeout errorcode.</param>
        /// <param name="endpointLockTimeout">Number of milliseconds to wait for an endpoint lock before returning a timeout errorcode.</param>
        public UsbLockStyle(DeviceLockType deviceLockType,
                            ControlEpLockType controlEpLockType,
                            DataEpLockType dataEpLockType,
                            int endpoint0Timeout,
                            int endpointLockTimeout)
        {
            mDeviceLockType = deviceLockType;
            mControlEpLock = controlEpLockType;
            mDataEpLock = dataEpLockType;
            mEndpointControlTimeout = endpoint0Timeout;
            mEndpointLockTimeout = endpointLockTimeout;
        }

        /// <summary>
        /// Locking strategy for the device. See <see cref="DeviceLockType"/> for more information.
        /// </summary>
        public DeviceLockType DeviceLockType
        {
            get
            {
                return mDeviceLockType;
            }
            set
            {
                mDeviceLockType = value;
            }
        }

        /// <summary>
        /// Locking strategy for <see cref="UsbDevice"/> Endpoint0 operations. This property will generally always be <see cref="ControlEpLockType.None"/>, See <see cref="ControlEpLockType"/> for more information.
        /// </summary>
        public ControlEpLockType ControlEpLock
        {
            get
            {
                return mControlEpLock;
            }
            set
            {
                mControlEpLock = value;
            }
        }

        /// <summary>
        /// Locking strategy for the <see cref="UsbDevice"/> endpoint operations. See <see cref="DataEpLockType"/> for more information.
        /// </summary>
        public DataEpLockType DataEpLock
        {
            get
            {
                return mDataEpLock;
            }
            set
            {
                mDataEpLock = value;
            }
        }

        /// <summary>
        /// Timeout value used when attempting to aquire an <see cref="ControlEpLockType"/> when <see cref="ControlEpLock"/> is set to a value other than <see cref="ControlEpLockType.None"/>.
        /// </summary>
        public int EndpointControlTimeout
        {
            get
            {
                return mEndpointControlTimeout;
            }
            set
            {
                mEndpointControlTimeout = value;
            }
        }

        /// <summary>
        /// Maximum time(ms) to wait for an endpoint to become idle before returning a <see cref="ErrorCode.EndpointLockTimedOut"/> error code.
        /// </summary>
        /// <remarks>
        /// This property has no affect unless the <see cref="UsbDevice.LockStyle"/> includes the <see cref="DataEpLockType.Locked"/> enumeration.
        /// </remarks>
        public int EndpointLockTimeout
        {
            get
            {
                return mEndpointLockTimeout;
            }
            set
            {
                mEndpointLockTimeout = value;
            }
        }
    }
}