コード例 #1
0
ファイル: module.php プロジェクト: Vansdan/SymconHUE
  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);
    }
  }
コード例 #2
0
ファイル: module.php プロジェクト: Nall-chan/IPSSqueezeBox
 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);
         }
     }
 }
コード例 #3
0
ファイル: IPSWatering.inc.php プロジェクト: KOS-CH/IPSLibrary
	function	IPSWatering_ActivateRefreshTimer($Value) {
		$Name    = 'Refresh';
		$scriptId_Timer = IPSUtil_ObjectIDByPath('Program.IPSLibrary.app.modules.IPSWatering.IPSWatering_RefreshTimer');
		$TimerId = @IPS_GetEventIDByName($Name, $scriptId_Timer);
		if ($TimerId === false) {
 			$TimerId = IPS_CreateEvent(1 /*Cyclic Event*/);
			IPS_SetName($TimerId, $Name);
			IPS_SetParent($TimerId, $scriptId_Timer);
			if (!IPS_SetEventCyclic($TimerId, 2 /*Daily*/, 1 /*Int*/,0 /*Days*/,0/*DayInt*/,1/*TimeType Sec*/,1/*Sec*/)) {
				IPSLogger_Err(__file__, "IPS_SetEventCyclic failed for Refresh Timer!!!");
				exit;
			}
		}

		if ($Value) {
			IPS_SetEventActive($TimerId, true);
		} else {
			$OneOrMoreCirclesActive = false;
			$categoryId_Circles = IPSUtil_ObjectIDByPath('Program.IPSLibrary.data.modules.IPSWatering.WaterCircles');
			$CircleIds          = IPS_GetChildrenIds($categoryId_Circles);
				foreach($CircleIds as $CircleId) {
				$OneOrMoreCirclesActive = ($OneOrMoreCirclesActive or GetValue(get_ControlId(c_Control_Active, $CircleId)));
			}
			if (!$OneOrMoreCirclesActive) {
				IPS_SetEventActive($TimerId, false);
			}
		}
	}
コード例 #4
0
 /**
  * disable
  * disables this event
  *
  * @access public
  */
 public function disable()
 {
     return IPS_SetEventActive($this->id, false);
 }
コード例 #5
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", E_USER_WARNING);
         }
         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);
     }
 }
コード例 #6
0
ファイル: module.php プロジェクト: finanzamt2002/Lueften
 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
 }
コード例 #7
0
 public function toogleGoodNight()
 {
     $goodnightstate = GetValue($this->GetIDForIdent("GoodNight"));
     $sleeptimerstate = GetValue($this->GetIDForIdent("SleepTimer"));
     $sleeptimervariableid = @$this->GetIDForIdent("SleepTimer");
     $sleeptimercontrolscriptid = @IPS_GetScriptIDByName("SleepTimerControl", $sleeptimervariableid);
     $sleeptimercontrolscripteventid = @IPS_GetEventIDByName("SleepTimerEvent", $sleeptimercontrolscriptid);
     if ($goodnightstate == false and $sleeptimerstate == false) {
         SetValue($this->GetIDForIdent("GoodNight"), true);
         SetValue($this->GetIDForIdent("VolumeFadeOut"), true);
         // set event
         $timenow = time();
         $timestamp = strtotime('+900 seconds', $timenow);
         $nextpowerofftime = strtotime('+1800 seconds', $timenow);
         $hour = date("H", $timestamp);
         $minute = date("i", $timestamp);
         $second = date("s", $timestamp);
         IPS_SetEventCyclicTimeFrom($sleeptimercontrolscripteventid, $hour, $minute, $second);
         IPS_SetEventActive($sleeptimercontrolscripteventid, true);
         // set next power off
         $day = date("l", $nextpowerofftime);
         $date = date("d.m.Y", $nextpowerofftime);
         $time = date("H:i:s", $nextpowerofftime);
         $nextpoweroff = $day . ", " . $date . ", " . $time;
         SetValue($this->GetIDForIdent("NextPowerOff"), $nextpoweroff);
         // calculate cycle time
         $fadeoutseconds = 900;
         $actualvolume = GetValue($this->GetIDForIdent("VolumeSlider"));
         $cycletime = floor(900 / ($actualvolume - 1));
         SetValue($this->GetIDForIdent("SleepCycle"), $cycletime);
     }
     if ($goodnightstate == true and $sleeptimerstate == false) {
         IPS_SetEventActive($sleeptimercontrolscripteventid, false);
         SetValue($this->GetIDForIdent("VolumeFadeOut"), false);
         SetValue($this->GetIDForIdent("GoodNight"), false);
         SetValue($this->GetIDForIdent("SleepCycle"), 0);
         SetValue($this->GetIDForIdent("NextPowerOff"), "");
     }
 }
