Mgerge branch 'master' of github.com:otcshare/GhostCluster into up3
[profile/ivi/GhostCluster.git] / business.js
index 5f38af5..2c32b6c 100644 (file)
@@ -137,6 +137,11 @@ window.onload = function()
 {
     var addy = "127.0.0.1:23000";
 
+    var vehicle = tizen.vehicle
+
+    var vehicleSpeed = vehicle.get("VehicleSpeed");
+    console.log("Vehicle speed: " + vehicleSpeed.VehicleSpeed);
+
     if(typeof(Storage)!== "undefined")
     {
         addyTemp = localStorage.address;
@@ -147,9 +152,9 @@ window.onload = function()
     $("#address").change(function() { localStorage.address = $("#address").val(); });
     $("#connectButton").click(function() { connect(addy) });
 
+    
 
-
-    connect(addy);
+    //connect(addy);
 
     var velocityUnits = $('#velocityUnits');
     velocityUnits.click(function() {
@@ -159,4 +164,66 @@ window.onload = function()
                               }
                               else velocityUnits.text("MPH");
                         });
+
+   vehicle.subscribe("VehicleSpeed",function(data) {
+                                 console.log("Vehicle data" + data.VehicleSpeed);
+                                  adjvalue = data.VehicleSpeed;
+                                  curVss = adjvalue;
+                                  var velocityUnits = $('#velocityUnits');
+
+                                  if(velocityUnits.text() === "MPH")
+                                      adjvalue = Math.floor(adjvalue * 0.62137);
+
+                                  $('#velocity').text(adjvalue);
+
+                                  calcAverageVelocity(adjvalue);
+                              });
+
+   vehicle.subscribe("EngineSpeed", function(data) {
+                                  var value = data.EngineSpeed;
+                                  if(value > 10000) value =10000;
+                                  var needleDegs = value / 10000 * 180;
+                                  $('#rpms').text(value);
+                                  $('#rpmNeedle').css("-webkit-transform","rotate("+needleDegs+"deg)");
+                              });
+
+    vehicle.subscribe("Transmission",function(data) {
+                                  value = data.GearPosition;
+                                  if(value == 128)
+                                      $('#gear').text('Reverse');
+                                  else if(value == 0)
+                                      $('#gear').text('Neutral');
+                                  else $('#gear').text(value);
+
+                              });
+
+    vehicle.subscribe("SteeringWheelAngle", function(data) {
+                                  value = data.SteeringWheelAngle;
+                                  $('#wheel').css("-webkit-transform","rotate("+value+"deg)");
+                                  $('#machinegun').css("-webkit-transform","rotate("+value+"deg)");
+                              });
+
+    vehicle.subscribe("ThrottlePosition", function(data) {
+                                  value = data.ThrottlePosition;
+                                  var needleDegs = (value / 100 * 180) + 270
+
+                                  $('#throttleNeedle').css("-webkit-transform","rotate("+needleDegs+"deg)");
+
+                              });
+
+    vehicle.subscribe("EngineCoolantTemperature", function(data) {
+                                  value = data.EngineCoolantTemperature;
+                                  var needleDegs = (value / 180 * 70) + 270
+
+                                  $('#engineCoolantNeedle').css("-webkit-transform","rotate("+needleDegs+"deg)");
+
+                              });
+
+    vehicle.subscribe("MachineGunTurretStatus", function(data) {
+                                  value = data.MachineGunTurretStatus;
+                                  if(value === "1")
+                                      $('#machineGunTurretPopup').popup('open');
+                                  else $('#machineGunTurretPopup').popup('close');
+
+                              });
 }