Added support for (attempting to) suppress alerts that are meaningless if the user has aborted a machine by exiting the page before it was done loading

This commit is contained in:
Jeff Parsons 2017-06-22 15:53:34 -07:00 • committed by Jeff Parsons
commit 1ce03810d3
32 changed files with 1827 additions and 1591 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1543,6 +1543,8 @@ class Computer8080 extends Component {
var computer = /** @type {Computer8080} */ (Component.getComponentByType("Computer", parmsComputer['id']));
if (computer) {
computer.flags.unloading = false;
if (DEBUG && computer.messageEnabled()) {
computer.printMessage("onShow(" + computer.fInitialized + "," + computer.flags.powered + ")");
}
@ -1597,6 +1599,11 @@ class Computer8080 extends Component {
var computer = /** @type {Computer8080} */ (Component.getComponentByType("Computer", parmsComputer['id']));
if (computer) {
/*
* Added a new flag that Component functions (eg, notice()) should check before alerting the user.
*/
computer.flags.unloading = true;
if (DEBUG && computer.messageEnabled()) {
computer.printMessage("onExit(" + computer.flags.powered + ")");
}

View file

@ -1571,6 +1571,8 @@ class Computer extends Component {
var computer = /** @type {Computer} */ (Component.getComponentByType("Computer", parmsComputer['id']));
if (computer) {
computer.flags.unloading = false;
if (DEBUG && computer.messageEnabled()) {
computer.printMessage("onShow(" + computer.fInitialized + "," + computer.flags.powered + ")");
}
@ -1620,6 +1622,11 @@ class Computer extends Component {
var computer = /** @type {Computer} */ (Component.getComponentByType("Computer", parmsComputer['id']));
if (computer) {
/*
* Added a new flag that Component functions (eg, notice()) should check before alerting the user.
*/
computer.flags.unloading = true;
if (DEBUG && computer.messageEnabled()) {
computer.printMessage("onExit(" + computer.flags.powered + ")");
}

View file

@ -1539,6 +1539,8 @@ class ComputerPDP10 extends Component {
var computer = /** @type {ComputerPDP10} */ (Component.getComponentByType("Computer", parmsComputer['id']));
if (computer) {
computer.flags.unloading = false;
if (DEBUG && computer.messageEnabled()) {
computer.printMessage("onShow(" + computer.fInitialized + "," + computer.flags.powered + ")");
}
@ -1593,6 +1595,11 @@ class ComputerPDP10 extends Component {
var computer = /** @type {ComputerPDP10} */ (Component.getComponentByType("Computer", parmsComputer['id']));
if (computer) {
/*
* Added a new flag that Component functions (eg, notice()) should check before alerting the user.
*/
computer.flags.unloading = true;
if (DEBUG && computer.messageEnabled()) {
computer.printMessage("onExit(" + computer.flags.powered + ")");
}

View file

@ -1543,6 +1543,8 @@ class ComputerPDP11 extends Component {
var computer = /** @type {ComputerPDP11} */ (Component.getComponentByType("Computer", parmsComputer['id']));
if (computer) {
computer.flags.unloading = false;
if (DEBUG && computer.messageEnabled()) {
computer.printMessage("onShow(" + computer.fInitialized + "," + computer.flags.powered + ")");
}
@ -1597,6 +1599,11 @@ class ComputerPDP11 extends Component {
var computer = /** @type {ComputerPDP11} */ (Component.getComponentByType("Computer", parmsComputer['id']));
if (computer) {
/*
* Added a new flag that Component functions (eg, notice()) should check before alerting the user.
*/
computer.flags.unloading = true;
if (DEBUG && computer.messageEnabled()) {
computer.printMessage("onExit(" + computer.flags.powered + ")");
}

View file

@ -134,6 +134,7 @@ class Component {
busy: false,
busyCancel: false,
powered: false,
unloading: false,
error: false
};
@ -852,7 +853,8 @@ class Component {
* @this {Component}
* @return {string}
*/
toString() {
toString()
{
return (this.name? this.name : (this.id || this.type));
}
@ -862,7 +864,8 @@ class Component {
* @this {Component}
* @return {number} unique machine number
*/
getMachineNum() {
getMachineNum()
{
var nMachine = 1;
if (this.idMachine) {
var aDigits = this.idMachine.match(/\d+/);
@ -884,7 +887,8 @@ class Component {
* @param {string} [sValue] optional data value
* @return {boolean} true if binding was successful, false if unrecognized binding request
*/
setBinding(sHTMLType, sBinding, control, sValue) {
setBinding(sHTMLType, sBinding, control, sValue)
{
switch (sBinding) {
case "clear":
if (!this.bindings[sBinding]) {
@ -957,7 +961,8 @@ class Component {
* @param {string} [s] is the message text
* @param {string} [type] is the message type
*/
log(s, type) {
log(s, type)
{
if (!COMPILED) {
Component.log(s, type || this.id || this.type);
}
@ -978,7 +983,8 @@ class Component {
* @param {boolean|number} f is the expression asserted to be true
* @param {string} [s] is a description of the assertion to be displayed or logged on failure
*/
assert(f, s) {
assert(f, s)
{
if (DEBUG) {
if (!f) {
s = "assertion failure in " + (this.id || this.type) + (s? ": " + s : "");
@ -1025,7 +1031,8 @@ class Component {
* @param {string} [type] is the message type
* @param {string} [id] is the caller's ID, if any
*/
println(s, type, id) {
println(s, type, id)
{
Component.println(s, type, id || this.id);
}
@ -1037,7 +1044,8 @@ class Component {
*
* @param {string} s is the message text
*/
status(s) {
status(s)
{
this.println(this.idComponent + ": " + s);
}
@ -1053,7 +1061,18 @@ class Component {
* @param {boolean} [fPrintOnly]
* @param {string} [id] is the caller's ID, if any
*/
notice(s, fPrintOnly, id) {
notice(s, fPrintOnly, id)
{
if (!fPrintOnly) {
/*
* See if the associated computer, if any, is "unloading"....
*/
var computer = Component.getComponentByType("Computer", this.id);
if (computer && computer.flags.unloading) {
console.log("ignoring notice during unload: " + s);
return;
}
}
Component.notice(s, fPrintOnly, id || this.type);
}
@ -1065,7 +1084,8 @@ class Component {
* @this {Component}
* @param {string} s describes a fatal error condition
*/
setError(s) {
setError(s)
{
this.flags.error = true;
this.notice(s); // TODO: Any cases where we should still prefix this string with "Fatal error: "?
}
@ -1089,7 +1109,8 @@ class Component {
* @this {Component}
* @return {boolean} true if a fatal error condition exists, false if not
*/
isError() {
isError()
{
if (this.flags.error) {
this.println(this.toString() + " error");
return true;
@ -1110,7 +1131,8 @@ class Component {
* @param {function()} [fnReady]
* @return {boolean} true if the component is in a "ready" state, false if not
*/
isReady(fnReady) {
isReady(fnReady)
{
if (fnReady) {
if (this.flags.ready) {
fnReady();
@ -1130,7 +1152,8 @@ class Component {
* @this {Component}
* @param {boolean} [fReady] is assumed to indicate "ready" unless EXPLICITLY set to false
*/
setReady(fReady) {
setReady(fReady)
{
if (!this.flags.error) {
this.flags.ready = (fReady !== false);
if (this.flags.ready) {
@ -1151,7 +1174,8 @@ class Component {
* @param {boolean} [fCancel] is set to true to cancel a "busy" state
* @return {boolean} true if "busy", false if not
*/
isBusy(fCancel) {
isBusy(fCancel)
{
if (this.flags.busy) {
if (fCancel) {
this.flags.busyCancel = true;
@ -1171,7 +1195,8 @@ class Component {
* @param {boolean} fBusy
* @return {boolean}
*/
setBusy(fBusy) {
setBusy(fBusy)
{
if (this.flags.busyCancel) {
this.flags.busy = false;
this.flags.busyCancel = false;
@ -1193,7 +1218,8 @@ class Component {
* @param {boolean} [fRepower] is true if this is "repower" notification
* @return {boolean} true if successful, false if failure
*/
powerUp(data, fRepower) {
powerUp(data, fRepower)
{
this.flags.powered = true;
return true;
}
@ -1206,7 +1232,8 @@ class Component {
* @param {boolean} [fShutdown]
* @return {Object|boolean} component state if fSave; otherwise, true if successful, false if failure
*/
powerDown(fSave, fShutdown) {
powerDown(fSave, fShutdown)
{
if (fShutdown) this.flags.powered = false;
return true;
}
@ -1220,7 +1247,8 @@ class Component {
* @param {number} [bitsMessage] is zero or more MESSAGE_* category flag(s)
* @return {boolean} true if all specified message enabled, false if not
*/
messageEnabled(bitsMessage) {
messageEnabled(bitsMessage)
{
if (DEBUGGER && this.dbg) {
if (this === this.dbg) {
bitsMessage |= 0;
@ -1244,7 +1272,8 @@ class Component {
* @param {number|boolean} [bitsMessage] is zero or more MESSAGE_* category flag(s)
* @param {boolean} [fAddress] is true to display the current address
*/
printMessage(sMessage, bitsMessage, fAddress) {
printMessage(sMessage, bitsMessage, fAddress)
{
if (DEBUGGER && this.dbg) {
if (bitsMessage === true || this.messageEnabled(bitsMessage | 0)) {
this.dbg.message(sMessage, fAddress);
@ -1266,7 +1295,8 @@ class Component {
* @param {number|null} [bIn] is the input value, if known, on an input operation
* @param {number|boolean} [bitsMessage] is zero or more MESSAGE_* category flag(s)
*/
printMessageIO(port, bOut, addrFrom, name, bIn, bitsMessage) {
printMessageIO(port, bOut, addrFrom, name, bIn, bitsMessage)
{
if (DEBUGGER && this.dbg) {
if (bitsMessage === true) {
bitsMessage = 0;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -2203,6 +2203,7 @@ class Component {
busy: false,
busyCancel: false,
powered: false,
unloading: false,
error: false
};
@ -2921,7 +2922,8 @@ class Component {
* @this {Component}
* @return {string}
*/
toString() {
toString()
{
return (this.name? this.name : (this.id || this.type));
}
@ -2931,7 +2933,8 @@ class Component {
* @this {Component}
* @return {number} unique machine number
*/
getMachineNum() {
getMachineNum()
{
var nMachine = 1;
if (this.idMachine) {
var aDigits = this.idMachine.match(/\d+/);
@ -2953,7 +2956,8 @@ class Component {
* @param {string} [sValue] optional data value
* @return {boolean} true if binding was successful, false if unrecognized binding request
*/
setBinding(sHTMLType, sBinding, control, sValue) {
setBinding(sHTMLType, sBinding, control, sValue)
{
switch (sBinding) {
case "clear":
if (!this.bindings[sBinding]) {
@ -3026,7 +3030,8 @@ class Component {
* @param {string} [s] is the message text
* @param {string} [type] is the message type
*/
log(s, type) {
log(s, type)
{
if (!COMPILED) {
Component.log(s, type || this.id || this.type);
}
@ -3047,7 +3052,8 @@ class Component {
* @param {boolean|number} f is the expression asserted to be true
* @param {string} [s] is a description of the assertion to be displayed or logged on failure
*/
assert(f, s) {
assert(f, s)
{
if (DEBUG) {
if (!f) {
s = "assertion failure in " + (this.id || this.type) + (s? ": " + s : "");
@ -3094,7 +3100,8 @@ class Component {
* @param {string} [type] is the message type
* @param {string} [id] is the caller's ID, if any
*/
println(s, type, id) {
println(s, type, id)
{
Component.println(s, type, id || this.id);
}
@ -3106,7 +3113,8 @@ class Component {
*
* @param {string} s is the message text
*/
status(s) {
status(s)
{
this.println(this.idComponent + ": " + s);
}
@ -3122,7 +3130,18 @@ class Component {
* @param {boolean} [fPrintOnly]
* @param {string} [id] is the caller's ID, if any
*/
notice(s, fPrintOnly, id) {
notice(s, fPrintOnly, id)
{
if (!fPrintOnly) {
/*
* See if the associated computer, if any, is "unloading"....
*/
var computer = Component.getComponentByType("Computer", this.id);
if (computer && computer.flags.unloading) {
console.log("ignoring notice during unload: " + s);
return;
}
}
Component.notice(s, fPrintOnly, id || this.type);
}
@ -3134,7 +3153,8 @@ class Component {
* @this {Component}
* @param {string} s describes a fatal error condition
*/
setError(s) {
setError(s)
{
this.flags.error = true;
this.notice(s); // TODO: Any cases where we should still prefix this string with "Fatal error: "?
}
@ -3158,7 +3178,8 @@ class Component {
* @this {Component}
* @return {boolean} true if a fatal error condition exists, false if not
*/
isError() {
isError()
{
if (this.flags.error) {
this.println(this.toString() + " error");
return true;
@ -3179,7 +3200,8 @@ class Component {
* @param {function()} [fnReady]
* @return {boolean} true if the component is in a "ready" state, false if not
*/
isReady(fnReady) {
isReady(fnReady)
{
if (fnReady) {
if (this.flags.ready) {
fnReady();
@ -3199,7 +3221,8 @@ class Component {
* @this {Component}
* @param {boolean} [fReady] is assumed to indicate "ready" unless EXPLICITLY set to false
*/
setReady(fReady) {
setReady(fReady)
{
if (!this.flags.error) {
this.flags.ready = (fReady !== false);
if (this.flags.ready) {
@ -3220,7 +3243,8 @@ class Component {
* @param {boolean} [fCancel] is set to true to cancel a "busy" state
* @return {boolean} true if "busy", false if not
*/
isBusy(fCancel) {
isBusy(fCancel)
{
if (this.flags.busy) {
if (fCancel) {
this.flags.busyCancel = true;
@ -3240,7 +3264,8 @@ class Component {
* @param {boolean} fBusy
* @return {boolean}
*/
setBusy(fBusy) {
setBusy(fBusy)
{
if (this.flags.busyCancel) {
this.flags.busy = false;
this.flags.busyCancel = false;
@ -3262,7 +3287,8 @@ class Component {
* @param {boolean} [fRepower] is true if this is "repower" notification
* @return {boolean} true if successful, false if failure
*/
powerUp(data, fRepower) {
powerUp(data, fRepower)
{
this.flags.powered = true;
return true;
}
@ -3275,7 +3301,8 @@ class Component {
* @param {boolean} [fShutdown]
* @return {Object|boolean} component state if fSave; otherwise, true if successful, false if failure
*/
powerDown(fSave, fShutdown) {
powerDown(fSave, fShutdown)
{
if (fShutdown) this.flags.powered = false;
return true;
}
@ -3289,7 +3316,8 @@ class Component {
* @param {number} [bitsMessage] is zero or more MESSAGE_* category flag(s)
* @return {boolean} true if all specified message enabled, false if not
*/
messageEnabled(bitsMessage) {
messageEnabled(bitsMessage)
{
if (DEBUGGER && this.dbg) {
if (this === this.dbg) {
bitsMessage |= 0;
@ -3313,7 +3341,8 @@ class Component {
* @param {number|boolean} [bitsMessage] is zero or more MESSAGE_* category flag(s)
* @param {boolean} [fAddress] is true to display the current address
*/
printMessage(sMessage, bitsMessage, fAddress) {
printMessage(sMessage, bitsMessage, fAddress)
{
if (DEBUGGER && this.dbg) {
if (bitsMessage === true || this.messageEnabled(bitsMessage | 0)) {
this.dbg.message(sMessage, fAddress);
@ -3335,7 +3364,8 @@ class Component {
* @param {number|null} [bIn] is the input value, if known, on an input operation
* @param {number|boolean} [bitsMessage] is zero or more MESSAGE_* category flag(s)
*/
printMessageIO(port, bOut, addrFrom, name, bIn, bitsMessage) {
printMessageIO(port, bOut, addrFrom, name, bIn, bitsMessage)
{
if (DEBUGGER && this.dbg) {
if (bitsMessage === true) {
bitsMessage = 0;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -2493,6 +2493,7 @@ class Component {
busy: false,
busyCancel: false,
powered: false,
unloading: false,
error: false
};
@ -3211,7 +3212,8 @@ class Component {
* @this {Component}
* @return {string}
*/
toString() {
toString()
{
return (this.name? this.name : (this.id || this.type));
}
@ -3221,7 +3223,8 @@ class Component {
* @this {Component}
* @return {number} unique machine number
*/
getMachineNum() {
getMachineNum()
{
var nMachine = 1;
if (this.idMachine) {
var aDigits = this.idMachine.match(/\d+/);
@ -3243,7 +3246,8 @@ class Component {
* @param {string} [sValue] optional data value
* @return {boolean} true if binding was successful, false if unrecognized binding request
*/
setBinding(sHTMLType, sBinding, control, sValue) {
setBinding(sHTMLType, sBinding, control, sValue)
{
switch (sBinding) {
case "clear":
if (!this.bindings[sBinding]) {
@ -3316,7 +3320,8 @@ class Component {
* @param {string} [s] is the message text
* @param {string} [type] is the message type
*/
log(s, type) {
log(s, type)
{
if (!COMPILED) {
Component.log(s, type || this.id || this.type);
}
@ -3337,7 +3342,8 @@ class Component {
* @param {boolean|number} f is the expression asserted to be true
* @param {string} [s] is a description of the assertion to be displayed or logged on failure
*/
assert(f, s) {
assert(f, s)
{
if (DEBUG) {
if (!f) {
s = "assertion failure in " + (this.id || this.type) + (s? ": " + s : "");
@ -3384,7 +3390,8 @@ class Component {
* @param {string} [type] is the message type
* @param {string} [id] is the caller's ID, if any
*/
println(s, type, id) {
println(s, type, id)
{
Component.println(s, type, id || this.id);
}
@ -3396,7 +3403,8 @@ class Component {
*
* @param {string} s is the message text
*/
status(s) {
status(s)
{
this.println(this.idComponent + ": " + s);
}
@ -3412,7 +3420,18 @@ class Component {
* @param {boolean} [fPrintOnly]
* @param {string} [id] is the caller's ID, if any
*/
notice(s, fPrintOnly, id) {
notice(s, fPrintOnly, id)
{
if (!fPrintOnly) {
/*
* See if the associated computer, if any, is "unloading"....
*/
var computer = Component.getComponentByType("Computer", this.id);
if (computer && computer.flags.unloading) {
console.log("ignoring notice during unload: " + s);
return;
}
}
Component.notice(s, fPrintOnly, id || this.type);
}
@ -3424,7 +3443,8 @@ class Component {
* @this {Component}
* @param {string} s describes a fatal error condition
*/
setError(s) {
setError(s)
{
this.flags.error = true;
this.notice(s); // TODO: Any cases where we should still prefix this string with "Fatal error: "?
}
@ -3448,7 +3468,8 @@ class Component {
* @this {Component}
* @return {boolean} true if a fatal error condition exists, false if not
*/
isError() {
isError()
{
if (this.flags.error) {
this.println(this.toString() + " error");
return true;
@ -3469,7 +3490,8 @@ class Component {
* @param {function()} [fnReady]
* @return {boolean} true if the component is in a "ready" state, false if not
*/
isReady(fnReady) {
isReady(fnReady)
{
if (fnReady) {
if (this.flags.ready) {
fnReady();
@ -3489,7 +3511,8 @@ class Component {
* @this {Component}
* @param {boolean} [fReady] is assumed to indicate "ready" unless EXPLICITLY set to false
*/
setReady(fReady) {
setReady(fReady)
{
if (!this.flags.error) {
this.flags.ready = (fReady !== false);
if (this.flags.ready) {
@ -3510,7 +3533,8 @@ class Component {
* @param {boolean} [fCancel] is set to true to cancel a "busy" state
* @return {boolean} true if "busy", false if not
*/
isBusy(fCancel) {
isBusy(fCancel)
{
if (this.flags.busy) {
if (fCancel) {
this.flags.busyCancel = true;
@ -3530,7 +3554,8 @@ class Component {
* @param {boolean} fBusy
* @return {boolean}
*/
setBusy(fBusy) {
setBusy(fBusy)
{
if (this.flags.busyCancel) {
this.flags.busy = false;
this.flags.busyCancel = false;
@ -3552,7 +3577,8 @@ class Component {
* @param {boolean} [fRepower] is true if this is "repower" notification
* @return {boolean} true if successful, false if failure
*/
powerUp(data, fRepower) {
powerUp(data, fRepower)
{
this.flags.powered = true;
return true;
}
@ -3565,7 +3591,8 @@ class Component {
* @param {boolean} [fShutdown]
* @return {Object|boolean} component state if fSave; otherwise, true if successful, false if failure
*/
powerDown(fSave, fShutdown) {
powerDown(fSave, fShutdown)
{
if (fShutdown) this.flags.powered = false;
return true;
}
@ -3579,7 +3606,8 @@ class Component {
* @param {number} [bitsMessage] is zero or more MESSAGE_* category flag(s)
* @return {boolean} true if all specified message enabled, false if not
*/
messageEnabled(bitsMessage) {
messageEnabled(bitsMessage)
{
if (DEBUGGER && this.dbg) {
if (this === this.dbg) {
bitsMessage |= 0;
@ -3603,7 +3631,8 @@ class Component {
* @param {number|boolean} [bitsMessage] is zero or more MESSAGE_* category flag(s)
* @param {boolean} [fAddress] is true to display the current address
*/
printMessage(sMessage, bitsMessage, fAddress) {
printMessage(sMessage, bitsMessage, fAddress)
{
if (DEBUGGER && this.dbg) {
if (bitsMessage === true || this.messageEnabled(bitsMessage | 0)) {
this.dbg.message(sMessage, fAddress);
@ -3625,7 +3654,8 @@ class Component {
* @param {number|null} [bIn] is the input value, if known, on an input operation
* @param {number|boolean} [bitsMessage] is zero or more MESSAGE_* category flag(s)
*/
printMessageIO(port, bOut, addrFrom, name, bIn, bitsMessage) {
printMessageIO(port, bOut, addrFrom, name, bIn, bitsMessage)
{
if (DEBUGGER && this.dbg) {
if (bitsMessage === true) {
bitsMessage = 0;
@ -24201,6 +24231,8 @@ class Computer8080 extends Component {
var computer = /** @type {Computer8080} */ (Component.getComponentByType("Computer", parmsComputer['id']));
if (computer) {
computer.flags.unloading = false;
if (DEBUG && computer.messageEnabled()) {
computer.printMessage("onShow(" + computer.fInitialized + "," + computer.flags.powered + ")");
}
@ -24255,6 +24287,11 @@ class Computer8080 extends Component {
var computer = /** @type {Computer8080} */ (Component.getComponentByType("Computer", parmsComputer['id']));
if (computer) {
/*
* Added a new flag that Component functions (eg, notice()) should check before alerting the user.
*/
computer.flags.unloading = true;
if (DEBUG && computer.messageEnabled()) {
computer.printMessage("onExit(" + computer.flags.powered + ")");
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -2721,6 +2721,7 @@ class Component {
busy: false,
busyCancel: false,
powered: false,
unloading: false,
error: false
};
@ -3439,7 +3440,8 @@ class Component {
* @this {Component}
* @return {string}
*/
toString() {
toString()
{
return (this.name? this.name : (this.id || this.type));
}
@ -3449,7 +3451,8 @@ class Component {
* @this {Component}
* @return {number} unique machine number
*/
getMachineNum() {
getMachineNum()
{
var nMachine = 1;
if (this.idMachine) {
var aDigits = this.idMachine.match(/\d+/);
@ -3471,7 +3474,8 @@ class Component {
* @param {string} [sValue] optional data value
* @return {boolean} true if binding was successful, false if unrecognized binding request
*/
setBinding(sHTMLType, sBinding, control, sValue) {
setBinding(sHTMLType, sBinding, control, sValue)
{
switch (sBinding) {
case "clear":
if (!this.bindings[sBinding]) {
@ -3544,7 +3548,8 @@ class Component {
* @param {string} [s] is the message text
* @param {string} [type] is the message type
*/
log(s, type) {
log(s, type)
{
if (!COMPILED) {
Component.log(s, type || this.id || this.type);
}
@ -3565,7 +3570,8 @@ class Component {
* @param {boolean|number} f is the expression asserted to be true
* @param {string} [s] is a description of the assertion to be displayed or logged on failure
*/
assert(f, s) {
assert(f, s)
{
if (DEBUG) {
if (!f) {
s = "assertion failure in " + (this.id || this.type) + (s? ": " + s : "");
@ -3612,7 +3618,8 @@ class Component {
* @param {string} [type] is the message type
* @param {string} [id] is the caller's ID, if any
*/
println(s, type, id) {
println(s, type, id)
{
Component.println(s, type, id || this.id);
}
@ -3624,7 +3631,8 @@ class Component {
*
* @param {string} s is the message text
*/
status(s) {
status(s)
{
this.println(this.idComponent + ": " + s);
}
@ -3640,7 +3648,18 @@ class Component {
* @param {boolean} [fPrintOnly]
* @param {string} [id] is the caller's ID, if any
*/
notice(s, fPrintOnly, id) {
notice(s, fPrintOnly, id)
{
if (!fPrintOnly) {
/*
* See if the associated computer, if any, is "unloading"....
*/
var computer = Component.getComponentByType("Computer", this.id);
if (computer && computer.flags.unloading) {
console.log("ignoring notice during unload: " + s);
return;
}
}
Component.notice(s, fPrintOnly, id || this.type);
}
@ -3652,7 +3671,8 @@ class Component {
* @this {Component}
* @param {string} s describes a fatal error condition
*/
setError(s) {
setError(s)
{
this.flags.error = true;
this.notice(s); // TODO: Any cases where we should still prefix this string with "Fatal error: "?
}
@ -3676,7 +3696,8 @@ class Component {
* @this {Component}
* @return {boolean} true if a fatal error condition exists, false if not
*/
isError() {
isError()
{
if (this.flags.error) {
this.println(this.toString() + " error");
return true;
@ -3697,7 +3718,8 @@ class Component {
* @param {function()} [fnReady]
* @return {boolean} true if the component is in a "ready" state, false if not
*/
isReady(fnReady) {
isReady(fnReady)
{
if (fnReady) {
if (this.flags.ready) {
fnReady();
@ -3717,7 +3739,8 @@ class Component {
* @this {Component}
* @param {boolean} [fReady] is assumed to indicate "ready" unless EXPLICITLY set to false
*/
setReady(fReady) {
setReady(fReady)
{
if (!this.flags.error) {
this.flags.ready = (fReady !== false);
if (this.flags.ready) {
@ -3738,7 +3761,8 @@ class Component {
* @param {boolean} [fCancel] is set to true to cancel a "busy" state
* @return {boolean} true if "busy", false if not
*/
isBusy(fCancel) {
isBusy(fCancel)
{
if (this.flags.busy) {
if (fCancel) {
this.flags.busyCancel = true;
@ -3758,7 +3782,8 @@ class Component {
* @param {boolean} fBusy
* @return {boolean}
*/
setBusy(fBusy) {
setBusy(fBusy)
{
if (this.flags.busyCancel) {
this.flags.busy = false;
this.flags.busyCancel = false;
@ -3780,7 +3805,8 @@ class Component {
* @param {boolean} [fRepower] is true if this is "repower" notification
* @return {boolean} true if successful, false if failure
*/
powerUp(data, fRepower) {
powerUp(data, fRepower)
{
this.flags.powered = true;
return true;
}
@ -3793,7 +3819,8 @@ class Component {
* @param {boolean} [fShutdown]
* @return {Object|boolean} component state if fSave; otherwise, true if successful, false if failure
*/
powerDown(fSave, fShutdown) {
powerDown(fSave, fShutdown)
{
if (fShutdown) this.flags.powered = false;
return true;
}
@ -3807,7 +3834,8 @@ class Component {
* @param {number} [bitsMessage] is zero or more MESSAGE_* category flag(s)
* @return {boolean} true if all specified message enabled, false if not
*/
messageEnabled(bitsMessage) {
messageEnabled(bitsMessage)
{
if (DEBUGGER && this.dbg) {
if (this === this.dbg) {
bitsMessage |= 0;
@ -3831,7 +3859,8 @@ class Component {
* @param {number|boolean} [bitsMessage] is zero or more MESSAGE_* category flag(s)
* @param {boolean} [fAddress] is true to display the current address
*/
printMessage(sMessage, bitsMessage, fAddress) {
printMessage(sMessage, bitsMessage, fAddress)
{
if (DEBUGGER && this.dbg) {
if (bitsMessage === true || this.messageEnabled(bitsMessage | 0)) {
this.dbg.message(sMessage, fAddress);
@ -3853,7 +3882,8 @@ class Component {
* @param {number|null} [bIn] is the input value, if known, on an input operation
* @param {number|boolean} [bitsMessage] is zero or more MESSAGE_* category flag(s)
*/
printMessageIO(port, bOut, addrFrom, name, bIn, bitsMessage) {
printMessageIO(port, bOut, addrFrom, name, bIn, bitsMessage)
{
if (DEBUGGER && this.dbg) {
if (bitsMessage === true) {
bitsMessage = 0;
@ -75213,6 +75243,8 @@ class Computer extends Component {
var computer = /** @type {Computer} */ (Component.getComponentByType("Computer", parmsComputer['id']));
if (computer) {
computer.flags.unloading = false;
if (DEBUG && computer.messageEnabled()) {
computer.printMessage("onShow(" + computer.fInitialized + "," + computer.flags.powered + ")");
}
@ -75262,6 +75294,11 @@ class Computer extends Component {
var computer = /** @type {Computer} */ (Component.getComponentByType("Computer", parmsComputer['id']));
if (computer) {
/*
* Added a new flag that Component functions (eg, notice()) should check before alerting the user.
*/
computer.flags.unloading = true;
if (DEBUG && computer.messageEnabled()) {
computer.printMessage("onExit(" + computer.flags.powered + ")");
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -2493,6 +2493,7 @@ class Component {
busy: false,
busyCancel: false,
powered: false,
unloading: false,
error: false
};
@ -3211,7 +3212,8 @@ class Component {
* @this {Component}
* @return {string}
*/
toString() {
toString()
{
return (this.name? this.name : (this.id || this.type));
}
@ -3221,7 +3223,8 @@ class Component {
* @this {Component}
* @return {number} unique machine number
*/
getMachineNum() {
getMachineNum()
{
var nMachine = 1;
if (this.idMachine) {
var aDigits = this.idMachine.match(/\d+/);
@ -3243,7 +3246,8 @@ class Component {
* @param {string} [sValue] optional data value
* @return {boolean} true if binding was successful, false if unrecognized binding request
*/
setBinding(sHTMLType, sBinding, control, sValue) {
setBinding(sHTMLType, sBinding, control, sValue)
{
switch (sBinding) {
case "clear":
if (!this.bindings[sBinding]) {
@ -3316,7 +3320,8 @@ class Component {
* @param {string} [s] is the message text
* @param {string} [type] is the message type
*/
log(s, type) {
log(s, type)
{
if (!COMPILED) {
Component.log(s, type || this.id || this.type);
}
@ -3337,7 +3342,8 @@ class Component {
* @param {boolean|number} f is the expression asserted to be true
* @param {string} [s] is a description of the assertion to be displayed or logged on failure
*/
assert(f, s) {
assert(f, s)
{
if (DEBUG) {
if (!f) {
s = "assertion failure in " + (this.id || this.type) + (s? ": " + s : "");
@ -3384,7 +3390,8 @@ class Component {
* @param {string} [type] is the message type
* @param {string} [id] is the caller's ID, if any
*/
println(s, type, id) {
println(s, type, id)
{
Component.println(s, type, id || this.id);
}
@ -3396,7 +3403,8 @@ class Component {
*
* @param {string} s is the message text
*/
status(s) {
status(s)
{
this.println(this.idComponent + ": " + s);
}
@ -3412,7 +3420,18 @@ class Component {
* @param {boolean} [fPrintOnly]
* @param {string} [id] is the caller's ID, if any
*/
notice(s, fPrintOnly, id) {
notice(s, fPrintOnly, id)
{
if (!fPrintOnly) {
/*
* See if the associated computer, if any, is "unloading"....
*/
var computer = Component.getComponentByType("Computer", this.id);
if (computer && computer.flags.unloading) {
console.log("ignoring notice during unload: " + s);
return;
}
}
Component.notice(s, fPrintOnly, id || this.type);
}
@ -3424,7 +3443,8 @@ class Component {
* @this {Component}
* @param {string} s describes a fatal error condition
*/
setError(s) {
setError(s)
{
this.flags.error = true;
this.notice(s); // TODO: Any cases where we should still prefix this string with "Fatal error: "?
}
@ -3448,7 +3468,8 @@ class Component {
* @this {Component}
* @return {boolean} true if a fatal error condition exists, false if not
*/
isError() {
isError()
{
if (this.flags.error) {
this.println(this.toString() + " error");
return true;
@ -3469,7 +3490,8 @@ class Component {
* @param {function()} [fnReady]
* @return {boolean} true if the component is in a "ready" state, false if not
*/
isReady(fnReady) {
isReady(fnReady)
{
if (fnReady) {
if (this.flags.ready) {
fnReady();
@ -3489,7 +3511,8 @@ class Component {
* @this {Component}
* @param {boolean} [fReady] is assumed to indicate "ready" unless EXPLICITLY set to false
*/
setReady(fReady) {
setReady(fReady)
{
if (!this.flags.error) {
this.flags.ready = (fReady !== false);
if (this.flags.ready) {
@ -3510,7 +3533,8 @@ class Component {
* @param {boolean} [fCancel] is set to true to cancel a "busy" state
* @return {boolean} true if "busy", false if not
*/
isBusy(fCancel) {
isBusy(fCancel)
{
if (this.flags.busy) {
if (fCancel) {
this.flags.busyCancel = true;
@ -3530,7 +3554,8 @@ class Component {
* @param {boolean} fBusy
* @return {boolean}
*/
setBusy(fBusy) {
setBusy(fBusy)
{
if (this.flags.busyCancel) {
this.flags.busy = false;
this.flags.busyCancel = false;
@ -3552,7 +3577,8 @@ class Component {
* @param {boolean} [fRepower] is true if this is "repower" notification
* @return {boolean} true if successful, false if failure
*/
powerUp(data, fRepower) {
powerUp(data, fRepower)
{
this.flags.powered = true;
return true;
}
@ -3565,7 +3591,8 @@ class Component {
* @param {boolean} [fShutdown]
* @return {Object|boolean} component state if fSave; otherwise, true if successful, false if failure
*/
powerDown(fSave, fShutdown) {
powerDown(fSave, fShutdown)
{
if (fShutdown) this.flags.powered = false;
return true;
}
@ -3579,7 +3606,8 @@ class Component {
* @param {number} [bitsMessage] is zero or more MESSAGE_* category flag(s)
* @return {boolean} true if all specified message enabled, false if not
*/
messageEnabled(bitsMessage) {
messageEnabled(bitsMessage)
{
if (DEBUGGER && this.dbg) {
if (this === this.dbg) {
bitsMessage |= 0;
@ -3603,7 +3631,8 @@ class Component {
* @param {number|boolean} [bitsMessage] is zero or more MESSAGE_* category flag(s)
* @param {boolean} [fAddress] is true to display the current address
*/
printMessage(sMessage, bitsMessage, fAddress) {
printMessage(sMessage, bitsMessage, fAddress)
{
if (DEBUGGER && this.dbg) {
if (bitsMessage === true || this.messageEnabled(bitsMessage | 0)) {
this.dbg.message(sMessage, fAddress);
@ -3625,7 +3654,8 @@ class Component {
* @param {number|null} [bIn] is the input value, if known, on an input operation
* @param {number|boolean} [bitsMessage] is zero or more MESSAGE_* category flag(s)
*/
printMessageIO(port, bOut, addrFrom, name, bIn, bitsMessage) {
printMessageIO(port, bOut, addrFrom, name, bIn, bitsMessage)
{
if (DEBUGGER && this.dbg) {
if (bitsMessage === true) {
bitsMessage = 0;
@ -26900,6 +26930,8 @@ class ComputerPDP10 extends Component {
var computer = /** @type {ComputerPDP10} */ (Component.getComponentByType("Computer", parmsComputer['id']));
if (computer) {
computer.flags.unloading = false;
if (DEBUG && computer.messageEnabled()) {
computer.printMessage("onShow(" + computer.fInitialized + "," + computer.flags.powered + ")");
}
@ -26954,6 +26986,11 @@ class ComputerPDP10 extends Component {
var computer = /** @type {ComputerPDP10} */ (Component.getComponentByType("Computer", parmsComputer['id']));
if (computer) {
/*
* Added a new flag that Component functions (eg, notice()) should check before alerting the user.
*/
computer.flags.unloading = true;
if (DEBUG && computer.messageEnabled()) {
computer.printMessage("onExit(" + computer.flags.powered + ")");
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -2721,6 +2721,7 @@ class Component {
busy: false,
busyCancel: false,
powered: false,
unloading: false,
error: false
};
@ -3439,7 +3440,8 @@ class Component {
* @this {Component}
* @return {string}
*/
toString() {
toString()
{
return (this.name? this.name : (this.id || this.type));
}
@ -3449,7 +3451,8 @@ class Component {
* @this {Component}
* @return {number} unique machine number
*/
getMachineNum() {
getMachineNum()
{
var nMachine = 1;
if (this.idMachine) {
var aDigits = this.idMachine.match(/\d+/);
@ -3471,7 +3474,8 @@ class Component {
* @param {string} [sValue] optional data value
* @return {boolean} true if binding was successful, false if unrecognized binding request
*/
setBinding(sHTMLType, sBinding, control, sValue) {
setBinding(sHTMLType, sBinding, control, sValue)
{
switch (sBinding) {
case "clear":
if (!this.bindings[sBinding]) {
@ -3544,7 +3548,8 @@ class Component {
* @param {string} [s] is the message text
* @param {string} [type] is the message type
*/
log(s, type) {
log(s, type)
{
if (!COMPILED) {
Component.log(s, type || this.id || this.type);
}
@ -3565,7 +3570,8 @@ class Component {
* @param {boolean|number} f is the expression asserted to be true
* @param {string} [s] is a description of the assertion to be displayed or logged on failure
*/
assert(f, s) {
assert(f, s)
{
if (DEBUG) {
if (!f) {
s = "assertion failure in " + (this.id || this.type) + (s? ": " + s : "");
@ -3612,7 +3618,8 @@ class Component {
* @param {string} [type] is the message type
* @param {string} [id] is the caller's ID, if any
*/
println(s, type, id) {
println(s, type, id)
{
Component.println(s, type, id || this.id);
}
@ -3624,7 +3631,8 @@ class Component {
*
* @param {string} s is the message text
*/
status(s) {
status(s)
{
this.println(this.idComponent + ": " + s);
}
@ -3640,7 +3648,18 @@ class Component {
* @param {boolean} [fPrintOnly]
* @param {string} [id] is the caller's ID, if any
*/
notice(s, fPrintOnly, id) {
notice(s, fPrintOnly, id)
{
if (!fPrintOnly) {
/*
* See if the associated computer, if any, is "unloading"....
*/
var computer = Component.getComponentByType("Computer", this.id);
if (computer && computer.flags.unloading) {
console.log("ignoring notice during unload: " + s);
return;
}
}
Component.notice(s, fPrintOnly, id || this.type);
}
@ -3652,7 +3671,8 @@ class Component {
* @this {Component}
* @param {string} s describes a fatal error condition
*/
setError(s) {
setError(s)
{
this.flags.error = true;
this.notice(s); // TODO: Any cases where we should still prefix this string with "Fatal error: "?
}
@ -3676,7 +3696,8 @@ class Component {
* @this {Component}
* @return {boolean} true if a fatal error condition exists, false if not
*/
isError() {
isError()
{
if (this.flags.error) {
this.println(this.toString() + " error");
return true;
@ -3697,7 +3718,8 @@ class Component {
* @param {function()} [fnReady]
* @return {boolean} true if the component is in a "ready" state, false if not
*/
isReady(fnReady) {
isReady(fnReady)
{
if (fnReady) {
if (this.flags.ready) {
fnReady();
@ -3717,7 +3739,8 @@ class Component {
* @this {Component}
* @param {boolean} [fReady] is assumed to indicate "ready" unless EXPLICITLY set to false
*/
setReady(fReady) {
setReady(fReady)
{
if (!this.flags.error) {
this.flags.ready = (fReady !== false);
if (this.flags.ready) {
@ -3738,7 +3761,8 @@ class Component {
* @param {boolean} [fCancel] is set to true to cancel a "busy" state
* @return {boolean} true if "busy", false if not
*/
isBusy(fCancel) {
isBusy(fCancel)
{
if (this.flags.busy) {
if (fCancel) {
this.flags.busyCancel = true;
@ -3758,7 +3782,8 @@ class Component {
* @param {boolean} fBusy
* @return {boolean}
*/
setBusy(fBusy) {
setBusy(fBusy)
{
if (this.flags.busyCancel) {
this.flags.busy = false;
this.flags.busyCancel = false;
@ -3780,7 +3805,8 @@ class Component {
* @param {boolean} [fRepower] is true if this is "repower" notification
* @return {boolean} true if successful, false if failure
*/
powerUp(data, fRepower) {
powerUp(data, fRepower)
{
this.flags.powered = true;
return true;
}
@ -3793,7 +3819,8 @@ class Component {
* @param {boolean} [fShutdown]
* @return {Object|boolean} component state if fSave; otherwise, true if successful, false if failure
*/
powerDown(fSave, fShutdown) {
powerDown(fSave, fShutdown)
{
if (fShutdown) this.flags.powered = false;
return true;
}
@ -3807,7 +3834,8 @@ class Component {
* @param {number} [bitsMessage] is zero or more MESSAGE_* category flag(s)
* @return {boolean} true if all specified message enabled, false if not
*/
messageEnabled(bitsMessage) {
messageEnabled(bitsMessage)
{
if (DEBUGGER && this.dbg) {
if (this === this.dbg) {
bitsMessage |= 0;
@ -3831,7 +3859,8 @@ class Component {
* @param {number|boolean} [bitsMessage] is zero or more MESSAGE_* category flag(s)
* @param {boolean} [fAddress] is true to display the current address
*/
printMessage(sMessage, bitsMessage, fAddress) {
printMessage(sMessage, bitsMessage, fAddress)
{
if (DEBUGGER && this.dbg) {
if (bitsMessage === true || this.messageEnabled(bitsMessage | 0)) {
this.dbg.message(sMessage, fAddress);
@ -3853,7 +3882,8 @@ class Component {
* @param {number|null} [bIn] is the input value, if known, on an input operation
* @param {number|boolean} [bitsMessage] is zero or more MESSAGE_* category flag(s)
*/
printMessageIO(port, bOut, addrFrom, name, bIn, bitsMessage) {
printMessageIO(port, bOut, addrFrom, name, bIn, bitsMessage)
{
if (DEBUGGER && this.dbg) {
if (bitsMessage === true) {
bitsMessage = 0;
@ -30777,6 +30807,8 @@ class ComputerPDP11 extends Component {
var computer = /** @type {ComputerPDP11} */ (Component.getComponentByType("Computer", parmsComputer['id']));
if (computer) {
computer.flags.unloading = false;
if (DEBUG && computer.messageEnabled()) {
computer.printMessage("onShow(" + computer.fInitialized + "," + computer.flags.powered + ")");
}
@ -30831,6 +30863,11 @@ class ComputerPDP11 extends Component {
var computer = /** @type {ComputerPDP11} */ (Component.getComponentByType("Computer", parmsComputer['id']));
if (computer) {
/*
* Added a new flag that Component functions (eg, notice()) should check before alerting the user.
*/
computer.flags.unloading = true;
if (DEBUG && computer.messageEnabled()) {
computer.printMessage("onExit(" + computer.flags.powered + ")");
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long