2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 var utils_ = xwalk.utils;
18 var privilege_ = utils_.privilege;
19 var validator_ = utils_.validator;
20 var converter_ = utils_.converter;
22 var types_ = validator_.Types;
23 var native_ = new utils_.NativeManager(extension);
30 PROXIMITY: 'PROXIMITY',
31 ULTRAVIOLET: 'ULTRAVIOLET',
34 GYROSCOPE: 'GYROSCOPE',
35 GYROSCOPE_ROTATION_VECTOR: 'GYROSCOPE_ROTATION_VECTOR',
36 LINEAR_ACCELERATION: 'LINEAR_ACCELERATION',
37 MAGNETIC_UNCALIBRATED: 'MAGNETIC_UNCALIBRATED',
38 GYROSCOPE_UNCALIBRATED: 'GYROSCOPE_UNCALIBRATED',
39 ACCELERATION: 'ACCELERATION'
42 var ProximityState = {
47 var MagneticSensorAccuracy = {
48 UNDEFINED: 'ACCURACY_UNDEFINED',
50 NORMAL: 'ACCURACY_NORMAL',
51 GOOD: 'ACCURACY_GOOD',
52 VERYGOOD: 'ACCURACY_VERYGOOD'
61 // helper class for sensor listeners
62 var SensorListener = function(type, constructor) {
63 this.sensorType = type;
64 this.state = SensorStates.NOT_STARTED;
65 this.callback = undefined;
66 this.callbackInterval = undefined;
67 this.callbackBatchLatency = undefined;
68 this.constructor = constructor;
71 SensorListener.prototype.tryCall = function(object) {
73 this.callback(new this.constructor(object));
77 SensorListener.prototype.start = function(successCallback, errorCallback) {
78 if (SensorStates.STARTED != this.state) {
80 this.state = SensorStates.STARTING;
81 var thisObject = this;
82 native_.call('Sensor_start', { sensorType: thisObject.sensorType }, function(
85 if (native_.isFailure(result)) {
86 thisObject.state = SensorStates.NOT_STARTED;
87 if (!T_.isNullOrUndefined(errorCallback)) {
88 errorCallback(native_.getErrorObject(result));
91 thisObject.state = SensorStates.STARTED;
96 // sensor is already started - just call success callback
97 setTimeout(function() {
103 SensorListener.prototype.stop = function() {
104 if (SensorStates.NOT_STARTED != this.state) {
105 var result = native_.callSync('Sensor_stop', { sensorType: this.sensorType });
106 if (native_.isFailure(result)) {
107 throw native_.getErrorObject(result);
109 this.state = SensorStates.NOT_STARTED;
113 SensorListener.prototype.setListener = function(successCallback, interval, batchLatency) {
116 this.callbackInterval != interval ||
117 this.callbackBatchLatency != batchLatency
119 //call platform only if there was no listener registered or parameters changed
120 var result = native_.callSync('Sensor_setChangeListener', {
121 sensorType: this.sensorType,
123 batchLatency: batchLatency
126 if (native_.isFailure(result)) {
127 throw native_.getErrorObject(result);
130 this.callbackInterval = interval;
131 this.callbackBatchLatency = batchLatency;
132 this.callback = successCallback;
135 SensorListener.prototype.unsetListener = function() {
137 //unregister in platform only if there is callback registered
138 this.callback = undefined;
139 var result = native_.callSync('Sensor_unsetChangeListener', {
140 sensorType: this.sensorType
142 if (native_.isFailure(result)) {
143 throw native_.getErrorObject(result);
148 SensorListener.prototype.getData = function(successCallback, errorCallback) {
150 if (SensorStates.STARTED != this.state) {
151 setTimeout(function() {
152 if (!T_.isNullOrUndefined(errorCallback)) {
155 WebAPIException.SERVICE_NOT_AVAILABLE_ERR,
156 'Service is not available.'
162 native_.call('Sensor_getData', { type: thisObj.sensorType }, function(result) {
163 if (native_.isFailure(result)) {
164 if (!T_.isNullOrUndefined(errorCallback)) {
165 errorCallback(native_.getErrorObject(result));
168 successCallback(new thisObj.constructor(result));
174 var _supportedSensors = [];
175 var _isChecked = false;
176 var _sensorListeners = {
185 GYROSCOPE_ROTATION_VECTOR: {},
186 LINEAR_ACCELERATION: {},
187 MAGNETIC_UNCALIBRATED: {},
188 GYROSCOPE_UNCALIBRATED: {},
192 var errorWrapper = function(err) {
193 if (err.name === 'UnknownError') {
194 err = new WebAPIException(WebAPIException.ABORT_ERR, err.message);
197 native_.callIfPossible(this.errorCallback, err);
200 var _listener = function(object) {
201 if (object.sensorType.substring(0, 4) === 'LED_') {
202 object.sensorType = 'HRM_RAW';
204 _sensorListeners[object.sensorType].tryCall(object);
207 var SENSOR_CHANGED_LISTENER = 'SensorChangedListener';
208 native_.addListener(SENSOR_CHANGED_LISTENER, _listener);
210 function getAvailableSensors() {
211 var result = native_.callSync('SensorService_getAvailableSensors', {});
212 if (native_.isFailure(result)) {
213 throw native_.getErrorObject(result);
215 _supportedSensors = native_.getResultObject(result);
219 function SensorService() {}
221 function getDefaultSensor() {
222 var args = validator_.validateArgs(arguments, [
226 values: T_.getValues(SensorType)
231 getAvailableSensors();
234 var index = _supportedSensors.indexOf(args.type);
236 throw new WebAPIException(WebAPIException.NOT_SUPPORTED_ERR, 'Not supported.');
237 } else if (_supportedSensors[index] === SensorType.LIGHT) {
238 return new LightSensor();
239 } else if (_supportedSensors[index] === SensorType.MAGNETIC) {
240 return new MagneticSensor();
241 } else if (_supportedSensors[index] === SensorType.PRESSURE) {
242 return new PressureSensor();
243 } else if (_supportedSensors[index] === SensorType.PROXIMITY) {
244 return new ProximitySensor();
245 } else if (_supportedSensors[index] === SensorType.ULTRAVIOLET) {
246 return new UltravioletSensor();
247 } else if (_supportedSensors[index] === SensorType.HRM_RAW) {
248 utils_.checkPrivilegeAccess(privilege_.HEALTHINFO);
249 return new HRMRawSensor();
250 } else if (_supportedSensors[index] === SensorType.GRAVITY) {
251 return new GravitySensor();
252 } else if (_supportedSensors[index] === SensorType.GYROSCOPE) {
253 return new GyroscopeSensor();
254 } else if (_supportedSensors[index] === SensorType.GYROSCOPE_ROTATION_VECTOR) {
255 return new GyroscopeRotationVectorSensor();
256 } else if (_supportedSensors[index] === SensorType.LINEAR_ACCELERATION) {
257 return new LinearAccelerationSensor();
258 } else if (_supportedSensors[index] === SensorType.MAGNETIC_UNCALIBRATED) {
259 return new MagneticUncalibratedSensor();
260 } else if (_supportedSensors[index] === SensorType.GYROSCOPE_UNCALIBRATED) {
261 return new GyroscopeUncalibratedSensor();
262 } else if (_supportedSensors[index] === SensorType.ACCELERATION) {
263 return new AccelerationSensor();
267 SensorService.prototype.getDefaultSensor = function() {
268 return getDefaultSensor.apply(this, arguments);
271 SensorService.prototype.getAvailableSensors = function() {
273 getAvailableSensors();
276 return _supportedSensors.slice();
279 //////////////////////Sensor classes/////////////////////////////
280 //// Base Sensor class
281 var Sensor = function(type) {
282 Object.defineProperties(this, {
283 sensorType: { value: type, writable: false, enumerable: true }
287 Sensor.prototype.start = function() {
288 var args = validator_.validateArgs(arguments, [
290 name: 'successCallback',
291 type: types_.FUNCTION
294 name: 'errorCallback',
295 type: types_.FUNCTION,
301 _sensorListeners[this.sensorType].start(args.successCallback, args.errorCallback);
304 Sensor.prototype.stop = function() {
305 _sensorListeners[this.sensorType].stop();
308 Sensor.prototype.setChangeListener = function() {
309 var args = validator_.validateArgs(arguments, [
311 name: 'successCallback',
312 type: types_.FUNCTION
321 name: 'batchLatency',
328 var interval = args.interval || 100;
329 if (interval < 10 || interval > 1000) {
330 throw new WebAPIException(
331 WebAPIException.INVALID_VALUES_ERR,
332 'Interval should be in range [10, 1000] milliseconds.'
336 var batchLatency = args.batchLatency || 0;
338 _sensorListeners[this.sensorType].setListener(
339 args.successCallback,
345 Sensor.prototype.unsetChangeListener = function() {
346 _sensorListeners[this.sensorType].unsetListener();
349 Sensor.prototype.getSensorHardwareInfo = function() {
350 var args = validator_.validateArgs(arguments, [
352 name: 'successCallback',
353 type: types_.FUNCTION
356 name: 'errorCallback',
357 type: types_.FUNCTION,
363 var callback = function(result) {
364 if (native_.isFailure(result)) {
365 if (!T_.isNullOrUndefined(errorCallback)) {
366 errorCallback(native_.getErrorObject(result));
369 args.successCallback(new SensorHardwareInfo(result));
373 var result = native_.call(
374 'Sensor_getSensorHardwareInfo',
375 { type: this.sensorType },
381 var LightSensor = function(data) {
382 Sensor.call(this, SensorType.LIGHT);
385 LightSensor.prototype = new Sensor();
387 LightSensor.prototype.constructor = Sensor;
389 LightSensor.prototype.getLightSensorData = function() {
390 var args = validator_.validateArgs(arguments, [
392 name: 'successCallback',
393 type: types_.FUNCTION
396 name: 'errorCallback',
397 type: types_.FUNCTION,
403 _sensorListeners[this.sensorType].getData(args.successCallback, args.errorCallback);
407 var MagneticSensor = function(data) {
408 Sensor.call(this, SensorType.MAGNETIC);
411 MagneticSensor.prototype = new Sensor();
413 MagneticSensor.prototype.constructor = Sensor;
415 MagneticSensor.prototype.getMagneticSensorData = function() {
416 var args = validator_.validateArgs(arguments, [
418 name: 'successCallback',
419 type: types_.FUNCTION
422 name: 'errorCallback',
423 type: types_.FUNCTION,
429 _sensorListeners[this.sensorType].getData(args.successCallback, args.errorCallback);
433 var PressureSensor = function(data) {
434 Sensor.call(this, SensorType.PRESSURE);
437 PressureSensor.prototype = new Sensor();
439 PressureSensor.prototype.constructor = Sensor;
441 PressureSensor.prototype.getPressureSensorData = function() {
442 var args = validator_.validateArgs(arguments, [
444 name: 'successCallback',
445 type: types_.FUNCTION
448 name: 'errorCallback',
449 type: types_.FUNCTION,
455 _sensorListeners[this.sensorType].getData(args.successCallback, args.errorCallback);
459 var ProximitySensor = function(data) {
460 Sensor.call(this, SensorType.PROXIMITY);
463 ProximitySensor.prototype = new Sensor();
465 ProximitySensor.prototype.constructor = Sensor;
467 ProximitySensor.prototype.getProximitySensorData = function() {
468 var args = validator_.validateArgs(arguments, [
470 name: 'successCallback',
471 type: types_.FUNCTION
474 name: 'errorCallback',
475 type: types_.FUNCTION,
481 _sensorListeners[this.sensorType].getData(args.successCallback, args.errorCallback);
484 //// UltravioletSensor
485 var UltravioletSensor = function(data) {
486 Sensor.call(this, SensorType.ULTRAVIOLET);
489 UltravioletSensor.prototype = new Sensor();
491 UltravioletSensor.prototype.constructor = Sensor;
493 UltravioletSensor.prototype.getUltravioletSensorData = function() {
494 var args = validator_.validateArgs(arguments, [
496 name: 'successCallback',
497 type: types_.FUNCTION
500 name: 'errorCallback',
501 type: types_.FUNCTION,
507 _sensorListeners[this.sensorType].getData(args.successCallback, args.errorCallback);
511 var HRMRawSensor = function(data) {
512 Sensor.call(this, SensorType.HRM_RAW);
515 HRMRawSensor.prototype = new Sensor();
517 HRMRawSensor.prototype.constructor = Sensor;
519 function getHRMRawSensorData() {
520 var args = validator_.validateArgs(arguments, [
522 name: 'successCallback',
523 type: types_.FUNCTION
526 name: 'errorCallback',
527 type: types_.FUNCTION,
533 utils_.checkPrivilegeAccess(privilege_.HEALTHINFO);
535 _sensorListeners[this.sensorType].getData(args.successCallback, args.errorCallback);
538 HRMRawSensor.prototype.getHRMRawSensorData = function() {
539 getHRMRawSensorData.apply(this, arguments);
543 var GravitySensor = function(data) {
544 Sensor.call(this, SensorType.GRAVITY);
547 GravitySensor.prototype = new Sensor();
549 GravitySensor.prototype.constructor = Sensor;
551 GravitySensor.prototype.getGravitySensorData = function() {
552 var args = validator_.validateArgs(arguments, [
554 name: 'successCallback',
555 type: types_.FUNCTION
558 name: 'errorCallback',
559 type: types_.FUNCTION,
565 _sensorListeners[this.sensorType].getData(
566 args.successCallback,
567 errorWrapper.bind(args)
572 var GyroscopeSensor = function(data) {
573 Sensor.call(this, SensorType.GYROSCOPE);
576 GyroscopeSensor.prototype = new Sensor();
578 GyroscopeSensor.prototype.constructor = Sensor;
580 GyroscopeSensor.prototype.getGyroscopeSensorData = function() {
581 var args = validator_.validateArgs(arguments, [
583 name: 'successCallback',
584 type: types_.FUNCTION
587 name: 'errorCallback',
588 type: types_.FUNCTION,
594 _sensorListeners[this.sensorType].getData(
595 args.successCallback,
596 errorWrapper.bind(args)
600 //// GyroscopeRotationVectorSensor
601 var GyroscopeRotationVectorSensor = function(data) {
602 Sensor.call(this, SensorType.GYROSCOPE_ROTATION_VECTOR);
605 GyroscopeRotationVectorSensor.prototype = new Sensor();
607 GyroscopeRotationVectorSensor.prototype.constructor = Sensor;
609 GyroscopeRotationVectorSensor.prototype.getGyroscopeRotationVectorSensorData =
611 var args = validator_.validateArgs(arguments, [
613 name: 'successCallback',
614 type: types_.FUNCTION
617 name: 'errorCallback',
618 type: types_.FUNCTION,
624 _sensorListeners[this.sensorType].getData(
625 args.successCallback,
626 errorWrapper.bind(args)
630 //// LinearAccelerationSensor
631 var LinearAccelerationSensor = function(data) {
632 Sensor.call(this, SensorType.LINEAR_ACCELERATION);
635 LinearAccelerationSensor.prototype = new Sensor();
637 LinearAccelerationSensor.prototype.constructor = Sensor;
639 LinearAccelerationSensor.prototype.getLinearAccelerationSensorData = function() {
640 var args = validator_.validateArgs(arguments, [
642 name: 'successCallback',
643 type: types_.FUNCTION
646 name: 'errorCallback',
647 type: types_.FUNCTION,
653 _sensorListeners[this.sensorType].getData(
654 args.successCallback,
655 errorWrapper.bind(args)
659 //// MagneticUncalibratedSensor
660 var MagneticUncalibratedSensor = function(data) {
661 Sensor.call(this, SensorType.MAGNETIC_UNCALIBRATED);
664 MagneticUncalibratedSensor.prototype = new Sensor();
666 MagneticUncalibratedSensor.prototype.constructor = Sensor;
668 MagneticUncalibratedSensor.prototype.getMagneticUncalibratedSensorData = function() {
669 var args = validator_.validateArgs(arguments, [
671 name: 'successCallback',
672 type: types_.FUNCTION
675 name: 'errorCallback',
676 type: types_.FUNCTION,
682 _sensorListeners[this.sensorType].getData(
683 args.successCallback,
684 errorWrapper.bind(args)
688 //// GyroscopeUncalibratedSensor
689 var GyroscopeUncalibratedSensor = function(data) {
690 Sensor.call(this, SensorType.GYROSCOPE_UNCALIBRATED);
693 GyroscopeUncalibratedSensor.prototype = new Sensor();
695 GyroscopeUncalibratedSensor.prototype.constructor = Sensor;
697 GyroscopeUncalibratedSensor.prototype.getGyroscopeUncalibratedSensorData = function() {
698 var args = validator_.validateArgs(arguments, [
700 name: 'successCallback',
701 type: types_.FUNCTION
704 name: 'errorCallback',
705 type: types_.FUNCTION,
711 _sensorListeners[this.sensorType].getData(
712 args.successCallback,
713 errorWrapper.bind(args)
717 //// AccelerationSensor
718 var AccelerationSensor = function(data) {
719 Sensor.call(this, SensorType.ACCELERATION);
722 AccelerationSensor.prototype = new Sensor();
724 AccelerationSensor.prototype.constructor = Sensor;
726 AccelerationSensor.prototype.getAccelerationSensorData = function() {
727 var args = validator_.validateArgs(arguments, [
729 name: 'successCallback',
730 type: types_.FUNCTION
733 name: 'errorCallback',
734 type: types_.FUNCTION,
740 _sensorListeners[this.sensorType].getData(
741 args.successCallback,
742 errorWrapper.bind(args)
746 ////////////////////// Sensor Data classes/////////////////////////////
747 ////Base SensorData class
748 var SensorData = function() {};
751 var SensorLightData = function(data) {
752 SensorData.call(this);
753 Object.defineProperties(this, {
754 lightLevel: { value: data.lightLevel, writable: false, enumerable: true }
758 SensorLightData.prototype = new SensorData();
760 SensorLightData.prototype.constructor = SensorData;
762 _sensorListeners[SensorType.LIGHT] = new SensorListener(
767 //// SensorMagneticData
768 var SensorMagneticData = function(data) {
769 SensorData.call(this);
770 Object.defineProperties(this, {
771 x: { value: data.x, writable: false, enumerable: true },
772 y: { value: data.y, writable: false, enumerable: true },
773 z: { value: data.z, writable: false, enumerable: true },
774 accuracy: { value: data.accuracy, writable: false, enumerable: true }
778 SensorMagneticData.prototype = new SensorData();
780 SensorMagneticData.prototype.constructor = SensorData;
782 _sensorListeners[SensorType.MAGNETIC] = new SensorListener(
787 //// SensorPressureData
788 var SensorPressureData = function(data) {
789 SensorData.call(this);
790 Object.defineProperties(this, {
791 pressure: { value: data.pressure, writable: false, enumerable: true }
795 SensorPressureData.prototype = new SensorData();
797 SensorPressureData.prototype.constructor = SensorData;
799 _sensorListeners[SensorType.PRESSURE] = new SensorListener(
804 //// SensorProximityData
805 var SensorProximityData = function(data) {
806 SensorData.call(this);
807 Object.defineProperties(this, {
808 proximityState: { value: data.proximityState, writable: false, enumerable: true }
812 SensorProximityData.prototype = new SensorData();
814 SensorProximityData.prototype.constructor = SensorData;
816 _sensorListeners[SensorType.PROXIMITY] = new SensorListener(
817 SensorType.PROXIMITY,
821 //// SensorUltravioletData
822 var SensorUltravioletData = function(data) {
823 SensorData.call(this);
824 Object.defineProperties(this, {
826 value: data.ultravioletLevel,
833 SensorUltravioletData.prototype = new SensorData();
835 SensorUltravioletData.prototype.constructor = SensorData;
837 _sensorListeners[SensorType.ULTRAVIOLET] = new SensorListener(
838 SensorType.ULTRAVIOLET,
839 SensorUltravioletData
843 var SensorHRMRawData = function(data) {
844 SensorData.call(this);
845 Object.defineProperties(this, {
846 lightType: { value: data.lightType, writable: false, enumerable: true },
847 lightIntensity: { value: data.lightIntensity, writable: false, enumerable: true }
851 SensorHRMRawData.prototype = new SensorData();
853 SensorHRMRawData.prototype.constructor = SensorData;
855 _sensorListeners[SensorType.HRM_RAW] = new SensorListener(
860 //// SensorGravityData
861 var SensorGravityData = function(data) {
862 SensorData.call(this);
863 Object.defineProperties(this, {
864 x: { value: data.x, writable: false, enumerable: true },
865 y: { value: data.y, writable: false, enumerable: true },
866 z: { value: data.z, writable: false, enumerable: true }
870 SensorGravityData.prototype = new SensorData();
872 SensorGravityData.prototype.constructor = SensorData;
874 _sensorListeners[SensorType.GRAVITY] = new SensorListener(
879 //// SensorGyroscopeData
880 var SensorGyroscopeData = function(data) {
881 SensorData.call(this);
882 Object.defineProperties(this, {
883 x: { value: data.x, writable: false, enumerable: true },
884 y: { value: data.y, writable: false, enumerable: true },
885 z: { value: data.z, writable: false, enumerable: true }
889 SensorGyroscopeData.prototype = new SensorData();
891 SensorGyroscopeData.prototype.constructor = SensorData;
893 _sensorListeners[SensorType.GYROSCOPE] = new SensorListener(
894 SensorType.GYROSCOPE,
898 //// SensorGyroscopeRotationVectorData
899 var SensorGyroscopeRotationVectorData = function(data) {
900 SensorData.call(this);
901 Object.defineProperties(this, {
902 x: { value: data.x, writable: false, enumerable: true },
903 y: { value: data.y, writable: false, enumerable: true },
904 z: { value: data.z, writable: false, enumerable: true },
905 w: { value: data.w, writable: false, enumerable: true }
909 SensorGyroscopeRotationVectorData.prototype = new SensorData();
911 SensorGyroscopeRotationVectorData.prototype.constructor = SensorData;
913 _sensorListeners[SensorType.GYROSCOPE_ROTATION_VECTOR] = new SensorListener(
914 SensorType.GYROSCOPE_ROTATION_VECTOR,
915 SensorGyroscopeRotationVectorData
918 //// SensorLinearAccelerationData
919 var SensorLinearAccelerationData = function(data) {
920 SensorData.call(this);
921 Object.defineProperties(this, {
922 x: { value: data.x, writable: false, enumerable: true },
923 y: { value: data.y, writable: false, enumerable: true },
924 z: { value: data.z, writable: false, enumerable: true }
928 SensorLinearAccelerationData.prototype = new SensorData();
930 SensorLinearAccelerationData.prototype.constructor = SensorData;
932 _sensorListeners[SensorType.LINEAR_ACCELERATION] = new SensorListener(
933 SensorType.LINEAR_ACCELERATION,
934 SensorLinearAccelerationData
937 //// SensorMagneticUncalibratedData
938 var SensorMagneticUncalibratedData = function(data) {
939 SensorData.call(this);
940 Object.defineProperties(this, {
941 x: { value: data.x, writable: false, enumerable: true },
942 y: { value: data.y, writable: false, enumerable: true },
943 z: { value: data.z, writable: false, enumerable: true },
944 xAxisBias: { value: data.xAxisBias, writable: false, enumerable: true },
945 yAxisBias: { value: data.yAxisBias, writable: false, enumerable: true },
946 zAxisBias: { value: data.zAxisBias, writable: false, enumerable: true }
950 SensorMagneticUncalibratedData.prototype = new SensorData();
952 SensorMagneticUncalibratedData.prototype.constructor = SensorData;
954 _sensorListeners[SensorType.MAGNETIC_UNCALIBRATED] = new SensorListener(
955 SensorType.MAGNETIC_UNCALIBRATED,
956 SensorMagneticUncalibratedData
959 //// SensorGyroscopeUncalibratedData
960 var SensorGyroscopeUncalibratedData = function(data) {
961 SensorData.call(this);
962 Object.defineProperties(this, {
963 x: { value: data.x, writable: false, enumerable: true },
964 y: { value: data.y, writable: false, enumerable: true },
965 z: { value: data.z, writable: false, enumerable: true },
966 xAxisDrift: { value: data.xAxisDrift, writable: false, enumerable: true },
967 yAxisDrift: { value: data.yAxisDrift, writable: false, enumerable: true },
968 zAxisDrift: { value: data.zAxisDrift, writable: false, enumerable: true }
972 SensorGyroscopeUncalibratedData.prototype = new SensorData();
974 SensorGyroscopeUncalibratedData.prototype.constructor = SensorData;
976 _sensorListeners[SensorType.GYROSCOPE_UNCALIBRATED] = new SensorListener(
977 SensorType.GYROSCOPE_UNCALIBRATED,
978 SensorGyroscopeUncalibratedData
981 //// SensorAccelerationData
982 var SensorAccelerationData = function(data) {
983 SensorData.call(this);
984 Object.defineProperties(this, {
985 x: { value: data.x, writable: false, enumerable: true },
986 y: { value: data.y, writable: false, enumerable: true },
987 z: { value: data.z, writable: false, enumerable: true }
991 SensorAccelerationData.prototype = new SensorData();
993 SensorAccelerationData.prototype.constructor = SensorData;
995 _sensorListeners[SensorType.ACCELERATION] = new SensorListener(
996 SensorType.ACCELERATION,
997 SensorAccelerationData
1000 //////////////////////SensorHardwareInfo classes/////////////////////////////
1001 function SensorHardwareInfo(data) {
1002 Object.defineProperties(this, {
1003 name: { value: data.name, writable: false, enumerable: true },
1004 type: { value: data.type, writable: false, enumerable: true },
1005 vendor: { value: data.vendor, writable: false, enumerable: true },
1006 minValue: { value: data.minValue, writable: false, enumerable: true },
1007 maxValue: { value: data.maxValue, writable: false, enumerable: true },
1008 resolution: { value: data.resolution, writable: false, enumerable: true },
1009 minInterval: { value: data.minInterval, writable: false, enumerable: true },
1010 maxBatchCount: { value: data.batchCount, writable: false, enumerable: true }
1014 exports = new SensorService();