
class DemoDatapointManager {

    static initDemoDatapointManager() {
        if (window.sigApi !== undefined) {
            const fm = new DemoDatapointManager(window.sigApi);
        } else {
            // ist sigApi noch nicht geladen, als EventListener fuer 'SigApiReady' registrieren
            window.addEventListener('SigApiReady', () => {
                const fm = new DemoDatapointManager(window.sigApi);
            });
        }
    }

    constructor(api) {
        this.events = null;
        this.eventMediator = null;
        this.datapointAPI = null;
        this._initAPIs(api);
        this._registerEvents();
    }

    //##################################################################################################
    // Alle benoetigten APIs zuweisen
    //##################################################################################################
    _initAPIs(api) {
        if ((api !== null) && (api !== undefined)) {
            if (api.datapointManager !== undefined) {
                this.datapointAPI = api.datapointManager;
            }
            if (api.eventMediator !== undefined) {
                this.eventMediator = api.eventMediator;
            }
            if (api.events !== undefined) {
                this.events = api.events;
            }
        }
    }
    _registerEvents() {
        let SelectedZoneID;
        if ((this.eventMediator !== null) && (this.eventMediator !== undefined) && (this.events !== null) && (this.events !== undefined)) {

            this.eventMediator.subscribe(this.events.getUserDefinedInternalEvent('Set_Set_Set_SelectedGroupID'), () => {
                this.datapointAPI.readDataPoint('10:SelectedZone1.ZoneID', 0)
                    .then((resolve) => {
                        SelectedZoneID = resolve.value + 1;
                        this.datapointAPI.writeDataPoint('10:SelectedZone1.ZoneID', SelectedZoneID)
                            .then((resolve) => {
                                switch (SelectedZoneID) {
                                    case 2:  this.setGroupIDandNavigateToDashboard('10:Zone2.GroupID',  '10:Zone1.OperationMode', '10:Zone2.OperationMode');break;
                                    case 3:  this.setGroupIDandNavigateToDashboard('10:Zone3.GroupID',  '10:Zone2.OperationMode', '10:Zone3.OperationMode');break;
                                    case 4:  this.setGroupIDandNavigateToDashboard('10:Zone4.GroupID',  '10:Zone3.OperationMode', '10:Zone4.OperationMode');break;
                                    case 5:  this.setGroupIDandNavigateToDashboard('10:Zone5.GroupID',  '10:Zone4.OperationMode', '10:Zone5.OperationMode');break;
                                    case 6:  this.setGroupIDandNavigateToDashboard('10:Zone6.GroupID',  '10:Zone5.OperationMode', '10:Zone6.OperationMode');break;
                                    case 7:  this.setGroupIDandNavigateToDashboard('10:Zone7.GroupID',  '10:Zone6.OperationMode', '10:Zone7.OperationMode');break;
                                    case 8:  this.setGroupIDandNavigateToDashboard('10:Zone8.GroupID',  '10:Zone7.OperationMode', '10:Zone8.OperationMode');break;
                                    case 9:  this.setGroupIDandNavigateToDashboard('10:Zone9.GroupID',  '10:Zone8.OperationMode', '10:Zone9.OperationMode');break;
                                    case 10: this.setGroupIDandNavigateToDashboard('10:Zone10.GroupID','10:Zone9.OperationMode', '10:Zone10.OperationMode');break;
                                    case 11: this.setGroupIDandNavigateToDashboard('10:Zone11.GroupID', '10:Zone10.OperationMode', '10:Zone11.OperationMode');break;
                                    case 12: this.setGroupIDandNavigateToDashboard('10:Zone12.GroupID', '10:Zone11.OperationMode', '10:Zone12.OperationMode');break;
                                    case 13: this.setGroupIDandNavigateToDashboard('10:Zone13.GroupID', '10:Zone12.OperationMode', '10:Zone13.OperationMode');break;
                                    case 14: this.setGroupIDandNavigateToDashboard('10:Zone14.GroupID', '10:Zone13.OperationMode', '10:Zone14.OperationMode');break;
                                    case 15: this.setGroupIDandNavigateToDashboard('10:Zone15.GroupID', '10:Zone14.OperationMode', '10:Zone15.OperationMode');break;
                                    case 16: this.setGroupIDandNavigateToDashboard('10:Zone16.GroupID', '10:Zone15.OperationMode', '10:Zone16.OperationMode');break;
                                    case 17: this.setGroupIDandNavigateToDashboard('10:Zone17.GroupID', '10:Zone16.OperationMode', '10:Zone17.OperationMode');break;
                                    case 18: this.setGroupIDandNavigateToDashboard('10:Zone18.GroupID', '10:Zone17.OperationMode', '10:Zone18.OperationMode');break;
                                    case 19: this.setGroupIDandNavigateToDashboard('10:Zone19.GroupID', '10:Zone18.OperationMode', '10:Zone19.OperationMode');break;
                                    case 20: this.setGroupIDandNavigateToDashboard('10:Zone20.GroupID', '10:Zone19.OperationMode', '10:Zone20.OperationMode');break;
                                    case 21: this.setGroupIDandNavigateToDashboard('10:Zone21.GroupID', '10:Zone20.OperationMode', '10:Zone21.OperationMode');break;
                                    case 22: this.setGroupIDandNavigateToDashboard('10:Zone22.GroupID', '10:Zone21.OperationMode', '10:Zone22.OperationMode');break;
                                    case 23: this.setGroupIDandNavigateToDashboard('10:Zone23.GroupID', '10:Zone22.OperationMode', '10:Zone23.OperationMode');break;
                                    case 24: this.setGroupIDandNavigateToDashboard('10:Zone24.GroupID', '10:Zone23.OperationMode', '10:Zone24.OperationMode');break;
                                }
                            });
                    });
            });
            this.eventMediator.subscribe(this.events.getUserDefinedInternalEvent('Set_Set_Set_SelectedGroupID_Back'), () => {

                this.datapointAPI.readDataPoint('10:SelectedZone1.ZoneID', 0)
                    .then((resolve) => {
                        SelectedZoneID = resolve.value - 1;

                        this.datapointAPI.writeDataPoint('10:SelectedZone1.ZoneID', SelectedZoneID)
                            .then((resolve) => {
                                switch (SelectedZoneID) {
                                    case 1:  this.setGroupIDandNavigateToDashboard('10:Zone1.GroupID', '10:Zone2.OperationMode', '10:Zone1.OperationMode');break;
                                    case 2:  this.setGroupIDandNavigateToDashboard('10:Zone2.GroupID',  '10:Zone3.OperationMode', '10:Zone2.OperationMode');break;
                                    case 3:  this.setGroupIDandNavigateToDashboard('10:Zone3.GroupID',  '10:Zone4.OperationMode', '10:Zone3.OperationMode');break;
                                    case 4:  this.setGroupIDandNavigateToDashboard('10:Zone4.GroupID',  '10:Zone5.OperationMode', '10:Zone4.OperationMode');break;
                                    case 5:  this.setGroupIDandNavigateToDashboard('10:Zone5.GroupID',  '10:Zone6.OperationMode', '10:Zone5.OperationMode');break;
                                    case 6:  this.setGroupIDandNavigateToDashboard('10:Zone6.GroupID',  '10:Zone7.OperationMode', '10:Zone6.OperationMode');break;
                                    case 7:  this.setGroupIDandNavigateToDashboard('10:Zone7.GroupID',  '10:Zone8.OperationMode', '10:Zone7.OperationMode');break;
                                    case 8:  this.setGroupIDandNavigateToDashboard('10:Zone8.GroupID',  '10:Zone9.OperationMode', '10:Zone8.OperationMode');break;
                                    case 9:  this.setGroupIDandNavigateToDashboard('10:Zone9.GroupID',  '10:Zone10.OperationMode', '10:Zone9.OperationMode');break;
                                    case 10: this.setGroupIDandNavigateToDashboard('10:Zone10.GroupID','10:Zone11.OperationMode', '10:Zone10.OperationMode');break;
                                    case 11: this.setGroupIDandNavigateToDashboard('10:Zone11.GroupID', '10:Zone12.OperationMode', '10:Zone11.OperationMode');break;
                                    case 12: this.setGroupIDandNavigateToDashboard('10:Zone12.GroupID', '10:Zone13.OperationMode', '10:Zone12.OperationMode');break;
                                    case 13: this.setGroupIDandNavigateToDashboard('10:Zone13.GroupID', '10:Zone14.OperationMode', '10:Zone13.OperationMode');break;
                                    case 14: this.setGroupIDandNavigateToDashboard('10:Zone14.GroupID', '10:Zone15.OperationMode', '10:Zone14.OperationMode');break;
                                    case 15: this.setGroupIDandNavigateToDashboard('10:Zone15.GroupID', '10:Zone16.OperationMode', '10:Zone15.OperationMode');break;
                                    case 16: this.setGroupIDandNavigateToDashboard('10:Zone16.GroupID', '10:Zone17.OperationMode', '10:Zone16.OperationMode');break;
                                    case 17: this.setGroupIDandNavigateToDashboard('10:Zone17.GroupID', '10:Zone18.OperationMode', '10:Zone17.OperationMode');break;
                                    case 18: this.setGroupIDandNavigateToDashboard('10:Zone18.GroupID', '10:Zone19.OperationMode', '10:Zone18.OperationMode');break;
                                    case 19: this.setGroupIDandNavigateToDashboard('10:Zone19.GroupID', '10:Zone20.OperationMode', '10:Zone19.OperationMode');break;
                                    case 20: this.setGroupIDandNavigateToDashboard('10:Zone20.GroupID', '10:Zone21.OperationMode', '10:Zone20.OperationMode');break;
                                    case 21: this.setGroupIDandNavigateToDashboard('10:Zone21.GroupID', '10:Zone22.OperationMode', '10:Zone21.OperationMode');break;
                                    case 22: this.setGroupIDandNavigateToDashboard('10:Zone22.GroupID', '10:Zone23.OperationMode', '10:Zone22.OperationMode');break;
                                    case 23: this.setGroupIDandNavigateToDashboard('10:Zone23.GroupID', '10:Zone24.OperationMode', '10:Zone23.OperationMode');break;
                                }
                            });
                    });
            });

            this.eventMediator.subscribe(this.events.getUserDefinedInternalEvent('Set_Set_Set_SelectedGroupID_ToOne'), () => {

                        SelectedZoneID = 1;

                        this.datapointAPI.writeDataPoint('10:SelectedZone1.ZoneID', SelectedZoneID)
                            .then((resolve) => {
                                this.setGroupIDandNavigateToDashboard('10:Zone1.GroupID', '10:Zone24.OperationMode', '10:Zone1.OperationMode');
                            });
            });

            this.eventMediator.subscribe(this.events.getUserDefinedInternalEvent('Set_Set_Set_SelectedGroupID_ToEnd'), () => {


                SelectedZoneID = 24;

                this.datapointAPI.writeDataPoint('10:SelectedZone1.ZoneID', SelectedZoneID)
                    .then((resolve) => {
                        this.setGroupIDandNavigateToDashboard('10:Zone24.GroupID', '10:Zone1.OperationMode', '10:Zone24.OperationMode');
                    });
            });


            this.eventMediator.subscribe(this.events.getUserDefinedInternalEvent('Set_Set_Set_SelectedGroupIDService'), () => {
                this.datapointAPI.readDataPoint('10:SelectedZone1.ZoneID', 0)
                    .then((resolve) => {
                        SelectedZoneID = resolve.value + 1;
                        this.datapointAPI.writeDataPoint('10:SelectedZone1.ZoneID', SelectedZoneID)
                            .then((resolve) => {
                                switch (SelectedZoneID) {
                                    case 2:  this.setGroupIDandNavigateToDashboardService('10:Zone2.GroupID');break;
                                    case 3:  this.setGroupIDandNavigateToDashboardService('10:Zone3.GroupID');break;
                                    case 4:  this.setGroupIDandNavigateToDashboardService('10:Zone4.GroupID');break;
                                    case 5:  this.setGroupIDandNavigateToDashboardService('10:Zone5.GroupID');break;
                                    case 6:  this.setGroupIDandNavigateToDashboardService('10:Zone6.GroupID');break;
                                    case 7:  this.setGroupIDandNavigateToDashboardService('10:Zone7.GroupID');break;
                                    case 8:  this.setGroupIDandNavigateToDashboardService('10:Zone8.GroupID');break;
                                    case 9:  this.setGroupIDandNavigateToDashboardService('10:Zone9.GroupID');break;
                                    case 10: this.setGroupIDandNavigateToDashboardService('10:Zone10.GroupID');break;
                                    case 11: this.setGroupIDandNavigateToDashboardService('10:Zone11.GroupID');break;
                                    case 12: this.setGroupIDandNavigateToDashboardService('10:Zone12.GroupID');break;
                                    case 13: this.setGroupIDandNavigateToDashboardService('10:Zone13.GroupID');break;
                                    case 14: this.setGroupIDandNavigateToDashboardService('10:Zone14.GroupID');break;
                                    case 15: this.setGroupIDandNavigateToDashboardService('10:Zone15.GroupID');break;
                                    case 16: this.setGroupIDandNavigateToDashboardService('10:Zone16.GroupID');break;
                                    case 17: this.setGroupIDandNavigateToDashboardService('10:Zone17.GroupID');break;
                                    case 18: this.setGroupIDandNavigateToDashboardService('10:Zone18.GroupID');break;
                                    case 19: this.setGroupIDandNavigateToDashboardService('10:Zone19.GroupID');break;
                                    case 20: this.setGroupIDandNavigateToDashboardService('10:Zone20.GroupID');break;
                                    case 21: this.setGroupIDandNavigateToDashboardService('10:Zone21.GroupID');break;
                                    case 22: this.setGroupIDandNavigateToDashboardService('10:Zone22.GroupID');break;
                                    case 23: this.setGroupIDandNavigateToDashboardService('10:Zone23.GroupID');break;
                                    case 24: this.setGroupIDandNavigateToDashboardService('10:Zone24.GroupID');break;
                                }
                            });
                    });
            });

            this.eventMediator.subscribe(this.events.getUserDefinedInternalEvent('Set_Set_Set_SelectedGroupID_BackService'), () => {

                this.datapointAPI.readDataPoint('10:SelectedZone1.ZoneID', 0)
                    .then((resolve) => {
                        SelectedZoneID = resolve.value - 1;

                        this.datapointAPI.writeDataPoint('10:SelectedZone1.ZoneID', SelectedZoneID)
                            .then((resolve) => {
                                switch (SelectedZoneID) {
                                    case 1:  this.setGroupIDandNavigateToDashboardService('10:Zone1.GroupID');break;
                                    case 2:  this.setGroupIDandNavigateToDashboardService('10:Zone2.GroupID');break;
                                    case 3:  this.setGroupIDandNavigateToDashboardService('10:Zone3.GroupID');break;
                                    case 4:  this.setGroupIDandNavigateToDashboardService('10:Zone4.GroupID');break;
                                    case 5:  this.setGroupIDandNavigateToDashboardService('10:Zone5.GroupID');break;
                                    case 6:  this.setGroupIDandNavigateToDashboardService('10:Zone6.GroupID');break;
                                    case 7:  this.setGroupIDandNavigateToDashboardService('10:Zone7.GroupID');break;
                                    case 8:  this.setGroupIDandNavigateToDashboardService('10:Zone8.GroupID');break;
                                    case 9:  this.setGroupIDandNavigateToDashboardService('10:Zone9.GroupID');break;
                                    case 10: this.setGroupIDandNavigateToDashboardService('10:Zone10.GroupID');break;
                                    case 11: this.setGroupIDandNavigateToDashboardService('10:Zone11.GroupID');break;
                                    case 12: this.setGroupIDandNavigateToDashboardService('10:Zone12.GroupID');break;
                                    case 13: this.setGroupIDandNavigateToDashboardService('10:Zone13.GroupID');break;
                                    case 14: this.setGroupIDandNavigateToDashboardService('10:Zone14.GroupID');break;
                                    case 15: this.setGroupIDandNavigateToDashboardService('10:Zone15.GroupID');break;
                                    case 16: this.setGroupIDandNavigateToDashboardService('10:Zone16.GroupID');break;
                                    case 17: this.setGroupIDandNavigateToDashboardService('10:Zone17.GroupID');break;
                                    case 18: this.setGroupIDandNavigateToDashboardService('10:Zone18.GroupID');break;
                                    case 19: this.setGroupIDandNavigateToDashboardService('10:Zone19.GroupID');break;
                                    case 20: this.setGroupIDandNavigateToDashboardService('10:Zone20.GroupID');break;
                                    case 21: this.setGroupIDandNavigateToDashboardService('10:Zone21.GroupID');break;
                                    case 22: this.setGroupIDandNavigateToDashboardService('10:Zone22.GroupID');break;
                                    case 23: this.setGroupIDandNavigateToDashboardService('10:Zone23.GroupID');break;
                                }
                            });
                    });
            });

            this.eventMediator.subscribe(this.events.getUserDefinedInternalEvent('Set_Set_Set_SelectedGroupID_ToOneService'), () => {

                SelectedZoneID = 1;

                this.datapointAPI.writeDataPoint('10:SelectedZone1.ZoneID', SelectedZoneID)
                    .then((resolve) => {
                        this.setGroupIDandNavigateToDashboardService('10:Zone1.GroupID');
                    });
            });

            this.eventMediator.subscribe(this.events.getUserDefinedInternalEvent('Set_Set_Set_SelectedGroupID_ToEndService'), () => {


                SelectedZoneID = 24;

                this.datapointAPI.writeDataPoint('10:SelectedZone1.ZoneID', SelectedZoneID)
                    .then((resolve) => {
                        this.setGroupIDandNavigateToDashboardService('10:Zone24.GroupID');
                    });
            });

            this.eventMediator.subscribe(this.events.getUserDefinedInternalEvent('NavigateToStart'), () => {

                window.sigApi.appRouter.navigate('Startseite');

            });

            this.eventMediator.subscribe(this.events.getUserDefinedInternalEvent('SetNamesForGroups'), () => {
                this.datapointAPI.writeDataPoint('10:PIDGroup1.GroupName', "-");
                this.datapointAPI.writeDataPoint('10:PIDGroup2.GroupName', "-");
                this.datapointAPI.writeDataPoint('10:PIDGroup3.GroupName', "-");
            });

            this.eventMediator.subscribe(this.events.getUserDefinedInternalEvent('SetNamesForAllGroups'), () => {
                this.datapointAPI.writeDataPoint('10:PIDGroup1.GroupName', "-");
                this.datapointAPI.writeDataPoint('10:PIDGroup2.GroupName', "-");
                this.datapointAPI.writeDataPoint('10:PIDGroup3.GroupName', "-");
                this.datapointAPI.writeDataPoint('10:PIDGroup4.GroupName', "-");
                this.datapointAPI.writeDataPoint('10:PIDGroup5.GroupName', "-");
                this.datapointAPI.writeDataPoint('10:PIDGroup6.GroupName', "-");
                this.datapointAPI.writeDataPoint('10:PIDGroup7.GroupName', "-");
                this.datapointAPI.writeDataPoint('10:PIDGroup8.GroupName', "-");
                this.datapointAPI.writeDataPoint('10:PIDGroup9.GroupName', "-");
                this.datapointAPI.writeDataPoint('10:PIDGroup10.GroupName', "-");
            });
        }

        this.eventMediator.subscribe(this.events.getUserDefinedInternalEvent('SetSetPointForAll'), () => {
            this.datapointAPI.readDataPoint('10:SelectedZone1.ZoneID', 0)
                .then((resolve) => {
                    switch (resolve.value) {
                        case 1:  sigApi.datapointManager.readDataPoint('10:Zone1.SetPoint', 0)
                            .then((resolve) => {
                                this.setSetPointForAll(resolve.value);
                            }); break;
                        case 2:  sigApi.datapointManager.readDataPoint('10:Zone2.SetPoint', 0)
                            .then((resolve) => {
                                this.setSetPointForAll(resolve.value);
                            }); break;
                        case 3:  sigApi.datapointManager.readDataPoint('10:Zone3.SetPoint', 0)
                            .then((resolve) => {
                                this.setSetPointForAll(resolve.value);
                            }); break;
                        case 4:  sigApi.datapointManager.readDataPoint('10:Zone4.SetPoint', 0)
                            .then((resolve) => {
                                this.setSetPointForAll(resolve.value);
                            }); break;
                        case 5:  sigApi.datapointManager.readDataPoint('10:Zone5.SetPoint', 0)
                            .then((resolve) => {
                                this.setSetPointForAll(resolve.value);
                            }); break;
                        case 6:  sigApi.datapointManager.readDataPoint('10:Zone6.SetPoint', 0)
                            .then((resolve) => {
                                this.setSetPointForAll(resolve.value);
                            }); break;
                        case 7:  sigApi.datapointManager.readDataPoint('10:Zone7.SetPoint', 0)
                            .then((resolve) => {
                                this.setSetPointForAll(resolve.value);
                            }); break;
                        case 8:  sigApi.datapointManager.readDataPoint('10:Zone8.SetPoint', 0)
                            .then((resolve) => {
                                this.setSetPointForAll(resolve.value);
                            }); break;
                        case 9:  sigApi.datapointManager.readDataPoint('10:Zone9.SetPoint', 0)
                            .then((resolve) => {
                                this.setSetPointForAll(resolve.value);
                            }); break;
                        case 10: sigApi.datapointManager.readDataPoint('10:Zone10.SetPoint', 0)
                            .then((resolve) => {
                                this.setSetPointForAll(resolve.value);
                            }); break;
                        case 11: sigApi.datapointManager.readDataPoint('10:Zone11.SetPoint', 0)
                            .then((resolve) => {
                                this.setSetPointForAll(resolve.value);
                            }); break;
                        case 12: sigApi.datapointManager.readDataPoint('10:Zone12.SetPoint', 0)
                            .then((resolve) => {
                                this.setSetPointForAll(resolve.value);
                            }); break;
                        case 13: sigApi.datapointManager.readDataPoint('10:Zone13.SetPoint', 0)
                            .then((resolve) => {
                                this.setSetPointForAll(resolve.value);
                            }); break;
                        case 14: sigApi.datapointManager.readDataPoint('10:Zone14.SetPoint', 0)
                            .then((resolve) => {
                                this.setSetPointForAll(resolve.value);
                            }); break;
                        case 15: sigApi.datapointManager.readDataPoint('10:Zone15.SetPoint', 0)
                            .then((resolve) => {
                                this.setSetPointForAll(resolve.value);
                            }); break;
                        case 16: sigApi.datapointManager.readDataPoint('10:Zone16.SetPoint', 0)
                            .then((resolve) => {
                                this.setSetPointForAll(resolve.value);
                            }); break;
                        case 17: sigApi.datapointManager.readDataPoint('10:Zone17.SetPoint', 0)
                            .then((resolve) => {
                                this.setSetPointForAll(resolve.value);
                            }); break;
                        case 18: sigApi.datapointManager.readDataPoint('10:Zone18.SetPoint', 0)
                            .then((resolve) => {
                                this.setSetPointForAll(resolve.value);
                            }); break;
                        case 19: sigApi.datapointManager.readDataPoint('10:Zone19.SetPoint', 0)
                            .then((resolve) => {
                                this.setSetPointForAll(resolve.value);
                            }); break;
                        case 20: sigApi.datapointManager.readDataPoint('10:Zone20.SetPoint', 0)
                            .then((resolve) => {
                                this.setSetPointForAll(resolve.value);
                            }); break;
                        case 21: sigApi.datapointManager.readDataPoint('10:Zone21.SetPoint', 0)
                            .then((resolve) => {
                                this.setSetPointForAll(resolve.value);
                            }); break;
                        case 22: sigApi.datapointManager.readDataPoint('10:Zone22.SetPoint', 0)
                            .then((resolve) => {
                                this.setSetPointForAll(resolve.value);
                            }); break;
                        case 23: sigApi.datapointManager.readDataPoint('10:Zone23.SetPoint', 0)
                            .then((resolve) => {
                                this.setSetPointForAll(resolve.value);
                            }); break;
                        case 24: sigApi.datapointManager.readDataPoint('10:Zone24.SetPoint', 0)
                            .then((resolve) => {
                                this.setSetPointForAll(resolve.value);
                            }); break;
                    }
                });
        });
    }

