Added support for automatic scripts (ie, autoScript)

This commit is contained in:
Jeff Parsons 2017-07-25 12:52:36 -07:00 • committed by Jeff Parsons
commit 30df38738c
34 changed files with 3895 additions and 3580 deletions

View file

@ -3412,7 +3412,7 @@ class Component {
* Component.processScript(idMachine, sScript)
*
* @param {string} idMachine
* @param {string} sScript
* @param {string} [sScript]
* @return {boolean}
*/
static processScript(idMachine, sScript)
@ -3497,7 +3497,7 @@ class Component {
}
if (!fSuccess) {
Component.alertUser("Script error: " + sCommand + (fnCommand? " failed" : " unrecognized"));
Component.alertUser("Script error: '" + sCommand + (fnCommand? " failed" : " unrecognized"));
break;
}
}
@ -20858,6 +20858,7 @@ class DriveController extends Component {
*
* autoMount: one or more JSON-encoded objects, each containing 'name' and 'path' properties
*
* @this {DriveController}
* @param {string} type
* @param {Object} parms
* @param {number} bitsMessage
@ -20900,10 +20901,10 @@ class DriveController extends Component {
this.irq = null;
this['exports'] = {
'bootDisk': this.bootSelectedDisk,
'loadDisk': this.loadSelectedDrive,
'selectDrive': this.selectDrive,
'wait': this.waitDrives
'bootDisk': this.bootSelectedDisk,
'loadDisk': this.loadSelectedDisk,
'selectDrive': this.selectDrive,
'wait': this.waitDrives
};
}
@ -20971,7 +20972,7 @@ class DriveController extends Component {
case "loadDisk":
this.bindings[sBinding] = control;
control.onclick = function onClickLoadDrive(event) {
dc.loadSelectedDrive();
dc.loadSelectedDisk();
};
return true;
@ -21058,7 +21059,7 @@ class DriveController extends Component {
if (file) {
var sDiskPath = file.name;
var sDiskName = Str.getBaseName(sDiskPath, true);
dc.loadSelectedDrive(sDiskName, sDiskPath, file);
dc.loadSelectedDisk(sDiskName, sDiskPath, file);
}
/*
* Prevent reloading of web page after form submission
@ -21320,7 +21321,7 @@ class DriveController extends Component {
drive.iHeadBoot = configDrive[i++];
drive.iSectorBoot = configDrive[i++];
drive.cbSectorBoot = configDrive[i++];
drive.status = configDrive[i++];
drive.status = configDrive[i];
/*
* The next group of properties are set by various controller command sequences.
@ -21500,7 +21501,7 @@ class DriveController extends Component {
}
/**
* loadSelectedDrive(sDiskName, sDiskPath, file)
* loadSelectedDisk(sDiskName, sDiskPath, file)
*
* @this {DriveController}
* @param {string} [sDiskName]
@ -21508,7 +21509,7 @@ class DriveController extends Component {
* @param {File} [file] is set if there's an associated File object
* @return {boolean}
*/
loadSelectedDrive(sDiskName, sDiskPath, file)
loadSelectedDisk(sDiskName, sDiskPath, file)
{
if (!sDiskName && !sDiskPath) {
var controlDisks = this.bindings["listDisks"];
@ -21613,7 +21614,7 @@ class DriveController extends Component {
this.unloadDrive(iDrive, true);
drive.fLocal = true;
var disk = new DiskPDP11(this, drive, DiskAPI.MODE.PRELOAD);
this.finishLoadDrive(drive, disk, sDiskName, sDiskPath, true);
this.doneLoadDrive(drive, disk, sDiskName, sDiskPath, true);
}
/**
@ -21652,7 +21653,7 @@ class DriveController extends Component {
}
drive.fLocal = !!file;
var disk = new DiskPDP11(this, drive, DiskAPI.MODE.PRELOAD);
if (disk.load(sDiskName, sDiskPath, file, this.finishLoadDrive)) {
if (disk.load(sDiskName, sDiskPath, file, this.doneLoadDrive)) {
nResult++;
}
}
@ -21661,7 +21662,7 @@ class DriveController extends Component {
}
/**
* finishLoadDrive(drive, disk, sDiskName, sDiskPath, fAutoMount)
* doneLoadDrive(drive, disk, sDiskName, sDiskPath, fAutoMount)
*
* The disk parameter is set if the disk was successfully loaded, null if not.
*
@ -21672,7 +21673,7 @@ class DriveController extends Component {
* @param {string} sDiskPath
* @param {boolean} [fAutoMount]
*/
finishLoadDrive(drive, disk, sDiskName, sDiskPath, fAutoMount)
doneLoadDrive(drive, disk, sDiskName, sDiskPath, fAutoMount)
{
drive.fBusy = false;
@ -32045,15 +32046,47 @@ function findMachineComponent(idMachine, sType)
}
/**
* processMachineScript(idMachine, sScript)
* commandMachine(control, fSingle, idMachine, sComponent, sCommand, sValue)
*
* Use Component methods to find the requested component for a specific machine, and if the component is found,
* then check its 'exports' table for an entry matching the specified command string, and if an entry is found, then
* the corresponding function is called with the specified data.
*
* @param {Object} control
* @param {boolean} fSingle
* @param {string} idMachine
* @param {string} sScript
* @param {string} sComponent
* @param {string} sCommand
* @param {string} [sValue]
* @return {boolean}
*/
function processMachineScript(idMachine, sScript)
function commandMachine(control, fSingle, idMachine, sComponent, sCommand, sValue)
{
return Component.processScript(idMachine, sScript);
if (sCommand == "script") {
if (Component.processScript(idMachine, sValue)) {
if (fSingle) control.disabled = true;
return true;
}
return false;
}
if (sComponent) {
var component = Component.getComponentByType(sComponent, idMachine + ".machine");
if (component) {
var exports = component['exports'];
if (exports) {
var fnCommand = exports[sCommand];
if (fnCommand) {
if (fnCommand.call(component, sValue)) {
if (fSingle) control.disabled = true;
return true;
}
return false;
}
}
}
}
console.log("unimplemented: commandMachine('" + idMachine + "','" + sComponent + "','" + sCommand + "','" + sValue + "')");
return false;
}
/**
@ -32077,8 +32110,7 @@ if (APPNAME == "PDPjs") {
window['embedPDP11'] = embedPDP11;
}
window['findMachineComponent'] = findMachineComponent;
window['processMachineScript'] = processMachineScript;
window['commandMachine'] = commandMachine;
window['enableEvents'] = Web.enablePageEvents;
window['sendEvent'] = Web.sendPageEvent;