+ Antworten
Ergebnis 1 bis 2 von 2
  1. #1
    Registriert seit
    Aug 2016

    Standard Module development + logging

    I am trying to develop an arbitrary module that, among others, creates various variables during creation. Ideally, these variables should be logged as well.

    This can be set using the AC_SetLoggingStatus, but this function returns an error in the example below. The $this->GetIDForIdent('consumptionT1') returns an object ID, which indicates it exists, but AC_SetLoggingStatus returns an error stating that the object does not exist. I can imagine that this happens when this function is called in the Create() part of the module, but I do not expect this to happen in the ApplyChanges() part.

    What would be the proper way of creating a variable and setting variable properties such as logging?

    	class P1SmartMeter extends IPSModule
    		public function Create()
    			//Never delete this line!
    			// Requires a Serialport I/O as parent.
    			// Set variables used for settings.
    			$this->RegisterPropertyInteger("DaysToKeep", "10");
    			$this->RegisterVariableFloat("consumptionT1", "Electricity consumption low", "Electricity", 10);
    			// Set timer for automatic data removal for historic data
    			$this->RegisterTimer("DataRemoval", 0, 'P1_PurgeOldData');
    		public function ApplyChanges()
    			//Never delete this line!
    			$this->SetTimerInterval("DataRemoval", $this->ReadPropertyInteger("DaysToKeep")*24*60*60*1000);
    			// Set variables for smart meter data
    			// Get ObjectID for first archive
    			$archives = IPS_GetInstanceListByModuleID("{43192F0B-135B-4CE7-A0A7-1475603F3060}");
    			AC_SetLoggingStatus($this->GetIDForIdent('consumptionT1'), $archives[0], true);

  2. #2
    Registriert seit
    Feb 2017

    The order of arguments is wrong. The Archive ID first, the variable ID second.

    Please note, that the decision if a variable should be logged should be made by the user, especially if you intend to publish your module. It's fine to provide a shortcut, but it should be obvious to the user that the newly created variables are logged. This could be realized by an according toggle box or similar.

Ähnliche Themen

  1. neue PHP-Module als Ersatz meiner Delphi-Module
    Von tommi im Forum PHP-Module
    Antworten: 187
    Letzter Beitrag: 17.06.19, 21:20
  2. Module werden falsch instanziert bei gleichem prefix in der jeweiligen module.json
    Von bumaas im Forum Entwicklung mit PHP-SDK/Delphi-SDK
    Antworten: 9
    Letzter Beitrag: 07.06.17, 15:50
  3. Development für Dummies
    Von McFly im Forum IPSLibrary
    Antworten: 1
    Letzter Beitrag: 23.04.12, 19:08
  4. php integrated development environment
    Von aag im Forum Allgemeine Diskussion (2.x/3.x)
    Antworten: 5
    Letzter Beitrag: 13.11.11, 15:49