File tree Expand file tree Collapse file tree
src/Commands/Functions/Arithmetic Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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" ,
Original file line number Diff line number Diff line change @@ -2,9 +2,10 @@ import { IOperationOrSignal } from '../../../Interfaces/IOperationOrSignal.js';
22import { IOperationOrSignalDirectionWrapper } from '../../../Interfaces/IOperationOrSignalDirectionWrapper.js' ;
33import { Direction } from '../../../Enums/Direction.js' ;
44import { VariableArithmeticCall } from './VariableArithmeticCall.js' ;
5+ import { numericType } from './ArithmeticCall.js' ;
56
67export 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
Original file line number Diff line number Diff line change 11import { 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
57export abstract class ArithmeticCall extends SystemFunctionCall {
6- type : string = '' ;
8+ type ?: numericType = 'Int ' ;
79
810 constructor ( options : ArithmeticCallOptions ) {
911 super ( options ) ;
Original file line number Diff line number Diff line change 11import { IOperationOrSignal } from '../../../Interfaces/IOperationOrSignal.js' ;
22import { IOperationOrSignalDirectionWrapper } from '../../../Interfaces/IOperationOrSignalDirectionWrapper.js' ;
33import { Direction } from '../../../Enums/Direction.js' ;
4- import { ArithmeticCall } from './ArithmeticCall.js' ;
4+ import { ArithmeticCall , numericType } from './ArithmeticCall.js' ;
55
66export interface DivCallOptions {
7- type : string ;
7+ type : numericType ;
88 in1 : IOperationOrSignal ;
99 in2 : IOperationOrSignal ;
1010 out1 ?: IOperationOrSignal | null ;
Original file line number Diff line number Diff line change 11import { IOperationOrSignal } from '../../../Interfaces/IOperationOrSignal.js' ;
22import { IOperationOrSignalDirectionWrapper } from '../../../Interfaces/IOperationOrSignalDirectionWrapper.js' ;
33import { Direction } from '../../../Enums/Direction.js' ;
4- import { ArithmeticCall } from './ArithmeticCall.js' ;
4+ import { ArithmeticCall , numericType } from './ArithmeticCall.js' ;
55
66export interface ModCallOptions {
7- type : string ;
7+ type : numericType ;
88 in1 : IOperationOrSignal ;
99 in2 : IOperationOrSignal ;
1010 out1 ?: IOperationOrSignal | null ;
Original file line number Diff line number Diff line change @@ -2,9 +2,10 @@ import { IOperationOrSignal } from '../../../Interfaces/IOperationOrSignal.js';
22import { IOperationOrSignalDirectionWrapper } from '../../../Interfaces/IOperationOrSignalDirectionWrapper.js' ;
33import { Direction } from '../../../Enums/Direction.js' ;
44import { VariableArithmeticCall } from './VariableArithmeticCall.js' ;
5+ import { numericType } from './ArithmeticCall.js' ;
56
67export 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
Original file line number Diff line number Diff line change 11import { IOperationOrSignal } from '../../../Interfaces/IOperationOrSignal.js' ;
22import { IOperationOrSignalDirectionWrapper } from '../../../Interfaces/IOperationOrSignalDirectionWrapper.js' ;
33import { Direction } from '../../../Enums/Direction.js' ;
4- import { ArithmeticCall } from './ArithmeticCall.js' ;
4+ import { ArithmeticCall , numericType } from './ArithmeticCall.js' ;
55
66export interface SubCallOptions {
7- type : string ;
7+ type : numericType ;
88 in1 : IOperationOrSignal ;
99 in2 : IOperationOrSignal ;
1010 out1 ?: IOperationOrSignal | null ;
Original file line number Diff line number Diff line change @@ -3,14 +3,18 @@ import { IOperationOrSignalDirectionWrapper } from '../../../Interfaces/IOperati
33import { Direction } from '../../../Enums/Direction.js' ;
44import { ArithmeticCall , ArithmeticCallOptions } from './ArithmeticCall.js' ;
55
6- export interface VariableArithmeticCallOptions extends ArithmeticCallOptions { }
6+ export interface VariableArithmeticCallOptions extends ArithmeticCallOptions { }
77
88export 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 ) ;
You can’t perform that action at this time.
0 commit comments