/**
 * Demo how to use sigApi.fileManager
 * 
 * demo setup:
 *   required user defined internal events
 *     * 'evtGetDriveList'
 *     * 'evtReadDir'
 *     * 'evtMakeDir'
 *     * 'evtRename'
 *     * 'evtCopy'
 *     * 'evtMove'
 *     * 'evtRemove'
 *     * 'evtReadFile'
 *     * 'evtWriteFile'
 *     * 'evtFileContent'
 *   required directories and files
 *     * 'c:\demo_api_fileManager\test' expected to contain file.txt (readDir/copy/move)
 *     * 'c:\demo_api_fileManager\new' expected not to exist (makeDir), expected to exist (rename)
 *     * 'c:\demo_api_fileManager\renamed' expected not to exist (rename)
 *     * 'c:\demo_api_fileManager\test\copy.txt' expected not to exist (copy/move), expected to exist (delete)
 *     * 'c:\demo_api_fileManager\file.txt' (writeFile/readFile)
 * 
 * copyright by Sigmatek GmbH & CoKG
 */

const PREFIX = 'c:/userdata'; //'c:\\demo_api_fileManager';

const NEW_FILE = `${PREFIX}\\service_.txt`;
const NEW_DIR = `${PREFIX}\\service`;

const NEW_FILE_PROTOKOLL = `${PREFIX}\\protokoll_.txt`;
const NEW_DIR_PROTOKOLL = `${PREFIX}\\protokoll`;

class WriteServiceFile {
    static init() {
        window.sigApiReadyPromise.then(() => {
            const codemodule = new WriteServiceFile();
        });
    }

    constructor() {
        this._registerEvents();
    }

    /**
     * @private
     * register to user defined events
     */
    _registerEvents() {

        sigApi.eventMediator.subscribe(
            sigApi.events.getUserDefinedInternalEvent('CreateServiceFile'),
            () => {
                this._onMakeDir();
                this._onWriteFile();
            }
        );

        sigApi.eventMediator.subscribe(
            sigApi.events.getUserDefinedInternalEvent('CreatePruefProtokoll'),
            () => {
                this._onMakeDirProtokoll();
                this._onWriteFileProtokoll();
            }
        );

    }

    /**
     * @private
     * create a directory
     */
    _onMakeDir() {
        console.log('[DemoApiFileManager] _onMakeDir()');
        sigApi.fileManager.makeDir(NEW_DIR).then((res) => {
            console.log(`[DemoApiFileManager] sigApi.fileManager.makeDir('${NEW_DIR}') uid: ${res.uid} dir: ${res.dir}`);
        }).catch((error) => {
            console.log(`[DemoApiFileManager] error in sigApi.fileManager.makeDir('${NEW_DIR}') uid: ${error.uid} status: ${error.status} errortxt: ${error.errortxt}`);
        });
    }

    _onMakeDirProtokoll() {
        console.log('[DemoApiFileManager] _onMakeDir()');
        sigApi.fileManager.makeDir(NEW_DIR_PROTOKOLL).then((res) => {
            console.log(`[DemoApiFileManager] sigApi.fileManager.makeDir('${NEW_DIR_PROTOKOLL}') uid: ${res.uid} dir: ${res.dir}`);
        }).catch((error) => {
            console.log(`[DemoApiFileManager] error in sigApi.fileManager.makeDir('${NEW_DIR_PROTOKOLL}') uid: ${error.uid} status: ${error.status} errortxt: ${error.errortxt}`);
        });
    }

