Variable mit Profil inkl. Assoziationen erstellen?

Hi,

ich versuche derzeit, meinem Modul eine Statusvariable inkl. eigenem Profil und Assoziationen anzulegen.

Leider scheint selbst der Demo Code nicht zu funktionieren:


 Test := TIPSVarProfile.CreateStringProfile('DemoTextProfile', 'Information','', '-->logged');
 RegisterVariable('LastLineVariable','LastText',vtString,'DemoTextProfile');

Später hätte ich dann Test.Associations die Assoziationen übergeben.

Aber der Code legt zwar die Variable „LastText“ an, aber das zugehörige Profil „DemoTextProfile“ erscheint nicht in den Variablen Details (also braucht man die Assoziationen erstmal nicht suchen ;)).

Fehlt da was, oder wie muss man vorgehen?

Gruss
Coyote

Zb. so,

// Anlegen der String Variable mit Profil ~HTMLBOX
      $meID = @IPS_GetInstanceIDByName("Log`s", $parentID); // erstmal gucken ob schon vorhanden
      if ($meID === false)  {                                                // wenn nicht vorhanden dann erstellen
         $meID = IPS_CreateVariable(3);
         IPS_SetName($meID, "Log");
	 IPS_SetParent($meID, $instancID);
	 IPS_SetVariableCustomProfile($meID, "~HTMLBox");
	 echo "HTML Ausgabe wurde angelegt. die ID lautet: ". "$meID
";

Hi,

vielen Dank für die schnelle Antwort.
Ich möchte allerdings nicht einer Variable ein existierendes Profil (wie ‚~HTMLBox‘) zuweisen, sondern ein neues Profil inkl. Assoziationen anlegen.

Gruss
Coyote

Hi,

ich habe es jetzt mittels


   fKernel.VariableManagerEx.CreateVariableProfileEx( );   

hinbekommen. Allerdings werden die Assoziationsnamen erst nach einem Neustart der Konsole angezeigt.

Gruss
Coyote

Ok, Sorry. Dann vlt so,

// Anlegen der Bool Variablen mit Profil und Association
      $instancID = @IPS_GetInstanceIDByName($IPS_SELF, $parentID);
      $VarID = @IPS_GetInstanceIDByName("Fehlermeldung", $parentID);
      if ($VarID === false)  {
         $VarID = IPS_CreateVariable(0);
         IPS_SetName($VarID, "Fehlermeldung");
			IPS_SetParent($VarID, $instancID);
	      IPS_CreateVariableProfile("ErrorLog", 0);
			IPS_SetVariableProfileAssociation("ErrorLog", 1, "Keine Einräge", "");
			IPS_SetVariableProfileAssociation("ErrorLog",0, "Löschen", "");
			IPS_SetVariableCustomProfile($VarID, "ErrorLog");
			IPS_SetVariableCustomAction($VarID, $IPS_SELF);
         SetValue($VarID, true);
         echo "Profil ErrorLog wurde angelegt. die ID lautet: ". "$VarID
";

Hier ein kleines Beispiel :slight_smile:



 RegisterProfile(TIPSVarProfile.CreateIntegerProfileEx('Shutter.xComfort', 'Shutter', '', '', ValueAssociations([ValueAssociation(0, _('N/A'), ''),
                                                                                                                 ValueAssociation(1, _('Opened'), ''),
                                                                                                                 ValueAssociation(2, _('Closed'), '')])));

 RegisterProfile(TIPSVarProfile.CreateIntegerProfileEx('ShutterAction.xComfort', 'ArrowRight', '', '', ValueAssociations([ValueAssociation(0, _('Hold'), ''),
                                                                                                                          ValueAssociation(1, _('Open'), ''),
                                                                                                                          ValueAssociation(2, _('Close'), '')])));


 RegisterVariable('LastMoveVariable', 'Last Move Direction', vtInteger, 'Shutter.xComfort');
 RegisterVariable('DataVariable', 'Move Direction', vtInteger, 'ShutterAction.xComfort');
 RegisterActionHandler('DataVariable', ShutterHandler);

paresy