Ejemplo n.º 1
0
  protected function RegisterTimer($ident, $interval, $script) {
    $id = @IPS_GetObjectIDByIdent($ident, $this->InstanceID);

    if ($id && IPS_GetEvent($id)['EventType'] <> 1) {
      IPS_DeleteEvent($id);
      $id = 0;
    }

    if (!$id) {
      $id = IPS_CreateEvent(1);
      IPS_SetParent($id, $this->InstanceID);
      IPS_SetIdent($id, $ident);
    }

    IPS_SetName($id, $ident);
    IPS_SetHidden($id, true);
    IPS_SetEventScript($id, "\$id = \$_IPS['TARGET'];\n$script;");

    if (!IPS_EventExists($id)) throw new Exception("Ident with name $ident is used for wrong object type");

    if (!($interval > 0)) {
      IPS_SetEventCyclic($id, 0, 0, 0, 0, 1, 1);
      IPS_SetEventActive($id, false);
    } else {
      IPS_SetEventCyclic($id, 0, 0, 0, 0, 1, $interval);
      IPS_SetEventActive($id, true);
    }
  }
Ejemplo n.º 2
0
 protected function SetTimerInterval($Name, $Interval)
 {
     $id = @IPS_GetObjectIDByIdent($Name, $this->InstanceID);
     if ($id === false) {
         throw new Exception('Timer not present');
     }
     if (!IPS_EventExists($id)) {
         throw new Exception('Timer not present');
     }
     $Event = IPS_GetEvent($id);
     if ($Interval < 1) {
         if ($Event['EventActive']) {
             IPS_SetEventActive($id, false);
         }
     } else {
         if ($Event['CyclicTimeValue'] != $Interval) {
             IPS_SetEventCyclic($id, 0, 0, 0, 0, 1, $Interval);
         }
         if (!$Event['EventActive']) {
             IPS_SetEventActive($id, true);
         }
     }
 }
Ejemplo n.º 3
0
 protected function UnregisterTimer($Name)
 {
     $id = @IPS_GetObjectIDByIdent($Name, $this->InstanceID);
     if ($id > 0) {
         if (!IPS_EventExists($id)) {
             throw new Exception('Timer not present', E_USER_NOTICE);
         }
         IPS_DeleteEvent($id);
     }
 }
Ejemplo n.º 4
0
 private function Registerevent121($var5_id, $TargetID)
 {
     if (!isset($_IPS)) {
         global $_IPS;
     }
     $EreignisID = @IPS_GetEventIDByName("E_TW", $TargetID);
     if ($EreignisID == true) {
         if (IPS_EventExists(IPS_GetEventIDByName("E_TW", $TargetID))) {
             IPS_DeleteEvent(IPS_GetEventIDByName("E_TW", $TargetID));
         }
     }
     $eid = IPS_CreateEvent(0);
     //Ausgelöstes Ereignis
     IPS_SetName($eid, "E_TW");
     IPS_SetEventTrigger($eid, 0, $var5_id);
     //Bei Änderung von Variable Wandtemp
     IPS_SetParent($eid, $TargetID);
     //Ereignis zuordnen
     IPS_SetEventScript($eid, 'SetValue($_IPS[\'TARGET\'], $_IPS[\'VALUE\']);');
     IPS_SetEventActive($eid, true);
     //Ereignis aktivieren
 }
 protected function RegisterEvent($Name, $Source, $Script)
 {
     $id = @IPS_GetObjectIDByIdent($Name, $this->InstanceID);
     if ($id === false) {
         $id = 0;
     }
     if ($id > 0) {
         if (!IPS_EventExists($id)) {
             throw new Exception("Ident with name " . $Name . " is used for wrong object type", E_USER_WARNING);
         }
         if (IPS_GetEvent($id)['EventType'] != 0) {
             IPS_DeleteEvent($id);
             $id = 0;
         }
     }
     if ($id == 0) {
         $id = IPS_CreateEvent(0);
         IPS_SetParent($id, $this->InstanceID);
         IPS_SetIdent($id, $Name);
     }
     IPS_SetName($id, $Name);
     IPS_SetHidden($id, true);
     IPS_SetEventScript($id, $Script);
     if ($Source > 0) {
         IPS_SetEventTrigger($id, 0, $Source);
         if (!IPS_GetEvent($id)['EventActive']) {
             IPS_SetEventActive($id, true);
         }
     } else {
         IPS_SetEventTrigger($id, 0, 0);
         if (IPS_GetEvent($id)['EventActive']) {
             IPS_SetEventActive($id, false);
         }
     }
 }
Ejemplo n.º 6
0
 protected function SetTimer($Name, $TargetTime)
 {
     $id = @IPS_GetObjectIDByIdent($Name, $this->InstanceID);
     if ($id === false) {
         throw new Exception('Timer not present');
     }
     if (!IPS_EventExists($id)) {
         throw new Exception('Timer not present');
     }
     $Event = IPS_GetEvent($id);
     if ($TargetTime < time()) {
         if ($Event['EventActive']) {
             IPS_SetEventActive($id, false);
         }
     } else {
         IPS_SetEventCyclic($id, 1, 0, 0, 0, 0, 0);
         IPS_SetEventCyclicDateFrom($id, (int) date("j", $TargetTime), (int) date("n", $TargetTime), (int) date("o", $TargetTime));
         IPS_SetEventCyclicDateTo($id, (int) date("j", $TargetTime), (int) date("n", $TargetTime), (int) date("o", $TargetTime));
         IPS_SetEventCyclicTimeFrom($id, (int) date("H", $TargetTime), (int) date("i", $TargetTime), (int) date("s", $TargetTime));
         IPS_SetEventCyclicTimeTo($id, (int) date("H", $TargetTime), (int) date("i", $TargetTime), (int) date("s", $TargetTime));
         if (!$Event['EventActive']) {
             IPS_SetEventActive($id, true);
         }
     }
 }
Ejemplo n.º 7
0
 protected function SetTimerIntervalTime($Name, $startzeith, $startzeitm, $stopzeith, $stopzeitm)
 {
     $id = @IPS_GetObjectIDByIdent($Name, $this->InstanceID);
     if ($id === false) {
         throw new Exception('Timer not present', E_USER_WARNING);
     }
     if (!IPS_EventExists($id)) {
         throw new Exception('Timer not present', E_USER_WARNING);
     }
     $Event = IPS_GetEvent($id);
     if ($startzeith > 23) {
         if ($Event['EventActive']) {
             IPS_SetEventActive($id, false);
         }
     } else {
         IPS_SetEventCyclicTimeFrom($id, $startzeith, $startzeitm, 0);
         IPS_SetEventCyclicTimeTo($id, $stopzeith, $stopzeitm, 0);
     }
 }