    /**
     * @private
     * write a file
     */
    _onWriteFile() {
        console.log('[WriteServiceFile] _onWriteFile()');

        sigApi.datapointManager.writeDataPoint('10:ToolsName1.ServiceFileOK', 0);
        sigApi.datapointManager.writeDataPoint('10:ToolsName1.Create', 0);

        sigApi.datapointManager.readDataPoint('10:Global_Set1.Language_Number', 0)
            .then((resolve) => {
                const Language = resolve.value;

                if (Language === 1) {

                sigApi.datapointManager.readDataPoint('10:PLC_Info1.CPU_Name', 0)
                    .then((resolve) => {
                        const PLC_Name = resolve.value;
                        sigApi.datapointManager.readDataPoint('10:ProjectRevision1.Data', 0)
                            .then((resolve) => {
                                const PLC_Version = resolve.value.toString();
                                sigApi.datapointManager.readDataPoint('10:PLC_Info1.SerNum', 0)
                                    .then((resolve) => {
                                        const PLC_Serie = resolve.value.toString();
                                        sigApi.datapointManager.readDataPoint('225:PLC_Info1.CPU_Name', 0)
                                            .then((resolve) => {
                                                const HMI_Name = resolve.value;
                                                sigApi.datapointManager.readDataPoint('225:ProjectRevision1.Data', 0)
                                                    .then((resolve) => {
                                                        const HMI_Version = resolve.value.toString();
                                                        sigApi.datapointManager.readDataPoint('225:VersionNumber1.SerialNumberString', 0)
                                                            .then((resolve) => {
                                                                const HMI_Serie = resolve.value.toString();
                                                                sigApi.datapointManager.readDataPoint('10:Global_Set1.AbsoluteMAXTemperatur', 0)
                                                                    .then((resolve) => {
                                                                        const Max_Temperature = resolve.value.toString();
                                                                        sigApi.datapointManager.readDataPoint('10:Global_Set1.ZielSollTemperaturRampe', 0)
                                                                            .then((resolve) => {
                                                                                const Ramp_Temperature = resolve.value.toString();
                                                                                sigApi.datapointManager.readDataPoint('10:Global_Set1.LowerValue', 0)
                                                                                    .then((resolve) => {
                                                                                        const Lower_Temperatur = resolve.value.toString();
                                                                                        sigApi.datapointManager.readDataPoint('10:Global_Set1.BoostValue', 0)
                                                                                            .then((resolve) => {
                                                                                                const Boost_Temperature = resolve.value.toString();
                                                                                                sigApi.datapointManager.readDataPoint('10:Global_Set1.BoostTime', 0)
                                                                                                    .then((resolve) => {
                                                                                                        const Boost_Time = resolve.value.toString();
                                                                                                        sigApi.datapointManager.readDataPoint('10:ToolsName1.Tools_Name', 0)
                                                                                                            .then((resolve) => {
                                                                                                                const newname = resolve.value;
                                                                                                                sigApi.datapointManager.readDataPoint('10:DeviceInformation1.MaxTmpZones', 0)
                                                                                                                    .then((resolve) => {
                                                                                                                        const number_of_zones = resolve.value;
                                                                                                                        sigApi.datapointManager.readDataPoint('10:DeviceInformation1.DeviceData', 0)
                                                                                                                            .then((resolve) => {
                                                                                                                                const serien_number = resolve.value;
                                                                                                                                sigApi.datapointManager.readDataPoint('10:StringOSVersion_Plc.Data', 0)
                                                                                                                                    .then((resolve) => {
                                                                                                                                        const OS_Version_PLC = resolve.value;
                                                                                                                                        sigApi.datapointManager.readDataPoint('225:StringOSVersion_HMI.Data', 0)
                                                                                                                                            .then((resolve) => {
                                                                                                                                                const OS_Version_HMI = resolve.value;


                                                                                                        let GroupIDsArray = [];
                                                                                                        let SetPointsArray = [];
                                                                                                        let ZoneOnArray = [];
                                                                                                        let GroupsArray = ['', '', '', '', '', '', '', '', '', '',''];
                                                                                                        let ElementenCounter = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0];

                                                                                                        let TextContent =
                                                                                                            'Werkzeug:          ' + newname + '\n' +
                                                                                                            'Anzahl der Zonen:  ' + number_of_zones + '\n' +
                                                                                                            'Seriennummer:      ' + serien_number + '\n\n' +
                                                                                                            'PLC: \n\n' +
                                                                                                            'Name:              ' + PLC_Name + '\n' +
                                                                                                            'Version:           ' + PLC_Version + '\n' +
                                                                                                            'OS Version:        ' + OS_Version_PLC + '\n' +
                                                                                                            'Serial number:     ' + PLC_Serie + '\n\n' +
                                                                                                            '___________________________________________________________________________ \n\n' +
                                                                                                            'HMI: \n\n' +
                                                                                                            'Name:              ' + HMI_Name + '\n' +
                                                                                                            'Version:           ' + HMI_Version + '\n' +
                                                                                                            'OS Version:        ' + OS_Version_HMI + '\n' +
                                                                                                            'Serial number:     ' + HMI_Serie + '\n\n' + '___________________________________________________________________________ \n\n' +
                                                                                                            'Temperatur-Einstellungen: \n\n' +
                                                                                                            'Maximale Temperatur: ' + '                         ' + (Max_Temperature / 10) + ' degC' + '\n' +
                                                                                                            'Softstart der Aufheizfunktion auf: ' + '           ' + (Ramp_Temperature / 10) + ' degC' + '\n' +
                                                                                                            'Absenken  um: ' + '                                ' + (Lower_Temperatur / 10) + ' degC' + '\n' +
                                                                                                            'Anheben um: ' + '                                  ' + (Boost_Temperature / 10) + '  degC' + '\n' +
                                                                                                            'Dauer der Anhebung: ' + '                          ' + (Boost_Time / 60000) + '   min' + '\n\n' +
                                                                                                            '___________________________________________________________________________ \n\n' +

                                                                                                            'Zonenstruktur:  \n\n' +

                                                                                                            '___________________________________________________________________________' + '\n' +
                                                                                                            '      Zone Nr.   |    Zone aktiv   |    Group Nr.   | Target temperature   |' + '\n' +
                                                                                                            '___________________________________________________________________________|' + '\n';

                                                                                                        const quality = 0;
                                                                                                        if (this.datapointAPI !== null) {
                                                                                                            return Promise.resolve()
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone1.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone2.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone3.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone4.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone5.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone6.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone7.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone8.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone9.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone10.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone11.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone12.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone13.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone14.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone15.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);

                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone16.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone17.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone18.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone19.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone20.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone21.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone22.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone23.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone24.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:SetPointManager1.SetPointLVD_Soll', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:SetPointManager2.SetPointLVD_Soll', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:SetPointManager3.SetPointLVD_Soll', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:SetPointManager4.SetPointLVD_Soll', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:SetPointManager5.SetPointLVD_Soll', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:SetPointManager6.SetPointLVD_Soll', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:SetPointManager7.SetPointLVD_Soll', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:SetPointManager8.SetPointLVD_Soll', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:SetPointManager9.SetPointLVD_Soll', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:SetPointManager10.SetPointLVD_Soll', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:SetPointManager11.SetPointLVD_Soll', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:SetPointManager12.SetPointLVD_Soll', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:SetPointManager13.SetPointLVD_Soll', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:SetPointManager14.SetPointLVD_Soll', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:SetPointManager15.SetPointLVD_Soll', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);

                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:SetPointManager16.SetPointLVD_Soll', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:SetPointManager17.SetPointLVD_Soll', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:SetPointManager18.SetPointLVD_Soll', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:SetPointManager19.SetPointLVD_Soll', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:SetPointManager20.SetPointLVD_Soll', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:SetPointManager21.SetPointLVD_Soll', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone22.SetPoint', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:SetPointManager23.SetPointLVD_Soll', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:SetPointManager24.SetPointLVD_Soll', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone1.ZoneOn', quality)
                                                                                                                        .then((resolve) => {

                                                                                                                            ZoneOnArray.push(resolve.value);

                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone2.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone3.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone4.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone5.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone6.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone7.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone8.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone9.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone10.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone11.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone12.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone13.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone14.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone15.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);

                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone16.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone17.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone18.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone19.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone20.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone21.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone22.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone23.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone24.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);

                                                                                                                            for (let index = 0; index < 24; index++) {

                                                                                                                                if (ZoneOnArray[index] !==0){
                                                                                                                                    switch (GroupIDsArray[index]) {
                                                                                                                                        case 0:
                                                                                                                                            ElementenCounter[10]++;
                                                                                                                                            if (index < 9) {
                                                                                                                                                GroupsArray[10] = GroupsArray[10] + 'Zone 0' + (index + 1) + '; ';
                                                                                                                                            } else {
                                                                                                                                                GroupsArray[10] = GroupsArray[10] + 'Zone ' + (index + 1) + '; ';
                                                                                                                                            }
                                                                                                                                            break;


                                                                                                                                        case 1:
                                                                                                                                            ElementenCounter[0]++;
                                                                                                                                            if (index < 9) {
                                                                                                                                                GroupsArray[0] = GroupsArray[0] + 'Zone 0' + (index + 1) + '; ';
                                                                                                                                            } else {
                                                                                                                                                GroupsArray[0] = GroupsArray[0] + 'Zone ' + (index + 1) + '; ';
                                                                                                                                            }
                                                                                                                                            break;
                                                                                                                                        case 2:
                                                                                                                                            ElementenCounter[1]++;
                                                                                                                                            if (index < 9) {
                                                                                                                                                GroupsArray[1] = GroupsArray[1] + 'Zone 0' + (index + 1) + '; ';
                                                                                                                                            } else {
                                                                                                                                                GroupsArray[1] = GroupsArray[1] + 'Zone ' + (index + 1) + '; ';
                                                                                                                                            }

                                                                                                                                            break;
                                                                                                                                        case 3:
                                                                                                                                            ElementenCounter[2]++;
                                                                                                                                            if (index < 9) {
                                                                                                                                                GroupsArray[2] = GroupsArray[2] + 'Zone 0' + (index + 1) + '; ';
                                                                                                                                            } else {
                                                                                                                                                GroupsArray[2] = GroupsArray[2] + 'Zone ' + (index + 1) + '; ';
                                                                                                                                            }

                                                                                                                                            break;
                                                                                                                                        case 4:
                                                                                                                                            ElementenCounter[3]++;
                                                                                                                                            if (index < 9) {
                                                                                                                                                GroupsArray[3] = GroupsArray[3] + 'Zone 0' + (index + 1) + '; ';
                                                                                                                                            } else {
                                                                                                                                                GroupsArray[3] = GroupsArray[3] + 'Zone ' + (index + 1) + '; ';
                                                                                                                                            }

                                                                                                                                            break;
                                                                                                                                        case 5:
                                                                                                                                            ElementenCounter[4]++;
                                                                                                                                            if (index < 9) {
                                                                                                                                                GroupsArray[4] = GroupsArray[4] + 'Zone 0' + (index + 1) + '; ';
                                                                                                                                            } else {
                                                                                                                                                GroupsArray[4] = GroupsArray[4] + 'Zone ' + (index + 1) + '; ';
                                                                                                                                            }

                                                                                                                                            break;
                                                                                                                                        case 6:
                                                                                                                                            ElementenCounter[5]++;
                                                                                                                                            if (index < 9) {
                                                                                                                                                GroupsArray[5] = GroupsArray[5] + 'Zone 0' + (index + 1) + '; ';
                                                                                                                                            } else {
                                                                                                                                                GroupsArray[5] = GroupsArray[5] + 'Zone ' + (index + 1) + '; ';
                                                                                                                                            }

                                                                                                                                            break;
                                                                                                                                        case 7:
                                                                                                                                            ElementenCounter[6]++;
                                                                                                                                            if (index < 9) {
                                                                                                                                                GroupsArray[6] = GroupsArray[6] + 'Zone 0' + (index + 1) + '; ';
                                                                                                                                            } else {
                                                                                                                                                GroupsArray[6] = GroupsArray[6] + 'Zone ' + (index + 1) + '; ';
                                                                                                                                            }

                                                                                                                                            break;
                                                                                                                                        case 8:
                                                                                                                                            ElementenCounter[7]++;
                                                                                                                                            if (index < 9) {
                                                                                                                                                GroupsArray[7] = GroupsArray[7] + 'Zone 0' + (index + 1) + '; ';
                                                                                                                                            } else {
                                                                                                                                                GroupsArray[7] = GroupsArray[7] + 'Zone ' + (index + 1) + '; ';
                                                                                                                                            }

                                                                                                                                            break;
                                                                                                                                        case 9:
                                                                                                                                            ElementenCounter[8]++;
                                                                                                                                            if (index < 9) {
                                                                                                                                                GroupsArray[8] = GroupsArray[8] + 'Zone 0' + (index + 1) + '; ';
                                                                                                                                            } else {
                                                                                                                                                GroupsArray[8] = GroupsArray[8] + 'Zone ' + (index + 1) + '; ';
                                                                                                                                            }

                                                                                                                                            break;
                                                                                                                                        case 10:
                                                                                                                                            ElementenCounter[9]++;
                                                                                                                                            if (index < 9) {
                                                                                                                                                GroupsArray[9] = GroupsArray[9] + 'Zone 0' + (index + 1) + '; ';
                                                                                                                                            } else {
                                                                                                                                                GroupsArray[9] = GroupsArray[9] + 'Zone ' + (index + 1) + '; ';
                                                                                                                                            }

                                                                                                                                            break;
                                                                                                                                    }
                                                                                                                                }
                                                                                                                            }


                                                                                                                            for (let i = 0; i < 24; i++) {
                                                                                                                                if (ZoneOnArray[i] !== 0){

                                                                                                                                    if (GroupIDsArray[i] !== 0){
                                                                                                                                        if (GroupIDsArray[i] < 10) {
                                                                                                                                            if (i < 9 && SetPointsArray[i] < 999) {
                                                                                                                                                TextContent = TextContent + '      Zone ' + (i + 1) + '     |        ' + ZoneOnArray[i] + '        |        ' + GroupIDsArray[i] + '       |   ' + (SetPointsArray[i] / 10)

                                                                                                                                                    + ' ' + ' degC' + '           | ' + '\n';

                                                                                                                                            } else if (i < 9 && SetPointsArray[i] >= 999) {
                                                                                                                                                TextContent = TextContent + '      Zone ' + (i + 1) + '     |        ' + ZoneOnArray[i] + '        |        ' + GroupIDsArray[i] + '       |   ' + (SetPointsArray[i] / 10)

                                                                                                                                                    + ' ' + 'degC' + '           | ' + '\n';
                                                                                                                                            } else if (i >= 9 && SetPointsArray[i] < 999) {
                                                                                                                                                TextContent = TextContent + '      Zone ' + (i + 1) + '    |        ' + ZoneOnArray[i] + '        |        ' + GroupIDsArray[i] + '       |   ' + (SetPointsArray[i] / 10)

                                                                                                                                                    + ' ' + ' degC' + '           | ' + '\n';


                                                                                                                                            } else if (i >= 9 && SetPointsArray[i] >= 999) {
                                                                                                                                                TextContent = TextContent + '      Zone ' + (i + 1) + '    |        ' + ZoneOnArray[i] + '        |        ' + GroupIDsArray[i] + '       |   ' + (SetPointsArray[i] / 10)

                                                                                                                                                    + ' ' + 'degC' + '           | ' + '\n';
                                                                                                                                            }

                                                                                                                                        } else {
                                                                                                                                            if (i < 9 && SetPointsArray[i] < 999) {
                                                                                                                                                TextContent = TextContent + '      Zone ' + (i + 1) + '     |        ' + ZoneOnArray[i] + '        |        ' + GroupIDsArray[i] + '      |   ' + (SetPointsArray[i] / 10)

                                                                                                                                                    + ' ' + ' degC' + '           | ' + '\n';

                                                                                                                                            } else if (i < 9 && SetPointsArray[i] >= 999) {
                                                                                                                                                TextContent = TextContent + '      Zone ' + (i + 1) + '     |        ' + ZoneOnArray[i] + '        |        ' + GroupIDsArray[i] + '      |   ' + (SetPointsArray[i] / 10)

                                                                                                                                                    + ' ' + 'degC' + '           | ' + '\n';
                                                                                                                                            } else if (i >= 9 && SetPointsArray[i] < 999) {
                                                                                                                                                TextContent = TextContent + '      Zone ' + (i + 1) + '    |        ' + ZoneOnArray[i] + '        |        ' + GroupIDsArray[i] + '      |   ' + (SetPointsArray[i] / 10)

                                                                                                                                                    + ' ' + ' degC' + '           | ' + '\n';


                                                                                                                                            } else if (i >= 9 && SetPointsArray[i] >= 999) {
                                                                                                                                                TextContent = TextContent + '      Zone ' + (i + 1) + '    |        ' + ZoneOnArray[i] + '        |        ' + GroupIDsArray[i] + '      |   ' + (SetPointsArray[i] / 10)

                                                                                                                                                    + ' ' + 'degC' + '           | ' + '\n';
                                                                                                                                            }
                                                                                                                                        }
                                                                                                                                    }else
                                                                                                                                    {
                                                                                                                                        if (GroupIDsArray[i] < 10) {
                                                                                                                                            if (i < 9 && SetPointsArray[i] < 999) {
                                                                                                                                                TextContent = TextContent + '      Zone ' + (i + 1) + '     |        ' + ZoneOnArray[i] + '        |        ' + '-' + '       |   ' + (SetPointsArray[i] / 10)

                                                                                                                                                    + ' ' + ' degC' + '           | ' + '\n';

                                                                                                                                            } else if (i < 9 && SetPointsArray[i] >= 999) {
                                                                                                                                                TextContent = TextContent + '      Zone ' + (i + 1) + '     |        ' + ZoneOnArray[i] + '        |        ' + '-' + '       |   ' + (SetPointsArray[i] / 10)

                                                                                                                                                    + ' ' + 'degC' + '           | ' + '\n';
                                                                                                                                            } else if (i >= 9 && SetPointsArray[i] < 999) {
                                                                                                                                                TextContent = TextContent + '      Zone ' + (i + 1) + '    |        ' + ZoneOnArray[i] + '        |        ' + '-' + '       |   ' + (SetPointsArray[i] / 10)

                                                                                                                                                    + ' ' + ' degC' + '           | ' + '\n';


                                                                                                                                            } else if (i >= 9 && SetPointsArray[i] >= 999) {
                                                                                                                                                TextContent = TextContent + '      Zone ' + (i + 1) + '    |        ' + ZoneOnArray[i] + '        |        ' + '-' + '       |   ' + (SetPointsArray[i] / 10)

                                                                                                                                                    + ' ' + 'degC' + '           | ' + '\n';
                                                                                                                                            }

                                                                                                                                        } else {
                                                                                                                                            if (i < 9 && SetPointsArray[i] < 999) {
                                                                                                                                                TextContent = TextContent + '      Zone ' + (i + 1) + '     |        ' + ZoneOnArray[i] + '        |        ' + '--' + '      |   ' + (SetPointsArray[i] / 10)

                                                                                                                                                    + ' ' + ' degC' + '           | ' + '\n';

                                                                                                                                            } else if (i < 9 && SetPointsArray[i] >= 999) {
                                                                                                                                                TextContent = TextContent + '      Zone ' + (i + 1) + '     |        ' + ZoneOnArray[i] + '        |        ' + '--' + '      |   ' + (SetPointsArray[i] / 10)

                                                                                                                                                    + ' ' + 'degC' + '           | ' + '\n';
                                                                                                                                            } else if (i >= 9 && SetPointsArray[i] < 999) {
                                                                                                                                                TextContent = TextContent + '      Zone ' + (i + 1) + '    |        ' + ZoneOnArray[i] + '        |        ' + '--' + '      |   ' + (SetPointsArray[i] / 10)

                                                                                                                                                    + ' ' + ' degC' + '           | ' + '\n';


                                                                                                                                            } else if (i >= 9 && SetPointsArray[i] >= 999) {
                                                                                                                                                TextContent = TextContent + '      Zone ' + (i + 1) + '    |        ' + ZoneOnArray[i] + '        |        ' + '--' + '      |   ' + (SetPointsArray[i] / 10)

                                                                                                                                                    + ' ' + 'degC' + '           | ' + '\n';
                                                                                                                                            }
                                                                                                                                        }
                                                                                                                                    }


                                                                                                                                }else {
                                                                                                                                    if (GroupIDsArray[i] < 10) {
                                                                                                                                        if (i < 9 && SetPointsArray[i] < 999) {
                                                                                                                                            TextContent = TextContent + '      Zone ' + (i + 1) + '     |        ' + 'x' + '        |        ' + 'x' + '       |   ' + 'xx'

                                                                                                                                                + ' ' + '     ' + '           | ' + '\n';

                                                                                                                                        } else if (i < 9 && SetPointsArray[i] >= 999) {
                                                                                                                                            TextContent = TextContent + '      Zone ' + (i + 1) + '     |        ' + 'x' + '        |        ' + 'x' + '       |   ' + 'xxx'

                                                                                                                                                + ' ' + '    ' + '           | ' + '\n';
                                                                                                                                        } else if (i >= 9 && SetPointsArray[i] < 999) {
                                                                                                                                            TextContent = TextContent + '      Zone ' + (i + 1) + '    |        ' + 'x' + '        |        ' + 'x' + '       |   ' + 'xx'

                                                                                                                                                + ' ' + '     ' + '           | ' + '\n';


                                                                                                                                        } else if (i >= 9 && SetPointsArray[i] >= 999) {
                                                                                                                                            TextContent = TextContent + '      Zone ' + (i + 1) + '    |        ' + 'x' + '        |        ' + 'x' + '       |   ' + 'xxx'

                                                                                                                                                + ' ' + '    ' + '           | ' + '\n';
                                                                                                                                        }

                                                                                                                                    } else {
                                                                                                                                        if (i < 9 && SetPointsArray[i] < 999) {
                                                                                                                                            TextContent = TextContent + '      Zone ' + (i + 1) + '     |        ' + 'x' + '        |        ' + 'x' + '      |   ' + 'xx'

                                                                                                                                                + ' ' + '     ' + '           | ' + '\n';

                                                                                                                                        } else if (i < 9 && SetPointsArray[i] >= 999) {
                                                                                                                                            TextContent = TextContent + '      Zone ' + (i + 1) + '     |        ' + 'x' + '        |        ' + 'x' + '      |   ' + 'xxx'

                                                                                                                                                + ' ' + '    ' + '           | ' + '\n';
                                                                                                                                        } else if (i >= 9 && SetPointsArray[i] < 999) {
                                                                                                                                            TextContent = TextContent + '      Zone ' + (i + 1) + '    |        ' + 'x' + '        |        ' + 'x' + '      |   ' + 'xx'

                                                                                                                                                + ' ' + '     ' + '           | ' + '\n';


                                                                                                                                        } else if (i >= 9 && SetPointsArray[i] >= 999) {
                                                                                                                                            TextContent = TextContent + '      Zone ' + (i + 1) + '    |        ' + 'x' + '        |        ' + 'x' + '      |   ' + 'xxx'

                                                                                                                                                + ' ' + '    ' + '           | ' + '\n';
                                                                                                                                        }
                                                                                                                                    }
                                                                                                                                }
                                                                                                                            }

                                                                                                                            TextContent = TextContent + '___________________________________________________________________________| \n\n' +
                                                                                                                                'Gruppenstruktur:  \n\n' +
                                                                                                                                '___________________________________________________________________________ \n';

                                                                                                                            for (let i = 0; i < 11; i++) {
                                                                                                                              //  if (GroupsArray[i] !== 0){
                                                                                                                                    if ( i === 10) {
                                                                                                                                        if (ElementenCounter[i] < 7) {
                                                                                                                                            TextContent = TextContent + ' ohne Gruppe  ' + '    | ' + GroupsArray[i] + '\n'
                                                                                                                                                + '___________________________________________________________________________ \n';
                                                                                                                                        } else if (ElementenCounter[i] >= 7 && ElementenCounter[i] < 13) {

                                                                                                                                            TextContent = TextContent + ' ohne Gruppe  ' + '    | ' + GroupsArray[i].slice(0, 54) + '\n' + '                  | '
                                                                                                                                                + GroupsArray[i].slice(54) + '\n'
                                                                                                                                                + '___________________________________________________________________________ \n';
                                                                                                                                        } else if (ElementenCounter[i] >= 13 && ElementenCounter[i] < 19) {

                                                                                                                                            TextContent = TextContent + ' ohne Gruppe  ' + '    | ' + GroupsArray[i].slice(0, 54) + '\n' + '                  | '
                                                                                                                                                + GroupsArray[i].slice(54, 108) + '\n' + '                  | ' +
                                                                                                                                                GroupsArray[i].slice(108) + '\n'
                                                                                                                                                + '___________________________________________________________________________ \n';
                                                                                                                                        } else if (ElementenCounter[i] >= 19) {

                                                                                                                                            TextContent = TextContent + ' ohne Gruppe  ' + '    | ' + GroupsArray[i].slice(0, 54) + '\n' + '                  | '
                                                                                                                                                + GroupsArray[i].slice(54, 108) + '\n' + '                  | ' +
                                                                                                                                                GroupsArray[i].slice(108, 162) + '\n' + '                  | ' +
                                                                                                                                                GroupsArray[i].slice(162) + '\n'
                                                                                                                                                + '___________________________________________________________________________ \n';
                                                                                                                                        }
                                                                                                                                    }
                                                                                                                                    else if (i !== 9){
                                                                                                                                        if (ElementenCounter[i] < 7) {
                                                                                                                                            TextContent = TextContent + '      Gruppe ' + (i + 1) + '    | ' + GroupsArray[i] + '\n'
                                                                                                                                                + '___________________________________________________________________________ \n';
                                                                                                                                        } else if (ElementenCounter[i] >= 7 && ElementenCounter[i] < 13) {

                                                                                                                                            TextContent = TextContent + '      Gruppe ' + (i + 1) + '    | ' + GroupsArray[i].slice(0, 54) + '\n' + '                  | '
                                                                                                                                                + GroupsArray[i].slice(54) + '\n'
                                                                                                                                                + '___________________________________________________________________________ \n';
                                                                                                                                        } else if (ElementenCounter[i] >= 13 && ElementenCounter[i] < 19) {

                                                                                                                                            TextContent = TextContent + '      Gruppe ' + (i + 1) + '    | ' + GroupsArray[i].slice(0, 54) + '\n' + '                  | '
                                                                                                                                                + GroupsArray[i].slice(54, 108) + '\n' + '                  | ' +
                                                                                                                                                GroupsArray[i].slice(108) + '\n'
                                                                                                                                                + '___________________________________________________________________________ \n';
                                                                                                                                        } else if (ElementenCounter[i] >= 19) {

                                                                                                                                            TextContent = TextContent + '      Gruppe ' + (i + 1) + '    | ' + GroupsArray[i].slice(0, 54) + '\n' + '                  | '
                                                                                                                                                + GroupsArray[i].slice(54, 108) + '\n' + '                  | ' +
                                                                                                                                                GroupsArray[i].slice(108, 162) + '\n' + '                  | ' +
                                                                                                                                                GroupsArray[i].slice(162) + '\n'
                                                                                                                                                + '___________________________________________________________________________ \n';
                                                                                                                                        }

                                                                                                                                    } else {

                                                                                                                                        if (ElementenCounter[i] < 7) {
                                                                                                                                            TextContent = TextContent + '      Gruppe ' + (i + 1) + '   | ' + GroupsArray[i] + '\n'
                                                                                                                                                + '___________________________________________________________________________ \n';
                                                                                                                                        } else if (ElementenCounter[i] >= 7 && ElementenCounter[i] < 13) {

                                                                                                                                            TextContent = TextContent + '      Gruppe ' + (i + 1) + '   | ' + GroupsArray[i].slice(0, 54) + '\n' + '                  | '
                                                                                                                                                + GroupsArray[i].slice(54) + '\n'
                                                                                                                                                + '___________________________________________________________________________ \n';
                                                                                                                                        } else if (ElementenCounter[i] >= 13 && ElementenCounter[i] < 19) {

                                                                                                                                            TextContent = TextContent + '      Gruppe ' + (i + 1) + '   | ' + GroupsArray[i].slice(0, 54) + '\n' + '                  | '
                                                                                                                                                + GroupsArray[i].slice(54, 108) + '\n' + '                  | ' +
                                                                                                                                                GroupsArray[i].slice(108) + '\n'
                                                                                                                                                + '___________________________________________________________________________ \n';
                                                                                                                                        } else if (ElementenCounter[i] >= 19) {

                                                                                                                                            TextContent = TextContent + '      Gruppe ' + (i + 1) + '   | ' + GroupsArray[i].slice(0, 54) + '\n' + '                  | '
                                                                                                                                                + GroupsArray[i].slice(54, 108) + '\n' + '                  | ' +
                                                                                                                                                GroupsArray[i].slice(108, 162) + '\n' + '                  | ' +
                                                                                                                                                GroupsArray[i].slice(162) + '\n'
                                                                                                                                                + '___________________________________________________________________________ \n';
                                                                                                                                        }
                                                                                                                                    }
                                                                                                                             /*   }else {

                                                                                                                                }*/
                                                                                                                            }
                                                                                                                            // TextContent = TextContent + '___________________________________________________________________________ \n';

                                                                                                                            const Text = [TextContent];

                                                                                                                            const blob = new Blob(Text, {type: 'text/plain'});

                                                                                                                            // save recipe file:

                                                                                                                            sigApi.datapointManager.readDataPoint('10:SysDateTimePLC.Month', 0)
                                                                                                                                .then((resolve) => {
                                                                                                                                    let month = resolve.value.toString();
                                                                                                                                    if (month.length < 2) {month ="0" + month;}
                                                                                                                                    sigApi.datapointManager.readDataPoint('10:SysDateTimePLC.Day', 0)
                                                                                                                                        .then((resolve) => {
                                                                                                                                            let day  = resolve.value.toString();
                                                                                                                                            if (day.length < 2) {day ="0" + day;}
                                                                                                                                            sigApi.datapointManager.readDataPoint('10:SysDateTimePLC.Hour', 0)
                                                                                                                                                .then((resolve) => {
                                                                                                                                                    let hour  = resolve.value.toString();
                                                                                                                                                    if (hour.length < 2) {hour ="0" + hour;}
                                                                                                                                                    sigApi.datapointManager.readDataPoint('10:SysDateTimePLC.Minute', 0)
                                                                                                                                                        .then((resolve) => {
                                                                                                                                                            let minute  = resolve.value.toString();
                                                                                                                                                            if (minute.length < 2) {minute ="0" + minute;}
                                                                                                                                                            sigApi.datapointManager.readDataPoint('10:SysDateTimePLC.Year', 0)
                                                                                                                                                                .then((resolve) => {
                                                                                                                                                                    let year  = resolve.value.toString().slice(2,4);
                                                                                                                                                                    sigApi.datapointManager.readDataPoint('10:SysDateTimePLC.Second', 0)
                                                                                                                                                                        .then((resolve) => {
                                                                                                                                                                            let second  = resolve.value.toString();
                                                                                                                                                                            if (second.length < 2) {second ="0" + second;}


                                                                                                                                                                            // this._onRecipeSave(newname);
                                                                                                                                                                            const NEW_FILE_NEW = `${PREFIX}\\service/service_${year}${month}${day}_${hour}${minute}${second}.txt`;

                                                                                                                                                                            sigApi.fileManager.writeFile(NEW_FILE_NEW, blob).then((res) => {
                                                                                                                                                                                console.log(`[WriteServiceFile] sigApi.fileManager.writeFile('${NEW_FILE}', ...) uid: ${res.uid}`);
                                                                                                                                                                                sigApi.datapointManager.writeDataPoint('10:ToolsName1.Create', 1);

                                                                                                                                                                            }).catch((error) => {
                                                                                                                                                                                console.log(`[WriteServiceFile] error in sigApi.fileManager.writeFile('${NEW_FILE}', ...) uid: ${error.uid} status: ${error.status} errortxt: ${error.errortxt}`);
                                                                                                                                                                                sigApi.datapointManager.writeDataPoint('10:ToolsName1.ServiceFileOK', 1);
                                                                                                                                                                            });
                                                                                                                                                                        });});});});});});





                                                                                                                        })
                                                                                                                });
                                                                                                        }
                                                                                                    });});});
                                                                                            });});});});
                                                                                    });
                                                                            });
                                                                    });
                                                            });
                                                    });
                                            });
                                    });
                            });
                    });

            } else
            {
                sigApi.datapointManager.readDataPoint('10:PLC_Info1.CPU_Name', 0)
                    .then((resolve) => {
                        const PLC_Name = resolve.value;
                        sigApi.datapointManager.readDataPoint('10:ProjectRevision1.Data', 0)
                            .then((resolve) => {
                                const PLC_Version = resolve.value.toString();
                                sigApi.datapointManager.readDataPoint('10:PLC_Info1.SerNum', 0)
                                    .then((resolve) => {
                                        const PLC_Serie = resolve.value.toString();

                                        sigApi.datapointManager.readDataPoint('225:PLC_Info1.CPU_Name', 0)
                                            .then((resolve) => {
                                                const HMI_Name = resolve.value;
                                                sigApi.datapointManager.readDataPoint('225:ProjectRevision1.Data', 0)
                                                    .then((resolve) => {
                                                        const HMI_Version = resolve.value.toString();
                                                        sigApi.datapointManager.readDataPoint('225:VersionNumber1.SerialNumberString', 0)
                                                            .then((resolve) => {
                                                                const HMI_Serie = resolve.value.toString();
                                                                sigApi.datapointManager.readDataPoint('10:Global_Set1.AbsoluteMAXTemperatur', 0)
                                                                    .then((resolve) => {
                                                                        const Max_Temperature = resolve.value.toString();
                                                                        sigApi.datapointManager.readDataPoint('10:Global_Set1.ZielSollTemperaturRampe', 0)
                                                                            .then((resolve) => {
                                                                                const Ramp_Temperature = resolve.value.toString();
                                                                                sigApi.datapointManager.readDataPoint('10:Global_Set1.LowerValue', 0)
                                                                                    .then((resolve) => {
                                                                                        const Lower_Temperatur = resolve.value.toString();
                                                                                        sigApi.datapointManager.readDataPoint('10:Global_Set1.BoostValue', 0)
                                                                                            .then((resolve) => {
                                                                                                const Boost_Temperature = resolve.value.toString();
                                                                                                sigApi.datapointManager.readDataPoint('10:Global_Set1.BoostTime', 0)
                                                                                                    .then((resolve) => {
                                                                                                        const Boost_Time = resolve.value.toString();
                                                                                                        sigApi.datapointManager.readDataPoint('10:ToolsName1.Tools_Name', 0)
                                                                                                            .then((resolve) => {
                                                                                                                const newname = resolve.value;
                                                                                                                sigApi.datapointManager.readDataPoint('10:DeviceInformation1.MaxTmpZones', 0)
                                                                                                                    .then((resolve) => {
                                                                                                                        const number_of_zones = resolve.value;
                                                                                                                        sigApi.datapointManager.readDataPoint('10:DeviceInformation1.DeviceData', 0)
                                                                                                                            .then((resolve) => {
                                                                                                                                const serien_number = resolve.value.toString();
                                                                                                                                sigApi.datapointManager.readDataPoint('10:StringOSVersion_Plc.Data', 0)
                                                                                                                                    .then((resolve) => {
                                                                                                                                        const OS_Version_PLC = resolve.value;
                                                                                                                                        sigApi.datapointManager.readDataPoint('225:StringOSVersion_HMI.Data', 0)
                                                                                                                                            .then((resolve) => {
                                                                                                                                                const OS_Version_HMI = resolve.value;


                                                                                                                                let GroupIDsArray = [];
                                                                                                                                let SetPointsArray = [];
                                                                                                                                let ZoneOnArray = [];
                                                                                                                                let GroupsArray = ['', '', '', '', '', '', '', '', '', '',''];
                                                                                                                                let ElementenCounter = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0];
                                                                                                                                let TextContent =
                                                                                                            'Tool:             ' + newname + '\n' +
                                                                                                            'Number of zones:  ' + number_of_zones + '\n' +
                                                                                                            'Serial number:    ' + serien_number + '\n\n' +
                                                                                                            'PLC: \n\n' +
                                                                                                            'Name:             ' + PLC_Name + '\n' +
                                                                                                            'Version:          ' + PLC_Version + '\n' +
                                                                                                                                    'OS version:       ' + OS_Version_PLC + '\n' +
                                                                                                            'Serial number:    ' + PLC_Serie + '\n\n' +
                                                                                                            '___________________________________________________________________________ \n\n' +
                                                                                                            'HMI: \n\n' +
                                                                                                            'Name:             ' + HMI_Name + '\n' +
                                                                                                            'Version:          ' + HMI_Version + '\n' +
                                                                                                                                    'OS version:       ' + OS_Version_HMI + '\n' +
                                                                                                            'Serial number:    ' + HMI_Serie + '\n\n' + '___________________________________________________________________________ \n\n' +
                                                                                                            'Temperatur settings: \n\n' +
                                                                                                            'Maximum temperature: ' + '                        ' + (Max_Temperature / 10) + ' degC' + '\n' +
                                                                                                            'Soft start of the heating function: ' + '         ' + (Ramp_Temperature / 10) + ' degC' + '\n' +
                                                                                                            'Lowering for: ' + '                               ' + (Lower_Temperatur / 10) + ' degC' + '\n' +
                                                                                                            'Boosten for: ' + '                                ' + (Boost_Temperature / 10) + '  degC' + '\n' +
                                                                                                            'Duration og the boosten: ' + '                    ' + (Boost_Time / 60000) + '   min' + '\n\n' +
                                                                                                            '___________________________________________________________________________ \n\n' +

                                                                                                            'Zone structure:  \n\n' +

                                                                                                            '___________________________________________________________________________' + '\n' +
                                                                                                            '      Zone Nr.   |    Zone aktiv   |    Group Nr.   | Target temperature   |' + '\n' +
                                                                                                            '___________________________________________________________________________|' + '\n';

                                                                                                        const quality = 0;
                                                                                                        if (this.datapointAPI !== null) {
                                                                                                            return Promise.resolve()
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone1.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone2.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone3.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone4.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone5.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone6.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone7.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone8.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone9.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone10.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone11.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone12.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone13.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone14.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone15.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);

                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone16.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone17.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone18.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone19.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone20.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone21.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone22.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone23.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone24.GroupID', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            GroupIDsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone1.SetPoint', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone2.SetPoint', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone3.SetPoint', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone4.SetPoint', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone5.SetPoint', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone6.SetPoint', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone7.SetPoint', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone8.SetPoint', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone9.SetPoint', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone10.SetPoint', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone11.SetPoint', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone12.SetPoint', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone13.SetPoint', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone14.SetPoint', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone15.SetPoint', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);

                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone16.SetPoint', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone17.SetPoint', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone18.SetPoint', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone19.SetPoint', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone20.SetPoint', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone21.SetPoint', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone22.SetPoint', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone23.SetPoint', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone24.SetPoint', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            SetPointsArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone1.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone2.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone3.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone4.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone5.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone6.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone7.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone8.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone9.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone10.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone11.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone12.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone13.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone14.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone15.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);

                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone16.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone17.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone18.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone19.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone20.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone21.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone22.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone23.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);
                                                                                                                        })
                                                                                                                })
                                                                                                                .then(() => {
                                                                                                                    return sigApi.datapointManager.readDataPoint('10:Zone24.ZoneOn', quality)
                                                                                                                        .then((resolve) => {
                                                                                                                            ZoneOnArray.push(resolve.value);

                                                                                                                            for (let index = 0; index < 24; index++) {

                                                                                                                                if (ZoneOnArray[index] !==0){
                                                                                                                                    switch (GroupIDsArray[index]) {
                                                                                                                                        case 0:
                                                                                                                                            ElementenCounter[10]++;
                                                                                                                                            if (index < 9) {
                                                                                                                                                GroupsArray[10] = GroupsArray[10] + 'Zone 0' + (index + 1) + '; ';
                                                                                                                                            } else {
                                                                                                                                                GroupsArray[10] = GroupsArray[10] + 'Zone ' + (index + 1) + '; ';
                                                                                                                                            }
                                                                                                                                            break;


                                                                                                                                        case 1:
                                                                                                                                            ElementenCounter[0]++;
                                                                                                                                            if (index < 9) {
                                                                                                                                                GroupsArray[0] = GroupsArray[0] + 'Zone 0' + (index + 1) + '; ';
                                                                                                                                            } else {
                                                                                                                                                GroupsArray[0] = GroupsArray[0] + 'Zone ' + (index + 1) + '; ';
                                                                                                                                            }
                                                                                                                                            break;
                                                                                                                                        case 2:
                                                                                                                                            ElementenCounter[1]++;
                                                                                                                                            if (index < 9) {
                                                                                                                                                GroupsArray[1] = GroupsArray[1] + 'Zone 0' + (index + 1) + '; ';
                                                                                                                                            } else {
                                                                                                                                                GroupsArray[1] = GroupsArray[1] + 'Zone ' + (index + 1) + '; ';
                                                                                                                                            }

                                                                                                                                            break;
                                                                                                                                        case 3:
                                                                                                                                            ElementenCounter[2]++;
                                                                                                                                            if (index < 9) {
                                                                                                                                                GroupsArray[2] = GroupsArray[2] + 'Zone 0' + (index + 1) + '; ';
                                                                                                                                            } else {
                                                                                                                                                GroupsArray[2] = GroupsArray[2] + 'Zone ' + (index + 1) + '; ';
                                                                                                                                            }

                                                                                                                                            break;
                                                                                                                                        case 4:
                                                                                                                                            ElementenCounter[3]++;
                                                                                                                                            if (index < 9) {
                                                                                                                                                GroupsArray[3] = GroupsArray[3] + 'Zone 0' + (index + 1) + '; ';
                                                                                                                                            } else {
                                                                                                                                                GroupsArray[3] = GroupsArray[3] + 'Zone ' + (index + 1) + '; ';
                                                                                                                                            }

                                                                                                                                            break;
                                                                                                                                        case 5:
                                                                                                                                            ElementenCounter[4]++;
                                                                                                                                            if (index < 9) {
                                                                                                                                                GroupsArray[4] = GroupsArray[4] + 'Zone 0' + (index + 1) + '; ';
                                                                                                                                            } else {
                                                                                                                                                GroupsArray[4] = GroupsArray[4] + 'Zone ' + (index + 1) + '; ';
                                                                                                                                            }

                                                                                                                                            break;
                                                                                                                                        case 6:
                                                                                                                                            ElementenCounter[5]++;
                                                                                                                                            if (index < 9) {
                                                                                                                                                GroupsArray[5] = GroupsArray[5] + 'Zone 0' + (index + 1) + '; ';
                                                                                                                                            } else {
                                                                                                                                                GroupsArray[5] = GroupsArray[5] + 'Zone ' + (index + 1) + '; ';
                                                                                                                                            }

                                                                                                                                            break;
                                                                                                                                        case 7:
                                                                                                                                            ElementenCounter[6]++;
                                                                                                                                            if (index < 9) {
                                                                                                                                                GroupsArray[6] = GroupsArray[6] + 'Zone 0' + (index + 1) + '; ';
                                                                                                                                            } else {
                                                                                                                                                GroupsArray[6] = GroupsArray[6] + 'Zone ' + (index + 1) + '; ';
                                                                                                                                            }

                                                                                                                                            break;
                                                                                                                                        case 8:
                                                                                                                                            ElementenCounter[7]++;
                                                                                                                                            if (index < 9) {
                                                                                                                                                GroupsArray[7] = GroupsArray[7] + 'Zone 0' + (index + 1) + '; ';
                                                                                                                                            } else {
                                                                                                                                                GroupsArray[7] = GroupsArray[7] + 'Zone ' + (index + 1) + '; ';
                                                                                                                                            }

                                                                                                                                            break;
                                                                                                                                        case 9:
                                                                                                                                            ElementenCounter[8]++;
                                                                                                                                            if (index < 9) {
                                                                                                                                                GroupsArray[8] = GroupsArray[8] + 'Zone 0' + (index + 1) + '; ';
                                                                                                                                            } else {
                                                                                                                                                GroupsArray[8] = GroupsArray[8] + 'Zone ' + (index + 1) + '; ';
                                                                                                                                            }

                                                                                                                                            break;
                                                                                                                                        case 10:
                                                                                                                                            ElementenCounter[9]++;
                                                                                                                                            if (index < 9) {
                                                                                                                                                GroupsArray[9] = GroupsArray[9] + 'Zone 0' + (index + 1) + '; ';
                                                                                                                                            } else {
                                                                                                                                                GroupsArray[9] = GroupsArray[9] + 'Zone ' + (index + 1) + '; ';
                                                                                                                                            }

                                                                                                                                            break;
                                                                                                                                    }
                                                                                                                                }
                                                                                                                            }

                                                                                                                            for (let i = 0; i < 24; i++) {
                                                                                                                                if (ZoneOnArray[i] !== 0){

                                                                                                                                    if (GroupIDsArray[i] !== 0){
                                                                                                                                        if (GroupIDsArray[i] < 10) {
                                                                                                                                            if (i < 9 && SetPointsArray[i] < 999) {
                                                                                                                                                TextContent = TextContent + '      Zone ' + (i + 1) + '     |        ' + ZoneOnArray[i] + '        |        ' + GroupIDsArray[i] + '       |   ' + (SetPointsArray[i] / 10)

                                                                                                                                                    + ' ' + ' degC' + '           | ' + '\n';

                                                                                                                                            } else if (i < 9 && SetPointsArray[i] >= 999) {
                                                                                                                                                TextContent = TextContent + '      Zone ' + (i + 1) + '     |        ' + ZoneOnArray[i] + '        |        ' + GroupIDsArray[i] + '       |   ' + (SetPointsArray[i] / 10)

                                                                                                                                                    + ' ' + 'degC' + '           | ' + '\n';
                                                                                                                                            } else if (i >= 9 && SetPointsArray[i] < 999) {
                                                                                                                                                TextContent = TextContent + '      Zone ' + (i + 1) + '    |        ' + ZoneOnArray[i] + '        |        ' + GroupIDsArray[i] + '       |   ' + (SetPointsArray[i] / 10)

                                                                                                                                                    + ' ' + ' degC' + '           | ' + '\n';


                                                                                                                                            } else if (i >= 9 && SetPointsArray[i] >= 999) {
                                                                                                                                                TextContent = TextContent + '      Zone ' + (i + 1) + '    |        ' + ZoneOnArray[i] + '        |        ' + GroupIDsArray[i] + '       |   ' + (SetPointsArray[i] / 10)

                                                                                                                                                    + ' ' + 'degC' + '           | ' + '\n';
                                                                                                                                            }

                                                                                                                                        } else {
                                                                                                                                            if (i < 9 && SetPointsArray[i] < 999) {
                                                                                                                                                TextContent = TextContent + '      Zone ' + (i + 1) + '     |        ' + ZoneOnArray[i] + '        |        ' + GroupIDsArray[i] + '      |   ' + (SetPointsArray[i] / 10)

                                                                                                                                                    + ' ' + ' degC' + '           | ' + '\n';

                                                                                                                                            } else if (i < 9 && SetPointsArray[i] >= 999) {
                                                                                                                                                TextContent = TextContent + '      Zone ' + (i + 1) + '     |        ' + ZoneOnArray[i] + '        |        ' + GroupIDsArray[i] + '      |   ' + (SetPointsArray[i] / 10)

                                                                                                                                                    + ' ' + 'degC' + '           | ' + '\n';
                                                                                                                                            } else if (i >= 9 && SetPointsArray[i] < 999) {
                                                                                                                                                TextContent = TextContent + '      Zone ' + (i + 1) + '    |        ' + ZoneOnArray[i] + '        |        ' + GroupIDsArray[i] + '      |   ' + (SetPointsArray[i] / 10)

                                                                                                                                                    + ' ' + ' degC' + '           | ' + '\n';


                                                                                                                                            } else if (i >= 9 && SetPointsArray[i] >= 999) {
                                                                                                                                                TextContent = TextContent + '      Zone ' + (i + 1) + '    |        ' + ZoneOnArray[i] + '        |        ' + GroupIDsArray[i] + '      |   ' + (SetPointsArray[i] / 10)

                                                                                                                                                    + ' ' + 'degC' + '           | ' + '\n';
                                                                                                                                            }
                                                                                                                                        }
                                                                                                                                    }else
                                                                                                                                    {
                                                                                                                                        if (GroupIDsArray[i] < 10) {
                                                                                                                                            if (i < 9 && SetPointsArray[i] < 999) {
                                                                                                                                                TextContent = TextContent + '      Zone ' + (i + 1) + '     |        ' + ZoneOnArray[i] + '        |        ' + '-' + '       |   ' + (SetPointsArray[i] / 10)

                                                                                                                                                    + ' ' + ' degC' + '           | ' + '\n';

                                                                                                                                            } else if (i < 9 && SetPointsArray[i] >= 999) {
                                                                                                                                                TextContent = TextContent + '      Zone ' + (i + 1) + '     |        ' + ZoneOnArray[i] + '        |        ' + '-' + '       |   ' + (SetPointsArray[i] / 10)

                                                                                                                                                    + ' ' + 'degC' + '           | ' + '\n';
                                                                                                                                            } else if (i >= 9 && SetPointsArray[i] < 999) {
                                                                                                                                                TextContent = TextContent + '      Zone ' + (i + 1) + '    |        ' + ZoneOnArray[i] + '        |        ' + '-' + '       |   ' + (SetPointsArray[i] / 10)

                                                                                                                                                    + ' ' + ' degC' + '           | ' + '\n';


                                                                                                                                            } else if (i >= 9 && SetPointsArray[i] >= 999) {
                                                                                                                                                TextContent = TextContent + '      Zone ' + (i + 1) + '    |        ' + ZoneOnArray[i] + '        |        ' + '-' + '       |   ' + (SetPointsArray[i] / 10)

                                                                                                                                                    + ' ' + 'degC' + '           | ' + '\n';
                                                                                                                                            }

                                                                                                                                        } else {
                                                                                                                                            if (i < 9 && SetPointsArray[i] < 999) {
                                                                                                                                                TextContent = TextContent + '      Zone ' + (i + 1) + '     |        ' + ZoneOnArray[i] + '        |        ' + '--' + '      |   ' + (SetPointsArray[i] / 10)

                                                                                                                                                    + ' ' + ' degC' + '           | ' + '\n';

                                                                                                                                            } else if (i < 9 && SetPointsArray[i] >= 999) {
                                                                                                                                                TextContent = TextContent + '      Zone ' + (i + 1) + '     |        ' + ZoneOnArray[i] + '        |        ' + '--' + '      |   ' + (SetPointsArray[i] / 10)

                                                                                                                                                    + ' ' + 'degC' + '           | ' + '\n';
                                                                                                                                            } else if (i >= 9 && SetPointsArray[i] < 999) {
                                                                                                                                                TextContent = TextContent + '      Zone ' + (i + 1) + '    |        ' + ZoneOnArray[i] + '        |        ' + '--' + '      |   ' + (SetPointsArray[i] / 10)

                                                                                                                                                    + ' ' + ' degC' + '           | ' + '\n';


                                                                                                                                            } else if (i >= 9 && SetPointsArray[i] >= 999) {
                                                                                                                                                TextContent = TextContent + '      Zone ' + (i + 1) + '    |        ' + ZoneOnArray[i] + '        |        ' + '--' + '      |   ' + (SetPointsArray[i] / 10)

                                                                                                                                                    + ' ' + 'degC' + '           | ' + '\n';
                                                                                                                                            }
                                                                                                                                        }
                                                                                                                                    }


                                                                                                                                }else {
                                                                                                                                    if (GroupIDsArray[i] < 10) {
                                                                                                                                        if (i < 9 && SetPointsArray[i] < 999) {
                                                                                                                                            TextContent = TextContent + '      Zone ' + (i + 1) + '     |        ' + 'x' + '        |        ' + 'x' + '       |   ' + 'xx'

                                                                                                                                                + ' ' + '     ' + '           | ' + '\n';

                                                                                                                                        } else if (i < 9 && SetPointsArray[i] >= 999) {
                                                                                                                                            TextContent = TextContent + '      Zone ' + (i + 1) + '     |        ' + 'x' + '        |        ' + 'x' + '       |   ' + 'xxx'

                                                                                                                                                + ' ' + '    ' + '           | ' + '\n';
                                                                                                                                        } else if (i >= 9 && SetPointsArray[i] < 999) {
                                                                                                                                            TextContent = TextContent + '      Zone ' + (i + 1) + '    |        ' + 'x' + '        |        ' + 'x' + '       |   ' + 'xx'

                                                                                                                                                + ' ' + '     ' + '           | ' + '\n';


                                                                                                                                        } else if (i >= 9 && SetPointsArray[i] >= 999) {
                                                                                                                                            TextContent = TextContent + '      Zone ' + (i + 1) + '    |        ' + 'x' + '        |        ' + 'x' + '       |   ' + 'xxx'

                                                                                                                                                + ' ' + '    ' + '           | ' + '\n';
                                                                                                                                        }

                                                                                                                                    } else {
                                                                                                                                        if (i < 9 && SetPointsArray[i] < 999) {
                                                                                                                                            TextContent = TextContent + '      Zone ' + (i + 1) + '     |        ' + 'x' + '        |        ' + 'x' + '      |   ' + 'xx'

                                                                                                                                                + ' ' + '     ' + '           | ' + '\n';

                                                                                                                                        } else if (i < 9 && SetPointsArray[i] >= 999) {
                                                                                                                                            TextContent = TextContent + '      Zone ' + (i + 1) + '     |        ' + 'x' + '        |        ' + 'x' + '      |   ' + 'xxx'

                                                                                                                                                + ' ' + '    ' + '           | ' + '\n';
                                                                                                                                        } else if (i >= 9 && SetPointsArray[i] < 999) {
                                                                                                                                            TextContent = TextContent + '      Zone ' + (i + 1) + '    |        ' + 'x' + '        |        ' + 'x' + '      |   ' + 'xx'

                                                                                                                                                + ' ' + '     ' + '           | ' + '\n';


                                                                                                                                        } else if (i >= 9 && SetPointsArray[i] >= 999) {
                                                                                                                                            TextContent = TextContent + '      Zone ' + (i + 1) + '    |        ' + 'x' + '        |        ' + 'x' + '      |   ' + 'xxx'

                                                                                                                                                + ' ' + '    ' + '           | ' + '\n';
                                                                                                                                        }
                                                                                                                                    }
                                                                                                                                }
                                                                                                                            }

                                                                                                                            TextContent = TextContent + '___________________________________________________________________________| \n\n' +
                                                                                                                                'Group structure:  \n\n' +
                                                                                                                                '___________________________________________________________________________ \n';

                                                                                                                            for (let i = 0; i < 11; i++) {
                                                                                                                                if ( i === 10) {
                                                                                                                                    if (ElementenCounter[i] < 7) {
                                                                                                                                        TextContent = TextContent + 'without Group   ' + '  | ' + GroupsArray[i] + '\n'
                                                                                                                                            + '___________________________________________________________________________ \n';
                                                                                                                                    } else if (ElementenCounter[i] >= 7 && ElementenCounter[i] < 13) {

                                                                                                                                        TextContent = TextContent + 'without Group   ' + '  | ' + GroupsArray[i].slice(0, 54) + '\n' + '                  | '
                                                                                                                                            + GroupsArray[i].slice(54) + '\n'
                                                                                                                                            + '___________________________________________________________________________ \n';
                                                                                                                                    } else if (ElementenCounter[i] >= 13 && ElementenCounter[i] < 19) {

                                                                                                                                        TextContent = TextContent + 'without Group   ' + '  | ' + GroupsArray[i].slice(0, 54) + '\n' + '                  | '
                                                                                                                                            + GroupsArray[i].slice(54, 108) + '\n' + '                  | ' +
                                                                                                                                            GroupsArray[i].slice(108) + '\n'
                                                                                                                                            + '___________________________________________________________________________ \n';
                                                                                                                                    } else if (ElementenCounter[i] >= 19) {

                                                                                                                                        TextContent = TextContent + 'without Group   ' + '  | ' + GroupsArray[i].slice(0, 54) + '\n' + '                  | '
                                                                                                                                            + GroupsArray[i].slice(54, 108) + '\n' + '                  | ' +
                                                                                                                                            GroupsArray[i].slice(108, 162) + '\n' + '                  | ' +
                                                                                                                                            GroupsArray[i].slice(162) + '\n'
                                                                                                                                            + '___________________________________________________________________________ \n';
                                                                                                                                    }
                                                                                                                                }
                                                                                                                                else if (i !== 9){
                                                                                                                                    if (ElementenCounter[i] < 7) {
                                                                                                                                        TextContent = TextContent + '      Group  ' + (i + 1) + '    | ' + GroupsArray[i] + '\n'
                                                                                                                                            + '___________________________________________________________________________ \n';
                                                                                                                                    } else if (ElementenCounter[i] >= 7 && ElementenCounter[i] < 13) {

                                                                                                                                        TextContent = TextContent + '      Group  ' + (i + 1) + '    | ' + GroupsArray[i].slice(0, 54) + '\n' + '                  | '
                                                                                                                                            + GroupsArray[i].slice(54) + '\n'
                                                                                                                                            + '___________________________________________________________________________ \n';
                                                                                                                                    } else if (ElementenCounter[i] >= 13 && ElementenCounter[i] < 19) {

                                                                                                                                        TextContent = TextContent + '      Group  ' + (i + 1) + '    | ' + GroupsArray[i].slice(0, 54) + '\n' + '                  | '
                                                                                                                                            + GroupsArray[i].slice(54, 108) + '\n' + '                  | ' +
                                                                                                                                            GroupsArray[i].slice(108) + '\n'
                                                                                                                                            + '___________________________________________________________________________ \n';
                                                                                                                                    } else if (ElementenCounter[i] >= 19) {

                                                                                                                                        TextContent = TextContent + '      Group  ' + (i + 1) + '    | ' + GroupsArray[i].slice(0, 54) + '\n' + '                  | '
                                                                                                                                            + GroupsArray[i].slice(54, 108) + '\n' + '                  | ' +
                                                                                                                                            GroupsArray[i].slice(108, 162) + '\n' + '                  | ' +
                                                                                                                                            GroupsArray[i].slice(162) + '\n'
                                                                                                                                            + '___________________________________________________________________________ \n';
                                                                                                                                    }

                                                                                                                                } else {

                                                                                                                                    if (ElementenCounter[i] < 7) {
                                                                                                                                        TextContent = TextContent + '      Group  ' + (i + 1) + '   | ' + GroupsArray[i] + '\n'
                                                                                                                                            + '___________________________________________________________________________ \n';
                                                                                                                                    } else if (ElementenCounter[i] >= 7 && ElementenCounter[i] < 13) {

                                                                                                                                        TextContent = TextContent + '      Group  ' + (i + 1) + '   | ' + GroupsArray[i].slice(0, 54) + '\n' + '                  | '
                                                                                                                                            + GroupsArray[i].slice(54) + '\n'
                                                                                                                                            + '___________________________________________________________________________ \n';
                                                                                                                                    } else if (ElementenCounter[i] >= 13 && ElementenCounter[i] < 19) {

                                                                                                                                        TextContent = TextContent + '      Group  ' + (i + 1) + '   | ' + GroupsArray[i].slice(0, 54) + '\n' + '                  | '
                                                                                                                                            + GroupsArray[i].slice(54, 108) + '\n' + '                  | ' +
                                                                                                                                            GroupsArray[i].slice(108) + '\n'
                                                                                                                                            + '___________________________________________________________________________ \n';
                                                                                                                                    } else if (ElementenCounter[i] >= 19) {

                                                                                                                                        TextContent = TextContent + '      Group  ' + (i + 1) + '   | ' + GroupsArray[i].slice(0, 54) + '\n' + '                  | '
                                                                                                                                            + GroupsArray[i].slice(54, 108) + '\n' + '                  | ' +
                                                                                                                                            GroupsArray[i].slice(108, 162) + '\n' + '                  | ' +
                                                                                                                                            GroupsArray[i].slice(162) + '\n'
                                                                                                                                            + '___________________________________________________________________________ \n';
                                                                                                                                    }
                                                                                                                                }
                                                                                                                            }
                                                                                                                            // TextContent = TextContent + '___________________________________________________________________________ \n';

                                                                                                                            const Text = [TextContent];

                                                                                                                            const blob = new Blob(Text, {type: 'text/plain'});

// save recipe file:
                                                                                                                            sigApi.datapointManager.readDataPoint('10:SysDateTimePLC.Month', 0)
                                                                                                                                .then((resolve) => {
                                                                                                                                    let month = resolve.value.toString();
                                                                                                                                    if (month.length < 2) {month ="0" + month;}
                                                                                                                                    sigApi.datapointManager.readDataPoint('10:SysDateTimePLC.Day', 0)
                                                                                                                                        .then((resolve) => {
                                                                                                                                    let day  = resolve.value.toString();
                                                                                                                                            if (day.length < 2) {day ="0" + day;}
                                                                                                                                            sigApi.datapointManager.readDataPoint('10:SysDateTimePLC.Hour', 0)
                                                                                                                                                .then((resolve) => {
                                                                                                                                                    let hour  = resolve.value.toString();
                                                                                                                                                    if (hour.length < 2) {hour ="0" + hour;}
                                                                                                                                                    sigApi.datapointManager.readDataPoint('10:SysDateTimePLC.Minute', 0)
                                                                                                                                                        .then((resolve) => {
                                                                                                                                                            let minute  = resolve.value.toString();
                                                                                                                                                            if (minute.length < 2) {minute ="0" + minute;}
                                                                                                                                                            sigApi.datapointManager.readDataPoint('10:SysDateTimePLC.Year', 0)
                                                                                                                                                                .then((resolve) => {
                                                                                                                                                                    const year  = resolve.value.toString().slice(2,4);
                                                                                                                                                                    sigApi.datapointManager.readDataPoint('10:SysDateTimePLC.Second', 0)
                                                                                                                                                                        .then((resolve) => {
                                                                                                                                                                            let second  = resolve.value.toString();
                                                                                                                                                                            if (second.length < 2) {second ="0" + second;}


                                                                                                                                                            // this._onRecipeSave(newname);
                                                                                                                                    const NEW_FILE_NEW = `${PREFIX}\\service/service_${year}${month}${day}_${hour}${minute}${second}.txt`;

                                                                                                                                    sigApi.fileManager.writeFile(NEW_FILE_NEW, blob).then((res) => {
                                                                                                                                        console.log(`[WriteServiceFile] sigApi.fileManager.writeFile('${NEW_FILE}', ...) uid: ${res.uid}`);
                                                                                                                                        sigApi.datapointManager.writeDataPoint('10:ToolsName1.Create', 1);

                                                                                                                                    }).catch((error) => {
                                                                                                                                        console.log(`[WriteServiceFile] error in sigApi.fileManager.writeFile('${NEW_FILE}', ...) uid: ${error.uid} status: ${error.status} errortxt: ${error.errortxt}`);
                                                                                                                                        sigApi.datapointManager.writeDataPoint('10:ToolsName1.ServiceFileOK', 1);
                                                                                                                                    });
                                                                                                                                });});});});});});








                                                                                                                                                                                                                                                 })
                                                                                                                                                                                                                                         });
                                                                                                                                                                                                                                 }
                                                                                                                                                                                                                             });});});
                                                                                                                                                                                                                     });}); });});
                                                                                                                                                                                                             });
                                                                                                                                                                                                     });
                                                                                                                                                                                             });
                                                                                                                                                                                     });
                                                                                                                                                                             });
                                                                                                                                                                     });
                                                                                                                                                             });
                                                                                                                                                     });
                                                                                                                                             });
                                                                                                                                 }

                                                                                                                                     });

                                                                                                                                 // save recipe file:

                                                                                                                            /*     sigApi.datapointManager.readDataPoint('10:ToolsName1.Tools_Name_Unsaved', 0)
                                                                                                                                     .then((resolve) => {
                                                                                                                                         const newname = resolve.value.toLowerCase();
                                                                                                                                         this._onRecipeSave(newname);
                                                                                                                                     });*/

    }

    _onWriteFileProtokoll() {
        console.log('[WriteServiceFile] _onWriteFile()');

        sigApi.datapointManager.readDataPoint('10:Global_Set1.Language_Number', 0)
            .then((resolve) => {
                const Language = resolve.value;
                const quality = 0;
                let NEW_FILE_NEW = ``;
                let month,day,hour,minute,year, second;
                let ActualValue25Array = [];
                let ActualValue325Array = [];
                let Differenz25Array = [];
                let Differenz325Array = [];

                let SerienNr = ``;
                let TextContent = ``;
                if (this.datapointAPI !== null) {

                    return Promise.resolve()
                        .then(() => {
                            return sigApi.datapointManager.readDataPoint('10:SysDateTimePLC.Month', 0)
                                .then((resolve) => {
                                    month = resolve.value.toString();
                                    if (month.length < 2) {month ="0" + month;}
                                })
                        })
                        .then(() => {
                            return sigApi.datapointManager.readDataPoint('10:SysDateTimePLC.Day', 0)
                                .then((resolve) => {
                                    day  = resolve.value.toString();
                                    if (day.length < 2) {day ="0" + day;}
                                })
                        })
                        .then(() => {
                            return sigApi.datapointManager.readDataPoint('10:SysDateTimePLC.Hour', 0)
                                .then((resolve) => {
                                    hour  = resolve.value.toString();
                                    if (hour.length < 2) {hour ="0" + hour;}
                                })
                        })
                        .then(() => {
                            return sigApi.datapointManager.readDataPoint('10:SysDateTimePLC.Minute', 0)
                                .then((resolve) => {
                                    minute  = resolve.value.toString();
                                    if (minute.length < 2) {minute ="0" + minute;}
                                })
                        })
                        .then(() => {
                            return sigApi.datapointManager.readDataPoint('10:SysDateTimePLC.Year', 0)
                                .then((resolve) => {
                                    year  = resolve.value.toString().slice(2,4);
                                })
                        })
                        .then(() => {
                            sigApi.datapointManager.readDataPoint('10:SysDateTimePLC.Second', 0)
                                .then((resolve) => {
                                    second  = resolve.value.toString();
                                    if (second.length < 2) {second ="0" + second;}
                                    NEW_FILE_NEW = `${PREFIX}\\protokoll/protokoll_${year}${month}${day}_${hour}${minute}${second}.txt`;
                                })
                        })
                        .then(() => {
                            sigApi.datapointManager.readDataPoint('10:DeviceInformation1.DeviceData', 0)
                                .then((resolve) => {
                                    SerienNr  = resolve.value;
                                    TextContent =
                                        '__________________________________________________________________________ ' + '\n' +
                                        '     Datum:      |    ' + year +  '.' + month + '.' + day + '     | Serien - Nr.:    |     '  + SerienNr +  '\n' +
                                        '__________________________________________________________________________ ' + '\n';
                                    TextContent = TextContent +
                                        '     Pruefer:    |                 | Kunde:           |                      ' + '\n' +
                                        '__________________________________________________________________________ ' + '\n\n';

                                    
                                    TextContent = TextContent + 'Sensor type L, 25 degC:  \n\n' +

                                        '__________________________________________________________________________ ' + '\n' +
                                        '      Zone Nr.   |    Soll temp.   |    Ist temp.     |    Differenz       ' + '\n' +
                                        '__________________________________________________________________________ ' + '\n';
                                })
                        })
                        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone1.ActualValueCalib25', quality)
                .then((resolve) => {
                    ActualValue25Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone2.ActualValueCalib25', quality)
                .then((resolve) => {
                    ActualValue25Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone3.ActualValueCalib25', quality)
                .then((resolve) => {
                    ActualValue25Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone4.ActualValueCalib25', quality)
                .then((resolve) => {
                    ActualValue25Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone5.ActualValueCalib25', quality)
                .then((resolve) => {
                    ActualValue25Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone6.ActualValueCalib25', quality)
                .then((resolve) => {
                    ActualValue25Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone7.ActualValueCalib25', quality)
                .then((resolve) => {
                    ActualValue25Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone8.ActualValueCalib25', quality)
                .then((resolve) => {
                    ActualValue25Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone9.ActualValueCalib25', quality)
                .then((resolve) => {
                    ActualValue25Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone10.ActualValueCalib25', quality)
                .then((resolve) => {
                    ActualValue25Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone11.ActualValueCalib25', quality)
                .then((resolve) => {
                    ActualValue25Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone12.ActualValueCalib25', quality)
                .then((resolve) => {
                    ActualValue25Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone13.ActualValueCalib25', quality)
                .then((resolve) => {
                    ActualValue25Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone14.ActualValueCalib25', quality)
                .then((resolve) => {
                    ActualValue25Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone15.ActualValueCalib25', quality)
                .then((resolve) => {
                    ActualValue25Array.push((resolve.value/10).toFixed(2));

                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone16.ActualValueCalib25', quality)
                .then((resolve) => {
                    ActualValue25Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone17.ActualValueCalib25', quality)
                .then((resolve) => {
                    ActualValue25Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone18.ActualValueCalib25', quality)
                .then((resolve) => {
                    ActualValue25Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone19.ActualValueCalib25', quality)
                .then((resolve) => {
                    ActualValue25Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone20.ActualValueCalib25', quality)
                .then((resolve) => {
                    ActualValue25Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone21.ActualValueCalib25', quality)
                .then((resolve) => {
                    ActualValue25Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone22.ActualValueCalib25', quality)
                .then((resolve) => {
                    ActualValue25Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone23.ActualValueCalib25', quality)
                .then((resolve) => {
                    ActualValue25Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone24.ActualValueCalib25', quality)
                .then((resolve) => {
                    ActualValue25Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone1.ActualValueCalib325', quality)
                .then((resolve) => {
                    ActualValue325Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone2.ActualValueCalib325', quality)
                .then((resolve) => {
                    ActualValue325Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone3.ActualValueCalib325', quality)
                .then((resolve) => {
                    ActualValue325Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone4.ActualValueCalib325', quality)
                .then((resolve) => {
                    ActualValue325Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone5.ActualValueCalib325', quality)
                .then((resolve) => {
                    ActualValue325Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone6.ActualValueCalib325', quality)
                .then((resolve) => {
                    ActualValue325Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone7.ActualValueCalib325', quality)
                .then((resolve) => {
                    ActualValue325Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone8.ActualValueCalib325', quality)
                .then((resolve) => {
                    ActualValue325Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone9.ActualValueCalib325', quality)
                .then((resolve) => {
                    ActualValue325Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone10.ActualValueCalib325', quality)
                .then((resolve) => {
                    ActualValue325Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone11.ActualValueCalib325', quality)
                .then((resolve) => {
                    ActualValue325Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone12.ActualValueCalib325', quality)
                .then((resolve) => {
                    ActualValue325Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone13.ActualValueCalib325', quality)
                .then((resolve) => {
                    ActualValue325Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone14.ActualValueCalib325', quality)
                .then((resolve) => {
                    ActualValue325Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone15.ActualValueCalib325', quality)
                .then((resolve) => {
                    ActualValue325Array.push((resolve.value/10).toFixed(2));

                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone16.ActualValueCalib325', quality)
                .then((resolve) => {
                    ActualValue325Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone17.ActualValueCalib325', quality)
                .then((resolve) => {
                    ActualValue325Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone18.ActualValueCalib325', quality)
                .then((resolve) => {
                    ActualValue325Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone19.ActualValueCalib325', quality)
                .then((resolve) => {
                    ActualValue325Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone20.ActualValueCalib325', quality)
                .then((resolve) => {
                    ActualValue325Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone21.ActualValueCalib325', quality)
                .then((resolve) => {
                    ActualValue325Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone22.ActualValueCalib325', quality)
                .then((resolve) => {
                    ActualValue325Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone23.ActualValueCalib325', quality)
                .then((resolve) => {
                    ActualValue325Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone24.ActualValueCalib325', quality)
                .then((resolve) => {
                    ActualValue325Array.push((resolve.value/10).toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone1.DeltaTempCalib25', quality)
                .then((resolve) => {
                    Differenz25Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone2.DeltaTempCalib25', quality)
                .then((resolve) => {
                    Differenz25Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone3.DeltaTempCalib25', quality)
                .then((resolve) => {
                    Differenz25Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone4.DeltaTempCalib25', quality)
                .then((resolve) => {
                    Differenz25Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone5.DeltaTempCalib25', quality)
                .then((resolve) => {
                    Differenz25Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone6.DeltaTempCalib25', quality)
                .then((resolve) => {
                    Differenz25Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone7.DeltaTempCalib25', quality)
                .then((resolve) => {
                    Differenz25Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone8.DeltaTempCalib25', quality)
                .then((resolve) => {
                    Differenz25Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone9.DeltaTempCalib25', quality)
                .then((resolve) => {
                    Differenz25Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone10.DeltaTempCalib25', quality)
                .then((resolve) => {
                    Differenz25Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone11.DeltaTempCalib25', quality)
                .then((resolve) => {
                    Differenz25Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone12.DeltaTempCalib25', quality)
                .then((resolve) => {
                    Differenz25Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone13.DeltaTempCalib25', quality)
                .then((resolve) => {
                    Differenz25Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone14.DeltaTempCalib25', quality)
                .then((resolve) => {
                    Differenz25Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone15.DeltaTempCalib25', quality)
                .then((resolve) => {
                    Differenz25Array.push(resolve.value.toFixed(2));

                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone16.DeltaTempCalib25', quality)
                .then((resolve) => {
                    Differenz25Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone17.DeltaTempCalib25', quality)
                .then((resolve) => {
                    Differenz25Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone18.DeltaTempCalib25', quality)
                .then((resolve) => {
                    Differenz25Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone19.DeltaTempCalib25', quality)
                .then((resolve) => {
                    Differenz25Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone20.DeltaTempCalib25', quality)
                .then((resolve) => {
                    Differenz25Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone21.DeltaTempCalib25', quality)
                .then((resolve) => {
                    Differenz25Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone22.DeltaTempCalib25', quality)
                .then((resolve) => {
                    Differenz25Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone23.DeltaTempCalib25', quality)
                .then((resolve) => {
                    Differenz25Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone24.DeltaTempCalib25', quality)
                .then((resolve) => {
                    Differenz25Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone1.DeltaTempCalib325', quality)
                .then((resolve) => {

                    Differenz325Array.push(resolve.value.toFixed(2));

                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone2.DeltaTempCalib325', quality)
                .then((resolve) => {
                    Differenz325Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone3.DeltaTempCalib325', quality)
                .then((resolve) => {
                    Differenz325Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone4.DeltaTempCalib325', quality)
                .then((resolve) => {
                    Differenz325Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone5.DeltaTempCalib325', quality)
                .then((resolve) => {
                    Differenz325Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone6.DeltaTempCalib325', quality)
                .then((resolve) => {
                    Differenz325Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone7.DeltaTempCalib325', quality)
                .then((resolve) => {
                    Differenz325Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone8.DeltaTempCalib325', quality)
                .then((resolve) => {
                    Differenz325Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone9.DeltaTempCalib325', quality)
                .then((resolve) => {
                    Differenz325Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone10.DeltaTempCalib325', quality)
                .then((resolve) => {
                    Differenz325Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone11.DeltaTempCalib325', quality)
                .then((resolve) => {
                    Differenz325Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone12.DeltaTempCalib325', quality)
                .then((resolve) => {
                    Differenz325Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone13.DeltaTempCalib325', quality)
                .then((resolve) => {
                    Differenz325Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone14.DeltaTempCalib325', quality)
                .then((resolve) => {
                    Differenz325Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone15.DeltaTempCalib325', quality)
                .then((resolve) => {
                    Differenz325Array.push(resolve.value.toFixed(2));

                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone16.DeltaTempCalib325', quality)
                .then((resolve) => {
                    Differenz325Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone17.DeltaTempCalib325', quality)
                .then((resolve) => {
                    Differenz325Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone18.DeltaTempCalib325', quality)
                .then((resolve) => {
                    Differenz325Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone19.DeltaTempCalib325', quality)
                .then((resolve) => {
                    Differenz325Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone20.DeltaTempCalib325', quality)
                .then((resolve) => {
                    Differenz325Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone21.DeltaTempCalib325', quality)
                .then((resolve) => {
                    Differenz325Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone22.DeltaTempCalib325', quality)
                .then((resolve) => {
                    Differenz325Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone23.DeltaTempCalib325', quality)
                .then((resolve) => {
                    Differenz325Array.push(resolve.value.toFixed(2));
                })
        })
        .then(() => {
            return sigApi.datapointManager.readDataPoint('10:Zone24.DeltaTempCalib325', quality)
                .then((resolve) => {
                    Differenz325Array.push(resolve.value.toFixed(2));

                    for (let i = 0; i < 24; i++) {

                            if (ActualValue25Array[i] < 10) {
                                    if (i < 9) {
                                        TextContent = TextContent + '      Zone ' + (i + 1) + '     |        ' + '25' + '      |        ' + ActualValue25Array[i] + '      |   ' + Differenz25Array[i]

                                            + ' ' + ' degC' + '\n';

                                    } else {
                                        TextContent = TextContent + '      Zone ' + (i + 1) + '    |        ' + '25' + '       |        ' + ActualValue25Array[i] + '      |   ' + Differenz25Array[i]

                                            + ' ' + ' degC' + '\n';
                                    }

                                } else {
                                    if (i < 9 ) {
                                        TextContent = TextContent + '      Zone ' + (i + 1) + '     |        ' + '25' + '       |        ' + ActualValue25Array[i] + '     |   ' + Differenz25Array[i]

                                            + ' ' + ' degC' + '\n';

                                    } else {
                                        TextContent = TextContent + '      Zone ' + (i + 1) + '    |        ' + '25' + '       |        ' + ActualValue25Array[i] + '     |   ' + Differenz25Array[i]

                                            + ' ' + ' degC' + '\n';
                                    }
                                }


                    }

                    TextContent = TextContent + '__________________________________________________________________________  \n\n';

                    TextContent =  TextContent + 'Sensor type L, 325 degC:  \n\n' +

                        '__________________________________________________________________________ ' + '\n' +
                        '      Zone Nr.   |    Soll temp.   |    Ist temp.      |    Differenz      ' + '\n' +
                        '__________________________________________________________________________ ' + '\n';

                    for (let i = 0; i < 24; i++) {
                            if (ActualValue25Array[i] < 10) {
                                if (i < 9) {
                                    TextContent = TextContent + '      Zone ' + (i + 1) + '     |        ' + '325' + '      |        ' + ActualValue325Array[i] + '      |   ' + Differenz325Array[i]

                                        + ' ' + ' degC' + '\n';

                                } else {
                                    TextContent = TextContent + '      Zone ' + (i + 1) + '    |        ' + '325' + '       |        ' + ActualValue325Array[i] + '      |   ' + Differenz325Array[i]

                                        + ' ' + ' degC' + '\n';
                                }
                            } else {
                                if (i < 9) {
                                    TextContent = TextContent + '      Zone ' + (i + 1) + '     |        ' + '325' + '      |        ' + ActualValue325Array[i] + '     |   ' + Differenz325Array[i]

                                        + ' ' + ' degC' + '\n';

                                } else {
                                    TextContent = TextContent + '      Zone ' + (i + 1) + '    |        ' + '325' + '      |        ' + ActualValue325Array[i] + '     |   ' + Differenz325Array[i]

                                        + ' ' + ' degC' + '\n';
                                }
                            }
                    }

                    TextContent = TextContent + '__________________________________________________________________________ \n\n';

                    const Text = [TextContent];

                    const blob = new Blob(Text, {type: 'text/plain'});

                    // save recipe file:
                    // this._onRecipeSave(newname);
                  //  const NEW_FILE_NEW = `${PREFIX}\\protokoll/protokoll_${year}${month}${day}_${hour}${minute}${second}.txt`;

                    sigApi.fileManager.writeFile(NEW_FILE_NEW, blob).then((res) => {
                        console.log(`[WriteServiceFile] sigApi.fileManager.writeFile('${NEW_FILE}', ...) uid: ${res.uid}`);
                        sigApi.datapointManager.writeDataPoint('10:ToolsName1.Create', 1);

                    }).catch((error) => {
                        console.log(`[WriteServiceFile] error in sigApi.fileManager.writeFile('${NEW_FILE}', ...) uid: ${error.uid} status: ${error.status} errortxt: ${error.errortxt}`);
                        sigApi.datapointManager.writeDataPoint('10:ToolsName1.ServiceFileOK', 1);
                    });
                })
        });
                }

            });
    }
}

/**
 * Create the codemodule instance
 */
WriteServiceFile.init();
