Handling of Asynchronous Function Calls

The communication between the WinCC OA JavaScript Manager for Node.js and other managers is asynchronous (e. g. WinccoaManager:dpGet()), so it is necessary for these functions to be called using the keyword await.

Methods that are handled asynchronously always return an object of the class Promise, this is also how they can be identified in the documentation.

CAUTION: Instead of method calls using await the Promise ()-functionality can also be used. This option should only be used by experienced JavaScript developers.

Asynchronous function call

import { WinccoaManager } from 'winccoa-manager';
const winccoa = new WinccoaManager();

// main function
async function main() {
  const dpeName = 'ExampleDP_Arg1.';
  const value = await winccoa.dpGet(dpeName);

  console.info('Node.js® manager for WinCC OA working');
  console.info('Value of ' + dpeName + ' = ' + value);

  winccoa.exit(0);
}

// start the main function
main();