@@ -33,6 +33,16 @@ def __str__(self) -> str:
3333 }
3434 return d .get (self , f"VehicleAreaType.{ self .name } " )
3535
36+ @staticmethod
37+ def get_java_doc (area : int ) -> str :
38+ if area == 0 :
39+ return "VEHICLE_AREA_TYPE_GLOBAL"
40+ elif area == 7 :
41+ return "VEHICLE_AREA_TYPE_VENDOR"
42+ else :
43+ logging .error (f"Vehicle property access must be 0 or 7, was { area } " )
44+ sys .exit (1 )
45+
3646
3747class VhalPropertyGroup (Enum ):
3848 """
@@ -43,7 +53,7 @@ class VhalPropertyGroup(Enum):
4353 VEHICLE_PROPERTY_GROUP_SYSTEM = int (0x10000000 ) # VehiclePropertyGroup.SYSTEM aidl
4454 VEHICLE_PROPERTY_GROUP_VENDOR = int (0x20000000 ) # VehiclePropertyGroup.VENDOR aidl
4555 VEHICLE_PROPERTY_GROUP_BACKPORTED = int (0x30000000 ) # VehiclePropertyGroup.BACKPORTED aidl
46- VEHICLE_PROPERTY_GROUP_VSS = int (0x40000000 ) # VehiclePropertyGroup.VSS aidl (COVESA)
56+ VEHICLE_PROPERTY_GROUP_OEM = int (0x40000000 ) # VehiclePropertyGroup.OEM aidl (COVESA)
4757
4858 @staticmethod
4959 def get (group : int ):
@@ -54,21 +64,49 @@ def get(group: int):
5464 elif group == 3 :
5565 return VhalPropertyGroup .VEHICLE_PROPERTY_GROUP_BACKPORTED
5666 elif group == 4 :
57- return VhalPropertyGroup .VEHICLE_PROPERTY_GROUP_VSS
67+ return VhalPropertyGroup .VEHICLE_PROPERTY_GROUP_OEM
5868 else :
5969 logging .error (f"Group must be between 1 and 4, was { group } " )
6070 sys .exit (1 )
6171
62- def __str__ (self ):
72+ def __str__ (self ) -> str :
6373 d = {
64- self .VEHICLE_PROPERTY_GROUP_SYSTEM : "VehiclePropertyGroup.SYSTEM" ,
65- self .VEHICLE_PROPERTY_GROUP_VENDOR : "VehiclePropertyGroup.VENDOR" ,
66- self .VEHICLE_PROPERTY_GROUP_BACKPORTED : "VehiclePropertyGroup.BACKPORTED" ,
67- self . VEHICLE_PROPERTY_GROUP_VSS : "VehiclePropertyGroup.VSS " ,
74+ VhalPropertyGroup .VEHICLE_PROPERTY_GROUP_SYSTEM : "VehiclePropertyGroup.SYSTEM" ,
75+ VhalPropertyGroup .VEHICLE_PROPERTY_GROUP_VENDOR : "VehiclePropertyGroup.VENDOR" ,
76+ VhalPropertyGroup .VEHICLE_PROPERTY_GROUP_BACKPORTED : "VehiclePropertyGroup.BACKPORTED" ,
77+ VhalPropertyGroup . VEHICLE_PROPERTY_GROUP_OEM : "VehiclePropertyGroup.OEM " ,
6878 }
6979 return d .get (self , "VehiclePropertyGroup.SYSTEM" )
7080
7181
82+ class VhalPropertyType (Enum ):
83+ VEHICLE_PROPERTY_TYPE_STRING = int (0x00100000 ) # VehiclePropertyType.STRING
84+ VEHICLE_PROPERTY_TYPE_BOOLEAN = int (0x00200000 ) # VehiclePropertyType.BOOLEAN
85+ VEHICLE_PROPERTY_TYPE_INT32 = int (0x00400000 ) # VehiclePropertyType.INT32
86+ VEHICLE_PROPERTY_TYPE_INT32_VEC = int (0x00410000 ) # VehiclePropertyType.INT32_VEC
87+ VEHICLE_PROPERTY_TYPE_INT64 = int (0x00500000 ) # VehiclePropertyType.INT64
88+ VEHICLE_PROPERTY_TYPE_INT64_VEC = int (0x00510000 ) # VehiclePropertyType.INT64_VEC
89+ VEHICLE_PROPERTY_TYPE_FLOAT = int (0x00600000 ) # VehiclePropertyType.FLOAT
90+ VEHICLE_PROPERTY_TYPE_FLOAT_VEC = int (0x00610000 ) # VehiclePropertyType.FLOAT_VEC
91+ VEHICLE_PROPERTY_TYPE_BYTES = int (0x00700000 ) # VehiclePropertyType.BYTES
92+ VEHICLE_PROPERTY_TYPE_MIXED = int (0x00E00000 ) # VehiclePropertyType.MIXED
93+
94+ def __str__ (self ) -> str :
95+ d = {
96+ VhalPropertyType .VEHICLE_PROPERTY_TYPE_STRING : "VehiclePropertyType.STRING" ,
97+ VhalPropertyType .VEHICLE_PROPERTY_TYPE_BOOLEAN : "VehiclePropertyType.BOOLEAN" ,
98+ VhalPropertyType .VEHICLE_PROPERTY_TYPE_INT32 : "VehiclePropertyType.INT32" ,
99+ VhalPropertyType .VEHICLE_PROPERTY_TYPE_INT32_VEC : "VehiclePropertyType.INT32_VEC" ,
100+ VhalPropertyType .VEHICLE_PROPERTY_TYPE_INT64 : "VehiclePropertyType.INT64" ,
101+ VhalPropertyType .VEHICLE_PROPERTY_TYPE_INT64_VEC : "VehiclePropertyType.INT64_VEC" ,
102+ VhalPropertyType .VEHICLE_PROPERTY_TYPE_FLOAT : "VehiclePropertyType.FLOAT" ,
103+ VhalPropertyType .VEHICLE_PROPERTY_TYPE_FLOAT_VEC : "VehiclePropertyType.FLOAT_VEC" ,
104+ VhalPropertyType .VEHICLE_PROPERTY_TYPE_BYTES : "VehiclePropertyType.BYTES" ,
105+ VhalPropertyType .VEHICLE_PROPERTY_TYPE_MIXED : "VehiclePropertyType.MIXED" ,
106+ }
107+ return d .get (self , "Unsupported" )
108+
109+
72110class VSSDatatypesToVhal :
73111 """
74112 Mapping of vss datatypes corresponding to standard VHAL property type IDs. For those VSS datatypes, which don't
@@ -87,27 +125,26 @@ class VSSDatatypesToVhal:
87125 Datatypes .INT64_ARRAY [0 ]: int (0x00510000 ), # INT64_VEC
88126 Datatypes .FLOAT [0 ]: int (0x00600000 ), # FLOAT
89127 Datatypes .FLOAT_ARRAY [0 ]: int (0x00610000 ), # FLOAT_VEC
90- # Further VSS types mapped to vendor hex values
91- Datatypes .STRING_ARRAY [0 ]: int (0x00110000 ),
92- Datatypes .BOOLEAN_ARRAY [0 ]: int (0x00210000 ),
93- Datatypes .INT8 [0 ]: int (0x00300000 ),
94- Datatypes .INT8_ARRAY [0 ]: int (0x00310000 ),
95- Datatypes .UINT8 [0 ]: int (0x00320000 ),
96- Datatypes .UINT8_ARRAY [0 ]: int (0x00330000 ),
97- Datatypes .INT16 [0 ]: int (0x00340000 ),
98- Datatypes .INT16_ARRAY [0 ]: int (0x00350000 ),
99- Datatypes .UINT16 [0 ]: int (0x00360000 ),
100- Datatypes .UINT16_ARRAY [0 ]: int (0x00370000 ),
101- Datatypes .UINT32 [0 ]: int (0x00420000 ),
102- Datatypes .UINT32_ARRAY [0 ]: int (0x00430000 ),
103- Datatypes .UINT64 [0 ]: int (0x00520000 ),
104- Datatypes .UINT64_ARRAY [0 ]: int (0x00530000 ),
105- Datatypes .DOUBLE [0 ]: int (0x00800000 ),
106- Datatypes .DOUBLE_ARRAY [0 ]: int (0x00810000 ),
107- Datatypes .NUMERIC [0 ]: int (0x00820000 ),
108- Datatypes .NUMERIC_ARRAY [0 ]: int (0x00830000 ),
128+ # Further VSS types mapped to hex values of supported types
129+ Datatypes .STRING_ARRAY [0 ]: int (0x00100000 ), # STRING
130+ Datatypes .BOOLEAN_ARRAY [0 ]: int (0x00410000 ), # INT32_VEC
131+ Datatypes .INT8 [0 ]: int (0x00400000 ), # INT32
132+ Datatypes .INT8_ARRAY [0 ]: int (0x00410000 ), # INT32_VEC
133+ Datatypes .UINT8 [0 ]: int (0x00400000 ), # INT32
134+ Datatypes .UINT8_ARRAY [0 ]: int (0x00410000 ), # INT32_VEC
135+ Datatypes .INT16 [0 ]: int (0x00400000 ), # INT32
136+ Datatypes .INT16_ARRAY [0 ]: int (0x00410000 ), # INT32_VEC
137+ Datatypes .UINT16 [0 ]: int (0x00400000 ), # INT32
138+ Datatypes .UINT16_ARRAY [0 ]: int (0x00410000 ), # INT32_VEC
139+ Datatypes .UINT32 [0 ]: int (0x00400000 ), # INT32
140+ Datatypes .UINT32_ARRAY [0 ]: int (0x00410000 ), # INT32_VEC
141+ Datatypes .UINT64 [0 ]: int (0x00500000 ), # INT64
142+ Datatypes .UINT64_ARRAY [0 ]: int (0x00510000 ), # INT64_VEC
143+ Datatypes .DOUBLE [0 ]: int (0x00600000 ), # fallback to FLOAT
144+ Datatypes .DOUBLE_ARRAY [0 ]: int (0x00610000 ), # fallback to FLOAT_VEC
145+ Datatypes .NUMERIC [0 ]: int (0x00600000 ), # fallback to FLOAT
146+ Datatypes .NUMERIC_ARRAY [0 ]: int (0x00610000 ), # fallback to FLOAT_VEC
109147 }
110- VHAL_TO_VSS_TYPE_MAP = {v : k for k , v in VSS_TO_VHAL_TYPE_MAP .items ()}
111148
112149 @classmethod
113150 def get_property_type_id (cls , vss_datatype : str ) -> int :
@@ -130,11 +167,11 @@ def get_property_type_repr(cls, datatype_id: int) -> str:
130167 @param datatype_id: datatype Integer representation.
131168 @return: String representation of a datatype
132169 """
133- datatype_name = VSSDatatypesToVhal . VHAL_TO_VSS_TYPE_MAP . get ( datatype_id )
170+ datatype_name = str ( VhalPropertyType ( datatype_id ) )
134171 if not datatype_name :
135172 raise Exception (f"Invalid property type id { datatype_id } , must be one of IDs listed in VSSDataTypeToVhal" )
136173
137- return f"VehiclePropertyType. { datatype_name } "
174+ return datatype_name
138175
139176
140177class VehiclePropertyAccess (IntEnum ):
@@ -147,6 +184,26 @@ class VehiclePropertyAccess(IntEnum):
147184 WRITE = 2
148185 READ_WRITE = 3
149186
187+ def __str__ (self ):
188+ d = {
189+ VehiclePropertyAccess .READ : "VehiclePropertyAccess.READ" ,
190+ VehiclePropertyAccess .WRITE : "VehiclePropertyAccess.WRITE" ,
191+ VehiclePropertyAccess .READ_WRITE : "VehiclePropertyAccess.READ_WRITE" ,
192+ }
193+ return d .get (self , "VehiclePropertyAccess.READ" )
194+
195+ @staticmethod
196+ def get_java_doc (access : int ) -> str :
197+ if access == 1 :
198+ return "VEHICLE_PROPERTY_ACCESS_READ"
199+ elif access == 2 :
200+ return "VEHICLE_PROPERTY_ACCESS_WRITE"
201+ elif access == 3 :
202+ return "VEHICLE_PROPERTY_ACCESS_READ_WRITE"
203+ else :
204+ logging .error (f"Vehicle property access must be between 1 and 3, was { access } " )
205+ sys .exit (1 )
206+
150207
151208class VehiclePropertyChangeMode (Enum ):
152209 """
@@ -157,3 +214,23 @@ class VehiclePropertyChangeMode(Enum):
157214 STATIC = 0
158215 ON_CHANGE = 1
159216 CONTINUOUS = 2
217+
218+ def __str__ (self ) -> str :
219+ d = {
220+ VehiclePropertyChangeMode .STATIC : "VehiclePropertyChangeMode.STATIC" ,
221+ VehiclePropertyChangeMode .ON_CHANGE : "VehiclePropertyChangeMode.ON_CHANGE" ,
222+ VehiclePropertyChangeMode .CONTINUOUS : "VehiclePropertyChangeMode.CONTINUOUS" ,
223+ }
224+ return d .get (self , "VehiclePropertyChangeMode.STATIC" )
225+
226+ @staticmethod
227+ def get_java_doc (mode : int ) -> str :
228+ if mode == 0 :
229+ return "VEHICLE_PROPERTY_CHANGE_MODE_STATIC"
230+ elif mode == 1 :
231+ return "VEHICLE_PROPERTY_CHANGE_MODE_ONCHANGE"
232+ elif mode == 2 :
233+ return "VEHICLE_PROPERTY_CHANGE_MODE_CONTINUOUS"
234+ else :
235+ logging .error (f"Change mode must be between 0 and 2, was { mode } " )
236+ sys .exit (1 )
0 commit comments