BASE_DATA_TYPES: {
    find: ((name: string) =>
        | null
        | {
            adsDataType: number;
            fromBuffer: ((buffer: Buffer) => string);
            name: string[];
            size: number;
            toBuffer: ((value: string, buffer: Buffer) => number);
        }
        | {
            adsDataType: number;
            fromBuffer: ((buffer: Buffer) => boolean);
            name: string[];
            size: number;
            toBuffer: ((value: number | boolean, buffer: Buffer) => number);
        }
        | {
            adsDataType: number;
            fromBuffer: ((buffer: Buffer) => number);
            name: string[];
            size: number;
            toBuffer: ((value: number, buffer: Buffer) => number);
        }
        | {
            adsDataType: number;
            fromBuffer: ((buffer: Buffer, convertDates: boolean) => number | Date);
            name: string[];
            size: number;
            toBuffer: ((value: number | Date, buffer: Buffer) => void);
        }
        | {
            adsDataType: number;
            fromBuffer: ((buffer: Buffer) => bigint | Buffer);
            name: string[];
            size: number;
            toBuffer: ((value: number | Buffer | BigInt, buffer: Buffer) => void);
        });
    findPseudoType: ((name: string) => undefined | {
        actualTypesBySize: {
            [k: number]: string;
        };
        name: string[];
    });
    fromBuffer: ((name: string, buffer: Buffer, convertDates: boolean) =>
        | string
        | number
        | bigint
        | boolean
        | Buffer
        | Date);
    getTypeByPseudoType: ((name: string, byteSize: number) => undefined | string);
    isKnownType: ((name: string) => boolean);
    isPseudoType: ((name: string) => boolean);
    pseudoTypes: {
        actualTypesBySize: {
            [k: number]: string;
        };
        name: string[];
    }[];
    toBuffer: ((name: string, value: PlcPrimitiveType, buffer?: Buffer) => Buffer);
    types: (
        | {
            adsDataType: number;
            fromBuffer: ((buffer: Buffer) => string);
            name: string[];
            size: number;
            toBuffer: ((value: string, buffer: Buffer) => number);
        }
        | {
            adsDataType: number;
            fromBuffer: ((buffer: Buffer) => boolean);
            name: string[];
            size: number;
            toBuffer: ((value: number | boolean, buffer: Buffer) => number);
        }
        | {
            adsDataType: number;
            fromBuffer: ((buffer: Buffer) => number);
            name: string[];
            size: number;
            toBuffer: ((value: number, buffer: Buffer) => number);
        }
        | {
            adsDataType: number;
            fromBuffer: ((buffer: Buffer, convertDates: boolean) => number | Date);
            name: string[];
            size: number;
            toBuffer: ((value: number | Date, buffer: Buffer) => void);
        }
        | {
            adsDataType: number;
            fromBuffer: ((buffer: Buffer) => bigint | Buffer);
            name: string[];
            size: number;
            toBuffer: ((value: number | Buffer | BigInt, buffer: Buffer) => void);
        })[];
} = ...

Base data types

Object that handles PLC base data types

