Skip to content

Commit b6b6de9

Browse files
committed
use objects for constructor parameters
1 parent be0afb8 commit b6b6de9

8 files changed

Lines changed: 23 additions & 13 deletions

File tree

TiaCodegen-ts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@node-projects/tia-codegen-ts",
3-
"version": "1.0.0",
3+
"version": "2.0.0",
44
"description": "TypeScript port of TiaCodeGen C# library",
55
"type": "module",
66
"main": "dist/index.js",

TiaCodegen-ts/src/Commands/Functions/Arithmetic/AddCall.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import { IOperationOrSignal } from '../../../Interfaces/IOperationOrSignal.js';
22
import { IOperationOrSignalDirectionWrapper } from '../../../Interfaces/IOperationOrSignalDirectionWrapper.js';
33
import { Direction } from '../../../Enums/Direction.js';
44
import { VariableArithmeticCall } from './VariableArithmeticCall.js';
5+
import { numericType } from './ArithmeticCall.js';
56

67
export interface AddCallOptions {
7-
type: string;
8+
type: numericType;
89
in1: IOperationOrSignal;
910
in2: IOperationOrSignal;
1011
in3?: IOperationOrSignal | null;
@@ -67,6 +68,7 @@ export class AddCall extends VariableArithmeticCall {
6768
this.type = type;
6869
this.iface['IN1'] = new IOperationOrSignalDirectionWrapper(in1, Direction.Input);
6970
this.iface['IN2'] = new IOperationOrSignalDirectionWrapper(in2, Direction.Input);
71+
//@ts-ignore
7072
this.addVariableInputs(options, 3, 50);
7173
this.iface['OUT'] = new IOperationOrSignalDirectionWrapper(out1, Direction.Output);
7274

TiaCodegen-ts/src/Commands/Functions/Arithmetic/ArithmeticCall.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { SystemFunctionCall, SystemFunctionCallOptions } from '../Base/SystemFunctionCall.js';
22

3-
export interface ArithmeticCallOptions extends SystemFunctionCallOptions {}
3+
export interface ArithmeticCallOptions extends SystemFunctionCallOptions { }
4+
5+
export type numericType = "Int" | "DInt" | "LInt" | "UInt" | "UDInt" | "ULInt" | "Real";
46

57
export abstract class ArithmeticCall extends SystemFunctionCall {
6-
type: string = '';
8+
type?: numericType = 'Int';
79

810
constructor(options: ArithmeticCallOptions) {
911
super(options);

TiaCodegen-ts/src/Commands/Functions/Arithmetic/DivCall.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { IOperationOrSignal } from '../../../Interfaces/IOperationOrSignal.js';
22
import { IOperationOrSignalDirectionWrapper } from '../../../Interfaces/IOperationOrSignalDirectionWrapper.js';
33
import { Direction } from '../../../Enums/Direction.js';
4-
import { ArithmeticCall } from './ArithmeticCall.js';
4+
import { ArithmeticCall, numericType } from './ArithmeticCall.js';
55

66
export interface DivCallOptions {
7-
type: string;
7+
type: numericType;
88
in1: IOperationOrSignal;
99
in2: IOperationOrSignal;
1010
out1?: IOperationOrSignal | null;

TiaCodegen-ts/src/Commands/Functions/Arithmetic/ModCall.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { IOperationOrSignal } from '../../../Interfaces/IOperationOrSignal.js';
22
import { IOperationOrSignalDirectionWrapper } from '../../../Interfaces/IOperationOrSignalDirectionWrapper.js';
33
import { Direction } from '../../../Enums/Direction.js';
4-
import { ArithmeticCall } from './ArithmeticCall.js';
4+
import { ArithmeticCall, numericType } from './ArithmeticCall.js';
55

66
export interface ModCallOptions {
7-
type: string;
7+
type: numericType;
88
in1: IOperationOrSignal;
99
in2: IOperationOrSignal;
1010
out1?: IOperationOrSignal | null;

TiaCodegen-ts/src/Commands/Functions/Arithmetic/MulCall.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import { IOperationOrSignal } from '../../../Interfaces/IOperationOrSignal.js';
22
import { IOperationOrSignalDirectionWrapper } from '../../../Interfaces/IOperationOrSignalDirectionWrapper.js';
33
import { Direction } from '../../../Enums/Direction.js';
44
import { VariableArithmeticCall } from './VariableArithmeticCall.js';
5+
import { numericType } from './ArithmeticCall.js';
56

67
export interface MulCallOptions {
7-
type: string;
8+
type: numericType;
89
in1: IOperationOrSignal;
910
in2: IOperationOrSignal;
1011
in3?: IOperationOrSignal | null;
@@ -67,6 +68,7 @@ export class MulCall extends VariableArithmeticCall {
6768
this.type = type;
6869
this.iface['IN1'] = new IOperationOrSignalDirectionWrapper(in1, Direction.Input);
6970
this.iface['IN2'] = new IOperationOrSignalDirectionWrapper(in2, Direction.Input);
71+
//@ts-ignore
7072
this.addVariableInputs(options, 3, 50);
7173
this.iface['OUT'] = new IOperationOrSignalDirectionWrapper(out1, Direction.Output);
7274

TiaCodegen-ts/src/Commands/Functions/Arithmetic/SubCall.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { IOperationOrSignal } from '../../../Interfaces/IOperationOrSignal.js';
22
import { IOperationOrSignalDirectionWrapper } from '../../../Interfaces/IOperationOrSignalDirectionWrapper.js';
33
import { Direction } from '../../../Enums/Direction.js';
4-
import { ArithmeticCall } from './ArithmeticCall.js';
4+
import { ArithmeticCall, numericType } from './ArithmeticCall.js';
55

66
export interface SubCallOptions {
7-
type: string;
7+
type: numericType;
88
in1: IOperationOrSignal;
99
in2: IOperationOrSignal;
1010
out1?: IOperationOrSignal | null;

TiaCodegen-ts/src/Commands/Functions/Arithmetic/VariableArithmeticCall.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@ import { IOperationOrSignalDirectionWrapper } from '../../../Interfaces/IOperati
33
import { Direction } from '../../../Enums/Direction.js';
44
import { ArithmeticCall, ArithmeticCallOptions } from './ArithmeticCall.js';
55

6-
export interface VariableArithmeticCallOptions extends ArithmeticCallOptions {}
6+
export interface VariableArithmeticCallOptions extends ArithmeticCallOptions { }
77

88
export abstract class VariableArithmeticCall extends ArithmeticCall {
99
constructor(options: VariableArithmeticCallOptions) {
1010
super(options);
1111
}
1212

13-
protected addVariableInputs(options: object, startIndex: number, endIndex: number): void {
13+
protected addVariableInputs(
14+
options: Record<string, IOperationOrSignal | null | undefined>,
15+
startIndex: number,
16+
endIndex: number
17+
): void {
1418
for (let i = startIndex; i <= endIndex; i++) {
1519
const value = ((options as Record<string, unknown>)[`in${i}`] as IOperationOrSignal | null | undefined) ?? null;
1620
this.iface[`IN${i}`] = new IOperationOrSignalDirectionWrapper(value, Direction.Input);

0 commit comments

Comments
 (0)