本文整理汇总了C#中DeviceMode类的典型用法代码示例。如果您正苦于以下问题:C# DeviceMode类的具体用法?C# DeviceMode怎么用?C# DeviceMode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DeviceMode类属于命名空间,在下文中一共展示了DeviceMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: XForwarder
/// <summary>
/// Initializes a new instance of the <see cref="XForwarder"/> class.
/// </summary>
/// <param name="context">The <see cref="NetMQContext"/> to use when creating the sockets.</param>
/// <param name="frontendBindAddress">The endpoint used to bind the frontend socket.</param>
/// <param name="backendBindAddress">The endpoint used to bind the backend socket.</param>
/// <param name="mode">The <see cref="DeviceMode"/> for the device.</param>
public XForwarder(NetMQContext context, string frontendBindAddress, string backendBindAddress,
DeviceMode mode = DeviceMode.Threaded)
: base(context.CreateXSubscriberSocket(), context.CreateXPublisherSocket(), mode)
{
this.FrontendSetup.Bind(frontendBindAddress);
this.BackendSetup.Bind(backendBindAddress);
}
示例2: DeviceBase
/// <summary>
/// Create a new instance of the <see cref="DeviceBase"/> class.
/// </summary>
/// <param name="poller">the <see cref="INetMQPoller"/> to use for detecting when messages are available</param>
/// <param name="frontendSocket">
/// A <see cref="NetMQSocket"/> that will pass incoming messages to <paramref name="backendSocket"/>.
/// </param>
/// <param name="backendSocket">
/// A <see cref="NetMQSocket"/> that will receive messages from (and optionally send replies to) <paramref name="frontendSocket"/>.
/// </param>
/// <param name="mode">the <see cref="DeviceMode"/> (either Blocking or Threaded) for this device</param>
/// <exception cref="ArgumentNullException">frontendSocket must not be null.</exception>
/// <exception cref="ArgumentNullException">backendSocket must not be null.</exception>
protected DeviceBase(INetMQPoller poller, NetMQSocket frontendSocket, NetMQSocket backendSocket, DeviceMode mode)
{
m_isInitialized = false;
if (frontendSocket == null)
throw new ArgumentNullException("frontendSocket");
if (backendSocket == null)
throw new ArgumentNullException("backendSocket");
FrontendSocket = frontendSocket;
BackendSocket = backendSocket;
FrontendSetup = new DeviceSocketSetup(FrontendSocket);
BackendSetup = new DeviceSocketSetup(BackendSocket);
m_poller = poller;
FrontendSocket.ReceiveReady += FrontendHandler;
BackendSocket.ReceiveReady += BackendHandler;
m_poller.Add(FrontendSocket);
m_poller.Add(BackendSocket);
m_runner = mode == DeviceMode.Blocking
? new DeviceRunner(this)
: new ThreadedDeviceRunner(this);
}
示例3: ForwarderDevice
/// <summary>
/// Initializes a new instance of the <see cref="ForwarderDevice"/> class.
/// </summary>
/// <param name="poller">The <see cref="INetMQPoller"/> to use.</param>
/// <param name="frontendBindAddress">The endpoint used to bind the frontend socket.</param>
/// <param name="backendBindAddress">The endpoint used to bind the backend socket.</param>
/// <param name="mode">The <see cref="DeviceMode"/> for the device.</param>
public ForwarderDevice(INetMQPoller poller, string frontendBindAddress, string backendBindAddress,
DeviceMode mode = DeviceMode.Threaded)
: base(poller, new SubscriberSocket(), new PublisherSocket(), mode)
{
FrontendSetup.Bind(frontendBindAddress);
BackendSetup.Bind(backendBindAddress);
}
示例4: ForwarderDevice
/// <summary>
/// Initializes a new instance of the <see cref="ForwarderDevice"/> class.
/// </summary>
/// <param name="context">The <see cref="NetMQContext"/> to use when creating the sockets.</param>
/// <param name="poller">The <see cref="Poller"/> to use.</param>
/// <param name="frontendBindAddress">The endpoint used to bind the frontend socket.</param>
/// <param name="backendBindAddress">The endpoint used to bind the backend socket.</param>
/// <param name="mode">The <see cref="DeviceMode"/> for the device.</param>
public ForwarderDevice(NetMQContext context, Poller poller, string frontendBindAddress, string backendBindAddress,
DeviceMode mode = DeviceMode.Threaded)
: base(poller, context.CreateSubscriberSocket(), context.CreatePublisherSocket(), mode)
{
FrontendSetup.Bind(frontendBindAddress);
BackendSetup.Bind(backendBindAddress);
}
示例5: XForwarderDevice
/// <summary>
/// Initializes a new instance of the <see cref="ForwarderDevice"/> class.
/// </summary>
/// <param name="context">The <see cref="ZmqContext"/> to use when creating the sockets.</param>
/// <param name="frontendBindAddr">The address used to bind the frontend socket.</param>
/// <param name="backendBindAddr">The endpoint used to bind the backend socket.</param>
/// <param name="mode">The <see cref="DeviceMode"/> for the current device.</param>
public XForwarderDevice(ZmqContext context, string frontendBindAddr, string backendBindAddr, DeviceMode mode)
: this(context, mode)
{
FrontendSetup.Bind(frontendBindAddr);
FrontendSetup.SubscribeAll();
BackendSetup.Bind(backendBindAddr);
}
示例6: QueueDevice
/// <summary>
/// Initializes a new instance of the <see cref="QueueDevice"/> class.
/// </summary>
/// <param name="context">The <see cref="NetMQContext"/> to use when creating the sockets.</param>
/// <param name="poller">The <see cref="Poller"/> to use.</param>
/// <param name="frontendBindAddress">The endpoint used to bind the frontend socket.</param>
/// <param name="backendBindAddress">The endpoint used to bind the backend socket.</param>
/// <param name="mode">The <see cref="DeviceMode"/> for the device.</param>
public QueueDevice(NetMQContext context, Poller poller, string frontendBindAddress, string backendBindAddress,
DeviceMode mode = DeviceMode.Threaded)
: base(poller, context.CreateRouterSocket(), context.CreateDealerSocket(), mode)
{
FrontendSetup.Bind(frontendBindAddress);
BackendSetup.Bind(backendBindAddress);
}
示例7: StreamerDevice
/// <summary>
/// Initializes a new instance of the <see cref="StreamerDevice"/> class.
/// </summary>
/// <param name="poller">The <see cref="INetMQPoller"/> to use.</param>
/// <param name="frontendBindAddress">The endpoint used to bind the frontend socket.</param>
/// <param name="backendBindAddress">The endpoint used to bind the backend socket.</param>
/// <param name="mode">The <see cref="DeviceMode"/> for the device.</param>
public StreamerDevice(INetMQPoller poller, string frontendBindAddress, string backendBindAddress,
DeviceMode mode = DeviceMode.Threaded)
: base(poller, new PullSocket(), new PushSocket(), mode)
{
FrontendSetup.Bind(frontendBindAddress);
BackendSetup.Bind(backendBindAddress);
}
示例8: StreamerDevice
/// <summary>
/// Initializes a new instance of the <see cref="StreamerDevice"/> class.
/// </summary>
/// <param name="context">The <see cref="NetMQContext"/> to use when creating the sockets.</param>
/// <param name="poller">The <see cref="Poller"/> to use.</param>
/// <param name="frontendBindAddress">The endpoint used to bind the frontend socket.</param>
/// <param name="backendBindAddress">The endpoint used to bind the backend socket.</param>
/// <param name="mode">The <see cref="DeviceMode"/> for the device.</param>
public StreamerDevice(NetMQContext context, Poller poller, string frontendBindAddress, string backendBindAddress,
DeviceMode mode = DeviceMode.Threaded)
: base(poller, context.CreatePullSocket(), context.CreatePushSocket(), mode)
{
FrontendSetup.Bind(frontendBindAddress);
BackendSetup.Bind(backendBindAddress);
}
示例9: Generate
/// <summary>
/// 画面を指定量回転させるためのオブジェクトを生成
/// </summary>
/// <param name="monitorID">ディスプレイのデバイス番号</param>
/// <returns>生成に失敗した場合はnull</returns>
public static DisplayRotate Generate(int monitorID)
{
var mode = new DeviceMode(monitorID);
return mode.IsSucceeded
? new DisplayRotate(mode)
: null;
}
示例10: HidDeviceMode
public HidDeviceMode(DeviceMode readMode, DeviceMode writeMode, ShareMode shareMode)
{
if (!_needChangeStatus) return;
/*
If the flag is "false", then we have the previous values of the attributes.
Update the values is not required.
*/
ReadMode = readMode;
WriteMode = writeMode;
ShareMode = shareMode;
_needChangeStatus = false;
}
示例11: BMP085
public BMP085(byte address, DeviceMode deviceMode)
{
Address = address;
_slaveConfig = new I2CDevice.Configuration(address, ClockRateKHz);
_oversamplingSetting = (byte)deviceMode;
// Get calibration data that will be used for future measurement taking.
GetCalibrationData();
// Take initial measurements.
TakeMeasurements();
}
示例12: OpenDeviceIO
internal static IntPtr OpenDeviceIO(string devicePath, DeviceMode deviceMode, uint deviceAccess)
{
var security = new NativeMethods.SECURITY_ATTRIBUTES();
var flags = 0;
if (deviceMode == DeviceMode.Overlapped) flags = NativeMethods.FILE_FLAG_OVERLAPPED;
security.lpSecurityDescriptor = IntPtr.Zero;
security.bInheritHandle = true;
security.nLength = Marshal.SizeOf(security);
return NativeMethods.CreateFile(devicePath, deviceAccess, NativeMethods.FILE_SHARE_READ | NativeMethods.FILE_SHARE_WRITE, ref security, NativeMethods.OPEN_EXISTING, flags, 0);
}
示例13: OpenDevice
public void OpenDevice(DeviceMode readMode, DeviceMode writeMode, ShareMode shareMode)
{
if (IsOpen) return;
_deviceReadMode = readMode;
_deviceWriteMode = writeMode;
try
{
Handle = OpenDeviceIO(_devicePath, readMode, NativeMethods.GENERIC_READ | NativeMethods.GENERIC_WRITE, shareMode);
}
catch (Exception exception)
{
IsOpen = false;
throw new Exception("Error opening HID device.", exception);
}
IsOpen = Handle.ToInt32() != NativeMethods.INVALID_HANDLE_VALUE;
}
示例14: HidDevice
public HidDevice(HidDeviceInfo info, DeviceMode devideReadMode, DeviceMode deviceWriteMode)
{
Path = info.Path;
Description = info.Description;
ReportID = 0x0;
DeviceReadMode = devideReadMode;
DeviceWriteMode = deviceWriteMode;
Timeout = 30;
try
{
Handle = OpenDeviceIO();
GetDeviceAttributes();
GetDeviceCapabilities();
}
catch
{
Dispose();
throw;
}
}
示例15: Device
/// <summary>
/// Initializes a new instance of the <see cref="Device"/> class.
/// </summary>
/// <param name="frontendSocket">
/// A <see cref="ZmqSocket"/> that will pass incoming messages to <paramref name="backendSocket"/>.
/// </param>
/// <param name="backendSocket">
/// A <see cref="ZmqSocket"/> that will receive messages from (and optionally send replies to) <paramref name="frontendSocket"/>.
/// </param>
/// <param name="mode">The <see cref="DeviceMode"/> for the current device.</param>
protected Device(ZmqSocket frontendSocket, ZmqSocket backendSocket, DeviceMode mode)
{
if (frontendSocket == null)
{
throw new ArgumentNullException("frontendSocket");
}
if (backendSocket == null)
{
throw new ArgumentNullException("backendSocket");
}
FrontendSocket = frontendSocket;
BackendSocket = backendSocket;
FrontendSetup = new DeviceSocketSetup(FrontendSocket);
BackendSetup = new DeviceSocketSetup(BackendSocket);
DoneEvent = new ManualResetEvent(false);
_poller = new Poller();
_runner = mode == DeviceMode.Blocking ? new DeviceRunner(this) : new ThreadedDeviceRunner(this);
}