nope/modules/mod-Beckhoff-PLC-Interface/helpers/gen.options.ts
Martin Karkowski c26c2b78db Adding comments
2020-09-08 10:48:08 +02:00

38 lines
818 B
TypeScript

/**
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @create date 2020-03-02 11:41:13
* @modify date 2020-09-08 08:17:21
* @desc [description]
*/
/**
* Function to generate ADS-Connection Options.
* @param options
*/
export function generateOptions(options: {
name: string;
host: string;
amsNetIdTarget: string;
amsNetIdSource: string;
twinCatVersion: 2 | 3;
port?: number;
amsPortSource?: number;
amsPortTarget?: number;
timeout?: number;
}) {
return Object.assign(
{
//The tcp destination port
port: 48898,
//The ams source port
amsPortSource: 32905,
//The ams target port for TwinCat 2 Runtime 1
amsPortTarget: options.twinCatVersion === 2 ? 801 : 851,
//The timeout for PLC requests
timeout: 500
},
options
);
}