-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example script for initial connection; make it callable by "npm t…
…est"
- Loading branch information
Christian Stimming
committed
Nov 27, 2020
1 parent
aa077d0
commit 4f4fbff
Showing
3 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,3 +59,4 @@ typings/ | |
|
||
# Visual Studio Code config folder | ||
.vscode | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const { Session, Clsid, ComServer } = require('../dcom') | ||
|
||
const domain = 'WORKGROUP' | ||
const username = 'myuser' | ||
const password = 'mypassword' | ||
const ipAddress = '1.2.3.4' | ||
const timeout = 1000 | ||
const classIdString = 'F8582CF2-88FB-11D0-B850-00C0F0104305' // Matrikon.OPC.Simulation | ||
|
||
const sessionSingleton = new Session() | ||
|
||
async function main () { | ||
const comSession = sessionSingleton.createSession(domain, username, password) | ||
comSession.setGlobalSocketTimeout(timeout) | ||
const clsid = new Clsid(classIdString) | ||
const comServer = new ComServer(clsid, ipAddress, comSession, { major: 5, minor: 7 }) | ||
|
||
try { | ||
// start the COM Server | ||
await comServer.init() | ||
console.log(`Successfully connected to ${ipAddress}`) | ||
|
||
await comServer.closeStub() | ||
} catch (err) { | ||
console.trace(err) | ||
} | ||
|
||
await comSession.destroySession(comSession) | ||
} | ||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters