Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | 1x 1x 1x 1x 1x 1x 4x 3x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 4x 4x 4x 4x 4x 4x 4x 4x 4x 1x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 1x 1x 11x 11x 11x 11x 11x 11x 11x 11x 11x 9x 9x 1x 1x 9x 11x 11x 11x 11x 11x 1x 137x 137x 1x 47x 47x 1x 72x 72x 1x 12x 12x 1x 1x 1x 1x 1x 1x | var assert = require("assert");
var path = require("path");
var _ = require("underscore");
var semver = require("semver");
var expected_version = "0.4.0";
exports.install = function(opcua) {
if (opcua.hasOwnProperty("ISA95")){
return false; // already installed
}
// verify that node-opcua version is compatible
Iif (semver.lt(opcua.version, expected_version)) {
throw new Error("node-opcua-isa95 need node-opcua version to be greater" +
" or equal than " + expected_version + ". Currently your version of node-opcua is " + opcua.version+ "" +
" Please update node-opcua");
}
Eif (semver.gt(opcua.version, expected_version)) {
console.log("warning : the expected version of node-opcua is less than " + expected_version + " - actual version is " + opcua.version)
console.log("Please, check if there is a newer version of node-opcua-isa95!")
}
var Enum = opcua.Enum;//require("enum");
var EquipmentLevel = new Enum({
// ISA95EquipmentElementLevelEnum
//
// This DataType is an enumeration that defines the equipment element levels defined in ISA-95. Its values are
// defined in a below table.
// Note: for enumeration DataTypes it is recommended that variables that use the enumeration also expose the EnumStrings
// property. This property allows a client to easily translate the enumeration (integer value) to a string for
// display (see OPC Part 3).
// Table 36 – ISA95EquipmentElementLevelEnum Values
//
// Value Description
// ENTERPRISE_0 An enterprise is a collection of sites and areas and represents the top level of a role based
// equipment hierarchy.
Enterprise: 0,
// SITE_1 A site is a physical, geographical, or logical grouping determined by the enterprise. It may contain
// areas, production lines, process cells, and production units.
Site: 1,
// AREA_2 An area is a physical, geographical, or logical grouping determined by the site. It may contain work
// centres such as process cells, production units, production lines, and storage zones.
Area: 2,
// PROCESSCELL_3 Process cells are the low level of equipment typically scheduled by the Level 4 and Level 3
// functions for batch manufacturing processes. The definitions for process cells are
// contained in IEC 61512-1.
ProcessCell: 3,
// UNIT_4 Units are low level of equipment typically scheduled by the Level 4 and Level 3 functions for batch
// manufacturing processes and continuous manufacturing processes. The definition of the unit for batch
// manufacturing processes is contained in IEC 61512-1.
Unit: 4,
// PRODUCTIONLINE_5 Production lines are low levels of equipment typically scheduled by the Level 4 or Level 3
// functions for discrete manufacturing processes.
ProductionLine: 5,
// WORKCELL_6 Work cells are low levels of equipment typically scheduled by the Level 4 or Level 3 functions for
// discrete manufacturing processes.
WorkCell: 6,
// PRODUCTIONUINT_7 Production units are the lowest level of equipment typically scheduled by the Level 4 or Level
// functions for continuous manufacturing processes.
ProductionUnit: 7,
// STORAGEZONE_8 Storage zones are low level of material movement equipment typically scheduled by the Level 4 and
// Level 3 functions for discrete, batch and continuous manufacturing processes.
StorageZone: 8,
// STORAGEUNIT_9 Storage units are low level of material movement equipment typically scheduled by the Level 4 and
// Level 3 functions for discrete, batch and continuous manufacturing processes.
// WORKCENTER_10 Work centres are typically the grouping of equipment scheduled by the Level 4 or
// Level 3 functions.
StorageUnit: 9,
// WORKUNIT_11 A work unit is any element of the equipment hierarchy under a work centre. Work units are the lowest
// form of elements in an equipment hierarchy that are typically scheduled by Level 3 functions.
WorkUnit: 11,
// EQUIPMENTMODULE_12 An equipment module entity is an engineered subdivision of a process cell, a unit, or another
// equipment module. The definition of the equipment module is contained in IEC61512-1.
EquipmentModule: 12,
// CONTROLMODULE_13 A control module entity is an engineered subdivision of a process cell, a unit, an equipment module,
// or another control module. The definition of the equipment module is contained in IEC 61512-1.
ControlModule: 13,
// OTHER_14 The types of work centres may be extended when required for application specific role based
// equipment hierarchies where the defined types do not apply. In that case, the equipment element
// level shall be specified as this value, and actual value that identifies the level shall be
// specified by OtherValue Property of ISAHierarchyScopeType defined in 7.4.1.
Other: 14
// When a new type is added it shall maintain the same relationship within the hierarchy as the defined work centre
// types (within an area and contains work units).
});
const registerBasicType = require("node-opcua-factory").registerBasicType;
registerBasicType({ name: "CDTIdentifier", subtype: "String", defaultValue: null});
assert(!opcua.hasOwnProperty('ISA95'),"already initialized ?");
opcua.ISA95= {};
opcua.ISA95.EquipmentLevel = EquipmentLevel;
var isa95_xml_file = path.join(__dirname, "../nodesets/Opc.ISA95.NodeSet2.xml");
opcua.ISA95.nodeset_file = isa95_xml_file;
function coerceISA95TypeDefinition(addressSpace,typeDefinition,baseType) {
var baseType = addressSpace.findISA95VariableType(baseType);
assert(baseType,baseType + " must exists ");
Eif (typeof typeDefinition === "string") {
var _typeDefinition = addressSpace.findISA95VariableType(typeDefinition);
assert(_typeDefinition,typeDefinition + " must exists ");
typeDefinition = _typeDefinition;
}
Iif (typeDefinition instanceof opcua.NodeId) {
typeDefinition = addressSpace.findNode(typeDefinition);
}
assert(typeDefinition.nodeId instanceof opcua.NodeId);
// istanbul ignore next
if (!baseType.isSupertypeOf(typeDefinition)) {
//xx throw new Error(typeDefinition.browseName.toString() + " must be a subtype of " + baseType.browseName.toString());
}
return typeDefinition;
}
/**
*
* @param options
* @param options.browseName
* @param options.ISA95ClassPropertyOf
* @param options.typeDefinition
* @param options.dataType
* @param options.value
*/
opcua.AddressSpace.prototype.addISA95ClassProperty = function(options) {
assert(options.dataType,"expecting a dataType here");
assert(!options.componentOf && !options.organizedBy && !options.propertyOf);
assert(options.typeDefinition, "expecting a typeDefinition");
assert(options.ISA95ClassPropertyOf,"expecting a parent object");
// todo ; check that nodeISA95 is a ...ClassType
var nodeISA95 = options.ISA95ClassPropertyOf;
var addressSpace = nodeISA95.addressSpace;
const namespace = addressSpace.getOwnNamespace();
function coerceISA95ClassPropertyTypeDefinition(typeDefinition) {
return coerceISA95TypeDefinition(addressSpace,typeDefinition,"ISA95ClassPropertyType");
}
var typeDefinition = coerceISA95ClassPropertyTypeDefinition(options.typeDefinition);
var ns = addressSpace.getISA95Namespace();
// placeHolder => HasISA95ClassProperty => <PropertyName>
// => TestedByEquipmentTest => <TestSpecification>
//
var property = namespace.addVariable({
typeDefinition: typeDefinition,
browseName: options.browseName,
dataType: options.dataType,
value: options.value
});
// not : the hasISA95ClassProperty reference will be turned into a hasISA95Property in the instantiated object
var hasISA95ClassProperty = addressSpace.findReferenceType("HasISA95ClassProperty",ns);
nodeISA95.addReference({
referenceType: hasISA95ClassProperty.nodeId,
nodeId: property
});
return property;
};
/**
*
* @param options
* @param options.browseName
* @param options.typeDefinition
* @param options.ISA95PropertyOf
* @param [options.modellingRule]
* @returns {UAVariable}
*/
opcua.AddressSpace.prototype.addISA95Property = function(options) {
assert(options.browseName,"expecting a browseName");
assert(options.dataType,"expecting a dataType here");
assert(!options.componentOf && !options.organizedBy && !options.propertyOf);
assert(options.typeDefinition, "expecting a typeDefinition");
assert(options.ISA95PropertyOf,"expecting a parent object");
// todo ; check that nodeISA95 is a ...ClassType
var nodeISA95 = options.ISA95PropertyOf;
var addressSpace = nodeISA95.addressSpace;
const namespace = addressSpace.getOwnNamespace();
var ns = addressSpace.getISA95Namespace();
var hasISA95Property = addressSpace.findReferenceType("HasISA95Property",ns);
function coerceISA95PropertyTypeDefinition(typeDefinition) {
return coerceISA95TypeDefinition(addressSpace,typeDefinition,"ISA95PropertyType");
}
var typeDefinition = coerceISA95PropertyTypeDefinition(options.typeDefinition);
var property = namespace.addVariable({
browseName: options.browseName,
typeDefinition: typeDefinition,
modellingRule: options.modellingRule,
dataType: options.dataType,
value: options.value
});
nodeISA95.addReference({
referenceType: hasISA95Property.nodeId,
nodeId: property
});
return property;
};
/**
*
* @param options
* @param options.browseName
* @param options.dataType
* @param options.value
* @param [options.typeDefinition]
* @param [options.modellingRule]
* @param options.ISA95AttributeOf
*/
opcua.AddressSpace.prototype.addISA95Attribute = function(options) {
assert(options.ISA95AttributeOf," ISA95AttributeOf options is expected");
var nodeISA95 = options.ISA95AttributeOf;
// modelling rule must be specified if nodeISA95 is a UAVariableType of UAObjectType;
Iif (!options.modellingRule &&
( nodeISA95.constructor.name === "UAVariableType" ||
nodeISA95.constructor.name === "UAObjectType")) {
throw new Error("Expecting options.modellingRule to be specified")
}
var addressSpace = nodeISA95.addressSpace;
const namespace = addressSpace.getOwnNamespace();
var ns = addressSpace.getNamespaceIndex("http://www.OPCFoundation.org/UA/2013/01/ISA95");
var hasISA95Attribute = addressSpace.findReferenceType("HasISA95Attribute",ns);
var dataType = options.dataType;
if (typeof dataType === "string") {
var dataTypeNode = addressSpace.findDataType(dataType,ns);
if (!dataTypeNode) {
dataTypeNode = addressSpace.findDataType(dataType);
Iif (!dataTypeNode) {
dataTypeNode = opcua.DataType[dataType];
}
}
dataType = dataTypeNode;
}
Iif(!dataType ){
console.log("opcua.",opcua.DataType);
throw new Error(" cannot find dataType " + options.dataType + " " + typeof options.dataType );
}
var typeDefinition = options.typeDefinition || addressSpace.findVariableType("BaseDataVariableType");
var property = namespace.addVariable({
typeDefinition: typeDefinition,
modellingRule: options.modellingRule,
browseName: options.browseName,
dataType: dataType,
value: options.value,
});
nodeISA95.addReference({
referenceType: hasISA95Attribute.nodeId,
nodeId: property
});
return property;
};
/**
* find a ReferenceType in the ISA95 namespace
* @param name {String}
* @return {opcua.ReferenceType}
*/
opcua.AddressSpace.prototype.getISA95Namespace = function() {
var addressSpace = this;
return addressSpace.getNamespaceIndex("http://www.OPCFoundation.org/UA/2013/01/ISA95");
};
opcua.AddressSpace.prototype.findISA95ReferenceType = function(name) {
var addressSpace = this;
return addressSpace.findReferenceType(name,addressSpace.getISA95Namespace());
};
opcua.AddressSpace.prototype.findISA95ObjectType = function(name) {
var addressSpace = this;
return addressSpace.findObjectType(name,addressSpace.getISA95Namespace());
};
opcua.AddressSpace.prototype.findISA95VariableType = function(name) {
var addressSpace = this;
return addressSpace.findVariableType(name,addressSpace.getISA95Namespace());
};
opcua.AddressSpace.prototype.findISA95DataType = function(name) {
var addressSpace = this;
return addressSpace.findDataType(name,addressSpace.getISA95Namespace());
};
require("./isa95_address_space_extension_utils")(opcua);
require("./isa95_address_space_extension_equipment")(opcua);
require("./isa95_address_space_extension_physical_asset")(opcua);
};
|