TODO: updated cabana to persist dbcs for routes and added an option to pass custom dbcs through the retropilot configuration
parent
64b3281d7e
commit
1214b91eb4
|
@ -1,5 +1,7 @@
|
||||||
import Moment from 'moment';
|
import Moment from 'moment';
|
||||||
import CorollaDBC from './corolla-dbc';
|
import CorollaDBC from './corolla-dbc';
|
||||||
|
import DBC from './models/can/dbc';
|
||||||
|
import { fetchPersistedDbc } from './api/localstorage';
|
||||||
|
|
||||||
export async function loadRetropilotDrive(retropilotHost, driveIdentifier, seekTime) {
|
export async function loadRetropilotDrive(retropilotHost, driveIdentifier, seekTime) {
|
||||||
if (driveIdentifier == null || !driveIdentifier.length) {
|
if (driveIdentifier == null || !driveIdentifier.length) {
|
||||||
|
@ -20,6 +22,8 @@ export async function loadRetropilotDrive(retropilotHost, driveIdentifier, seekT
|
||||||
}
|
}
|
||||||
global.retropilotLogUrls = retropilotDrive.logUrls;
|
global.retropilotLogUrls = retropilotDrive.logUrls;
|
||||||
|
|
||||||
|
const dbcObj = retropilotDrive.dbc && retropilotDrive.dbc.length > 0 ? new DBC(retropilotDrive.dbc) : CorollaDBC;
|
||||||
|
|
||||||
global.retropilotProps = {
|
global.retropilotProps = {
|
||||||
autoplay: true,
|
autoplay: true,
|
||||||
startTime: seekTime,
|
startTime: seekTime,
|
||||||
|
@ -28,16 +32,26 @@ export async function loadRetropilotDrive(retropilotHost, driveIdentifier, seekT
|
||||||
max: global.retropilotLogUrls.length,
|
max: global.retropilotLogUrls.length,
|
||||||
name: retropilotDrive.driveIdentifier,
|
name: retropilotDrive.driveIdentifier,
|
||||||
dongleId: retropilotDrive.dongleId,
|
dongleId: retropilotDrive.dongleId,
|
||||||
dbc: CorollaDBC,
|
dbc: dbcObj,
|
||||||
dbcFilename: 'toyota_nodsu_pt_generated.dbc'
|
dbcFilename: retropilotDrive.dbcFilename || 'toyota_nodsu_pt_generated.dbc',
|
||||||
};
|
};
|
||||||
|
|
||||||
global.retropilotRoute = {
|
global.retropilotRoute = {
|
||||||
fullname: retropilotDrive.name,
|
fullname: retropilotDrive.name,
|
||||||
proclog: global.retropilotProps.max,
|
proclog: global.retropilotProps.max,
|
||||||
start_time: Moment(global.retropilotProps.name, 'YYYY-MM-DD--H-m-s'),
|
start_time: Moment(global.retropilotProps.name, 'YYYY-MM-DD--H-m-s'),
|
||||||
url: retropilotDrive.driveUrl
|
url: retropilotDrive.driveUrl,
|
||||||
};
|
};
|
||||||
|
|
||||||
global.retropilotLoaded = global.retropilotProps.max > 0;
|
if (global.retropilotProps.max > 0) {
|
||||||
|
const persistedDbc = fetchPersistedDbc(global.retropilotRoute.fullname);
|
||||||
|
if (persistedDbc) {
|
||||||
|
const { dbcFilename, dbc } = persistedDbc;
|
||||||
|
global.retropilotProps.dbc = dbc;
|
||||||
|
global.retropilotProps.dbcFilename = dbcFilename;
|
||||||
|
}
|
||||||
|
global.retropilotLoaded = true;
|
||||||
|
} else {
|
||||||
|
global.retropilotLoaded = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue