@st-one-io/nodes7
Advanced tools
Comparing version 1.0.0-beta.1 to 1.0.0-beta.2
{ | ||
"name": "@st-one-io/nodes7", | ||
"description": "A javascript library to communicate with Siemens S7 PLCs", | ||
"version": "1.0.0-beta.1", | ||
"version": "1.0.0-beta.2", | ||
"author": "Guilherme Francescon <guilherme@st-one.io>", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
@@ -14,2 +14,3 @@ //@ts-check | ||
const S7Item = require('./s7item'); | ||
const S7Connection = require('./s7connection.js'); | ||
@@ -44,5 +45,5 @@ const NodeS7Error = require('./errors.js'); | ||
* @typedef {object} ComponentIdentification | ||
* @property {string} [systemName] W#16#0001: Name of the automation system | ||
* @property {string} [plcName] W#16#0001: Name of the automation system | ||
* @property {string} [moduleName] W#16#0002: Name of the module | ||
* @property {string} [plantName] W#16#0003: Plant designation of the module | ||
* @property {string} [plantID] W#16#0003: Plant designation of the module | ||
* @property {string} [copyright] W#16#0004: Copyright entry | ||
@@ -621,2 +622,18 @@ * @property {string} [serialNumber] W#16#0005: Serial number of the module | ||
/** | ||
* Reads a S7Item individually | ||
* | ||
* @param {S7Item} item | ||
*/ | ||
async readItem(item) { | ||
debug('S7Endpoint readItem'); | ||
let req = item.getReadItemRequest(); | ||
let res = await this.readVars([req]); | ||
item.readValueFromResponse(res[0], req); | ||
item.updateValueFromBuffer(); | ||
return item.value; | ||
} | ||
/** | ||
* Writes multiple values onto multiple PLC areas. Care must be | ||
@@ -909,3 +926,3 @@ * taken not to exceed the maximum PDU size both of the request | ||
let blockList = await this.listAllBlocks(); | ||
const uploadType = async typ => { | ||
@@ -991,3 +1008,7 @@ for (const blk of blockList[typ]) { | ||
let moduleInfo = {}; | ||
let moduleInfo = { | ||
moduleOrderNumber: null, | ||
hardwareOrderNumber: null, | ||
firmwareOrderNumber: null | ||
}; | ||
@@ -1032,3 +1053,19 @@ for (const buf of res) { | ||
let deviceInfo = {}; | ||
/** @type {ComponentIdentification} */ | ||
let deviceInfo = { | ||
plcName: null, | ||
moduleName: null, | ||
plantID: null, | ||
copyright: null, | ||
serialNumber: null, | ||
partType: null, | ||
mmcSerialNumber: null, | ||
vendorId: null, | ||
profileId: null, | ||
profileSpecific: null, | ||
oemString: null, | ||
oemId: null, | ||
oemAdditionalId: null, | ||
location: null | ||
}; | ||
@@ -1074,3 +1111,3 @@ for (const buf of devInfo) { | ||
default: | ||
//unknown id, ignore it | ||
//unknown id, ignore it | ||
} | ||
@@ -1077,0 +1114,0 @@ } |
@@ -361,3 +361,3 @@ //@ts-check | ||
* | ||
* @param {string|Array<string>} tags the tag or list of tags to be added | ||
* @param {string|S7Item|Array<string>|Array<S7Item>} tags the tag or list of tags to be added | ||
* @throws if the supplied parameter is not a string or an array of strings | ||
@@ -369,19 +369,17 @@ * @throws if the format of the address of the tag is invalid | ||
if (typeof tags === 'string') { | ||
tags = [tags]; | ||
} else if (!Array.isArray(tags)) { | ||
throw new NodeS7Error('ERR_INVALID_ARGUMENT', "Parameter must be a string or an array of strings"); | ||
} | ||
let tagsArr = Array.isArray(tags) ? tags : [tags]; | ||
for (const tag of tags) { | ||
for (const tag of tagsArr) { | ||
debug("S7ItemGroup addItems item", tag); | ||
if (typeof tag !== 'string') { | ||
throw new NodeS7Error('ERR_INVALID_ARGUMENT', "Tags must be of string type"); | ||
if (tag instanceof S7Item){ | ||
this._items.set(tag.name, tag); | ||
} else if (typeof tag === 'string') { | ||
let addr = this._translationCallback(tag); | ||
let item = new S7Item(tag, addr); | ||
this._items.set(tag, item); | ||
} else { | ||
throw new NodeS7Error('ERR_INVALID_ARGUMENT', "Tags must be of type string or S7Item"); | ||
} | ||
let addr = this._translationCallback(tag); | ||
let item = new S7Item(tag, addr); | ||
this._items.set(tag, item); | ||
} | ||
@@ -388,0 +386,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
423028
7463