Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
Make write and close use await as well as per lib.
Browse files Browse the repository at this point in the history
  • Loading branch information
grigals committed Nov 22, 2023
1 parent 7fe7a0f commit 4060ced
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/devices/S7.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export class S7Connection extends DeviceConnection {
* Writes metric values to the PLC
* @param {array} metrics Array of metric objects to write to the PLC
*/
writeMetrics(metrics: Metrics) {
async writeMetrics(metrics: Metrics) {
// This doesn't seem to work for Ixxx value writes
// Untested with other writes at present

Expand All @@ -116,22 +116,22 @@ export class S7Connection extends DeviceConnection {
// Notify user
log(`Writing ${values} to ${addrs}`);
// Write metric values
this.#itemGroup.writeItems(addrs, values);
await this.#itemGroup.writeItems(addrs, values);
}
}

/**
* Close connection and tidy up
*/
close() {
async close() {
// Clear the variable list
this.#vars = {};
// Destroy the metric item group, if it exists
if (this.#itemGroup) {
this.#itemGroup.destroy();
}
// Close the PLC connection
this.#s7Conn.disconnect();
await this.#s7Conn.disconnect();
}
}

Expand Down

0 comments on commit 4060ced

Please sign in to comment.