Durch Bitmaske eine mehrfache Elementauswahl ermöglichen

Hallo zusammen,

Frage an die Entwickler: bestände denn die Möglichkeit, einen neuen Variablentyp „Byte“ in einer kommenden Version hinzuzufügen?
Vorteil, den ich sehe: eine Variable könnte mehrere Stati annehmen, je nach gesetztem Bit. Man spart sich damit also Variablen, da man mit einer Einzigen mehrere Zustände zusammenfassen kann.
Für das Variablenprofil könnte man entweder die Bits auswählen für die Assoziation oder den Dezimalwert des Bytes.

Was haltet ihr davon?

Gruß
dfhome

Das könntest du doch aber auch mit einem Integer abbilden?!

Der Aufwand steht in keinem Verhältnis zum Nutzen, da wird paresy nichts machen. Ich glaube auch nicht das er Variablen sparen will.:cool:

Und wie domezei385 schon gesagt hat kannst Du mit Bitoperationen auch einen Integerwert bearbeiten. Es bleibt dann aber auch nur ein Bytewert.

Die anderen haben Recht. Im Integer sind mehr mehr Bits als in einem Byte :wink:
Somit erledigt sich diese Frage wahrscheinlich direkt…

paresy

Auf was ich eigentlich ab will (Beispiel - und das geht aktuell nicht):
Ich habe meinen Rolladenaktor, und möchte diesen für bestimmte Szenarien aktiv schalten. D.h. in einem Byte sind mehrere Bits gesetzt und diese EINZELNEN Bits werden in den Assoziationen visualisiert. Aktuell ist es so, dass eine Variable eben nur EINEN Wert anzeigen kann, d.h. entweder ist „Sonnenaufgang“ aktiv oder eben „Sonnenuntergang“. Beides gleichzeitig aktiv setzen geht eben nicht - und das gleichzeitig auch noch visualisieren.
Beispielschema: (x heißt aktiv und grün unterlegt im WebFront):

Sonnenaufgang___Sonnenuntergang___Beschattung___Automatik___Abwesenheit
X_____________X____________________________X___________

Aktuell ist es doch so, dass nur ein Wert aktiv sein kann. Jetzt besser verständlich, was ich meine?

so langsam ahne ich, was du willst: sowas wie eine Multiple-Checkbox, im Stil einer WFE-Integer-Variable.
Das ist m.E. aber kein Variablentyp sondern ein völlig neues WFE-Element.

Aber schlecht wär sowas nicht :wink:

Jetzt wo ich nochmal drüber nachgedacht hab, hast Du recht. Ist eher eine Änderung bzgl. Assoziationen als ein Variablentyp. Ist und bleibt ein Integer, beispielsweise.
Geht also eher alles in Richtung Visualisierung.

Wurde bei mir schon abgelehnt. :frowning:

Über eine HTML Box ist das lösbar.

Aber dann bräuchte ich wieder eine eigene „Eingabevariable“, oder? Du meinst die HTML-Box nur für die Visualisierung nutzen?

Ich habe den Titel mal ein wenig angepasst.

Es gab letztens schon einmal ein Thema in dem gewünscht wurde, dass bei Assoziationen ein Mehrfachauswahl möglich sein soll. Das ist aber leider nicht ganz so einfach zu realisieren.

paresy

Kann man nicht auch durch UND-Verknüpfungen entsprechende Variablen erzeugen?

Gruß Helmut

Aber dann bräuchte ich wieder eine eigene „Eingabevariable“, oder? Du meinst die HTML-Box nur für die Visualisierung nutzen?

Du kannst das für die Visu nutzen oder auch Umgekehrt etwas komplizierter als Eingabemedium mit Visu welches den Wert an IPS übergibt und in einer Integer Var speichert. Es gibt ja einige hier im Forum welche die html Box für Ihre eigenen Projekte benutzen. Hier bist Du ja frei und fast ungebunden.

Wenn ich es richtig Verstande habe suchst du sowas http://www.ip-symcon.de/forum/threads/19136-Integer-Assoziationen-Ver%C3%A4ndern?p=170708#post170708

Ich habe das mittlerweile noch ein wenig aus gereift . Aber leider immer noch das Problem das alle außer die letzte geklickte Assoziation aus gegraut sind.

Ich lese z.b. Über die Farben aus welche aktiv und nicht aktiv sind.
Das kommt deiner Bit Variante ja sehr nah.

Mastershort

bei ms-access gibt es sowas auch, da heisst es „optionsgruppe“.

Danke für die zahlreichen Antworten. Bin gespannt, ob es vielleicht irgendwann kommt. In meinen Augen auf jeden Fall sehr praktisch, da ich nun sehr simpel die einzelnen Rolläden konfigurieren kann.
Ich hab´s jetzt aber auch mit Bordmitteln hinbekommen. Zwar relativ aufwendig, aber ging dann doch.
Im Anhang mal, wie es jetzt ausschaut. Ich musste nun halt für jeden Rolladen 5 Variablen für die Bits anlegen sowie jeweils ein eigenes Variablenprofil. Das Skript kann ich bei Bedarf auch noch posten.