コード例 #8
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);
     }
 }
コード例 #9
0
ファイル: module.php プロジェクト: BayaroX/BY_HostMonitor
 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;
     }
 }
コード例 #10
0
		/**
		 * @public
		 *
		 * Erzeugt ein Event für eine übergebene Variable, das den IPSMessageHandler beim Auslösen
		 * aufruft.
		 *
		 * @param integer $variableId ID der auslösenden Variable
		 * @param string $eventType Type des Events (OnUpdate oder OnChange)
		 */
		public static function CreateEvent($variableId, $eventType) {
			switch ($eventType) {
				case 'OnChange':
					$triggerType = 1;
					break;
				case 'OnUpdate':
					$triggerType = 0;
					break;
				default:
					throw new IPSMessageHandlerException('Found unknown EventType '.$eventType);
			}
			$eventName = $eventType.'_'.$variableId;
			$scriptId  = IPS_GetObjectIDByIdent('IPSMessageHandler_Event', IPSUtil_ObjectIDByPath('Program.IPSLibrary.app.core.IPSMessageHandler'));
			$eventId   = @IPS_GetObjectIDByIdent($eventName, $scriptId);
			if ($eventId === false) {
				$eventId = IPS_CreateEvent(0);
				IPS_SetName($eventId, $eventName);
				IPS_SetIdent($eventId, $eventName);
				IPS_SetEventTrigger($eventId, $triggerType, $variableId);
				IPS_SetParent($eventId, $scriptId);
				IPS_SetEventActive($eventId, true);
				IPSLogger_Dbg (__file__, 'Created IPSMessageHandler Event for Variable='.$variableId);
			}
		}
コード例 #11
0
	function CreateTimer ($Name, $Parent, $Hour) {
	   $TimerId = @IPS_GetEventIDByName($Name, $Parent);
	   if ($TimerId === false) {
 			$TimerId = IPS_CreateEvent(1 /*Cyclic Event*/);
   		IPS_SetName($TimerId, $Name);
   		IPS_SetParent($TimerId, $Parent);
			if (!IPS_SetEventCyclic($TimerId, 2 /**Daily*/, 1,0,0,0,0)) {
				echo "IPS_SetEventCyclic failed !!!\n";
			}
			if (!IPS_SetEventCyclicTimeBounds($TimerId, mktime($Hour, 0, 0), 0)) {
				echo "IPS_SetEventCyclicTimeBounds failed !!!\n";
			}
   		IPS_SetEventActive($TimerId, true);
			echo 'Created Timer '.$Name.'='.$TimerId."\n";
		}
		return $TimerId;
	}
コード例 #12
0
ファイル: module.php プロジェクト: Nall-chan/paresyMisc
 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);
         }
     }
 }
コード例 #13
0
ファイル: IPSEDIP.class.php プロジェクト: KOS-CH/IPSLibrary
		private function GenerateEvents() {
			$objectIds = explode(',',GetValue($this->objectIdsId));
			$edipName  = IPS_GetName($this->instanceId);
			foreach ($objectIds as $objectId) {
			   $objectId   = (int)$objectId;
				$objectData = IPS_GetObject($objectId);
				if ($objectData['ObjectType']==2) {
				   $eventName = $edipName.'_'.IPS_GetName($objectId);
					$eventId   = @IPS_GetEventIdByName($eventName ,EDIP_ID_EVENTSCRIPT);
					if ($eventId===false) {
						$eventId = IPS_CreateEvent(0);
						IPSLogger_Trc(__file__, "Create Event=$eventName, ID=$eventId, Parent=".EDIP_ID_EVENTSCRIPT);
				  		IPS_SetName($eventId, $eventName);
						IPS_SetEventTrigger($eventId, 1, $objectId);
						IPS_SetParent($eventId, EDIP_ID_EVENTSCRIPT);
						IPS_SetEventActive($eventId, true);
					}
				}
			}
		}
コード例 #14
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);
     }
 }