    setGroupIDandNavigateToDashboard(ActZone, PreviousZone, ActZoneOperMode) {
        let SelGroupID;
        let PrevousOperMode;
        let ActOperMode;
        this.datapointAPI.readDataPoint(ActZone, 0)
            .then((resolve) => {
                SelGroupID = resolve.value;
                this.datapointAPI.readDataPoint(PreviousZone, 0)
                    .then((resolve) => {
                        PrevousOperMode = resolve.value;
                        this.datapointAPI.writeDataPoint('10:SelectedGroup1.GroupID', SelGroupID)
                            .then((resolve) => {
                                this.datapointAPI.readDataPoint(ActZoneOperMode, 0)
                                    .then((resolve) => {
                                        ActOperMode = resolve.value;
                                        if (ActOperMode === 0) {
                                            if (ActOperMode !== PrevousOperMode){
                                                window.sigApi.appRouter.navigate('ZoneDetail');
                                            }
                                        } else if (ActOperMode === 1) {
                                            if (ActOperMode !== PrevousOperMode){
                                                window.sigApi.appRouter.navigate('ZoneDetail_Stellbetrieb');
                                            }
                                        } else if (ActOperMode === 2) {
                                            if (ActOperMode !== PrevousOperMode){
                                                window.sigApi.appRouter.navigate('ZoneDetail_Leitbetrieb');
                                            }
                                        } else if (ActOperMode === 3) {
                                            if (ActOperMode !== PrevousOperMode){
                                                window.sigApi.appRouter.navigate('ZoneDetail_Monitorbetrieb');
                                            }
                                        } else if (ActOperMode === 4) {
                                            if (ActOperMode !== PrevousOperMode){
                                                window.sigApi.appRouter.navigate('ZoneDetail_Tuning');
                                            }
                                        } else {
                                            if (ActOperMode !== PrevousOperMode){
                                                window.sigApi.appRouter.navigate('ZoneDetail_Inaktiv');
                                            }
                                        }
                                    });
                            });
                    });
            });
    }

