/// <summary> /// Generates a collection of audio endpoint devices that meet the specified criteria. /// </summary> /// <param name="dataFlow">The data-flow direction for the endpoint device.</param> /// <param name="stateMask">The state or states of the endpoints that are to be included in the collection.</param> /// <returns><see cref="MMDeviceCollection"/> which contains the enumerated devices.</returns> public static MMDeviceCollection EnumerateDevices(DataFlow dataFlow, DeviceState stateMask) { using (var enumerator = new MMDeviceEnumerator()) { return enumerator.EnumAudioEndpoints(dataFlow, stateMask); } }
public IHttpActionResult GetByState(Guid companyId, DeviceState state) { IReadOnlyCollection<Device> devices; if (state == DeviceState.Pending) { devices = DeviceRepository.GetPending(companyId); } else if (state == DeviceState.Approved) { devices = DeviceRepository.GetApproved(companyId); } else if (state == DeviceState.Declined) { devices = DeviceRepository.GetDeclined(companyId); } else if (state == DeviceState.Blocked) { devices = DeviceRepository.GetBlocked(companyId); } else { throw new NotImplementedException(String.Format("There is no implementation for DeviceState '{0}'", state)); } var model = devices.Select(x => DeviceModel.From(x)); return Ok(model); }
/// <summary> /// Generates a collection of audio endpoint devices that meet the specified criteria. /// </summary> /// <param name="dataFlow">The data-flow direction for the endpoint device.</param> /// <param name="stateMask">The state or states of the endpoints that are to be included in the collection.</param> /// <returns><see cref="MMDeviceCollection"/> which contains the enumerated devices.</returns> public MMDeviceCollection EnumAudioEndpoints(DataFlow dataFlow, DeviceState stateMask) { IntPtr pcollection; CoreAudioAPIException.Try(EnumAudioEndpointsNative(dataFlow, stateMask, out pcollection), InterfaceName, "EnumAudioEndpoints"); return new MMDeviceCollection(pcollection); }
public HardDrive(RenderWindow window, VirtualMachine virtualMachine, XElement config) { vm = virtualMachine; state = DeviceState.None; var errorMsg = ""; try { errorMsg = "Bad Port"; devPort = short.Parse(Util.ElementValue(config, "Port", null)); errorMsg = "Bad FileName"; var fileName = Util.ElementValue(config, "FileName", null); if (fileName == null) throw new Exception(); errorMsg = string.Format("Failed to open '{0}'", fileName); diskImage = new FileStream(fileName, FileMode.Open); sectorCount = (ushort)(new FileInfo(fileName).Length / BytesPerSector); } catch (Exception e) { throw new Exception(string.Format("HardDrive: {0}", errorMsg), e); } }
public AudioDeviceLister(DeviceState state) { _state = state; AudioController.DeviceAdded += AudioControllerOnDeviceAdded; AudioController.DeviceRemoved += AudioControllerOnDeviceRemoved; AudioController.DeviceStateChanged += AudioControllerOnDeviceStateChanged; }
public unsafe int EnumAudioEndpointsNative(DataFlow dataFlow, DeviceState stateMask, out IntPtr collection) { IntPtr pcollection; int result = InteropCalls.CallI(_basePtr, unchecked(dataFlow), unchecked(stateMask), &pcollection, ((void**)(*(void**)_basePtr))[3]); collection = pcollection; return result; }
/// <summary> /// Creates a device with the specific serial number /// </summary> /// <param name="serialNo">The serial number of the device as a String</param> /// <param name="model">The model of the device</param> /// <param name="productName">The product name of the device</param> /// <param name="state">The state of the device</param> internal Device(string serialNo, string model, string productName, string name, DeviceState state) { mSerialNumber = serialNo; mProductName = productName; mModel = model; mConnectionStatus = state; mName = name; }
public override Boolean Open(int Instance = 0) { if (base.Open(Instance)) { m_State = DeviceState.Reserved; } return State == DeviceState.Reserved; }
public static DeviceStateRequest From(DeviceState state, DateTime changeDate, string comment) { return new DeviceStateRequest() { State = state, ChangeDate = changeDate, Comment = comment }; }
public virtual void ApplyState(DeviceState state) { // Shouldn't change any of these post creation state.Name = mState.Name; state.DisplayName = mState.DisplayName; state.Archetype = mState.Archetype; if (!state.Type.Equals(mState.Type)) throw new InvalidOperationException(string.Format("Type {0} of source state does not match type {1} of target state", state.Type, mState.Type)); }
public override Boolean Close() { if (IsActive) { Unplug(0); m_State = DeviceState.Disconnected; } return base.Close(); }
public static StateModel From(DeviceState state, DateTime changeDate, string macAddress, string comment) { return new StateModel() { State = state.ToString(), ChangeDate = changeDate, MacAddress = macAddress, Comment = comment }; }
protected DeviceBase(DeviceState state, DeviceCreationInfo creationInfo) { mState = state; mState.Name = creationInfo.Configuration.name; try { mState.DisplayName = creationInfo.Configuration.displayName; } catch (RuntimeBinderException) { } // Optional mState.Type = GetType().ToString(); }
public DirectXOutputDevice(Controller controller) { _controller = controller; _deviceState = DeviceState.Stopped; _streamWriteProcDelegate = OutputStreamWriteProc; _silence = new Silence(); _deviceNo = GetDeviceNo(); BASSInit flags = BASSInit.BASS_DEVICE_DEFAULT; // Because all deviceinfo is saved in a static dictionary, // we need to determine the latency only once. if (!_deviceInfos.ContainsKey(_deviceNo)) flags |= BASSInit.BASS_DEVICE_LATENCY; bool result = Bass.BASS_Init( _deviceNo, 44100, //Only relevant for -> pre-XP (VxD drivers) flags, IntPtr.Zero); BASSError? bassInitErrorCode = result ? null : new BASSError?(Bass.BASS_ErrorGetCode()); // If the GetDeviceNo() method returned BassConstants.BassDefaultDevice, we must request the actual device number // of the choosen default device _deviceNo = Bass.BASS_GetDevice(); if (bassInitErrorCode.HasValue) { if (bassInitErrorCode.Value == BASSError.BASS_ERROR_ALREADY) { if (!Bass.BASS_SetDevice(_deviceNo)) throw new BassLibraryException("BASS_SetDevice"); bassInitErrorCode = null; } } if (bassInitErrorCode.HasValue) throw new BassLibraryException("BASS_Init", bassInitErrorCode.Value); CollectDeviceInfo(_deviceNo); int ms = Convert.ToInt32(Controller.GetSettings().DirectSoundBufferSize.TotalMilliseconds); if (!Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_BUFFER, ms)) throw new BassLibraryException("BASS_SetConfig"); // Enable update thread while the output device is active if (!Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATEPERIOD, ms / 4)) throw new BassLibraryException("BASS_SetConfig"); }
public override Boolean Open(String DevicePath) { m_Path = DevicePath; m_WinUsbHandle = (IntPtr) INVALID_HANDLE_VALUE; if (GetDeviceHandle(m_Path)) { m_IsActive = true; m_State = DeviceState.Reserved; } return State == DeviceState.Reserved; }
public override void ApplyState(DeviceState state) { base.ApplyState(state); var newState = (ComputerState)state; var currentState = (ComputerState)mState; if (newState.Power != currentState.Power) SetPower(newState.Power); if (newState.MonitorPower != currentState.MonitorPower) SetMonitorPower(newState.MonitorPower); }
/// <summary> /// Initializes a default InputManager without config. /// This means almost none of the methods will work such as IsPressed() /// </summary> /// <param name="device">The target Joystick which needs to be managed</param> public DirectInputManager(Joystick device) { this.device = device; if (device != null) { device.Acquire(); } config = new List <Tuple <int, DeviceButton> >(); // for digital dpads DeviceState state = GetState(); X_CENTER_L = state.LeftThumbStick.X; Y_CENTER_L = state.LeftThumbStick.Y; X_CENTER_R = state.RightThumbStick.X; Y_CENTER_R = state.RightThumbStick.Y; }
/// <summary> /// Creates a new instance of the GPU General Purpose FIFO class. /// </summary> /// <param name="context">GPU context</param> public GPFifoClass(GpuContext context) { _context = context; _state = new DeviceState <GPFifoClassState>(new Dictionary <string, RwCallback> { { nameof(GPFifoClassState.Semaphored), new RwCallback(Semaphored, null) }, { nameof(GPFifoClassState.Syncpointb), new RwCallback(Syncpointb, null) }, { nameof(GPFifoClassState.WaitForIdle), new RwCallback(WaitForIdle, null) }, { nameof(GPFifoClassState.LoadMmeInstructionRam), new RwCallback(LoadMmeInstructionRam, null) }, { nameof(GPFifoClassState.LoadMmeStartAddressRam), new RwCallback(LoadMmeStartAddressRam, null) }, { nameof(GPFifoClassState.SetMmeShadowRamControl), new RwCallback(SetMmeShadowRamControl, null) } }); _macros = new Macro[MacrosCount]; _macroCode = new int[MacroCodeSize]; }
public void OnDeviceStateChanged(string deviceId, DeviceState newState) { var device = _sessions.FirstOrDefault(meter => meter.Id == deviceId); if (device is null) { return; } if (newState == DeviceState.Active) { _dirtySources = true; } _logger.LogInformation($"OnDeviceStateChanged: {deviceId}, {newState}"); }
public void OnStateChanged(DeviceState state) { if (_lastState == state) { return; } _lastState = state; if (Dispatcher.CheckAccess()) { SetNewState(state); } else { Dispatcher.BeginInvoke(new Action(() => SetNewState(state))); } }
public void SetCurrent(DeviceState deviceState) { switch (deviceState) { case DeviceState.ON: _state = new On(); break; case DeviceState.OFF: _state = new Off(); break; default: break; } }
public override CoreAudioDevice GetDevice(Guid id, DeviceState state) { var acquiredLock = _lock.AcquireReadLockNonReEntrant(); try { return(_deviceCache.FirstOrDefault(x => x.Id == id && state.HasFlag(x.State))); } finally { if (acquiredLock) { _lock.ExitReadLock(); } } }
private void parseDeviceState(DeviceState result, string html) { html = Regex.Replace(html, @"\<!--.*?--\>", ""); var m = _regState.Match(html); var data = getDataFromHtmlRegex(m, _regState); result.ConnTime = data["ConnTime"]; result.TxRate = data["TxRate"]; result.RxRate = data["RxRate"]; result.ExtenderSsid = data["ExtenderSsid"]; result.CurChan = int.Parse(data["CurChan"]); result.WlanConnected = int.Parse(data["WlanConnStatus"]) == 1; result.InternetStatus = (DeviceState.InternetStatusEnum) int.Parse(data["InternetStatus"]); result.IPConnStatus = (DeviceState.ConnStatusEnum) int.Parse(data["IpConnStatus"]); result.CurRootapRssi = double.Parse(data["CurRootapRssi"]); }
internal void SetResult(DeviceState State, Types.VTM.TestResults Result) { if (State != DeviceState.InProcess) { IsRunning = false; if (State == DeviceState.Success) { Plot(Result.SelfTestArray, Result.CapacitorsArray); } } else { ClearStatus(); } }
public Device(ILogger loggerIn, IDeviceConnection deviceConnectionIn, IDeviceCommunication deviceCommunicationIn) { logger = loggerIn; deviceConnection = deviceConnectionIn; deviceCommunication = deviceCommunicationIn; deviceConnection.SetCallback(GetHost, GetPort, SetDeviceState, OnReceiveMessage); deviceState = DeviceState.NotConnected; discoveredDevice = new DiscoveredDevice(); volumeSetting = new Volume { controlType = "attenuation", level = 0.0f, muted = false, stepInterval = 0.05f }; }
//check connected device with specific state private bool autodetect(DeviceState Tstate) { bool res = false; timer2.Enabled = true; if (devices.State == Tstate) { res = true; } else if (devices.State != Tstate) { timer2.Enabled = true; res = false; } return(res); }
public void SetUp() { _fakeUsbDevice = Mock.Of <IUsbDevice>(); _fakeEvalBoard = Mock.Of <IDenseDacEvalBoard>(); _deviceState = new DeviceState(); Mock.Get(_fakeEvalBoard) .SetupGet(x => x.DeviceState) .Returns(_deviceState); Mock.Get(_fakeEvalBoard) .SetupGet(x => x.UsbDevice) .Returns(_fakeUsbDevice); _usbControlTransferCommand = new USBControlTransferCommand(_fakeEvalBoard); }
/// <summary> /// Save the time to do the firewall check later. /// </summary> /// <param name="state"></param> private void DoFirewallCheckSaveTimes(DeviceState state) { if (state == DeviceState.LoadingMedia) { lastLoadMessageTime = DateTime.Now; addStreamingConnectionTime = null; } else if (state != DeviceState.Idle && state != DeviceState.Connected && state != DeviceState.NotConnected && state != DeviceState.Buffering && state != DeviceState.Closed) { lastLoadMessageTime = null; } }
public void SetUp() { _fakeEvalBoard = Mock.Of <IDenseDacEvalBoard>(); _deviceState = new DeviceState(); Mock.Get(_fakeEvalBoard) .SetupGet(x => x.DeviceState) .Returns(_deviceState); _deviceState.UseRegisterCache = true; _fakeSendSpecialFunctionCommand = Mock.Of <ISendSpecialFunction>(); Mock.Get(_fakeSendSpecialFunctionCommand) .Setup(x => x.SendSpecialFunction(It.IsAny <SpecialFunctionCode>(), It.IsAny <ushort>())) .Verifiable(); _writeOFS0RegisterCommand = new WriteOFS0RegisterCommand(_fakeEvalBoard, _fakeSendSpecialFunctionCommand); }
public ZWaveCommandClass?ConvertStateToCommand(DeviceState state, out object value) { switch (state) { case DeviceState.On: value = 255; return(ZWaveCommandClass.Basic); case DeviceState.Off: value = 0; return(ZWaveCommandClass.Basic); } value = null; return(null); }
/// <summary> /// Set the device status. /// </summary> /// <param name="state">the state</param> /// <param name="statusText">status text</param> public void SetDeviceState(DeviceState state, string statusText = null) { if (deviceControl == null || deviceControl.IsDisposed) { return; } if (deviceControl.InvokeRequired) { if (!deviceControl.IsDisposed) { try { SetDeviceStateCallback callback = new SetDeviceStateCallback(SetDeviceState); deviceControl?.Invoke(callback, new object[] { state, statusText }); } catch (Exception ex) { Console.WriteLine($"SetDeviceState: {ex.Message}"); } } } else { // Restart when recovering from a connection error. if (state != DeviceState.ConnectError && wasPlayingWhenConnectError) { wasPlayingWhenConnectError = false; ResumePlaying(); } else if (state == DeviceState.ConnectError && deviceState == DeviceState.Playing) { wasPlayingWhenConnectError = true; } if (state == DeviceState.ConnectError && IsGroup()) { deviceState = state; deviceControl?.SetStatus(deviceState, statusText); } else { deviceState = state; deviceControl?.SetStatus(deviceState, statusText); } } }
public void SetStatus(DeviceState state, string text) { if (InvokeRequired) { Invoke(new Action <DeviceState, string>(SetStatus), new object[] { state, text }); return; } lblStatus.Text = string.Format("{0} {1}", state, text); btnDevice.Width = Width - 2 - btnDevice.Left; trbVolume.Width = Width - trbVolume.Left - 2; switch (state) { case DeviceState.NotConnected: case DeviceState.Idle: case DeviceState.Disposed: case DeviceState.LaunchingApplication: case DeviceState.LaunchedApplication: case DeviceState.LoadingMedia: case DeviceState.Closed: case DeviceState.Paused: SetBackColor(Color.LightGray); device.GetMenuItem().Checked = false; picturePlayPause.Image = Properties.Resources.Play; break; case DeviceState.Buffering: case DeviceState.Playing: SetBackColor(Color.PaleGreen); device.GetMenuItem().Checked = true; picturePlayPause.Image = Properties.Resources.Pause; break; case DeviceState.ConnectError: case DeviceState.LoadCancelled: case DeviceState.LoadFailed: case DeviceState.InvalidRequest: SetBackColor(Color.PeachPuff); device.GetMenuItem().Checked = false; picturePlayPause.Image = Properties.Resources.Play; break; default: break; } }
public override void ApplyState(DeviceState state) { base.ApplyState(state); var newState = (ComputerState)state; var currentState = (ComputerState)mState; if (newState.Power != currentState.Power) { SetPower(newState.Power); } if (newState.MonitorPower != currentState.MonitorPower) { SetMonitorPower(newState.MonitorPower); } }
/// <summary> /// Initializes a new instance of the <see cref="Device"/> class. /// </summary> /// <param name="serial">The serial.</param> /// <param name="state">The state.</param> /// <param name="model">The model.</param> /// <param name="product">The product.</param> /// <param name="device">The device.</param> public Device(string serial, DeviceState state, string model, string product, string device) { this.SerialNumber = serial; this.State = state; MountPoints = new Dictionary <String, MountPoint> ( ); Properties = new Dictionary <string, string> ( ); EnvironmentVariables = new Dictionary <string, string> ( ); Clients = new List <IClient> ( ); FileSystem = new FileSystem(this); BusyBox = new BusyBox(this); Model = model; Product = product; DeviceProperty = device; RetrieveDeviceInfo( ); }
/// <summary> /// 尝试从一行设备信息字符串中获取信息 /// </summary> /// <param name="input"></param> /// <param name="serialNumber"></param> /// <param name="state"></param> /// <returns></returns> public static bool TryGetBasicInfo(string input, out string serialNumber, out DeviceState state) { var match = _deviceRegex.Match(input); if (!match.Success) { serialNumber = null; state = default(DeviceState); return(false); } else { serialNumber = match.Result("${sn}"); state = match.Result("${state}").Trim().ToDeviceState(); return(true); } }
/// <summary> /// Closes the Wirekite devices. /// </summary> /// <remarks> /// A closed device can no longer be used. It must be disconnected and connected again, /// or the Wirekite service must be restarted. /// </remarks> public void Close() { if (_deviceState == DeviceState.Closed) { return; } _ports.Clear(); _throttler.Clear(); _pendingRequests.Clear(); _service.RemoveDevice(this); WinUsb_Free(_interfaceHandle); _interfaceHandle = IntPtr.Zero; _deviceHandle.Dispose(); _deviceHandle = null; _deviceState = DeviceState.Closed; }
public FT_STATUS GetDeviceInfoDetail( uint index, ref DeviceState flags, ref ChipType chiptype, ref uint id, ref uint locid, byte[] serialnumber, byte[] description, ref IntPtr ftHandle) => FT_GetDeviceInfoDetail( index, ref flags, ref chiptype, ref id, ref locid, serialnumber, description, ref ftHandle);
public void OnDeviceStateChanged(string deviceId, DeviceState newState) { if (_mediaSystemAudioDevicesChanged != null) { pm_AudioDevicesEventArgs._inputDevice = IsAudioInputDevice(deviceId); pm_AudioDevicesEventArgs._deviceId = deviceId; if (newState == DeviceState.Active) { pm_AudioDevicesEventArgs._notification = SystemAudioDevicesNotification.Activated; } else { pm_AudioDevicesEventArgs._notification = SystemAudioDevicesNotification.Disabled; } _mediaSystemAudioDevicesChanged(null, pm_AudioDevicesEventArgs); } }
/// <summary> /// Constructor. /// </summary> public GXDLMSDevice(Gurux.Common.IGXMedia media) { StartProtocol = StartProtocolType.IEC; ClientID = 0x10; // Public client (lowest security level). PhysicalAddress = 1; Password = ""; Authentication = Authentication.None; m_Communicator = new GXDLMSCommunicator(this, media); m_Objects = m_Communicator.m_Cosem.Objects; m_Objects.Tag = this; m_Communicator.OnProgress += new ProgressEventHandler(this.NotifyProgress); this.KeepAlive = new System.Timers.Timer(); this.KeepAlive.Interval = 40000; this.KeepAlive.Elapsed += new System.Timers.ElapsedEventHandler(KeepAlive_Elapsed); m_Status = DeviceState.Initialized; WaitTime = 5; }
//----------------------------------------------------------------------------------------- // Construction //----------------------------------------------------------------------------------------- public Device(string serial, DeviceState state, string model, string product, string device) { this.SerialNumber = serial; this.State = state; this.Model = model; this.Product = product; this.DeviceProperty = device; this.MountPoints = new Dictionary <string, MountPoint>(); this.Properties = new Dictionary <string, string>(); this.EnvironmentVariables = new Dictionary <string, string>(); this.Clients = new List <IClient>(); this.FileSystem = new FileSystem(this); this.BusyBox = new BusyBox(this); RefreshFromDevice(); }
public PortState(string body) : base(body) { Port = body.Substring(6, 2); StateChangeEvent = (DeviceState)Convert.ToInt32(body.Substring(8, 2), 16); PortLetter = Port switch { "00" => "A", "01" => "B", "02" => "C", "03" => "D", _ => "?", }; if (StateChangeEvent != DeviceState.Detached) { DeviceType = IoDeviceTypes.GetByCode(body.Substring(10, 2)); } }
internal static string GetJavascriptDeviceState(DeviceState state) { switch (state) { case DeviceState.Active: return ACTIVE; case DeviceState.NotPresent: return NOTPRESENT; case DeviceState.Unplugged: return UNPLUGGED; case DeviceState.Disabled: return DISABLED; case DeviceState.All: return ALL; } throw new ArgumentOutOfRangeException("state"); }
public void SetUp() { _fakeEvalBoard = Mock.Of <IDenseDacEvalBoard>(); _deviceState = new DeviceState(); Mock.Get(_fakeEvalBoard) .SetupGet(x => x.DeviceState) .Returns(_deviceState); _fakeSendSPICommand = Mock.Of <ISendSPI>(); Mock.Get(_fakeSendSPICommand) .Setup(x => x.SendSPI(It.IsAny <uint>())) .Callback <uint>( a => { _sendSPICallOrder = _callOrder; _callOrder++; } ) .Verifiable(); _fakeSetCLRPinLowCommand = Mock.Of <ISetCLRPinLow>(); Mock.Get(_fakeSetCLRPinLowCommand) .Setup(x => x.SetCLRPinLow()) .Callback(() => { _setCLRPinLowCallOrder = _callOrder; _callOrder++; } ) .Verifiable(); _fakeSetCLRPinHighCommand = Mock.Of <ISetCLRPinHigh>(); Mock.Get(_fakeSetCLRPinHighCommand) .Setup(x => x.SetCLRPinHigh()) .Callback(() => { _setCLRPinHighCallOrder = _callOrder; _callOrder++; } ) .Verifiable(); _setDacChannelGainCommand = new SetDacChannelGainCommand( _fakeEvalBoard, _fakeSendSPICommand, _fakeSetCLRPinLowCommand, _fakeSetCLRPinHighCommand); }
private void MeasurementLogicRoutine(Types.Commutation.TestParameters Commutation) { try { m_State = DeviceState.InProcess; FireAllEvent(m_State); if (m_IOCommutation.Switch(Types.Commutation.CommutationMode.Gate, Commutation.CommutationType, Commutation.Position) == DeviceState.Fault) { m_State = DeviceState.Fault; FireAllEvent(m_State); return; } if (Kelvin()) { Resistance(); IgtVgt(); Ih(); Il(); } if (m_IOCommutation.Switch(Types.Commutation.CommutationMode.None) == DeviceState.Fault) { m_State = DeviceState.Fault; FireAllEvent(m_State); return; } m_State = m_Stop ? DeviceState.Stopped : DeviceState.Success; FireAllEvent(m_State); } catch (Exception ex) { m_IOCommutation.Switch(Types.Commutation.CommutationMode.None); m_State = DeviceState.Fault; FireAllEvent(m_State); FireExceptionEvent(ex.Message); throw; } }
public DeviceStateAttempt SetAttempt(DeviceType device, DeviceState state) { DeviceStateAttempt attempt; if (_attempts.TryGetValue(device, out attempt)) { attempt.TargetState = state; } else { attempt = new DeviceStateAttempt(state); _attempts.TryAdd(device, attempt); } attempt.IsEnabled = true; return(attempt); }
/// <summary> /// Sets the device state asynchronously /// </summary> /// <param name="deviceId">The device identifier.</param> /// <param name="deviceState">State of the device.</param> /// <returns></returns> /// <exception cref="DeviceException">Unable to communicate with device with ID= + deviceId</exception> public async Task SetDeviceStateAsync(byte deviceId, DeviceState deviceState) { try { var data = new[] { (ushort)deviceState }; await this.deviceAccessLayer.WriteToDeviceAsync(deviceId, Registry.STATE_ADDR, data); } catch (Exception e) { this.logger.Error( string.Format( "Unable to set state of device {0} to {1}. Exception occured {2}", deviceId, deviceState, e)); throw new DeviceException("Unable to communicate with device with ID= " + deviceId); } }
static IEnumerable <IMMDevice> GetDevices( DataFlow dataFlow, DeviceState deviceStates) { MMDeviceEnumerator deviceEnumerator = new MMDeviceEnumerator(); IMMDeviceCollection devices; Int32 hr = deviceEnumerator .EnumAudioEndpoints(dataFlow, deviceStates, out devices); Int32 deviceCount; hr = devices.GetCount(out deviceCount); for (Int32 deviceIndex = 0; deviceIndex < deviceCount; deviceIndex++) { IMMDevice device; hr = devices.Item(deviceIndex, out device); yield return(device); } }
public override void Update(GameTime gameTime) { if (trackedDevice != null) { Matrix mat; Vector3 vel, angVel; internalState = OpenVR.GetTrackerPose(trackedDevice.TrackerIndex, out mat, out vel, out angVel); if (internalState != DeviceState.Invalid) { Vector3 scale; mat.Decompose(out scale, out currentRot, out currentPos); currentLinearVelocity = vel; currentAngularVelocity = new Vector3(MathUtil.DegreesToRadians(angVel.X), MathUtil.DegreesToRadians(angVel.Y), MathUtil.DegreesToRadians(angVel.Z)); } } base.Update(gameTime); }
public DeviceStateChangedEventArgs(string deviceID, DeviceState deviceState) : base(deviceID) { DeviceState = deviceState; }
internal DeviceEventArgs(String deviceName, DeviceState previousState, DeviceState newState) { this.deviceName = deviceName; this.previousState = previousState; this.newState = newState; }
protected virtual void Init() { this.State = DeviceState.UNKNOWN; }
public override Boolean Stop() { if (IsActive) { Unplug(0); m_State = DeviceState.Reserved; } return base.Stop(); }
/// <summary> /// Get the ListViewItem group in which the device belongs. /// </summary> /// <param name="deviceState"></param> /// <param name="listView"></param> /// <returns></returns> private ListViewGroup GetGroup(DeviceState deviceState, ListView listView) { switch (deviceState) { case DeviceState.Active: return listView.Groups[DeviceState.Active.ToString()]; default: return listView.Groups[DeviceState.NotPresent.ToString()]; } }
public static void StartCapture(SocketObject state) { var deviceState1 = new DeviceState(); lock (deviceState1) { deviceState1.Device = state.device; deviceState1.Handle = IntPtr.Zero; deviceState1.Cancel = false; deviceState1.State = state; var num = Marshal.AllocHGlobal(12); try { if (_activeDevices.ContainsKey(state.device.Name)) { StopCapture(state.device.Name); } var errbuff = new StringBuilder(256); deviceState1.Handle = pcap_open(state.device.Name, 65536, 0, 500, IntPtr.Zero, errbuff); if (deviceState1.Handle == IntPtr.Zero) { throw new ApplicationException("Cannot open pcap interface [" + state.device.Name + "]. Error: " + errbuff); } deviceState1.LinkType = pcap_datalink(deviceState1.Handle); if (deviceState1.LinkType != 1 && deviceState1.LinkType != 0) { throw new ApplicationException("Interface [" + state.device.Description + "] does not appear to support Ethernet."); } if (pcap_compile(deviceState1.Handle, num, "ip and tcp", 1, 0U) != 0) { throw new ApplicationException("Unable to create TCP packet filter."); } if (pcap_setfilter(deviceState1.Handle, num) != 0) { throw new ApplicationException("Unable to apply TCP packet filter."); } pcap_freecode(num); _activeDevices[state.device.Name] = deviceState1; } catch (Exception ex) { if (deviceState1.Handle != IntPtr.Zero) { pcap_close(deviceState1.Handle); } throw new ApplicationException("Unable to open winpcap device [" + state.device.Name + "].", ex); } finally { Marshal.FreeHGlobal(num); } ThreadPool.QueueUserWorkItem(PollNetworkDevice, _activeDevices[state.device.Name]); } }
public override Boolean Start() { if (IsActive) { m_State = DeviceState.Connected; } return State == DeviceState.Connected; }
void UpdateStatus(DeviceState state) { //Clear connecting. if (state == DeviceState.Connected) { state &= ~DeviceState.Connecting; state |= DeviceState.Initialized; } m_Status = state; if (OnStatusChanged != null) { OnStatusChanged(this, m_Status); } }
private DeviceState SetState() { string state = null; using (StringReader r = new StringReader(Adb.Devices())) { string line; while (r.Peek() != -1) { line = r.ReadLine(); if (line.Contains(this.serialNumber)) state = line.Substring(line.IndexOf('\t') + 1); } } if (state == null) { using (StringReader r = new StringReader(Fastboot.Devices())) { string line; while (r.Peek() != -1) { line = r.ReadLine(); if (line.Contains(this.serialNumber)) state = line.Substring(line.IndexOf('\t') + 1); } } } switch (state) { case "device": return DeviceState.ONLINE; case "recovery": return DeviceState.RECOVERY; case "fastboot": return DeviceState.FASTBOOT; default: return DeviceState.UNKNOWN; } }
/// <summary> /// Updates all values in current instance of <see cref="Device"/> /// </summary> public void Update() { this.state = SetState(); this.su = new Su(this); this.battery = new BatteryInfo(this); this.buildProp = new BuildProp(this); this.busyBox = new BusyBox(this); this.phone = new Phone(this); this.fileSystem = new FileSystem(this); }
internal static DeviceModel From(MacAddress macAddress, DeviceState state, DateTime lastRequestDate, string comment) { return new DeviceModel() { MacAddress = macAddress.ToString(), State = state.ToString(), LastRequestDate = lastRequestDate, Comment = comment }; }