public Xdk3DModelController(Xdk3DModel model, Sprite[] gaugeSprites, Xdk xdk) : base(xdk, model.Name) { _gaugeSprites = gaugeSprites; _xdk = xdk; _model = model; AddControllers(); }
public MagnetometerGaugeController(Xdk xdk) : base(xdk, null, "MagnetometerGauge") { _indicator = GameObject.Find("MagneticFieldStrengthIndicator").GetComponent <Image>(); _compassNeedle = GameObject.Find("CompassNeedle").GetComponent <Image>(); UseTiltCompensation = true; }
public LedController(Xdk xdk, string gameObjectName, int ledIndex) : base(xdk, gameObjectName) { _led = Xdk.Leds[ledIndex]; if (TargetGameObject != null) { _meshRenderer = TargetGameObject.GetComponent <MeshRenderer>(); _offColor = _meshRenderer.material.color; } }
private void ConnectSerial(string portName) { Xdk.ConnectSerial(portName); Invoke(() => { IsPortConnected = Xdk.IsSerialConnected; }); CommandManager.InvalidateRequerySuggested(); }
private void SetLedsValues(Xdk xdk) { var currentSecond = DateTime.Now.Second; for (int i = 0; i < Xdk.LedCount; i++) { xdk.Leds[i].IsOn = currentSecond % (i + 2) == 0; } }
public void OnConnect(string deviceAddress) { if (DeviceHandler != null) { Debug.Log("Connecting to " + deviceAddress); Xdk.Reset(); DeviceHandler.ConnectToPeripheral(deviceAddress); } }
public ButtonController(Xdk xdk, string gameObjectName, int index) : base(xdk, gameObjectName) { _index = index; if (TargetGameObject != null) { _meshRenderer = TargetGameObject.GetComponent <MeshRenderer>(); _normalColor = _meshRenderer.material.color; } }
private async Task DisconnectSerialAsync() { try { await Xdk.DisconnectSerialAsync(); } finally { Invoke(() => { IsPortConnected = Xdk.IsSerialConnected; }); } CommandManager.InvalidateRequerySuggested(); }
private void DisconnectSerial() { try { Xdk.DisconnectSerial(); } finally { Invoke(() => { IsPortConnected = Xdk.IsSerialConnected; }); } CommandManager.InvalidateRequerySuggested(); }
public void WhenSettingByteValueCharacteristic_ShouldSetByteValueInDeviceModel() { // Arrange var guid = Guid.NewGuid(); var characteristic = new BluetoothLeCharacteristic <Xdk>(guid, "TestValue").WithSetter((Xdk, value) => Xdk.NoiseSensor.DbSpl.Value = value.TryGetByte()); var testXdk = new Xdk(); var byteArray = new byte[] { 8 }; // Act characteristic.SetValue(testXdk, byteArray); // Assert Assert.That(testXdk.NoiseSensor.DbSpl.Value, Is.EqualTo(8)); }
public void WhenSettingUInt32ValueCharacteristic_ShouldSetUInt32ValueInDeviceModel() { // Arrange var guid = Guid.NewGuid(); var characteristic = new BluetoothLeCharacteristic <Xdk>(guid, "TestValue").WithSetter((Xdk, value) => Xdk.LightSensor.MilliLux.Value = value.TryGetUInt32()); var testXdk = new Xdk(); const UInt32 intValue = UInt32.MaxValue; var byteArray = BitConverter.GetBytes(intValue); // Act characteristic.SetValue(testXdk, byteArray); // Assert Assert.That(testXdk.LightSensor.MilliLux.Value, Is.EqualTo(intValue)); }
public void WhenCreatingLowPriority2Message_ShouldBeValid() { // Arrange var xdk = new Xdk(); xdk.MagnetometerSensor.Resistance.Value = 10; xdk.MagnetometerSensor.XAxis.Value = 20; // Act byte[] message = xdk.ToLowPriorityMessage2(); // Assert var testXdk = new Xdk(); message.SetLowPriorityValues(testXdk); Assert.That(testXdk.MagnetometerSensor.Resistance.Value, Is.EqualTo(xdk.MagnetometerSensor.Resistance.Value)); Assert.That(testXdk.MagnetometerSensor.XAxis.Value, Is.EqualTo(xdk.MagnetometerSensor.XAxis.Value)); }
public void WhenCreatingLowPriority1Message_ShouldBeValid() { // Arrange var xdk = new Xdk(); xdk.LightSensor.MilliLux.Value = 10; xdk.NoiseSensor.DbSpl.Value = 20; // Act byte[] message = xdk.ToLowPriorityMessage1(); // Assert var testXdk = new Xdk(); message.SetLowPriorityValues(testXdk); Assert.That(testXdk.LightSensor.MilliLux.Value, Is.EqualTo(xdk.LightSensor.MilliLux.Value)); Assert.That(testXdk.NoiseSensor.DbSpl.Value, Is.EqualTo(xdk.NoiseSensor.DbSpl.Value)); }
public void WhenCreatingHighPriorityMessage_ShouldBeValid() { // Arrange var xdk = new Xdk(); xdk.AccelerometerSensor.XAxis.Value = 10; xdk.AccelerometerSensor.YAxis.Value = 20; xdk.AccelerometerSensor.ZAxis.Value = 30; // Act byte[] message = xdk.ToHighPriorityMessage(); // Assert var testXdk = new Xdk(); message.SetHighPriorityValues(testXdk); Assert.That(testXdk.AccelerometerSensor.XAxis.Value, Is.EqualTo(xdk.AccelerometerSensor.XAxis.Value)); Assert.That(testXdk.AccelerometerSensor.YAxis.Value, Is.EqualTo(xdk.AccelerometerSensor.YAxis.Value)); Assert.That(testXdk.AccelerometerSensor.ZAxis.Value, Is.EqualTo(xdk.AccelerometerSensor.ZAxis.Value)); }
/// <summary> /// Initialize all main components and link them together. /// </summary> public void Start() { _xdk = new Xdk(); _gaugeSprites = Resources.LoadAll <Sprite>("Sprites/assets_200x200"); CreateDialogControllers(); IBluetoothLeCommander commander = null; if (Application.isMobilePlatform) { #if UNITY_IPHONE commander = new BluetoothLEiOsCommander(); #endif #if UNITY_ANDROID commander = new BluetoothLeAndroidCommander(); #endif } if (commander == null) { commander = new BluetoothLeCommanderMock(); } _deviceHandler = new BluetoothLeMessageHandler(_xdk, XdkProfile.Create(), commander); _deviceListController.DeviceHandler = _deviceHandler; _settingsController.DeviceHandler = _deviceHandler; _protocolCheckController.DeviceHandler = _deviceHandler; var receiver = GameObject.Find(BluetoothLeReceiverGameobjectName) ?? new GameObject(BluetoothLeReceiverGameobjectName); _messageRouter = receiver.AddComponent <BluetoothLeMessageRouter>(); _messageRouter.Handler = _deviceHandler; CreateUpdateControllers(); _xdk3DModelManager.Open(); _initialised = true; }
public void OnResetApp() { Debug.Log("OnResetApp"); Xdk.ResetOrientation(); }
protected UpdateControllerBase(Xdk xdk, string gameObjectName) { this._xdk = xdk; _targetGameObject = GameObject.Find(gameObjectName); }
public override void Close() { base.Close(); DeviceHandler.Disconnect(); Xdk.ResetProtocolVersion(); }
private void SetButtonValues(Xdk xdk) { var currentSecond = DateTime.Now.Second; xdk.IsButton2Pressed = currentSecond % 2 == 0; }
protected MultiValueGaugeController(Xdk xdk, IEnumerable <Sprite> sprites, string spriteNamePattern, string gaugeObjectName) : base(xdk, sprites.Where(s => s.name.StartsWith(spriteNamePattern)).ToArray(), gaugeObjectName) { _gaugeImage = TargetGameObject.GetComponent <Image>(); }
public ThermometerGaugeController(Xdk xdk) : base(xdk, null, "ThermometerGauge") { _indicator = GameObject.Find("TemperatureIndicator").GetComponent <Image>(); }
public IEnumerable <IUpdateController> CreateControllers(Sprite[] gaugeSprites, Xdk xdk) { foreach (var model in _xdk3DModels) { var modelControler = new Xdk3DModelController(model, gaugeSprites, xdk); _controllers.Add(modelControler); } return(_controllers.OfType <IUpdateController>()); }
public SdCardGaugeController(Xdk xdk, IEnumerable <Sprite> sprites) : base(xdk, sprites, "sdcard_", "SimCardGauge") { }
public RotationGaugeController(Xdk xdk, string threeDModelName) : base(xdk, null, threeDModelName) { }
public HygrometerGaugeController(Xdk xdk, IEnumerable <Sprite> sprites) : base(xdk, sprites, "water_", "HygrometerGauge") { }
public LightGaugeController(Xdk xdk, IEnumerable <Sprite> sprites) : base(xdk, sprites, "light_", "LightGauge") { }
public ManometerGaugeController(Xdk xdk) : base(xdk, null, "ManometerGauge") { _manometerNeedle = GameObject.Find("ManometerNeedle").GetComponent <Image>(); }
public NoiseGaugeController(Xdk xdk, IEnumerable <Sprite> sprites) : base(xdk, sprites, "speaker_", "NoiseGauge") { }
protected GaugeController(Xdk xdk, Sprite[] sprites, string gaugeName) : base(xdk, gaugeName) { this.Sprites = sprites; }