Accessing the VarHeader information. #46
byteinsight
started this conversation in
General
Replies: 3 comments
-
with open('vars.txt', 'w') as f:
headers = ir._var_headers_dict
f.write('\n'.join([
'{0:34}{1.desc}, {1.unit}'.format(k, headers[k]).strip()
for k in sorted(headers.keys(), key=str.lower)
])) |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Thanks :) |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Morning Kutu, Thank you for your code snippet. I have been able to use it to access the details regarding the 'race' variables. This is the current output. sdk_vars.json My next question is "Do we have access to the same information for WeekendInfo etc.?" Thanks as always. Chris :) def get_the_vars(self):
self.check_sim_connection()
if self.state.ir_connected:
# This is so we get consistent data from inside that tick
# and the data isn't updated by apis inbetween calls.
self.ir.freeze_var_buffer_latest()
print(f"Getting the SDK Vars from Session ID: {self.ir['WeekendInfo']['SessionID']}")
race_vars = {}
var_headers = self.ir._var_headers_dict
for k, v in var_headers.items():
race_vars[k] = {'desc': v.desc, 'unit': v.unit}
sdk_dictionary = {
'RaceVars': race_vars,
'WeekendInfo': self.get_dict_keys(self.ir['WeekendInfo']),
'SessionInfo': self.get_dict_keys(self.ir['SessionInfo']),
'QualifyResultsInfo': self.get_dict_keys(self.ir['QualifyResultsInfo']),
'CameraInfo': self.get_dict_keys(self.ir['CameraInfo']),
'RadioInfo': self.get_dict_keys(self.ir['RadioInfo']),
'DriverInfo': self.get_dict_keys(self.ir['DriverInfo']),
'SplitTimeInfo': self.get_dict_keys(self.ir['SplitTimeInfo']),
}
json_file_name = os.path.join(self.config.get('root_path', ""), "static", "data", "sdk_vars.json")
with open(json_file_name, 'w') as fp:
json.dump(sdk_dictionary, fp, indent=4)get_dict_keys looks like: def get_dict_keys(self, current_dict):
key_dict = {}
if current_dict:
for key, value in current_dict.items():
if isinstance(value, dict):
sub_key_dict = self.get_dict_keys(value)
key_dict[key] = sub_key_dict
elif isinstance(value, list):
sub_key_dict = self.get_dict_keys(value[0])
key_dict[key] = sub_key_dict
else:
key_dict[key] = ""
return key_dict |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
Please can you explain how I can access the VarHeader information. I'd like to be able to automatically generate an output like the telemetry_11_23_15.pdf thats available on the iRacing forum but with all the available vars including those in the SessionInfo blocks.
I already have a recusive dictionary function that outputs to json but without the types, units and descriptions. Is this something thats possible?
Thanks Chris
Beta Was this translation helpful? Give feedback.
All reactions