nope/modules/mod-Beckhoff-PLC-Interface/helpers/gen.options.ts

30 lines
712 B
TypeScript
Raw Normal View History

2020-08-30 07:45:44 +00:00
/**
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @create date 2020-03-02 11:41:13
2020-12-30 18:56:48 +00:00
* @modify date 2020-12-30 13:49:05
2020-08-30 07:45:44 +00:00
* @desc [description]
*/
2020-09-08 14:59:06 +00:00
import { IBeckhoffOptions } from "../type/interfaces";
2020-09-08 08:48:08 +00:00
/**
* Function to generate ADS-Connection Options.
2020-12-01 12:03:37 +00:00
* @param options
2020-09-08 08:48:08 +00:00
*/
2020-12-30 18:56:48 +00:00
export function generateAdsOptions(options: IBeckhoffOptions) {
2020-08-30 07:45:44 +00:00
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
2020-12-30 18:56:48 +00:00
timeout: 1000
2020-08-30 07:45:44 +00:00
},
options
2020-09-08 14:59:06 +00:00
) as IBeckhoffOptions;
2020-08-30 07:45:44 +00:00
}