This repository was archived by the owner on Feb 10, 2026. It is now read-only.
forked from eclipse-velocitas/vehicle-app-python-sdk
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsample.py
More file actions
113 lines (85 loc) · 3.15 KB
/
Copy pathsample.py
File metadata and controls
113 lines (85 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# Copyright (c) 2022 Robert Bosch GmbH and Microsoft Corporation
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0
"""Sample Vehicle Data Model"""
# Disable pylint warnings for snake_case naming convention because of gRPC stubs.
# pylint: disable=C0103
from vehicle_model.proto.hvac_pb2 import (
AcStatus,
SetAcStatusRequest,
SetTemperatureRequest,
)
from vehicle_model.proto.hvac_pb2_grpc import HvacStub
from sdv.model import DataPointBoolean, DataPointFloat, Model, Service
class HvacService(Service):
"HVAC Service model"
def __init__(self):
super().__init__()
self._stub = HvacStub(self.channel)
async def ToggleAcStatus(self, status: bool):
if status:
response = await self._stub.SetAcStatus(
SetAcStatusRequest(status=AcStatus.ON), metadata=self.metadata
)
else:
response = await self._stub.SetAcStatus(
SetAcStatusRequest(status=AcStatus.OFF), metadata=self.metadata
)
return response
async def SetTemperature(
self,
temperature: float,
):
response = await self._stub.SetTemperature(
SetTemperatureRequest(
temperature=temperature, # type: ignore
),
metadata=self.metadata,
)
return response
class Cabin(Model):
"Cabin model."
def __init__(self, parent):
super().__init__(parent)
# Dogmode Sample
self.HvacService = HvacService()
self.IsAirConditioningActive = DataPointBoolean("IsAirConditioningActive", self)
self.DogMode = DataPointBoolean("DogMode", self)
self.AmbientAirTemperature = DataPointFloat("AmbientAirTemperature", self)
self.DesiredAmbientAirTemperature = DataPointFloat(
"DesiredAmbientAirTemperature", self
)
self.DogModeTemperature = DataPointFloat("DogModeTemperature", self)
class Battery(Model):
"""Battery model"""
def __init__(self, parent: Model):
super().__init__(parent)
self.StateOfCharge = StateOfCharge(self)
class Powertrain(Model):
"""Powertrain model"""
def __init__(self, parent: Model):
super().__init__(parent)
self.Battery = Battery(self)
class StateOfCharge(Model):
"""StateOfCharge model"""
def __init__(self, parent: Model):
super().__init__(parent)
self.Current = DataPointFloat("Current", self)
class Vehicle(Model):
"""Sample Vehicle model."""
def __init__(self):
super().__init__()
self.Powertrain = Powertrain(self)
self.Speed = DataPointFloat("Speed", self)
self.Cabin = Cabin(self)
vehicle = Vehicle()