Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
/*
* Copyright (C) 2021 Sienci Labs Inc.
*
* This file is part of gSender.
*
* gSender is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, under version 3 of the License.
*
* gSender is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gSender. If not, see <https://www.gnu.org/licenses/>.
*
* Contact for information regarding this program and its license
* can be sent through gSender@sienci.com or mailed to the main office
* of Sienci Labs Inc. in Waterloo, Ontario, Canada.
*
*/
import events from "events";
// Workflow State
export const WORKFLOW_STATE_RUNNING = "running";
export const WORKFLOW_STATE_PAUSED = "paused";
export const WORKFLOW_STATE_IDLE = "idle";
class Workflow extends events.EventEmitter {
state = WORKFLOW_STATE_IDLE;
isRunning() {
return this.state === WORKFLOW_STATE_RUNNING;
}
isPaused() {
return this.state === WORKFLOW_STATE_PAUSED;
}
isIdle() {
return this.state === WORKFLOW_STATE_IDLE;
}
start(...args) {
if (this.state !== WORKFLOW_STATE_RUNNING) {
this.state = WORKFLOW_STATE_RUNNING;
this.emit("start", ...args);
}
}
stop(...args) {
if (this.state !== WORKFLOW_STATE_IDLE) {
this.state = WORKFLOW_STATE_IDLE;
this.emit("stop", ...args);
}
}
stopTesting() {
this.state = WORKFLOW_STATE_IDLE;
this.emit("stop");
}
resumeTesting() {
if (this.state === WORKFLOW_STATE_PAUSED) {
this.state = WORKFLOW_STATE_RUNNING;
this.emit("resume");
}
}
pause(...args) {
if (this.state === WORKFLOW_STATE_RUNNING) {
this.state = WORKFLOW_STATE_PAUSED;
}
this.emit("pause", ...args);
}
resume(...args) {
if (this.state === WORKFLOW_STATE_PAUSED) {
this.state = WORKFLOW_STATE_RUNNING;
}
this.emit("resume", ...args);
}
}
export default Workflow;
b6d6e761eThis file is pinned to the selected release. Download the original to open it in your design tool.