Ja poste mal dein Skript. Vielleicht wird dann klarer was du gemacht hast und was was du vor hast.

Ok, hier das Skript:


<?
if ($IPS_SENDER == "WebFront") {
   $bit0 = IPS_GetVariableIDByName("Bit 0", $IPS_VARIABLE);
   $bit1 = IPS_GetVariableIDByName("Bit 1", $IPS_VARIABLE);
   $bit2 = IPS_GetVariableIDByName("Bit 2", $IPS_VARIABLE);
   $bit3 = IPS_GetVariableIDByName("Bit 3", $IPS_VARIABLE);
   $bit4 = IPS_GetVariableIDByName("Bit 4", $IPS_VARIABLE);
   $bit5 = IPS_GetVariableIDByName("Bit 5", $IPS_VARIABLE);
	$id_profilenr = IPS_GetVariableIDByName("ProfileNr", $IPS_VARIABLE);
  	$id_instance = IPS_GetParent($IPS_VARIABLE);
	$id_working = IPS_GetStatusVariableID($id_instance, "WORKING");
	$id_level = IPS_GetStatusVariableID($id_instance, "LEVEL");
	$id_inhibit = IPS_GetStatusVariableID($id_instance, "INHIBIT");
	$profilenr = GetValue($id_profilenr);
	$profile = "BitMask_Rolladen_".str_pad($profilenr, 2 ,'0', STR_PAD_LEFT);
	switch ($IPS_VALUE) {
	   case 0:
			/* Rolladen schließen */
         if (GetValue($id_working)) {
			   HM_WriteValueBoolean($id_instance, "STOP", true);
			} else {
			   HM_WriteValueFloat($id_instance, "LEVEL", 0);
			}
			SetValue($IPS_VARIABLE, 0);
			/* Restliche Bits visualisieren */
			if (!GetValue($bit2)) {
		      IPS_SetVariableProfileAssociation($profile, 2, "Sonnenaufgang", "Shutter", -1);
			} else {
		      IPS_SetVariableProfileAssociation($profile, 2, "Sonnenaufgang", "Shutter", 0xffff00);
			}
			if (!GetValue($bit3)) {
		      IPS_SetVariableProfileAssociation($profile, 3, "Sonnenuntergang", "Shutter", -1);
			} else {
		      IPS_SetVariableProfileAssociation($profile, 3, "Sonnenuntergang", "Shutter", 0xff6633);
			}
			if (!GetValue($bit4)) {
		      IPS_SetVariableProfileAssociation($profile, 4, "Beschattung", "Shutter", -1);
			} else {
		      IPS_SetVariableProfileAssociation($profile, 4, "Beschattung", "Shutter", 0x9933ff);
			}
			if (!GetValue($bit5)) {
		      IPS_SetVariableProfileAssociation($profile, 5, "Tastensperre", "Shutter", -1);
			} else {
		      IPS_SetVariableProfileAssociation($profile, 5, "Tastensperre", "Shutter", 0x0000ff);
			}
			break;
		case 1:
		   /* Rolladen öffnen */
         if (GetValue($id_working)) {
			   HM_WriteValueBoolean($id_instance, "STOP", true);
			} else {
			   HM_WriteValueFloat($id_instance, "LEVEL", 1);
			}
			SetValue($IPS_VARIABLE, 1);
			/* Restliche Bits visualisieren */
			if (!GetValue($bit2)) {
		      IPS_SetVariableProfileAssociation($profile, 2, "Sonnenaufgang", "Shutter", -1);
			} else {
		      IPS_SetVariableProfileAssociation($profile, 2, "Sonnenaufgang", "Shutter", 0xffff00);
			}
			if (!GetValue($bit3)) {
		      IPS_SetVariableProfileAssociation($profile, 3, "Sonnenuntergang", "Shutter", -1);
			} else {
		      IPS_SetVariableProfileAssociation($profile, 3, "Sonnenuntergang", "Shutter", 0xff6633);
			}
			if (!GetValue($bit4)) {
		      IPS_SetVariableProfileAssociation($profile, 4, "Beschattung", "Shutter", -1);
			} else {
		      IPS_SetVariableProfileAssociation($profile, 4, "Beschattung", "Shutter", 0x9933ff);
			}
			if (!GetValue($bit5)) {
		      IPS_SetVariableProfileAssociation($profile, 5, "Tastensperre", "Shutter", -1);
			} else {
		      IPS_SetVariableProfileAssociation($profile, 5, "Tastensperre", "Shutter", 0x0000ff);
			}
		   break;
	   case 2:
			if (!GetValue($bit2)) {
			   SetValue($bit2, true);
		      IPS_SetVariableProfileAssociation($profile, 2, "Sonnenaufgang", "Shutter", 0xffff00);
			} else {
			   SetValue($bit2, false);
		      IPS_SetVariableProfileAssociation($profile, 2, "Sonnenaufgang", "Shutter", -1);
			}
			if (!GetValue($bit3)) {
		      IPS_SetVariableProfileAssociation($profile, 3, "Sonnenuntergang", "Shutter", -1);
			} else {
		      IPS_SetVariableProfileAssociation($profile, 3, "Sonnenuntergang", "Shutter", 0xff6633);
			}
			if (!GetValue($bit4)) {
		      IPS_SetVariableProfileAssociation($profile, 4, "Beschattung", "Shutter", -1);
			} else {
		      IPS_SetVariableProfileAssociation($profile, 4, "Beschattung", "Shutter", 0x9933ff);
			}
			if (!GetValue($bit5)) {
		      IPS_SetVariableProfileAssociation($profile, 5, "Tastensperre", "Shutter", -1);
			} else {
		      IPS_SetVariableProfileAssociation($profile, 5, "Tastensperre", "Shutter", 0x0000ff);
			}
	      break;
		case 3:
			if (!GetValue($bit2)) {
		      IPS_SetVariableProfileAssociation($profile, 2, "Sonnenaufgang", "Shutter", -1);
			} else {
		      IPS_SetVariableProfileAssociation($profile, 2, "Sonnenaufgang", "Shutter", 0xffff00);
			}
			if (!GetValue($bit3)) {
			   SetValue($bit3, true);
		      IPS_SetVariableProfileAssociation($profile, 3, "Sonnenuntergang", "Shutter", 0xff6633);
			} else {
			   SetValue($bit3, false);
		      IPS_SetVariableProfileAssociation($profile, 3, "Sonnenuntergang", "Shutter", -1);
			}
			if (!GetValue($bit4)) {
		      IPS_SetVariableProfileAssociation($profile, 4, "Beschattung", "Shutter", -1);
			} else {
		      IPS_SetVariableProfileAssociation($profile, 4, "Beschattung", "Shutter", 0x9933ff);
			}
			if (!GetValue($bit5)) {
		      IPS_SetVariableProfileAssociation($profile, 5, "Tastensperre", "Shutter", -1);
			} else {
		      IPS_SetVariableProfileAssociation($profile, 5, "Tastensperre", "Shutter", 0x00ff);
			}
		   break;
	   case 4:
			if (!GetValue($bit2)) {
		      IPS_SetVariableProfileAssociation($profile, 2, "Sonnenaufgang", "Shutter", -1);
			} else {
		      IPS_SetVariableProfileAssociation($profile, 2, "Sonnenaufgang", "Shutter", 0xffff00);
			}
			if (!GetValue($bit3)) {
		      IPS_SetVariableProfileAssociation($profile, 3, "Sonnenuntergang", "Shutter", -1);
			} else {
		      IPS_SetVariableProfileAssociation($profile, 3, "Sonnenuntergang", "Shutter", 0xff6633);
			}
			if (!GetValue($bit4)) {
			   SetValue($bit4, true);
		      IPS_SetVariableProfileAssociation($profile, 4, "Beschattung", "Shutter", 0x9933ff);
			} else {
			   SetValue($bit4, false);
		      IPS_SetVariableProfileAssociation($profile, 4, "Beschattung", "Shutter", -1);
			}
			if (!GetValue($bit5)) {
		      IPS_SetVariableProfileAssociation($profile, 5, "Tastensperre", "Shutter", -1);
			} else {
		      IPS_SetVariableProfileAssociation($profile, 5, "Tastensperre", "Shutter", 0x0000ff);
			}
	      break;
		case 5:
			if (!GetValue($bit2)) {
		      IPS_SetVariableProfileAssociation($profile, 2, "Sonnenaufgang", "Shutter", -1);
			} else {
		      IPS_SetVariableProfileAssociation($profile, 2, "Sonnenaufgang", "Shutter", 0xffff00);
			}
			if (!GetValue($bit3)) {
		      IPS_SetVariableProfileAssociation($profile, 3, "Sonnenuntergang", "Shutter", -1);
			} else {
		      IPS_SetVariableProfileAssociation($profile, 3, "Sonnenuntergang", "Shutter", 0xff6633);
			}
			if (!GetValue($bit4)) {
		      IPS_SetVariableProfileAssociation($profile, 4, "Beschattung", "Shutter", -1);
			} else {
		      IPS_SetVariableProfileAssociation($profile, 4, "Beschattung", "Shutter", 0x9933ff);
			}
			if (!GetValue($bit5)) {
			   HM_WriteValueBoolean($id_instance, "INHIBIT", true);
			   SetValue($bit5, true);
		      IPS_SetVariableProfileAssociation($profile, 5, "Tastensperre", "Shutter", 0x0000ff);
			} else {
			   HM_WriteValueBoolean($id_instance, "INHIBIT", false);
			   SetValue($bit5, false);
		      IPS_SetVariableProfileAssociation($profile, 5, "Tastensperre", "Shutter", -1);
			}
		   break;
	}
}
?>

Damit bin ich jetzt erstmal zufrieden. Das die Auswahlmöglichkeiten ausgegraut sind, ist ok, da ich über „Geschlossen“ und „Geöffnet“ noch den aktuellen Zustand des Rolladens anzeige.

So was ist immer noch nicht geplant, oder? :stuck_out_tongue:

Aber das ist doch nichts anderes als eine Integer Variable, die eine Assoziation bekommt wenn ich das richtig sehe.