예제 #1
0
 public Xdk3DModelController(Xdk3DModel model, Sprite[] gaugeSprites, Xdk xdk) : base(xdk, model.Name)
 {
     _gaugeSprites = gaugeSprites;
     _xdk          = xdk;
     _model        = model;
     AddControllers();
 }
예제 #2
0
 public MagnetometerGaugeController(Xdk xdk)
     : base(xdk, null, "MagnetometerGauge")
 {
     _indicator          = GameObject.Find("MagneticFieldStrengthIndicator").GetComponent <Image>();
     _compassNeedle      = GameObject.Find("CompassNeedle").GetComponent <Image>();
     UseTiltCompensation = true;
 }
예제 #3
0
 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;
     }
 }
예제 #4
0
 private void ConnectSerial(string portName)
 {
     Xdk.ConnectSerial(portName);
     Invoke(() =>
     {
         IsPortConnected = Xdk.IsSerialConnected;
     });
     CommandManager.InvalidateRequerySuggested();
 }
예제 #5
0
        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;
            }
        }
예제 #6
0
 public void OnConnect(string deviceAddress)
 {
     if (DeviceHandler != null)
     {
         Debug.Log("Connecting to " + deviceAddress);
         Xdk.Reset();
         DeviceHandler.ConnectToPeripheral(deviceAddress);
     }
 }
예제 #7
0
 public ButtonController(Xdk xdk, string gameObjectName, int index) : base(xdk, gameObjectName)
 {
     _index = index;
     if (TargetGameObject != null)
     {
         _meshRenderer = TargetGameObject.GetComponent <MeshRenderer>();
         _normalColor  = _meshRenderer.material.color;
     }
 }
예제 #8
0
 private async Task DisconnectSerialAsync()
 {
     try
     {
         await Xdk.DisconnectSerialAsync();
     }
     finally
     {
         Invoke(() =>
         {
             IsPortConnected = Xdk.IsSerialConnected;
         });
     }
     CommandManager.InvalidateRequerySuggested();
 }
예제 #9
0
 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));
        }
예제 #12
0
        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));
        }
예제 #13
0
        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));
        }
예제 #14
0
        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));
        }
예제 #15
0
        /// <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();
 }
예제 #19
0
        private void SetButtonValues(Xdk xdk)
        {
            var currentSecond = DateTime.Now.Second;

            xdk.IsButton2Pressed = currentSecond % 2 == 0;
        }
예제 #20
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>();
 }
예제 #22
0
 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>());
 }
예제 #23
0
 public SdCardGaugeController(Xdk xdk, IEnumerable <Sprite> sprites)
     : base(xdk, sprites, "sdcard_", "SimCardGauge")
 {
 }
예제 #24
0
 public RotationGaugeController(Xdk xdk, string threeDModelName)
     : base(xdk, null, threeDModelName)
 {
 }
예제 #25
0
 public HygrometerGaugeController(Xdk xdk, IEnumerable <Sprite> sprites)
     : base(xdk, sprites, "water_", "HygrometerGauge")
 {
 }
예제 #26
0
 public LightGaugeController(Xdk xdk, IEnumerable <Sprite> sprites) : base(xdk, sprites, "light_", "LightGauge")
 {
 }
예제 #27
0
 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")
 {
 }
예제 #29
0
 protected GaugeController(Xdk xdk, Sprite[] sprites, string gaugeName) : base(xdk, gaugeName)
 {
     this.Sprites = sprites;
 }