本文整理汇总了TypeScript中node-opcua.OPCUAServer类的典型用法代码示例。如果您正苦于以下问题:TypeScript OPCUAServer类的具体用法?TypeScript OPCUAServer怎么用?TypeScript OPCUAServer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OPCUAServer类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: before
before(done => {
port += 1;
const options = { port };
server = new OPCUAServer(options);
server.on("post_initialize", () => {
const addressSpace = server.engine.addressSpace!;
const group = addressSpace.getOwnNamespace().addObject({
browseName: "Group",
organizedBy: addressSpace.rootFolder.objects
});
for (let i = 0; i < 27; i++) {
addressSpace.getOwnNamespace().addObject({
browseName: "Object" + i,
organizedBy: group
});
}
groupNodeId = group.nodeId;
});
server.start((err?: Error) => {
if (err) {
return done(err);
}
endpointUrl = server.endpoints[0].endpointDescriptions()[0].endpointUrl;
if (err) {
return done(err);
}
done();
});
});
开发者ID:node-opcua,项目名称:node-opcua,代码行数:33,代码来源:test_e2e_#519_Nodecrawler_is_not_browsing_some_nodes.ts
示例2: main
async function main() {
try {
const server = new OPCUAServer({
nodeset_filename: [
nodesets.standard_nodeset_file
]
});
await server.initialize();
// post-initialize
const addressSpace = server.engine.addressSpace!;
const object = installObjectWithMethod(addressSpace);
console.log("object = ", object.toString());
await callMethodFromServer(addressSpace, object.nodeId);
await server.start();
console.log(" Server started ", server.endpoints[0].endpointDescriptions()[0].endpointUrl);
} catch (err) {
console.log(" Error: ", err.message);
console.log(err.stack);
}
}
示例3: startServer
// openssl req -x509 -newkey rsa:4096 -sha256 -nodes -keyout example.pem \
// -outform der -out example.der -subj "/CN=example.com" -days 3650
async function startServer(): Promise<OPCUAServer> {
server = new OPCUAServer({
maxAllowedSessionNumber: 10,
nodeset_filename: empty_nodeset_filename,
port,
});
await server.start();
endpointUrl = server.endpoints[0].endpointDescriptions()[0].endpointUrl!;
return server;
}
示例4: main
async function main() {
const server = new OPCUAServer(server_options);
server.on("post_initialize", () => {
/* empty */
});
console.log(chalk.yellow(" server PID :"), process.pid);
console.log(chalk.yellow(" silent :"), argv.silent);
await server.start();
const endpointUrl = server.endpoints[0].endpointDescriptions()[0].endpointUrl!;
console.log(chalk.yellow(" server on port :"), chalk.cyan(server.endpoints[0].port.toString()));
console.log(chalk.yellow(" endpointUrl :"), chalk.cyan(endpointUrl));
console.log(chalk.yellow("\n server now waiting for connections. CTRL+C to stop"));
if (argv.silent) {
console.log("silent");
console.log = (...args: [any?, ... any[]]) => {
/* silent */
};
}
server.on("create_session", (session: ServerSession) => {
console.log(" SESSION CREATED");
console.log(chalk.cyan(" client application URI: "), session.clientDescription!.applicationUri);
console.log(chalk.cyan(" client product URI: "), session.clientDescription!.productUri);
console.log(chalk.cyan(" client application name: "), session.clientDescription!.applicationName.toString());
console.log(chalk.cyan(" client application type: "), session.clientDescription!.applicationType.toString());
console.log(chalk.cyan(" session name: "), session.sessionName ? session.sessionName.toString() : "<null>");
console.log(chalk.cyan(" session timeout: "), session.sessionTimeout);
console.log(chalk.cyan(" session id: "), session.nodeId);
});
server.on("session_closed", (session: ServerSession, reason: string) => {
console.log(" SESSION CLOSED :", reason);
console.log(chalk.cyan(" session name: "), session.sessionName ? session.sessionName.toString() : "<null>");
});
process.on("SIGINT", async () => {
// only work on linux apparently
console.error(chalk.red.bold(" Received server interruption from user "));
console.error(chalk.red.bold(" shutting down ..."));
await server.shutdown(1000);
console.error(chalk.red.bold(" shot down ..."));
process.exit(1);
});
}
示例5: main
async function main() {
const server = new OPCUAServer(server_options);
console.log(chalk.yellow(" server PID :"), process.pid);
server.on("post_initialize", () => {
const addressSpace = server.engine.addressSpace!;
// to do: expose new nodeid here
const ns = addressSpace.getNamespaceIndex("http://yourorganisation.org/my_data_type/");
const myStructureType = addressSpace.findVariableType("MyStructureType", ns);
if (!myStructureType) {
console.log(" ns = ", ns, "cannot find MyStructureDataType ");
return;
}
const namespace = addressSpace.getOwnNamespace();
const someObject = namespace.addObject({
browseName: "SomeObject",
organizedBy: addressSpace.rootFolder.objects
});
myStructureType.instantiate({
browseName: "MyVar",
componentOf: someObject
});
});
try {
await server.start();
} catch (err) {
console.log(" Server failed to start ... exiting");
process.exit(-3);
}
const endpointUrl = server.endpoints[0].endpointDescriptions()[0].endpointUrl!;
console.log(chalk.yellow(" server on port :"), chalk.cyan(server.endpoints[0].port.toString()));
console.log(chalk.yellow(" endpointUrl :"), chalk.cyan(endpointUrl));
console.log(chalk.yellow("\n server now waiting for connections. CTRL+C to stop"));
process.on("SIGINT", async () => {
// only work on linux apparently
await server.shutdown(1000);
console.log(chalk.red.bold(" shutting down completed "));
process.exit(-1);
});
}
示例6: main
async function main() {
const tmpFolder = path.join(__dirname, "../certificates/myApp");
const applicationGroup = new CertificateManager({
location: tmpFolder
});
await applicationGroup.initialize();
const server = new OPCUAServer(server_options);
console.log(" Configuration rootdir = ", server.serverCertificateManager.rootDir);
console.log(chalk.yellow(" server PID :"), process.pid);
server.on("post_initialize", () => {
const addressSpace = server.engine.addressSpace!;
// to do: expose new nodeid here
const ns = addressSpace.getNamespaceIndex("http://yourorganisation.org/my_data_type/");
installPushCertificateManagement(addressSpace, {
applicationGroup: server.serverCertificateManager,
userTokenGroup: server.userCertificateManager
});
console.log("Certificate rejected folder ", server.serverCertificateManager.rejectedFolder);
});
try {
await server.start();
} catch (err) {
console.log(" Server failed to start ... exiting");
process.exit(-3);
}
const endpointUrl = server.endpoints[0].endpointDescriptions()[0].endpointUrl!;
console.log(chalk.yellow(" server on port :"), chalk.cyan(server.endpoints[0].port.toString()));
console.log(chalk.yellow(" endpointUrl :"), chalk.cyan(endpointUrl));
console.log(chalk.yellow("\n server now waiting for connections. CTRL+C to stop"));
process.on("SIGINT", async () => {
// only work on linux apparently
await server.shutdown(1000);
console.log(chalk.red.bold(" shutting down completed "));
process.exit(-1);
});
}
示例7: startMultiHeadServer
async function startMultiHeadServer() {
const server_options: OPCUAServerOptions = {
isAuditing: false,
nodeset_filename: [
nodesets.standard
],
serverInfo: {
applicationName: { text: "Mini NodeOPCUA Server", locale: "en" },
applicationUri: makeApplicationUrn("%FQDN%", "MiniNodeOPCUA-Server"),
productUri: "Mini NodeOPCUA-Server"
},
// default endpoint
allowAnonymous: false,
alternateHostname: ["MyHostname1"],
port: port1,
securityModes: [MessageSecurityMode.None],
securityPolicies: [SecurityPolicy.None],
// alternate endpoint
alternateEndpoints: [
{
allowAnonymous: false,
alternateHostname: ["1.2.3.4"],
port: port2,
securityModes: [MessageSecurityMode.SignAndEncrypt],
securityPolicies: [SecurityPolicy.Basic256Sha256]
}
]
};
server = new OPCUAServer(server_options);
server.on("post_initialize", () => {/**/
});
console.log(chalk.yellow(" server PID :"), process.pid);
try {
await server.start();
} catch (err) {
console.log(" Server failed to start ... exiting => err:", err.message);
return;
}
}
示例8: startServer
async function startServer() {
const server_options: OPCUAServerOptions = {
port: port1,
nodeset_filename: [
nodesets.standard
],
serverInfo: {
applicationUri: makeApplicationUrn("%FQDN%", "MiniNodeOPCUA-Server"),
productUri: "Mini NodeOPCUA-Server",
applicationName: { text: "Mini NodeOPCUA Server", locale: "en" }
},
alternateHostname: ["MyHostname1", "MyHostname2"],
isAuditing: false
};
server = new OPCUAServer(server_options);
server.on("post_initialize", () => {/**/
});
console.log(chalk.yellow(" server PID :"), process.pid);
try {
await server.start();
} catch (err) {
console.log(" Server failed to start ... exiting => err:", err.message);
return;
}
for (const endpoint of server.endpoints) {
const endpointUrl = endpoint.endpointDescriptions()[0].endpointUrl!;
console.log(chalk.yellow(" server on port1 :"), endpoint.port.toString());
console.log(chalk.yellow(" endpointUrl1 :"), chalk.cyan(endpointUrl));
}
}
示例9: main
async function main() {
process.title = "Node OPCUA Server on port : " + server_options.port;
const server = new OPCUAServer(server_options);
server.on("post_initialize", () => {/**/
});
console.log(chalk.yellow(" server PID :"), process.pid);
try {
await server.start();
} catch (err) {
console.log(" Server failed to start ... exiting");
process.exit(-3);
}
const endpointUrl = server.endpoints[0].endpointDescriptions()[0].endpointUrl!;
console.log(chalk.yellow(" server on port :"), server.endpoints[0].port.toString());
console.log(chalk.yellow(" endpointUrl :"), chalk.cyan(endpointUrl));
console.log(chalk.yellow("\n server now waiting for connections. CTRL+C to stop"));
server.on("create_session", (session: ServerSession) => {
console.log(" SESSION CREATED");
console.log(chalk.cyan(" client application URI: "), session.clientDescription!.applicationUri);
console.log(chalk.cyan(" client product URI: "), session.clientDescription!.productUri);
console.log(chalk.cyan(" client application name: "), session.clientDescription!.applicationName.toString());
console.log(chalk.cyan(" client application type: "), session.clientDescription!.applicationType.toString());
console.log(chalk.cyan(" session name: "), session.sessionName ? session.sessionName.toString() : "<null>");
console.log(chalk.cyan(" session timeout: "), session.sessionTimeout);
console.log(chalk.cyan(" session id: "), session.nodeId);
});
server.on("session_closed", (session: ServerSession, reason: string) => {
console.log(" SESSION CLOSED :", reason);
console.log(chalk.cyan(" session name: "), session.sessionName ? session.sessionName.toString() : "<null>");
});
}
示例10: stopServer
async function stopServer() {
await server.shutdown();
}