8-Bit-Eingang lesen

Update für Version 4


<?

//Nur Trigger durch Variable erlauben
if($_IPS['SENDER'] != "Variable") {
    return;
}

for($i=0; $i<12; $i++) {
    $bitvalue = (($_IPS['VALUE'] & (1 << $i)) == (1 << $i));
    $varname = IPS_GetName($_IPS['VARIABLE'])."_Bit".$i;
    $vid = CreateVariableByIdent($_IPS['VARIABLE'], $varname, 0);
    SetValue($vid, $bitvalue);
}

function CreateVariableByIdent($id, $name, $type){
   global $IPS_SELF;
   $vid = @IPS_GetObjectIDByIdent($name, $id);
   if($vid===false) {
      $vid = IPS_CreateVariable($type);
      IPS_SetParent($vid, $id);
      IPS_SetName($vid, $name);
      IPS_SetIdent($vid, $name);
      IPS_SetInfo($vid, "This Variable was created by Script");
   }
   return $vid;
}

paresy

1 „Gefällt mir“