Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
context: SessionContext,
callback: (err: Error | null, callMethodResult: CallMethodResultOptions) => void
) {
const stateMachineW = this.parent! as StateMachine;
// tslint:disable-next-line:no-console
console.log("Boiler System : " + methodName + " about to process");
stateMachineW.setState(toState);
callback(null, {
outputArguments: [],
statusCode: StatusCodes.Good,
});
});
assert(programStateMachine.getMethodByName(methodName) !== null,
"Method " + methodName + " should be added to parent object (checked with getMethodByName)");
const lc_name = lowerFirstLetter(methodName);
}
public uninstall_extra_properties(reference: Reference) {
const addressSpace = this.addressSpace;
if (addressSpace.isFrugal) {
// skipping
return;
}
const childNode = resolveReferenceNode(addressSpace, reference);
const name = lowerFirstLetter(childNode.browseName.name!.toString());
if (reservedNames.hasOwnProperty(name)) {
if (doDebug) {
// tslint:disable-next-line:no-console
console.log(chalk.bgWhite.red("Ignoring reserved keyword " + name));
}
return;
}
/* istanbul ignore next */
if (!this.hasOwnProperty(name)) {
return;
}
Object.defineProperty(this, name, {
value: undefined
});
}
ServerSession.prototype.incrementRequestTotalCounter = function (counterName) {
const session = this;
if (session._sessionDiagnostics) {
const propName = lowerFirstLetter(counterName + "Count");
if (!session._sessionDiagnostics.hasOwnProperty(propName)) {
console.log(" cannot find", propName);
//xx return;
}
// console.log(self._sessionDiagnostics.toString());
session._sessionDiagnostics[propName].totalCount = session._sessionDiagnostics[propName].totalCount + 1;
}
};
ServerSession.prototype.incrementRequestErrorCounter = function (counterName) {
}
// ignore also methods
if (node instanceof UAMethod) {
//xx console.log(" skipping method ", node.browseName.toString());
return;
}
_process_var(self,"",node);
// also store value in index
//xx eventData.__nodes[node.nodeId.toString()] = eventData[lowerName];
const children =node.getAggregates();
if (children.length >0) {
const lowerName =lowerFirstLetter(node.browseName.name);
//xx console.log(" Children to visit = ",lowerName,children.map(function(a){ return a.browseName.toString();}).join(" "));
children.map(function(child) {
_process_var(self,lowerName + ".",child);
});
}
});
}
private _send_chunk(callback: ErrorCallback | undefined, messageChunk: Buffer | null) {
if (messageChunk) {
this.transport.write(messageChunk);
} else {
if (doPerfMonitoring) {
// record tick 3 : transaction completed.
this._tick3 = get_clock_tick();
}
if (callback) {
setImmediate(callback);
}
if (doPerfMonitoring) {
this._record_transaction_statistics();
/* istanbul ignore next */
if (doDebug) {
// dump some statistics about transaction ( time and sizes )
_dump_transaction_statistics(this.last_transaction_stats);
}
}
this.emit("transaction_done");
this._packetAssembler.on("newMessage", (info, data) => {
if (doPerfMonitoring) {
// record tick 0: when the first data is received
this._tick0 = get_clock_tick();
}
/**
*
* notify the observers that a new message is being built
* @event start_chunk
* @param info
* @param data
*/
this.emit("start_chunk", info, data);
});
console.log(" CANNOT FIND ENCODE METHOD ON VARIANT !!! HELP",dataValue.toString());
}
dataValue.value.encode(stream);
}
// write statusCode
if (check_flag(encoding_mask, DataValueEncodingByte.StatusCode)) {
//ec.encodeUInt32(dataValue.statusCode.value,stream);
ec.encodeStatusCode(dataValue.statusCode,stream);
}
// write sourceTimestamp
if (check_flag(encoding_mask, DataValueEncodingByte.SourceTimestamp)) {
ec.encodeHighAccuracyDateTime(dataValue.sourceTimestamp,dataValue.sourcePicoseconds,stream);
}
// write sourcePicoseconds
if (check_flag(encoding_mask, DataValueEncodingByte.SourcePicoseconds)) {
assert(dataValue.sourcePicoseconds != null );
const sourcePicoseconds = Math.floor((dataValue.sourcePicoseconds % 100000) /10);
ec.encodeUInt16(sourcePicoseconds,stream);
}
// write serverTimestamp
if (check_flag(encoding_mask, DataValueEncodingByte.ServerTimestamp)) {
ec.encodeHighAccuracyDateTime(dataValue.serverTimestamp,dataValue.serverPicoseconds,stream);
}
// write serverPicoseconds
if (check_flag(encoding_mask, DataValueEncodingByte.ServerPicoseconds)) {
assert(dataValue.serverPicoseconds != null);
const serverPicoseconds = Math.floor((dataValue.serverPicoseconds % 100000 ) / 10) ; // we encode 10-pios
ec.encodeUInt16(serverPicoseconds,stream);
}
},
decode_debug: function(dataValue,stream,options) {
import {
EnumerationDefinitionSchema,
FieldCategory,
getStandartDataTypeFactory,
StructuredTypeSchema,
} from "node-opcua-factory";
import { EnumeratedType, parseBinaryXSD, TypeDictionary } from "node-opcua-schemas";
import { LineFile } from "node-opcua-utils";
import { promisify } from "util";
import { writeStructuredType } from "./factory_code_generator";
// Xx import * as prettier from "prettier";
const readFile = promisify(fs.readFile);
const parseBinaryXSD2 = promisify(parseBinaryXSD);
const f = new LineFile();
function write(...args: string[]) {
f.write.apply(f, args);
}
function writeEnumeratedType(enumerationSchema: EnumerationDefinitionSchema) {
// make sure there is a Invalid key in the enum => else insert one
const hasInvalid = enumerationSchema.enumValues.hasOwnProperty("Invalid");
if (!hasInvalid) {
// xx console.log("Adding Invalid Enum entry on ", enumeratedType.name);
enumerationSchema.enumValues[enumerationSchema.enumValues.Invalid = 0xFFFFFFFF] = "Invalid";
}
const arrayValues = Object.keys(enumerationSchema.enumValues)
.filter((a: string) => a.match("[0-9]+"))
);
} else {
write(
`import { ${field.fieldType} } from "../source/imports";`
);
}
}
// -------------------------------------------------------------------------
// - insert definition of base class
// -------------------------------------------------------------------------
if (baseClass !== "BaseUAObject") {
const filename = get_class_tscript_filename_local(baseClass);
const localFilename = normalize_require_file(folderForSourceFile, filename);
// xx console.log(" ===> filename", filename, localFilename, fs.existsSync(filename));
if (fs.existsSync(filename)) {
assert(!localFilename.match(/\\/));
write("import { " + baseClass + " } from \"" + localFilename + "\";");
} else {
write("const " + baseClass + " = getStructureTypeConstructor(\"" + baseClass + "\");");
}
}
write_expose_encoder_decoder(write, schema);
writeStructuredType(write, schema);
f.saveFormat(generatedTypescriptFilename, (code) => {
const options: prettier.Options = {
// if binaryEncodingNodeId is in the standard factory => no need to overwrite
if (!bForce && (hasConstructor(dataType.binaryEncodingNodeId) || dataType.binaryEncodingNodeId.namespace === 0)) {
//xx console.log(chalk.bgYellow("Skipping standard constructor") ," for dataType" ,dataType.browseName.toString());
return getConstructor(dataType.binaryEncodingNodeId);
}
const schema = constructSchema(addressSpace, dataType);
generateFileCode(namespaceUri, schema, schema_folder);
generateStructureCode(namespaceUri, schema);
const filename = getSchemaSourceFile(namespaceUri, schema.name, "");
const relative_filename = normalize_require_file(__dirname, filename);
const constructor = require(relative_filename)[schema.name];
assert(_.isFunction(constructor), "expecting a constructor here");
return constructor;
}