Example #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);
    }
  }
Example #2
0
 protected function RegisterTimer($Name, $Interval, $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");
         }
         if (IPS_GetEvent($id)['EventType'] != 1) {
             IPS_DeleteEvent($id);
             $id = 0;
         }
     }
     if ($id == 0) {
         $id = IPS_CreateEvent(1);
         IPS_SetParent($id, $this->InstanceID);
         IPS_SetIdent($id, $Name);
     }
     IPS_SetName($id, $Name);
     IPS_SetHidden($id, true);
     IPS_SetEventScript($id, $Script);
     if ($Interval > 0) {
         IPS_SetEventCyclic($id, 0, 0, 0, 0, 1, $Interval);
         IPS_SetEventActive($id, true);
     } else {
         IPS_SetEventCyclic($id, 0, 0, 0, 0, 1, 1);
         IPS_SetEventActive($id, false);
     }
 }
Example #3
0
 protected function RegisterTimer($Name, $Interval, $Script)
 {
     $id = @IPS_GetObjectIDByIdent($Name, $this->InstanceID);
     if ($id === false) {
         $id = IPS_CreateEvent(1);
         IPS_SetParent($id, $this->InstanceID);
         IPS_SetIdent($id, $Name);
     }
     IPS_SetName($id, $Name);
     IPS_SetHidden($id, true);
     IPS_SetEventScript($id, $Script);
     if ($Interval > 0) {
         IPS_SetEventCyclic($id, 0, 0, 0, 0, 1, $Interval);
         IPS_SetEventActive($id, true);
     } else {
         IPS_SetEventCyclic($id, 0, 0, 0, 0, 1, 1);
         IPS_SetEventActive($id, false);
     }
 }
Example #4
0
 protected function CreateLink($Ident, $Name, $Target = 0)
 {
     if (!($LinkID = @IPS_GetObjectIdByIdent($Ident, $this->InstanceID))) {
         $LinkID = IPS_CreateLink();
         IPS_SetName($LinkID, $Name);
         IPS_SetParent($LinkID, $this->InstanceID);
         IPS_SetIdent($LinkID, $Ident);
         if ($Target) {
             IPS_SetLinkTargetID($LinkID, $Target);
             $EventID = IPS_CreateEvent(0);
             IPS_SetParent($EventID, $this->InstanceID);
             // $LinkID);
             IPS_SetEventTrigger($EventID, 1, $Target);
             IPS_SetEventScript($EventID, 'PJ_UpdateColor($_IPS[\'TARGET\']);');
         }
     }
 }
Example #5
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
 }
Example #6
0
 /**
  * ModBusMaster_WriteCoil
  * @param boolean $Value
  * @return boolean
  */
 public function WriteCoil($Value)
 {
     if ($this->ReadPropertyBoolean("ReadOnly")) {
         trigger_error("Address is marked as read-only!", E_USER_WARNING);
         return;
     }
     if ($this->ReadPropertyInteger("DataType") === 0) {
         $resultat = $this->SendDataToParent(json_encode(array("DataID" => "{A3419A88-C83B-49D7-8706-D3AFD596DFBB}", "FC" => "5", "Address" => $this->ReadPropertyInteger("Address"), "Data" => $Value)));
         if ($this->ReadPropertyInteger("SwitchDuration") > 0 and $Value) {
             $eid = @IPS_GetObjectIDByIdent("SwitchDuration", $this->InstanceID);
             if ($eid === false) {
                 $eid = 0;
             } else {
                 if (IPS_GetEvent($eid)['EventType'] != 1) {
                     IPS_DeleteEvent($eid);
                     $eid = 0;
                 }
             }
             if ($eid == 0) {
                 $eid = IPS_CreateEvent(1);
                 IPS_SetParent($eid, $this->InstanceID);
                 IPS_SetIdent($eid, "SwitchDuration");
                 IPS_SetName($eid, "SwitchDuration");
                 IPS_SetHidden($eid, true);
                 IPS_SetEventScript($eid, "ModBusMaster_WriteCoil(\$_IPS['TARGET'], false);IPS_SetEventActive(\$_IPS['EVENT'],false);");
             }
             IPS_SetEventCyclicTimeFrom($eid, date("H"), date("i"), date("s"));
             IPS_SetEventCyclic($eid, 0, 0, 0, 0, 1, $this->ReadPropertyInteger("SwitchDuration"));
             IPS_SetEventActive($eid, true);
         }
         return $resultat;
     } else {
         trigger_error("Invalid DataType!", E_USER_WARNING);
     }
 }
Example #7
0
 protected function SetTimerByIdent_InSekunden($ident, $Sekunden)
 {
     $eid = @IPS_GetObjectIDByIdent($ident, $this->InstanceID);
     if ($eid === false) {
         $eid = IPS_CreateEvent(1);
         IPS_SetParent($eid, $this->InstanceID);
         IPS_SetName($eid, $ident);
         IPS_SetIdent($eid, $ident);
         IPS_SetEventScript($eid, 'HMON_Benachrichtigung($_IPS[\'TARGET\'], false, true);');
         IPS_SetInfo($eid, "this timer was created by script #" . $_IPS['SELF']);
     }
     if ($Sekunden === false) {
         IPS_SetEventActive($eid, false);
         return $eid;
     } else {
         IPS_SetEventCyclicTimeFrom($eid, intval(date("H", time() + $Sekunden)), intval(date("i", time() + $Sekunden)), intval(date("s", time() + $Sekunden)));
         IPS_SetEventActive($eid, true);
         return $eid;
     }
 }
 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);
         }
     }
 }
Example #9
0
 protected function RegisterTimer($Ident, $Milliseconds, $Action)
 {
     $id = @IPS_GetObjectIDByIdent($Ident, $this->InstanceID);
     if ($id === false) {
         $id = 0;
     }
     if ($id > 0) {
         if (!IPS_EventExists($id)) {
             throw new Exception("Ident with name " . $Ident . " is used for wrong object type");
         }
         if (IPS_GetEvent($id)['EventType'] != 1) {
             IPS_DeleteEvent($id);
             $id = 0;
         }
     }
     if ($id == 0) {
         $id = IPS_CreateEvent(1);
         IPS_SetParent($id, $this->InstanceID);
         IPS_SetIdent($id, $Ident);
     }
     IPS_SetName($id, $Ident);
     IPS_SetHidden($id, true);
     IPS_SetEventScript($id, $Action);
     IPS_SetEventActive($id, false);
 }