    setGroupIDandNavigateToDashboardService(ActZone) {
        let SelGroupID;
        this.datapointAPI.readDataPoint(ActZone, 0)
            .then((resolve) => {
                SelGroupID = resolve.value;
                this.datapointAPI.writeDataPoint('10:SelectedGroup1.GroupID', SelGroupID)
            });
    }

    setSetPointForAll(SetPoint) {
        return Promise.resolve()
            .then(()=>
            {
                return this._if_Zone_exists_set_SetPoint(1, '10:Zone1.ZoneNotExist', SetPoint);
            })
            .then(()=>
            {
                return this._if_Zone_exists_set_SetPoint(2, '10:Zone2.ZoneNotExist', SetPoint);
            })
            .then(()=>
            {
                return this._if_Zone_exists_set_SetPoint(3, '10:Zone3.ZoneNotExist', SetPoint);
            })
            .then(()=>
            {
                return this._if_Zone_exists_set_SetPoint(4, '10:Zone4.ZoneNotExist', SetPoint);
            })
            .then(()=>
            {
                return this._if_Zone_exists_set_SetPoint(5, '10:Zone5.ZoneNotExist', SetPoint);
            })
            .then(()=>
            {
                return this._if_Zone_exists_set_SetPoint(6, '10:Zone6.ZoneNotExist', SetPoint);
            })
            .then(()=>
            {
                return this._if_Zone_exists_set_SetPoint(7, '10:Zone7.ZoneNotExist', SetPoint);
            })
            .then(()=>
            {
                return this._if_Zone_exists_set_SetPoint(8, '10:Zone8.ZoneNotExist', SetPoint);
            })
            .then(()=>
            {
                return this._if_Zone_exists_set_SetPoint(9, '10:Zone9.ZoneNotExist', SetPoint);
            })
            .then(()=>
            {
                return this._if_Zone_exists_set_SetPoint(10, '10:Zone10.ZoneNotExist', SetPoint);
            })
            .then(()=>
            {
                return this._if_Zone_exists_set_SetPoint(11, '10:Zone11.ZoneNotExist', SetPoint);
            })
            .then(()=>
            {
                return this._if_Zone_exists_set_SetPoint(12, '10:Zone12.ZoneNotExist', SetPoint);
            })
            .then(()=>
            {
                return this._if_Zone_exists_set_SetPoint(13, '10:Zone13.ZoneNotExist', SetPoint);
            })
            .then(()=>
            {
                return this._if_Zone_exists_set_SetPoint(14, '10:Zone14.ZoneNotExist', SetPoint);
            })
            .then(()=>
            {
                return this._if_Zone_exists_set_SetPoint(15, '10:Zone15.ZoneNotExist', SetPoint);
            })
            .then(()=>
            {
                return this._if_Zone_exists_set_SetPoint(16, '10:Zone16.ZoneNotExist', SetPoint);
            })
            .then(()=>
            {
                return this._if_Zone_exists_set_SetPoint(17, '10:Zone17.ZoneNotExist', SetPoint);
            })
            .then(()=>
            {
                return this._if_Zone_exists_set_SetPoint(18, '10:Zone18.ZoneNotExist', SetPoint);
            })
            .then(()=>
            {
                return this._if_Zone_exists_set_SetPoint(19, '10:Zone19.ZoneNotExist', SetPoint);
            })
            .then(()=>
            {
                return this._if_Zone_exists_set_SetPoint(20, '10:Zone20.ZoneNotExist', SetPoint);
            })
            .then(()=>
            {
                return this._if_Zone_exists_set_SetPoint(21, '10:Zone21.ZoneNotExist', SetPoint);
            })
            .then(()=>
            {
                return this._if_Zone_exists_set_SetPoint(22, '10:Zone22.ZoneNotExist', SetPoint);
            })
            .then(()=>
            {
                return this._if_Zone_exists_set_SetPoint(23, '10:Zone23.ZoneNotExist', SetPoint);
            })
            .then(()=>
            {
                return this._if_Zone_exists_set_SetPoint(24, '10:Zone24.ZoneNotExist', SetPoint);
            })
    }