Type declaration

  • find: ((name: string) =>
        | null
        | {
            adsDataType: number;
            fromBuffer: ((buffer: Buffer) => string);
            name: string[];
            size: number;
            toBuffer: ((value: string, buffer: Buffer) => number);
        }
        | {
            adsDataType: number;
            fromBuffer: ((buffer: Buffer) => boolean);
            name: string[];
            size: number;
            toBuffer: ((value: number | boolean, buffer: Buffer) => number);
        }
        | {
            adsDataType: number;
            fromBuffer: ((buffer: Buffer) => number);
            name: string[];
            size: number;
            toBuffer: ((value: number, buffer: Buffer) => number);
        }
        | {
            adsDataType: number;
            fromBuffer: ((buffer: Buffer, convertDates: boolean) => number | Date);
            name: string[];
            size: number;
            toBuffer: ((value: number | Date, buffer: Buffer) => void);
        }
        | {
            adsDataType: number;
            fromBuffer: ((buffer: Buffer) => bigint | Buffer);
            name: string[];
            size: number;
            toBuffer: ((value: number | Buffer | BigInt, buffer: Buffer) => void);
        })

    Finds the given data type from array

      • (name):
            | null
            | {
                adsDataType: number;
                fromBuffer: ((buffer: Buffer) => string);
                name: string[];
                size: number;
                toBuffer: ((value: string, buffer: Buffer) => number);
            }
            | {
                adsDataType: number;
                fromBuffer: ((buffer: Buffer) => boolean);
                name: string[];
                size: number;
                toBuffer: ((value: number | boolean, buffer: Buffer) => number);
            }
            | {
                adsDataType: number;
                fromBuffer: ((buffer: Buffer) => number);
                name: string[];
                size: number;
                toBuffer: ((value: number, buffer: Buffer) => number);
            }
            | {
                adsDataType: number;
                fromBuffer: ((buffer: Buffer, convertDates: boolean) => number | Date);
                name: string[];
                size: number;
                toBuffer: ((value: number | Date, buffer: Buffer) => void);
            }
            | {
                adsDataType: number;
                fromBuffer: ((buffer: Buffer) => bigint | Buffer);
                name: string[];
                size: number;
                toBuffer: ((value: number | Buffer | BigInt, buffer: Buffer) => void);
            }
      • Parameters

        • name: string

          Data type name

        Returns
            | null
            | {
                adsDataType: number;
                fromBuffer: ((buffer: Buffer) => string);
                name: string[];
                size: number;
                toBuffer: ((value: string, buffer: Buffer) => number);
            }
            | {
                adsDataType: number;
                fromBuffer: ((buffer: Buffer) => boolean);
                name: string[];
                size: number;
                toBuffer: ((value: number | boolean, buffer: Buffer) => number);
            }
            | {
                adsDataType: number;
                fromBuffer: ((buffer: Buffer) => number);
                name: string[];
                size: number;
                toBuffer: ((value: number, buffer: Buffer) => number);
            }
            | {
                adsDataType: number;
                fromBuffer: ((buffer: Buffer, convertDates: boolean) => number | Date);
                name: string[];
                size: number;
                toBuffer: ((value: number | Date, buffer: Buffer) => void);
            }
            | {
                adsDataType: number;
                fromBuffer: ((buffer: Buffer) => bigint | Buffer);
                name: string[];
                size: number;
                toBuffer: ((value: number | Buffer | BigInt, buffer: Buffer) => void);
            }

  • findPseudoType: ((name: string) => undefined | {
        actualTypesBySize: {
            [k: number]: string;
        };
        name: string[];
    })

    Finds the given pseudo data type from array using regular expressions

      • (name): undefined | {
            actualTypesBySize: {
                [k: number]: string;
            };
            name: string[];
        }
      • Parameters

        • name: string

          Pseudo data type name

        Returns undefined | {
            actualTypesBySize: {
                [k: number]: string;
            };
            name: string[];
        }

  • fromBuffer: ((name: string, buffer: Buffer, convertDates: boolean) =>
        | string
        | number
        | bigint
        | boolean
        | Buffer
        | Date)

    Reads given data type from given buffer

      • (name, buffer, convertDates):
            | string
            | number
            | bigint
            | boolean
            | Buffer
            | Date
      • Parameters

        • name: string

          Data type name

        • buffer: Buffer

          Buffer to read from

        • convertDates: boolean

        Returns
            | string
            | number
            | bigint
            | boolean
            | Buffer
            | Date

  • getTypeByPseudoType: ((name: string, byteSize: number) => undefined | string)

    Finds the given pseudo data type from array using regular expressions

      • (name, byteSize): undefined | string
      • Parameters

        • name: string

          Pseudo data type name (like PVOID)

        • byteSize: number

        Returns undefined | string

  • isKnownType: ((name: string) => boolean)

    Returns true if given data type is found and known

      • (name): boolean
      • Parameters

        • name: string

          Data type name

        Returns boolean

  • isPseudoType: ((name: string) => boolean)

    Returns true if given data type is found and known

      • (name): boolean
      • Parameters

        • name: string

          Data type name

        Returns boolean

  • pseudoTypes: {
        actualTypesBySize: {
            [k: number]: string;
        };
        name: string[];
    }[]

    All pseudo data types and their actual types depending on size Example: XINT is 4 bytes @ 32 bit platform -> DINT

  • toBuffer: ((name: string, value: PlcPrimitiveType, buffer?: Buffer) => Buffer)

    Writes given value to given or new buffer

      • (name, value, buffer?): Buffer
      • Parameters

        • name: string

          Data type name

        • value: PlcPrimitiveType

          Value to write

        • Optionalbuffer: Buffer

          Optional - Buffer to write to. If not given, new Buffer is allocated

        Returns Buffer

  • types: (
        | {
            adsDataType: number;
            fromBuffer: ((buffer: Buffer) => string);
            name: string[];
            size: number;
            toBuffer: ((value: string, buffer: Buffer) => number);
        }
        | {
            adsDataType: number;
            fromBuffer: ((buffer: Buffer) => boolean);
            name: string[];
            size: number;
            toBuffer: ((value: number | boolean, buffer: Buffer) => number);
        }
        | {
            adsDataType: number;
            fromBuffer: ((buffer: Buffer) => number);
            name: string[];
            size: number;
            toBuffer: ((value: number, buffer: Buffer) => number);
        }
        | {
            adsDataType: number;
            fromBuffer: ((buffer: Buffer, convertDates: boolean) => number | Date);
            name: string[];
            size: number;
            toBuffer: ((value: number | Date, buffer: Buffer) => void);
        }
        | {
            adsDataType: number;
            fromBuffer: ((buffer: Buffer) => bigint | Buffer);
            name: string[];
            size: number;
            toBuffer: ((value: number | Buffer | BigInt, buffer: Buffer) => void);
        })[]

    All base data types and properties