public async Task <IActionResult> PutPeripheral(int id, Peripheral peripheral) { if (id != peripheral.UIDNumber) { return(BadRequest()); } _context.Entry(peripheral).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PeripheralExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
async void Start() { // get head head = animator.GetBoneTransform(HumanBodyBones.Head); // scan grayBluePeripheral = await FindFirstGrayBlueAsync(); // apply rotation var baseSensorQuat = Quaternion.identity; var baseHeadQuat = head?.rotation ?? Quaternion.identity; grayBluePeripheral? .ReactiveIMUData() .Take(1) .Subscribe(x => { baseSensorQuat = Quaternion.Inverse(x.unity.quat); }) .AddTo(this); grayBluePeripheral? .ReactiveIMUData() .Skip(1) .Subscribe(x => { var sensorRelativeRotation = baseSensorQuat * x.unity.quat; // reverse x,y like mirror var euler = sensorRelativeRotation.eulerAngles; head.localRotation = Quaternion.Euler(-euler.x, -euler.y, euler.z); }) .AddTo(this); grayBluePeripheral?.ListenEvent(); }
void SetCtrState(Peripheral peripheral) { if (ctrPeripheral == null) { ctrPeripheral = peripheral; } ctrflag = peripheral.Connected; Ctr.Find("Switch").gameObject.SetActive(ctrflag); Ctr.Find("False").gameObject.SetActive(!ctrflag); if (CtrState != null) { CtrState(ctrflag); } if (ctrflag) { if (peripheral.GetBatteryLevel() < 0) { SetBatteryLevel = true; } else { Ctr.Find("Text").GetComponent <UnityEngine.UI.Text>().text = peripheral.GetBatteryLevel().ToString() + "%"; } } }
void _InitPeripheral() { if (my_peripheral == null) { my_peripheral = Peripheral.Instance; } }
public async Task <ActionResult <Peripheral> > PostPeripheral(Peripheral peripheral) { _context.Peripherals.Add(peripheral); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetPeripheral), new { id = peripheral.UIDNumber }, peripheral)); }
public IObservable <IPeripheral> ListenForMe(string eventName, Peripheral me) => this .peripheralSubject .Where(x => x.Name.Equals(eventName) && x.Arg.Native.Address.Equals(me.Native.Address) ) .Select(x => x.Arg);
void Start() { InitElements(); //my_settings_panel.SetVolume(5); ClearGUI(GameState.Null); // peripheral = (GameObject.Find ("Peripheral")).gameObject.GetComponentInParent<Peripheral>(); peripheral = Peripheral.Instance; if (Instance != null && Instance != this) { Destroy(gameObject); } Instance = this; central = Central.Instance; // cameras.Add(GameObject.Find("MAINCAMERA").transform); x_coord = Screen.width; y_coord = Screen.height; // UICamera.genericEventHandler = this.gameObject; PlaceState(GameState.MainMenu); }
internal BGService(Peripheral localPeripheral, IEnumerable <byte> uuid, UInt16 startAttHandle, UInt16 endAttHandle, BGLibApi bgApi) : base(localPeripheral, uuid, startAttHandle, endAttHandle) { _bgApi = bgApi; _procedureCompletedWaitHandle = new AsyncAutoResetEvent(false); _clientConfigurationAttributeHandles = new List <UInt16>(); }
public static void SetPeripheralState(Peripheral device, Switch state) { portState = state == Switch.On ? true : false; switch (device) { case Peripheral.Ethernet: if (peripheralPorts[0] == null) peripheralPorts[0] = new OutputPort((Cpu.Pin)Peripheral.Ethernet, !portState); else peripheralPorts[0].Write(!portState); break; case Peripheral.PowerLED: if (peripheralPorts[1] == null) peripheralPorts[1] = new OutputPort((Cpu.Pin)Peripheral.PowerLED, portState); else peripheralPorts[1].Write(portState); break; case Peripheral.SDCard: if (peripheralPorts[2] == null) peripheralPorts[2] = new OutputPort((Cpu.Pin)Peripheral.SDCard, portState); else peripheralPorts[2].Write(portState); break; case Peripheral.PowerHeaders: if (peripheralPorts[3] == null) peripheralPorts[3] = new OutputPort((Cpu.Pin)Peripheral.PowerHeaders, portState); else peripheralPorts[3].Write(portState); break; default: throw new ArgumentOutOfRangeException("device"); } }
public PeripheralSettingsWindow(Peripheral peripheral) { InitializeComponent(); DataContext = this; Peripheral = peripheral; NewName = peripheral.Name; }
public ActionResult <IQueryable <Peripheral> > PostPeripheral(Peripheral peripheral) { // Validate no more than ten peripherals allowed per gateway var gId = peripheral.GatewayId; var peripherals = _context.Peripherals.Where(p => p.GatewayId == gId); if (peripherals.Count() >= 10) { return(ValidationProblem("Gateway cannot have more than 10 peripherals.")); } var gateway = _context.Gateways.FirstOrDefault(g => g.Id == gId); if (gateway == null) { return(ValidationProblem("Peripheral has to be associated to a valid gateway")); } try { _context.Peripherals.Add(peripheral); _context.SaveChanges(); return(new CreatedResult($"/peripherals/{peripheral.Id}", peripheral)); } catch (Exception e) { return(ValidationProblem(e.Message)); } }
public IPeripheral AddPeripheral(BluetoothLEDevice native) { var dev = new Peripheral(this, native); this.peripherals.TryAdd(native.BluetoothAddress, dev); return(dev); }
// Update is called once per frame void FixedUpdate() { Peripheral Periph = GetComponent <Peripheral> (); BasePartBehaviour bph = GetComponent <BasePartBehaviour> (); Periph.Ports [0] = Mathf.RoundToInt(bph.Thermal.Temperature); }
public void UpdatePeripheralStatus(Peripheral peripheral, bool status) { if (peripheral == Peripheral.Backlight) { if (status) { backlightStatusIcon.Source = GREEN_IMAGE; } else { backlightStatusIcon.Source = YELLOW_IMAGE; } Properties.Settings.Default.BacklightStatus = status; } else if (peripheral == Peripheral.GrowLight) { if (status) { growlightStatusIcon.Source = GREEN_IMAGE; } else { growlightStatusIcon.Source = YELLOW_IMAGE; } Properties.Settings.Default.GrowlightStatus = status; } }
public void OnDiscoveringDevice(Peripheral peripheral) { DiscoveredDeviceEventArgs args = new DiscoveredDeviceEventArgs(); args.DiscoveredPeripheral = peripheral; DiscoveredDevice?.Invoke(this, args); }
private void DisconnectPrinter() { if (Peripheral.IsConnected()) { Peripheral.CancelConnection(); } }
public override T Read(long offset) { var originalValue = OriginalMethod(offset); Peripheral.DebugLog("Read{0} from 0x{1:X}{3}, returned 0x{2:X}.", Name, offset, originalValue, mapper.ToString(offset, " ({0})")); return(originalValue); }
public string AddPeripheral(int computerId, int id, string peripheralType, string manufacturer, string model, decimal price, double overallPerformance, string connectionType) { Validation.ComputerExists(computerId, _computers); if (this._peripherals.Any(p => p.Id == id)) { throw new ArgumentException(ExceptionMessages.ExistingPeripheralId); } Peripheral peripheral = peripheralType switch { "Headset" => new Headset(id, manufacturer, model, price, overallPerformance, connectionType), "Keyboard" => new Keyboard(id, manufacturer, model, price, overallPerformance, connectionType), "Monitor" => new Monitor(id, manufacturer, model, price, overallPerformance, connectionType), "Mouse" => new Mouse(id, manufacturer, model, price, overallPerformance, connectionType), _ => throw new ArgumentException(ExceptionMessages.InvalidPeripheralType) }; var comp = GetComputerById(computerId); this._peripherals.Add(peripheral); comp.AddPeripheral(peripheral); return(string.Format(SuccessMessages.AddedPeripheral, peripheralType, id, computerId)); }
public override void SetSelectedToy(bool s) { if (!s && Peripheral.Instance.getSelectedToy() != content) { return; } if (peripheral == null) { peripheral = Peripheral.Instance; } if (peripheral == null) { Debug.Log("Peripheral is not present yet, why are you trying to do stuff with MyDraggableButton?\n"); return; } if (type.EndsWith("selected")) { if (s) { peripheral.SelectToy(content, rune_type); } else { peripheral.SelectToy(null, RuneType.Null); } } if (!s) { EagleEyes.Instance.ClearInfo(); } }
public override void Write(long offset, T value) { var valueForDisplay = needsByteSwapForDisplay ? Misc.SwapBytes(value) : value; Peripheral.Log(LogLevel.Info, machine.SystemBus.DecorateWithCPUNameAndPC($"Write{Name} to 0x{offset:X}{(mapper.ToString(offset, " ({0})"))}, value 0x{valueForDisplay:X}.")); OriginalMethod(offset, value); }
public void UpdatePeripheralStatus(Peripheral peripheral, bool status) { this.Dispatcher.Invoke(() => //this will auto update the peripheral when in another thread already { if (peripheral == Peripheral.Backlight) { if (status) { backlightStatusIcon.Source = GREEN_IMAGE; } else { backlightStatusIcon.Source = YELLOW_IMAGE; } Properties.Settings.Default.BacklightStatus = status; } else if (peripheral == Peripheral.GrowLight) { if (status) { growlightStatusIcon.Source = GREEN_IMAGE; } else { growlightStatusIcon.Source = YELLOW_IMAGE; } Properties.Settings.Default.GrowlightStatus = status; } }); }
void Start() { InitMe(); peripheral = Peripheral.Instance; enabled = true; }
public ActionResult Add() { Peripheral peripheral = new Peripheral(); //peripheral.Date = DateTime.Now.ToString("MMMM dd, yyyy"); return(View(peripheral)); }
public override T Read(long offset) { var originalValue = OriginalMethod(offset); Peripheral.Log(LogLevel.Info, machine.SystemBus.DecorateWithCPUNameAndPC($"Read{Name} from 0x{offset:X}{(mapper.ToString(offset, " ({0})"))}, returned 0x{originalValue:X}.")); return(originalValue); }
public Peripheral Find(uint address) { Peripheral ret = null; for (int i = 0; i < m_InternalList.Count; i++) { ListItem listItem = m_InternalList[i]; Peripheral peripheral = listItem.Peripheral; if (peripheral.AddressRangeEnd < address || peripheral.AddressRangeStart > address) { continue; } listItem.AccessCount++; m_InternalList[i] = listItem; ret = peripheral; BubbleUp(i); break; } return(ret); }
internal BGCharacteristic(Peripheral localPeripheral, BGLibApi bgApi) : base(localPeripheral) { _bgApi = bgApi; _procedureCompletedWaitHandle = new AsyncAutoResetEvent(false); _attributeValueWaitHandle = new AsyncAutoResetEvent(false); _bgApi.ATTClientAttributeValue += BGApi_NotificationAndIndicationHandler; }
public override void ReadCharacteristic(object characteristic) { CBCharacteristic c = characteristic as CBCharacteristic; if (c == null) return; Peripheral.ReadValue(c); }
public Peripheral getPeripheral() { if (peripheral == null) { peripheral = Peripheral.Instance; } return(peripheral); }
public void Add(Peripheral p) => m_InternalList.Add( new ListItem { AccessCount = 0, Peripheral = p } );
public ActionResult DeleteConfirmed(int id) { Peripheral peripheral = db.Peripherals.Find(id); db.Peripherals.Remove(peripheral); db.SaveChanges(); return(RedirectToAction("Index")); }
public override T Read(long offset) { var originalValue = OriginalMethod(offset); var valueForDisplay = needsByteSwapForDisplay ? Misc.SwapBytes(originalValue) : originalValue; Peripheral.Log(LogLevel.Info, machine.SystemBus.DecorateWithCPUNameAndPC($"Read{Name} from 0x{offset:X}{(mapper.ToString(offset, " ({0})"))}, returned 0x{valueForDisplay:X}.")); return(originalValue); }