    _if_Zone_exists_set_SetPoint(index, Zone, SetPoint){
        sigApi.datapointManager.readDataPoint(Zone, 0)
            .then((resolve) => {
                if (resolve.value === 0){
                    this._set_SetPoint(index, SetPoint);
                }
                
            });
    }

    _set_SetPoint(index, SetPoint){
        switch (index) {
            case 1: sigApi.datapointManager.writeDataPoint('10:SetPointManager1.SetPointLVD', SetPoint); break;
            case 2: sigApi.datapointManager.writeDataPoint('10:SetPointManager2.SetPointLVD', SetPoint); break;
            case 3: sigApi.datapointManager.writeDataPoint('10:SetPointManager3.SetPointLVD', SetPoint); break;
            case 4: sigApi.datapointManager.writeDataPoint('10:SetPointManager4.SetPointLVD', SetPoint); break;
            case 5: sigApi.datapointManager.writeDataPoint('10:SetPointManager5.SetPointLVD', SetPoint); break;
            case 6: sigApi.datapointManager.writeDataPoint('10:SetPointManager6.SetPointLVD', SetPoint); break;
            case 7: sigApi.datapointManager.writeDataPoint('10:SetPointManager7.SetPointLVD', SetPoint); break;
            case 8: sigApi.datapointManager.writeDataPoint('10:SetPointManager8.SetPointLVD', SetPoint); break;
            case 9: sigApi.datapointManager.writeDataPoint('10:SetPointManager9.SetPointLVD', SetPoint); break;
            case 10: sigApi.datapointManager.writeDataPoint('10:SetPointManager10.SetPointLVD', SetPoint); break;
            case 11: sigApi.datapointManager.writeDataPoint('10:SetPointManager11.SetPointLVD', SetPoint); break;
            case 12: sigApi.datapointManager.writeDataPoint('10:SetPointManager12.SetPointLVD', SetPoint); break;
            case 13: sigApi.datapointManager.writeDataPoint('10:SetPointManager13.SetPointLVD', SetPoint); break;
            case 14: sigApi.datapointManager.writeDataPoint('10:SetPointManager14.SetPointLVD', SetPoint); break;
            case 15: sigApi.datapointManager.writeDataPoint('10:SetPointManager15.SetPointLVD', SetPoint); break;
            case 16: sigApi.datapointManager.writeDataPoint('10:SetPointManager16.SetPointLVD', SetPoint); break;
            case 17: sigApi.datapointManager.writeDataPoint('10:SetPointManager17.SetPointLVD', SetPoint); break;
            case 18: sigApi.datapointManager.writeDataPoint('10:SetPointManager18.SetPointLVD', SetPoint); break;
            case 19: sigApi.datapointManager.writeDataPoint('10:SetPointManager19.SetPointLVD', SetPoint); break;
            case 20: sigApi.datapointManager.writeDataPoint('10:SetPointManager20.SetPointLVD', SetPoint); break;
            case 21: sigApi.datapointManager.writeDataPoint('10:SetPointManager21.SetPointLVD', SetPoint); break;
            case 22: sigApi.datapointManager.writeDataPoint('10:SetPointManager22.SetPointLVD', SetPoint); break;
            case 23: sigApi.datapointManager.writeDataPoint('10:SetPointManager23.SetPointLVD', SetPoint); break;
            case 24: sigApi.datapointManager.writeDataPoint('10:SetPointManager24.SetPointLVD', SetPoint); break;
        }
    }




}
DemoDatapointManager.initDemoDatapointManager();