Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. [gelöst] Ordner Global und das Problem mit Klassen

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    [gelöst] Ordner Global und das Problem mit Klassen

    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      Psens last edited by

      Hallo,

      vielleicht könnt ihr mir weiter Helfen, ich habe im Global, nachfolgende Klasse definiert, wenn ich jetzt versuche das Script auszuführen, stürzt der Javascript Adapter ab und startet neu, ich möchte diese Klassendefinition Global haben da ich immer wieder das gleiche Konstrukt brauche, welches ich dann über einzelne Funktionen aufrufe um somit die Möglichkeit zu haben die einzelnen Instanzen getrennt von einander zu starten und zu stoppen.

      Skript Global: global/V1

      const request = require("request");
      const fs = require("fs");
      
      function BmaTelegramBot(bmaName, password, ipAddress, abrufIntervall, telegramInstance){
          this._bmaName = bmaName;
          this._password = password;
          this._ipAddress = ipAddress;
          this._abrufIntervall = abrufIntervall;
          this._telegramInstance = telegramInstance;
      
          this._historyFile = "history.txt";
          this._usersFile = "users.conf";
          this._jsInstance = "javascript.0.";
      
          this._rawRequest = this._telegramInstance + ".communicate.requestRaw";
          this._usersState = this._jsInstance + this._bmaName + ".users";
          this._msgLast = this._jsInstance + this._bmaName + ".lastMsg";
          this._msgMan = this._jsInstance + this._bmaName + ".manMsg";
      
          createState(this._msgLast, "");
          createState(this._usersState, '{}');
          createState(this._msgMan, "");
      
          if(!fs.existsSync("\\" + this._bmaName + "\\")){
              fs.mkdirSync("\\" + this._bmaName + "\\");
              console.log("Ordern angelegt");
          }
      
          if(!fs.existsSync("\\" + this._bmaName + "\\" + this._historyFile)){
              fs.writeFile("\\" + this._bmaName + "\\" + this._historyFile,"");
              console.log("History angelegt");
          }
      
          this.getUsers = function(){
              return JSON.parse(getState(this._usersState).val);
          };
      
          this.sendTxtMsg = function(userId, text){
              sendTo(this._telegramInstance, {chatId: userId, text: text, parse_mode: "HTML"});
          };
      }
      

      Logeinträge: (ps: habe gerade festgestellt das er den javascript Adapter auch neu Startet wenn ich das V1 Skript nur speichere ohne das es läuft)

      javascript.0	2018-10-05 09:18:36.111	info	received all objects
      javascript.0	2018-10-05 09:18:36.033	info	received all states
      javascript.0	2018-10-05 09:18:35.924	info	requesting all objects
      javascript.0	2018-10-05 09:18:35.924	info	requesting all states
      javascript.0	2018-10-05 09:18:35.924	info	starting. Version 3.6.4 in C:/ioBroker/node_modules/iobroker.javascript, node: v8.12.0
      host.srv-1037099-1	2018-10-05 09:18:35.142	info	instance system.adapter.javascript.0 started with pid 9168
      host.srv-1037099-1	2018-10-05 09:18:32.626	info	instance system.adapter.javascript.0 terminated with code null ()
      host.srv-1037099-1	2018-10-05 09:18:32.626	warn	instance system.adapter.javascript.0 terminated due to SIGTERM
      host.srv-1037099-1	2018-10-05 09:18:32.626	info	stopInstance system.adapter.javascript.0 killing pid 8804
      host.srv-1037099-1	2018-10-05 09:18:32.626	info	stopInstance system.adapter.javascript.0
      host.srv-1037099-1	2018-10-05 09:18:32.611	info	object change system.adapter.javascript.0
      

      Kann mir hier jemand Helfen?

      Gruß Dominic

      1 Reply Last reply Reply Quote 0
      • Dutchman
        Dutchman Developer Most Active Administrators last edited by

        Wen man ein globales Script speichert wird immer der JavaScript Adapter neu gestartet.

        Das muss so sein damit die Definitionen im Global fornallen regulären Scripten angehängt werden kann.

        Als der Neustart (kein Absturz) ist "works AS Designed"

        Sent from my iPhone using Tapatalk

        1 Reply Last reply Reply Quote 0
        • P
          Psens last edited by

          @Dutchman:

          Wen man ein globales Script speichert wird immer der JavaScript Adapter neu gestartet.

          Das muss so sein damit die Definitionen im Global fornallen regulären Scripten angehängt werden kann.

          Als der Neustart (kein Absturz) ist "works AS Designed"

          Sent from my iPhone using Tapatalk `

          Dankeschön, klappt alles war eine Fehlinterpretierung meinerseits.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post

          Support us

          ioBroker
          Community Adapters
          Donate

          805
          Online

          31.7k
          Users

          79.9k
          Topics

          1.3m
          Posts

          2
          3
          465
          Loading More Posts
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes
          Reply
          • Reply as topic
          Log in to reply
          Community
          Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
          The ioBroker Community 2014-2023
          logo