"mochaExplorer.files": ["test/**/*.test.ts"],
"mochaExplorer.debuggerConfig": "Debug Simulator Unit Tests",
"cSpell.words": [
+ "backoff",
"benoit",
"bufferutil",
"cacheable",
const moduleName = 'ChargingStationWorker';
/**
- * Create and start a charging station instance
+ * Creates and starts a charging station instance
*
* @param data - workerData
*/
}
/**
- * Get one idtag from the cache given the distribution
+ * Gets one idtag from the cache given the distribution
* Must be called after checking the cache is not an empty array
*
* @param distribution -
}
/**
- * Get all idtags from the cache
+ * Gets all idtags from the cache
* Must be called after checking the cache is not an empty array
*
* @param file -
return Math.floor(crypto.randomInt(max + 1));
}
+ /**
+ * Rounds the given number to the given scale.
+ * The rounding is done using the "round half away from zero" method.
+ *
+ * @param numberValue - The number to round.
+ * @param scale - The scale to round to.
+ * @returns The rounded number.
+ */
public static roundTo(numberValue: number, scale: number): number {
const roundPower = Math.pow(10, scale);
return Math.round(numberValue * roundPower * (1 + Number.EPSILON)) / roundPower;
`${str.slice(0, pos)}${subStr}${str.slice(pos)}`;
/**
+ * Computes the retry delay in milliseconds using an exponential backoff algorithm.
+ *
* @param retryNumber - the number of retries that have already been attempted
* @returns delay in milliseconds
*/
}
/**
- * Generate a cryptographically secure random number in the [0,1[ range
+ * Generates a cryptographically secure random number in the [0,1[ range
*
* @returns
*/
}
/**
- * Convert websocket error code to human readable string message
+ * Converts websocket error code to human readable string message
*
* @param code - websocket error code
* @returns human readable string message
}
/**
- * Start the worker pool/set.
+ * Starts the worker pool/set.
*/
public abstract start(): Promise<void>;
/**
- * Stop the worker pool/set.
+ * Stops the worker pool/set.
*/
public abstract stop(): Promise<void>;
/**
- * Add a task element to the worker pool/set.
+ * Adds a task element to the worker pool/set.
*
* @param elementData -
*/
private readonly pool: DynamicThreadPool<WorkerData>;
/**
- * Create a new `WorkerDynamicPool`.
+ * Creates a new `WorkerDynamicPool`.
*
* @param workerScript -
* @param workerOptions -
private readonly workerSet: Set<WorkerSetElement>;
/**
- * Create a new `WorkerSet`.
+ * Creates a new `WorkerSet`.
*
* @param workerScript -
* @param workerOptions -
}
/**
- * Add a new `WorkerSetElement`.
+ * Adds a new `WorkerSetElement`.
*/
private addWorkerSetElement(): WorkerSetElement {
const worker = new Worker(this.workerScript, {
private readonly pool: FixedThreadPool<WorkerData>;
/**
- * Create a new `WorkerStaticPool`.
+ * Creates a new `WorkerStaticPool`.
*
* @param workerScript -
* @param workerOptions -