TimerPool Fehlermeldung

Ich versuche mich an meinem ersten Modul für dne Libre Hardware Monitor
Ich bin eigentlich recht gut auf Kurs aber am Timer mühe ich mich extrem ab.

Ich erhalte folgende Fehlermeldung vom TimerPool im Intervall der Update-Zeit

21.01.2024, 12:26:37 | TimerPool            | Hardware Monitor (UpdateTimer): 
Fatal error: Uncaught Error: Call to undefined function Update() in C:\Windows\System32\-:1
Stack trace:
#0 {main}
  thrown in C:\Windows\System32\- on line 1

Irgendwas kriege ich mit dem Timer nicht auf die Reihe…
Was ist hier falsch?

   public function Create()
    {
        parent::Create();

        $this->RegisterPropertyString('IPAddress', '192.168.178.76');
        $this->RegisterPropertyInteger('Port', 8085);
        $this->RegisterPropertyString('IDListe', '[]');
        $this->RegisterPropertyInteger('UpdateInterval', 5);

        // Timer für Aktualisierung registrieren
        $this->RegisterTimer('UpdateTimer', $this->ReadPropertyInteger('UpdateInterval') * 1000, 'Update(' . $this->InstanceID . ');');
    }


    public function ApplyChanges()
    {
        parent::ApplyChanges();

        // Timer für Aktualisierung aktualisieren
        $this->SetTimerInterval('UpdateTimer', $this->ReadPropertyInteger('UpdateInterval') * 1000);
        //$this->SetTimerInterval('Update', 0);

        // Bei Änderungen am Konfigurationsformular oder bei der Initialisierung auslösen
        $this->Update();
    }

    public function Update()
    {
        // Libre Hardware Monitor abfragen
        $content = file_get_contents("http://{$this->ReadPropertyString('IPAddress')}:{$this->ReadPropertyInteger('Port')}/data.json");
        $contentArray = json_decode($content, true);

        // Gewählte ID's abfragen
        $idListeString = $this->ReadPropertyString('IDListe');
        $idListe = json_decode($idListeString, true);

Im Modul über das Kontexmenu funktioniert die Aktualiserung wunderbar…
image

Update ist keine Instanz Funktion.
Du musst hier PREFIX_Update also HW_Update benutzen.
Als Tip, im create den Timer mit Intervall 0 erzeugen.
Der Intervall wird im Applychanges gesetzt.
Ich meine ReadProprty liefert eh nix im create.

Michael

Funktioniert perfekt, vielen Dank…

1 „Gefällt mir“