summaryrefslogtreecommitdiffstats
path: root/recipes-demo/kuksa-vss-init/files
diff options
context:
space:
mode:
authorAakash Solanki <tech2aks@gmail.com>2022-08-06 13:49:55 +0200
committerAakash Solanki <tech2aks@gmail.com>2022-08-08 20:44:07 +0200
commitf8eb43810177a33d2fb414341e31caa0ae75bdfe (patch)
tree7ed6fedcb67834c57791da21b3a251fc5c59ace2 /recipes-demo/kuksa-vss-init/files
parent85d834afe1cdc9c25e3d94daefc8d515b7d0c361 (diff)
Update agl-cluster-demo-platform-flutter image
- Remove packagegroup and add packages to image - Add a script to set some value in Kuksa data model - Add Simple-CAN-simulator Bug-AGL: SPEC-4508 Change-Id: Ibf4f4c2b02f7860e2f93c08a5c0e064272652657 Signed-off-by: Aakash Solanki <tech2aks@gmail.com>
Diffstat (limited to 'recipes-demo/kuksa-vss-init/files')
-rw-r--r--recipes-demo/kuksa-vss-init/files/kuksa_vss_init.py98
1 files changed, 98 insertions, 0 deletions
diff --git a/recipes-demo/kuksa-vss-init/files/kuksa_vss_init.py b/recipes-demo/kuksa-vss-init/files/kuksa_vss_init.py
new file mode 100644
index 000000000..5453112c9
--- /dev/null
+++ b/recipes-demo/kuksa-vss-init/files/kuksa_vss_init.py
@@ -0,0 +1,98 @@
+#!/usr/bin/env python3
+# Copyright (c) 2022 Aakash Solanki, tech2aks@gmail.com
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy of
+# this software and associated documentation files (the "Software"), to deal in
+# the Software without restriction, including without limitation the rights to
+# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+# of the Software, and to permit persons to whom the Software is furnished to do
+# so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in all
+# copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+import kuksa_viss_client
+import time
+
+
+class VSS:
+ def __init__(self, client):
+ self.client = client
+
+ self.speed = "Vehicle.Speed"
+ self.engineRPM = "Vehicle.Powertrain.CombustionEngine.Engine.Speed"
+ self.fuelLevel = "Vehicle.Powertrain.FuelSystem.Level"
+ self.coolantTemp = "Vehicle.Powertrain.CombustionEngine.Engine.ECT"
+ self.leftIndicator = "Vehicle.Body.Lights.IsLeftIndicatorOn"
+ self.rightIndicator = "Vehicle.Body.Lights.IsRightIndicatorOn"
+ # // Selected Gear output = > 0 = Neutral, 1/2/.. = Forward, -1/.. = Reverse, 126 = Park, 127 = Drive
+ self.selectedGear = "Vehicle.Powertrain.Transmission.SelectedGear"
+ self.lowBeamOn = "Vehicle.Body.Lights.IsLowBeamOn"
+ self.highBeamOn = "Vehicle.Body.Lights.IsHighBeamOn"
+ self.parkingLightOn = "Vehicle.Body.Lights.IsParkingOn"
+ self.hazardLightOn = "Vehicle.Body.Lights.IsHazardOn"
+ self.travelledDistance = "Vehicle.TravelledDistance"
+ self.trunkLocked = "Vehicle.Body.Trunk.IsLocked"
+ self.trunkOpen = "Vehicle.Body.Trunk.IsOpen"
+ # // \"normal\", \"sport\", \"economy\", \"snow\", \"rain\"]
+ self.performanceMode = "Vehicle.Powertrain.Transmission.PerformanceMode"
+ self.ambientAirTemperature = "Vehicle.AmbientAirTemperature"
+ self.mil = "Vehicle.OBD.Status.MIL"
+ self.cruiseControlError = "Vehicle.ADAS.CruiseControl.Error"
+ self.cruiseControlSpeedSet = "Vehicle.ADAS.CruiseControl.SpeedSet"
+ self.cruiseControlisActive = "Vehicle.ADAS.CruiseControl.IsActive"
+ self.batteryChargingStatus = "Vehicle.Powertrain.Battery.Charging.Status"
+
+ def setInitialValues(self):
+ print("Setting values")
+ self.client.setValue(self.speed, '5')
+ self.client.setValue(self.engineRPM, '1000')
+ self.client.setValue(self.fuelLevel, '50')
+ self.client.setValue(self.coolantTemp, '70')
+ self.client.setValue(self.leftIndicator, "false")
+ self.client.setValue(self.rightIndicator, "false")
+ self.client.setValue(self.selectedGear, '127')
+ self.client.setValue(self.lowBeamOn, "true")
+ self.client.setValue(self.highBeamOn, "false")
+ self.client.setValue(self.parkingLightOn, "true")
+ self.client.setValue(self.hazardLightOn, "false")
+ self.client.setValue(self.travelledDistance, '100')
+ self.client.setValue(self.trunkLocked, "true")
+ self.client.setValue(self.trunkOpen, "false")
+ self.client.setValue(self.performanceMode, "normal")
+ self.client.setValue(self.ambientAirTemperature, '28')
+ self.client.setValue(self.mil, "false")
+ self.client.setValue(self.cruiseControlError, "false")
+ self.client.setValue(self.cruiseControlisActive, "false")
+ self.client.setValue(self.cruiseControlSpeedSet, '60')
+ self.client.setValue(self.batteryChargingStatus, "true")
+ print("All value set succesfully")
+
+
+def main():
+ config = {"ip": "localhost", "port": 8090, "insecure": False}
+ client = kuksa_viss_client.KuksaClientThread(config)
+ client.start()
+ token_file = open(
+ "/usr/lib/python3.10/site-packages/kuksa_certificates/jwt/all-read-write.json.token", "r")
+ token = token_file.read()
+ client.authorize(token, timeout=2)
+
+ vss = VSS(client)
+
+ time.sleep(2)
+
+ vss.setInitialValues()
+ client.stop()
+
+
+if __name__ == '__main__':
+ main()