public async Task <TelemetrySet> ParseTelemetrySessionAsync(IDictionary <object, object> telemetryValues) { var set = new TelemetrySet(); await UpdateTelemetrySessionAsync(telemetryValues, set); return(set); }
public async Task UpdateTelemetrySessionAsync(IDictionary <object, object> telemetryValues, TelemetrySet telemetryInstance) { await Task.Run(() => { FormatExceptions = new List <FormatExceptionError>(); UnhandledDataTypes = new List <UnhandledDataTypeError>(); BuildSanitizeMaps(); // WeekendInfo IDictionary <object, object> weekendInfoValues = (IDictionary <object, object>)telemetryValues["WeekendInfo"]; SetValues(telemetryInstance.WeekendInfo, weekendInfoValues); // WeekendInfo.WeekendOptions IDictionary <object, object> weekendOptionsValues = (IDictionary <object, object>)weekendInfoValues["WeekendOptions"]; SetValues(telemetryInstance.WeekendInfo.WeekendOptions, weekendOptionsValues); // SessionInfo IDictionary <object, object> sessionInfoValues = (IDictionary <object, object>)telemetryValues["SessionInfo"]; var sessionList = (IList <object>)sessionInfoValues["Sessions"]; foreach (IDictionary <object, object> sessionItemValues in sessionList) { var sessionInstance = new Session(); SetValues(sessionInstance, sessionItemValues); var resultsPositionList = (IList <object>)sessionItemValues["ResultsPositions"]; if (resultsPositionList != null) { foreach (IDictionary <object, object> resultsPositionValues in resultsPositionList) { var resultsPositionsInstance = new ResultsPosition(); SetValues(resultsPositionsInstance, resultsPositionValues); sessionInstance.ResultsPositions.Add(resultsPositionsInstance); } } var resultsFastestLapList = (IList <object>)sessionItemValues["ResultsFastestLap"]; foreach (IDictionary <object, object> resultsFastestLapValues in resultsFastestLapList) { var resultsFastestLapInstance = new ResultsFastestLap(); SetValues(resultsFastestLapInstance, resultsFastestLapValues); sessionInstance.ResultsFastestLap.Add(resultsFastestLapInstance); } telemetryInstance.SessionInfo.Sessions.Add(sessionInstance); } // DriverInfo IDictionary <object, object> driverInfoValues = (IDictionary <object, object>)telemetryValues["DriverInfo"]; SetValues(telemetryInstance.DriverInfo, driverInfoValues); var driverList = (IList <object>)driverInfoValues["Drivers"]; foreach (IDictionary <object, object> driverValues in driverList) { var driverInstance = new Driver(); SetValues(driverInstance, driverValues); telemetryInstance.DriverInfo.Drivers.Add(driverInstance); } // SplitTimeInfo var splitTimeInfoValues = (IDictionary <object, object>)telemetryValues["SplitTimeInfo"]; var sectorList = (IList <object>)splitTimeInfoValues["Sectors"]; foreach (IDictionary <object, object> values in sectorList) { var instance = new Sector(); SetValues(instance, values); telemetryInstance.SplitTimeInfo.Sectors.Add(instance); } // CarSetup (sk modified) var setupValues = (IDictionary <object, object>)telemetryValues["CarSetup"]; telemetryInstance.CarSetup.UpdateCount = int.Parse(setupValues["UpdateCount"].ToString()); var tiresValues = (IDictionary <object, object>)setupValues["Tires"]; SetValues(telemetryInstance.CarSetup.Tires.LeftFront, (IDictionary <object, object>)tiresValues["LeftFront"]); SetValues(telemetryInstance.CarSetup.Tires.LeftRear, (IDictionary <object, object>)tiresValues["LeftRear"]); SetValues(telemetryInstance.CarSetup.Tires.RightFront, (IDictionary <object, object>)tiresValues["RightFront"]); SetValues(telemetryInstance.CarSetup.Tires.RightRear, (IDictionary <object, object>)tiresValues["RightRear"]); var chassisValues = (IDictionary <object, object>)setupValues["Chassis"]; SetValues(telemetryInstance.CarSetup.Chassis.Front, (IDictionary <object, object>)chassisValues["Front"]); SetValues(telemetryInstance.CarSetup.Chassis.LeftFront, (IDictionary <object, object>)chassisValues["LeftFront"]); SetValues(telemetryInstance.CarSetup.Chassis.LeftRear, (IDictionary <object, object>)chassisValues["LeftRear"]); SetValues(telemetryInstance.CarSetup.Chassis.RightFront, (IDictionary <object, object>)chassisValues["RightFront"]); SetValues(telemetryInstance.CarSetup.Chassis.RightRear, (IDictionary <object, object>)chassisValues["RightRear"]); SetValues(telemetryInstance.CarSetup.Chassis.Rear, (IDictionary <object, object>)chassisValues["Rear"]); }); DisplayErrors(); }
public async Task <IList <IFieldDefinition> > BuildFieldDefinitionListAsync(IDictionary <object, object> telemetryValues) { SessionFieldDefinitions = new List <IFieldDefinition>(); var telemetryInstance = new TelemetrySet(); await Task.Run(() => { FormatExceptions = new List <FormatExceptionError>(); UnhandledDataTypes = new List <UnhandledDataTypeError>(); BuildSanitizeMaps(); // WeekendInfo IDictionary <object, object> weekendInfoValues = (IDictionary <object, object>)telemetryValues["WeekendInfo"]; CreateFieldDefinitions("WeekendInfo", telemetryInstance.WeekendInfo, weekendInfoValues); // WeekendInfo.WeekendOptions IDictionary <object, object> weekendOptionsValues = (IDictionary <object, object>)weekendInfoValues["WeekendOptions"]; CreateFieldDefinitions("WeekendInfo.WeekendOptions", telemetryInstance.WeekendInfo.WeekendOptions, weekendOptionsValues); // SessionInfo IDictionary <object, object> sessionInfoValues = (IDictionary <object, object>)telemetryValues["SessionInfo"]; var sessionList = (IList <object>)sessionInfoValues["Sessions"]; foreach (IDictionary <object, object> sessionItemValues in sessionList) { var sessionInstance = new Session(); CreateFieldDefinitions("SessionInfo.Sessions[]", sessionInstance, sessionItemValues); var resultsPositionList = (IList <object>)sessionItemValues["ResultsPositions"]; if (resultsPositionList != null) { foreach (IDictionary <object, object> resultsPositionValues in resultsPositionList) { var resultsPositionsInstance = new ResultsPosition(); CreateFieldDefinitions("SessionInfo.Sessions[].ResultsPositions[]", resultsPositionsInstance, resultsPositionValues); sessionInstance.ResultsPositions.Add(resultsPositionsInstance); } } var resultsFastestLapList = (IList <object>)sessionItemValues["ResultsFastestLap"]; foreach (IDictionary <object, object> resultsFastestLapValues in resultsFastestLapList) { var resultsFastestLapInstance = new ResultsFastestLap(); CreateFieldDefinitions("SessionInfo.Sessions[].ResultsFastestLap[]", resultsFastestLapInstance, resultsFastestLapValues); sessionInstance.ResultsFastestLap.Add(resultsFastestLapInstance); } telemetryInstance.SessionInfo.Sessions.Add(sessionInstance); } // DriverInfo IDictionary <object, object> driverInfoValues = (IDictionary <object, object>)telemetryValues["DriverInfo"]; CreateFieldDefinitions("DriverInfo", telemetryInstance.DriverInfo, driverInfoValues); var driverList = (IList <object>)driverInfoValues["Drivers"]; foreach (IDictionary <object, object> driverValues in driverList) { var driverInstance = new Driver(); CreateFieldDefinitions("DriverInfo.Drivers[]", driverInstance, driverValues); telemetryInstance.DriverInfo.Drivers.Add(driverInstance); } // SplitTimeInfo var splitTimeInfoValues = (IDictionary <object, object>)telemetryValues["SplitTimeInfo"]; var sectorList = (IList <object>)splitTimeInfoValues["Sectors"]; foreach (IDictionary <object, object> values in sectorList) { var instance = new Sector(); CreateFieldDefinitions("SplitTimeInfo.Sectors[]", instance, values); telemetryInstance.SplitTimeInfo.Sectors.Add(instance); } // CarSetup (sk modified) var setupValues = (IDictionary <object, object>)telemetryValues["CarSetup"]; CreateFieldDefinitions("CarSetup", telemetryInstance.CarSetup, (IDictionary <object, object>)telemetryValues["CarSetup"]); var tiresValues = (IDictionary <object, object>)setupValues["Tires"]; CreateFieldDefinitions("CarSetup.Tires.LeftFront", telemetryInstance.CarSetup.Tires.LeftFront, (IDictionary <object, object>)tiresValues["LeftFront"]); CreateFieldDefinitions("CarSetup.Tires.LeftRear", telemetryInstance.CarSetup.Tires.LeftRear, (IDictionary <object, object>)tiresValues["LeftRear"]); CreateFieldDefinitions("CarSetup.Tires.RightFront", telemetryInstance.CarSetup.Tires.RightFront, (IDictionary <object, object>)tiresValues["RightFront"]); CreateFieldDefinitions("CarSetup.Tires.RightRear", telemetryInstance.CarSetup.Tires.RightRear, (IDictionary <object, object>)tiresValues["RightRear"]); var chassisValues = (IDictionary <object, object>)setupValues["Chassis"]; CreateFieldDefinitions("CarSetup.Chassis.Front", telemetryInstance.CarSetup.Chassis.Front, (IDictionary <object, object>)chassisValues["Front"]); CreateFieldDefinitions("CarSetup.Tires.LeftFront", telemetryInstance.CarSetup.Chassis.LeftFront, (IDictionary <object, object>)chassisValues["LeftFront"]); CreateFieldDefinitions("CarSetup.Chassis.LeftRear", telemetryInstance.CarSetup.Chassis.LeftRear, (IDictionary <object, object>)chassisValues["LeftRear"]); CreateFieldDefinitions("CarSetup.Chassis.RightFront", telemetryInstance.CarSetup.Chassis.RightFront, (IDictionary <object, object>)chassisValues["RightFront"]); CreateFieldDefinitions("CarSetup.Chassis.RightRear", telemetryInstance.CarSetup.Chassis.RightRear, (IDictionary <object, object>)chassisValues["RightRear"]); CreateFieldDefinitions("CarSetup.Tires.Rear", telemetryInstance.CarSetup.Chassis.Rear, (IDictionary <object, object>)chassisValues["Rear"]); }); DisplayErrors(); return(SessionFieldDefinitions); }