awv3
Version:
⚡ AWV3 embedded CAD
52 lines (41 loc) • 1.49 kB
JavaScript
import Events from '../core/events';
import v4 from 'uuid-v4';
export default class extends Events {
constructor(options = {}) {
super();
if (options !== false) {
this.id = v4();
this.alive = false;
this.options = options;
this.socket = undefined;
this.tasks = new Map();
this.url = undefined;
}
}
execute(task, factory) {
return this.request({ command: 'Execute', task }, factory);
}
result(task, factory) {
return this.request({ command: 'Execute', task: 'RETURN ' + task }, factory).then(context => context.results);
}
setVerboseLevel(level) {
return this.request({ command: 'Execute', task: 'CADH_SetVerboseLevel(' + (level || 16391) + ');' });
}
log() {
return this
.request({ command: 'Execute', task: 'RETURN CADH_GetVerboseFileContent();' })
.then(context => context.firstResult);
}
resetLog() {
return this.request({ command: 'Execute', task: 'CADH_ResetVerboseFile();' });
}
getState() {
return this.request({ command: 'StoreState' }).then(context => context.firstResult);
}
setState(data, updateGraphics = false) {
return this.request({ command: 'LoadState', data, recalc: false, updateGraphics });
}
recalc() {
return this.request({ command: 'Execute', task: '_C.GlobaleFunktionen.UseOnStartRecalc(_O);' });
}
}