diff --git a/TiaCodegen-ts/src/Commands/Comparisons/InRangeCall.ts b/TiaCodegen-ts/src/Commands/Comparisons/InRangeCall.ts index 0560c6c..ea69e86 100644 --- a/TiaCodegen-ts/src/Commands/Comparisons/InRangeCall.ts +++ b/TiaCodegen-ts/src/Commands/Comparisons/InRangeCall.ts @@ -11,7 +11,7 @@ export class InRangeCall extends SystemFunctionCall { out: IOperationOrSignal, eno: IOperationOrSignal | null = null, ) { - super('InRange', eno); + super({ functionName: 'InRange', eno }); this.disableEno = false; this.iface['min'] = new IOperationOrSignalDirectionWrapper(min, Direction.Input); this.iface['in'] = new IOperationOrSignalDirectionWrapper(inParam, Direction.Input); diff --git a/TiaCodegen-ts/src/Commands/Comparisons/OutRangeCall.ts b/TiaCodegen-ts/src/Commands/Comparisons/OutRangeCall.ts index 5320a4f..9c683e7 100644 --- a/TiaCodegen-ts/src/Commands/Comparisons/OutRangeCall.ts +++ b/TiaCodegen-ts/src/Commands/Comparisons/OutRangeCall.ts @@ -11,7 +11,7 @@ export class OutRangeCall extends SystemFunctionCall { out: IOperationOrSignal, eno: IOperationOrSignal | null = null, ) { - super('OutRange', eno); + super({ functionName: 'OutRange', eno }); this.disableEno = false; this.iface['min'] = new IOperationOrSignalDirectionWrapper(min, Direction.Input); this.iface['in'] = new IOperationOrSignalDirectionWrapper(inParam, Direction.Input); diff --git a/TiaCodegen-ts/src/Commands/Functions/AckGlCall.ts b/TiaCodegen-ts/src/Commands/Functions/AckGlCall.ts index fd6d841..263b69c 100644 --- a/TiaCodegen-ts/src/Commands/Functions/AckGlCall.ts +++ b/TiaCodegen-ts/src/Commands/Functions/AckGlCall.ts @@ -3,13 +3,16 @@ import { IOperationOrSignalDirectionWrapper } from '../../Interfaces/IOperationO import { Direction } from '../../Enums/Direction.js'; import { SystemFunctionBlockCall } from './Base/SystemFunctionBlockCall.js'; +export interface AckGlCallOptions { + instanceName: string; + ackGlob?: IOperationOrSignal | null; + eno?: IOperationOrSignal | null; +} + export class AckGlCall extends SystemFunctionBlockCall { - constructor( - instanceName: string, - ackGlob: IOperationOrSignal | null = null, - eno: IOperationOrSignal | null = null, - ) { - super('ACK_GL', instanceName, eno); + constructor(options: AckGlCallOptions) { + const { instanceName, ackGlob = null, eno = null } = options; + super({ functionName: 'ACK_GL', instanceName, eno }); this.iface['ACK_GLOB'] = new IOperationOrSignalDirectionWrapper(ackGlob, Direction.Input); this.additionalSafetyTemplateValues = ` diff --git a/TiaCodegen-ts/src/Commands/Functions/Arithmetic/AddCall.ts b/TiaCodegen-ts/src/Commands/Functions/Arithmetic/AddCall.ts index 3ffd2c0..084c54c 100644 --- a/TiaCodegen-ts/src/Commands/Functions/Arithmetic/AddCall.ts +++ b/TiaCodegen-ts/src/Commands/Functions/Arithmetic/AddCall.ts @@ -3,115 +3,71 @@ import { IOperationOrSignalDirectionWrapper } from '../../../Interfaces/IOperati import { Direction } from '../../../Enums/Direction.js'; import { VariableArithmeticCall } from './VariableArithmeticCall.js'; +export interface AddCallOptions { + type: string; + in1: IOperationOrSignal; + in2: IOperationOrSignal; + in3?: IOperationOrSignal | null; + in4?: IOperationOrSignal | null; + in5?: IOperationOrSignal | null; + in6?: IOperationOrSignal | null; + in7?: IOperationOrSignal | null; + in8?: IOperationOrSignal | null; + in9?: IOperationOrSignal | null; + in10?: IOperationOrSignal | null; + in11?: IOperationOrSignal | null; + in12?: IOperationOrSignal | null; + in13?: IOperationOrSignal | null; + in14?: IOperationOrSignal | null; + in15?: IOperationOrSignal | null; + in16?: IOperationOrSignal | null; + in17?: IOperationOrSignal | null; + in18?: IOperationOrSignal | null; + in19?: IOperationOrSignal | null; + in20?: IOperationOrSignal | null; + in21?: IOperationOrSignal | null; + in22?: IOperationOrSignal | null; + in23?: IOperationOrSignal | null; + in24?: IOperationOrSignal | null; + in25?: IOperationOrSignal | null; + in26?: IOperationOrSignal | null; + in27?: IOperationOrSignal | null; + in28?: IOperationOrSignal | null; + in29?: IOperationOrSignal | null; + in30?: IOperationOrSignal | null; + in31?: IOperationOrSignal | null; + in32?: IOperationOrSignal | null; + in33?: IOperationOrSignal | null; + in34?: IOperationOrSignal | null; + in35?: IOperationOrSignal | null; + in36?: IOperationOrSignal | null; + in37?: IOperationOrSignal | null; + in38?: IOperationOrSignal | null; + in39?: IOperationOrSignal | null; + in40?: IOperationOrSignal | null; + in41?: IOperationOrSignal | null; + in42?: IOperationOrSignal | null; + in43?: IOperationOrSignal | null; + in44?: IOperationOrSignal | null; + in45?: IOperationOrSignal | null; + in46?: IOperationOrSignal | null; + in47?: IOperationOrSignal | null; + in48?: IOperationOrSignal | null; + in49?: IOperationOrSignal | null; + in50?: IOperationOrSignal | null; + out1?: IOperationOrSignal | null; + eno?: IOperationOrSignal | null; +} + export class AddCall extends VariableArithmeticCall { - constructor( - type: string, - in1: IOperationOrSignal, - in2: IOperationOrSignal, - in3: IOperationOrSignal | null = null, - in4: IOperationOrSignal | null = null, - in5: IOperationOrSignal | null = null, - in6: IOperationOrSignal | null = null, - in7: IOperationOrSignal | null = null, - in8: IOperationOrSignal | null = null, - in9: IOperationOrSignal | null = null, - in10: IOperationOrSignal | null = null, - in11: IOperationOrSignal | null = null, - in12: IOperationOrSignal | null = null, - in13: IOperationOrSignal | null = null, - in14: IOperationOrSignal | null = null, - in15: IOperationOrSignal | null = null, - in16: IOperationOrSignal | null = null, - in17: IOperationOrSignal | null = null, - in18: IOperationOrSignal | null = null, - in19: IOperationOrSignal | null = null, - in20: IOperationOrSignal | null = null, - in21: IOperationOrSignal | null = null, - in22: IOperationOrSignal | null = null, - in23: IOperationOrSignal | null = null, - in24: IOperationOrSignal | null = null, - in25: IOperationOrSignal | null = null, - in26: IOperationOrSignal | null = null, - in27: IOperationOrSignal | null = null, - in28: IOperationOrSignal | null = null, - in29: IOperationOrSignal | null = null, - in30: IOperationOrSignal | null = null, - in31: IOperationOrSignal | null = null, - in32: IOperationOrSignal | null = null, - in33: IOperationOrSignal | null = null, - in34: IOperationOrSignal | null = null, - in35: IOperationOrSignal | null = null, - in36: IOperationOrSignal | null = null, - in37: IOperationOrSignal | null = null, - in38: IOperationOrSignal | null = null, - in39: IOperationOrSignal | null = null, - in40: IOperationOrSignal | null = null, - in41: IOperationOrSignal | null = null, - in42: IOperationOrSignal | null = null, - in43: IOperationOrSignal | null = null, - in44: IOperationOrSignal | null = null, - in45: IOperationOrSignal | null = null, - in46: IOperationOrSignal | null = null, - in47: IOperationOrSignal | null = null, - in48: IOperationOrSignal | null = null, - in49: IOperationOrSignal | null = null, - in50: IOperationOrSignal | null = null, - out1: IOperationOrSignal | null = null, - eno: IOperationOrSignal | null = null, - ) { - super('Add', eno); + constructor(options: AddCallOptions) { + const { type, in1, in2, out1 = null, eno = null } = options; + super({ functionName: 'Add', eno }); this.disableEno = true; this.type = type; this.iface['IN1'] = new IOperationOrSignalDirectionWrapper(in1, Direction.Input); this.iface['IN2'] = new IOperationOrSignalDirectionWrapper(in2, Direction.Input); - this.iface['IN3'] = new IOperationOrSignalDirectionWrapper(in3, Direction.Input); - this.iface['IN4'] = new IOperationOrSignalDirectionWrapper(in4, Direction.Input); - this.iface['IN5'] = new IOperationOrSignalDirectionWrapper(in5, Direction.Input); - this.iface['IN6'] = new IOperationOrSignalDirectionWrapper(in6, Direction.Input); - this.iface['IN7'] = new IOperationOrSignalDirectionWrapper(in7, Direction.Input); - this.iface['IN8'] = new IOperationOrSignalDirectionWrapper(in8, Direction.Input); - this.iface['IN9'] = new IOperationOrSignalDirectionWrapper(in9, Direction.Input); - this.iface['IN10'] = new IOperationOrSignalDirectionWrapper(in10, Direction.Input); - this.iface['IN11'] = new IOperationOrSignalDirectionWrapper(in11, Direction.Input); - this.iface['IN12'] = new IOperationOrSignalDirectionWrapper(in12, Direction.Input); - this.iface['IN13'] = new IOperationOrSignalDirectionWrapper(in13, Direction.Input); - this.iface['IN14'] = new IOperationOrSignalDirectionWrapper(in14, Direction.Input); - this.iface['IN15'] = new IOperationOrSignalDirectionWrapper(in15, Direction.Input); - this.iface['IN16'] = new IOperationOrSignalDirectionWrapper(in16, Direction.Input); - this.iface['IN17'] = new IOperationOrSignalDirectionWrapper(in17, Direction.Input); - this.iface['IN18'] = new IOperationOrSignalDirectionWrapper(in18, Direction.Input); - this.iface['IN19'] = new IOperationOrSignalDirectionWrapper(in19, Direction.Input); - this.iface['IN20'] = new IOperationOrSignalDirectionWrapper(in20, Direction.Input); - this.iface['IN21'] = new IOperationOrSignalDirectionWrapper(in21, Direction.Input); - this.iface['IN22'] = new IOperationOrSignalDirectionWrapper(in22, Direction.Input); - this.iface['IN23'] = new IOperationOrSignalDirectionWrapper(in23, Direction.Input); - this.iface['IN24'] = new IOperationOrSignalDirectionWrapper(in24, Direction.Input); - this.iface['IN25'] = new IOperationOrSignalDirectionWrapper(in25, Direction.Input); - this.iface['IN26'] = new IOperationOrSignalDirectionWrapper(in26, Direction.Input); - this.iface['IN27'] = new IOperationOrSignalDirectionWrapper(in27, Direction.Input); - this.iface['IN28'] = new IOperationOrSignalDirectionWrapper(in28, Direction.Input); - this.iface['IN29'] = new IOperationOrSignalDirectionWrapper(in29, Direction.Input); - this.iface['IN30'] = new IOperationOrSignalDirectionWrapper(in30, Direction.Input); - this.iface['IN31'] = new IOperationOrSignalDirectionWrapper(in31, Direction.Input); - this.iface['IN32'] = new IOperationOrSignalDirectionWrapper(in32, Direction.Input); - this.iface['IN33'] = new IOperationOrSignalDirectionWrapper(in33, Direction.Input); - this.iface['IN34'] = new IOperationOrSignalDirectionWrapper(in34, Direction.Input); - this.iface['IN35'] = new IOperationOrSignalDirectionWrapper(in35, Direction.Input); - this.iface['IN36'] = new IOperationOrSignalDirectionWrapper(in36, Direction.Input); - this.iface['IN37'] = new IOperationOrSignalDirectionWrapper(in37, Direction.Input); - this.iface['IN38'] = new IOperationOrSignalDirectionWrapper(in38, Direction.Input); - this.iface['IN39'] = new IOperationOrSignalDirectionWrapper(in39, Direction.Input); - this.iface['IN40'] = new IOperationOrSignalDirectionWrapper(in40, Direction.Input); - this.iface['IN41'] = new IOperationOrSignalDirectionWrapper(in41, Direction.Input); - this.iface['IN42'] = new IOperationOrSignalDirectionWrapper(in42, Direction.Input); - this.iface['IN43'] = new IOperationOrSignalDirectionWrapper(in43, Direction.Input); - this.iface['IN44'] = new IOperationOrSignalDirectionWrapper(in44, Direction.Input); - this.iface['IN45'] = new IOperationOrSignalDirectionWrapper(in45, Direction.Input); - this.iface['IN46'] = new IOperationOrSignalDirectionWrapper(in46, Direction.Input); - this.iface['IN47'] = new IOperationOrSignalDirectionWrapper(in47, Direction.Input); - this.iface['IN48'] = new IOperationOrSignalDirectionWrapper(in48, Direction.Input); - this.iface['IN49'] = new IOperationOrSignalDirectionWrapper(in49, Direction.Input); - this.iface['IN50'] = new IOperationOrSignalDirectionWrapper(in50, Direction.Input); + this.addVariableInputs(options, 3, 50); this.iface['OUT'] = new IOperationOrSignalDirectionWrapper(out1, Direction.Output); for (const w of Object.values(this.iface)) { diff --git a/TiaCodegen-ts/src/Commands/Functions/Arithmetic/ArithmeticCall.ts b/TiaCodegen-ts/src/Commands/Functions/Arithmetic/ArithmeticCall.ts index 91c6e9e..6c127b2 100644 --- a/TiaCodegen-ts/src/Commands/Functions/Arithmetic/ArithmeticCall.ts +++ b/TiaCodegen-ts/src/Commands/Functions/Arithmetic/ArithmeticCall.ts @@ -1,10 +1,11 @@ -import { IOperationOrSignal } from '../../../Interfaces/IOperationOrSignal.js'; -import { SystemFunctionCall } from '../Base/SystemFunctionCall.js'; +import { SystemFunctionCall, SystemFunctionCallOptions } from '../Base/SystemFunctionCall.js'; + +export interface ArithmeticCallOptions extends SystemFunctionCallOptions {} export abstract class ArithmeticCall extends SystemFunctionCall { type: string = ''; - constructor(functionName: string, eno: IOperationOrSignal | null = null) { - super(functionName, eno); + constructor(options: ArithmeticCallOptions) { + super(options); } } diff --git a/TiaCodegen-ts/src/Commands/Functions/Arithmetic/DivCall.ts b/TiaCodegen-ts/src/Commands/Functions/Arithmetic/DivCall.ts index 7efbc76..5ce35c7 100644 --- a/TiaCodegen-ts/src/Commands/Functions/Arithmetic/DivCall.ts +++ b/TiaCodegen-ts/src/Commands/Functions/Arithmetic/DivCall.ts @@ -3,15 +3,18 @@ import { IOperationOrSignalDirectionWrapper } from '../../../Interfaces/IOperati import { Direction } from '../../../Enums/Direction.js'; import { ArithmeticCall } from './ArithmeticCall.js'; +export interface DivCallOptions { + type: string; + in1: IOperationOrSignal; + in2: IOperationOrSignal; + out1?: IOperationOrSignal | null; + eno?: IOperationOrSignal | null; +} + export class DivCall extends ArithmeticCall { - constructor( - type: string, - in1: IOperationOrSignal, - in2: IOperationOrSignal, - out1: IOperationOrSignal | null = null, - eno: IOperationOrSignal | null = null, - ) { - super('Div', eno); + constructor(options: DivCallOptions) { + const { type, in1, in2, out1 = null, eno = null } = options; + super({ functionName: 'Div', eno }); this.disableEno = true; this.type = type; this.iface['IN1'] = new IOperationOrSignalDirectionWrapper(in1, Direction.Input); diff --git a/TiaCodegen-ts/src/Commands/Functions/Arithmetic/ModCall.ts b/TiaCodegen-ts/src/Commands/Functions/Arithmetic/ModCall.ts index f291889..aaf4177 100644 --- a/TiaCodegen-ts/src/Commands/Functions/Arithmetic/ModCall.ts +++ b/TiaCodegen-ts/src/Commands/Functions/Arithmetic/ModCall.ts @@ -3,15 +3,18 @@ import { IOperationOrSignalDirectionWrapper } from '../../../Interfaces/IOperati import { Direction } from '../../../Enums/Direction.js'; import { ArithmeticCall } from './ArithmeticCall.js'; +export interface ModCallOptions { + type: string; + in1: IOperationOrSignal; + in2: IOperationOrSignal; + out1?: IOperationOrSignal | null; + eno?: IOperationOrSignal | null; +} + export class ModCall extends ArithmeticCall { - constructor( - type: string, - in1: IOperationOrSignal, - in2: IOperationOrSignal, - out1: IOperationOrSignal | null = null, - eno: IOperationOrSignal | null = null, - ) { - super('Mod', eno); + constructor(options: ModCallOptions) { + const { type, in1, in2, out1 = null, eno = null } = options; + super({ functionName: 'Mod', eno }); this.disableEno = true; this.type = type; this.iface['IN1'] = new IOperationOrSignalDirectionWrapper(in1, Direction.Input); diff --git a/TiaCodegen-ts/src/Commands/Functions/Arithmetic/MulCall.ts b/TiaCodegen-ts/src/Commands/Functions/Arithmetic/MulCall.ts index 6708dfd..a71a6fa 100644 --- a/TiaCodegen-ts/src/Commands/Functions/Arithmetic/MulCall.ts +++ b/TiaCodegen-ts/src/Commands/Functions/Arithmetic/MulCall.ts @@ -3,115 +3,71 @@ import { IOperationOrSignalDirectionWrapper } from '../../../Interfaces/IOperati import { Direction } from '../../../Enums/Direction.js'; import { VariableArithmeticCall } from './VariableArithmeticCall.js'; +export interface MulCallOptions { + type: string; + in1: IOperationOrSignal; + in2: IOperationOrSignal; + in3?: IOperationOrSignal | null; + in4?: IOperationOrSignal | null; + in5?: IOperationOrSignal | null; + in6?: IOperationOrSignal | null; + in7?: IOperationOrSignal | null; + in8?: IOperationOrSignal | null; + in9?: IOperationOrSignal | null; + in10?: IOperationOrSignal | null; + in11?: IOperationOrSignal | null; + in12?: IOperationOrSignal | null; + in13?: IOperationOrSignal | null; + in14?: IOperationOrSignal | null; + in15?: IOperationOrSignal | null; + in16?: IOperationOrSignal | null; + in17?: IOperationOrSignal | null; + in18?: IOperationOrSignal | null; + in19?: IOperationOrSignal | null; + in20?: IOperationOrSignal | null; + in21?: IOperationOrSignal | null; + in22?: IOperationOrSignal | null; + in23?: IOperationOrSignal | null; + in24?: IOperationOrSignal | null; + in25?: IOperationOrSignal | null; + in26?: IOperationOrSignal | null; + in27?: IOperationOrSignal | null; + in28?: IOperationOrSignal | null; + in29?: IOperationOrSignal | null; + in30?: IOperationOrSignal | null; + in31?: IOperationOrSignal | null; + in32?: IOperationOrSignal | null; + in33?: IOperationOrSignal | null; + in34?: IOperationOrSignal | null; + in35?: IOperationOrSignal | null; + in36?: IOperationOrSignal | null; + in37?: IOperationOrSignal | null; + in38?: IOperationOrSignal | null; + in39?: IOperationOrSignal | null; + in40?: IOperationOrSignal | null; + in41?: IOperationOrSignal | null; + in42?: IOperationOrSignal | null; + in43?: IOperationOrSignal | null; + in44?: IOperationOrSignal | null; + in45?: IOperationOrSignal | null; + in46?: IOperationOrSignal | null; + in47?: IOperationOrSignal | null; + in48?: IOperationOrSignal | null; + in49?: IOperationOrSignal | null; + in50?: IOperationOrSignal | null; + out1?: IOperationOrSignal | null; + eno?: IOperationOrSignal | null; +} + export class MulCall extends VariableArithmeticCall { - constructor( - type: string, - in1: IOperationOrSignal, - in2: IOperationOrSignal, - in3: IOperationOrSignal | null = null, - in4: IOperationOrSignal | null = null, - in5: IOperationOrSignal | null = null, - in6: IOperationOrSignal | null = null, - in7: IOperationOrSignal | null = null, - in8: IOperationOrSignal | null = null, - in9: IOperationOrSignal | null = null, - in10: IOperationOrSignal | null = null, - in11: IOperationOrSignal | null = null, - in12: IOperationOrSignal | null = null, - in13: IOperationOrSignal | null = null, - in14: IOperationOrSignal | null = null, - in15: IOperationOrSignal | null = null, - in16: IOperationOrSignal | null = null, - in17: IOperationOrSignal | null = null, - in18: IOperationOrSignal | null = null, - in19: IOperationOrSignal | null = null, - in20: IOperationOrSignal | null = null, - in21: IOperationOrSignal | null = null, - in22: IOperationOrSignal | null = null, - in23: IOperationOrSignal | null = null, - in24: IOperationOrSignal | null = null, - in25: IOperationOrSignal | null = null, - in26: IOperationOrSignal | null = null, - in27: IOperationOrSignal | null = null, - in28: IOperationOrSignal | null = null, - in29: IOperationOrSignal | null = null, - in30: IOperationOrSignal | null = null, - in31: IOperationOrSignal | null = null, - in32: IOperationOrSignal | null = null, - in33: IOperationOrSignal | null = null, - in34: IOperationOrSignal | null = null, - in35: IOperationOrSignal | null = null, - in36: IOperationOrSignal | null = null, - in37: IOperationOrSignal | null = null, - in38: IOperationOrSignal | null = null, - in39: IOperationOrSignal | null = null, - in40: IOperationOrSignal | null = null, - in41: IOperationOrSignal | null = null, - in42: IOperationOrSignal | null = null, - in43: IOperationOrSignal | null = null, - in44: IOperationOrSignal | null = null, - in45: IOperationOrSignal | null = null, - in46: IOperationOrSignal | null = null, - in47: IOperationOrSignal | null = null, - in48: IOperationOrSignal | null = null, - in49: IOperationOrSignal | null = null, - in50: IOperationOrSignal | null = null, - out1: IOperationOrSignal | null = null, - eno: IOperationOrSignal | null = null, - ) { - super('Mul', eno); + constructor(options: MulCallOptions) { + const { type, in1, in2, out1 = null, eno = null } = options; + super({ functionName: 'Mul', eno }); this.disableEno = true; this.type = type; this.iface['IN1'] = new IOperationOrSignalDirectionWrapper(in1, Direction.Input); this.iface['IN2'] = new IOperationOrSignalDirectionWrapper(in2, Direction.Input); - this.iface['IN3'] = new IOperationOrSignalDirectionWrapper(in3, Direction.Input); - this.iface['IN4'] = new IOperationOrSignalDirectionWrapper(in4, Direction.Input); - this.iface['IN5'] = new IOperationOrSignalDirectionWrapper(in5, Direction.Input); - this.iface['IN6'] = new IOperationOrSignalDirectionWrapper(in6, Direction.Input); - this.iface['IN7'] = new IOperationOrSignalDirectionWrapper(in7, Direction.Input); - this.iface['IN8'] = new IOperationOrSignalDirectionWrapper(in8, Direction.Input); - this.iface['IN9'] = new IOperationOrSignalDirectionWrapper(in9, Direction.Input); - this.iface['IN10'] = new IOperationOrSignalDirectionWrapper(in10, Direction.Input); - this.iface['IN11'] = new IOperationOrSignalDirectionWrapper(in11, Direction.Input); - this.iface['IN12'] = new IOperationOrSignalDirectionWrapper(in12, Direction.Input); - this.iface['IN13'] = new IOperationOrSignalDirectionWrapper(in13, Direction.Input); - this.iface['IN14'] = new IOperationOrSignalDirectionWrapper(in14, Direction.Input); - this.iface['IN15'] = new IOperationOrSignalDirectionWrapper(in15, Direction.Input); - this.iface['IN16'] = new IOperationOrSignalDirectionWrapper(in16, Direction.Input); - this.iface['IN17'] = new IOperationOrSignalDirectionWrapper(in17, Direction.Input); - this.iface['IN18'] = new IOperationOrSignalDirectionWrapper(in18, Direction.Input); - this.iface['IN19'] = new IOperationOrSignalDirectionWrapper(in19, Direction.Input); - this.iface['IN20'] = new IOperationOrSignalDirectionWrapper(in20, Direction.Input); - this.iface['IN21'] = new IOperationOrSignalDirectionWrapper(in21, Direction.Input); - this.iface['IN22'] = new IOperationOrSignalDirectionWrapper(in22, Direction.Input); - this.iface['IN23'] = new IOperationOrSignalDirectionWrapper(in23, Direction.Input); - this.iface['IN24'] = new IOperationOrSignalDirectionWrapper(in24, Direction.Input); - this.iface['IN25'] = new IOperationOrSignalDirectionWrapper(in25, Direction.Input); - this.iface['IN26'] = new IOperationOrSignalDirectionWrapper(in26, Direction.Input); - this.iface['IN27'] = new IOperationOrSignalDirectionWrapper(in27, Direction.Input); - this.iface['IN28'] = new IOperationOrSignalDirectionWrapper(in28, Direction.Input); - this.iface['IN29'] = new IOperationOrSignalDirectionWrapper(in29, Direction.Input); - this.iface['IN30'] = new IOperationOrSignalDirectionWrapper(in30, Direction.Input); - this.iface['IN31'] = new IOperationOrSignalDirectionWrapper(in31, Direction.Input); - this.iface['IN32'] = new IOperationOrSignalDirectionWrapper(in32, Direction.Input); - this.iface['IN33'] = new IOperationOrSignalDirectionWrapper(in33, Direction.Input); - this.iface['IN34'] = new IOperationOrSignalDirectionWrapper(in34, Direction.Input); - this.iface['IN35'] = new IOperationOrSignalDirectionWrapper(in35, Direction.Input); - this.iface['IN36'] = new IOperationOrSignalDirectionWrapper(in36, Direction.Input); - this.iface['IN37'] = new IOperationOrSignalDirectionWrapper(in37, Direction.Input); - this.iface['IN38'] = new IOperationOrSignalDirectionWrapper(in38, Direction.Input); - this.iface['IN39'] = new IOperationOrSignalDirectionWrapper(in39, Direction.Input); - this.iface['IN40'] = new IOperationOrSignalDirectionWrapper(in40, Direction.Input); - this.iface['IN41'] = new IOperationOrSignalDirectionWrapper(in41, Direction.Input); - this.iface['IN42'] = new IOperationOrSignalDirectionWrapper(in42, Direction.Input); - this.iface['IN43'] = new IOperationOrSignalDirectionWrapper(in43, Direction.Input); - this.iface['IN44'] = new IOperationOrSignalDirectionWrapper(in44, Direction.Input); - this.iface['IN45'] = new IOperationOrSignalDirectionWrapper(in45, Direction.Input); - this.iface['IN46'] = new IOperationOrSignalDirectionWrapper(in46, Direction.Input); - this.iface['IN47'] = new IOperationOrSignalDirectionWrapper(in47, Direction.Input); - this.iface['IN48'] = new IOperationOrSignalDirectionWrapper(in48, Direction.Input); - this.iface['IN49'] = new IOperationOrSignalDirectionWrapper(in49, Direction.Input); - this.iface['IN50'] = new IOperationOrSignalDirectionWrapper(in50, Direction.Input); + this.addVariableInputs(options, 3, 50); this.iface['OUT'] = new IOperationOrSignalDirectionWrapper(out1, Direction.Output); for (const w of Object.values(this.iface)) { diff --git a/TiaCodegen-ts/src/Commands/Functions/Arithmetic/SubCall.ts b/TiaCodegen-ts/src/Commands/Functions/Arithmetic/SubCall.ts index 5b99280..0c124cb 100644 --- a/TiaCodegen-ts/src/Commands/Functions/Arithmetic/SubCall.ts +++ b/TiaCodegen-ts/src/Commands/Functions/Arithmetic/SubCall.ts @@ -3,15 +3,18 @@ import { IOperationOrSignalDirectionWrapper } from '../../../Interfaces/IOperati import { Direction } from '../../../Enums/Direction.js'; import { ArithmeticCall } from './ArithmeticCall.js'; +export interface SubCallOptions { + type: string; + in1: IOperationOrSignal; + in2: IOperationOrSignal; + out1?: IOperationOrSignal | null; + eno?: IOperationOrSignal | null; +} + export class SubCall extends ArithmeticCall { - constructor( - type: string, - in1: IOperationOrSignal, - in2: IOperationOrSignal, - out1: IOperationOrSignal | null = null, - eno: IOperationOrSignal | null = null, - ) { - super('Sub', eno); + constructor(options: SubCallOptions) { + const { type, in1, in2, out1 = null, eno = null } = options; + super({ functionName: 'Sub', eno }); this.disableEno = true; this.type = type; this.iface['IN1'] = new IOperationOrSignalDirectionWrapper(in1, Direction.Input); diff --git a/TiaCodegen-ts/src/Commands/Functions/Arithmetic/VariableArithmeticCall.ts b/TiaCodegen-ts/src/Commands/Functions/Arithmetic/VariableArithmeticCall.ts index 2133fdf..683c919 100644 --- a/TiaCodegen-ts/src/Commands/Functions/Arithmetic/VariableArithmeticCall.ts +++ b/TiaCodegen-ts/src/Commands/Functions/Arithmetic/VariableArithmeticCall.ts @@ -1,8 +1,19 @@ import { IOperationOrSignal } from '../../../Interfaces/IOperationOrSignal.js'; -import { ArithmeticCall } from './ArithmeticCall.js'; +import { IOperationOrSignalDirectionWrapper } from '../../../Interfaces/IOperationOrSignalDirectionWrapper.js'; +import { Direction } from '../../../Enums/Direction.js'; +import { ArithmeticCall, ArithmeticCallOptions } from './ArithmeticCall.js'; + +export interface VariableArithmeticCallOptions extends ArithmeticCallOptions {} export abstract class VariableArithmeticCall extends ArithmeticCall { - constructor(functionName: string, eno: IOperationOrSignal | null = null) { - super(functionName, eno); + constructor(options: VariableArithmeticCallOptions) { + super(options); + } + + protected addVariableInputs(options: object, startIndex: number, endIndex: number): void { + for (let i = startIndex; i <= endIndex; i++) { + const value = ((options as Record)[`in${i}`] as IOperationOrSignal | null | undefined) ?? null; + this.iface[`IN${i}`] = new IOperationOrSignalDirectionWrapper(value, Direction.Input); + } } } diff --git a/TiaCodegen-ts/src/Commands/Functions/Base/FunctionBlockCall.ts b/TiaCodegen-ts/src/Commands/Functions/Base/FunctionBlockCall.ts index 8c20ffb..bb09961 100644 --- a/TiaCodegen-ts/src/Commands/Functions/Base/FunctionBlockCall.ts +++ b/TiaCodegen-ts/src/Commands/Functions/Base/FunctionBlockCall.ts @@ -1,11 +1,18 @@ import { IOperationOrSignal } from '../../../Interfaces/IOperationOrSignal.js'; import { FunctionCall } from './FunctionCall.js'; +export interface FunctionBlockCallOptions { + functionName: string; + instanceName: string; + eno?: IOperationOrSignal | null; +} + export class FunctionBlockCall extends FunctionCall { instanceName: string; - constructor(functionName: string, instanceName: string, eno: IOperationOrSignal | null = null) { - super(functionName, eno); + constructor(options: FunctionBlockCallOptions) { + const { functionName, instanceName, eno = null } = options; + super({ functionName, eno }); this.instanceName = instanceName; } } diff --git a/TiaCodegen-ts/src/Commands/Functions/Base/FunctionCall.ts b/TiaCodegen-ts/src/Commands/Functions/Base/FunctionCall.ts index ed2904a..402802b 100644 --- a/TiaCodegen-ts/src/Commands/Functions/Base/FunctionCall.ts +++ b/TiaCodegen-ts/src/Commands/Functions/Base/FunctionCall.ts @@ -2,6 +2,11 @@ import { IOperationOrSignal } from '../../../Interfaces/IOperationOrSignal.js'; import { IOperationOrSignalDirectionWrapper } from '../../../Interfaces/IOperationOrSignalDirectionWrapper.js'; import { Direction } from '../../../Enums/Direction.js'; +export interface FunctionCallOptions { + functionName: string; + eno?: IOperationOrSignal | null; +} + export class FunctionCall implements IOperationOrSignal { safetyTemplateString: string | null = null; debugInfo: string | null = null; @@ -20,7 +25,8 @@ export class FunctionCall implements IOperationOrSignal { cardinality: number = 0; hasNoEn: boolean = false; - constructor(functionName: string, eno: IOperationOrSignal | null = null) { + constructor(options: FunctionCallOptions) { + const { functionName, eno = null } = options; this.functionName = functionName; this.iface = {}; this.children = []; diff --git a/TiaCodegen-ts/src/Commands/Functions/Base/SystemFunctionBlockCall.ts b/TiaCodegen-ts/src/Commands/Functions/Base/SystemFunctionBlockCall.ts index 6a71454..207e588 100644 --- a/TiaCodegen-ts/src/Commands/Functions/Base/SystemFunctionBlockCall.ts +++ b/TiaCodegen-ts/src/Commands/Functions/Base/SystemFunctionBlockCall.ts @@ -1,12 +1,13 @@ -import { IOperationOrSignal } from '../../../Interfaces/IOperationOrSignal.js'; -import { FunctionBlockCall } from './FunctionBlockCall.js'; +import { FunctionBlockCall, FunctionBlockCallOptions } from './FunctionBlockCall.js'; + +export interface SystemFunctionBlockCallOptions extends FunctionBlockCallOptions {} export class SystemFunctionBlockCall extends FunctionBlockCall { templateValueName: string | null = null; templateValueType: string | null = null; templateValue: string | null = null; - constructor(functionName: string, instanceName: string, eno: IOperationOrSignal | null = null) { - super(functionName, instanceName, eno); + constructor(options: SystemFunctionBlockCallOptions) { + super(options); } } diff --git a/TiaCodegen-ts/src/Commands/Functions/Base/SystemFunctionCall.ts b/TiaCodegen-ts/src/Commands/Functions/Base/SystemFunctionCall.ts index 0ef7899..312f773 100644 --- a/TiaCodegen-ts/src/Commands/Functions/Base/SystemFunctionCall.ts +++ b/TiaCodegen-ts/src/Commands/Functions/Base/SystemFunctionCall.ts @@ -1,8 +1,9 @@ -import { IOperationOrSignal } from '../../../Interfaces/IOperationOrSignal.js'; -import { FunctionCall } from './FunctionCall.js'; +import { FunctionCall, FunctionCallOptions } from './FunctionCall.js'; + +export interface SystemFunctionCallOptions extends FunctionCallOptions {} export class SystemFunctionCall extends FunctionCall { - constructor(functionName: string, eno: IOperationOrSignal | null = null) { - super(functionName, eno); + constructor(options: SystemFunctionCallOptions) { + super(options); } } diff --git a/TiaCodegen-ts/src/Commands/Functions/CTUCall.ts b/TiaCodegen-ts/src/Commands/Functions/CTUCall.ts index 287151a..7293cee 100644 --- a/TiaCodegen-ts/src/Commands/Functions/CTUCall.ts +++ b/TiaCodegen-ts/src/Commands/Functions/CTUCall.ts @@ -3,16 +3,19 @@ import { IOperationOrSignalDirectionWrapper } from '../../Interfaces/IOperationO import { Direction } from '../../Enums/Direction.js'; import { SystemFunctionBlockCall } from './Base/SystemFunctionBlockCall.js'; +export interface CTUCallOptions { + instanceName: string; + r?: IOperationOrSignal | null; + pv?: IOperationOrSignal | null; + q?: IOperationOrSignal | null; + cv?: IOperationOrSignal | null; + templateValue?: string; +} + export class CTUCall extends SystemFunctionBlockCall { - constructor( - instanceName: string, - r: IOperationOrSignal | null = null, - pv: IOperationOrSignal | null = null, - q: IOperationOrSignal | null = null, - cv: IOperationOrSignal | null = null, - templateValue: string = 'Int', - ) { - super('CTU', instanceName, null); + constructor(options: CTUCallOptions) { + const { instanceName, r = null, pv = null, q = null, cv = null, templateValue = 'Int' } = options; + super({ functionName: 'CTU', instanceName }); this.iface['R'] = new IOperationOrSignalDirectionWrapper(r, Direction.Input); this.iface['PV'] = new IOperationOrSignalDirectionWrapper(pv, Direction.Input); this.iface['Q'] = new IOperationOrSignalDirectionWrapper(q, Direction.Output); diff --git a/TiaCodegen-ts/src/Commands/Functions/CTUDCall.ts b/TiaCodegen-ts/src/Commands/Functions/CTUDCall.ts index 3e4531e..5649588 100644 --- a/TiaCodegen-ts/src/Commands/Functions/CTUDCall.ts +++ b/TiaCodegen-ts/src/Commands/Functions/CTUDCall.ts @@ -3,19 +3,22 @@ import { IOperationOrSignalDirectionWrapper } from '../../Interfaces/IOperationO import { Direction } from '../../Enums/Direction.js'; import { SystemFunctionBlockCall } from './Base/SystemFunctionBlockCall.js'; +export interface CTUDCallOptions { + instanceName: string; + cd?: IOperationOrSignal | null; + r?: IOperationOrSignal | null; + ld?: IOperationOrSignal | null; + pv?: IOperationOrSignal | null; + qu?: IOperationOrSignal | null; + qd?: IOperationOrSignal | null; + cv?: IOperationOrSignal | null; + templateValue?: string; +} + export class CTUDCall extends SystemFunctionBlockCall { - constructor( - instanceName: string, - cd: IOperationOrSignal | null = null, - r: IOperationOrSignal | null = null, - ld: IOperationOrSignal | null = null, - pv: IOperationOrSignal | null = null, - qu: IOperationOrSignal | null = null, - qd: IOperationOrSignal | null = null, - cv: IOperationOrSignal | null = null, - templateValue: string = 'Int', - ) { - super('CTUD', instanceName, null); + constructor(options: CTUDCallOptions) { + const { instanceName, cd = null, r = null, ld = null, pv = null, qu = null, qd = null, cv = null, templateValue = 'Int' } = options; + super({ functionName: 'CTUD', instanceName }); this.iface['CD'] = new IOperationOrSignalDirectionWrapper(cd, Direction.Input); this.iface['R'] = new IOperationOrSignalDirectionWrapper(r, Direction.Input); this.iface['LD'] = new IOperationOrSignalDirectionWrapper(ld, Direction.Input); diff --git a/TiaCodegen-ts/src/Commands/Functions/FDBACKCall.ts b/TiaCodegen-ts/src/Commands/Functions/FDBACKCall.ts index b80e599..09bbb29 100644 --- a/TiaCodegen-ts/src/Commands/Functions/FDBACKCall.ts +++ b/TiaCodegen-ts/src/Commands/Functions/FDBACKCall.ts @@ -3,21 +3,36 @@ import { IOperationOrSignalDirectionWrapper } from '../../Interfaces/IOperationO import { Direction } from '../../Enums/Direction.js'; import { SystemFunctionBlockCall } from './Base/SystemFunctionBlockCall.js'; +export interface FDBACKCallOptions { + instanceName: string; + on?: IOperationOrSignal | null; + feedback?: IOperationOrSignal | null; + qbad_fio?: IOperationOrSignal | null; + ack_nec?: IOperationOrSignal | null; + ack?: IOperationOrSignal | null; + fdb_time?: IOperationOrSignal | null; + q?: IOperationOrSignal | null; + error?: IOperationOrSignal | null; + ack_req?: IOperationOrSignal | null; + diag?: IOperationOrSignal | null; +} + export class FDBACKCall extends SystemFunctionBlockCall { - constructor( - instanceName: string, - on: IOperationOrSignal | null = null, - feedback: IOperationOrSignal | null = null, - qbad_fio: IOperationOrSignal | null = null, - ack_nec: IOperationOrSignal | null = null, - ack: IOperationOrSignal | null = null, - fdb_time: IOperationOrSignal | null = null, - q: IOperationOrSignal | null = null, - error: IOperationOrSignal | null = null, - ack_req: IOperationOrSignal | null = null, - diag: IOperationOrSignal | null = null, - ) { - super('FDBACK', instanceName, null); + constructor(options: FDBACKCallOptions) { + const { + instanceName, + on = null, + feedback = null, + qbad_fio = null, + ack_nec = null, + ack = null, + fdb_time = null, + q = null, + error = null, + ack_req = null, + diag = null, + } = options; + super({ functionName: 'FDBACK', instanceName }); this.iface['ON'] = new IOperationOrSignalDirectionWrapper(on, Direction.Input); this.iface['FEEDBACK'] = new IOperationOrSignalDirectionWrapper(feedback, Direction.Input); this.iface['QBAD_FIO'] = new IOperationOrSignalDirectionWrapper(qbad_fio, Direction.Input); diff --git a/TiaCodegen-ts/src/Commands/Functions/FTrigCall.ts b/TiaCodegen-ts/src/Commands/Functions/FTrigCall.ts index 24ab1f2..39d91a3 100644 --- a/TiaCodegen-ts/src/Commands/Functions/FTrigCall.ts +++ b/TiaCodegen-ts/src/Commands/Functions/FTrigCall.ts @@ -3,14 +3,17 @@ import { IOperationOrSignalDirectionWrapper } from '../../Interfaces/IOperationO import { Direction } from '../../Enums/Direction.js'; import { SystemFunctionBlockCall } from './Base/SystemFunctionBlockCall.js'; +export interface FTrigCallOptions { + instanceName: string; + clk?: IOperationOrSignal | null; + q?: IOperationOrSignal | null; + eno?: IOperationOrSignal | null; +} + export class FTrigCall extends SystemFunctionBlockCall { - constructor( - instanceName: string, - clk: IOperationOrSignal | null = null, - q: IOperationOrSignal | null = null, - eno: IOperationOrSignal | null = null, - ) { - super('F_TRIG', instanceName, eno); + constructor(options: FTrigCallOptions) { + const { instanceName, clk = null, q = null, eno = null } = options; + super({ functionName: 'F_TRIG', instanceName, eno }); this.iface['CLK'] = new IOperationOrSignalDirectionWrapper(clk, Direction.Input); this.iface['Q'] = new IOperationOrSignalDirectionWrapper(q, Direction.Output); diff --git a/TiaCodegen-ts/src/Commands/Functions/NTrigCall.ts b/TiaCodegen-ts/src/Commands/Functions/NTrigCall.ts index acde17b..c63caf8 100644 --- a/TiaCodegen-ts/src/Commands/Functions/NTrigCall.ts +++ b/TiaCodegen-ts/src/Commands/Functions/NTrigCall.ts @@ -2,10 +2,15 @@ import { Signal } from '../Signals/Signal.js'; import { IPartName } from '../../Interfaces/IPartName.js'; import { BaseNPCoil } from '../Coils/BaseNPCoil.js'; +export interface NTrigCallOptions { + signal: Signal; +} + export class NTrigCall extends BaseNPCoil implements IPartName { partName: string; - constructor(signal: Signal) { + constructor(options: NTrigCallOptions) { + const { signal } = options; super(signal, null, null); this.partName = 'NBox'; } diff --git a/TiaCodegen-ts/src/Commands/Functions/PTrigCall.ts b/TiaCodegen-ts/src/Commands/Functions/PTrigCall.ts index 8861f3d..d4e5942 100644 --- a/TiaCodegen-ts/src/Commands/Functions/PTrigCall.ts +++ b/TiaCodegen-ts/src/Commands/Functions/PTrigCall.ts @@ -2,10 +2,15 @@ import { Signal } from '../Signals/Signal.js'; import { IPartName } from '../../Interfaces/IPartName.js'; import { BaseNPCoil } from '../Coils/BaseNPCoil.js'; +export interface PTrigCallOptions { + signal: Signal; +} + export class PTrigCall extends BaseNPCoil implements IPartName { partName: string; - constructor(signal: Signal) { + constructor(options: PTrigCallOptions) { + const { signal } = options; super(signal, null, null); this.partName = 'PBox'; } diff --git a/TiaCodegen-ts/src/Commands/Functions/RTrigCall.ts b/TiaCodegen-ts/src/Commands/Functions/RTrigCall.ts index ebfcb28..eef1f34 100644 --- a/TiaCodegen-ts/src/Commands/Functions/RTrigCall.ts +++ b/TiaCodegen-ts/src/Commands/Functions/RTrigCall.ts @@ -3,14 +3,17 @@ import { IOperationOrSignalDirectionWrapper } from '../../Interfaces/IOperationO import { Direction } from '../../Enums/Direction.js'; import { SystemFunctionBlockCall } from './Base/SystemFunctionBlockCall.js'; +export interface RTrigCallOptions { + instanceName: string; + clk?: IOperationOrSignal | null; + q?: IOperationOrSignal | null; + eno?: IOperationOrSignal | null; +} + export class RTrigCall extends SystemFunctionBlockCall { - constructor( - instanceName: string, - clk: IOperationOrSignal | null = null, - q: IOperationOrSignal | null = null, - eno: IOperationOrSignal | null = null, - ) { - super('R_TRIG', instanceName, eno); + constructor(options: RTrigCallOptions) { + const { instanceName, clk = null, q = null, eno = null } = options; + super({ functionName: 'R_TRIG', instanceName, eno }); this.iface['CLK'] = new IOperationOrSignalDirectionWrapper(clk, Direction.Input); this.iface['Q'] = new IOperationOrSignalDirectionWrapper(q, Direction.Output); diff --git a/TiaCodegen-ts/src/Commands/Functions/TOFCall.ts b/TiaCodegen-ts/src/Commands/Functions/TOFCall.ts index 5f079b0..6e333e4 100644 --- a/TiaCodegen-ts/src/Commands/Functions/TOFCall.ts +++ b/TiaCodegen-ts/src/Commands/Functions/TOFCall.ts @@ -3,15 +3,17 @@ import { IOperationOrSignalDirectionWrapper } from '../../Interfaces/IOperationO import { Direction } from '../../Enums/Direction.js'; import { SystemFunctionBlockCall } from './Base/SystemFunctionBlockCall.js'; -export class TOFCall extends SystemFunctionBlockCall { - constructor( - instanceName: string, - pt: IOperationOrSignal | null = null, +export interface TOFCallOptions { + instanceName: string; + pt?: IOperationOrSignal | null; + q?: IOperationOrSignal | null; + et?: IOperationOrSignal | null; +} - q: IOperationOrSignal | null = null, - et: IOperationOrSignal | null = null, - ) { - super('TOF', instanceName, null); +export class TOFCall extends SystemFunctionBlockCall { + constructor(options: TOFCallOptions) { + const { instanceName, pt = null, q = null, et = null } = options; + super({ functionName: 'TOF', instanceName }); this.iface['PT'] = new IOperationOrSignalDirectionWrapper(pt, Direction.Input); this.iface['Q'] = new IOperationOrSignalDirectionWrapper(q, Direction.Output); diff --git a/TiaCodegen-ts/src/Commands/Functions/TONCall.ts b/TiaCodegen-ts/src/Commands/Functions/TONCall.ts index 53b1c4f..4184e23 100644 --- a/TiaCodegen-ts/src/Commands/Functions/TONCall.ts +++ b/TiaCodegen-ts/src/Commands/Functions/TONCall.ts @@ -3,15 +3,17 @@ import { IOperationOrSignalDirectionWrapper } from '../../Interfaces/IOperationO import { Direction } from '../../Enums/Direction.js'; import { SystemFunctionBlockCall } from './Base/SystemFunctionBlockCall.js'; -export class TONCall extends SystemFunctionBlockCall { - constructor( - instanceName: string, - pt: IOperationOrSignal | null = null, +export interface TONCallOptions { + instanceName: string; + pt?: IOperationOrSignal | null; + q?: IOperationOrSignal | null; + et?: IOperationOrSignal | null; +} - q: IOperationOrSignal | null = null, - et: IOperationOrSignal | null = null, - ) { - super('TON', instanceName, null); +export class TONCall extends SystemFunctionBlockCall { + constructor(options: TONCallOptions) { + const { instanceName, pt = null, q = null, et = null } = options; + super({ functionName: 'TON', instanceName }); this.iface['PT'] = new IOperationOrSignalDirectionWrapper(pt, Direction.Input); this.iface['Q'] = new IOperationOrSignalDirectionWrapper(q, Direction.Output); diff --git a/TiaCodegen-ts/src/Commands/Functions/TONRCall.ts b/TiaCodegen-ts/src/Commands/Functions/TONRCall.ts index 2a566ed..16247d6 100644 --- a/TiaCodegen-ts/src/Commands/Functions/TONRCall.ts +++ b/TiaCodegen-ts/src/Commands/Functions/TONRCall.ts @@ -3,15 +3,18 @@ import { IOperationOrSignalDirectionWrapper } from '../../Interfaces/IOperationO import { Direction } from '../../Enums/Direction.js'; import { SystemFunctionBlockCall } from './Base/SystemFunctionBlockCall.js'; +export interface TONRCallOptions { + instanceName: string; + pt?: IOperationOrSignal | null; + r?: IOperationOrSignal | null; + q?: IOperationOrSignal | null; + et?: IOperationOrSignal | null; +} + export class TONRCall extends SystemFunctionBlockCall { - constructor( - instanceName: string, - pt: IOperationOrSignal | null = null, - r: IOperationOrSignal | null = null, - q: IOperationOrSignal | null = null, - et: IOperationOrSignal | null = null, - ) { - super('TONR', instanceName, null); + constructor(options: TONRCallOptions) { + const { instanceName, pt = null, r = null, q = null, et = null } = options; + super({ functionName: 'TONR', instanceName }); this.iface['PT'] = new IOperationOrSignalDirectionWrapper(pt, Direction.Input); this.iface['R'] = new IOperationOrSignalDirectionWrapper(r, Direction.Input); this.iface['Q'] = new IOperationOrSignalDirectionWrapper(q, Direction.Output); diff --git a/TiaCodegen-ts/src/Commands/Functions/TPCall.ts b/TiaCodegen-ts/src/Commands/Functions/TPCall.ts index 4302cb3..6740a11 100644 --- a/TiaCodegen-ts/src/Commands/Functions/TPCall.ts +++ b/TiaCodegen-ts/src/Commands/Functions/TPCall.ts @@ -3,15 +3,17 @@ import { IOperationOrSignalDirectionWrapper } from '../../Interfaces/IOperationO import { Direction } from '../../Enums/Direction.js'; import { SystemFunctionBlockCall } from './Base/SystemFunctionBlockCall.js'; -export class TPCall extends SystemFunctionBlockCall { - constructor( - instanceName: string, - pt: IOperationOrSignal | null = null, +export interface TPCallOptions { + instanceName: string; + pt?: IOperationOrSignal | null; + q?: IOperationOrSignal | null; + et?: IOperationOrSignal | null; +} - q: IOperationOrSignal | null = null, - et: IOperationOrSignal | null = null, - ) { - super('TP', instanceName, null); +export class TPCall extends SystemFunctionBlockCall { + constructor(options: TPCallOptions) { + const { instanceName, pt = null, q = null, et = null } = options; + super({ functionName: 'TP', instanceName }); this.iface['PT'] = new IOperationOrSignalDirectionWrapper(pt, Direction.Input); this.iface['Q'] = new IOperationOrSignalDirectionWrapper(q, Direction.Output); diff --git a/TiaCodegen-ts/src/index.ts b/TiaCodegen-ts/src/index.ts index bed6d2a..3a4f52e 100644 --- a/TiaCodegen-ts/src/index.ts +++ b/TiaCodegen-ts/src/index.ts @@ -53,33 +53,33 @@ export { InRangeCall } from './Commands/Comparisons/InRangeCall.js'; export { OutRangeCall } from './Commands/Comparisons/OutRangeCall.js'; // Function Base -export { FunctionCall } from './Commands/Functions/Base/FunctionCall.js'; -export { FunctionBlockCall } from './Commands/Functions/Base/FunctionBlockCall.js'; -export { SystemFunctionCall } from './Commands/Functions/Base/SystemFunctionCall.js'; -export { SystemFunctionBlockCall } from './Commands/Functions/Base/SystemFunctionBlockCall.js'; +export { FunctionCall, type FunctionCallOptions } from './Commands/Functions/Base/FunctionCall.js'; +export { FunctionBlockCall, type FunctionBlockCallOptions } from './Commands/Functions/Base/FunctionBlockCall.js'; +export { SystemFunctionCall, type SystemFunctionCallOptions } from './Commands/Functions/Base/SystemFunctionCall.js'; +export { SystemFunctionBlockCall, type SystemFunctionBlockCallOptions } from './Commands/Functions/Base/SystemFunctionBlockCall.js'; // Arithmetic -export { ArithmeticCall } from './Commands/Functions/Arithmetic/ArithmeticCall.js'; -export { VariableArithmeticCall } from './Commands/Functions/Arithmetic/VariableArithmeticCall.js'; -export { AddCall } from './Commands/Functions/Arithmetic/AddCall.js'; -export { MulCall } from './Commands/Functions/Arithmetic/MulCall.js'; -export { SubCall } from './Commands/Functions/Arithmetic/SubCall.js'; -export { DivCall } from './Commands/Functions/Arithmetic/DivCall.js'; -export { ModCall } from './Commands/Functions/Arithmetic/ModCall.js'; +export { ArithmeticCall, type ArithmeticCallOptions } from './Commands/Functions/Arithmetic/ArithmeticCall.js'; +export { VariableArithmeticCall, type VariableArithmeticCallOptions } from './Commands/Functions/Arithmetic/VariableArithmeticCall.js'; +export { AddCall, type AddCallOptions } from './Commands/Functions/Arithmetic/AddCall.js'; +export { MulCall, type MulCallOptions } from './Commands/Functions/Arithmetic/MulCall.js'; +export { SubCall, type SubCallOptions } from './Commands/Functions/Arithmetic/SubCall.js'; +export { DivCall, type DivCallOptions } from './Commands/Functions/Arithmetic/DivCall.js'; +export { ModCall, type ModCallOptions } from './Commands/Functions/Arithmetic/ModCall.js'; // Functions -export { AckGlCall } from './Commands/Functions/AckGlCall.js'; -export { CTUCall } from './Commands/Functions/CTUCall.js'; -export { CTUDCall } from './Commands/Functions/CTUDCall.js'; -export { FDBACKCall } from './Commands/Functions/FDBACKCall.js'; -export { FTrigCall } from './Commands/Functions/FTrigCall.js'; -export { NTrigCall } from './Commands/Functions/NTrigCall.js'; -export { PTrigCall } from './Commands/Functions/PTrigCall.js'; -export { RTrigCall } from './Commands/Functions/RTrigCall.js'; -export { TOFCall } from './Commands/Functions/TOFCall.js'; -export { TONCall } from './Commands/Functions/TONCall.js'; -export { TONRCall } from './Commands/Functions/TONRCall.js'; -export { TPCall } from './Commands/Functions/TPCall.js'; +export { AckGlCall, type AckGlCallOptions } from './Commands/Functions/AckGlCall.js'; +export { CTUCall, type CTUCallOptions } from './Commands/Functions/CTUCall.js'; +export { CTUDCall, type CTUDCallOptions } from './Commands/Functions/CTUDCall.js'; +export { FDBACKCall, type FDBACKCallOptions } from './Commands/Functions/FDBACKCall.js'; +export { FTrigCall, type FTrigCallOptions } from './Commands/Functions/FTrigCall.js'; +export { NTrigCall, type NTrigCallOptions } from './Commands/Functions/NTrigCall.js'; +export { PTrigCall, type PTrigCallOptions } from './Commands/Functions/PTrigCall.js'; +export { RTrigCall, type RTrigCallOptions } from './Commands/Functions/RTrigCall.js'; +export { TOFCall, type TOFCallOptions } from './Commands/Functions/TOFCall.js'; +export { TONCall, type TONCallOptions } from './Commands/Functions/TONCall.js'; +export { TONRCall, type TONRCallOptions } from './Commands/Functions/TONRCall.js'; +export { TPCall, type TPCallOptions } from './Commands/Functions/TPCall.js'; // Blocks export { CodeBlock } from './Blocks/CodeBlock.js'; diff --git a/TiaCodegen-ts/tests/SampleTests.test.ts b/TiaCodegen-ts/tests/SampleTests.test.ts index 8175993..60dd11c 100644 --- a/TiaCodegen-ts/tests/SampleTests.test.ts +++ b/TiaCodegen-ts/tests/SampleTests.test.ts @@ -151,7 +151,7 @@ describe('SampleTests', () => { const codeblock = new CodeBlock(); const nw = new Network('Test2', 'Test2en'); - const f = new FunctionBlockCall('CheckContour', 'CheckContourInstance'); + const f = new FunctionBlockCall({ functionName: 'CheckContour', instanceName: 'CheckContourInstance' }); f.iface['BoolPar'] = new IOperationOrSignalDirectionWrapper( new Or(new Signal('P1'), new Signal('P2')), Direction.InOut, @@ -177,7 +177,7 @@ describe('SampleTests', () => { new Distributor( new And(new Coil(new Signal('#monitoringSignal'))), new And( - new TONCall('OnDelaySafetyDoorSDA11N13', new Signal('T#60s', SignalType.ConstantTime)), + new TONCall({ instanceName: 'OnDelaySafetyDoorSDA11N13', pt: new Signal('T#60s', SignalType.ConstantTime) }), ), ), ), @@ -214,7 +214,7 @@ describe('SampleTests', () => { codeblock.safety = true; const nw = new Network('Test2', 'Test2en'); - const f = new TONCall('Hallo', new Signal('T#4m', SignalType.ConstantTime)); + const f = new TONCall({ instanceName: 'Hallo', pt: new Signal('T#4m', SignalType.ConstantTime) }); nw.add(f); codeblock.add(nw); @@ -231,7 +231,7 @@ describe('SampleTests', () => { const f = new And( new Signal('aa'), - new CTUCall('Hallo', new Signal('bbb', SignalType.Bool), new Signal('2', SignalType.ConstantInt), new Coil(new Signal('ccc', SignalType.Bool))), + new CTUCall({ instanceName: 'Hallo', r: new Signal('bbb', SignalType.Bool), pv: new Signal('2', SignalType.ConstantInt), q: new Coil(new Signal('ccc', SignalType.Bool)) }), ); nw.add(f); codeblock.add(nw); @@ -249,15 +249,15 @@ describe('SampleTests', () => { const and = new And( new Signal('#aaa'), - new TPCall( - 'PulseStartPrint', - new Signal('T#100ms', SignalType.ConstantTime), - new Distributor( + new TPCall({ + instanceName: 'PulseStartPrint', + pt: new Signal('T#100ms', SignalType.ConstantTime), + q: new Distributor( new Coil(new Signal('#bbbb')), new RCoil(new Signal('#cccc')), new SCoil(new Signal('#dddd')), ), - ), + }), ); nw.add(and); codeblock.add(nw); @@ -373,7 +373,7 @@ describe('SampleTests', () => { codeblock.safety = false; const nw = new Network('TestDPXX_DAT', 'TestDPXX_DATen'); - const sf1 = new SystemFunctionCall('DPRD_DAT'); + const sf1 = new SystemFunctionCall({ functionName: 'DPRD_DAT' }); sf1.iface['LADDR'] = new IOperationOrSignalDirectionWrapper( new Signal('#Configuration.GeneralMoviC.ModuleHardwareID'), Direction.Input,