diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentAVControl/IPSComponentAVControl_AudioMax.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentAVControl/IPSComponentAVControl_AudioMax.class.php index e60d2dc..ccf1b54 100644 --- a/IPSLibrary/app/core/IPSComponent/IPSComponentAVControl/IPSComponentAVControl_AudioMax.class.php +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentAVControl/IPSComponentAVControl_AudioMax.class.php @@ -10,21 +10,21 @@ IPSUtils_Include ('IPSComponentAVControl.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentAVControl'); IPSUtils_Include ("AudioMax.inc.php", 'IPSLibrary::app::hardware::AudioMax'); - /** - * @class IPSComponentAVControl_AudioMax - * - * Definiert ein IPSComponentAVControl_AudioMax Object, das ein IPSComponentAVControl Object mit Hilfe der + /** + * @class IPSComponentAVControl_AudioMax + * + * Definiert ein IPSComponentAVControl_AudioMax Object, das ein IPSComponentAVControl Object mit Hilfe der * AudioMax MultiRoom Steuerung e-Service Online implementiert - * - * @author Andreas Brauneis - * @version - * Version 2.50.1, 31.01.2012
- */ + * + * @author Andreas Brauneis + * @version + * Version 2.50.1, 31.01.2012
+ */ class IPSComponentAVControl_AudioMax extends IPSComponentAVControl{ private $instanceId; - + /** * @public * @@ -34,8 +34,8 @@ class IPSComponentAVControl_AudioMax extends IPSComponentAVControl{ */ public function __construct($instanceId) { $this->instanceId = (int)$instanceId; - if ($this->instanceId==null) { - $this->instanceId = IPSUtil_ObjectIDByPath('Program.IPSLibrary.data.hardware.AudioMax.AudioMax_Server'); + if ($this->instanceId==null) { + $this->instanceId = IPSUtil_ObjectIDByPath('Program.IPSLibrary.data.hardware.AudioMax.AudioMax_Server'); } } @@ -49,7 +49,7 @@ public function __construct($instanceId) { * @return string Parameter String des IPSComponent Object */ public function GetComponentParams() { - return get_class(this).','.$this->instanceId; + return get_class($this).','.$this->instanceId; } @@ -75,10 +75,16 @@ public function HandleEvent($variable, $value, IPSModuleAVControl $module) { switch($command) { case AM_CMD_POWER: case AM_CMD_ROOM: - for ($roomId=0;$roomIdinstanceId) and AudioMax_GetRoomPower($this->instanceId, $roomId); + if (!AudioMax_GetMainPower($this->instanceId) and $command==AM_CMD_ROOM) { + break; + } + for ($roomId=0;$roomIdinstanceId) and AudioMax_GetRoomPower($this->instanceId, $roomId)) { + $status='1'; + } $module->SyncPower($status, $roomId, $this); - } + } break; case AM_CMD_AUDIO: if (count($parameters)<6) return; @@ -87,22 +93,25 @@ public function HandleEvent($variable, $value, IPSModuleAVControl $module) { $value = $parameters[5]; switch($function) { case AM_FNC_BALANCE: - $module->SyncBalance($value, $roomId, $this); + $module->SyncBalance($value * 100 / AM_VAL_BALANCE_MAX, $roomId, $this); break; case AM_FNC_VOLUME: - $module->SyncVolume($value, $roomId, $this); + $module->SyncVolume($value * 100 / AM_VAL_VOLUME_MAX, $roomId, $this); + break; + case AM_FNC_MUTE: + $module->SyncMute($value, $roomId, $this); break; case AM_FNC_TREBLE: - $module->SyncTreble($value, $roomId, $this); + $module->SyncTreble($value * 100 / AM_VAL_TREBLE_MAX, $roomId, $this); break; case AM_FNC_MIDDLE: - $module->SyncMiddle($value, $roomId, $this); + $module->SyncMiddle($value * 100 / AM_VAL_MIDDLE_MAX, $roomId, $this); break; case AM_FNC_BASS: - $module->SyncBass($value, $roomId, $this); + $module->SyncBass($value * 100 / AM_VAL_BASS_MAX, $roomId, $this); break; case AM_FNC_INPUTSELECT: - $module->SyncSource($value, $roomId, $this); + $module->SyncSource($value, $roomId, $this); break; case AM_FNC_INPUTGAIN: break; @@ -115,6 +124,13 @@ public function HandleEvent($variable, $value, IPSModuleAVControl $module) { } } + private function HandleError($result) { + if ($result==false) { + $errorMessage = GetValue(IPS_GetObjectIDByIdent(AM_VAR_LASTERROR, $this->instanceId)); + trigger_error($errorMessage); + } + } + /** * @public * @@ -124,18 +140,20 @@ public function HandleEvent($variable, $value, IPSModuleAVControl $module) { * @param boolean $value Wert für Power (Wertebereich false=Off, true=On) */ public function SetPower($outputId, $value) { - AudioMax_SetRoomPower($this->instanceId, $outputId, $value); + $result = AudioMax_SetRoomPower($this->instanceId, $outputId, $value); + $this->HandleError($result); if ($value) { - AudioMax_SetMainPower($this->instanceId, $value); + $result = AudioMax_SetMainPower($this->instanceId, $value); } else { - $allRoomesOff = true; + $allRoomesOff = true; for ($roomId=0;$roomIdinstanceId, $roomId); + $allRoomesOff = ($allRoomesOff and !AudioMax_GetRoomPower($this->instanceId, $roomId)); } if ($allRoomesOff) { - AudioMax_SetMainPower($this->instanceId, $value); + $result = AudioMax_SetMainPower($this->instanceId, $value); } } + $this->HandleError($result); } /** @@ -161,7 +179,7 @@ public function GetPower($outputId) { * @param integer $value Eingang der gesetzt werden soll (Wertebereich 0 - x) */ public function SetSource($outputId, $value) { - AudioMax_SetRoomPower($this->instanceId, $outputId, $value); + $this->HandleError(AudioMax_SetInputSelect($this->instanceId, $outputId, $value)); } /** @@ -173,7 +191,7 @@ public function SetSource($outputId, $value) { * @return integer Eingang der gerade gewählt ist (Wertebereich 0 - x) */ public function GetSource($outputId) { - return AudioMax_SetRoomPower($this->instanceId, $outputId); + return AudioMax_GetInputSelect($this->instanceId, $outputId); } /** @@ -185,7 +203,7 @@ public function GetSource($outputId) { * @param integer $value Wert der Lautstärke (Wertebereich 0 - 100) */ public function SetVolume($outputId, $value) { - AudioMax_SetVolume($this->instanceId, $outputId, $value * AM_VAL_VOLUME_MAX / 100); + $this->HandleError(AudioMax_SetVolume($this->instanceId, $outputId, $value * AM_VAL_VOLUME_MAX / 100)); } /** @@ -197,7 +215,7 @@ public function SetVolume($outputId, $value) { * @return integer Wert der Lautstärke (Wertebereich 0 - 100) */ public function GetVolume($outputId) { - return AudioMax_GetVolume($this->instanceId, $outputId) * 100 / AM_VAL_VOLUME_MAX; + return AudioMax_GetVolume($this->instanceId, $outputId) * 100 / AM_VAL_VOLUME_MAX; } /** @@ -209,7 +227,18 @@ public function GetVolume($outputId) { * @param boolean $value Wert für Muting (Wertebereich true oder false) */ public function SetMute($outputId, $value) { - return AudioMax_SetMute($this->instanceId, $outputId, $value); + $this->HandleError(AudioMax_SetMute($this->instanceId, $outputId, $value)); + } + + /** + * @public + * + * Setzen des Mutings für einen Ausgang + * + * @param integer $outputId Ausgang der geändert werden soll (Wertebereich 0 - x) + */ + public function ToggleMute($outputId) { + $this->HandleError(AudioMax_SetMute($this->instanceId, $outputId, !AudioMax_GetMute($this->instanceId))); } /** @@ -221,7 +250,7 @@ public function SetMute($outputId, $value) { * @return boolean Wert für Muting (Wertebereich true oder false) */ public function GetMute($outputId) { - return AudioMax_GetMute($this->instanceId, $outputId); + return AudioMax_GetMute($this->instanceId, $outputId); } /** @@ -233,7 +262,7 @@ public function GetMute($outputId) { * @param integer $value Wert für Balance (Wertebereich: Links 0 - 50 , 51 - 100 Rechts) */ public function SetBalance($outputId, $value) { - AudioMax_SetBalance($this->instanceId, $outputId, $value * AM_VAL_BALANCE_MAX / 100); + $this->HandleError(AudioMax_SetBalance($this->instanceId, $outputId, $value * AM_VAL_BALANCE_MAX / 100)); } /** @@ -245,7 +274,7 @@ public function SetBalance($outputId, $value) { * @return integer Wert für Balance (Wertebereich: Links 0 - 50 , 51 - 100 Rechts) */ public function GetBalance($outputId) { - return AudioMax_GetBalance($this->instanceId, $outputId) * 100 / AM_VAL_BALANCE_MAX; + return AudioMax_GetBalance($this->instanceId, $outputId) * 100 / AM_VAL_BALANCE_MAX; } /** @@ -257,7 +286,7 @@ public function GetBalance($outputId) { * @param integer $value Wert für Höhen (Wertebereich 0 - 100) */ public function SetTreble($outputId, $value) { - AudioMax_SetTreble($this->instanceId, $outputId, $value * AM_VAL_TREBLE_MAX / 100); + $this->HandleError(AudioMax_SetTreble($this->instanceId, $outputId, $value * AM_VAL_TREBLE_MAX / 100)); } /** @@ -269,7 +298,7 @@ public function SetTreble($outputId, $value) { * @return integer Wert der Höhen (Wertebereich 0 -100) */ public function GetTreble($outputId) { - return AudioMax_GetTreble($this->instanceId, $outputId) * 100 / AM_VAL_TREBLE_MAX; + return AudioMax_GetTreble($this->instanceId, $outputId) * 100 / AM_VAL_TREBLE_MAX; } /** @@ -281,7 +310,7 @@ public function GetTreble($outputId) { * @param integer $value Wert für Mitten (Wertebereich 0 - 100) */ public function SetMiddle($outputId, $value) { - AudioMax_SetMiddle($this->instanceId, $outputId, $value * AM_VAL_MIDDLE_MAX / 100); + $this->HandleError(AudioMax_SetMiddle($this->instanceId, $outputId, $value * AM_VAL_MIDDLE_MAX / 100)); } /** @@ -293,7 +322,7 @@ public function SetMiddle($outputId, $value) { * @return integer Wert der Mitten (Wertebereich 0 -100) */ public function GetMiddle($outputId) { - return AudioMax_GetMiddle($this->instanceId, $outputId) * 100 / AM_VAL_MIDDLE_MAX; + return AudioMax_GetMiddle($this->instanceId, $outputId) * 100 / AM_VAL_MIDDLE_MAX; } /** @@ -305,7 +334,7 @@ public function GetMiddle($outputId) { * @param integer $value Wert für Bässe (Wertebereich 0 - 100) */ public function SetBass($outputId, $value) { - AudioMax_SetBass($this->instanceId, $outputId, $value * AM_VAL_BASS_MAX / 100); + $this->HandleError(AudioMax_SetBass($this->instanceId, $outputId, $value * AM_VAL_BASS_MAX / 100)); } /** @@ -317,7 +346,7 @@ public function SetBass($outputId, $value) { * @return integer Wert der Bässe (Wertebereich 0 -100) */ public function GetBass($outputId) { - return AudioMax_GetBass($this->instanceId, $outputId) * 100 / AM_VAL_BASS_MAX; + return AudioMax_GetBass($this->instanceId, $outputId) * 100 / AM_VAL_BASS_MAX; } } diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentAVControl/IPSModuleAVControl_Entertainment.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentAVControl/IPSModuleAVControl_Entertainment.class.php index dc19275..1cc91f4 100644 --- a/IPSLibrary/app/core/IPSComponent/IPSComponentAVControl/IPSModuleAVControl_Entertainment.class.php +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentAVControl/IPSModuleAVControl_Entertainment.class.php @@ -7,7 +7,7 @@ * */ - IPSUtils_Include ("Entertainment_InterfaceIPSComponent.inc.php", "IPSLibrary::app::modules::Entertainment"); + IPSUtils_Include ("Entertainment_InterfaceIPSComponentAVControl.inc.php", "IPSLibrary::app::modules::Entertainment"); IPSUtils_Include ('IPSModuleAVControl.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentAVControl'); /** @@ -41,7 +41,7 @@ public function __construct() { * @param IPSComponentAVControl $component Component Object das einen Werte synchronisieren will */ public function SyncPower($value, $outputId, IPSComponentAVControl $component) { - Entertainment_IPSComponent_ReceiveData($component->GetComponentParams(), 'SetPower', $output, $value); + Entertainment_IPSComponent_ReceiveData($component->GetComponentParams(), 'SetPower', $outputId, $value); } /** @@ -54,7 +54,7 @@ public function SyncPower($value, $outputId, IPSComponentAVControl $component) { * @param IPSComponentAVControl $component Component Object das einen Werte synchronisieren will */ public function SyncVolume($value, $outputId, IPSComponentAVControl $component) { - Entertainment_IPSComponent_ReceiveData($component->GetComponentParams(), 'SetVolume', $output, $value); + Entertainment_IPSComponent_ReceiveData($component->GetComponentParams(), 'SetVolume', $outputId, $value); } /** @@ -67,7 +67,7 @@ public function SyncVolume($value, $outputId, IPSComponentAVControl $component) * @param IPSComponentAVControl $component Component Object das einen Werte synchronisieren will */ public function SyncMute($value, $outputId, IPSComponentAVControl $component) { - Entertainment_IPSComponent_ReceiveData($component->GetComponentParams(), 'SetMute', $output, $value); + Entertainment_IPSComponent_ReceiveData($component->GetComponentParams(), 'SetMute', $outputId, $value); } /** @@ -80,7 +80,7 @@ public function SyncMute($value, $outputId, IPSComponentAVControl $component) { * @param IPSComponentAVControl $component Component Object das einen Werte synchronisieren will */ public function SyncBalance($value, $outputId, IPSComponentAVControl $component) { - Entertainment_IPSComponent_ReceiveData($component->GetComponentParams(), 'SetBalance', $output, $value); + Entertainment_IPSComponent_ReceiveData($component->GetComponentParams(), 'SetBalance', $outputId, $value); } /** @@ -93,7 +93,7 @@ public function SyncBalance($value, $outputId, IPSComponentAVControl $component) * @param IPSComponentAVControl $component Component Object das einen Werte synchronisieren will */ public function SyncSource($value, $outputId, IPSComponentAVControl $component) { - Entertainment_IPSComponent_ReceiveData($component->GetComponentParams(), 'SetSource', $output, $value); + Entertainment_IPSComponent_ReceiveData($component->GetComponentParams(), 'SetSource', $outputId, $value); } /** @@ -106,7 +106,7 @@ public function SyncSource($value, $outputId, IPSComponentAVControl $component) * @param IPSComponentAVControl $component Component Object das einen Werte synchronisieren will */ public function SyncTreble($value, $outputId, IPSComponentAVControl $component) { - Entertainment_IPSComponent_ReceiveData($component->GetComponentParams(), 'SetTreble', $output, $value); + Entertainment_IPSComponent_ReceiveData($component->GetComponentParams(), 'SetTreble', $outputId, $value); } /** @@ -119,7 +119,7 @@ public function SyncTreble($value, $outputId, IPSComponentAVControl $component) * @param IPSComponentAVControl $component Component Object das einen Werte synchronisieren will */ public function SyncMiddle($value, $outputId, IPSComponentAVControl $component) { - Entertainment_IPSComponent_ReceiveData($component->GetComponentParams(), 'SetMiddle', $output, $value); + Entertainment_IPSComponent_ReceiveData($component->GetComponentParams(), 'SetMiddle', $outputId, $value); } /** @@ -132,7 +132,7 @@ public function SyncMiddle($value, $outputId, IPSComponentAVControl $component) * @param IPSComponentAVControl $component Component Object das einen Werte synchronisieren will */ public function SyncBass($value, $outputId, IPSComponentAVControl $component) { - Entertainment_IPSComponent_ReceiveData($component->GetComponentParams(), 'SetBass', $output, $value); + Entertainment_IPSComponent_ReceiveData($component->GetComponentParams(), 'SetBass', $outputId, $value); } diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam.class.php new file mode 100644 index 0000000..c2a9736 --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam.class.php @@ -0,0 +1,135 @@ + + */ + + IPSUtils_Include ('IPSComponent.class.php', 'IPSLibrary::app::core::IPSComponent'); + + abstract class IPSComponentCam extends IPSComponent { + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleCam $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + abstract public function HandleEvent($variable, $value, IPSModuleCam $module); + + /** + * @public + * + * Liefert URL des Kamera Live Streams + * + * @param integer $size Größe des Streams, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return string URL des Streams + */ + abstract public function Get_URLLiveStream($size=IPSCOMPONENTCAM_SIZE_MIDDLE); + + /** + * @public + * + * Liefert URL des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return string URL des Bildes + */ + abstract public function Get_URLPicture($size=IPSCOMPONENTCAM_SIZE_MIDDLE); + + /** + * @public + * + * Bewegen der Kamera + * + * @param integer $urlType Type der URL die geliefert werden soll. + * mögliche Werte: IPSCOMPONENTCAM_URL_MOVEHOME + IPSCOMPONENTCAM_URL_MOVELEFT + IPSCOMPONENTCAM_URL_MOVERIGHT + IPSCOMPONENTCAM_URL_MOVEUP + IPSCOMPONENTCAM_URL_MOVEDOWN + IPSCOMPONENTCAM_URL_PREDEFPOS1 + IPSCOMPONENTCAM_URL_PREDEFPOS2 + IPSCOMPONENTCAM_URL_PREDEFPOS3 + IPSCOMPONENTCAM_URL_PREDEFPOS4 + IPSCOMPONENTCAM_URL_PREDEFPOS5 + */ + abstract public function Get_URL($urlType); + + + /** + * @public + * + * Liefert Breite des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return integer Breite des Bildes in Pixel + */ + abstract public function Get_Width($size=IPSCOMPONENTCAM_SIZE_MIDDLE); + + /** + * @public + * + * Liefert Höhe des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return integer Höhe des Bildes in Pixel + */ + abstract public function Get_Height($size=IPSCOMPONENTCAM_SIZE_MIDDLE); + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Abus.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Abus.class.php new file mode 100644 index 0000000..27368cf --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Abus.class.php @@ -0,0 +1,235 @@ + + */ + + IPSUtils_Include ('IPSComponentCam.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentCam'); + + class IPSComponentCam_Abus extends IPSComponentCam { + + private $ipAddress; + private $username; + private $password; + + /** + * @public + * + * Initialisierung eines IPSComponentCam_Abus Objektes + * + * @param string $ipAddress IP Adresse der Kamera + * @param string $username Username für Kamera Zugriff + * @param string $password Passwort für Kamera Zugriff + */ + public function __construct($ipAddress, $username, $password) { + $this->ipAddress = $ipAddress; + $this->username = $username; + $this->password = $password; + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleCam $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleCam $module) { + $name = IPS_GetName($variable); + throw new IPSComponentException('Event Handling NOT supported for Variable '.$variable.'('.$name.')'); + } + + /** + * @public + * + * Liefert URL des Kamera Live Streams + * + * @param integer $size Größe des Streams, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return string URL des Streams + */ + public function Get_URLLiveStream($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + $url = 'http://'.$this->username.':'.$this->password.'@'.$this->ipAddress.'/video.mjpg.cgi'; + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $url .= ''; // Not supported + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $url .= ''; // Not supported + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $url .= ''; // Not supported + break; + default: + trigger_error('Unknown Size '.$size); + } + return $url; + } + + /** + * @public + * + * Liefert URL des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return string URL des Bildes + */ + public function Get_URLPicture($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + $url = 'http://'.$this->username.':'.$this->password.'@'.$this->ipAddress.'/image.jpg'; + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $url .= ''; // Not supported + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $url .= ''; // Not supported + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $url .= ''; // Not supported + break; + default: + trigger_error('Unknown Size '.$size); + } + return $url; + } + + /** + * @public + * + * Bewegen der Kamera + * + * @param integer $urlType Type der URL die geliefert werden soll. + * mögliche Werte: IPSCOMPONENTCAM_URL_MOVEHOME + IPSCOMPONENTCAM_URL_MOVELEFT + IPSCOMPONENTCAM_URL_MOVERIGHT + IPSCOMPONENTCAM_URL_MOVEUP + IPSCOMPONENTCAM_URL_MOVEDOWN + IPSCOMPONENTCAM_URL_PREDEFPOS1 + IPSCOMPONENTCAM_URL_PREDEFPOS2 + IPSCOMPONENTCAM_URL_PREDEFPOS3 + IPSCOMPONENTCAM_URL_PREDEFPOS4 + IPSCOMPONENTCAM_URL_PREDEFPOS5 + */ + public function Get_URL($urlType) { + $url = ''; + switch ($urlType) { + case IPSCOMPONENTCAM_URL_MOVELEFT: + case IPSCOMPONENTCAM_URL_MOVERIGHT: + case IPSCOMPONENTCAM_URL_MOVEUP: + case IPSCOMPONENTCAM_URL_MOVEDOWN: + case IPSCOMPONENTCAM_URL_MOVEHOME: + case IPSCOMPONENTCAM_URL_PREDEFPOS1: + case IPSCOMPONENTCAM_URL_PREDEFPOS2: + case IPSCOMPONENTCAM_URL_PREDEFPOS3: + case IPSCOMPONENTCAM_URL_PREDEFPOS4: + case IPSCOMPONENTCAM_URL_PREDEFPOS5: + $url = $url.''; // Not supported + break; + default: + trigger_error('Diese Funktion ist für eine Abus Kamera noch NICHT implementiert !!!'); + } + return $url; + } + + /** + * @public + * + * Liefert Breite des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return integer Breite des Bildes in Pixel + */ + public function Get_Width($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $return = 320; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $return = 640; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $return = 1024; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $return; + } + + /** + * @public + * + * Liefert Höhe des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return integer Höhe des Bildes in Pixel + */ + public function Get_Height($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $return = 240; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $return = 480; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $return = 768; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $return; + } + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Allnet.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Allnet.class.php new file mode 100644 index 0000000..234bb76 --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Allnet.class.php @@ -0,0 +1,245 @@ + + */ + + IPSUtils_Include ('IPSComponentCam.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentCam'); + + class IPSComponentCam_Allnet extends IPSComponentCam { + + private $ipAddress; + private $username; + private $password; + + /** + * @public + * + * Initialisierung eines IPSComponentCam_Allnet Objektes + * + * @param string $ipAddress IP Adresse der Kamera + * @param string $username Username für Kamera Zugriff + * @param string $password Passwort für Kamera Zugriff + */ + public function __construct($ipAddress, $username, $password) { + $this->ipAddress = $ipAddress; + $this->username = $username; + $this->password = $password; + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleCam $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleCam $module) { + $name = IPS_GetName($variable); + throw new IPSComponentException('Event Handling NOT supported for Variable '.$variable.'('.$name.')'); + } + + /** + * @public + * + * Liefert URL des Kamera Live Streams + * + * @param integer $size Größe des Streams, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return string URL des Streams + */ + public function Get_URLLiveStream($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + $url = 'http://'.$this->username.':'.$this->password.'@'.$this->ipAddress.'/cgi/mjpg/mjpg.cgi'; + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $url .= ''; // Not supported + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $url .= ''; // Not supported + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $url .= ''; // Not supported + break; + default: + trigger_error('Unknown Size '.$size); + } + return $url; + } + + /** + * @public + * + * Liefert URL des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return string URL des Bildes + */ + public function Get_URLPicture($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + $url = 'http://'.$this->username.':'.$this->password.'@'.$this->ipAddress.'/cgi/jpg/image.cgi'; + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $url .= ''; // Not supported + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $url .= ''; // Not supported + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $url .= ''; // Not supported + break; + default: + trigger_error('Unknown Size '.$size); + } + return $url; + } + + /** + * @public + * + * Bewegen der Kamera + * + * @param integer $urlType Type der URL die geliefert werden soll. + * mögliche Werte: IPSCOMPONENTCAM_URL_MOVEHOME + IPSCOMPONENTCAM_URL_MOVELEFT + IPSCOMPONENTCAM_URL_MOVERIGHT + IPSCOMPONENTCAM_URL_MOVEUP + IPSCOMPONENTCAM_URL_MOVEDOWN + IPSCOMPONENTCAM_URL_PREDEFPOS1 + IPSCOMPONENTCAM_URL_PREDEFPOS2 + IPSCOMPONENTCAM_URL_PREDEFPOS3 + IPSCOMPONENTCAM_URL_PREDEFPOS4 + IPSCOMPONENTCAM_URL_PREDEFPOS5 + */ + public function Get_URL($urlType) { + $url = 'http://'.$this->username.':'.$this->password.'@'.$this->ipAddress.'/admin/ptctl.cgi?move=p1-p8?'; + switch ($urlType) { + case IPSCOMPONENTCAM_URL_MOVELEFT: + case IPSCOMPONENTCAM_URL_MOVERIGHT: + case IPSCOMPONENTCAM_URL_MOVEUP: + case IPSCOMPONENTCAM_URL_MOVEDOWN: + case IPSCOMPONENTCAM_URL_MOVEHOME: + $url = $url.''; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS1: + $url = $url.'move=p1'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS2: + $url = $url.'move=p2'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS3: + $url = $url.'move=p3'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS4: + $url = $url.'move=p4'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS5: + $url = $url.'move=p5'; + break; + default: + trigger_error('Diese Funktion ist für eine Allnet Kamera noch NICHT implementiert !!!'); + } + return $url; + } + + /** + * @public + * + * Liefert Breite des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return integer Breite des Bildes in Pixel + */ + public function Get_Width($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $return = 320; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $return = 640; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $return = 1024; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $return; + } + + /** + * @public + * + * Liefert Höhe des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return integer Höhe des Bildes in Pixel + */ + public function Get_Height($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $return = 240; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $return = 480; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $return = 768; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $return; + } + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Android.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Android.class.php new file mode 100644 index 0000000..0a0413b --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Android.class.php @@ -0,0 +1,238 @@ + + */ + + IPSUtils_Include ('IPSComponentCam.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentCam'); + + class IPSComponentCam_Android extends IPSComponentCam { + + private $ipAddress; + private $username; + private $password; + private $port; + + /** + * @public + * + * Initialisierung eines IPSComponentCam_Android Objektes + * + * @param string $ipAddress IP Adresse der Kamera + * @param string $username Username für Kamera Zugriff + * @param string $password Passwort für Kamera Zugriff + * @param string $port Port für Kamera Zugriff + */ + public function __construct($ipAddress, $username, $password, $port) { + $this->ipAddress = $ipAddress; + $this->username = $username; + $this->password = $password; + $this->port = $port; + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleCam $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleCam $module) { + $name = IPS_GetName($variable); + throw new IPSComponentException('Event Handling NOT supported for Variable '.$variable.'('.$name.')'); + } + + /** + * @public + * + * Liefert URL des Kamera Live Streams + * + * @param integer $size Größe des Streams, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return string URL des Streams + */ + public function Get_URLLiveStream($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + $url = 'http://'.$this->username.':'.$this->password.'@'.$this->ipAddress.':'.$this->port.'/videofeed'; + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $url .= ''; // Not supported + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $url .= ''; // Not supported + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $url .= ''; // Not supported + break; + default: + trigger_error('Unknown Size '.$size); + } + return $url; + } + + /** + * @public + * + * Liefert URL des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return string URL des Bildes + */ + public function Get_URLPicture($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + $url = 'http://'.$this->username.':'.$this->password.'@'.$this->ipAddress.':'.$this->port.'/photoaf.jpg'; + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $url .= ''; // Not supported + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $url .= ''; // Not supported + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $url .= ''; // Not supported + break; + default: + trigger_error('Unknown Size '.$size); + } + return $url; + } + + /** + * @public + * + * Bewegen der Kamera + * + * @param integer $urlType Type der URL die geliefert werden soll. + * mögliche Werte: IPSCOMPONENTCAM_URL_MOVEHOME + IPSCOMPONENTCAM_URL_MOVELEFT + IPSCOMPONENTCAM_URL_MOVERIGHT + IPSCOMPONENTCAM_URL_MOVEUP + IPSCOMPONENTCAM_URL_MOVEDOWN + IPSCOMPONENTCAM_URL_PREDEFPOS1 + IPSCOMPONENTCAM_URL_PREDEFPOS2 + IPSCOMPONENTCAM_URL_PREDEFPOS3 + IPSCOMPONENTCAM_URL_PREDEFPOS4 + IPSCOMPONENTCAM_URL_PREDEFPOS5 + */ + public function Get_URL($urlType) { + $url = ''; + switch ($urlType) { + case IPSCOMPONENTCAM_URL_MOVELEFT: + case IPSCOMPONENTCAM_URL_MOVERIGHT: + case IPSCOMPONENTCAM_URL_MOVEUP: + case IPSCOMPONENTCAM_URL_MOVEDOWN: + case IPSCOMPONENTCAM_URL_MOVEHOME: + case IPSCOMPONENTCAM_URL_PREDEFPOS1: + case IPSCOMPONENTCAM_URL_PREDEFPOS2: + case IPSCOMPONENTCAM_URL_PREDEFPOS3: + case IPSCOMPONENTCAM_URL_PREDEFPOS4: + case IPSCOMPONENTCAM_URL_PREDEFPOS5: + $url = $url.''; // Not supported + break; + default: + trigger_error('Diese Funktion ist für eine Abus Kamera noch NICHT implementiert !!!'); + } + return $url; + } + + /** + * @public + * + * Liefert Breite des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return integer Breite des Bildes in Pixel + */ + public function Get_Width($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $return = 320; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $return = 640; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $return = 1024; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $return; + } + + /** + * @public + * + * Liefert Höhe des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return integer Höhe des Bildes in Pixel + */ + public function Get_Height($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $return = 240; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $return = 480; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $return = 768; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $return; + } + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Axis.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Axis.class.php new file mode 100644 index 0000000..11e49a1 --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Axis.class.php @@ -0,0 +1,218 @@ + + */ + + IPSUtils_Include ('IPSComponentCam.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentCam'); + + class IPSComponentCam_Axis extends IPSComponentCam { + + private $ipAddress; + private $username; + private $password; + + /** + * @public + * + * Initialisierung eines IPSComponentCam_Axis Objektes + * + * @param string $ipAddress IP Adresse der Kamera + * @param string $username Username für Kamera Zugriff + * @param string $password Passwort für Kamera Zugriff + */ + public function __construct($ipAddress, $username, $password) { + $this->ipAddress = $ipAddress; + $this->username = $username; + $this->password = $password; + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleCam $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleCam $module) { + $name = IPS_GetName($variable); + throw new IPSComponentException('Event Handling NOT supported for Variable '.$variable.'('.$name.')'); + } + + /** + * @public + * + * Liefert URL des Kamera Live Streams + * + * @param integer $size Größe des Streams, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return string URL des Streams + */ + public function Get_URLLiveStream($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + $url = 'http://'.$this->username.':'.$this->password.'@'.$this->ipAddress.'/axis-cgi/mjpg/video.cgi'; + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $url .= '?resolution=320x240'; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $url .= '?resolution=640x480'; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $url .= '?resolution=640x480'; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $url; + } + + /** + * @public + * + * Liefert URL des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return string URL des Bildes + */ + public function Get_URLPicture($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + $url = 'http://'.$this->username.':'.$this->password.'@'.$this->ipAddress.'/jpg/1/image.jpg'; + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $url .= '?resolution=320x240'; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $url .= '?resolution=640x480'; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $url .= '?resolution=640x480'; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $url; + } + + /** + * @public + * + * Bewegen der Kamera + * + * @param integer $urlType Type der URL die geliefert werden soll. + * mögliche Werte: IPSCOMPONENTCAM_URL_MOVEHOME + IPSCOMPONENTCAM_URL_MOVELEFT + IPSCOMPONENTCAM_URL_MOVERIGHT + IPSCOMPONENTCAM_URL_MOVEUP + IPSCOMPONENTCAM_URL_MOVEDOWN + IPSCOMPONENTCAM_URL_PREDEFPOS1 + IPSCOMPONENTCAM_URL_PREDEFPOS2 + IPSCOMPONENTCAM_URL_PREDEFPOS3 + IPSCOMPONENTCAM_URL_PREDEFPOS4 + IPSCOMPONENTCAM_URL_PREDEFPOS5 + */ + public function Get_URL($urlType) { + trigger_error('Diese Funktion ist für eine Axis Kamera noch NICHT implementiert !!!'); + } + + /** + * @public + * + * Liefert Breite des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return integer Breite des Bildes in Pixel + */ + public function Get_Width($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $return = 320; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $return = 640; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $return = 1024; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $return; + } + + /** + * @public + * + * Liefert Höhe des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return integer Höhe des Bildes in Pixel + */ + public function Get_Height($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $return = 240; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $return = 480; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $return = 768; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $return; + } + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_AxisM7001.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_AxisM7001.class.php new file mode 100644 index 0000000..061e797 --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_AxisM7001.class.php @@ -0,0 +1,219 @@ + + */ + + IPSUtils_Include ('IPSComponentCam.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentCam'); + + class IPSComponentCam_AxisM7001 extends IPSComponentCam { + + private $ipAddress; + private $username; + private $password; + + /** + * @public + * + * Initialisierung eines IPSComponentCam_AxisM7001 Objektes + * + * @param string $ipAddress IP Adresse der Kamera + * @param string $username Username für Kamera Zugriff + * @param string $password Passwort für Kamera Zugriff + */ + public function __construct($ipAddress, $username, $password) { + $this->ipAddress = $ipAddress; + $this->username = $username; + $this->password = $password; + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleCam $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleCam $module) { + $name = IPS_GetName($variable); + throw new IPSComponentException('Event Handling NOT supported for Variable '.$variable.'('.$name.')'); + } + + /** + * @public + * + * Liefert URL des Kamera Live Streams + * + * @param integer $size Größe des Streams, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return string URL des Streams + */ + public function Get_URLLiveStream($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + $url = 'http://'.$this->username.':'.$this->password.'@'.$this->ipAddress.'/axis-cgi/mjpg/video.cgi'; + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $url .= '?resolution=CIF'; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $url .= '?resolution=4CIF'; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $url .= '?resolution=D1'; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $url; + } + + /** + * @public + * + * Liefert URL des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return string URL des Bildes + */ +//http://video-m7001.narwald-home.de/axis-cgi/jpg/image.cgi?resolution=D1&clock=0&date=0&text=0&nocache=1370185453237&camera=1 + public function Get_URLPicture($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + $url = 'http://'.$this->username.':'.$this->password.'@'.$this->ipAddress.'/axis-cgi/jpg/image.cgi'; + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $url .= '?resolution=176x144'; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $url .= '?resolution=352x288'; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $url .= '?resolution=720x576'; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $url; + } + + /** + * @public + * + * Bewegen der Kamera + * + * @param integer $urlType Type der URL die geliefert werden soll. + * mögliche Werte: IPSCOMPONENTCAM_URL_MOVEHOME + IPSCOMPONENTCAM_URL_MOVELEFT + IPSCOMPONENTCAM_URL_MOVERIGHT + IPSCOMPONENTCAM_URL_MOVEUP + IPSCOMPONENTCAM_URL_MOVEDOWN + IPSCOMPONENTCAM_URL_PREDEFPOS1 + IPSCOMPONENTCAM_URL_PREDEFPOS2 + IPSCOMPONENTCAM_URL_PREDEFPOS3 + IPSCOMPONENTCAM_URL_PREDEFPOS4 + IPSCOMPONENTCAM_URL_PREDEFPOS5 + */ + public function Get_URL($urlType) { + trigger_error('Diese Funktion ist für eine Axis Kamera noch NICHT implementiert !!!'); + } + + /** + * @public + * + * Liefert Breite des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return integer Breite des Bildes in Pixel + */ + public function Get_Width($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $return = 320; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $return = 640; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $return = 1024; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $return; + } + + /** + * @public + * + * Liefert Höhe des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return integer Höhe des Bildes in Pixel + */ + public function Get_Height($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $return = 240; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $return = 480; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $return = 768; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $return; + } + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Cisco.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Cisco.class.php new file mode 100644 index 0000000..2e8828a --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Cisco.class.php @@ -0,0 +1,222 @@ + + */ + + IPSUtils_Include ('IPSComponentCam.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentCam'); + + class IPSComponentCam_Cisco extends IPSComponentCam { + + private $ipAddress; + private $username; + private $password; + + /** + * @public + * + * Initialisierung eines IPSComponentCam_Cisco Objektes + * + * @param string $ipAddress IP Adresse der Kamera + * @param string $username Username für Kamera Zugriff + * @param string $password Passwort für Kamera Zugriff + */ + public function __construct($ipAddress, $username, $password) { + $this->ipAddress = $ipAddress; + $this->username = $username; + $this->password = $password; + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleCam $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleCam $module) { + $name = IPS_GetName($variable); + throw new IPSComponentException('Event Handling NOT supported for Variable '.$variable.'('.$name.')'); + } + + /** + * @public + * + * Liefert URL des Kamera Live Streams + * + * @param integer $size Größe des Streams, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return string URL des Streams + */ + public function Get_URLLiveStream($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + $url = 'http://'.$this->username.':'.$this->password.'@'.$this->ipAddress.'/img/mjpeg.cgi'; + + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $url .= '?size=1&framerate=30'; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $url .= '?size=2&framerate=30'; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $url .= '?size=3&framerate=30'; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $url; + } + + /** + * @public + * + * Liefert URL des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return string URL des Bildes + */ + public function Get_URLPicture($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + $url = 'http://'.$this->username.':'.$this->password.'@'.$this->ipAddress.'/img/snapshot.cgi'; + + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $url .= '?size=1&quality=3'; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $url .= '?size=2&quality=3'; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $url .= '?size=3&quality=3'; + break; + default: + trigger_error('Unknown Size '.$size); + } + + return $url; + } + + /** + * @public + * + * Bewegen der Kamera + * + * @param integer $urlType Type der URL die geliefert werden soll. + * mögliche Werte: IPSCOMPONENTCAM_URL_MOVEHOME + IPSCOMPONENTCAM_URL_MOVELEFT + IPSCOMPONENTCAM_URL_MOVERIGHT + IPSCOMPONENTCAM_URL_MOVEUP + IPSCOMPONENTCAM_URL_MOVEDOWN + IPSCOMPONENTCAM_URL_PREDEFPOS1 + IPSCOMPONENTCAM_URL_PREDEFPOS2 + IPSCOMPONENTCAM_URL_PREDEFPOS3 + IPSCOMPONENTCAM_URL_PREDEFPOS4 + IPSCOMPONENTCAM_URL_PREDEFPOS5 + */ + public function Get_URL($urlType) { + trigger_error('Diese Funktion ist für eine Cisco Kamera noch NICHT implementiert !!!'); + } + + /** + * @public + * + * Liefert Breite des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return integer Breite des Bildes in Pixel + */ + public function Get_Width($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $return = 160; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $return = 320; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $return = 640; + break; + + default: + trigger_error('Unknown Size '.$size); + } + return $return; + } + + /** + * @public + * + * Liefert Höhe des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return integer Höhe des Bildes in Pixel + */ + public function Get_Height($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $return = 120; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $return = 240; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $return = 480; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $return; + } + } + + /** @}*/ +?> diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_DLink.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_DLink.class.php new file mode 100644 index 0000000..b79e395 --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_DLink.class.php @@ -0,0 +1,235 @@ + + */ + + IPSUtils_Include ('IPSComponentCam.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentCam'); + + class IPSComponentCam_DLink extends IPSComponentCam { + + private $ipAddress; + private $username; + private $password; + + /** + * @public + * + * Initialisierung eines IPSComponentCam_DLink Objektes + * + * @param string $ipAddress IP Adresse der Kamera + * @param string $username Username für Kamera Zugriff + * @param string $password Passwort für Kamera Zugriff + */ + public function __construct($ipAddress, $username, $password) { + $this->ipAddress = $ipAddress; + $this->username = $username; + $this->password = $password; + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleCam $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleCam $module) { + $name = IPS_GetName($variable); + throw new IPSComponentException('Event Handling NOT supported for Variable '.$variable.'('.$name.')'); + } + + /** + * @public + * + * Liefert URL des Kamera Live Streams + * + * @param integer $size Größe des Streams, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return string URL des Streams + */ + public function Get_URLLiveStream($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + $url = 'http://'.$this->username.':'.$this->password.'@'.$this->ipAddress.'/MJPEG.cgi'; + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $url .= ''; // Not supported + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $url .= ''; // Not supported + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $url .= ''; // Not supported + break; + default: + trigger_error('Unknown Size '.$size); + } + return $url; + } + + /** + * @public + * + * Liefert URL des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return string URL des Bildes + */ + public function Get_URLPicture($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + $url = 'http://'.$this->username.':'.$this->password.'@'.$this->ipAddress.'/image.jpg'; + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $url .= ''; // Not supported + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $url .= ''; // Not supported + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $url .= ''; // Not supported + break; + default: + trigger_error('Unknown Size '.$size); + } + return $url; + } + + /** + * @public + * + * Bewegen der Kamera + * + * @param integer $urlType Type der URL die geliefert werden soll. + * mögliche Werte: IPSCOMPONENTCAM_URL_MOVEHOME + IPSCOMPONENTCAM_URL_MOVELEFT + IPSCOMPONENTCAM_URL_MOVERIGHT + IPSCOMPONENTCAM_URL_MOVEUP + IPSCOMPONENTCAM_URL_MOVEDOWN + IPSCOMPONENTCAM_URL_PREDEFPOS1 + IPSCOMPONENTCAM_URL_PREDEFPOS2 + IPSCOMPONENTCAM_URL_PREDEFPOS3 + IPSCOMPONENTCAM_URL_PREDEFPOS4 + IPSCOMPONENTCAM_URL_PREDEFPOS5 + */ + public function Get_URL($urlType) { + $url = ''; + switch ($urlType) { + case IPSCOMPONENTCAM_URL_MOVELEFT: + case IPSCOMPONENTCAM_URL_MOVERIGHT: + case IPSCOMPONENTCAM_URL_MOVEUP: + case IPSCOMPONENTCAM_URL_MOVEDOWN: + case IPSCOMPONENTCAM_URL_MOVEHOME: + case IPSCOMPONENTCAM_URL_PREDEFPOS1: + case IPSCOMPONENTCAM_URL_PREDEFPOS2: + case IPSCOMPONENTCAM_URL_PREDEFPOS3: + case IPSCOMPONENTCAM_URL_PREDEFPOS4: + case IPSCOMPONENTCAM_URL_PREDEFPOS5: + $url = $url.''; // Not supported + break; + default: + trigger_error('Diese Funktion ist für eine DLink Kamera noch NICHT implementiert !!!'); + } + return $url; + } + + /** + * @public + * + * Liefert Breite des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return integer Breite des Bildes in Pixel + */ + public function Get_Width($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $return = 320; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $return = 640; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $return = 1024; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $return; + } + + /** + * @public + * + * Liefert Höhe des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return integer Höhe des Bildes in Pixel + */ + public function Get_Height($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $return = 240; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $return = 480; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $return = 768; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $return; + } + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_DLink932.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_DLink932.class.php new file mode 100644 index 0000000..9960add --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_DLink932.class.php @@ -0,0 +1,235 @@ + + */ + + IPSUtils_Include ('IPSComponentCam.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentCam'); + + class IPSComponentCam_DLink932 extends IPSComponentCam { + + private $ipAddress; + private $username; + private $password; + + /** + * @public + * + * Initialisierung eines IPSComponentCam_DLink932 Objektes + * + * @param string $ipAddress IP Adresse der Kamera + * @param string $username Username für Kamera Zugriff + * @param string $password Passwort für Kamera Zugriff + */ + public function __construct($ipAddress, $username, $password) { + $this->ipAddress = $ipAddress; + $this->username = $username; + $this->password = $password; + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleCam $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleCam $module) { + $name = IPS_GetName($variable); + throw new IPSComponentException('Event Handling NOT supported for Variable '.$variable.'('.$name.')'); + } + + /** + * @public + * + * Liefert URL des Kamera Live Streams + * + * @param integer $size Größe des Streams, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return string URL des Streams + */ + public function Get_URLLiveStream($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + $url = 'http://'.$this->ipAddress.'/MJPEG.cgi?user='.$this->username.'&password='.$this->password; + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $url .= ''; // Not supported + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $url .= ''; // Not supported + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $url .= ''; // Not supported + break; + default: + trigger_error('Unknown Size '.$size); + } + return $url; + } + + /** + * @public + * + * Liefert URL des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return string URL des Bildes + */ + public function Get_URLPicture($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + $url = 'http://'.$this->ipAddress.'/image/jpeg.cgi?user='.$this->username.'&password='.$this->password; + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $url .= ''; // Not supported + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $url .= ''; // Not supported + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $url .= ''; // Not supported + break; + default: + trigger_error('Unknown Size '.$size); + } + return $url; + } + + /** + * @public + * + * Bewegen der Kamera + * + * @param integer $urlType Type der URL die geliefert werden soll. + * mögliche Werte: IPSCOMPONENTCAM_URL_MOVEHOME + IPSCOMPONENTCAM_URL_MOVELEFT + IPSCOMPONENTCAM_URL_MOVERIGHT + IPSCOMPONENTCAM_URL_MOVEUP + IPSCOMPONENTCAM_URL_MOVEDOWN + IPSCOMPONENTCAM_URL_PREDEFPOS1 + IPSCOMPONENTCAM_URL_PREDEFPOS2 + IPSCOMPONENTCAM_URL_PREDEFPOS3 + IPSCOMPONENTCAM_URL_PREDEFPOS4 + IPSCOMPONENTCAM_URL_PREDEFPOS5 + */ + public function Get_URL($urlType) { + $url = ''; + switch ($urlType) { + case IPSCOMPONENTCAM_URL_MOVELEFT: + case IPSCOMPONENTCAM_URL_MOVERIGHT: + case IPSCOMPONENTCAM_URL_MOVEUP: + case IPSCOMPONENTCAM_URL_MOVEDOWN: + case IPSCOMPONENTCAM_URL_MOVEHOME: + case IPSCOMPONENTCAM_URL_PREDEFPOS1: + case IPSCOMPONENTCAM_URL_PREDEFPOS2: + case IPSCOMPONENTCAM_URL_PREDEFPOS3: + case IPSCOMPONENTCAM_URL_PREDEFPOS4: + case IPSCOMPONENTCAM_URL_PREDEFPOS5: + $url = $url.''; // Not supported + break; + default: + trigger_error('Diese Funktion ist für eine DLink932 Kamera noch NICHT implementiert !!!'); + } + return $url; + } + + /** + * @public + * + * Liefert Breite des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return integer Breite des Bildes in Pixel + */ + public function Get_Width($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $return = 320; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $return = 640; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $return = 1024; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $return; + } + + /** + * @public + * + * Liefert Höhe des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return integer Höhe des Bildes in Pixel + */ + public function Get_Height($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $return = 240; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $return = 480; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $return = 768; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $return; + } + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Edimax.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Edimax.class.php new file mode 100644 index 0000000..31156fa --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Edimax.class.php @@ -0,0 +1,253 @@ + + */ + + IPSUtils_Include ('IPSComponentCam.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentCam'); + + class IPSComponentCam_Edimax extends IPSComponentCam { + + private $ipAddress; + private $username; + private $password; + + /** + * @public + * + * Initialisierung eines IPSComponentCam_Edimax Objektes + * + * @param string $ipAddress IP Adresse der Kamera + * @param string $username Username für Kamera Zugriff + * @param string $password Passwort für Kamera Zugriff + */ + public function __construct($ipAddress, $username, $password) { + $this->ipAddress = $ipAddress; + $this->username = $username; + $this->password = $password; + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleCam $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleCam $module) { + $name = IPS_GetName($variable); + throw new IPSComponentException('Event Handling NOT supported for Variable '.$variable.'('.$name.')'); + } + + /** + * @public + * + * Liefert URL des Kamera Live Streams + * + * @param integer $size Größe des Streams, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return string URL des Streams + */ + public function Get_URLLiveStream($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + $url = 'http://'.$this->username.':'.$this->password.'@'.$this->ipAddress.'/snapshot.cgi'; + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $url .= '?resolution=320x240'; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $url .= '?resolution=640x480'; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $url .= '?resolution=1024x768'; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $url; + } + + /** + * @public + * + * Liefert URL des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return string URL des Bildes + */ + public function Get_URLPicture($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + $url = 'http://'.$this->username.':'.$this->password.'@'.$this->ipAddress.'/snapshot.jpg'; + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $url .= '?resolution=320x240'; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $url .= '?resolution=640x480'; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $url .= '?resolution=1024x768'; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $url; + } + + /** + * @public + * + * Bewegen der Kamera + * + * @param integer $urlType Type der URL die geliefert werden soll. + * mögliche Werte: IPSCOMPONENTCAM_URL_MOVEHOME + IPSCOMPONENTCAM_URL_MOVELEFT + IPSCOMPONENTCAM_URL_MOVERIGHT + IPSCOMPONENTCAM_URL_MOVEUP + IPSCOMPONENTCAM_URL_MOVEDOWN + IPSCOMPONENTCAM_URL_PREDEFPOS1 + IPSCOMPONENTCAM_URL_PREDEFPOS2 + IPSCOMPONENTCAM_URL_PREDEFPOS3 + IPSCOMPONENTCAM_URL_PREDEFPOS4 + IPSCOMPONENTCAM_URL_PREDEFPOS5 + */ + public function Get_URL($urlType) { + $url = 'http://'.$this->username.':'.$this->password.'@'.$this->ipAddress.'/camera-cgi/com/ptz.cgi?'; + switch ($urlType) { + case IPSCOMPONENTCAM_URL_MOVELEFT: + $url = $url.'move=left'; + break; + case IPSCOMPONENTCAM_URL_MOVERIGHT: + $url = $url.'move=right'; + break; + case IPSCOMPONENTCAM_URL_MOVEUP: + $url = $url.'move=up'; + break; + case IPSCOMPONENTCAM_URL_MOVEDOWN: + $url = $url.'move=down'; + break; + case IPSCOMPONENTCAM_URL_MOVEHOME: + $url = $url.'move=center'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS1: + $url = $url.'gotoserverpresetIndex=0'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS2: + $url = $url.'gotoserverpresetIndex=1'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS3: + $url = $url.'gotoserverpresetIndex=2'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS4: + $url = $url.'gotoserverpresetIndex=3'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS5: + $url = $url.'gotoserverpresetIndex=4'; + break; + default: + trigger_error('Diese Funktion ist für eine Edimax Kamera noch NICHT implementiert !!!'); + } + return $url; + } + + /** + * @public + * + * Liefert Breite des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return integer Breite des Bildes in Pixel + */ + public function Get_Width($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $return = 320; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $return = 640; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $return = 1024; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $return; + } + + /** + * @public + * + * Liefert Höhe des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return integer Höhe des Bildes in Pixel + */ + public function Get_Height($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $return = 240; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $return = 480; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $return = 768; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $return; + } + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Foscam.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Foscam.class.php new file mode 100644 index 0000000..0a55e33 --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Foscam.class.php @@ -0,0 +1,261 @@ + + */ + + IPSUtils_Include ('IPSComponentCam.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentCam'); + + class IPSComponentCam_Foscam extends IPSComponentCam { + + private $ipAddress; + private $username; + private $password; + + /** + * @public + * + * Initialisierung eines IPSComponentCam_Foscam Objektes + * + * @param string $ipAddress IP Adresse der Kamera + * @param string $username Username für Kamera Zugriff + * @param string $password Passwort für Kamera Zugriff + */ + public function __construct($ipAddress, $username, $password) { + $this->ipAddress = $ipAddress; + $this->username = $username; + $this->password = $password; + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleCam $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleCam $module) { + $name = IPS_GetName($variable); + throw new IPSComponentException('Event Handling NOT supported for Variable '.$variable.'('.$name.')'); + } + + /** + * @public + * + * Liefert URL des Kamera Live Streams + * + * @param integer $size Größe des Streams, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return string URL des Streams + */ + public function Get_URLLiveStream($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + $url = 'http://'.$this->ipAddress.'/cgi-bin/CGIStream.cgi?cmd=GetMJStream&usr='.$this->username.'&pwd='.$this->password; + + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $url .= '&resolution=0'; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $url .= '&resolution=0'; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $url .= '&resolution=0'; + break; + + default: + trigger_error('Unknown Size '.$size); + } + return $url; + } + + /** + * @public + * + * Liefert URL des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return string URL des Bildes + */ + public function Get_URLPicture($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + + $url = 'http://'.$this->ipAddress.'/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr='.$this->username.'&pwd='.$this->password; + /* + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $url .= '?resolution=320x240'; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $url .= '?resolution=640x480'; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $url .= '?resolution=640x480'; + break; + default: + trigger_error('Unknown Size '.$size); + } + */ + IPS_LogMessage ("...",$url); + return $url; + } + + /** + * @public + * + * Bewegen der Kamera + * + * @param integer $urlType Type der URL die geliefert werden soll. + * mögliche Werte: IPSCOMPONENTCAM_URL_MOVEHOME + IPSCOMPONENTCAM_URL_MOVELEFT + IPSCOMPONENTCAM_URL_MOVERIGHT + IPSCOMPONENTCAM_URL_MOVEUP + IPSCOMPONENTCAM_URL_MOVEDOWN + IPSCOMPONENTCAM_URL_PREDEFPOS1 + IPSCOMPONENTCAM_URL_PREDEFPOS2 + IPSCOMPONENTCAM_URL_PREDEFPOS3 + IPSCOMPONENTCAM_URL_PREDEFPOS4 + IPSCOMPONENTCAM_URL_PREDEFPOS5 + */ + public function Get_URL($urlType) { + $url = 'http://'.$this->ipAddress.'/cgi-bin/CGIProxy.fcgi?'; + + + switch ($urlType) { + case IPSCOMPONENTCAM_URL_MOVELEFT: + $url = 'cmd=ptzMoveLeft'; + break; + case IPSCOMPONENTCAM_URL_MOVERIGHT: + $url = 'cmd=ptzMoveRight'; + break; + case IPSCOMPONENTCAM_URL_MOVEUP: + $url = 'cmd=ptzMoveUp'; + break; + case IPSCOMPONENTCAM_URL_MOVEDOWN: + $url = 'cmd=ptzMoveDown'; + break; + case IPSCOMPONENTCAM_URL_STOP: + $url = 'cmd=ptzStopRun'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS1: + $url = 'cmd=ptzGotoPresetPoint'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS2: + $url = 'cmd=ptzGotoPresetPoint'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS3: + $url = 'cmd=ptzGotoPresetPoint'; + + + default: + trigger_error('Diese Funktion ist für eine Foscam Kamera noch NICHT implementiert !!!'); + } + + $url = $url. '&user='.$this->username.'&pwd='.$this->password ; + IPS_LogMessage ("...",$url); + return $url; + + } + + /** + * @public + * + * Liefert Breite des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return integer Breite des Bildes in Pixel + */ + public function Get_Width($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $return = 320; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $return = 320; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $return = 640; + break; + + default: + trigger_error('Unknown Size '.$size); + } + return $return; + } + + /** + * @public + * + * Liefert Höhe des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return integer Höhe des Bildes in Pixel + */ + public function Get_Height($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $return = 240; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $return = 240; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $return = 480; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $return; + } + } + + /** @}*/ +?> diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Foscam89x.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Foscam89x.class.php new file mode 100644 index 0000000..4979660 --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Foscam89x.class.php @@ -0,0 +1,262 @@ + + */ + + IPSUtils_Include ('IPSComponentCam.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentCam'); + + class IPSComponentCam_Foscam89x extends IPSComponentCam { + + private $ipAddress; + private $username; + private $password; + + /** + * @public + * + * Initialisierung eines IPSComponentCam_Foscam89x Objektes + * + * @param string $ipAddress IP Adresse der Kamera + * @param string $username Username für Kamera Zugriff + * @param string $password Passwort für Kamera Zugriff + */ + public function __construct($ipAddress, $username, $password) { + $this->ipAddress = $ipAddress; + $this->username = $username; + $this->password = $password; + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleCam $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleCam $module) { + $name = IPS_GetName($variable); + throw new IPSComponentException('Event Handling NOT supported for Variable '.$variable.'('.$name.')'); + } + + /** + * @public + * + * Liefert URL des Kamera Live Streams + * + * @param integer $size Größe des Streams, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return string URL des Streams + */ + public function Get_URLLiveStream($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + $url = 'http://'.$this->ipAddress.'/videostream.cgi?user='.$this->username.'&pwd='.$this->password; + + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $url .= '&resolution=8&rate=0'; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $url .= '&resolution=8&rate=0'; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $url .= '&resolution=32&rate=0'; + break; + + default: + trigger_error('Unknown Size '.$size); + } + return $url; + } + + /** + * @public + * + * Liefert URL des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return string URL des Bildes + */ + public function Get_URLPicture($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + + $url = 'http://'.$this->ipAddress.'/snapshot.jpg?user='.$this->username.'&pwd='.$this->password; + + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $url .= '&resolution=8&rate=0'; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $url .= '&resolution=8&rate=0'; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $url .= '&resolution=32&rate=0'; + break; + + default: + trigger_error('Unknown Size '.$size); + } + return $url; + } + + /** + * @public + * + * Bewegen der Kamera + * + * @param integer $urlType Type der URL die geliefert werden soll. + * mögliche Werte: IPSCOMPONENTCAM_URL_MOVEHOME + IPSCOMPONENTCAM_URL_MOVELEFT + IPSCOMPONENTCAM_URL_MOVERIGHT + IPSCOMPONENTCAM_URL_MOVEUP + IPSCOMPONENTCAM_URL_MOVEDOWN + IPSCOMPONENTCAM_URL_PREDEFPOS1 + IPSCOMPONENTCAM_URL_PREDEFPOS2 + IPSCOMPONENTCAM_URL_PREDEFPOS3 + IPSCOMPONENTCAM_URL_PREDEFPOS4 + IPSCOMPONENTCAM_URL_PREDEFPOS5 + */ + public function Get_URL($urlType) { + $url = 'http://'.$this->ipAddress.'/decoder_control.cgi?user='.$this->username.'&pwd='.$this->password; + + switch ($urlType) { + case IPSCOMPONENTCAM_URL_MOVELEFT: + $url = $url.'command=4'; + break; + case IPSCOMPONENTCAM_URL_MOVERIGHT: + $url = $url.'command=6'; + break; + case IPSCOMPONENTCAM_URL_MOVEUP: + $url = $url.'command=0'; + break; + case IPSCOMPONENTCAM_URL_MOVEDOWN: + $url = $url.'command=2'; + break; + case IPSCOMPONENTCAM_URL_MOVEHOME: + $url = $url.'command=1'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS1: + $url = $url.'command=31'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS2: + $url = $url.'command=33'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS3: + $url = $url.'command=35'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS4: + $url = $url.'command=37'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS5: + $url = $url.'command=37'; + break; + default: + trigger_error('Diese Funktion ist für eine Foxcam Kamera noch NICHT implementiert !!!'); + } + + return $url; + + } + + /** + * @public + * + * Liefert Breite des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return integer Breite des Bildes in Pixel + */ + public function Get_Width($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $return = 320; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $return = 320; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $return = 640; + break; + + default: + trigger_error('Unknown Size '.$size); + } + return $return; + } + + /** + * @public + * + * Liefert Höhe des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return integer Höhe des Bildes in Pixel + */ + public function Get_Height($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $return = 240; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $return = 240; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $return = 480; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $return; + } + } + + /** @}*/ +?> diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Instar.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Instar.class.php new file mode 100644 index 0000000..d53c7d7 --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Instar.class.php @@ -0,0 +1,296 @@ + + */ + + IPSUtils_Include ('IPSComponentCam.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentCam'); + + class IPSComponentCam_Instar extends IPSComponentCam { + + private $ipAddress; + private $username; + private $password; + + /** + * @public + * + * Initialisierung eines IPSComponentCam_Instar Objektes + * + * @param string $ipAddress IP Adresse der Kamera + * @param string $username Username für Kamera Zugriff + * @param string $password Passwort für Kamera Zugriff + */ + public function __construct($ipAddress, $username, $password) { + $this->ipAddress = $ipAddress; + $this->username = $username; + $this->password = $password; + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleCam $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleCam $module) { + $name = IPS_GetName($variable); + throw new IPSComponentException('Event Handling NOT supported for Variable '.$variable.'('.$name.')'); + } + + /** + * @public + * + * Liefert URL des Kamera Live Streams + * + * @param integer $size Größe des Streams, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return string URL des Streams + */ + public function Get_URLLiveStream($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + $url = 'http://'.$this->ipAddress.'/videostream.cgi?user='.$this->username.'&pwd='.$this->password; + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $url .= '&resolution=8'; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $url .= '&resolution=8'; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $url .= '&resolution=32'; + break; + + default: + trigger_error('Unknown Size '.$size); + } IPS_LogMessage ("...",$url); + return $url; + } + + /** + * @public + * + * Liefert URL des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return string URL des Bildes + */ + public function Get_URLPicture($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + + $url = 'http://'.$this->ipAddress.'/snapshot.cgi?user='.$this->username.'&pwd='.$this->password.'&next_url=snapshot.jpg'; + /* + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $url .= '?resolution=320x240'; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $url .= '?resolution=640x480'; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $url .= '?resolution=640x480'; + break; + default: + trigger_error('Unknown Size '.$size); + } + */ + IPS_LogMessage ("...",$url); + return $url; + } + + /** + * @public + * + * Bewegen der Kamera + * + * @param integer $urlType Type der URL die geliefert werden soll. + * mögliche Werte: IPSCOMPONENTCAM_URL_MOVEHOME + IPSCOMPONENTCAM_URL_MOVELEFT + IPSCOMPONENTCAM_URL_MOVERIGHT + IPSCOMPONENTCAM_URL_MOVEUP + IPSCOMPONENTCAM_URL_MOVEDOWN + IPSCOMPONENTCAM_URL_PREDEFPOS1 + IPSCOMPONENTCAM_URL_PREDEFPOS2 + IPSCOMPONENTCAM_URL_PREDEFPOS3 + IPSCOMPONENTCAM_URL_PREDEFPOS4 + IPSCOMPONENTCAM_URL_PREDEFPOS5 + */ + public function Get_URL($urlType) { + $url = 'http://'.$this->ipAddress.'/decoder_control.cgi?'; + + + switch ($urlType) { + case IPSCOMPONENTCAM_URL_MOVELEFT: + $url = $url.'command=4&onestep=1'; + break; + case IPSCOMPONENTCAM_URL_MOVERIGHT: + $url = $url.'command=6&onestep=1'; + break; + case IPSCOMPONENTCAM_URL_MOVEUP: + $url = $url.'command=0&onestep=1'; + break; + case IPSCOMPONENTCAM_URL_MOVEDOWN: + $url = $url.'command=2&onestep=1'; + break; + case IPSCOMPONENTCAM_URL_MOVEHOME: + $url = $url.'command=25'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS1: + $url = $url.'command=31'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS2: + $url = $url.'command=33'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS3: + $url = $url.'command=35'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS4: + $url = $url.'command=37'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS5: + $url = $url.'command=39'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS6: + $url = $url.'command=41'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS7: + $url = $url.'command=43'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS8: + $url = $url.'command=45'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS9: + $url = $url.'command=47'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS10: + $url = $url.'command=49'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS11: + $url = $url.'command=51'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS12: + $url = $url.'command=53'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS13: + $url = $url.'command=55'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS14: + $url = $url.'command=57'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS15: + $url = $url.'command=59'; + break; + + default: + trigger_error('Diese Funktion ist für eine Instar Kamera noch NICHT implementiert !!!'); + } + + $url = $url. '&user='.$this->username.'&pwd='.$this->password ; + IPS_LogMessage ("...",$url); + return $url; + + } + + /** + * @public + * + * Liefert Breite des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return integer Breite des Bildes in Pixel + */ + public function Get_Width($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $return = 320; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $return = 320; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $return = 640; + break; + + default: + trigger_error('Unknown Size '.$size); + } + return $return; + } + + /** + * @public + * + * Liefert Höhe des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return integer Höhe des Bildes in Pixel + */ + public function Get_Height($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $return = 240; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $return = 240; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $return = 480; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $return; + } + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Mobotix.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Mobotix.class.php new file mode 100644 index 0000000..7e1ffc0 --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Mobotix.class.php @@ -0,0 +1,219 @@ + + */ + + IPSUtils_Include ('IPSComponentCam.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentCam'); + + class IPSComponentCam_Mobotix extends IPSComponentCam { + + private $ipAddress; + private $username; + private $password; + + /** + * @public + * + * Initialisierung eines IPSComponentCam_Mobotix Objektes + * + * @param string $ipAddress IP Adresse der Kamera + * @param string $username Username für Kamera Zugriff + * @param string $password Passwort für Kamera Zugriff + */ + public function __construct($ipAddress, $username, $password) { + $this->ipAddress = $ipAddress; + $this->username = $username; + $this->password = $password; + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleCam $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleCam $module) { + $name = IPS_GetName($variable); + throw new IPSComponentException('Event Handling NOT supported for Variable '.$variable.'('.$name.')'); + } + + /** + * @public + * + * Liefert URL des Kamera Live Streams + * + * @param integer $size Größe des Streams, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return string URL des Streams + */ + public function Get_URLLiveStream($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + $url = 'http://'.$this->username.':'.$this->password.'@'.$this->ipAddress.'/cgi-bin/faststream.jpg'; + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $url .= '?streamid=0'; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $url .= '?streamid=1'; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $url .= '?streamid=2'; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $url; + } + + /** + * @public + * + * Liefert URL des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return string URL des Bildes + */ + public function Get_URLPicture($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + $url = 'http://'.$this->username.':'.$this->password.'@'.$this->ipAddress.'/cgi-bin/image.jpg'; + + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $url .= '?streamid=0'; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $url .= '?streamid=1'; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $url .= '?streamid=2'; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $url; + } + + /** + * @public + * + * Bewegen der Kamera + * + * @param integer $urlType Type der URL die geliefert werden soll. + * mögliche Werte: IPSCOMPONENTCAM_URL_MOVEHOME + IPSCOMPONENTCAM_URL_MOVELEFT + IPSCOMPONENTCAM_URL_MOVERIGHT + IPSCOMPONENTCAM_URL_MOVEUP + IPSCOMPONENTCAM_URL_MOVEDOWN + IPSCOMPONENTCAM_URL_PREDEFPOS1 + IPSCOMPONENTCAM_URL_PREDEFPOS2 + IPSCOMPONENTCAM_URL_PREDEFPOS3 + IPSCOMPONENTCAM_URL_PREDEFPOS4 + IPSCOMPONENTCAM_URL_PREDEFPOS5 + */ + public function Get_URL($urlType) { + trigger_error('Diese Funktion ist für eine Mobotix Kamera noch NICHT implementiert !!!'); + } + + /** + * @public + * + * Liefert Breite des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return integer Breite des Bildes in Pixel + */ + public function Get_Width($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $return = 320; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $return = 640; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $return = 1024; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $return; + } + + /** + * @public + * + * Liefert Höhe des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return integer Höhe des Bildes in Pixel + */ + public function Get_Height($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $return = 240; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $return = 400; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $return = 768; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $return; + } + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Planet.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Planet.class.php new file mode 100644 index 0000000..c8873f6 --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Planet.class.php @@ -0,0 +1,245 @@ + + */ + + IPSUtils_Include ('IPSComponentCam.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentCam'); + + class IPSComponentCam_Planet extends IPSComponentCam { + + private $ipAddress; + private $username; + private $password; + + /** + * @public + * + * Initialisierung eines IPSComponentCam_Planet Objektes + * + * @param string $ipAddress IP Adresse der Kamera + * @param string $username Username für Kamera Zugriff + * @param string $password Passwort für Kamera Zugriff + */ + public function __construct($ipAddress, $username, $password) { + $this->ipAddress = $ipAddress; + $this->username = $username; + $this->password = $password; + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleCam $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleCam $module) { + $name = IPS_GetName($variable); + throw new IPSComponentException('Event Handling NOT supported for Variable '.$variable.'('.$name.')'); + } + + /** + * @public + * + * Liefert URL des Kamera Live Streams + * + * @param integer $size Größe des Streams, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return string URL des Streams + */ + public function Get_URLLiveStream($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + $url = 'http://'.$this->username.':'.$this->password.'@'.$this->ipAddress.'/GetData.cgi'; + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $url .= ''; // Not supported + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $url .= ''; // Not supported + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $url .= ''; // Not supported + break; + default: + trigger_error('Unknown Size '.$size); + } + return $url; + } + + /** + * @public + * + * Liefert URL des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return string URL des Bildes + */ + public function Get_URLPicture($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + $url = 'http://'.$this->username.':'.$this->password.'@'.$this->ipAddress.'/GetImage.cgi'; + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $url .= ''; // Not supported + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $url .= ''; // Not supported + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $url .= ''; // Not supported + break; + default: + trigger_error('Unknown Size '.$size); + } + return $url; + } + + /** + * @public + * + * Bewegen der Kamera + * + * @param integer $urlType Type der URL die geliefert werden soll. + * mögliche Werte: IPSCOMPONENTCAM_URL_MOVEHOME + IPSCOMPONENTCAM_URL_MOVELEFT + IPSCOMPONENTCAM_URL_MOVERIGHT + IPSCOMPONENTCAM_URL_MOVEUP + IPSCOMPONENTCAM_URL_MOVEDOWN + IPSCOMPONENTCAM_URL_PREDEFPOS1 + IPSCOMPONENTCAM_URL_PREDEFPOS2 + IPSCOMPONENTCAM_URL_PREDEFPOS3 + IPSCOMPONENTCAM_URL_PREDEFPOS4 + IPSCOMPONENTCAM_URL_PREDEFPOS5 + */ + public function Get_URL($urlType) { + $url = 'http://'.$this->username.':'.$this->password.'@'.$this->ipAddress.'/admin/ptctl.cgi?move=p1-p8?'; + switch ($urlType) { + case IPSCOMPONENTCAM_URL_MOVELEFT: + case IPSCOMPONENTCAM_URL_MOVERIGHT: + case IPSCOMPONENTCAM_URL_MOVEUP: + case IPSCOMPONENTCAM_URL_MOVEDOWN: + case IPSCOMPONENTCAM_URL_MOVEHOME: + $url = $url.''; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS1: + $url = $url.'move=p1'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS2: + $url = $url.'move=p2'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS3: + $url = $url.'move=p3'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS4: + $url = $url.'move=p4'; + break; + case IPSCOMPONENTCAM_URL_PREDEFPOS5: + $url = $url.'move=p5'; + break; + default: + trigger_error('Diese Funktion ist für eine Planet Kamera noch NICHT implementiert !!!'); + } + return $url; + } + + /** + * @public + * + * Liefert Breite des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return integer Breite des Bildes in Pixel + */ + public function Get_Width($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $return = 320; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $return = 640; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $return = 1024; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $return; + } + + /** + * @public + * + * Liefert Höhe des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return integer Höhe des Bildes in Pixel + */ + public function Get_Height($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $return = 240; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $return = 480; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $return = 768; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $return; + } + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Vivotek.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Vivotek.class.php new file mode 100644 index 0000000..6a1eca1 --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_Vivotek.class.php @@ -0,0 +1,225 @@ + + */ + + IPSUtils_Include ('IPSComponentCam.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentCam'); + + class IPSComponentCam_Vivotek extends IPSComponentCam { + + private $ipAddress; + private $username; + private $password; + + /** + * @public + * + * Initialisierung eines IPSComponentCam_Vivotek Objektes + * + * @param string $ipAddress IP Adresse der Kamera + * @param string $username Username für Kamera Zugriff + * @param string $password Passwort für Kamera Zugriff + */ + public function __construct($ipAddress, $username, $password) { + $this->ipAddress = $ipAddress; + $this->username = $username; + $this->password = $password; + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleCam $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleCam $module) { + $name = IPS_GetName($variable); + throw new IPSComponentException('Event Handling NOT supported for Variable '.$variable.'('.$name.')'); + } + + /** + * @public + * + * Liefert URL des Kamera Live Streams + * + * @param integer $size Größe des Streams, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return string URL des Streams + */ + public function Get_URLLiveStream($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + $url = 'http://'.$this->username.':'.$this->password.'@'.$this->ipAddress.'/video'; + switch ($size) + { + case IPSCOMPONENTCAM_SIZE_SMALL: + $url .= '3'; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $url .= '2'; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $url .= ''; + break; + default: + trigger_error('Unknown Size '.$size); + } + + $url .= '.mjpg'; + + return $url; + } + + /** + * @public + * + * Liefert URL des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return string URL des Bildes + */ + public function Get_URLPicture($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + $url = 'http://'.$this->username.':'.$this->password.'@'.$this->ipAddress.'/cgi-bin/viewer/video.jpg?resolution='; + + switch ($size) + { + case IPSCOMPONENTCAM_SIZE_SMALL: + $url .= (int)(1280*(IPSCAM_HEIGHT_SMALL/720)).'x'.IPSCAM_HEIGHT_SMALL; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $url .= (int)(1280*(IPSCAM_HEIGHT_MIDDLE/720)).'x'.IPSCAM_HEIGHT_MIDDLE; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $url .= (int)(1280*(IPSCAM_HEIGHT_LARGE/720)).'x'.IPSCAM_HEIGHT_LARGE; + break; + default: + trigger_error('Unknown Size '.$size); + } + + return $url; + } + + /** + * @public + * + * Bewegen der Kamera + * + * @param integer $urlType Type der URL die geliefert werden soll. + * mögliche Werte: IPSCOMPONENTCAM_URL_MOVEHOME + IPSCOMPONENTCAM_URL_MOVELEFT + IPSCOMPONENTCAM_URL_MOVERIGHT + IPSCOMPONENTCAM_URL_MOVEUP + IPSCOMPONENTCAM_URL_MOVEDOWN + IPSCOMPONENTCAM_URL_PREDEFPOS1 + IPSCOMPONENTCAM_URL_PREDEFPOS2 + IPSCOMPONENTCAM_URL_PREDEFPOS3 + IPSCOMPONENTCAM_URL_PREDEFPOS4 + IPSCOMPONENTCAM_URL_PREDEFPOS5 + */ + public function Get_URL($urlType) { + trigger_error('Diese Funktion ist für eine Vivotek Kamera noch NICHT implementiert !!!'); + } + + /** + * @public + * + * Liefert Breite des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return integer Breite des Bildes in Pixel + */ + public function Get_Width($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $return = 320; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $return = 640; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $return = 1024; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $return; + } + + /** + * @public + * + * Liefert Höhe des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return integer Höhe des Bildes in Pixel + */ + public function Get_Height($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $return = 240; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $return = 400; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $return = 768; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $return; + } + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_YCam.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_YCam.class.php new file mode 100644 index 0000000..0d50008 --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentCam/IPSComponentCam_YCam.class.php @@ -0,0 +1,223 @@ + + */ + + IPSUtils_Include ('IPSComponentCam.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentCam'); + + class IPSComponentCam_YCam extends IPSComponentCam { + + private $ipAddress; + private $port; + private $username; + private $password; + + /** + * @public + * + * Initialisierung eines IPSComponentCam_YCam Objektes + * + * @param string $ipAddress IP Adresse der Kamera + * @param string $username Username für Kamera Zugriff + * @param string $password Passwort für Kamera Zugriff + * @param string $port Port für Kamera Zugriff + */ + public function __construct($ipAddress, $username, $password, $port=8150) { + $this->ipAddress = $ipAddress; + $this->username = $username; + $this->password = $password; + $this->port = $port; + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleCam $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleCam $module) { + $name = IPS_GetName($variable); + throw new IPSComponentException('Event Handling NOT supported for Variable '.$variable.'('.$name.')'); + } + + /** + * @public + * + * Liefert URL des Kamera Live Streams + * + * @param integer $size Größe des Streams, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return string URL des Streams + */ + public function Get_URLLiveStream($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + $url = 'http://'.$this->username.':'.$this->password.'@'.$this->ipAddress.':'.$this->port.'/stream'; + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $url .= '1'; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $url .= ''; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $url .= ''; + break; + default: + trigger_error('Unknown Size '.$size); + } + $url .= '.jpg'; + + return $url; + } + + /** + * @public + * + * Liefert URL des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return string URL des Bildes + */ + public function Get_URLPicture($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + $url = 'http://'.$this->username.':'.$this->password.'@'.$this->ipAddress.':'.$this->port.'/snapshot.jpg'; + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $url .= ''; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $url .= ''; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $url .= ''; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $url; + } + + /** + * @public + * + * Bewegen der Kamera + * + * @param integer $urlType Type der URL die geliefert werden soll. + * mögliche Werte: IPSCOMPONENTCAM_URL_MOVEHOME + IPSCOMPONENTCAM_URL_MOVELEFT + IPSCOMPONENTCAM_URL_MOVERIGHT + IPSCOMPONENTCAM_URL_MOVEUP + IPSCOMPONENTCAM_URL_MOVEDOWN + IPSCOMPONENTCAM_URL_PREDEFPOS1 + IPSCOMPONENTCAM_URL_PREDEFPOS2 + IPSCOMPONENTCAM_URL_PREDEFPOS3 + IPSCOMPONENTCAM_URL_PREDEFPOS4 + IPSCOMPONENTCAM_URL_PREDEFPOS5 + */ + public function Get_URL($urlType) { + trigger_error('Diese Funktion ist für eine YCam Kamera noch NICHT implementiert !!!'); + } + + /** + * @public + * + * Liefert Breite des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return integer Breite des Bildes in Pixel + */ + public function Get_Width($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $return = 320; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $return = 640; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $return = 1024; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $return; + } + + /** + * @public + * + * Liefert Höhe des Kamera Bildes + * + * @param integer $size Größe des Bildes, mögliche Werte: + * IPSCOMPONENTCAM_SIZE_SMALL, IPSCOMPONENTCAM_SIZE_MIDDLE oder IPSCOMPONENTCAM_SIZE_LARGE + * @return integer Höhe des Bildes in Pixel + */ + public function Get_Height($size=IPSCOMPONENTCAM_SIZE_MIDDLE) { + switch ($size) { + case IPSCOMPONENTCAM_SIZE_SMALL: + $return = 240; + break; + case IPSCOMPONENTCAM_SIZE_MIDDLE: + $return = 480; + break; + case IPSCOMPONENTCAM_SIZE_LARGE: + $return = 768; + break; + default: + trigger_error('Unknown Size '.$size); + } + return $return; + } + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentDimmer/IPSComponentDimmer.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentDimmer/IPSComponentDimmer.class.php index cb01d58..a69bc03 100644 --- a/IPSLibrary/app/core/IPSComponent/IPSComponentDimmer/IPSComponentDimmer.class.php +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentDimmer/IPSComponentDimmer.class.php @@ -18,6 +18,8 @@ * Version 2.50.1, 31.01.2012
*/ + IPSUtils_Include ('IPSComponent.class.php', 'IPSLibrary::app::core::IPSComponent'); + abstract class IPSComponentDimmer extends IPSComponent { /** diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentDimmer/IPSComponentDimmer_DMX.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentDimmer/IPSComponentDimmer_DMX.class.php new file mode 100644 index 0000000..5037087 --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentDimmer/IPSComponentDimmer_DMX.class.php @@ -0,0 +1,110 @@ + + */ + + IPSUtils_Include ('IPSComponentDimmer.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentDimmer'); + + class IPSComponentDimmer_DMX extends IPSComponentDimmer { + + private $instanceId; + private $channel; + + /** + * @public + * + * Initialisierung eines IPSComponentDimmer_DMX Objektes + * + * @param integer $instanceId InstanceId des DMX Devices + */ + public function __construct($instanceId, $channel=1) { + $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); + $this->channel = (int)$channel; + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId.','.$this->channel; + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleDimmer $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleDimmer $module){ + } + + /** + * @public + * + * Zustand Setzen + * + * @param integer $power Geräte Power + * @param integer $level Wert für Dimmer Einstellung (Wertebereich 0-100) + */ + public function SetState($power, $level) { + if (!$power) { + DMX_SetValue ($this->instanceId, $this->channel, 0); + } else { + $levelDMX = $level / 100 * 255; + DMX_SetValue ($this->instanceId, $this->channel, $levelDMX); + } + + } + + /** + * @public + * + * Liefert aktuellen Level des Dimmers + * + * @return integer aktueller Dimmer Level + */ + public function GetLevel() { + return GetValue(IPS_GetVariableIDByIdent('ChannelValue'.$this->channel, $this->instanceId))*100/255; + } + + /** + * @public + * + * Liefert aktuellen Power Zustand des Dimmers + * + * @return boolean Gerätezustand On/Off des Dimmers + */ + public function GetPower() { + return GetValue(IPS_GetVariableIDByIdent('ChannelValue'.$this->channel, $this->instanceId)) > 0; + } + + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentDimmer/IPSComponentDimmer_Dummy.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentDimmer/IPSComponentDimmer_Dummy.class.php new file mode 100644 index 0000000..2a9b014 --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentDimmer/IPSComponentDimmer_Dummy.class.php @@ -0,0 +1,101 @@ + + */ + + IPSUtils_Include ('IPSComponentDimmer.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentDimmer'); + + class IPSComponentDimmer_Dummy extends IPSComponentDimmer { + + private $instanceId; + + /** + * @public + * + * Initialisierung eines IPSComponentDimmer_Dummy Objektes + * + * @param integer $instanceId InstanceId des Dummy Devices + */ + public function __construct($instanceId) { + $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleDimmer $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleDimmer $module){ + } + + /** + * @public + * + * Zustand Setzen + * + * @param integer $power Geräte Power + * @param integer $level Wert für Dimmer Einstellung (Wertebereich 0-100) + */ + public function SetState($power, $level) { + } + + /** + * @public + * + * Liefert aktuellen Level des Dimmers + * + * @return integer aktueller Dimmer Level + */ + public function GetLevel() { + return null; + } + + /** + * @public + * + * Liefert aktuellen Power Zustand des Dimmers + * + * @return boolean Gerätezustand On/Off des Dimmers + */ + public function GetPower() { + return null; + } + + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentDimmer/IPSComponentDimmer_EIB.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentDimmer/IPSComponentDimmer_EIB.class.php new file mode 100644 index 0000000..b3754fa --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentDimmer/IPSComponentDimmer_EIB.class.php @@ -0,0 +1,185 @@ + + */ + + IPSUtils_Include ('IPSComponentDimmer.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentDimmer'); + + class IPSComponentDimmer_EIB extends IPSComponentDimmer { + + private $instanceId; + private $groupFunction; + private $groupInterpretation; + + /** + * @public + * + * Initialisierung eines IPSComponentDimmer_EIB Objektes + * + * @param integer $instanceId InstanceId des EIB Devices + */ + public function __construct($instanceId) { + $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); + $this->groupFunction = EIB_GetGroupFunction($this->instanceId); + $this->groupInterpretation = EIB_GetGroupInterpretation($this->instanceId); + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleDimmer $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleDimmer $module){ + } + + /** + * @public + * + * Zustand Setzen + * + * @param integer $power Geräte Power + * @param integer $level Wert für Dimmer Einstellung (Wertebereich 0-100) + */ + public function SetState($power, $level) { + if (!$power) { + switch ($this->groupFunction) { + case 'Scale': + EIB_Scale($this->instanceId, 0); + break; + case 'DimControl': + EIB_DimControl($this->instanceId, 0); + break; + case 'DimValue': + EIB_DimValue($this->instanceId, 0); + break; + default: + trigger_error('Unsupported EIB GroupFunction "'.$this->groupFunction.'"'); + } + } else { + switch ($this->groupFunction) { + case 'Scale': + if ($this->groupInterpretation=='Standard') { /* 0 .. 255 */ + EIB_Scale($this->instanceId, round($level/100*255)); + } elseif ($this->groupInterpretation=='Percent') { /* 0 .. 100 */ + EIB_Scale($this->instanceId, round($level)); + } else { + trigger_error('Unsupported EIB GroupInterpretation "'.$this->groupInterpretation.'"'); + } + break; + case 'DimControl': + if ($this->groupInterpretation=='Standard') { /* 0 .. 15 */ + EIB_DimControl($this->instanceId, round($level/100*15)); + } elseif ($this->groupInterpretation=='Enhanced') { /* 0 .. 7 */ + EIB_DimControl($this->instanceId, round($level/100*7)); + } else { + trigger_error('Unsupported EIB GroupInterpretation "'.$this->groupInterpretation.'"'); + } + break; + case 'DimValue': + if ($this->groupInterpretation=='Standard') { /* 0 .. 255 */ + EIB_Value($this->instanceId, round($level/100*255)); + } elseif ($this->groupInterpretation=='Percent') { /* 0 .. 100 */ + EIB_DimValue($this->instanceId, round($level)); + } else { + trigger_error('Unsupported EIB GroupInterpretation "'.$this->groupInterpretation.'"'); + } + break; + default: + trigger_error('Unsupported EIB GroupFunction "'||$this->groupFunction.'"'); + } + } + + } + + /** + * @public + * + * Liefert aktuellen Level des Dimmers + * + * @return integer aktueller Dimmer Level + */ + public function GetLevel() { + $value = GetValue(IPS_GetObjectIdByIdent('Value', $this->instanceId)); + switch ($this->groupFunction) { + case 'Scale': + if ($this->groupInterpretation=='Standard') { /* 0 .. 255 */ + $value = round($value / 255 * 100); + } elseif ($this->groupInterpretation=='Percent') { /* 0 .. 100 */ + null; + } else { + trigger_error('Unsupported EIB GroupInterpretation "'.$this->groupInterpretation.'"'); + } + break; + case 'DimControl': + if ($this->groupInterpretation=='Standard') { /* 0 .. 15 */ + $value = round($value / 15 * 100); + } elseif ($this->groupInterpretation=='Enhanced') { /* 0 .. 7 */ + $value = round($value / 7 * 100); + } else { + trigger_error('Unsupported EIB GroupInterpretation "'.$this->groupInterpretation.'"'); + } + break; + case 'DimValue': + if ($this->groupInterpretation=='Standard') { /* 0 .. 255 */ + $value = round($value / 255 * 100); + } elseif ($this->groupInterpretation=='Percent') { /* 0 .. 100 */ + null; + } else { + trigger_error('Unsupported EIB GroupInterpretation "'.$this->groupInterpretation.'"'); + } + break; + default: + trigger_error('Unsupported EIB GroupFunction "'||$this->groupFunction.'"'); + } + return $value; + } + + /** + * @public + * + * Liefert aktuellen Power Zustand des Dimmers + * + * @return boolean Gerätezustand On/Off des Dimmers + */ + public function GetPower() { + return GetValue(IPS_GetObjectIdByIdent('Value', $this->instanceId)) > 0; + } + + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentDimmer/IPSComponentDimmer_EatonMoeller.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentDimmer/IPSComponentDimmer_EatonMoeller.class.php new file mode 100644 index 0000000..8fb0c5a --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentDimmer/IPSComponentDimmer_EatonMoeller.class.php @@ -0,0 +1,105 @@ + + */ + + IPSUtils_Include ('IPSComponentDimmer.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentDimmer'); + + class IPSComponentDimmer_EatonMoeller extends IPSComponentDimmer { + + private $instanceId; + + /** + * @public + * + * Initialisierung eines IPSComponentDimmer_EatonMoeller Objektes + * + * @param integer $instanceId InstanceId des EatonMoeller Devices + */ + public function __construct($instanceId) { + $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleDimmer $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleDimmer $module){ + } + + /** + * @public + * + * Zustand Setzen + * + * @param integer $power Geräte Power + * @param integer $level Wert für Dimmer Einstellung (Wertebereich 0-100) + */ + public function SetState($power, $level) { + MXC_SwitchMode($this->instanceId, $power); + if ($power) { + MXC_DimSet($this->instanceId, $level); + } + } + + /** + * @public + * + * Liefert aktuellen Level des Dimmers + * + * @return integer aktueller Dimmer Level + */ + public function GetLevel() { + return GetValue(IPS_GetVariableIDByName('Intensity', $this->instanceId)); + } + + /** + * @public + * + * Liefert aktuellen Power Zustand des Dimmers + * + * @return boolean Gerätezustand On/Off des Dimmers + */ + public function GetPower() { + return GetValue(IPS_GetVariableIDByName('Status', $this->instanceId)) > 0; + } + + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentDimmer/IPSComponentDimmer_Enocean.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentDimmer/IPSComponentDimmer_Enocean.class.php new file mode 100644 index 0000000..663b31d --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentDimmer/IPSComponentDimmer_Enocean.class.php @@ -0,0 +1,106 @@ + + */ + + IPSUtils_Include ('IPSComponentDimmer.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentDimmer'); + + class IPSComponentDimmer_Enocean extends IPSComponentDimmer { + + private $instanceId; + + /** + * @public + * + * Initialisierung eines IPSComponentDimmer_Enocean Objektes + * + * @param integer $instanceId InstanceId des Dummy Devices + */ + public function __construct($instanceId) { + $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleDimmer $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleDimmer $module){ + } + + /** + * @public + * + * Zustand Setzen + * + * @param integer $power Geräte Power + * @param integer $level Wert für Dimmer Einstellung (Wertebereich 0-100) + */ + public function SetState($power, $level) { + if (!$power) { + ENO_DimSet($this->instanceId, 0); + } else { + ENO_DimSet($this->instanceId, $level); + } + } + + /** + * @public + * + * Liefert aktuellen Level des Dimmers + * + * @return integer aktueller Dimmer Level + */ + public function GetLevel() { + return GetValue(IPS_GetVariableIDByName('Intensity', $this->instanceId)); + } + + /** + * @public + * + * Liefert aktuellen Power Zustand des Dimmers + * + * @return boolean Gerätezustand On/Off des Dimmers + */ + public function GetPower() { + return GetValue(IPS_GetVariableIDByName('Intensity', $this->instanceId)) > 0; + } + + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentDimmer/IPSComponentDimmer_FS20.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentDimmer/IPSComponentDimmer_FS20.class.php new file mode 100644 index 0000000..65ceb72 --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentDimmer/IPSComponentDimmer_FS20.class.php @@ -0,0 +1,115 @@ + + */ + + IPSUtils_Include ('IPSComponentDimmer.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentDimmer'); + + class IPSComponentDimmer_FS20 extends IPSComponentDimmer { + + private $instanceId; + + /** + * @public + * + * Initialisierung eines IPSComponentDimmer_FS20 Objektes + * + * @param integer $instanceId InstanceId des FS20 Devices + */ + public function __construct($instanceId) { + $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleDimmer $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleDimmer $module){ + } + + /** + * @public + * + * Zustand Setzen + * + * @param integer $power Geräte Power + * @param integer $level Wert für Dimmer Einstellung (Wertebereich 0-100) + */ + public function SetState($power, $level) { + // Zeit in Sekunden wie schnell der Aktor dimmmen soll + $DimspeedSec = 2; + if (!$power) { + FS20_SetIntensity ($this->instanceId, 0, $DimspeedSec); + // Wartezeit um den Aktor auf OFF zu Schalten + // IPS_Sleep wird in Millisekunden angegeben, darum * 1000 + IPS_Sleep ($DimspeedSec*1000); + FS20_SwitchMode ($this->instanceId, false); + } else { + // 100% Helligkeit Entsprechen bei FS20 dem Wert 16 + $levelFS20 = round($level / 100 * 16); + FS20_SetIntensity ($this->instanceId, $levelFS20, $DimspeedSec); + } + + } + + /** + * @public + * + * Liefert aktuellen Level des Dimmers + * + * @return integer aktueller Dimmer Level + */ + public function GetLevel() { + return GetValue(IPS_GetVariableIDByName('Intensität', $this->instanceId)); + } + + /** + * @public + * + * Liefert aktuellen Power Zustand des Dimmers + * + * @return boolean Gerätezustand On/Off des Dimmers + */ + public function GetPower() { + return GetValue(IPS_GetVariableIDByName('Intensität', $this->instanceId)) > 0; + } + + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentDimmer/IPSComponentDimmer_Homematic.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentDimmer/IPSComponentDimmer_Homematic.class.php index a5912ae..c66ae41 100644 --- a/IPSLibrary/app/core/IPSComponent/IPSComponentDimmer/IPSComponentDimmer_Homematic.class.php +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentDimmer/IPSComponentDimmer_Homematic.class.php @@ -19,7 +19,9 @@ * Version 2.50.1, 31.01.2012
*/ - abstract class IPSComponentDimmer_Homematic extends IPSComponentDimmer { + IPSUtils_Include ('IPSComponentDimmer.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentDimmer'); + + class IPSComponentDimmer_Homematic extends IPSComponentDimmer { private $instanceId; @@ -34,6 +36,19 @@ public function __construct($instanceId) { $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); } + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + /** * @public * diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentDimmer/IPSComponentDimmer_ZW.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentDimmer/IPSComponentDimmer_ZW.class.php new file mode 100644 index 0000000..c82d3b8 --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentDimmer/IPSComponentDimmer_ZW.class.php @@ -0,0 +1,108 @@ + + */ + + IPSUtils_Include ('IPSComponentDimmer.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentDimmer'); + + class IPSComponentDimmer_ZW extends IPSComponentDimmer { + + private $instanceId; + + /** + * @public + * + * Initialisierung eines IPSComponentDimmer_ZW Objektes + * + * @param integer $instanceId InstanceId des Z-Wave Devices + */ + public function __construct($instanceId) { + $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleDimmer $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleDimmer $module){ + } + + /** + * @public + * + * Zustand Setzen + * + * @param integer $power Geräte Power + * @param integer $level Wert für Dimmer Einstellung (Wertebereich 0-100) + */ + public function SetState($power, $level) { + if (!$power) { + ZW_DimSet($this->instanceId, 0); + } else { + $levelZW = $level; + ZW_DimSet($this->instanceId, $levelZW); + } + + } + + /** + * @public + * + * Liefert aktuellen Level des Dimmers + * + * @return integer aktueller Dimmer Level + */ + public function GetLevel() { + return GetValue(IPS_GetVariableIDByName('Intensity', $this->instanceId)); + } + + /** + * @public + * + * Liefert aktuellen Power Zustand des Dimmers + * + * @return boolean Gerätezustand On/Off des Dimmers + */ + public function GetPower() { + return GetValue(IPS_GetVariableIDByName('Intensity', $this->instanceId)) > 0; + } + + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentPlayer/IPSComponentPlayer.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentPlayer/IPSComponentPlayer.class.php index ceb1867..687a84d 100644 --- a/IPSLibrary/app/core/IPSComponent/IPSComponentPlayer/IPSComponentPlayer.class.php +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentPlayer/IPSComponentPlayer.class.php @@ -18,6 +18,8 @@ * Version 2.50.1, 31.01.2012
*/ + IPSUtils_Include ('IPSComponent.class.php', 'IPSLibrary::app::core::IPSComponent'); + abstract class IPSComponentPlayer extends IPSComponent { /** diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentPlayer/IPSComponentPlayer_Mediaplayer.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentPlayer/IPSComponentPlayer_Mediaplayer.class.php index 76fa9a6..1cad5ea 100644 --- a/IPSLibrary/app/core/IPSComponent/IPSComponentPlayer/IPSComponentPlayer_Mediaplayer.class.php +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentPlayer/IPSComponentPlayer_Mediaplayer.class.php @@ -137,7 +137,7 @@ public function ClearPlaylist(){ */ public function SetPlaylistPosition($position){ if (WAC_GetPlaylistLength($this->instanceId) > 0 and - $position < WAC_GetPlaylistLength($this->instanceId) and + $position <= WAC_GetPlaylistLength($this->instanceId) and $position > 0){ WAC_SetPlaylistPosition($this->instanceId, (int)$position); WAC_Play($this->instanceId); diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentRGB/IPSComponentRGB.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentRGB/IPSComponentRGB.class.php index 7e19aeb..5dc043f 100644 --- a/IPSLibrary/app/core/IPSComponent/IPSComponentRGB/IPSComponentRGB.class.php +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentRGB/IPSComponentRGB.class.php @@ -12,7 +12,7 @@ /** * @class IPSComponentRGB * - * Definiert ein IPSComponentRGB Object, das als Wrapper für Dimmer Geräte verschiedener Hersteller + * Definiert ein IPSComponentRGB Object, das als Wrapper für RGB Geräte verschiedener Hersteller * verwendet werden kann. * * @author Andreas Brauneis @@ -20,6 +20,8 @@ * Version 2.50.1, 31.01.2012
*/ + IPSUtils_Include ('IPSComponent.class.php', 'IPSLibrary::app::core::IPSComponent'); + abstract class IPSComponentRGB extends IPSComponent { /** @@ -30,9 +32,9 @@ abstract class IPSComponentRGB extends IPSComponent { * * @param integer $variable ID der auslösenden Variable * @param string $value Wert der Variable - * @param IPSModuleDimmer $module Module Object an das das aufgetretene Event weitergeleitet werden soll + * @param IPSModuleRGB $module Module Object an das das aufgetretene Event weitergeleitet werden soll */ - abstract public function HandleEvent($variable, $value, IPSModuleDimmer $module); + abstract public function HandleEvent($variable, $value, IPSModuleRGB $module); /** * @public diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentRGB/IPSComponentRGB_DMX.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentRGB/IPSComponentRGB_DMX.class.php new file mode 100644 index 0000000..2a2576b --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentRGB/IPSComponentRGB_DMX.class.php @@ -0,0 +1,100 @@ + + */ + + IPSUtils_Include ('IPSComponentRGB.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentRGB'); + + class IPSComponentRGB_DMX extends IPSComponentRGB { + + private $instanceId; + private $channel1; + private $channel2; + private $channel3; + + /** + * @public + * + * Initialisierung eines IPSComponentRGB_DMX Objektes + * + * @param integer $instanceId InstanceId des IPS-RGBW868 Devices + */ + public function __construct($instanceId, $channel1=1, $channel2=2, $channel3=3) { + $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); + $this->channel1 = $channel1; + $this->channel2 = $channel2; + $this->channel3 = $channel3; + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleRGB $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleRGB $module){ + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId.','.$this->channel1.','.$this->channel2.','.$this->channel3; + } + + /** + * @public + * + * Zustand Setzen + * + * @param boolean $power RGB Gerät On/Off + * @param integer $color RGB Farben (Hex Codierung) + * @param integer $level Dimmer Einstellung der RGB Beleuchtung (Wertebereich 0-100) + */ + public function SetState($power, $color, $level) { + if (!$power) { + DMX_SetValue ($this->instanceId, 0, 0); + } else { + $red = floor($color/256/256); + $green = floor(($color-$red*256*256)/256); + $blue = floor(($color-$red*256*256-$green*256)); + $red = floor($red*$level/100); + $green = floor($green*$level/100); + $blue = floor($blue*$level/100); + + DMX_SetValue ($this->instanceId, $this->channel1, $red); + DMX_SetValue ($this->instanceId, $this->channel2, $green); + DMX_SetValue ($this->instanceId, $this->channel3, $blue); + } + } + + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentRGB/IPSComponentRGB_Dummy.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentRGB/IPSComponentRGB_Dummy.class.php new file mode 100644 index 0000000..9960fd3 --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentRGB/IPSComponentRGB_Dummy.class.php @@ -0,0 +1,80 @@ + + */ + + IPSUtils_Include ('IPSComponentRGB.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentRGB'); + + class IPSComponentRGB_Dummy extends IPSComponentRGB { + + private $instanceId; + + /** + * @public + * + * Initialisierung eines IPSComponentRGB_Dummy Objektes + * + * @param integer $instanceId InstanceId des Dummy Devices + */ + public function __construct($instanceId) { + $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleRGB $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleRGB $module){ + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + + /** + * @public + * + * Zustand Setzen + * + * @param boolean $power RGB Gerät On/Off + * @param integer $color RGB Farben (Hex Codierung) + * @param integer $level Dimmer Einstellung der RGB Beleuchtung (Wertebereich 0-100) + */ + public function SetState($power, $color, $level) { + } + + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentRGB/IPSComponentRGB_IPS868.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentRGB/IPSComponentRGB_IPS868.class.php index 4e2219c..4a7141f 100644 --- a/IPSLibrary/app/core/IPSComponent/IPSComponentRGB/IPSComponentRGB_IPS868.class.php +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentRGB/IPSComponentRGB_IPS868.class.php @@ -19,7 +19,9 @@ * Version 2.50.1, 31.01.2012
*/ - abstract class IPSComponentRGB_IPS868 extends IPSComponentRGB { + IPSUtils_Include ('IPSComponentRGB.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentRGB'); + + class IPSComponentRGB_IPS868 extends IPSComponentRGB { private $instanceId; @@ -47,6 +49,19 @@ public function __construct($instanceId) { public function HandleEvent($variable, $value, IPSModuleRGB $module){ } + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + /** * @public * @@ -57,7 +72,7 @@ public function HandleEvent($variable, $value, IPSModuleRGB $module){ * @param integer $level Dimmer Einstellung der RGB Beleuchtung (Wertebereich 0-100) */ public function SetState($power, $color, $level) { - if (!power) { + if (!$power) { @PJ_DimRGBW ($this->instanceId, 0, 2, 0, 2, 0, 2, 0, 2); } else { $red = floor($color/256/256); diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentRGB/IPSComponentRGB_PhilipsHUE.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentRGB/IPSComponentRGB_PhilipsHUE.class.php new file mode 100644 index 0000000..0d3d4da --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentRGB/IPSComponentRGB_PhilipsHUE.class.php @@ -0,0 +1,458 @@ + + */ + + IPSUtils_Include ('IPSComponentRGB.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentRGB'); + IPSUtils_Include ("IPSLogger.inc.php", "IPSLibrary::app::core::IPSLogger"); + + class IPSComponentRGB_PhilipsHUE extends IPSComponentRGB { + + private $bridgeIP; + private $lampNr; + private $hueKey; + private $modelID; + + public $Status; + public $Hue; + public $ModelID; + public $XY; + public $Level; + public $Saturation; + + + /** + * @public + * + * Initialisierung eines IPSComponentRGB_PhilipsHUE Objektes + * + * @param string $bridgeIP IP Addresse der HUE Lampe + * @param string $hueKey Key zum Zugriff auf die Lampe + * @param string $lampNr Nummer der Lampe + * @param string $modelID Philips Modelnummer der Lampe + * + */ + public function __construct($bridgeIP, $hueKey, $lampNr, $modelID) { + + $this->bridgeIP = $bridgeIP; + $this->hueKey = $hueKey; + $this->lampNr = $lampNr; + $this->modelID = $modelID; + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleRGB $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleRGB $module){ + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->bridgeIP.','.$this->hueKey.','.$this->lampNr.','.$this->modelID; + } + + /** + * @brief Sends command to HUE bridge using JSON + * + * @param [in] $type Type of parameter ([Lights, Bridge] + * @param [in] $request [GET,PUT] + * @param [in] $cmd Command string + * @return Returns the result of the JSON command + * + */ + private function hue_SendLampCommand($type, $request, $cmd = null) { + + switch ($type) { + + case 'Lights': + $json_url = 'http://'.$this->bridgeIP.'/api/'.$this->hueKey.'/lights/'.$this->lampNr.'/state'; + break; + + case 'Bridge': + $json_url = 'http://'.$this->bridgeIP.'/api/'.$this->hueKey; + break; + + case 'api': + //For further development + break; + + default: + break; + } + + + $json_string = '{'.$cmd.'}'; + + // Configuring curl + $ch = curl_init($json_url); + $options = array( + CURLOPT_RETURNTRANSFER => true, + CURLOPT_CUSTOMREQUEST => $request, + CURLOPT_HTTPHEADER => array('Content-type: application/json') , + CURLOPT_POSTFIELDS => $json_string + ); + curl_setopt_array($ch, $options); + IPSLogger_Inf(__file__, 'Send PhilipsHUE: JsonURL='.$json_url.', Command='.$json_string); + + // Execute + if ($this->bridgeIP <> '') { + $json_result = curl_exec($ch); + return json_decode($json_result); + } + } + + + /** + * @public + * + * @brief Zustand Setzen + * + * @param boolean $power RGB Gerät On/Off + * @param integer $color RGB Farben (Hex Codierung) + * @param integer $level Dimmer Einstellung der RGB Beleuchtung (Wertebereich 0-100) + */ + public function SetState($power, $color, $level) { + if (!$power) { + $cmd = '"on":false'; + } else { + + $rotDec = (($color >> 16) & 0xFF); + $gruenDec = (($color >> 8) & 0xFF); + $blauDec = (($color >> 0) & 0xFF); + $color_array = array($rotDec,$gruenDec,$blauDec); + + $modelID = $this->modelID; + + //Convert RGB to XY values + $values = $this->calculateXY($color_array, $modelID); + + //IPSLight is using percentage in variable Level, Hue is using [0..255] + $level = round($level * 2,55); + $cmd = '"bri":'.$level.', "xy":['.$values->x.','.$values->y.'], "on":true'; + + } + + $type = 'Lights'; //Type of Command + $request = 'PUT'; //Type of Request + + //Send command to Hue lamp + $this->hue_SendLampCommand($type, $request, $cmd); + } + + /** + * @brief Queries bridge for details of the lamp + * + * @return None, details are populated in the public variables of the class + * + */ + public function QueryHUE() { + + + $type = 'Bridge'; //Type of Command + $request = 'GET'; //Type of Request + + //Send command to Hue lamp + $result = $this->hue_SendLampCommand($type, $request); + + $id = 1; + + foreach ($result->lights as $light) { + + if ($id == $this->lampNr) { + + $this->Status = $light->state->on; + $this->Hue = $light->state->hue; + $this->ModelID = $light->modelid; + $this->XY = $light->state->xy; + $this->Level = $light->state->bri; + $this->Saturation = $light->state->sat; + + } + + $id=$id+1; + + } + } + + /** + * @brief Sets the alert state. 'select' blinks once, 'lselect' blinks repeatedly, 'none' turns off blinking + * + */ + public function SetAlert( $alert_type = 'select' ) { + + $type = 'Lights'; //Type of Command + $request = 'PUT'; //Type of Request + $cmd = '"alert":"'.$alert_type.'"'; + + //Send command to Hue lamp + $this->hue_SendLampCommand($type, $request, $cmd); + } + + /** + * @brief Converts colour value from RGB to XY + * + * @param [in] $color Color in RGB + * @param [in] $model Philips lamp model + * @return XY value + */ + private function calculateXY($color, $model) { + + // Get the RGB values from color object and convert them to be between 0 and 1. + $red = round($color[0] / 255,2); + $green = round($color[1] / 255,2); + $blue = round($color[2] / 255,2); + + // Apply a gamma correction to the RGB values + $r = ($red > 0.04045) ? pow(($red + 0.055) / (1.0 + 0.055), 2.4) : ($red / 12.92); + $g = ($green > 0.04045) ? pow(($green + 0.055) / (1.0 + 0.055), 2.4) : ($green / 12.92); + $b = ($blue > 0.04045) ? pow(($blue + 0.055) / (1.0 + 0.055), 2.4) : ($blue / 12.92); + + // Convert the RGB values to XYZ using the Wide RGB D65 conversion formula + $X = $r * 0.649926 + $g * 0.103455 + $b * 0.197109; + $Y = $r * 0.234327 + $g * 0.743075 + $b * 0.022598; + $Z = $r * 0.0000000 + $g * 0.053077 + $b * 1.035763; + + // Calculate the xy values from the XYZ values + if($X==0 && $Y ==0 && $Z ==0) $Z = 0.1; + + $cx = $X / ($X + $Y + $Z); + $cy = $Y / ($X + $Y + $Z); + if(is_nan($cx)) $cx = 0.0; + if(is_nan($cy)) $cy = 0.0; + + // Check if the found xy value is within the color gamut of the light + $xyPoint = new cgpoint($cx, $cy); + $colorPoints = $this->getColorPointsForModel($model); + $inReachOfLamps = $this->checkPointInLampsReach($xyPoint, $colorPoints); + + if(!$inReachOfLamps) + { + // Calculate the closest point on the color gamut triangle and use that as xy value + $pAB = $this->getClosestPointToPoints($colorPoints[0], $colorPoints[1], $xyPoint); + $pAC = $this->getClosestPointToPoints($colorPoints[2], $colorPoints[0], $xyPoint); + $pBC = $this->getClosestPointToPoints($colorPoints[1], $colorPoints[2], $xyPoint); + + $dAB = $this->getDistanceBetweenTwoPoints($xyPoint, $pAB); + $dAC = $this->getDistanceBetweenTwoPoints($xyPoint, $pAC); + $dBC = $this->getDistanceBetweenTwoPoints($xyPoint, $pBC); + + $lowest = $dAB; + $closestPoint = $pAB; + + if($dAC < $lowest) + { + $lowest = $dAC; + $closestPoint = $pAC; + } + if($dBC < $lowest) + { + $lowest = $dBC; + $closestPoint = $pBC; + } + + $cx = $closestPoint->x; + $cy = $closestPoint->y; + } + return new cgpoint($cx, $cy); + } + + /** + * @brief Returns the color gamut of a specific Philips light model + * + * @param [in] $model ID of the lamp model + * @return Array with color gamut + * + * @details + * + * Following models are supported: + * + * Hue + * "LCT001": Hue A19 + * "LCT002": Hue BR30 + * "LCT003": Hue GU10 + * LivingColors + * "LLC001": Monet, Renoir, Mondriaan (gen II) + * "LLC005": Bloom (gen II) + * "LLC006": Iris (gen III) + * "LLC007": Bloom, Aura (gen III) + * "LLC011": Hue Bloom + * "LLC012": Hue Bloom + * "LLC013": Storylight + * "LST001": Light Strips + * + */ + private function getColorPointsForModel($model) { + $colorPoints = array(); + $hueBulbs = array("LCT001","LCT002","LCT003"); + $livingColors = array("LLC001","LLC005","LLC006","LLC007","LLC011","LLC012","LLC013","LST001"); + + if(in_array($model, $hueBulbs)) + { + array_push($colorPoints, new cgpoint(0.674,0.322)); + array_push($colorPoints, new cgpoint(0.408,0.517)); + array_push($colorPoints, new cgpoint(0.168,0.041)); + } + else if(in_array($model, $livingColors)) + { + array_push($colorPoints, new cgpoint(0.703,0.296)); + array_push($colorPoints, new cgpoint(0.214,0.709)); + array_push($colorPoints, new cgpoint(0.139,0.081)); + } + else + { + array_push($colorPoints, new cgpoint(1.0,0.0)); + array_push($colorPoints, new cgpoint(0.0,1.0)); + array_push($colorPoints, new cgpoint(0.0,0.0)); + } + + return $colorPoints; + } + + /** + * @brief Find the distance between two points. + * + * @param one + * @param two + * @return the distance between point one and two + */ + private function getDistanceBetweenTwoPoints($one, $two) { + + $dx = $one->x - $two->x; + $dy = $one->y - $two->y; + $dist = sqrt($dx * $dx + $dy * $dy); + return $dist; + } + + /** + * @brief Find the closest point on a line. This point will be within reach of the lamp. + * + * @param A the point where the line starts + * @param B the point where the line ends + * @param P the point which is close to a line. + * @return the point which is on the line. + */ + private function getClosestPointToPoints($A, $B, $P) { + + $AP = new cgpoint($P->x - $A->x, $P->y - $A->y); + $AB = new cgpoint($B->x - $A->x, $B->y - $A->y); + $ab2 = $AB->x * $AB->x + $AB->y * $AB->y; + $ap_ab = $AP->x * $AB->x + $AP->y * $AB->y; + + $t = $ap_ab / $ab2; + if($t < 0.0) + { + $t = 0.0; + } + else if($t > 1.0) + { + $t = 1.0; + } + $newPoint = new cgpoint($A->x + $AB->x * $t, $A->y + $AB->y * $t); + return $newPoint; + } + + /** + * @brief Calculates crossProduct of two 2D vectors / points + * + * @param p1 first point used as vector + * @param p2 second point used as vector + * @return crossProduct of vectors + * + */ + private function getCrossProduct($p1, $p2) { + return ($p1->x * $p2->y - $p1->y * $p2->x); + } + + /** + * @brief Method to see if the given XY value is within the reach of the lamps. + * + * @param p the point containing the X,Y value + * @return true if within reach, false otherwise. + * + */ + private function checkPointInLampsReach($p, $colorPoints) { + + $red = $colorPoints[0]; + $green = $colorPoints[1]; + $blue = $colorPoints[2]; + $grx =$green->x - $red->x; + $gry =$green->y - $red->y; + $brx =$blue->x - $red->x; + $bry =$blue->y -$red->y; + $prx =$p->x - $red->x; + $pry =$p->y - $red->y; + $v1 = new cgpoint($grx, $gry); + $v2 = new cgpoint($brx, $bry); + $q = new cgpoint($prx, $pry); + + $s = ($this->getCrossProduct($q, $v2) / $this->getCrossProduct($v1, $v2)); + $t = ($this->getCrossProduct($v1, $q) / $this->getCrossProduct($v1, $v2)); + + if(($s > 0.0) && ($t >= 0.0) && ($s + $t <= 1.0)) + { + return true; + } + return false; + } + + + } + + // @cond Ignore this class in doxygen + /** + * + * Helper class to ease translation from Philips C-coding + * Implements CGPoint class from iOS SDK + * + */ + + class cgpoint { + + public $x; + public $y; + + function __construct($_x, $_y) { + $this->x = $_x; + $this->y = $_y; + } + + }; + // @endcond + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentSensor/IPSComponentSensor.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentSensor/IPSComponentSensor.class.php new file mode 100644 index 0000000..7255436 --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentSensor/IPSComponentSensor.class.php @@ -0,0 +1,42 @@ + + */ + + IPSUtils_Include ('IPSComponent.class.php', 'IPSLibrary::app::core::IPSComponent'); + + abstract class IPSComponentSensor extends IPSComponent { + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleSensor $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + abstract public function HandleEvent($variable, $value, IPSModuleSensor $module); + + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentSensor/IPSComponentSensor_Button.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentSensor/IPSComponentSensor_Button.class.php new file mode 100644 index 0000000..3188251 --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentSensor/IPSComponentSensor_Button.class.php @@ -0,0 +1,57 @@ + + */ + + IPSUtils_Include ('IPSComponentSensor.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentSensor'); + + class IPSComponentSensor_Button extends IPSComponentSensor { + + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleSensor $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleSensor $module){ + $module->SyncButton($value, $this); + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this); + } + + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentSensor/IPSComponentSensor_IRTrans.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentSensor/IPSComponentSensor_IRTrans.class.php new file mode 100644 index 0000000..1393f6f --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentSensor/IPSComponentSensor_IRTrans.class.php @@ -0,0 +1,70 @@ + + */ + + IPSUtils_Include ('IPSComponentSensor.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentSensor'); + + class IPSComponentSensor_IRTrans extends IPSComponentSensor { + + + private $instanceId; + + /** + * @public + * + * Initialisierung des IPSComponentSensor_IRTrans + * + * @param integer $instanceId InstanceId von IRTrans + */ + public function __construct($instanceId) { + $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleSensor $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleSensor $module){ + $module->SyncButton($value, $this); + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this); + } + + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentSensor/IPSModuleSensor.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentSensor/IPSModuleSensor.class.php new file mode 100644 index 0000000..00e4d0d --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentSensor/IPSModuleSensor.class.php @@ -0,0 +1,49 @@ + + */ + + IPSUtils_Include ('IPSModule.class.php', 'IPSLibrary::app::core::IPSComponent'); + + abstract class IPSModuleSensor extends IPSModule { + + /** + * @public + * + * Ermöglicht die Synchronisation von Sensorwerten mit Modulen + * + * @param string $value Sensorwert + * @param IPSComponentSensor $component Sensor Komponente + */ + abstract public function SyncButton($value, IPSComponentSensor $component); + + /** + * @public + * + * Ermöglicht das Verarbeiten eines Taster Signals + * + */ + abstract public function ExecuteButton(); + + + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentSensor/IPSModuleSensor_Entertainment.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentSensor/IPSModuleSensor_Entertainment.class.php new file mode 100644 index 0000000..2012d4d --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentSensor/IPSModuleSensor_Entertainment.class.php @@ -0,0 +1,107 @@ + + */ + + IPSUtils_Include ("Entertainment_InterfaceIPSComponentSensor.inc.php", "IPSLibrary::app::modules::Entertainment"); + IPSUtils_Include ('IPSModuleSensor.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentSensor'); + + class IPSModuleSensor_Entertainment extends IPSModuleSensor { + + private $functionToCall; + private $param1; + private $param2; + private $param3; + + /** + * @public + * + * Initialisierung eines IPSModuleSensor_Entertainment Objektes + * + * @param integer $functionToCall Funktion, die aufgerufen werden soll + * @param boolean $param1 Parameter 1 + * @param boolean $param2 Parameter 2 + * @param boolean $param3 Parameter 3 + */ + public function __construct($functionToCall, $param1='', $param2='', $param3='') { + $this->functionToCall = $functionToCall; + $this->param1 = $param1; + $this->param2 = $param2; + $this->param3 = $param3; + } + + private function GetParam($param) { + if (is_numeric($param)) { + return (int)$param; + } elseif ($param=='true') { + return true; + } elseif ($param=='false') { + return false; + } else { + return $param; + } + } + + private function GetParamArray() { + $parameters = array(); + if ($this->param3<>'') { + $parameters[] = $this->GetParam($this->param1); + $parameters[] = $this->GetParam($this->param2); + $parameters[] = $this->GetParam($this->param3); + } elseif ($this->param2<>'') { + $parameters[] = $this->GetParam($this->param1); + $parameters[] = $this->GetParam($this->param2); + } elseif ($this->param1<>'') { + $parameters[] = $this->GetParam($this->param1); + } else { + } + return $parameters; + } + + /** + * @public + * + * Ermöglicht die Synchronisation von Sensorwerten mit Modulen + * + * @param string $value Sensorwert + * @param IPSComponentSensor $component Sensor Komponente + */ + public function SyncButton($value, IPSComponentSensor $component) { + $this->ExecuteButton(); + } + + /** + * @public + * + * Ermöglicht das Verarbeiten eines Taster Signals + * + */ + public function ExecuteButton () { + if (function_exists($this->functionToCall)) { + call_user_func_array($this->functionToCall, $this->GetParamArray()); + } else { + Entertainment_IPSComponentSensor_ReceiveData($this->functionToCall, $this->param1, $this->param2, $this->param3); + } + } + + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentSensor/IPSModuleSensor_IPSLight.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentSensor/IPSModuleSensor_IPSLight.class.php new file mode 100644 index 0000000..1b5558c --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentSensor/IPSModuleSensor_IPSLight.class.php @@ -0,0 +1,107 @@ + + */ + + IPSUtils_Include ('IPSLight.inc.php', 'IPSLibrary::app::modules::IPSLight'); + IPSUtils_Include ('IPSModuleSensor.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentSensor'); + + class IPSModuleSensor_IPSLight extends IPSModuleSensor { + + private $lightObject; + private $lightFunction; + private $lightValue; + + /** + * @public + * + * Initialisierung eines IPSModuleSensor_IPSLight Objektes + * + * @param string $lightObject Licht Object/Name (Leuchte, Gruppe, Programm, ...) + * @param string $lightFunction Function die ausgeführt werden soll + * @param string $lightValue Wert für Beleuchtungs Änderung + */ + public function __construct($lightFunction, $lightObject, $lightValue=null) { + $this->lightObject = $lightObject; + $this->lightFunction = $lightFunction; + $this->lightValue = $lightValue; + } + + + /** + * @public + * + * Ermöglicht die Synchronisation von Sensorwerten mit Modulen + * + * @param string $value Sensorwert + * @param IPSComponentSensor $component Sensor Komponente + */ + public function SyncButton($value, IPSComponentSensor $component) { + $this->ExecuteButton(); + } + + /** + * @public + * + * Ermöglicht das Verarbeiten eines Taster Signals + * + */ + public function ExecuteButton () { + switch ($this->lightFunction) { + case 'IPSLight_DimAbsoluteByName': + IPSLight_DimAbsoluteByName($this->lightObject, $this->lightValue); + break; + case 'IPSLight_DimRelativByName': + IPSLight_DimRelativByName($this->lightObject, $this->lightValue); + break; + + case 'IPSLight_SetSwitchByName': + if ($this->lightValue == 'true') + IPSLight_SetSwitchByName($this->lightObject, true); + else + IPSLight_SetSwitchByName($this->lightObject, false); + break; + case 'IPSLight_ToggleSwitchByName': + IPSLight_ToggleSwitchByName($this->lightObject); + break; + + + case 'IPSLight_SetGroupByName': + IPSLight_SetGroupByName($this->lightObject, $this->lightValue); + break; + case 'IPSLight_ToggleGroupByName': + IPSLight_ToggleGroupByName($this->lightObject); + break; + + case 'IPSLight_SetProgramNextByName': + IPSLight_SetProgramNextByName($this->lightObject); + break; + case 'IPSLight_SetProgramName': + IPSLight_SetProgramName($this->lightObject, $this->lightValue); + break; + default: + IPSLogger_Wrn(__file__, 'Unknown Button Function "'.$this->lightFunction.'"'); + } + } + + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentSensor/IPSModuleSensor_IPSShadowing.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentSensor/IPSModuleSensor_IPSShadowing.class.php new file mode 100644 index 0000000..d890f2e --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentSensor/IPSModuleSensor_IPSShadowing.class.php @@ -0,0 +1,76 @@ + + */ + + IPSUtils_Include ("IPSShadowing.inc.php", "IPSLibrary::app::modules::IPSShadowing"); + IPSUtils_Include ('IPSModuleSensor.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentSensor'); + + class IPSModuleSensor_IPSShadowing extends IPSModuleSensor { + + private $instanceId; + private $movementId; + + /** + * @public + * + * Initialisierung eines IPSModuleSensor_IPSShadowing Objektes + * + * @param integer $instanceId InstanceId des Homematic Devices + * @param boolean $movementId Movement Command + */ + public function __construct($instanceId, $movementId) { + $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); + $this->movementId = $movementId; + } + + + /** + * @public + * + * Ermöglicht die Synchronisation von Sensorwerten mit Modulen + * + * @param string $value Sensorwert + * @param IPSComponentSensor $component Sensor Komponente + */ + public function SyncButton($value, IPSComponentSensor $component) { + $this->ExecuteButton(); + } + + /** + * @public + * + * Ermöglicht das Verarbeiten eines Taster Signals + * + */ + public function ExecuteButton () { + $device = new IPSShadowing_Device($this->instanceId); + $movementId = GetValue(IPS_GetObjectIDByIdent(c_Control_Movement, $this->instanceId)); + if ($movementId==c_MovementId_MovingIn or $movementId==c_MovementId_MovingOut or $movementId==c_MovementId_Up or $movementId==c_MovementId_Down) { + $device->MoveByControl(c_MovementId_Stop); + } else { + $device->MoveByControl($this->movementId); + } + } + + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentSensor/IPSModuleSensor_IRTrans.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentSensor/IPSModuleSensor_IRTrans.class.php new file mode 100644 index 0000000..f02fbbc --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentSensor/IPSModuleSensor_IRTrans.class.php @@ -0,0 +1,73 @@ + + */ + + IPSUtils_Include ("IRTrans_InterfaceIPSComponentSensor.inc.php", "IPSLibrary::app::modules::IRTrans"); + IPSUtils_Include ('IPSModuleSensor.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentSensor'); + + class IPSModuleSensor_IRTrans extends IPSModuleSensor { + + private $instanceId; + private $device; + private $button; + + /** + * @public + * + * Initialisierung eines IPSModuleSensor_IRTrans Objektes + * + * @param integer $instanceId InstanceId + * @param string $device Device + * @param string $button Button + */ + public function __construct($instanceId, $device='', $button='') { + $this->instanceId = $instanceId; + $this->device = $device; + $this->button = $button; + } + + + /** + * @public + * + * Ermöglicht die Synchronisation von Sensorwerten mit Modulen + * + * @param string $value Sensorwert + * @param IPSComponentSensor $component Sensor Komponente + */ + public function SyncButton($value, IPSComponentSensor $component) { + $this->ExecuteButton(); + } + + /** + * @public + * + * Ermöglicht das Verarbeiten eines Taster Signals + * + */ + public function ExecuteButton () { + IRT_SendOnce($this->instanceId, $this->device, $this->button); + } + + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentSensor/IPSModuleSensor_NetPlayer.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentSensor/IPSModuleSensor_NetPlayer.class.php new file mode 100644 index 0000000..b0367a5 --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentSensor/IPSModuleSensor_NetPlayer.class.php @@ -0,0 +1,89 @@ + + */ + + IPSUtils_Include ("NetPlayer.inc.php", "IPSLibrary::app::modules::NetPlayer"); + IPSUtils_Include ('IPSModuleSensor.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentSensor'); + + class IPSModuleSensor_NetPlayer extends IPSModuleSensor { + + private $functionToCall; + private $param1; + private $param2; + private $param3; + + /** + * @public + * + * Initialisierung eines IPSModuleSensor_NetPlayer Objektes + * + * @param integer $functionToCall Funktion + * @param boolean $param1 Parameter 1 + * @param boolean $param2 Parameter 2 + * @param boolean $param3 Parameter 3 + */ + public function __construct($functionToCall, $param1='', $param2='', $param3='') { + $this->functionToCall = $functionToCall; + $this->param1 = $param1; + $this->param2 = $param2; + $this->param3 = $param3; + } + + + /** + * @public + * + * Ermöglicht die Synchronisation von Sensorwerten mit Modulen + * + * @param string $value Sensorwert + * @param IPSComponentSensor $component Sensor Komponente + */ + public function SyncButton($value, IPSComponentSensor $component) { + $this->ExecuteButton(); + } + + /** + * @public + * + * Ermöglicht das Verarbeiten eines Taster Signals + * + */ + public function ExecuteButton () { + $parameters = array(); + if ($this->param3<>'') { + $parameters[] = $this->param1; + $parameters[] = $this->param2; + $parameters[] = $this->param3; + } elseif ($this->param2<>'') { + $parameters[] = $this->param1; + $parameters[] = $this->param2; + } elseif ($this->param1<>'') { + $parameters[] = $this->param1; + } else { + } + + call_user_func_array($this->functionToCall, $parameters); + } + + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter.class.php index d846bdf..8939826 100644 --- a/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter.class.php +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter.class.php @@ -20,6 +20,8 @@ * Version 2.50.1, 31.01.2012
*/ + IPSUtils_Include ('IPSComponent.class.php', 'IPSLibrary::app::core::IPSComponent'); + abstract class IPSComponentShutter extends IPSComponent { /** diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_1Wire.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_1Wire.class.php index f5ac4a8..705f36f 100644 --- a/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_1Wire.class.php +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_1Wire.class.php @@ -19,9 +19,12 @@ * Version 2.50.1, 31.01.2012
*/ - abstract class IPSComponentShutter_1Wire extends IPSComponentShutter { + IPSUtils_Include ('IPSComponentShutter.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentShutter'); + + class IPSComponentShutter_1Wire extends IPSComponentShutter { private $instanceId; + private $reverseControl; /** * @public @@ -29,9 +32,24 @@ abstract class IPSComponentShutter_1Wire extends IPSComponentShutter { * Initialisierung eines IPSComponentShutter_1Wire Objektes * * @param integer $instanceId InstanceId des 1Wire Devices + * @param boolean $reverseControl Reverse Ansteuerung des Devices + */ + public function __construct($instanceId, $reverseControl=false) { + $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); + $this->reverseControl = $reverseControl; + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object */ - public function __construct($instanceId) { - $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; } /** @@ -55,8 +73,13 @@ public function HandleEvent($variable, $value, IPSModuleShutter $module){ * Hinauffahren der Beschattung */ public function MoveUp(){ - @TMEX_F29_SetStrobe($this->instanceId, True); - @TMEX_F29_SetPort((integer)$this->instanceId, (integer)120+128); + if ($this->reverseControl) { + @TMEX_F29_SetStrobe($this->instanceId, True); + @TMEX_F29_SetPort((integer)$this->instanceId, (integer)120); + } else { + @TMEX_F29_SetStrobe($this->instanceId, True); + @TMEX_F29_SetPort((integer)$this->instanceId, (integer)120+128); + } } /** @@ -65,8 +88,13 @@ public function MoveUp(){ * Hinunterfahren der Beschattung */ public function MoveDown(){ - @TMEX_F29_SetStrobe($this->instanceId, True); - @TMEX_F29_SetPort((integer)$this->instanceId, (integer)120); + if ($this->reverseControl) { + @TMEX_F29_SetStrobe($this->instanceId, True); + @TMEX_F29_SetPort((integer)$this->instanceId, (integer)120+128); + } else { + @TMEX_F29_SetStrobe($this->instanceId, True); + @TMEX_F29_SetPort((integer)$this->instanceId, (integer)120); + } } /** diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_Dummy.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_Dummy.class.php index 07830e9..52e7f68 100644 --- a/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_Dummy.class.php +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_Dummy.class.php @@ -19,7 +19,9 @@ * Version 2.50.1, 31.01.2012
*/ - abstract class IPSComponentShutter_Dummy extends IPSComponentShutter { + IPSUtils_Include ('IPSComponentShutter.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentShutter'); + + class IPSComponentShutter_Dummy extends IPSComponentShutter { private $instanceId; @@ -34,6 +36,19 @@ public function __construct($instanceId) { $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); } + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + /** * @public * diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_EIB.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_EIB.class.php new file mode 100644 index 0000000..0034c0d --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_EIB.class.php @@ -0,0 +1,125 @@ + + */ + + IPSUtils_Include ('IPSComponentShutter.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentShutter'); + + class IPSComponentShutter_EIB extends IPSComponentShutter { + + private $instanceId1; + private $instanceId2; + private $reverseControl; + /** + * @public + * + * Initialisierung eines IPSComponentShutter_EIB Objektes + * + * @param integer $instanceId1 InstanceId des EIB Devices + * @param integer $instanceId2 InstanceId 2 des EIB Devices (Richtungs Relais für den Fall das normale EIB Switches verwendet werden) + * @param boolean $reverseControl Richtungs Schalter (default=false) + */ + public function __construct($instanceId1, $instanceId2='', $reverseControl=false) { + $this->instanceId1 = IPSUtil_ObjectIDByPath($instanceId1); + if ($this->instanceId2<>'') { + $this->instanceId2 = IPSUtil_ObjectIDByPath($instanceId2); + } + $this->reverseControl = $reverseControl; + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleShutter $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleShutter $module){ + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId1.','.$this->instanceId2.','.$this->reverseControl; + } + + /** + * @public + * + * Hinauffahren der Beschattung + */ + public function MoveUp(){ + if ($this->instanceId2==null) { + if ($this->reverseControl) { + EIB_Move($this->instanceId1, 4); //0 = Open, 2 = Stop, 4 = Close + } else { + EIB_Move($this->instanceId1, 0); //0 = Open, 2 = Stop, 4 = Close + } + } else { + EIB_Switch($this->instanceId1, true); + EIB_Switch($this->instanceId2, $this->reverseControl); + } + } + + /** + * @public + * + * Hinunterfahren der Beschattung + */ + public function MoveDown(){ + if ($this->instanceId2==null) { + if ($this->reverseControl) { + EIB_Move($this->instanceId1, 0); //0 = Open, 2 = Stop, 4 = Close + } else { + EIB_Move($this->instanceId1, 4); //0 = Open, 2 = Stop, 4 = Close + } + } else { + EIB_Switch($this->instanceId1, true); + EIB_Switch($this->instanceId2, !$this->reverseControl); + } + } + + /** + * @public + * + * Stop + */ + public function Stop() { + if ($this->instanceId2==null) { + EIB_Move($this->instanceId1, 2); //0 = Open, 2 = Stop, 4 = Close + } else { + EIB_Switch($this->instanceId1, false); + EIB_Switch($this->instanceId2, false); + } + } + + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_Enocean.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_Enocean.class.php index 7402154..182f2e7 100644 --- a/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_Enocean.class.php +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_Enocean.class.php @@ -19,11 +19,13 @@ * Version 2.50.1, 31.01.2012
*/ - abstract class IPSComponentShutter_Enocean extends IPSComponentShutter { + IPSUtils_Include ('IPSComponentShutter.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentShutter'); + + class IPSComponentShutter_Enocean extends IPSComponentShutter { private $instanceId; private $isRunningId; - + /** * @public * @@ -33,20 +35,33 @@ abstract class IPSComponentShutter_Enocean extends IPSComponentShutter { */ public function __construct($instanceId) { $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); - $this->isRunningId = @IPS_GetObjectIDByIdent('isrunning', $this->instanceId); + $this->isRunningId = @IPS_GetObjectIDByIdent('runningMode', $this->instanceId); if($this->isRunningId===false) { - $this->isRunningId = IPS_CreateVariable($this->instanceId); - IPS_SetParent($this->isRunningId, $id); - IPS_SetName($this->isRunningId, 'IsRunning'); - IPS_SetIdent($this->isRunningId, 'isrunning'); - IPS_SetInfo($this->isRunningId, "This Variable was created by Script IPSComponentShutter_FS20"); + $this->isRunningId = IPS_CreateVariable(1 /*Integer*/); + IPS_SetParent($this->isRunningId, $this->instanceId); + IPS_SetName($this->isRunningId, 'RunningMode'); + IPS_SetIdent($this->isRunningId, 'runningMode'); + IPS_SetInfo($this->isRunningId, "This Variable was created by Script IPSComponentShutter_Enocean"); } } /** * @public * - * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event * an das entsprechende Module zu leiten. * * @param integer $variable ID der auslösenden Variable @@ -65,11 +80,11 @@ public function HandleEvent($variable, $value, IPSModuleShutter $module){ */ public function MoveUp(){ if(!GetValue($this->isRunningId)) { - ENO_SwitchMode($this->InstanceId, true); - SetValue($this->isRunningId, true); + ENO_SwitchMode($this->instanceId, true); + SetValue($this->isRunningId, 1); } } - + /** * @public * @@ -77,24 +92,28 @@ public function MoveUp(){ */ public function MoveDown(){ if(!GetValue($this->isRunningId)) { - ENO_SwitchMode($this->InstanceId, false); - SetValue($this->isRunningId, true); + ENO_SwitchMode($this->instanceId, false); + SetValue($this->isRunningId, 2); } } - + /** * @public * * Stop */ public function Stop() { - if(GetValue($this->isRunningId)) { - $value = GetValue(IPS_GetObjectIDByIdent($this->InstanceId, "StatusVariable") - ENO_SwitchMode($this->InstanceId, $value); - SetValue($this->isRunningId, false); + $running = GetValue($this->isRunningId); + if($running != 0) { + if ($running == 1) { + ENO_SwitchMode($this->instanceId, true); + } else if ($running == 2) { + ENO_SwitchMode($this->instanceId, false); + } else { + } + SetValue($this->isRunningId, 0); } } - } /** @}*/ diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_FS20.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_FS20.class.php index 1c3690a..05e3814 100644 --- a/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_FS20.class.php +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_FS20.class.php @@ -19,7 +19,9 @@ * Version 2.50.1, 31.01.2012
*/ - abstract class IPSComponentShutter_FS20 extends IPSComponentShutter { + IPSUtils_Include ('IPSComponentShutter.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentShutter'); + + class IPSComponentShutter_FS20 extends IPSComponentShutter { private $instanceId; private $isRunningId; @@ -35,14 +37,27 @@ public function __construct($instanceId) { $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); $this->isRunningId = @IPS_GetObjectIDByIdent('isrunning', $this->instanceId); if($this->isRunningId===false) { - $this->isRunningId = IPS_CreateVariable($this->instanceId); - IPS_SetParent($this->isRunningId, $id); + $this->isRunningId = IPS_CreateVariable(0); + IPS_SetParent($this->isRunningId, $this->instanceId); IPS_SetName($this->isRunningId, 'IsRunning'); IPS_SetIdent($this->isRunningId, 'isrunning'); IPS_SetInfo($this->isRunningId, "This Variable was created by Script IPSComponentShutter_FS20"); } } + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + /** * @public * @@ -65,7 +80,7 @@ public function HandleEvent($variable, $value, IPSModuleShutter $module){ */ public function MoveUp(){ if(!GetValue($this->isRunningId)) { - FS20_SwitchMode($this->InstanceId, true); + FS20_SwitchMode($this->instanceId, true); SetValue($this->isRunningId, true); } } @@ -77,7 +92,7 @@ public function MoveUp(){ */ public function MoveDown(){ if(!GetValue($this->isRunningId)) { - FS20_SwitchMode($this->InstanceId, false); + FS20_SwitchMode($this->instanceId, false); SetValue($this->isRunningId, true); } } @@ -89,8 +104,8 @@ public function MoveDown(){ */ public function Stop() { if(GetValue($this->isRunningId)) { - $value = GetValue(IPS_GetObjectIDByIdent($this->InstanceId, "StatusVariable") - FS20_SwitchMode($this->InstanceId, $value); + $value = GetValue(IPS_GetObjectIDByIdent("StatusVariable", $this->instanceId)); + FS20_SwitchMode($this->instanceId, $value); SetValue($this->isRunningId, false); } } diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_Homematic.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_Homematic.class.php index dda998d..e561a7b 100644 --- a/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_Homematic.class.php +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_Homematic.class.php @@ -19,19 +19,24 @@ * Version 2.50.1, 31.01.2012
*/ - abstract class IPSComponentShutter_Homematic extends IPSComponentShutter { + IPSUtils_Include ('IPSComponentShutter.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentShutter'); + + class IPSComponentShutter_Homematic extends IPSComponentShutter { private $instanceId; - + private $reverseControl; + /** * @public * * Initialisierung eines IPSComponentShutter_Homematic Objektes * * @param integer $instanceId InstanceId des Homematic Devices + * @param boolean $reverseControl Reverse Ansteuerung des Devices */ - public function __construct($instanceId) { - $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); + public function __construct($instanceId, $reverseControl=false) { + $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); + $this->reverseControl = $reverseControl; } /** @@ -45,6 +50,24 @@ public function __construct($instanceId) { * @param IPSModuleShutter $module Module Object an das das aufgetretene Event weitergeleitet werden soll */ public function HandleEvent($variable, $value, IPSModuleShutter $module){ + if ($this->reverseControl) { + $module->SyncPosition(($value*100), $this); + } else { + $module->SyncPosition(100-($value*100), $this); + } + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; } /** @@ -53,7 +76,11 @@ public function HandleEvent($variable, $value, IPSModuleShutter $module){ * Hinauffahren der Beschattung */ public function MoveUp(){ - HM_WriteValueFloat($this->InstanceId , 'LEVEL', 1); + if ($this->reverseControl) { + HM_WriteValueFloat($this->instanceId , 'LEVEL', 0); + } else { + HM_WriteValueFloat($this->instanceId , 'LEVEL', 1); + } } /** @@ -62,7 +89,11 @@ public function MoveUp(){ * Hinunterfahren der Beschattung */ public function MoveDown(){ - HM_WriteValueFloat($this->InstanceId , 'LEVEL', 0); + if ($this->reverseControl) { + HM_WriteValueFloat($this->instanceId , 'LEVEL', 1); + } else { + HM_WriteValueFloat($this->instanceId , 'LEVEL', 0); + } } /** @@ -71,7 +102,7 @@ public function MoveDown(){ * Stop */ public function Stop() { - HM_WriteValueFloat($this->InstanceId , 'STOP', true); + HM_WriteValueBoolean($this->instanceId , 'STOP', true); } } diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_HomematicRelay.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_HomematicRelay.class.php new file mode 100644 index 0000000..7cbd7d6 --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_HomematicRelay.class.php @@ -0,0 +1,105 @@ + + */ + + IPSUtils_Include ('IPSComponentShutter.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentShutter'); + + class IPSComponentShutter_HomematicRelay extends IPSComponentShutter { + + private $instanceId1; + private $instanceId2; + private $directionSwitch; + + + /** + * @public + * + * Initialisierung eines IPSComponentShutter_HomematicRelay Objektes + * + * @param integer $instanceId1 InstanceId 1 des HM Devices (Movement) + * @param integer $instanceId2 InstanceId 2 des HM Devices (Direction) + * @param boolean $directionSwitch Richtungs Schalter (default=false) + */ + public function __construct($instanceId1, $instanceId2, $directionSwitch=false) { + $this->instanceId1 = IPSUtil_ObjectIDByPath($instanceId1); + $this->instanceId2 = IPSUtil_ObjectIDByPath($instanceId2); + $this->directionSwitch = $directionSwitch; + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId1.','.$this->instanceId2; + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleShutter $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleShutter $module){ + $name = IPS_GetName($variable); + throw new IPSComponentException('Event Handling NOT supported for Variable '.$variable.'('.$name.')'); + } + + /** + * @public + * + * Hinauffahren der Beschattung + */ + public function MoveUp() { + HM_WriteValueBoolean($this->instanceId1, 'STATE', true); + HM_WriteValueBoolean($this->instanceId2, 'STATE', $this->directionSwitch); + } + + /** + * @public + * + * Hinunterfahren der Beschattung + */ + public function MoveDown() { + HM_WriteValueBoolean($this->instanceId1, 'STATE', true); + HM_WriteValueBoolean($this->instanceId2, 'STATE', !$this->directionSwitch); + } + + /** + * @public + * + * Stop + */ + public function Stop() { + HM_WriteValueBoolean($this->instanceId1, 'STATE', false); + } + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_IPSShutterControl.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_IPSShutterControl.class.php index 265d96d..1e043f9 100644 --- a/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_IPSShutterControl.class.php +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_IPSShutterControl.class.php @@ -19,7 +19,9 @@ * Version 2.50.1, 31.01.2012
*/ - abstract class IPSComponentShutter_IPSShutterControl extends IPSComponentShutter { + IPSUtils_Include ('IPSComponentShutter.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentShutter'); + + class IPSComponentShutter_IPSShutterControl extends IPSComponentShutter { private $instanceId; @@ -34,6 +36,19 @@ public function __construct($instanceId) { $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); } + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + /** * @public * diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_LCN.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_LCN.class.php index 23a7b32..e6c6e77 100644 --- a/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_LCN.class.php +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_LCN.class.php @@ -19,7 +19,9 @@ * Version 2.50.1, 31.01.2012
*/ - abstract class IPSComponentShutter_LCN extends IPSComponentShutter { + IPSUtils_Include ('IPSComponentShutter.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentShutter'); + + class IPSComponentShutter_LCN extends IPSComponentShutter { private $instanceId1; private $instanceId2; @@ -42,6 +44,19 @@ public function __construct($instanceId1, $instanceId2, $directionSwitch=false) $this->unitType = LCN_GetUnit($this->instanceId1); } + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId1.','.$this->instanceId2; + } + /** * @public * @@ -68,8 +83,8 @@ public function MoveUp(){ LCN_SetIntensity($this->instanceId1,100,4); break; case 2: - LCN_SwitchRelay($this->instanceId1, true); LCN_SwitchRelay($this->instanceId2, $this->directionSwitch); + LCN_SwitchRelay($this->instanceId1, true); break; default: throw new IPSComponentException('Unknown Unittype '.$this->unitType.' for LCN Device with ID='.$this->instanceId1); @@ -87,8 +102,8 @@ public function MoveDown(){ LCN_SetIntensity($this->instanceId1,100,4); break; case 2: + LCN_SwitchRelay($this->instanceId2, !$this->directionSwitch); LCN_SwitchRelay($this->instanceId1, true); - LCN_SwitchRelay($this->instanceId2, $this->directionSwitch); break; default: throw new IPSComponentException('Unknown Unittype '.$this->unitType.' for LCN Device with ID='.$this->instanceId1); diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_MoellerEaton.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_MoellerEaton.class.php index 8ef57b3..1a35b72 100644 --- a/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_MoellerEaton.class.php +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_MoellerEaton.class.php @@ -19,7 +19,9 @@ * Version 2.50.1, 31.01.2012
*/ - abstract class IPSComponentShutter_MoellerEaton extends IPSComponentShutter { + IPSUtils_Include ('IPSComponentShutter.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentShutter'); + + class IPSComponentShutter_MoellerEaton extends IPSComponentShutter { private $instanceId; @@ -34,6 +36,20 @@ public function __construct($instanceId) { $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + /** * @public * diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_digitalStrom.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_digitalStrom.class.php new file mode 100644 index 0000000..8ab6c2f --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_digitalStrom.class.php @@ -0,0 +1,97 @@ + + */ + + IPSUtils_Include ('IPSComponentShutter.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentShutter'); + + class IPSComponentShutter_digitalStrom extends IPSComponentShutter { + + private $instanceId; + + /** + * @public + * + * Initialisierung eines IPSComponentShutter_digitalStrom Objektes + * + * @param integer $instanceId InstanceId des digitalStrom Devices + */ + public function __construct($instanceId) { + $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleShutter $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleShutter $module){ + $name = IPS_GetName($variable); + throw new IPSComponentException('Event Handling NOT supported for Variable '.$variable.'('.$name.')'); + } + + /** + * @public + * + * Hinauffahren der Beschattung + */ + public function MoveUp(){ + DS_ShutterMoveUp($this->instanceId); + } + + /** + * @public + * + * Hinunterfahren der Beschattung + */ + public function MoveDown(){ + DS_ShutterMoveDown($this->instanceId); + } + + /** + * @public + * + * Stop + */ + public function Stop() { + DS_ShutterStop($this->instanceId); + } + + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_zwave.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_zwave.class.php new file mode 100644 index 0000000..a7ee782 --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSComponentShutter_zwave.class.php @@ -0,0 +1,111 @@ +< + */ + + IPSUtils_Include ('IPSComponentShutter.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentShutter'); + + class IPSComponentShutter_zwave extends IPSComponentShutter { + + private $instanceId; + private $reverseControl; + + /** + * @public + * + * Initialisierung eines IPSComponentShutter_zwave Objektes + * + * @param integer $instanceId InstanceId des Homematic Devices + * @param boolean $reverseControl Reverse Ansteuerung des Devices + */ + public function __construct($instanceId, $reverseControl=false) { + $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); + $this->reverseControl = $reverseControl; + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleShutter $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleShutter $module){ + if ($this->reverseControl) { + $module->SyncPosition(($value*100), $this); + } else { + $module->SyncPosition(100-($value*100), $this); + } + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + + /** + * @public + * + * Hinauffahren der Beschattung + */ + public function MoveUp(){ + if ($this->reverseControl) { + ZW_ShutterMoveDown($this->instanceId); + } else { + ZW_ShutterMoveUp($this->instanceId); + } + } + + /** + * @public + * + * Hinunterfahren der Beschattung + */ + public function MoveDown(){ + if ($this->reverseControl) { + ZW_ShutterMoveUp($this->instanceId); + } else { + ZW_ShutterMoveDown($this->instanceId); + } + } + + /** + * @public + * + * Stop + */ + public function Stop() { + ZW_ShutterStop ($this->instanceId); + } + + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSModuleShutter.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSModuleShutter.class.php index 54420a0..14c6d32 100644 --- a/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSModuleShutter.class.php +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSModuleShutter.class.php @@ -29,7 +29,7 @@ abstract class IPSModuleShutter extends IPSModule { * * @param string $position Aktuelle Position der Beschattung (Wertebereich 0-100) */ - abstract public function SyncPosition($position); + abstract public function SyncPosition($position, IPSComponentShutter $component); } diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSModuleShutter_IPSShadowing.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSModuleShutter_IPSShadowing.class.php new file mode 100644 index 0000000..0d1e99c --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentShutter/IPSModuleShutter_IPSShadowing.class.php @@ -0,0 +1,55 @@ + + */ + + IPSUtils_Include ("IPSShadowing.inc.php", "IPSLibrary::app::modules::IPSShadowing"); + IPSUtils_Include ('IPSModuleShutter.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentShutter'); + + class IPSModuleShutter_IPSShadowing extends IPSModuleShutter { + + /** + * @public + * + * Ermöglicht die Synchronisation der aktuellen Position der Beschattung + * + * @param string $position Aktuelle Position der Beschattung (Wertebereich 0-100) + */ + public function SyncPosition($position, IPSComponentShutter $componentToSync) { + $componentParamsToSync = $componentToSync->GetComponentParams(); + $deviceConfig = get_ShadowingConfiguration(); + foreach ($deviceConfig as $deviceIdent=>$deviceData) { + $componentConfig = IPSComponent::CreateObjectByParams($deviceData[c_Property_Component]); + $componentParamsConfig = $componentConfig->GetComponentParams(); + if ($componentParamsConfig==$componentParamsToSync) { + $categoryIdDevices = IPSUtil_ObjectIDByPath('Program.IPSLibrary.data.modules.IPSShadowing.Devices'); + $deviceId = IPS_GetObjectIDByIdent($deviceIdent, $categoryIdDevices); + + $device = new IPSShadowing_Device($deviceId); + $device->MoveByEvent($position); + } + } + } + + + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch.class.php index 8443b15..d8c693c 100644 --- a/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch.class.php +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch.class.php @@ -20,6 +20,8 @@ * Version 2.50.1, 31.01.2012
*/ + IPSUtils_Include ('IPSComponent.class.php', 'IPSLibrary::app::core::IPSComponent'); + abstract class IPSComponentSwitch extends IPSComponent { /** @@ -40,8 +42,10 @@ abstract public function HandleEvent($variable, $value, IPSModuleSwitch $module) * Zustand Setzen * * @param boolean $value Wert für Schalter + * @param integer $onTime Zeit in Sekunden nach der der Aktor automatisch ausschalten soll (ACHTUNG: wird nicht von + * allen Hardware Komponenten unterstützt). */ - abstract public function SetState($value); + abstract public function SetState($value, $onTime=false); /** * @public diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_1WireD2408.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_1WireD2408.class.php index abddba5..22c5e11 100644 --- a/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_1WireD2408.class.php +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_1WireD2408.class.php @@ -32,10 +32,24 @@ class IPSComponentSwitch_1WireD2408 extends IPSComponentSwitch { * Initialisierung eines IPSComponentSwitch_1WireD2408 Objektes * * @param integer $instanceId InstanceId des 1WireD2408 Devices + * @param integer $channelId Kanal des 1WireD2408 Devices */ public function __construct($instanceId, $channelId) { $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); - $this->channelId = $channelId; + $this->channelId = (int)$channelId; + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId.','.$this->channelId; } /** @@ -49,6 +63,7 @@ public function __construct($instanceId, $channelId) { * @param IPSModuleSwitch $module Module Object an das das aufgetretene Event weitergeleitet werden soll */ public function HandleEvent($variable, $value, IPSModuleSwitch $module){ + $module->SyncState($value, $this); } /** @@ -57,8 +72,9 @@ public function HandleEvent($variable, $value, IPSModuleSwitch $module){ * Zustand Setzen * * @param boolean $value Wert für Schalter + * @param integer $onTime Zeit in Sekunden nach der der Aktor automatisch ausschalten soll (nicht unterstützt) */ - public function SetState($value) { + public function SetState($value, $onTime=false) { TMEX_F29_SetPin($this->instanceId, $this->channelId, $value); } diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_1WireD2413.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_1WireD2413.class.php new file mode 100644 index 0000000..def604e --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_1WireD2413.class.php @@ -0,0 +1,95 @@ + + */ + + IPSUtils_Include ('IPSComponentSwitch.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentSwitch'); + + class IPSComponentSwitch_1WireD2413 extends IPSComponentSwitch { + + private $instanceId; + private $channelId; + + /** + * @public + * + * Initialisierung eines IPSComponentSwitch_1WireD2413 Objektes + * + * @param integer $instanceId InstanceId des 1WireD2413 Devices + * @param integer $channelId Kanal des 1WireD2413 Devices + */ + public function __construct($instanceId, $channelId) { + $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); + $this->channelId = (int)$channelId; + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId.','.$this->channelId; + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleSwitch $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleSwitch $module){ + $module->SyncState($value, $this); + } + + /** + * @public + * + * Zustand Setzen + * + * @param boolean $value Wert für Schalter + * @param integer $onTime Zeit in Sekunden nach der der Aktor automatisch ausschalten soll (nicht unterstützt) + */ + public function SetState($value, $onTime=false) { + TMEX_F3A_SetPin($this->instanceId, $this->channelId, $value); + } + + /** + * @public + * + * Liefert aktuellen Zustand + * + * @return boolean aktueller Schaltzustand + */ + public function GetState() { + return null; + } + + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_ALLNET.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_ALLNET.class.php new file mode 100644 index 0000000..cc479b8 --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_ALLNET.class.php @@ -0,0 +1,92 @@ + + */ + + IPSUtils_Include ('IPSComponentSwitch.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentSwitch'); + + class IPSComponentSwitch_ALLNET extends IPSComponentSwitch { + + private $instanceId; + + /** + * @public + * + * Initialisierung eines IPSComponentSwitch_ALLNET Objektes + * + * @param integer $instanceId InstanceId des ALLNET Devices + */ + public function __construct($instanceId) { + $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleSwitch $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleSwitch $module){ + $module->SyncState($value, $this); + } + + /** + * @public + * + * Zustand Setzen + * + * @param boolean $value Wert für Schalter + */ + public function SetState($value) { + ALL_SwitchMode($this->instanceId, $value); + } + + /** + * @public + * + * Liefert aktuellen Zustand + * + * @return boolean aktueller Schaltzustand + */ + public function GetState() { + $value = GetValueBoolean(IPS_GetObjectIDByIdent("StatusVariable",$this->instanceId)); + return $value; + } + + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_DMX.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_DMX.class.php new file mode 100644 index 0000000..d9b0614 --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_DMX.class.php @@ -0,0 +1,99 @@ + + */ + + IPSUtils_Include ('IPSComponentSwitch.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentSwitch'); + + class IPSComponentSwitch_DMX extends IPSComponentSwitch { + + private $instanceId; + private $channelId; + + /** + * @public + * + * Initialisierung eines IPSComponentSwitch_DMX Objektes + * + * @param integer $instanceId InstanceId des DMX Devices + * @param integer $channelId Kanal des DMX Devices + */ + public function __construct($instanceId, $channelId) { + $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); + $this->channelId = (int)$channelId; + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId.','.$this->channelId; + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleSwitch $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleSwitch $module){ + $module->SyncState($value, $this); + } + + /** + * @public + * + * Zustand Setzen + * + * @param boolean $value Wert für Schalter + * @param integer $onTime Zeit in Sekunden nach der der Aktor automatisch ausschalten soll (nicht unterstützt) + */ + public function SetState($value, $onTime=false) { + if ($value) { + DMX_SetValue ($this->instanceId, $this->channel1, 255); + } else { + DMX_SetValue ($this->instanceId, $this->channel1, 0); + } + } + + /** + * @public + * + * Liefert aktuellen Zustand + * + * @return boolean aktueller Schaltzustand + */ + public function GetState() { + return null; + } + + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_Dummy.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_Dummy.class.php index 9caac34..dcc8a5a 100644 --- a/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_Dummy.class.php +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_Dummy.class.php @@ -36,6 +36,19 @@ public function __construct($instanceId) { $this->instanceId = $instanceId; } + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + /** * @public * @@ -55,9 +68,13 @@ public function HandleEvent($variable, $value, IPSModuleSwitch $module){ * Zustand Setzen * * @param boolean $value Wert für Schalter + * @param integer $onTime Zeit in Sekunden nach der der Aktor automatisch ausschalten soll (nicht unterstützt) */ - public function SetState($value) { - IPSLogger_Trc(__file__, 'Activate Dummy-Switch "'.$this->instanceId.'", Value='.($value?'On':'Off')); + public function SetState($value, $onTime=false) { + if ($onTime!==false and $value) + IPSLogger_Trc(__file__, 'Activate Dummy-Switch "'.$this->instanceId.'", Value='.($value?'On':'Off').', OnTime='.$onTime); + else + IPSLogger_Trc(__file__, 'Activate Dummy-Switch "'.$this->instanceId.'", Value='.($value?'On':'Off')); } /** diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_EIB.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_EIB.class.php new file mode 100644 index 0000000..65441fa --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_EIB.class.php @@ -0,0 +1,92 @@ + + */ + + IPSUtils_Include ('IPSComponentSwitch.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentSwitch'); + + class IPSComponentSwitch_EIB extends IPSComponentSwitch { + + private $instanceId; + + /** + * @public + * + * Initialisierung eines IPSComponentSwitch_EIB Objektes + * + * @param integer $instanceId InstanceId des EIB Devices + */ + public function __construct($instanceId) { + $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleSwitch $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleSwitch $module){ + $module->SyncState($value, $this); + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + + /** + * @public + * + * Zustand Setzen + * + * @param boolean $value Wert für Schalter + * @param integer $onTime Zeit in Sekunden nach der der Aktor automatisch ausschalten soll (nicht unterstützt) + */ + public function SetState($value, $onTime=false) { + EIB_Switch($this->instanceId, $value); + } + + /** + * @public + * + * Liefert aktuellen Zustand + * + * @return boolean aktueller Schaltzustand + */ + public function GetState() { + GetValue(IPS_GetVariableIDByName('Value', $this->instanceId)); + } + + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_EatonMoeller.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_EatonMoeller.class.php new file mode 100644 index 0000000..412ebb6 --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_EatonMoeller.class.php @@ -0,0 +1,78 @@ + + */ + + IPSUtils_Include ('IPSComponentSwitch.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentSwitch'); + + class IPSComponentSwitch_EatonMoeller extends IPSComponentSwitch { + + private $instanceId; + + /** + * @public + * + * Initialisierung eines IPSComponentSwitch_EatonMoeller Objektes + * + * @param integer $instanceId InstanceId des EatonMoeller Devices + */ + public function __construct($instanceId) { + $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleSwitch $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleSwitch $module){ + } + + /** + * @public + * + * Zustand Setzen + * + * @param boolean $value Wert für Schalter + * @param integer $onTime Zeit in Sekunden nach der der Aktor automatisch ausschalten soll (nicht unterstützt) + */ + public function SetState($value, $onTime=false) { + MXC_SwitchMode($this->instanceId, $value); + } + + /** + * @public + * + * Liefert aktuellen Zustand + * + * @return boolean aktueller Schaltzustand + */ + public function GetState() { + GetValue(IPS_GetVariableIDByName('Status', $this->instanceId)); + } + + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_Enocean.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_Enocean.class.php new file mode 100644 index 0000000..19dac57 --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_Enocean.class.php @@ -0,0 +1,92 @@ + + */ + + IPSUtils_Include ('IPSComponentSwitch.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentSwitch'); + + class IPSComponentSwitch_Enocean extends IPSComponentSwitch { + + private $instanceId; + + /** + * @public + * + * Initialisierung eines IPSComponentSwitch_Enocean Objektes + * + * @param integer $instanceId InstanceId des Homematic Devices + */ + public function __construct($instanceId) { + $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleSwitch $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleSwitch $module){ + $module->SyncState($value, $this); + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + + /** + * @public + * + * Zustand Setzen + * + * @param boolean $value Wert für Schalter + * @param integer $onTime Zeit in Sekunden nach der der Aktor automatisch ausschalten soll + */ + public function SetState($value, $onTime=false) { + ENO_SwitchMode($this->instanceId, $value); + } + + /** + * @public + * + * Liefert aktuellen Zustand + * + * @return boolean aktueller Schaltzustand + */ + public function GetState() { + GetValue(IPS_GetVariableIDByIdent('STATE', $this->instanceId)); + } + + } + + /** @}*/ +?> diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_FS20.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_FS20.class.php index 9c66567..b311f3b 100644 --- a/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_FS20.class.php +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_FS20.class.php @@ -36,6 +36,19 @@ public function __construct($instanceId) { $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); } + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + /** * @public * @@ -47,6 +60,7 @@ public function __construct($instanceId) { * @param IPSModuleSwitch $module Module Object an das das aufgetretene Event weitergeleitet werden soll */ public function HandleEvent($variable, $value, IPSModuleSwitch $module){ + $module->SyncState($value, $this); } /** @@ -55,9 +69,13 @@ public function HandleEvent($variable, $value, IPSModuleSwitch $module){ * Zustand Setzen * * @param boolean $value Wert für Schalter + * @param integer $onTime Zeit in Sekunden nach der der Aktor automatisch ausschalten soll */ - public function SetState($value) { - FS20_SwitchMode($this->instanceId, $value); + public function SetState($value, $onTime=false) { + if (!$onTime or !$value) + FS20_SwitchMode($this->instanceId, $value); + else + FS20_SwitchDuration($this->instanceId, $value, $onTime); } /** @@ -68,7 +86,9 @@ public function SetState($value) { * @return boolean aktueller Schaltzustand */ public function GetState() { - return null; + $value = GetValueBoolean(IPS_GetObjectIDByIdent("StatusVariable",$this->instanceId)); + return $value; + } } diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_Homematic.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_Homematic.class.php index fff4910..7328b51 100644 --- a/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_Homematic.class.php +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_Homematic.class.php @@ -24,6 +24,7 @@ class IPSComponentSwitch_Homematic extends IPSComponentSwitch { private $instanceId; + private $supportsOnTime; /** * @public @@ -31,9 +32,11 @@ class IPSComponentSwitch_Homematic extends IPSComponentSwitch { * Initialisierung eines IPSComponentSwitch_Homematic Objektes * * @param integer $instanceId InstanceId des Homematic Devices + * @param integer $supportsOnTime spezifiziert ob das Homematic Device eine ONTIME unterstützt */ - public function __construct($instanceId) { - $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); + public function __construct($instanceId, $supportsOnTime=true) { + $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); + $this->supportsOnTime = $supportsOnTime; } /** @@ -47,6 +50,20 @@ public function __construct($instanceId) { * @param IPSModuleSwitch $module Module Object an das das aufgetretene Event weitergeleitet werden soll */ public function HandleEvent($variable, $value, IPSModuleSwitch $module){ + $module->SyncState($value, $this); + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; } /** @@ -55,8 +72,12 @@ public function HandleEvent($variable, $value, IPSModuleSwitch $module){ * Zustand Setzen * * @param boolean $value Wert für Schalter + * @param integer $onTime Zeit in Sekunden nach der der Aktor automatisch ausschalten soll */ - public function SetState($value) { + public function SetState($value, $onTime=false) { + if ($onTime!==false and $value and $this->supportsOnTime===true) + HM_WriteValueFloat($this->instanceId, "ON_TIME", $onTime); + HM_WriteValueBoolean($this->instanceId, "STATE", $value); } @@ -68,7 +89,7 @@ public function SetState($value) { * @return boolean aktueller Schaltzustand */ public function GetState() { - GetValue(IPS_GetVariableIDByName('STATE', $this->instanceId)); + GetValue(IPS_GetVariableIDByIdent('STATE', $this->instanceId)); } } diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_LCN.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_LCN.class.php new file mode 100644 index 0000000..7095948 --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_LCN.class.php @@ -0,0 +1,92 @@ + + */ + + IPSUtils_Include ('IPSComponentSwitch.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentSwitch'); + + class IPSComponentSwitch_LCN extends IPSComponentSwitch { + + private $instanceId; + + /** + * @public + * + * Initialisierung eines IPSComponentSwitch_LCN Objektes + * + * @param integer $instanceId InstanceId des LCN Devices + */ + public function __construct($instanceId) { + $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleSwitch $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleSwitch $module){ + $module->SyncState($value, $this); + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + + /** + * @public + * + * Zustand Setzen + * + * @param boolean $value Wert für Schalter + * @param integer $onTime Zeit in Sekunden nach der der Aktor automatisch ausschalten soll (nicht unterstützt) + */ + public function SetState($value, $onTime=false) { + LCN_SwitchRelay($this->instanceId, $value); + } + + /** + * @public + * + * Liefert aktuellen Zustand + * + * @return boolean aktueller Schaltzustand + */ + public function GetState() { + GetValue(IPS_GetVariableIDByName('Status', $this->instanceId)); + } + + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_LCNa.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_LCNa.class.php new file mode 100644 index 0000000..ad290ba --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_LCNa.class.php @@ -0,0 +1,98 @@ + + */ + + IPSUtils_Include ('IPSComponentSwitch.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentSwitch'); + + class IPSComponentSwitch_LCNa extends IPSComponentSwitch { + + private $instanceId; + + /** + * @public + * + * Initialisierung eines IPSComponentSwitch_LCNa Objektes + * + * @param integer $instanceId InstanceId des LCN Devices + */ + public function __construct($instanceId) { + $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleSwitch $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleSwitch $module) { + if ($value > 0) + $module->SyncState(true, $this); + else + $module->SyncState(false, $this); + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId; + } + + /** + * @public + * + * Zustand Setzen + * + * @param boolean $value Wert für Schalter + * @param integer $onTime Zeit in Sekunden nach der der Aktor automatisch ausschalten soll (nicht unterstützt) + */ + public function SetState($value, $onTime=false) { + if ($value) + LCN_SetIntensity($this->instanceId, 100, 0.2); + else + LCN_SetIntensity($this->instanceId, 0, 0.2); + } + + /** + * @public + * + * Liefert aktuellen Zustand + * + * @return boolean aktueller Schaltzustand + */ + public function GetState() { + GetValue(IPS_GetVariableIDByName('Intensity', $this->instanceId)); + } + + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_ModBus.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_ModBus.class.php new file mode 100644 index 0000000..3050846 --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_ModBus.class.php @@ -0,0 +1,79 @@ + + */ + + IPSUtils_Include ('IPSComponentSwitch.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentSwitch'); + + class IPSComponentSwitch_ModBus extends IPSComponentSwitch { + + private $instanceId; + + /** + * @public + * + * Initialisierung eines IPSComponentSwitch_ModBus Objektes + * + * @param integer $instanceId InstanceId des ModBus Devices + */ + public function __construct($instanceId) { + $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleSwitch $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleSwitch $module){ + $module->SyncState($value, $this); + } + + /** + * @public + * + * Zustand Setzen + * + * @param boolean $value Wert für Schalter + * @param integer $onTime Zeit in Sekunden nach der der Aktor automatisch ausschalten soll (nicht unterstützt) + */ + public function SetState($value, $onTime=false) { + ModBus_WriteCoil($this->instanceId, $value); + } + + /** + * @public + * + * Liefert aktuellen Zustand + * + * @return boolean aktueller Schaltzustand + */ + public function GetState() { + GetValue(IPS_GetObjectIDByIdent('Value', $this->instanceId)); + } + + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_Plugwise.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_Plugwise.class.php new file mode 100644 index 0000000..71afd5b --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_Plugwise.class.php @@ -0,0 +1,138 @@ + + */ + + IPSUtils_Include ('IPSComponentSwitch.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentSwitch'); + IPSUtils_Include("Plugwise_Include.ips.php","IPSLibrary::app::hardware::Plugwise"); + IPSUtils_Include ('IPSMessageHandler.class.php', 'IPSLibrary::app::core::IPSMessageHandler'); + + class IPSComponentSwitch_Plugwise extends IPSComponentSwitch { + + private $instanceId; + + /** + * @public + * + * Initialisierung eines IPSComponentSwitch_Plugwise Objektes + * + * @param integer $instanceId InstanceId des Plugwise Devices + */ + public function __construct($instanceId) + { + // automatischen Einbinden/Konfiguration + // wenn schon vorhanden dann ohne Einfluss + $var = (int)$instanceId; + + $component = "IPSComponentSwitch_Plugwise,".$var; + $module = "IPSModuleSwitch_IPSLight"; + + $messageHandler = new IPSMessageHandler(); + + $messageHandler->RegisterOnChangeEvent($var, $component, $module); + + $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); + + + + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + + return get_class($this).','.$this->instanceId; + + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleSwitch $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleSwitch $module){ + $module->SyncState($value, $this); + IPS_LogMessage(__File__,"Variable ".$variable." sync"); + + } + + /** + * @public + * + * Zustand Setzen + * + * @param boolean $value Wert für Schalter + */ + public function SetState($value,$onTime=false) { + + // Gibt es die Variable ? + $exist = IPS_VariableExists($this->instanceId); + if ( !$exist) + { + IPS_LogMessage(__File__,"Variable ".$this->instanceId." existiert nicht"); + return; + } + $parent = @IPS_GetParent($this->instanceId); + $obj = @IPS_GetObject ( $parent ); + if ( !$obj ) + { + IPS_LogMessage(__File__,"ParentVariable ".$parent." existiert nicht"); + return; + } + $ident = $obj['ObjectIdent']; + + $state = circle_on_off($ident,$value); + return $state; + } + + /** + * @public + * + * Liefert aktuellen Zustand + * + * @return boolean aktueller Schaltzustand + */ + public function GetState() { + //$value = GetValueBoolean(IPS_GetObjectIDByIdent("StatusVariable",$this->instanceId)); + $VarId = @IPS_GetVariableIDByName("Status",$this->instanceId); + if ( !$VarId ) + { + IPS_LogMessage(__File__,"Variable Status von ".$this->instanceId." existiert nicht"); + return; + } + + return $value; + } + + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_ZW.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_ZW.class.php new file mode 100644 index 0000000..d8b5f22 --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSComponentSwitch_ZW.class.php @@ -0,0 +1,130 @@ + + */ + + IPSUtils_Include ('IPSComponentSwitch.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentSwitch'); + + class IPSComponentSwitch_ZW extends IPSComponentSwitch { + + private $instanceId; + private $channel; + + // Welche Klassen unterstütz der Schalter? + private $b_class_basic = false; + private $b_class_switch = false; + private $b_class_multi = false; + + /** + * @public + * + * Initialisierung eines IPSComponentSwitch_ZW_Basic Objektes + * + * @param integer $instanceId InstanceId des Z-Wave Devices + */ + public function __construct($instanceId, $channel=0) { + $this->instanceId = IPSUtil_ObjectIDByPath($instanceId); + // Bei Multiinstanz fähigen Schalter gleich den Kanal merken + $this->channel = (int)$channel; + //Ermittlung der unterstützten Klassen + $classes = ZW_GetNodeClasses((int)$instanceId); + foreach ($classes as $class) { + switch ((int)$class){ + case 32: + $this->b_class_basic = true; + break; + case 37: + $this->b_class_switch = true; + break; + case 96: + $this->b_class_multi = true; + break; + } + } + + } + + /** + * @public + * + * Funktion liefert String IPSComponent Constructor String. + * String kann dazu benützt werden, das Object mit der IPSComponent::CreateObjectByParams + * wieder neu zu erzeugen. + * + * @return string Parameter String des IPSComponent Object + */ + public function GetComponentParams() { + return get_class($this).','.$this->instanceId.','.$this->channel; + } + + /** + * @public + * + * Function um Events zu behandeln, diese Funktion wird vom IPSMessageHandler aufgerufen, um ein aufgetretenes Event + * an das entsprechende Module zu leiten. + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param IPSModuleSwitch $module Module Object an das das aufgetretene Event weitergeleitet werden soll + */ + public function HandleEvent($variable, $value, IPSModuleSwitch $module){ + $module->SyncState($value, $this); + } + + /** + * @public + * + * Zustand Setzen + * + * @param boolean $value Wert für Schalter + * @param integer $onTime Zeit in Sekunden nach der der Aktor automatisch ausschalten soll (nicht unterstützt) + */ + public function SetState($value, $onTime=false) { + // Ein Binary Switch + if ($this->b_class_switch and ($this->channel == 0)) + ZW_SwitchMode((int)$this->instanceId, $value); + // Ein Basic Switch + elseif ($this->b_class_basic and ($this->channel == 0)) + ZW_Basic((int)$this->instanceId, $value); + // Ein Multiswitch + elseif (($this->channel > 0) and $this->b_class_multi) + ZW_SwitchModeEx((int)$this->instanceId, $value, $this->channel); + } + + /** + * @public + * + * Liefert aktuellen Zustand + * + * @return boolean aktueller Schaltzustand + */ + public function GetState() { + if ($this->b_class_multi and ($this->channel > 0)) + $id = @IPS_GetObjectIDByIdent("MultiInstance".$this->channel."Variable",(int)$this->instanceId); + else + $id = @IPS_GetObjectIDByIdent("DataVariableBoolean",(int)$this->instanceId); + + if ($id > 0) + return GetValue($id); + else + return false; + } + + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSModuleSwitch.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSModuleSwitch.class.php index 4667738..81c1df0 100644 --- a/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSModuleSwitch.class.php +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSModuleSwitch.class.php @@ -29,7 +29,7 @@ abstract class IPSModuleSwitch extends IPSModule { * * @param boolean $state aktueller Status des Gerätes */ - abstract public function SyncState($state); + abstract public function SyncState($state, IPSComponentSwitch $componentToSync); } diff --git a/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSModuleSwitch_IPSLight.class.php b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSModuleSwitch_IPSLight.class.php new file mode 100644 index 0000000..4ae100c --- /dev/null +++ b/IPSLibrary/app/core/IPSComponent/IPSComponentSwitch/IPSModuleSwitch_IPSLight.class.php @@ -0,0 +1,52 @@ + + */ + + IPSUtils_Include ("IPSLight.inc.php", "IPSLibrary::app::modules::IPSLight"); + IPSUtils_Include ('IPSModuleSwitch.class.php', 'IPSLibrary::app::core::IPSComponent::IPSComponentSwitch'); + + class IPSModuleSwitch_IPSLight extends IPSModuleSwitch { + + /** + * @public + * + * Ermöglicht die Synchronisation einer Beleuchtung zu IPSLight + * + * @param string $state Aktueller Status des Switch + */ + public function SyncState($state, IPSComponentSwitch $componentToSync) { + $componentParamsToSync = $componentToSync->GetComponentParams(); + $deviceConfig = IPSLight_GetLightConfiguration(); + foreach ($deviceConfig as $deviceIdent=>$deviceData) { + $componentConfig = IPSComponent::CreateObjectByParams($deviceData[IPSLIGHT_COMPONENT]); + $componentParamsConfig = $componentConfig->GetComponentParams(); + if ($componentParamsConfig==$componentParamsToSync) { + $lightManager = new IPSLight_Manager(); + $lightManager->SynchronizeSwitch($deviceIdent, $state); + } + } + } + + + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSConfigHandler/IPSConfigHandler.class.php b/IPSLibrary/app/core/IPSConfigHandler/IPSConfigHandler.class.php index e3a4608..d97abe0 100644 --- a/IPSLibrary/app/core/IPSConfigHandler/IPSConfigHandler.class.php +++ b/IPSLibrary/app/core/IPSConfigHandler/IPSConfigHandler.class.php @@ -30,12 +30,14 @@ class IPSConfigurationException extends Exception { */ abstract class IPSConfigHandler { - const VERSION = 'Version'; // Current Module Verison + const SCRIPTVERSION = 'Version'; // Current Module Verison (Script) + const INSTALLVERSION = 'InstallVersion'; // Current Module Verison (Installation) const MODULENAMESPACE = 'ModuleNamespace'; // Module Namespace const SOURCEREPOSITORY = 'SourceRepository'; // Pfad/Url zum Source Repository const LOGDIRECTORY = 'LogDirectory'; // Logging Directory + const CHANGELIST = 'ChangeList'; // ChangeList + const REQUIREDMODULES = 'RequiredModules'; // Required Modules - protected $configData = array(); /** @@ -48,10 +50,10 @@ abstract class IPSConfigHandler { * @return boolean liefert Existenz des übergebenen Parameters */ public function ExistsValue($key, $section=null) { - if ($section==null) { - return array_key_exists($key,$this->configData); + if ($section==null) { + return array_key_exists($key,$this->configData); } else { - return (array_key_exists($section,$this->configData) and array_key_exists($key,$this->configData[$section])); + return (array_key_exists($section,$this->configData) and array_key_exists($key,$this->configData[$section])); } } @@ -66,10 +68,10 @@ public function ExistsValue($key, $section=null) { * @throws IPSConfigurationException wenn der betroffene Parameter nicht gefunden wurde */ public function GetValue($key, $section=null) { - if (!$this->ExistsValue($key, $section)) { + if (!$this->ExistsValue($key, $section)) { throw new IPSConfigurationException('Configuration Value with Key='.$key.' could NOT be found (Section="'.$section.'")', - E_USER_ERROR); - } elseif ($section==null) { + E_USER_ERROR); + } elseif ($section==null) { return $this->configData[$key]; } else { return $this->configData[$section][$key]; @@ -87,7 +89,7 @@ public function GetValue($key, $section=null) { * @throws IPSConfigurationException wenn der betroffene Parameter nicht gefunden wurde */ public function GetValueInt ($key, $section=null) { - return (int)$this->GetValue($key, $section); + return (int)$this->GetValue($key, $section); } /** @@ -101,7 +103,14 @@ public function GetValueInt ($key, $section=null) { * @throws IPSConfigurationException wenn der betroffene Parameter nicht gefunden wurde */ public function GetValueBool ($key, $section=null) { - return (boolean)$this->GetValue($key, $section); + $value = $this->GetValue($key, $section); + if ($value=='false') { + return false; + } elseif ($value=='true') { + return true; + } else { + return (boolean)$value; + } } /** @@ -115,7 +124,7 @@ public function GetValueBool ($key, $section=null) { * @throws IPSConfigurationException wenn der betroffene Parameter nicht gefunden wurde */ public function GetValueFloat ($key, $section=null) { - return (float)$this->GetValue($key, $section); + return (float)$this->GetValue($key, $section); } /** @@ -130,14 +139,14 @@ public function GetValueFloat ($key, $section=null) { * @return string liefert den Wert des übergebenen Parameters */ public function GetValueDef($key, $section=null, $defaultValue="") { - if ($section==null) { - if ($this->ExistsValue($key, $section)) { + if ($section==null) { + if ($this->ExistsValue($key, $section)) { $result = $this->configData[$key]; } else { $result = $defaultValue; } } else { - if ($this->ExistsValue($key, $section)) { + if ($this->ExistsValue($key, $section)) { $result = $this->configData[$section][$key]; } else { $result = $defaultValue; @@ -158,7 +167,7 @@ public function GetValueDef($key, $section=null, $defaultValue="") { * @return integer retouniert den Wert des übergebenen Parameters */ public function GetValueIntDef($key, $section=null, $defaultValue="") { - return (int)$this->GetValueDef($key, $section, $defaultValue); + return (int)$this->GetValueDef($key, $section, $defaultValue); } /** @@ -173,7 +182,14 @@ public function GetValueIntDef($key, $section=null, $defaultValue="") { * @return boolean retouniert den Wert des übergebenen Parameters */ public function GetValueBoolDef ($key, $section=null, $defaultValue="") { - return (boolean)$this->GetValueDef($key, $section, $defaultValue); + $value = $this->GetValueDef($key, $section, $defaultValue); + if ($value=='false') { + return false; + } elseif ($value=='true') { + return true; + } else { + return (boolean)$value; + } } /** @@ -188,7 +204,7 @@ public function GetValueBoolDef ($key, $section=null, $defaultValue="") { * @return float retouniert den Wert des übergebenen Parameters */ public function GetValueFloatDef ($key, $section=null, $defaultValue="") { - return (float)$this->GetValueDef($key, $section, $defaultValue); + return (float)$this->GetValueDef($key, $section, $defaultValue); } } diff --git a/IPSLibrary/app/core/IPSConfigHandler/IPSIniConfigHandler.class.php b/IPSLibrary/app/core/IPSConfigHandler/IPSIniConfigHandler.class.php index abf3217..28c2b53 100644 --- a/IPSLibrary/app/core/IPSConfigHandler/IPSIniConfigHandler.class.php +++ b/IPSLibrary/app/core/IPSConfigHandler/IPSIniConfigHandler.class.php @@ -23,41 +23,40 @@ class IPSIniConfigHandler extends IPSConfigHandler { private $iniFileName=""; /** - * @public + * @public * * Initialisierung INI File ConigurationHandlers * - * @param string $iniFileName Name der INI Datei. - * @param string $namespace Namespace des INI Files + * @param string $iniFileName Name der INI Datei. + * @param string $namespace Namespace des INI Files */ public function __construct($iniFileName, $namespace="") { - $this->iniFileName = $this->GetFileName($iniFileName, $namespace); + $this->iniFileName = $this->GetFileName($iniFileName, $namespace); $this->LoadFile($this->iniFileName); - } + } + /** - * @public + * @public * * Initialisierung INI File ConfigHandlers * - * @param string $iniFileName Name der INI Datei. - * @param string $namespace Namespace des INI Files + * @param string $iniFileName Name der INI Datei. + * @param string $namespace Namespace des INI Files */ private function LoadFile () { - if (!file_exists($this->iniFileName)) { + if (!file_exists($this->iniFileName)) { throw new Exception('script '.$this->iniFileName.' could NOT be found!', E_USER_ERROR); } - - $this->configData = parse_ini_file($this->iniFileName, true); + $this->configData = parse_ini_file($this->iniFileName, true); } private function GetFileName ($iniFileName, $namespace="") { - if ($namespace=="") { + if ($namespace=="") { $result = $iniFileName; - } else { + } else { $result = IPS_GetKernelDir().'\\scripts\\'.str_replace('::','\\',$namespace).'\\'.$iniFileName;; - } - - return $result; + } + return $result; } } diff --git a/IPSLibrary/app/core/IPSLogger/IPSLogger.inc.php b/IPSLibrary/app/core/IPSLogger/IPSLogger.inc.php index 10863e6..5d796a9 100644 --- a/IPSLibrary/app/core/IPSLogger/IPSLogger.inc.php +++ b/IPSLibrary/app/core/IPSLogger/IPSLogger.inc.php @@ -129,9 +129,9 @@ function IPSLogger_Fat($LogContext, $LogMessage) { * @param $LogContext - Context of Logging (Identifier or Filename). * @param $LogMessage - Message to be logged */ - function IPSLogger_Err($LogContext, $LogMessage) { - IPSLogger_Out(c_LogLevel_Error, c_LogType_Error, $LogContext, $LogMessage); - } + function IPSLogger_Err($LogContext, $LogMessage) { + IPSLogger_Out(c_LogLevel_Error, c_LogType_Error, $LogContext, $LogMessage); + } // --------------------------------------------------------------------------------------------------------------------------- /** Procedure to log a Warning @@ -151,7 +151,7 @@ function IPSLogger_Wrn($LogContext, $LogMessage) { * @param $Priority - Priority of Notificaton Message (0 means high priority, higher values indicates a lower priority) */ function IPSLogger_Not($LogContext, $LogMessage, $Priority=0) { - IPSLogger_Out(c_LogLevel_Information, c_LogType_Information, $LogContext, $LogMessage, $Priority); + IPSLogger_Out(c_LogLevel_Notification, c_LogType_Notification, $LogContext, $LogMessage, $Priority); } // --------------------------------------------------------------------------------------------------------------------------- diff --git a/IPSLibrary/app/core/IPSLogger/IPSLogger_ChangeSettings.ips.php b/IPSLibrary/app/core/IPSLogger/IPSLogger_ChangeSettings.ips.php index de2e229..1759eb6 100644 --- a/IPSLibrary/app/core/IPSLogger/IPSLogger_ChangeSettings.ips.php +++ b/IPSLibrary/app/core/IPSLogger/IPSLogger_ChangeSettings.ips.php @@ -15,21 +15,21 @@ */ include "IPSLogger_Constants.inc.php"; - if ($IPS_VARIABLE==c_ID_EMailOutEnabled) { + if ($_IPS['VARIABLE']==c_ID_EMailOutEnabled) { if (c_ID_SmtpDevice <> 0) { - SetValue($IPS_VARIABLE, $IPS_VALUE); + SetValue($_IPS['VARIABLE'], $_IPS['VALUE']); if (!GetValue(c_ID_EMailOutEnabled)) { SetValue(c_ID_EMailOutMsgList, ''); IPS_SetScriptTimer(c_ID_ScriptSendMail, 0); } } - } else if ($IPS_VARIABLE==c_ID_ProwlOutEnabled) { + } else if ($_IPS['VARIABLE']==c_ID_ProwlOutEnabled) { if (c_Key_ProwlService <> '') { - SetValue($IPS_VARIABLE, $IPS_VALUE); + SetValue($_IPS['VARIABLE'], $_IPS['VALUE']); } } else { - SetValue($IPS_VARIABLE, $IPS_VALUE); + SetValue($_IPS['VARIABLE'], $_IPS['VALUE']); } ; /** @}*/ diff --git a/IPSLibrary/app/core/IPSLogger/IPSLogger_Output.inc.php b/IPSLibrary/app/core/IPSLogger/IPSLogger_Output.inc.php index 432774f..2b8af88 100644 --- a/IPSLibrary/app/core/IPSLogger/IPSLogger_Output.inc.php +++ b/IPSLibrary/app/core/IPSLogger/IPSLogger_Output.inc.php @@ -50,6 +50,8 @@ function IPSLogger_Out($LogLevel, $LogType, $Context, $Msg, $Priority=0) { IPSLogger_OutLog4IPS($LogLevel, $LogType, $Context, $Msg.$StackTxt); IPSLogger_OutEcho($LogLevel, $LogType, $Context, $Msg.$StackTxt); IPSLogger_OutProwl($LogLevel, $LogType, $Context, $Msg.$StackTxt, $Priority); + @IPSLogger_OutSysLog($LogLevel, $LogType, $Context, $Msg.$StackTxt); + @IPSLogger_OutMySQL($LogLevel, $LogType, $Context, $Msg.$StackTxt); } // --------------------------------------------------------------------------------------------------------------------------- @@ -106,6 +108,43 @@ function IPSLogger_OutLog4IPS($LogLevel, $LogType, $Context, $Msg) { } } + // --------------------------------------------------------------------------------------------------------------------------- + function IPSLogger_OutSysLog($LogLevel, $LogType, $Context, $Msg) { + if (defined('c_SysLog_Enabled') and c_SysLog_Enabled) { + $logTypeEnabled = true; + if (isset($SysLog_LogTypes) and array_key_exists($LogLevel, $SysLog_LogTypes) and $SysLog_LogTypes[$LogLevel]==false) { + $logTypeEnabled = false; + } + if ($logTypeEnabled) { + + // Sample Message + //<14>May 19 20:15:42 sbs2008.wps-computer.local IP-Symcon: ID 34690::SENDER Execute: My third PHP syslog message + + $severityList = array(2 /*Critical*/, 3 /*Error*/, 4 /*Warning*/, 5 /*Notice*/, 6 /*Info*/, 7 /*Debug*/, 7 /*Debug*/, 7 /*Debug*/, 7 /*Debug*/); + $severity = $severityList[$LogLevel]; + $facility = 1; + $priority = "<".($facility*8 + $severity).">"; + + $timestamp = date("M j H:i:s"); + $host = ''; + if (isset($_ENV["COMPUTERNAME"])) $host=$_ENV["COMPUTERNAME"]; + $message = substr($priority.$timestamp.' '.$host.' IP-Symcon-'.$Context.': '.$Msg, 0, 1024); + + if (c_SysLog_Instance != '') { + CSCK_SendText((int)c_SysLog_Instance, $message); + } else if (c_SysLog_Host != '') { + $handle = fsockopen("udp://".c_SysLog_Host, c_SysLog_Port, $errno, $errstr); + if ($handle) { + fwrite($handle, $message); + fclose($handle); + } + } else { + echo $message.PHP_EOL; + } + } + } + } + // --------------------------------------------------------------------------------------------------------------------------- function IPSLogger_OutEMail($LogLevel, $LogType, $Context, $Msg, $Priority) { if (GetValue(c_ID_EMailOutEnabled) and @@ -163,7 +202,10 @@ function IPSLogger_OutHtml($LogLevel, $LogType, $Context, $Msg) { $MsgList = GetValue(c_ID_HtmlOutMsgList); $MsgCount = GetValue(c_ID_HtmlOutMsgCount); - $TablePrefix = ''; + $TablePrefix = ' +
'; $TablePrefix .= c_Style_HtmlOutColGroup; //IPSymcon-Inf-WinLIRC 2010-12-03 22:09:13.000 Msg ... @@ -270,11 +312,11 @@ function IPSLogger_SendProwlMessage($Event, $Description, $Priority) { } // ---------------------------------------------------------------------------------------------------------------------------- - function IPSLogger_OutProgram($Msg, $HtmlId, $LogId, $MsgCount) { + function IPSLogger_OutProgram($Msg, $HtmlId, $LogId, $MsgCount, $FontSize=10) { $Msg = htmlentities($Msg, ENT_COMPAT, 'ISO-8859-1'); $Msg = str_replace("\n", "
", $Msg); $MsgList = GetValue($HtmlId); - $TablePrefix = '
'; + $TablePrefix = '
'; $CurrentMsgId = GetValue($LogId)+1; SetValue($LogId, $CurrentMsgId); @@ -288,7 +330,7 @@ function IPSLogger_OutProgram($Msg, $HtmlId, $LogId, $MsgCount) { if (strpos($MsgList, '
') === false) { $MsgList = ""; } else { - $StrTmp = ''); } - /** @}*/ -?> \ No newline at end of file + + function IPSLogger_OutMySQL($LogLevel, $LogType, $Context, $Msg) + { + $logTypeEnabled = false; + if (defined('c_DB_MySQL_Enabled') and c_DB_MySQL_Enabled) { + $logTypeEnabled = true; + if (isset($DB_MySQL_LogTypes) and array_key_exists($LogLevel, $DB_MySQL_LogTypes) and $DB_MySQL_LogTypes[$LogLevel]==false) { + $logTypeEnabled = false; + } + } + if (!$logTypeEnabled) return; + + if (!defined("c_DB_MySQL_Server")) return; + if (!defined("c_DB_MySQL_Port")) return; + if (!defined("c_DB_MySQL_Database")) return; + if (!defined("c_DB_MySQL_Table")) return; + if (!defined("c_DB_MySQL_User")) return; + if (!defined("c_DB_MySQL_Password")) return; + + // Testen ob Verbindung moeglich + ini_set('mysql.connect_timeout','10'); + $server = @mysql_connect(c_DB_MySQL_Server.":".c_DB_MySQL_Port,c_DB_MySQL_User,c_DB_MySQL_Password); + if ( !$server ) + { + IPS_Logmessage(__FILE__,"MySQL-Server nicht bereit"); + return false; + } + + // Datenbank anlegen wenn nicht vorhanden + $db_exist = @mysql_select_db(c_DB_MySQL_Database, $server); + if (!$db_exist) + { + IPS_Logmessage(__FILE__,"MySQL-Datenbank wird angelegt"); + $mysqlstring = 'CREATE DATABASE ' . c_DB_MySQL_Database .";"; + $db_exist = mysql_query($mysqlstring); + } + if ( !$db_exist ) + { + IPS_Logmessage(__FILE__,"MySQL-Datenbank nicht bereit"); + return false; + } + + // Tabelle erstellen wenn nicht vorhanden + $result = mysql_query("SHOW TABLES LIKE '".c_DB_MySQL_Table."'"); + if (@mysql_num_rows($result) == 0) + { + IPS_Logmessage(__FILE__,"MySQL-Tabelle nicht vorhanden wird erstellt"); + $sql = "CREATE TABLE `" . c_DB_MySQL_Table . "` "; + $sql = $sql . "( `ID` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , "; + $sql = $sql . "`TIMESTAMP` TIMESTAMP NOT NULL ,"; + $sql = $sql . "`LOGLEVEL` INT ,"; + $sql = $sql . "`LOGTYPE` VARCHAR( 150 ) ,"; + $sql = $sql . "`CONTEXT` VARCHAR( 150 ),"; + $sql = $sql . "`MESSAGE` VARCHAR( 1024 ), "; + $sql = $sql . "INDEX (LOGLEVEL), "; + $sql = $sql . "INDEX (LOGTYPE), "; + $sql = $sql . "INDEX (CONTEXT), "; + $sql = $sql . "INDEX (MESSAGE) "; + $sql = $sql . " ) ENGINE = MYISAM ;"; + + $tab_exist = mysql_query($sql); + } + else + $tab_exist = true; + + if ( !$tab_exist ) + { + IPS_Logmessage(__FILE__,"MySQL-Tabelle Fehler bei Tabellenerstellung"); + return; + } + + $Context = str_replace("'",'"',$Context); + $Context = str_replace("\\","\\\\",$Context); + $Msg = str_replace("'",'"',$Msg); + $Msg = str_replace("\\",'\\\\',$Msg); + + $Context = substr($Context,0,150); + $Msg = substr($Msg,0,1024); + + // Meldung eintragen + $sql = ""; + $sql = $sql . "INSERT INTO ".c_DB_MySQL_Table." "; + $sql = $sql . "(`LOGLEVEL`,`LOGTYPE`,`CONTEXT`,`MESSAGE`) "; + $sql = $sql . "VALUES ('".$LogLevel."','".$LogType."','".$Context."','".$Msg."'); "; + + @mysql_query($sql); + if ( mysql_error($server) ) + { + $error = mysql_errno($server) . ": " . mysql_error($server) . "\n"; + IPS_LogMessage(__FILE__,"MySQL Fehler :". $error); + } + + mysql_close($server); + + } + + /** @}*/ +?> diff --git a/IPSLibrary/app/core/IPSLogger/IPSLogger_PhpErrorHandler.inc.php b/IPSLibrary/app/core/IPSLogger/IPSLogger_PhpErrorHandler.inc.php index 548a4bd..da0bccd 100644 --- a/IPSLibrary/app/core/IPSLogger/IPSLogger_PhpErrorHandler.inc.php +++ b/IPSLibrary/app/core/IPSLogger/IPSLogger_PhpErrorHandler.inc.php @@ -24,37 +24,44 @@ function IPSLogger_PhpErrorHandler ($ErrType, $ErrMsg, $FileName, $LineNum, $Vars) { if (error_reporting() == 0) {return false;} // No Reporting of suppressed Erros (suppressed @) - require_once "IPSLogger.inc.php"; $ErrorDetails = c_lf." Error in Script ".$FileName." on Line ".$LineNum; - switch ($ErrType) { + $FatalError = false; + switch ($ErrType) { case E_ERROR: IPSLogger_Err("PHP", 'Error: '.$ErrMsg.$ErrorDetails); + $FatalError = true; break; case E_WARNING: IPSLogger_Err("PHP", 'Warning: '.$ErrMsg.$ErrorDetails); break; case E_PARSE: IPSLogger_Err("PHP", 'Parsing Error: '.$ErrMsg.$ErrorDetails); + $FatalError = true; break; case E_NOTICE: IPSLogger_Err("PHP", 'Notice: '.$ErrMsg.$ErrorDetails); break; case E_CORE_ERROR: IPSLogger_Err("PHP", 'Core Error: '.$ErrMsg.$ErrorDetails); + $FatalError = true; break; case E_CORE_WARNING: IPSLogger_Err("PHP", 'Core Warning: '.$ErrMsg.$ErrorDetails); + $FatalError = true; break; case E_COMPILE_ERROR: IPSLogger_Err("PHP", 'Compile Error: '.$ErrMsg.$ErrorDetails); + $FatalError = true; break; case E_COMPILE_WARNING: IPSLogger_Err("PHP", 'Compile Warning: '.$ErrMsg.$ErrorDetails); + $FatalError = true; break; case E_USER_ERROR: IPSLogger_Err("PHP", 'User Error: '.$ErrMsg.$ErrorDetails); + $FatalError = true; break; case E_USER_WARNING: IPSLogger_Err("PHP", 'User Warning: '.$ErrMsg.$ErrorDetails); @@ -63,16 +70,32 @@ function IPSLogger_PhpErrorHandler ($ErrType, $ErrMsg, $FileName, $LineNum, $Var IPSLogger_Err("PHP", 'User Notice: '.$ErrMsg.$ErrorDetails); break; case E_STRICT: + $FatalError = true; IPSLogger_Err("PHP", 'Runtime Notice: '.$ErrMsg.$ErrorDetails); break; default: IPSLogger_Err("PHP", 'Unknown Error: '.$ErrMsg.$ErrorDetails); + $FatalError = true; break; } - // Abort Processing + if (array_key_exists('ERROR_COUNT', $_IPS)) { + $errorCount=$_IPS['ERROR_COUNT'] + 1; + } else { + $errorCount=1; + } + $_IPS['ERROR_COUNT'] = $errorCount; + + // Abort Processing during "Abort Flag" if (array_key_exists('ABORT_ON_ERROR', $_IPS) and $_IPS['ABORT_ON_ERROR']) { exit('Abort Processing during Error: '.$ErrMsg.$ErrorDetails); + // Abort Processing during "FATAL Error" + } elseif ($FatalError) { + exit('Abort Processing during Fatal-Error: '.$ErrMsg.$ErrorDetails); + // Abort Processing during maximal Error Counter + } elseif ($errorCount > 10) { + IPSLogger_Err("PHP", 'Maximal ErrorCount exceeded for this Session --> Abort Processing'); + exit('Abort Processing during exceed of maximal ErrorCount: '.$ErrMsg.$ErrorDetails); } else { return false; } @@ -81,20 +104,28 @@ function IPSLogger_PhpErrorHandler ($ErrType, $ErrMsg, $FileName, $LineNum, $Var $old_error_handler = set_error_handler("IPSLogger_PhpErrorHandler",E_ALL); function IPSLogger_PhpFatalErrorHandler() { - if (@is_array($e = @error_get_last())) { + if (@is_array($e = @error_get_last())) { //print_r($e); echo "Reporting=".error_reporting()."\n"; - $code = isset($e['type']) ? $e['type'] : 0; - $msg = isset($e['message']) ? $e['message'] : ''; - $file = isset($e['file']) ? $e['file'] : ''; - $line = isset($e['line']) ? $e['line'] : ''; - if ($code==1 /*Error*/) { - IPSLogger_PhpErrorHandler ($code, $msg, $file, $line, null); - } + $code = isset($e['type']) ? $e['type'] : 0; + $msg = isset($e['message']) ? $e['message'] : ''; + $file = isset($e['file']) ? $e['file'] : ''; + $line = isset($e['line']) ? $e['line'] : ''; + switch($code) { + case E_ERROR: + case E_PARSE: + case E_CORE_ERROR: + case E_CORE_WARNING: + case E_COMPILE_ERROR: + case E_COMPILE_WARNING: + IPSLogger_PhpErrorHandler ($code, $msg, $file, $line, null); + break; + default: + break; + } } } - register_shutdown_function('IPSLogger_PhpFatalErrorHandler'); - + register_shutdown_function('IPSLogger_PhpFatalErrorHandler'); /** @}*/ ?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSLogger/IPSLogger_PurgeLogFiles.ips.php b/IPSLibrary/app/core/IPSLogger/IPSLogger_PurgeLogFiles.ips.php index cffd38e..d7b1e37 100644 --- a/IPSLibrary/app/core/IPSLogger/IPSLogger_PurgeLogFiles.ips.php +++ b/IPSLibrary/app/core/IPSLogger/IPSLogger_PurgeLogFiles.ips.php @@ -17,7 +17,7 @@ define ("c_LogId", "IPSLogger_PurgeLogFiles"); PurgeLogFiles(c_File_Directory, c_File_Extension, c_ID_FileOutEnabled, c_ID_FileOutDays); - PurgeLogFiles(c_Log4IPS_Directory, c_Log4IPS_Extension, c_ID_FileOutEnabled, c_ID_Log4IPSOutDays); + PurgeLogFiles(c_Log4IPS_Directory, c_Log4IPS_Extension, c_ID_Log4IPSOutEnabled, c_ID_Log4IPSOutDays); function PurgeLogFiles($Directory, $Extension, $ID_OutSwitch, $ID_OutDays) { if (GetValue($ID_OutSwitch)) { diff --git a/IPSLibrary/app/core/IPSLogger/ProwlPHP.php b/IPSLibrary/app/core/IPSLogger/ProwlPHP.php new file mode 100644 index 0000000..1abe71b --- /dev/null +++ b/IPSLibrary/app/core/IPSLogger/ProwlPHP.php @@ -0,0 +1,199 @@ + maxsize] + 'apikey' => 204, // User API Key. + 'providerkey' => 40, // Provider key. + 'priority' => 2, // Range from -2 to 2. + 'application' => 254, // Name of the app. + 'event' => 1024, // Name of the event. + 'description' => 10000, // Description of the event. + 'url' => 512, + ); + + public function __construct($apikey=null, $verify=false, $provkey=null, $proxy=null, $userpwd=null) + { + $curl_info = curl_version(); // Checks for cURL function and SSL version. Thanks Adrian Rollett! + if(!function_exists('curl_exec') || empty($curl_info['ssl_version'])) + { + die($this->getError(10000)); + } + + if(isset($proxy)) + $this->_setProxy($proxy, $userpwd); + + if(isset($apikey) && $verify) + $this->verify($apikey, $provkey); + + $this->_api_key = $apikey; + } + + public function verify($apikey, $provkey) + { + $return = $this->_execute(sprintf($this->_url_verify, $apikey, $provkey)); + return $this->_response($return); + } + + public function push($params, $is_post=false) + { + if($is_post) + $post_params = ''; + + $url = $is_post ? $this->_url_push : $this->_url_push . '?'; + $params = func_get_args(); + + if(isset($this->_api_key) && !isset($params[0]['apikey'])) + $params[0]['apikey'] = $this->_api_key; + + if(isset($this->_prov_key) && !isset($params[0]['providerkey'])) + $params[0]['providerkey'] = $this->_prov_key; + + foreach($params[0] as $k => $v) + { + $v = str_replace("\\n","\n",$v); // Fixes line break issue! Cheers Fr3d! + if(!isset($this->_params[$k])) + { + $this->_return_code = 400; + return false; + } + if(strlen($v) > $this->_params[$k]) + { + $this->_return_code = 10001; + return false; + } + + if($is_post) + $post_params .= $k . '=' . urlencode($v) . '&'; + else + $url .= $k . '=' . urlencode($v) . '&'; + } + + if($is_post) + $params = substr($post_params, 0, strlen($post_params)-1); + else + $url = substr($url, 0, strlen($url)-1); + + $return = $this->_execute($url, $is_post ? true : false, $params); + + return $this->_response($return); + } + + public function getError($code=null) + { + $code = (empty($code)) ? $this->_return_code : $code; + switch($code) + { + case 200: return 'Request Successful.'; break; + case 400: return 'Bad request, the parameters you provided did not validate.'; break; + case 401: return 'The API key given is not valid, and does not correspond to a user.'; break; + case 405: return 'Method not allowed, you attempted to use a non-SSL connection to Prowl.'; break; + case 406: return 'Your IP address has exceeded the API limit.'; break; + case 500: return 'Internal server error, something failed to execute properly on the Prowl side.'; break; + case 10000: return 'cURL library missing vital functions or does not support SSL. cURL w/SSL is required to execute ProwlPHP.'; break; + case 10001: return 'Parameter value exceeds the maximum byte size.'; break; + default: return false; break; + } + } + + public function getRemaining() + { + if(!isset($this->_remaining)) + return false; + + return $this->_remaining; + } + + public function getResetDate() + { + if(!isset($this->_resetdate)) + return false; + + return $this->_resetdate; + } + + private function _execute($url, $is_post=false, $params=null) + { + $this->_obj_curl = curl_init($this->_api_domain . $url); + curl_setopt($this->_obj_curl, CURLOPT_HEADER, 0); + curl_setopt($this->_obj_curl, CURLOPT_USERAGENT, "ProwlPHP/" . $this->_version); + curl_setopt($this->_obj_curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY); + curl_setopt($this->_obj_curl, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($this->_obj_curl, CURLOPT_RETURNTRANSFER, 1); + + if($is_post) + { + curl_setopt($this->_obj_curl, CURLOPT_POST, 1); + curl_setopt($this->_obj_curl, CURLOPT_POSTFIELDS, $params); + } + + if($this->_use_proxy) + { + curl_setopt($this->_obj_curl, CURLOPT_HTTPPROXYTUNNEL, 1); + curl_setopt($this->_obj_curl, CURLOPT_PROXY, $this->_proxy); + curl_setopt($this->_obj_curl, CURLOPT_PROXYUSERPWD, $this->_proxy_userpwd); + } + + $return = curl_exec($this->_obj_curl); + curl_close($this->_obj_curl); + return $return; + } + + private function _response($return) + { + if($return===false) + { + $this->_return_code = 500; + return false; + } + + $response = new SimpleXMLElement($return); + + if(isset($response->success)) + { + $this->_return_code = (int)$response->success['code']; + $this->_remaining = (int)$response->success['remaining']; + $this->_resetdate = (int)$response->success['resetdate']; + } + else + { + $this->_return_code = $response->error['code']; + } + + switch($this->_return_code) + { + case 200: return true; break; + default: return false; break; + } + + unset($response); + } + + private function _setProxy($proxy, $userpwd=null) + { + if(strlen($proxy) > 0) + { + $this->_use_proxy = true; + $this->_proxy = $proxy; + $this->_proxy_userpwd = $userpwd; + } + } +} + +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSMessageHandler/IPSMessageHandler.class.php b/IPSLibrary/app/core/IPSMessageHandler/IPSMessageHandler.class.php index 180a8f8..a5fc766 100644 --- a/IPSLibrary/app/core/IPSMessageHandler/IPSMessageHandler.class.php +++ b/IPSLibrary/app/core/IPSMessageHandler/IPSMessageHandler.class.php @@ -32,12 +32,14 @@ class IPSMessageHandlerException extends Exception { IPSUtils_Include ('IPSLogger.inc.php', 'IPSLibrary::app::core::IPSLogger'); IPSUtils_Include ('IPSMessageHandler_Configuration.inc.php', 'IPSLibrary::config::core::IPSMessageHandler'); + IPSUtils_Include ('IPSMessageHandler_Custom.inc.php', 'IPSLibrary::config::core::IPSMessageHandler'); IPSUtils_Include ('IPSComponent.class.php', 'IPSLibrary::app::core::IPSComponent'); IPSUtils_Include ('IPSModule.class.php', 'IPSLibrary::app::core::IPSComponent'); class IPSMessageHandler { - private static $eventConfiguration = null; + private static $eventConfigurationAuto = array(); + private static $eventConfigurationCust = array(); /** * @public @@ -51,15 +53,29 @@ public function __construct() { /** * @private * - * Liefert die aktuelle Event Konfiguration + * Liefert die aktuelle Auto Event Konfiguration * * @return string[] Event Konfiguration */ - private static function Get_EventConfiguration() { - if (self::$eventConfiguration == null) { - self::$eventConfiguration = IPSMessageHandler_GetEventConfiguration(); - } - return self::$eventConfiguration; + private static function Get_EventConfigurationAuto() { + if (self::$eventConfigurationAuto == null) { + self::$eventConfigurationAuto = IPSMessageHandler_GetEventConfiguration(); + } + return self::$eventConfigurationAuto; + } + + /** + * @private + * + * Liefert die aktuelle Customer Event Konfiguration + * + * @return string[] Event Konfiguration + */ + private static function Get_EventConfigurationCust() { + if (self::$eventConfigurationCust == null and function_exists('IPSMessageHandler_GetEventConfigurationCust')) { + self::$eventConfigurationCust = IPSMessageHandler_GetEventConfigurationCust(); + } + return self::$eventConfigurationCust; } /** @@ -69,8 +85,8 @@ private static function Get_EventConfiguration() { * * @param string[] $configuration Neue Event Konfiguration */ - private static function Set_EventConfiguration($configuration) { - self::$eventConfiguration = $configuration; + private static function Set_EventConfigurationAuto($configuration) { + self::$eventConfigurationAuto = $configuration; } /** @@ -80,7 +96,12 @@ private static function Set_EventConfiguration($configuration) { * */ public static function CreateEvents() { - $configuration = self::Get_EventConfiguration(); + $configuration = self::Get_EventConfigurationAuto(); + + foreach ($configuration as $variableId=>$params) { + self::CreateEvent($variableId, $params[0]); + } + $configuration = self::Get_EventConfigurationCust(); foreach ($configuration as $variableId=>$params) { self::CreateEvent($variableId, $params[0]); @@ -98,14 +119,14 @@ public static function CreateEvents() { */ public static function CreateEvent($variableId, $eventType) { switch ($eventType) { - case 'OnChange': - $triggerType = 1; - break; - case 'OnUpdate': - $triggerType = 0; - break; + case 'OnChange': + $triggerType = 1; + break; + case 'OnUpdate': + $triggerType = 0; + break; default: - throw new IPSMessageHandlerException('Found unknown EventType '.$eventType); + throw new IPSMessageHandlerException('Found unknown EventType '.$eventType); } $eventName = $eventType.'_'.$variableId; $scriptId = IPS_GetObjectIDByIdent('IPSMessageHandler_Event', IPSUtil_ObjectIDByPath('Program.IPSLibrary.app.core.IPSMessageHandler')); @@ -132,16 +153,16 @@ public static function CreateEvent($variableId, $eventType) { private static function StoreEventConfiguration($configuration) { // Build Configuration String - $configString = '$eventConfiguration = array('; - foreach ($configuration as $variableId=>$params) { - $configString .= PHP_EOL.chr(9).chr(9).chr(9).$variableId.' => array('; - for ($i=0; $i$params) { + $configString .= PHP_EOL.chr(9).chr(9).chr(9).$variableId.' => array('; + for ($i=0; $i0) $configString .= PHP_EOL.chr(9).chr(9).chr(9).' '; - $configString .= "'".$params[$i]."','".$params[$i+1]."','".$params[$i+2]."',"; + $configString .= "'".$params[$i]."','".$params[$i+1]."','".$params[$i+2]."',"; } - $configString .= '),'; - } - $configString .= PHP_EOL.chr(9).chr(9).chr(9).');'.PHP_EOL.PHP_EOL.chr(9).chr(9); + $configString .= '),'; + } + $configString .= PHP_EOL.chr(9).chr(9).chr(9).');'.PHP_EOL.PHP_EOL.chr(9).chr(9); // Write to File $fileNameFull = IPS_GetKernelDir().'scripts\\IPSLibrary\\config\\core\\IPSMessageHandler\\IPSMessageHandler_Configuration.inc.php'; @@ -151,14 +172,13 @@ private static function StoreEventConfiguration($configuration) { $fileContent = file_get_contents($fileNameFull, true); $pos1 = strpos($fileContent, '$eventConfiguration = array('); $pos2 = strpos($fileContent, 'return $eventConfiguration;'); - + if ($pos1 === false or $pos2 === false) { throw new IPSMessageHandlerException('EventConfiguration could NOT be found !!!', E_USER_ERROR); } $fileContentNew = substr($fileContent, 0, $pos1).$configString.substr($fileContent, $pos2); file_put_contents($fileNameFull, $fileContentNew); - self::Set_EventConfiguration($configuration); - + self::Set_EventConfigurationAuto($configuration); } /** @@ -174,40 +194,48 @@ private static function StoreEventConfiguration($configuration) { * @param string $moduleParams Parameter für verlinktes Module (Klasse+Parameter) */ public static function RegisterEvent($variableId, $eventType, $componentParams, $moduleParams) { - $configuration = self::Get_EventConfiguration(); + $configurationAuto = self::Get_EventConfigurationAuto(); + $configurationCust = self::Get_EventConfigurationCust(); // Search Configuration $found = false; - if (array_key_exists($variableId, $configuration)) { - $moduleParamsNew = explode(',', $moduleParams); - $moduleClassNew = $moduleParamsNew[0]; - - $params = $configuration[$variableId]; - - for ($i=0; $i Update Configuration - if ($moduleClassCfg=$moduleClassNew) { - $found = true; - $configuration[$variableId][$i] = $eventType; - $configuration[$variableId][$i+1] = $componentParams; - $configuration[$variableId][$i+2] = $moduleParams; - } - } + if (array_key_exists($variableId, $configurationCust)) { + $found = true; } - // Variable NOT found --> Create Configuration if (!$found) { - $configuration[$variableId][] = $eventType; - $configuration[$variableId][] = $componentParams; - $configuration[$variableId][] = $moduleParams; - } + if (array_key_exists($variableId, $configurationAuto)) { + $moduleParamsNew = explode(',', $moduleParams); + $moduleClassNew = $moduleParamsNew[0]; + + $params = $configurationAuto[$variableId]; + + for ($i=0; $i Update Configuration + if ($moduleClassCfg=$moduleClassNew) { + $found = true; + $configurationAuto[$variableId][$i] = $eventType; + $configurationAuto[$variableId][$i+1] = $componentParams; + $configurationAuto[$variableId][$i+2] = $moduleParams; + } + } + } - self::StoreEventConfiguration($configuration); - self::CreateEvent($variableId, $eventType); - } + + // Variable NOT found --> Create Configuration + if (!$found) { + $configurationAuto[$variableId][] = $eventType; + $configurationAuto[$variableId][] = $componentParams; + $configurationAuto[$variableId][] = $moduleParams; + } + + self::StoreEventConfiguration($configurationAuto); + self::CreateEvent($variableId, $eventType); + } + } /** * @public @@ -220,9 +248,9 @@ public static function RegisterEvent($variableId, $eventType, $componentParams, * @param string $componentParams Parameter für verlinkte Hardware Komponente (Klasse+Parameter) * @param string $moduleParams Parameter für verlinktes Module (Klasse+Parameter) */ - public static function RegisterOnChangeEvent($variableId, $componentParams, $moduleParams) { - self::RegisterEvent($variableId, 'OnChange', $componentParams, $moduleParams); - } + public static function RegisterOnChangeEvent($variableId, $componentParams, $moduleParams) { + self::RegisterEvent($variableId, 'OnChange', $componentParams, $moduleParams); + } /** * @public @@ -235,10 +263,64 @@ public static function RegisterOnChangeEvent($variableId, $componentParams, $mod * @param string $componentParams Parameter für verlinkte Hardware Komponente (Klasse+Parameter) * @param string $moduleParams Parameter für verlinktes Module (Klasse+Parameter) */ - public static function RegisterOnUpdateEvent($variableId, $componentParams, $moduleParams) { - self::RegisterEvent($variableId, 'OnUpdate', $componentParams, $moduleParams); - } + public static function RegisterOnUpdateEvent($variableId, $componentParams, $moduleParams) { + self::RegisterEvent($variableId, 'OnUpdate', $componentParams, $moduleParams); + } + + /** + * @public + * + * Methode um autretende IR Events zu processen + * + * @param integer $variable ID der auslösenden Variable + * @param string $value Wert der Variable + */ + public function HandleIREvent($variable, $value) { + $configuration = IPSMessageHandler_GetEventConfigurationIR(); + + if ($value == '') { + return; + } + + $irButton = $value; + $irInstanceId = IPS_GetParent($variable); + $childrenIds = IPS_GetChildrenIDs($irInstanceId); + foreach ($childrenIds as $id) { + if ($id <> $variable) { + $irRemoteControl = GetValue($id); + } + } + IPSLogger_Com(__file__, "Received Data from IR-Variable, Control='$irRemoteControl', Command='$irButton'"); + + $irMessage = $irRemoteControl.','.$irButton; + if (array_key_exists($irRemoteControl.'.'.$irButton, $configuration)) { + $params = $configuration[$irRemoteControl.'.'.$irButton]; + } elseif (array_key_exists($irRemoteControl.'.*', $configuration)) { + $params = $configuration[$irRemoteControl.'.'.$irButton]; + } else { + $params = ''; + } + if ($params<>'') { + if (count($params) < 2) { + throw new IPSMessageHandlerException('Invalid IPSMessageHandler Configuration, Event Defintion needs 2 parameters'); + } + $component = IPSComponent::CreateObjectByParams($params[0]); + $module = IPSModule::CreateObjectByParams($params[1]); + + if (function_exists('IPSMessageHandler_BeforeHandleEvent')) { + if (IPSMessageHandler_BeforeHandleEvent($variable, $value, $component, $module)) { + $component->HandleEvent($variable, $value, $module); + } + } else { + $component->HandleEvent($variable, $value, $module); + } + if (function_exists('IPSMessageHandler_AfterHandleEvent')) { + IPSMessageHandler_AfterHandleEvent($variable, $value, $component, $module); + } + } +} + /** * @public * @@ -248,22 +330,59 @@ public static function RegisterOnUpdateEvent($variableId, $componentParams, $mod * @param string $value Wert der Variable */ public function HandleEvent($variable, $value) { - $configuration = IPSMessageHandler_GetEventConfiguration(); - - if (array_key_exists($variable, $configuration)) { - $params = $configuration[$variable]; + $configurationAuto = self::Get_EventConfigurationAuto(); + $configurationCust = self::Get_EventConfigurationCust(); + + if (array_key_exists($variable, $configurationCust)) { + $params = $configurationCust[$variable]; + } elseif (array_key_exists($variable, $configurationAuto)) { + $params = $configurationAuto[$variable]; + //} elseif ($variable==IPSMH_IRTRANS_BUTTON_VARIABLE_ID) { + //$params = ''; + //$this->HandleIREvent($variable, $value); + } else { + $params = ''; + IPSLogger_Wrn(__file__, 'Variable '.$variable.' NOT found in IPSMessageHandler Configuration!'); + } + + if ($params<>'') { if (count($params) < 3) { - throw new IPSMessageHandlerException('Invalid IPSMessageHandler Configuration, Event Defintion needs 2 parameters'); + throw new IPSMessageHandlerException('Invalid IPSMessageHandler Configuration, Event Defintion needs 3 parameters'); } $component = IPSComponent::CreateObjectByParams($params[1]); $module = IPSModule::CreateObjectByParams($params[2]); - - $component->HandleEvent($variable, $value, $module); - } else { - IPSLogger_Wrn(__file__, 'Variable '.$variable.' NOT found in IPSMessageHandler Configuration!'); + + if (function_exists('IPSMessageHandler_BeforeHandleEvent')) { + if (IPSMessageHandler_BeforeHandleEvent($variable, $value, $component, $module)) { + $component->HandleEvent($variable, $value, $module); + if (function_exists('IPSMessageHandler_AfterHandleEvent')) { + IPSMessageHandler_AfterHandleEvent($variable, $value, $component, $module); + } + } + } else { + $component->HandleEvent($variable, $value, $module); + if (function_exists('IPSMessageHandler_AfterHandleEvent')) { + IPSMessageHandler_AfterHandleEvent($variable, $value, $component, $module); + } + } } } - + } + + /** + * @public + * + * Methode um autretende Library Events zu processen + * + * @param string $variable ID der auslösenden Variable + * @param string $value Wert der Variable + * @param string $module Name des auslösenden Modules + * @param string $event Name des auslösenden Events + */ + function IPSMessageHandler_HandleLibraryEvent($variable, $value, $module='', $event='') { + if (function_exists('IPSMessageHandler_AfterHandleLibraryEvent')) { + IPSMessageHandler_AfterHandleLibraryEvent($variable, $value, $module, $event); + } } /** @}*/ diff --git a/IPSLibrary/app/core/IPSMessageHandler/IPSMessageHandler_Event.ips.php b/IPSLibrary/app/core/IPSMessageHandler/IPSMessageHandler_Event.ips.php index 567aea8..6101ad1 100644 --- a/IPSLibrary/app/core/IPSMessageHandler/IPSMessageHandler_Event.ips.php +++ b/IPSLibrary/app/core/IPSMessageHandler/IPSMessageHandler_Event.ips.php @@ -11,8 +11,8 @@ * */ - $variable = $_IPS['VARIABLE']; - $value = $_IPS['VALUE']; + $variable = $_IPS['VARIABLE']; + $value = $_IPS['VALUE']; IPSUtils_Include ('IPSMessageHandler.class.php', 'IPSLibrary::app::core::IPSMessageHandler'); diff --git a/IPSLibrary/app/core/IPSMessageHandler/IPSMessageHandler_IREvent.ips.php b/IPSLibrary/app/core/IPSMessageHandler/IPSMessageHandler_IREvent.ips.php new file mode 100644 index 0000000..4b4dfc2 --- /dev/null +++ b/IPSLibrary/app/core/IPSMessageHandler/IPSMessageHandler_IREvent.ips.php @@ -0,0 +1,23 @@ + + * + * Script dient als EventScript um den IPSMessageHandler über Variablen Änderungen der Componenten zu informieren + * + */ + + $variable = $_IPS['VARIABLE']; + $value = $_IPS['VALUE']; + + IPSUtils_Include ('IPSMessageHandler.class.php', 'IPSLibrary::app::core::IPSMessageHandler'); + + $messageHandler = new IPSMessageHandler(); + $messageHandler->HandleIREvent($variable, $value); + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/core/IPSUtils/IPSUtils.inc.php b/IPSLibrary/app/core/IPSUtils/IPSUtils.inc.php index 29cac86..a6a512f 100644 --- a/IPSLibrary/app/core/IPSUtils/IPSUtils.inc.php +++ b/IPSLibrary/app/core/IPSUtils/IPSUtils.inc.php @@ -35,7 +35,7 @@ function IPSUtils_Include($file, $namespace="") { include_once $file; } else { $file = IPS_GetKernelDir().'\\scripts\\'.str_replace('::','\\',$namespace).'\\'.$file; - + if (!file_exists($file)) { throw new Exception('script '.$file.' could NOT be found!', E_USER_ERROR); } @@ -93,4 +93,4 @@ function IPS_GetIdent($objId) { /** @}*/ -?> +?> \ No newline at end of file diff --git a/IPSLibrary/app/hardware/AudioMax/AudioMax.inc.php b/IPSLibrary/app/hardware/AudioMax/AudioMax.inc.php new file mode 100644 index 0000000..a0a5cc8 --- /dev/null +++ b/IPSLibrary/app/hardware/AudioMax/AudioMax.inc.php @@ -0,0 +1,341 @@ + + * + * Dieses File kann von anderen Scripts per INCLUDE eingebunden werden und enthält Funktionen + * um alle AudioMax Funktionen bequem per Funktionsaufruf steueren zu können. + * + */ + + include_once 'AudioMax_Server.class.php'; + + /** + * Server Ein- und Ausschalten + * + * @param int $instanceId ID des AudioMax Servers + * @param string $value TRUE oder '1' für An, FALSE oder '0' für Aus + * @return boolean Funktions Ergebnis, TRUE für OK, FALSE für Fehler + */ + function AudioMax_SetMainPower($instanceId, $value) { + $server = AudioMax_GetServer($instanceId); + return $server->SendData(AM_TYP_SET, AM_CMD_POWER, null, null, $value); + } + + /** + * Status ServerPower lesen + * + * @param int $instanceId ID des AudioMax Servers + * @return boolean Power Status + */ + function AudioMax_GetMainPower($instanceId) { + $server = AudioMax_GetServer($instanceId); + return $server->SendData(AM_TYP_GET, AM_CMD_POWER, null, null, null); + } + + /** + * Ein- und Ausschalten eines einzelnen Raumes + * + * @param int $instanceId ID des AudioMax Servers + * @param int $roomId Raum der geändert werden soll (0-3) + * @param string $value TRUE oder '1' für An, FALSE oder '0' für Aus + * @return boolean Funktions Ergebnis, TRUE für OK, FALSE für Fehler + */ + function AudioMax_SetRoomPower($instanceId, $roomId, $value) { + $server = AudioMax_GetServer($instanceId); + return $server->SendData(AM_TYP_SET, AM_CMD_ROOM, $roomId, null, $value); + } + + /** + * Status Raumverstärker lesen + * + * @param int $instanceId ID des AudioMax Servers + * @param int $roomId Raum der ausgelesen werden soll (0-3) + * @return boolean Status Raumverstärker + */ + function AudioMax_GetRoomPower($instanceId, $roomId) { + $server = AudioMax_GetServer($instanceId); + return $server->SendData(AM_TYP_GET, AM_CMD_ROOM, $roomId, null, null); + } + + /** + * Auswahl des Eingangs, der für einen bestimmten Raum verwendet werden soll + * + * @param int $instanceId ID des AudioMax Servers + * @param int $roomId Raum der geändert werden soll (0-3) + * @param int $value Eingang (1-4) + * @return boolean Funktions Ergebnis, TRUE für OK, FALSE für Fehler + */ + function AudioMax_SetInputSelect($instanceId, $roomId, $value) { + $server = AudioMax_GetServer($instanceId); + return $server->SendData(AM_TYP_SET, AM_CMD_AUDIO, $roomId, AM_FNC_INPUTSELECT, $value); + } + + /** + * Eingangswahlschalter lesen + * + * @param int $instanceId ID des AudioMax Servers + * @param int $roomId Raum der ausgelesen werden soll (0-3) + * @return int Eingangswahl (1-4) + */ + function AudioMax_GetInputSelect($instanceId, $roomId) { + $server = AudioMax_GetServer($instanceId); + return $server->SendData(AM_TYP_GET, AM_CMD_AUDIO, $roomId, AM_FNC_INPUTSELECT, null)+1; + } + + /** + * Eingangsverstärkung setzen + * + * @param int $instanceId ID des AudioMax Servers + * @param int $roomId Raum der geändert werden soll (0-3) + * @param int $value Verstärkung (0-15) + * @return boolean Funktions Ergebnis, TRUE für OK, FALSE für Fehler + */ + function AudioMax_SetInputGain($instanceId, $roomId, $value) { + $server = AudioMax_GetServer($instanceId); + return $server->SendData(AM_TYP_SET, AM_CMD_AUDIO, $roomId, AM_FNC_INPUTGAIN, $value); + } + + /** + * Eingangsverstärkung lesen + * + * @param int $instanceId ID des AudioMax Servers + * @param int $roomId Raum der ausgelesen werden soll (0-3) + * @return int Verstärkung (0-15) + */ + function AudioMax_GetInputGain($instanceId, $roomId) { + $server = AudioMax_GetServer($instanceId); + return $server->SendData(AM_TYP_GET, AM_CMD_AUDIO, $roomId, AM_FNC_INPUTGAIN, null); + } + + /** + * Laustärke setzen + * + * @param int $instanceId ID des AudioMax Servers + * @param int $roomId Raum der geändert werden soll (0-3) + * @param int $value Lautstärke (0-40) + * @return boolean Funktions Ergebnis, TRUE für OK, FALSE für Fehler + */ + function AudioMax_SetVolume($instanceId, $roomId, $value) { + $server = AudioMax_GetServer($instanceId); + return $server->SendData(AM_TYP_SET, AM_CMD_AUDIO, $roomId, AM_FNC_VOLUME, round(AM_VAL_VOLUME_MAX-$value)); + } + + /** + * Laustärke lesen + * + * @param int $instanceId ID des AudioMax Servers + * @param int $roomId Raum der ausgelesen werden soll (0-3) + * @return int Lautstärke (0-40) + */ + function AudioMax_GetVolume($instanceId, $roomId) { + $server = AudioMax_GetServer($instanceId); + return $server->SendData(AM_TYP_GET, AM_CMD_AUDIO, $roomId, AM_FNC_VOLUME, null); + } + + /** + * Muting setzen + * + * @param int $instanceId ID des AudioMax Servers + * @param int $roomId Raum der geändert werden soll (0-3) + * @param string $value TRUE oder '1' für An, FALSE oder '0' für Aus + * @return boolean Funktions Ergebnis, TRUE für OK, FALSE für Fehler + */ + function AudioMax_SetMute($instanceId, $roomId, $value) { + $server = AudioMax_GetServer($instanceId); + return $server->SendData(AM_TYP_SET, AM_CMD_AUDIO, $roomId, AM_FNC_MUTE, $value); + } + + /** + * Status Muting lesen + * + * @param int $instanceId ID des AudioMax Servers + * @param int $roomId Raum der ausgelesen werden soll (0-3) + * @return boolean Status Muting + */ + function AudioMax_GetMute($instanceId, $roomId) { + $server = AudioMax_GetServer($instanceId); + return $server->SendData(AM_TYP_GET, AM_CMD_AUDIO, $roomId, AM_FNC_MUTE, null); + } + + /** + * Balance setzen + * + * @param int $instanceId ID des AudioMax Servers + * @param int $roomId Raum der geändert werden soll (0-3) + * @param int $value Wert Balance (0-15) + * @return boolean Funktions Ergebnis, TRUE für OK, FALSE für Fehler + */ + function AudioMax_SetBalance($instanceId, $roomId, $value) { + $server = AudioMax_GetServer($instanceId); + return $server->SendData(AM_TYP_SET, AM_CMD_AUDIO, $roomId, AM_FNC_BALANCE, $value); + } + + /** + * Balance lesen + * + * @param int $instanceId ID des AudioMax Servers + * @param int $roomId Raum der ausgelesen werden soll (0-3) + * @return int Wert Balance (0-15) + */ + function AudioMax_GetBalance($instanceId, $roomId) { + $server = AudioMax_GetServer($instanceId); + return $server->SendData(AM_TYP_GET, AM_CMD_AUDIO, $roomId, AM_FNC_BALANCE, null); + } + + /** + * Einstellung Höhen + * + * @param int $instanceId ID des AudioMax Servers + * @param int $roomId Raum der geändert werden soll (0-3) + * @param int $value Wert Höhen (0-15) + * @return boolean Funktions Ergebnis, TRUE für OK, FALSE für Fehler + */ + function AudioMax_SetTreble($instanceId, $roomId, $value) { + $server = AudioMax_GetServer($instanceId); + return $server->SendData(AM_TYP_SET, AM_CMD_AUDIO, $roomId, AM_FNC_TREBLE, $value); + } + + /** + * Einstellung Höhen lesen + * + * @param int $instanceId ID des AudioMax Servers + * @param int $roomId Raum der ausgelesen werden soll (0-3) + * @return int Wert Höhen (0-15) + */ + function AudioMax_GetTreble($instanceId, $roomId) { + $server = AudioMax_GetServer($instanceId); + return $server->SendData(AM_TYP_GET, AM_CMD_AUDIO, $roomId, AM_FNC_TREBLE, null); + } + + /** + * Einstellung Mitten + * + * @param int $instanceId ID des AudioMax Servers + * @param int $roomId Raum der geändert werden soll (0-3) + * @param int $value Wert Mitten (0-15) + * @return boolean Funktions Ergebnis, TRUE für OK, FALSE für Fehler + */ + function AudioMax_SetMiddle($instanceId, $roomId, $value) { + $server = AudioMax_GetServer($instanceId); + return $server->SendData(AM_TYP_SET, AM_CMD_AUDIO, $roomId, AM_FNC_MIDDLE, $value); + } + + /** + * Einstellung Mitten lesen + * + * @param int $instanceId ID des AudioMax Servers + * @param int $roomId Raum der ausgelesen werden soll (0-3) + * @return int Wert Mitten (0-15) + */ + function AudioMax_GetMiddle($instanceId, $roomId) { + $server = AudioMax_GetServer($instanceId); + return $server->SendData(AM_TYP_GET, AM_CMD_AUDIO, $roomId, AM_FNC_MIDDLE, null); + } + + /** + * Einstellung Bass setzen + * + * @param int $instanceId ID des AudioMax Servers + * @param int $roomId Raum der geändert werden soll (0-3) + * @param int $value Wert Bass (0-15) + * @return boolean Funktions Ergebnis, TRUE für OK, FALSE für Fehler + */ + function AudioMax_SetBass($instanceId, $roomId, $value) { + $server = AudioMax_GetServer($instanceId); + return $server->SendData(AM_TYP_SET, AM_CMD_AUDIO, $roomId, AM_FNC_BASS, $value); + } + + /** + * Einstellung Bass lesen + * + * @param int $instanceId ID des AudioMax Servers + * @param int $roomId Raum der ausgelesen werden soll (0-3) + * @return int Wert Bass (0-15) + */ + function AudioMax_GetBass($instanceId, $roomId) { + $server = AudioMax_GetServer($instanceId); + return $server->SendData(AM_TYP_GET, AM_CMD_AUDIO, $roomId, AM_FNC_BASS, null); + } + + /** + * Set Mode + * + * @param int $instanceId ID des AudioMax Servers + * @param int $mode Mode (0-4) + * @param int $value Wert (0 oder 1) + * @return boolean Funktions Ergebnis, TRUE für OK, FALSE für Fehler + */ + function AudioMax_SetMode($instanceId, $mode, $value) { + $server = AudioMax_GetServer($instanceId); + return $server->SendData(AM_TYP_SET, AM_CMD_MODE, null, $mode, $value); + } + + /** + * Get Mode + * + * @param int $instanceId ID des AudioMax Servers + * @param int $mode Mode (0-4) + * @return integer Mode Value (0 oder 1) + */ + function AudioMax_GetMode($instanceId, $mode) { + $server = AudioMax_GetServer($instanceId); + return $server->SendData(AM_TYP_SET, AM_CMD_MODE, null, $mode, null); + } + + /** + * Set Text + * + * @param int $instanceId ID des AudioMax Servers + * @param string $text1 Text Zeile 1 + * @param string $text2 Text Zeile 2 + * @param string $text3 Text Zeile 3 + * @return boolean Funktions Ergebnis, TRUE für OK, FALSE für Fehler + */ + function AudioMax_SetText($instanceId, $text1, $text2=null, $text3=null) { + $server = AudioMax_GetServer($instanceId); + return $server->SendData(AM_TYP_SET, AM_CMD_TEXT, null, null, $text1.AM_COM_SEPARATOR.$text2.AM_COM_SEPARATOR.$text3); + } + + /** + * Get Server + * + * @param int $instanceId ID des AudioMax Servers + * @return AudioMax AudioMax Server Object + */ + function AudioMax_GetServer($instanceId) { + if ($instanceId==null) { + $instanceId = IPSUtil_ObjectIDByPath('Program.IPSLibrary.data.hardware.AudioMax.AudioMax_Server'); + } + return new AudioMax_Server($instanceId); + } + + + /** @}*/ + + +?> \ No newline at end of file diff --git a/IPSLibrary/app/hardware/AudioMax/AudioMax_ChangeSettings.ips.php b/IPSLibrary/app/hardware/AudioMax/AudioMax_ChangeSettings.ips.php new file mode 100644 index 0000000..5cbb0ff --- /dev/null +++ b/IPSLibrary/app/hardware/AudioMax/AudioMax_ChangeSettings.ips.php @@ -0,0 +1,103 @@ + + * AudioMax Action Script + * + * Dieses Script ist als Action Script für diverse AudioMax Variablen hinterlegt, um + * eine Änderung über das WebFront zu ermöglichen. + * + */ + + include_once 'AudioMax.inc.php'; + + $variableId = $_IPS['VARIABLE']; + $variableValue = $_IPS['VALUE']; + $variableIdent = IPS_GetIdent($variableId); + + $serverId = IPSUtil_ObjectIDByPath('Program.IPSLibrary.data.hardware.AudioMax.AudioMax_Server'); + $instanceId = IPS_GetParent($variableId); + if ($serverId<>$instanceId) { + $roomIds = GetValue(IPS_GetObjectIDByIdent(AM_VAR_ROOMIDS, $serverId)); + $roomList = array_flip(explode(',',$roomIds)); + $roomId = $roomList[$instanceId]; + } + + switch($variableIdent) { + case AM_VAR_CONNECTION: + $server = new AudioMax_Server($serverId); + $server->SetConnection($variableValue); + break; + + case AM_VAR_MODESERVERDEBUG: + AudioMax_SetMode($serverId, AM_MOD_SERVERDEBUG, $variableValue); + break; + case AM_VAR_MODEACKNOWLEDGE: + AudioMax_SetMode($serverId, AM_MOD_ACKNOWLEDGE, $variableValue); + break; + case AM_VAR_MODEPOWERREQUEST: + AudioMax_SetMode($serverId, AM_MOD_POWERREQUEST, $variableValue); + break; + case AM_VAR_MODEEMULATESTATE: + SetValue(IPS_GetObjectIDByIdent(AM_VAR_MODEEMULATESTATE, $instanceId), $variableValue); + break; + + case AM_VAR_MAINPOWER: + AudioMax_SetMainPower($serverId, $variableValue); + break; + + case AM_VAR_ROOMPOWER: + AudioMax_SetRoomPower($serverId , $roomId, $variableValue); + break; + case AM_VAR_BALANCE: + AudioMax_SetBalance($serverId , $roomId, $variableValue); + break; + case AM_VAR_VOLUME: + AudioMax_SetVolume($serverId , $roomId, $variableValue); + break; + case AM_VAR_MUTE: + AudioMax_SetMute($serverId , $roomId, $variableValue); + break; + case AM_VAR_TREBLE: + AudioMax_SetTreble($serverId , $roomId, $variableValue); + break; + case AM_VAR_MIDDLE: + AudioMax_SetMiddle($serverId , $roomId, $variableValue); + break; + case AM_VAR_BASS: + AudioMax_SetBass($serverId , $roomId, $variableValue); + break; + case AM_VAR_INPUTSELECT: + AudioMax_SetInputSelect($serverId , $roomId, $variableValue); + break; + case AM_VAR_INPUTGAIN: + AudioMax_SetInputGain($serverId , $roomId, $variableValue); + break; + default: + break; + } + ; + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/hardware/AudioMax/AudioMax_Constants.inc.php b/IPSLibrary/app/hardware/AudioMax/AudioMax_Constants.inc.php new file mode 100644 index 0000000..de1385f --- /dev/null +++ b/IPSLibrary/app/hardware/AudioMax/AudioMax_Constants.inc.php @@ -0,0 +1,167 @@ + + * + * Prinzipieller Aufbau der Kommunikation: + * CommandType Command Room Function Value + * + * Jeder Kommando Teil wird durch einen Separator voneinander getrennt (Semikolon). Terminiert + * wird jedes Kommando von einem CR. + * + * Examples: + * set;svr;pwr;1\ AudioMax Server Ein + * evt;svr;kal;0\ Keep alive Message vom Server + * set;svr;roo;00;1\ Raumverstärker in Raum 1 einschalten + * set;svr;aud;00;inp;1\ Eingang 2 in Raum 1 selektieren + * set;svr;aud;02;vol;08\ Lautstärke in Raum 3 auf 8 + * set;svr;aud;03;bas;14\ Bass Raum 4 auf 14 + * + * + */ + define ('AM_COM_SEPARATOR', ';'); + define ('AM_COM_TERMINATOR', chr(13)); + define ('AM_COM_KEEPALIVE', 60); + define ('AM_COM_MAXRETRIES', 8); + define ('AM_COM_WAIT', 50); + define ('AM_COM_MAXWAIT', 500); + + // Kommunikations Kommando Typen + define ('AM_TYP_SET', 'SET'); + define ('AM_TYP_GET', 'GET'); + define ('AM_TYP_EVT', 'EVT'); + define ('AM_TYP_DBG', 'DBG'); + + // Kommunikations Device Type + define ('AM_DEV_SERVER', 'SVR'); + + // Error Codes + define ('AM_ERR_UNKNOWNCMD1', '1'); + define ('AM_ERR_UNKNOWNCMD2', '2'); + define ('AM_ERR_UNKNOWNCMD3', '3'); + define ('AM_ERR_UNKNOWNCMD4', '4'); + define ('AM_ERR_UNKNOWNCMD5', '5'); + + // Acknowledge + define ('AM_VAL_ACKNOWLEDGE', '0'); + + // Kommunikations Kommandos + define ('AM_CMD_POWER', 'PWR'); + define ('AM_CMD_KEEPALIVE', 'KAL'); + define ('AM_CMD_AUDIO', 'AUD'); + define ('AM_CMD_ROOM', 'ROO'); + define ('AM_CMD_TEXT', 'TEX'); + define ('AM_CMD_MODE', 'MOD'); + + // Kommunikations Actions + define ('AM_FNC_POWERREQUEST', 'PUS'); + define ('AM_FNC_BALANCE', 'BAL'); + define ('AM_FNC_VOLUME', 'VOL'); + define ('AM_FNC_MUTE', 'MUT'); + define ('AM_FNC_TREBLE', 'TRE'); + define ('AM_FNC_MIDDLE', 'MID'); + define ('AM_FNC_BASS', 'BAS'); + define ('AM_FNC_INPUTSELECT', 'INP'); + define ('AM_FNC_INPUTGAIN', 'GAI'); + + // Modes + define ('AM_MOD_ACKNOWLEDGE', 0); + define ('AM_MOD_SERVERDEBUG', 1); + define ('AM_MOD_POWERREQUEST', 2); + define ('AM_MOD_KEEPALIVE', 3); + + // Max, Min und Default Werte + define ('AM_VAL_ROOM_MIN', 0); + define ('AM_VAL_ROOM_MAX', 15); + + define ('AM_VAL_BOOLEAN_FALSE', 0); + define ('AM_VAL_BOOLEAN_TRUE', 1); + + define ('AM_VAL_VOLUME_MIN', 0); + define ('AM_VAL_VOLUME_MAX', 40); + define ('AM_VAL_VOLUME_DEFAULT', 20); + + define ('AM_VAL_MUTE_OFF', AM_VAL_BOOLEAN_FALSE); + define ('AM_VAL_MUTE_ON', AM_VAL_BOOLEAN_TRUE); + define ('AM_VAL_MUTE_DEFAULT', AM_VAL_BOOLEAN_FALSE); + + define ('AM_VAL_TREBLE_MIN', 0); + define ('AM_VAL_TREBLE_MAX', 15); + define ('AM_VAL_TREBLE_DEFAULT', 7); + + define ('AM_VAL_BALANCE_MIN', 0); + define ('AM_VAL_BALANCE_MAX', 15); + define ('AM_VAL_BALANCE_DEFAULT', 0); + + define ('AM_VAL_MIDDLE_MIN', 0); + define ('AM_VAL_MIDDLE_MAX', 15); + define ('AM_VAL_MIDDLE_DEFAULT', 7); + + define ('AM_VAL_BASS_MIN', 0); + define ('AM_VAL_BASS_MAX', 15); + define ('AM_VAL_BASS_DEFAULT', 7); + + define ('AM_VAL_INPUTSELECT_MIN', 0); + define ('AM_VAL_INPUTSELECT_MAX', 3); + define ('AM_VAL_INPUTSELECT_DEFAULT', 0); + + define ('AM_VAL_INPUTGAIN_MIN', 0); + define ('AM_VAL_INPUTGAIN_MAX', 15); + define ('AM_VAL_INPUTGAIN_DEFAULT', 7); + + define ('AM_VAL_POWER_OFF', AM_VAL_BOOLEAN_FALSE); + define ('AM_VAL_POWER_ON', AM_VAL_BOOLEAN_TRUE); + define ('AM_VAL_POWER_DEFAULT', AM_VAL_BOOLEAN_FALSE); + + + // Variablen Definitionen + define ('AM_VAR_MAINPOWER', 'MAINPOWER'); + define ('AM_VAR_BUSY', 'BUSY'); + define ('AM_VAR_CONNECTION', 'CONNECTION'); + define ('AM_VAR_ROOMCOUNT', 'ROOM_COUNT'); + define ('AM_VAR_ROOMIDS', 'ROOM_IDS'); + define ('AM_VAR_PORTID', 'PORT_ID'); + define ('AM_VAR_KEEPALIVECOUNT', 'KEEP_ALIVE_COUNT'); + define ('AM_VAR_KEEPALIVESTATUS', 'KEEP_ALIVE_STATUS'); + define ('AM_VAR_LASTERROR', 'LAST_ERROR'); + define ('AM_VAR_LASTCOMMAND', 'LAST_COMMAND'); + define ('AM_VAR_INPUTBUFFER', 'INPUT_BUFFER'); + define ('AM_VAR_MODESERVERDEBUG', 'MODE_SERVERDEBUG'); + define ('AM_VAR_MODEPOWERREQUEST', 'MODE_POWERREQUEST'); + define ('AM_VAR_MODEEMULATESTATE', 'MODE_EMULATESTATE'); + define ('AM_VAR_MODEACKNOWLEDGE', 'MODE_ACKNOWLEDGE'); + + define ('AM_VAR_ROOMPOWER', 'ROOMPOWER'); + define ('AM_VAR_BALANCE', 'BALANCE'); + define ('AM_VAR_MUTE', 'MUTE'); + define ('AM_VAR_VOLUME', 'VOLUME'); + define ('AM_VAR_TREBLE', 'TREBLE'); + define ('AM_VAR_MIDDLE', 'MIDDLE'); + define ('AM_VAR_BASS', 'BASS'); + define ('AM_VAR_INPUTSELECT', 'INPUTSELECT'); + define ('AM_VAR_INPUTGAIN', 'INPUTGAIN'); + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/hardware/AudioMax/AudioMax_KeepAlive.ips.php b/IPSLibrary/app/hardware/AudioMax/AudioMax_KeepAlive.ips.php new file mode 100644 index 0000000..0a840e8 --- /dev/null +++ b/IPSLibrary/app/hardware/AudioMax/AudioMax_KeepAlive.ips.php @@ -0,0 +1,71 @@ + + * + * Dieses Script wird von Timer aufgerufen, um die "Keep Alive" Message zu senden bzw. + * das Signal vom Server zu überprüfen. + * + */ + + include_once 'AudioMax.inc.php'; + + $serverId = IPSUtil_ObjectIDByPath('Program.IPSLibrary.data.hardware.AudioMax.AudioMax_Server'); + $eventName = IPS_GetName($_IPS['EVENT']); + + // Alle 60 Sek wird KeepAlive Message zum Server gesendet + if ($eventName == 'SendAlive') { + $server = new AudioMax_Server($serverId); + $server->SendData(AM_TYP_SET, AM_CMD_KEEPALIVE, null, null, '0'); + } + + // Alle 65 Sekunden wird überprüft, ob eine KeepAlive Message vom Server erhalten wurde. + // Keep Alive Count wird alle 65 Sekunden erhöht und muss innerhalb des nächsten + // Zyklus durch eine Message vom Server wieder auf 0 gesetzt werden. + if ($eventName == 'CheckAlive') { + // Read KeepAliveStatus: false=Error, true=OK + $id_Status = IPS_GetVariableIDByName(AM_VAR_KEEPALIVESTATUS, $serverId); + + // Read KeepAliveFlag: ">0"=Waiting, 0=OK + $id_Count = IPS_GetVariableIDByName(AM_VAR_KEEPALIVECOUNT, $serverId); + + // Count not reseted by KeepAlive Message and Status=OK -> Status=Error + if (GetValue($id_Count) > 1 and GetValue($id_Status)) { + SetValue($id_Status, false); + IPSLogger_Wrn(__file__, 'AudioMax KeepAlive Message Stream is broken'); + + // Count cleared by KeepAlive and Status Error -> Status=OK + } else if (GetValue($id_Count)==0 and !GetValue($id_Status)) { + SetValue($id_Status, true); + IPSLogger_Inf(__file__, 'AudioMax KeepAlive Message Stream is online again'); + + } else { + } + + // KeepAliveFlag=Waiting + SetValue($id_Count, GetValue($id_Count)+1); + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/hardware/AudioMax/AudioMax_Receive.ips.php b/IPSLibrary/app/hardware/AudioMax/AudioMax_Receive.ips.php new file mode 100644 index 0000000..58138a7 --- /dev/null +++ b/IPSLibrary/app/hardware/AudioMax/AudioMax_Receive.ips.php @@ -0,0 +1,41 @@ + + * + */ + + include_once 'AudioMax.inc.php'; + + $msg = $_IPS['VALUE']; + + $serverId = IPSUtil_ObjectIDByPath('Program.IPSLibrary.data.hardware.AudioMax.AudioMax_Server'); + + $server = new AudioMax_Server($serverId); + $server->ReceiveData($msg); + + /** @}*/ + +?> \ No newline at end of file diff --git a/IPSLibrary/app/hardware/AudioMax/AudioMax_Room.class.php b/IPSLibrary/app/hardware/AudioMax/AudioMax_Room.class.php new file mode 100644 index 0000000..a0d8ae4 --- /dev/null +++ b/IPSLibrary/app/hardware/AudioMax/AudioMax_Room.class.php @@ -0,0 +1,126 @@ + + */ + class AudioMax_Room { + + /** + * @private + * ID des AudioMax Server + */ + private $instanceId; + + /** + * @private + * Variablen Mapping der Befehle + */ + private $functionMapping; + + /** + * @public + * + * Initialisiert einen AudioMax Raum + * + * @param $instanceId - ID des AudioMax Server. + */ + public function __construct($instanceId) { + $this->instanceId = $instanceId; + $this->functionMapping = array( + AM_FNC_VOLUME => AM_VAR_VOLUME, + AM_FNC_MUTE => AM_VAR_MUTE, + AM_FNC_BALANCE => AM_VAR_BALANCE, + AM_FNC_INPUTSELECT => AM_VAR_INPUTSELECT, + AM_FNC_INPUTGAIN => AM_VAR_INPUTGAIN, + AM_FNC_TREBLE => AM_VAR_TREBLE, + AM_FNC_MIDDLE => AM_VAR_MIDDLE, + AM_FNC_BASS => AM_VAR_BASS, + ); + } + + /** + * @public + * + * Liefert den zugehörigen Variablen Namen für eine Message + * + * @param string $command Kommando + * @param string $function Funktion + */ + private function GetVariableName($command, $function) { + switch($command) { + case AM_CMD_ROOM: + $variableName = AM_VAR_ROOMPOWER; + break; + case AM_CMD_AUDIO: + $variableName = $this->functionMapping[$function]; + break; + default: + throw new Exception('Unknown Command "'.$command.'", VariableName could NOT be found !!!'); + } + return $variableName; + } + + /** + * @public + * + * Liefert den aktuellen Wert für eine Message + * + * @param string $command Kommando + * @param string $function Funktion + * @return string Wert + */ + public function GetValue ($command, $function) { + $name = $this->GetVariableName($command, $function); + return GetValue(IPS_GetObjectIDByIdent($name, $this->instanceId)); + } + + /** + * @public + * + * Setzt den Wert einer Variable auf den Wert einer Message + * + * @param string $command Kommando + * @param string $function Funktion + * @param string $value Wert + */ + public function SetValue ($command, $function, $value) { + $name = $this->GetVariableName($command, $function); + $variableId = IPS_GetObjectIDByIdent($name, $this->instanceId); + if (GetValue($variableId)<>$value) { + SetValue($variableId, $value); + } + } + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/hardware/AudioMax/AudioMax_Server.class.php b/IPSLibrary/app/hardware/AudioMax/AudioMax_Server.class.php new file mode 100644 index 0000000..0045816 --- /dev/null +++ b/IPSLibrary/app/hardware/AudioMax/AudioMax_Server.class.php @@ -0,0 +1,804 @@ + + */ + class AudioMax_Server { + + /** + * @private + * ID des AudioMax Server + */ + private $instanceId; + + /** + * @private + * Retry Count Senden + */ + private $retryCount; + + /** + * @private + * Debugging of AudioMax Server Enabled/Disabled + */ + private $debugEnabled; + + /** + * @public + * + * Initializes the AudioMax Server + * + * @param integer $instanceId - ID des AudioMax Server. + */ + public function __construct($instanceId) { + $this->instanceId = $instanceId; + $this->debugEnabled = GetValue(IPS_GetObjectIDByIdent(AM_VAR_MODESERVERDEBUG, $this->instanceId)); + $this->retryCount = 0; + } + + /** + * @private + * + * Protokollierung einer Meldung im AudioMax Log + * + * @param string $logType Type der Logging Meldung + * @param string $msg Meldung + */ + private function Log ($logType, $msg) { + if ($this->debugEnabled) { + IPSLogger_WriteFile("", 'AudioMax.log', date('Y-m-d H:i:s').' '.$logType.' - '.$msg, null); + } + } + + /** + * @private + * + * Protokollierung einer Error Meldung + * + * @param string $msg Meldung + */ + private function LogErr($msg) { + IPSLogger_Err(__file__, $msg); + $this->Log('Err', $msg); + $variableId = IPS_GetObjectIDByIdent(AM_VAR_LASTERROR, $this->instanceId); + SetValue($variableId, $msg); + } + + /** + * @private + * + * Protokollierung einer Info Meldung + * + * @param string $msg Meldung + */ + private function LogInf($msg) { + IPSLogger_Inf(__file__, $msg); + $this->Log('Inf', $msg); + } + + /** + * @private + * + * Protokollierung einer Debug Meldung + * + * @param string $msg Meldung + */ + private function LogDbg($msg) { + IPSLogger_Dbg(__file__, $msg); + $this->Log('Dbg', $msg); + } + + /** + * @private + * + * Protokollierung einer Kommunikations Meldung + * + * @param string $msg Meldung + */ + private function LogCom($msg) { + IPSLogger_Com(__file__, $msg); + $this->Log('Com', $msg); + } + + /** + * @private + * + * Protokollierung einer Trace Meldung + * + * @param string $msg Meldung + */ + private function LogTrc($msg) { + IPSLogger_Trc(__file__, $msg); + $this->Log('Trc', $msg); + } + + /** + * @public + * + * Setz den Status der Verbindung auf Active oder Inactiv. + * Im inaktiven Zustand wird der IO Port deaktiviert und alle ausgehenden Meldungen ignoriert. + * + * @param boolean $value Status der Verbindung. + */ + public function SetConnection($value) { + $variableId = IPS_GetObjectIDByIdent(AM_VAR_CONNECTION, $this->instanceId); + SetValue($variableId, $value); + + $this->LogInf('Set AudioMax Connection Status to '.($value ? 'Connection Active' : 'Connection Inactiv')); + + $comPortId = GetValue(IPS_GetObjectIDByIdent('PORT_ID', $this->instanceId)); + COMPort_SetOpen($comPortId, $value); + IPS_ApplyChanges($comPortId); + if ($value) { + $this->SendData(AM_TYP_SET, AM_CMD_KEEPALIVE, null, null, '0'); + } + } + + /** + * @private + * + * Ermittelt ob die Instanzen der Räume installiert sind + * + * @return boolean Räume installiert + */ + private function GetAudioMaxRoomVariablesEnabled() { + $roomIds = GetValue(IPS_GetObjectIDByIdent(AM_VAR_ROOMIDS, $this->instanceId)); + return ($roomIds <> ''); + } + + /** + * @private + * + * Liefert ein AudioMaxRoom Objekt für eine Raum Nummer, sind keine Räume vorhanden + * liefert die Funktion false. + * + * @param integer $roomId Nummer des Raumes (1-4). + * @return AudioMax_Room AudioMax Room Object + */ + private function GetAudioMaxRoom($roomId) { + $roomIds = GetValue(IPS_GetObjectIDByIdent(AM_VAR_ROOMIDS, $this->instanceId)); + if ($roomIds=="") { + return false; + } + $roomIds = explode(',', $roomIds); + $roomInstanceId = false; + $audioMaxRoom = false; + if (array_key_exists($roomId, $roomIds)) { + $roomInstanceId = (int)$roomIds[$roomId]; + $audioMaxRoom = new AudioMax_Room($roomInstanceId); + } + + return $audioMaxRoom; + } + + + /** + * @private + * + * Validieren der Daten und Variablen setzen + * + * @param string $type Kommando Type + * @param string $command Kommando + * @param integer $roomId Nummer des Raumes + * @param string $function Funktion + * @param string $value Wert + */ + private function ValidateAndSetValue ($type, $command, $roomId, $function, $value) { + if ($this->ValidateData($type, $command, $roomId, $function, $value)) { + $this->SetValue($type, $command, $roomId, $function, $value); + } + } + + /** + * @private + * + * Setzt den ensprechenden Wert einer Variable auf den Wert der Message + * + * @param string $type Kommando Type + * @param string $command Kommando + * @param integer $roomId Nummer des Raumes + * @param string $function Funktion + * @param string $value Wert + */ + private function SetValue ($type, $command, $roomId, $function, $value) { + if ($type==AM_TYP_GET) { + return; + } + if ($command==AM_CMD_POWER or $command==AM_CMD_ROOM) { + if ($value===AM_VAL_BOOLEAN_TRUE) $value=true; + if ($value===AM_VAL_BOOLEAN_FALSE) $value=false; + } + $modification = false; + switch ($command) { + case AM_CMD_POWER: + $variableId = IPS_GetObjectIDByIdent(AM_VAR_MAINPOWER, $this->instanceId); + if (GetValue($variableId)<>$value) { + SetValue($variableId, $value); + $modification = true; + } + break; + case AM_CMD_TEXT: + break; + case AM_CMD_MODE: + if ($function==AM_MOD_SERVERDEBUG) { + $variableId = IPS_GetObjectIDByIdent(AM_VAR_MODESERVERDEBUG, $this->instanceId); + if (GetValue($variableId)<>$value) { + SetValue($variableId, $value); + $modification = true; + } + } + if ($function==AM_MOD_POWERREQUEST) { + $variableId = IPS_GetObjectIDByIdent(AM_VAR_MODEPOWERREQUEST, $this->instanceId); + if (GetValue($variableId)<>$value) { + SetValue($variableId, $value); + $modification = true; + } + } + if ($function==AM_MOD_ACKNOWLEDGE) { + $variableId = IPS_GetObjectIDByIdent(AM_VAR_MODEACKNOWLEDGE, $this->instanceId); + if (GetValue($variableId)<>$value) { + SetValue($variableId, $value); + $modification = true; + } + } + break; + case AM_CMD_ROOM: + $room = $this->GetAudioMaxRoom($roomId); + if ($room===false) { + $modification = true; + break; + } + if ($room->GetValue($command, '')<>$value) { + $room->SetValue($command, '', $value); + $modification = true; + } + break; + case AM_CMD_AUDIO: + if ($function==AM_FNC_VOLUME) $value=AM_VAL_VOLUME_MAX-$value; + $room = $this->GetAudioMaxRoom($roomId); + if ($room===false) { + $modification = true; + break; + } + if ($room->GetValue($command, $function)<>$value) { + $room->SetValue($command, $function, $value); + $modification = true; + } + break; + case AM_CMD_KEEPALIVE: + $modification = true; + break; + default: + $this->LogErr('Unknown Command '.$command); + } + if ($modification) { + SetValue(IPS_GetObjectIDByIdent(AM_VAR_LASTCOMMAND, $this->instanceId), $this->BuildMsg($type, $command, $roomId, $function, $value, false)); + SetValue(IPS_GetObjectIDByIdent(AM_VAR_LASTERROR, $this->instanceId), ""); + } + } + + /** + * @private + * + * Lesen der AudioMax Werte aus den Instanz Variablen + * + * @param string $type Kommando Type + * @param string $command Kommando + * @param integer $roomId Nummer des Raumes + * @param string $function Funktion + * @return string Wert + */ + private function GetValue ($type, $command, $roomId, $function) { + $result = ''; + if ($type==AM_TYP_GET) { + switch ($command) { + case AM_CMD_POWER: + $result = GetValue(IPS_GetObjectIDByIdent(AM_VAR_MAINPOWER, $this->instanceId)); + break; + case AM_CMD_TEXT: + case AM_CMD_MODE: + case AM_CMD_KEEPALIVE: + break; + case AM_CMD_ROOM: + $room = $this->GetAudioMaxRoom($roomId); + if ($room!==false) { + $result = $room->GetValue($command, ''); + } + break; + case AM_CMD_AUDIO: + $room = $this->GetAudioMaxRoom($roomId); + if ($room!==false) { + $result = $room->GetValue($command, $function); + } + break; + default: + $this->LogErr('Unknown Command '.$command); + } + } + return $result; + } + + /** + * @public + * + * Setzt die AudioMax Variablen Werte auf den DEFAULT Wert zurück. + */ + public function Reset () { + $this->LogDbg("Execute AudioMax Reset ..."); + $this->SetValue(AM_TYP_SET, AM_CMD_POWER, null, null, AM_VAL_POWER_DEFAULT); + + $roomCount = GetValue(IPS_GetObjectIDByIdent(AM_VAR_ROOMCOUNT, $this->instanceId)); + for ($roomId=0;$roomId<$roomCount;$roomId++) { + $this->SetValue(AM_TYP_SET, AM_CMD_ROOM, $roomId, null, AM_VAL_POWER_DEFAULT); + $this->SetValue(AM_TYP_SET, AM_CMD_AUDIO, $roomId, AM_FNC_TREBLE, AM_VAL_TREBLE_DEFAULT); + $this->SetValue(AM_TYP_SET, AM_CMD_AUDIO, $roomId, AM_FNC_MIDDLE, AM_VAL_MIDDLE_DEFAULT); + $this->SetValue(AM_TYP_SET, AM_CMD_AUDIO, $roomId, AM_FNC_BASS, AM_VAL_BASS_DEFAULT); + $this->SetValue(AM_TYP_SET, AM_CMD_AUDIO, $roomId, AM_FNC_VOLUME, AM_VAL_VOLUME_DEFAULT); + $this->SetValue(AM_TYP_SET, AM_CMD_AUDIO, $roomId, AM_FNC_MUTE, AM_VAL_MUTE_DEFAULT); + $this->SetValue(AM_TYP_SET, AM_CMD_AUDIO, $roomId, AM_FNC_BALANCE, AM_VAL_BALANCE_DEFAULT); + $this->SetValue(AM_TYP_SET, AM_CMD_AUDIO, $roomId, AM_FNC_INPUTSELECT, AM_VAL_INPUTSELECT_DEFAULT); + $this->SetValue(AM_TYP_SET, AM_CMD_AUDIO, $roomId, AM_FNC_INPUTGAIN, AM_VAL_INPUTGAIN_DEFAULT); + } + } + + /** + * @public + * + * Initialisiert den AudioMax Server und setzt alle Einstellungen auf den aktuellen Wert von IPS zurück. + */ + public function Initialize () { + $this->LogDbg("Execute AudioMax Initialization ..."); + + $this->SendData(AM_TYP_SET, AM_CMD_POWER, null, null, GetValue(IPS_GetObjectIDByIdent(AM_VAR_MAINPOWER, $this->instanceId))); + + $roomCount = GetValue(IPS_GetObjectIDByIdent(AM_VAR_ROOMCOUNT, $this->instanceId)); + for ($roomId=0;$roomId<$roomCount;$roomId++) { + $room=$this->GetAudioMaxRoom($roomId); + $this->SendData(AM_TYP_SET, AM_CMD_ROOM, $roomId, null, $room->GetValue(AM_CMD_ROOM, '')); + $this->SendData(AM_TYP_SET, AM_CMD_AUDIO, $roomId, AM_FNC_TREBLE, $room->GetValue(AM_CMD_AUDIO, AM_FNC_TREBLE)); + $this->SendData(AM_TYP_SET, AM_CMD_AUDIO, $roomId, AM_FNC_MIDDLE, $room->GetValue(AM_CMD_AUDIO, AM_FNC_MIDDLE)); + $this->SendData(AM_TYP_SET, AM_CMD_AUDIO, $roomId, AM_FNC_BASS, $room->GetValue(AM_CMD_AUDIO, AM_FNC_BASS)); + $this->SendData(AM_TYP_SET, AM_CMD_AUDIO, $roomId, AM_FNC_VOLUME, $room->GetValue(AM_CMD_AUDIO, AM_FNC_VOLUME)); + $this->SendData(AM_TYP_SET, AM_CMD_AUDIO, $roomId, AM_FNC_MUTE, $room->GetValue(AM_CMD_AUDIO, AM_FNC_MUTE)); + $this->SendData(AM_TYP_SET, AM_CMD_AUDIO, $roomId, AM_FNC_BALANCE, $room->GetValue(AM_CMD_AUDIO, AM_FNC_BALANCE)); + $this->SendData(AM_TYP_SET, AM_CMD_AUDIO, $roomId, AM_FNC_INPUTSELECT, $room->GetValue(AM_CMD_AUDIO, AM_FNC_INPUTSELECT)); + $this->SendData(AM_TYP_SET, AM_CMD_AUDIO, $roomId, AM_FNC_INPUTGAIN, $room->GetValue(AM_CMD_AUDIO, AM_FNC_INPUTGAIN)); + } + } + + /** + * @private + * + * Setzt das BUSY Flag des AudioMax Server + */ + private function SetBusy() { + $result = IPS_SemaphoreEnter('AudioMax', 3000); + if ($result===true) { + $VariableId = IPS_GetObjectIDByIdent(AM_VAR_BUSY, $this->instanceId); + SetValue($VariableId, true); + } + return $result; + } + + /** + * @private + * + * Zurücksetzen des BUSY Flags des AudioMax Servers. + */ + private function ResetBusy() { + $VariableId = IPS_GetObjectIDByIdent(AM_VAR_BUSY, $this->instanceId); + SetValue($VariableId, false); + IPS_SemaphoreLeave('AudioMax'); + } + + + + /** + * @private + * + * Initializes the AudioMax Server Object + * + * @param string $type Kommando Type + * @param string $command Kommando + * @param integer $roomId Raum (1-4) + * @param string $function Funktion + * @param string $value Wert + * @return boolean TRUE für OK, FALSE bei Fehler + */ + private function BuildMsg($type, $command, $roomId, $function, $value, $addTerminator=true) { + if ($value===true) $value=AM_VAL_BOOLEAN_TRUE; + if ($value===false) $value=AM_VAL_BOOLEAN_FALSE; + + if ($type==AM_TYP_GET) { + $msg = $type.AM_COM_SEPARATOR.AM_DEV_SERVER.AM_COM_SEPARATOR.$command; + switch ($command) { + case AM_CMD_POWER: + case AM_CMD_KEEPALIVE: + case AM_CMD_TEXT: + case AM_CMD_MODE: + break; + case AM_CMD_ROOM: + $msg .= AM_COM_SEPARATOR.$roomId; + break; + case AM_CMD_AUDIO: + $msg .= AM_COM_SEPARATOR.$roomId.AM_COM_SEPARATOR.$function; + break; + default: + $this->LogErr("Unable to build Message - unknown Command '.$command'"); + exit; + } + } else { + $msg = $type.AM_COM_SEPARATOR.AM_DEV_SERVER.AM_COM_SEPARATOR.$command.AM_COM_SEPARATOR; + switch ($command) { + case AM_CMD_POWER: + case AM_CMD_KEEPALIVE: + case AM_CMD_TEXT: + $msg .= $value; + break; + case AM_CMD_MODE: + $msg .= $function.AM_COM_SEPARATOR.$value; + break; + case AM_CMD_ROOM: + $msg .= $roomId.AM_COM_SEPARATOR.$value; + break; + case AM_CMD_AUDIO: + $msg .= $roomId.AM_COM_SEPARATOR.$function.AM_COM_SEPARATOR; + //$msg .= str_pad($value, 2, '0', STR_PAD_LEFT);//$value; + $msg .= $value; + break; + default: + $this->LogErr("Unable to build Message - unknown Command '.$command'"); + exit; + } + } + if ($addTerminator) { + $msg .= AM_COM_TERMINATOR; + } + return $msg; + } + + /** + * @private + * + * Validierung der Daten + * + * @param string $type Kommando Type + * @param string $command Kommando + * @param integer $roomId Raum (1-4) + * @param string $function Funktion + * @param string $value Wert + * @return boolean TRUE für OK, FALSE bei Fehler + */ + private function ValidateData($type, $command, $roomId, $function, $value) { + $errorMsg = ''; + $result = false; + switch($command) { + case AM_CMD_POWER: + $result = ($value==true or $value==AM_VAL_BOOLEAN_TRUE or $value==false or $value==AM_VAL_BOOLEAN_FALSE); + $errorMsg = "Value '$value' for MainPower NOT in Range (use 0,1 or boolean)"; + break; + case AM_CMD_KEEPALIVE: /*0..1*/ + $result = ($value=='0'); + $errorMsg = "Value '$value' for KeepAlive NOT in Range (use '0')"; + break; + case AM_CMD_TEXT: + $result = true; + break; + case AM_CMD_MODE: /*0..1*/ + $result = ($value=='0' or $value=='1'); + $errorMsg = "Value '$value' for Mode NOT in Range (use '0')"; + break; + case AM_CMD_ROOM: + $roomOk = $roomId>=0 and $roomIdinstanceId)); + $result = $roomOk and ($value==true or $value==AM_VAL_BOOLEAN_TRUE or $value==false or $value==AM_VAL_BOOLEAN_FALSE); + $errorMsg = "Value '$value' for RoomPower NOT in Range (use 0,1 or boolean)"; + break; + case AM_CMD_AUDIO: + $roomOk = $roomId>=0 and $roomIdinstanceId)); + switch($function) { + case AM_FNC_VOLUME: /*0..78*/ + $result = $roomOk and ($value>=AM_VAL_VOLUME_MIN and $value<=AM_VAL_VOLUME_MAX); + $errorMsg = "Value '$value' for Volume NOT in Range (use ".AM_VAL_VOLUME_MIN." <= value <=".AM_VAL_VOLUME_MAX.")"; + break; + case AM_FNC_MUTE: /*0..78*/ + $result = $roomOk and ($value==true or $value==AM_VAL_BOOLEAN_TRUE or $value==false or $value==AM_VAL_BOOLEAN_FALSE); + $errorMsg = "Value '$value' for Mute NOT in Range (use 0,1 or boolean)"; + break; + case AM_FNC_BALANCE: /*0..78*/ + $result = $roomOk and ($value>=AM_VAL_BALANCE_MIN and $value<=AM_VAL_BALANCE_MAX); + $errorMsg = "Value '$value' for Balance NOT in Range (use ".AM_VAL_BALANCE_MIN." <= value <=".AM_VAL_BALANCE_MAX.")"; + break; + case AM_FNC_INPUTGAIN: /*1..15*/ + $result = $roomOk and ($value>=AM_VAL_INPUTGAIN_MIN and $value<=AM_VAL_INPUTGAIN_MAX); + $errorMsg = "Value '$value' for InputGain NOT in Range (use ".AM_VAL_INPUTGAIN_MIN." <= value <=".AM_VAL_INPUTGAIN_MAX.")"; + break; + case AM_FNC_INPUTSELECT: /*0..3*/ + $result = $roomOk and ($value>=AM_VAL_INPUTSELECT_MIN and $value<=AM_VAL_INPUTSELECT_MAX); + $errorMsg = "Value '$value' for InputSelect NOT in Range (use ".AM_VAL_INPUTSELECT_MIN." <= value <=".AM_VAL_INPUTSELECT_MAX.")"; + break; + case AM_FNC_TREBLE: /*0..14*/ + $result = $roomOk and ($value>=AM_VAL_TREBLE_MIN and $value<=AM_VAL_TREBLE_MAX); + $errorMsg = "Value '$value' for Treble NOT in Range (use ".AM_VAL_TREBLE_MIN." <= value <=".AM_VAL_TREBLE_MAX.")"; + break; + case AM_FNC_MIDDLE: /*0..14*/ + $result = $roomOk and ($value>=AM_VAL_MIDDLE_MIN and $value<=AM_VAL_MIDDLE_MAX); + $errorMsg = "Value '$value' for Middle NOT in Range (use ".AM_VAL_MIDDLE_MIN." <= value <=".AM_VAL_MIDDLE_MAX.")"; + break; + case AM_FNC_BASS: /*0..14*/ + $result = $roomOk and ($value>=AM_VAL_BASS_MIN and $value<=AM_VAL_BASS_MAX); + $errorMsg = "Value '$value' for Bass NOT in Range (use ".AM_VAL_BASS_MIN." <= value <=".AM_VAL_BASS_MAX.")"; + break; + default: + $errorMsg = "Unknonw function '$function' for Command '$command'"; + } + break; + default: + $errorMsg = "Unknonw Command '$command'"; + } + if (!$result) { + $this->LogErr($errorMsg); + } + return $result; + } + + + /** + * @private + * + * Senden von Befehlen zum AudioMax Server per COM Port + * + * @param string $type Kommando Type + * @param string $command Kommando + * @param integer $roomId Raum (0-15) + * @param string $function Funktion + * @param string $value Wert + * @return boolean TRUE für OK, FALSE bei Fehler + */ + private function SendDataComPort($type, $command, $roomId, $function, $value) { + $result = false; + + if (GetValue(IPS_GetObjectIDByIdent(AM_VAR_CONNECTION, $this->instanceId))) { + $this->LogCom('Snd Message: '.$this->BuildMsg($type, $command, $roomId, $function, $value, false)); + $comPortId = GetValue(IPS_GetObjectIDByIdent('PORT_ID', $this->instanceId)); + $msg = $this->BuildMsg($type, $command, $roomId, $function, $value); + $result = @COMPort_SendText($comPortId, $msg); + if ($result===false) { + $this->LogDbg('Write to ComPort failed --> Try Reconnect'); + COMPort_SetOpen($comPortId,false); + COMPort_SetOpen($comPortId,true); + IPS_ApplyChanges($comPortId); + $result = COMPort_SendText($comPortId, $msg); + } + } else { + $this->LogCom('Snd Message: '.$this->BuildMsg($type, $command, $roomId, $function, $value, false).' (Connection Inactive - Msg will be ignored)!'); + $result = true; + } + + return $result; + } + + /** + * @private + * + * Warten auf die Anwort vom Server + * + * @param string $type Kommando Type + * @param string $command Kommando + * @param integer $roomId Raum (0-15) + * @param string $function Funktion + * @param string $value Wert + * @return boolean TRUE für OK, FALSE bei Fehler + */ + private function WaitForServerResponse($type, $command, $roomId, $function, $value) { + $result = false; + $error = ''; + + $inputBufferId = IPS_GetObjectIDByIdent(AM_VAR_INPUTBUFFER, $this->instanceId); + $waited = 0; + while ($waited < AM_COM_MAXWAIT) { + IPS_Sleep(AM_COM_WAIT); + $waited = $waited + AM_COM_WAIT; + $message = GetValue($inputBufferId); + if ($message<>'') { + $waited = AM_COM_MAXWAIT; + $params = explode(AM_COM_SEPARATOR, $message); + if ($message==AM_VAL_ACKNOWLEDGE) { + if (GetValue(IPS_GetObjectIDByIdent(AM_VAR_MODEACKNOWLEDGE, $this->instanceId))==1) { + $result = true; + } else { + $result = false; + $error = 'Ack Mode NOT Active'; + } + } elseif ($message==AM_ERR_UNKNOWNCMD1) { + $result = false; + $error = 'Unknown Command Part 1'; + } elseif ($message==AM_ERR_UNKNOWNCMD2) { + $result = false; + $error = 'Unknown Command Part 2'; + } elseif ($message==AM_ERR_UNKNOWNCMD3) { + $result = false; + $error = 'Unknown Command Part 3'; + } elseif ($message==AM_ERR_UNKNOWNCMD4) { + $result = false; + $error = 'Out of Range Part 4'; + } elseif ($message==AM_ERR_UNKNOWNCMD5) { + $result = false; + $error = 'Out of Range Part 5'; + } elseif ($params[2] == AM_CMD_POWER) { + $result = $value==$params[3]; + } elseif ($params[2] == AM_CMD_KEEPALIVE) { + $result = $value==$params[3]; + } elseif ($params[2] == AM_CMD_ROOM) { + $result = $roomId==$params[3] and $value==$params[4]; + } elseif ($params[2] == AM_CMD_AUDIO) { + $result = $roomId==$params[3] and $function==$params[4] and $value==$params[5]; + } elseif ($params[2] == AM_CMD_MODE) { + $result = $function==$params[3] and $value==$params[4]; + } else { + $result = false; + } + } else { + $error = 'Timeout'; + } + } + if (!$result) { + if ($error<>'') { + $error = ' ('.$error.')'; + } + if ($this->retryCount==AM_COM_MAXRETRIES) { + $this->LogErr('Received invalid Acknowledge from Server: '.$message.$error); + } else { + $this->LogTrc('Received invalid Acknowledge from Server: '.$message.$error); + } + } + return $result; + } + + /** + * @public + * + * Senden von Befehlen zum AudioMax Server + * + * @param string $type Kommando Type + * @param string $command Kommando + * @param integer $roomId Raum (0-15) + * @param string $function Funktion + * @param string $value Wert + * @return boolean TRUE für OK, FALSE bei Fehler + */ + public function SendData($type, $command, $roomId, $function, $value) { + $result = false; + + if ($type==AM_TYP_GET and $this->GetAudioMaxRoomVariablesEnabled()) { + if ($this->ValidateData($type, $command, $roomId, $function, $value)) { + $result = $this->GetValue($type, $command, $roomId, $function); + } + return $result; + } + + if ($this->SetBusy()) { + $this->LogTrc("Process Type='$type', Command='$command', Function='$function' and Value='$value' for Room $roomId"); + if ($this->ValidateData($type, $command, $roomId, $function, $value)) { + SetValue(IPS_GetObjectIDByIdent(AM_VAR_INPUTBUFFER, $this->instanceId), ''); + + $result = $this->SendDataComPort($type, $command, $roomId, $function, $value); + if ($result) { + if (GetValue(IPS_GetObjectIDByIdent(AM_VAR_MODEEMULATESTATE, $this->instanceId))) { + $this->SetValue($type, $command, $roomId, $function, $value); + IPS_Sleep(AM_COM_WAIT); + } elseif (!GetValue(IPS_GetObjectIDByIdent(AM_VAR_CONNECTION, $this->instanceId))) { + $this->SetValue($type, $command, $roomId, $function, $value); + } else { + $this->retryCount = 1; + while ($this->retryCount<=AM_COM_MAXRETRIES) { + if ($this->WaitForServerResponse($type, $command, $roomId, $function, $value)) { + $this->SetValue($type, $command, $roomId, $function, $value); + $this->retryCount = AM_COM_MAXRETRIES; + } else { + $this->LogTrc('Timeout or invalid Response while waiting for Server Response (Retry='.$this->retryCount.') --> Resend Message '. + $this->BuildMsg($type, $command, $roomId, $function, $value, false)); + SetValue(IPS_GetObjectIDByIdent(AM_VAR_INPUTBUFFER, $this->instanceId), ''); + $result = $this->SendDataComPort($type, $command, $roomId, $function, $value); + } + $this->retryCount++; + } + } + } + } + $this->ResetBusy(); + } else { + $this->LogErr("AudioMax is already BUSY, ignore Message".$this->BuildMsg($type, $command, $roomId, $function, $value, false)); + } + return $result; + } + + /** + * @public + * + * Empfangen von Befehlen vom AudioMax Server + * + * @param string $message Message vom AudioMax Server + */ + public function ReceiveData($message) { + $message = str_replace(chr(13), '', $message); + $message = str_replace(chr(10), '', $message); + $params = explode(AM_COM_SEPARATOR, $message); + + if ($message=='') return; + + $this->LogCom('Rcv Message: '.$message); + switch ($params[0]) { + case AM_TYP_EVT: + if ($params[2] == AM_CMD_POWER) { + $this->ValidateAndSetValue(AM_TYP_SET, AM_CMD_POWER, null, null, $params[3]); + } elseif ($params[2] == AM_CMD_MODE) { + $this->ValidateAndSetValue(AM_TYP_SET, AM_CMD_MODE, null, $params[3], $params[4]); + } elseif ($params[2] == AM_CMD_KEEPALIVE) { + SetValue(IPS_GetObjectIDByIdent(AM_VAR_KEEPALIVECOUNT, $this->instanceId), 0); + } elseif ($params[2] == AM_CMD_ROOM) { + $this->ValidateAndSetValue(AM_TYP_SET, AM_CMD_ROOM, $params[3], null, $params[4]); + } elseif ($params[2] == AM_CMD_AUDIO) { + $this->ValidateAndSetValue(AM_TYP_SET, AM_CMD_AUDIO, $params[3], $params[4], $params[5]); + } else { + //$this->LogErr("Received invalid Message".$message); + } + break; + case AM_TYP_GET: + case AM_TYP_SET: + SetValue(IPS_GetObjectIDByIdent(AM_VAR_INPUTBUFFER, $this->instanceId), $message); + break; + case AM_TYP_DBG: + break; + case AM_ERR_UNKNOWNCMD1: + case AM_ERR_UNKNOWNCMD2: + case AM_ERR_UNKNOWNCMD3: + case AM_ERR_UNKNOWNCMD4: + case AM_ERR_UNKNOWNCMD5: + break; + default: + $this->LogInf("Received unknown Message=".$message.', Type='.$params[0]); + break; + } + } + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/hardware/IPSEDIP/IPSEDIP.class.php b/IPSLibrary/app/hardware/IPSEDIP/IPSEDIP.class.php index 22f5f91..e7f5252 100644 --- a/IPSLibrary/app/hardware/IPSEDIP/IPSEDIP.class.php +++ b/IPSLibrary/app/hardware/IPSEDIP/IPSEDIP.class.php @@ -32,7 +32,6 @@ /** @}*/ /**@defgroup ipsedip IPSEDIP - * @ingroup hardware * @{ * * Es handelt sich bei IPSEDIP um Scripts, mit denen es möglich ist IPS Strukturen auf einem EDIP43 Display @@ -54,6 +53,8 @@ IPSUtils_Include ("IPSLogger.inc.php", "IPSLibrary::app::core::IPSLogger"); IPSUtils_Include ("IPSEDIP_Configuration.inc.php", "IPSLibrary::config::hardware::IPSEDIP"); + $_IPS['ABORT_ON_ERROR'] = true; + /** * @class IPSEDIP * @@ -70,6 +71,7 @@ abstract class IPSEDIP{ protected $rootId=0; protected $currentId=0; private $registerId=0; + private $errorcounter=0; protected $objectIdsId=0; protected $objectValuesId=0; @@ -368,15 +370,15 @@ private function AddObjects() { switch($object['ObjectType']) { case 0: // Category case 1: // Instance - echo 'Found Category '.$name."\n"; + //echo 'Found Category '.$name."\n"; $this->AddObjectCategory($linkId, $childrenId, $name, $position); break; case 2: // Variable - echo 'Found Variable '.$name."\n"; + //echo 'Found Variable '.$name."\n"; $this->AddObjectVariable($linkId, $childrenId, $name, $position); break; case 3: // Script - echo 'Found Script '.$name."\n"; + //echo 'Found Script '.$name."\n"; $this->AddObjectScript($linkId, $childrenId, $name, $position); break; default: @@ -585,7 +587,17 @@ public function SendText($string){ $string .= chr($checkSum % 256); //IPSLogger_Com(__file__,'Send Msg to EDIP: '.$string); - RegVar_SendText($this->registerId, $string); + $result = @RegVar_SendText($this->registerId, $string); + if ($result===false) { + $instanceId = IPS_GetInstance($this->registerId)['ConnectionID']; + IPS_SetProperty($instanceId, 'Open', false); + IPS_SetProperty($instanceId, 'Open', true); + IPS_ApplyChanges($instanceId); + $this->errorCounter++; + if ($this->errorCounter==2) { + IPSLogger_Wrn(__file__, 'Error sending EDIP Message to "'.IPS_GetName($this->instanceId).'"'); + } + } ips_sleep($this->sendDelay); } } diff --git a/IPSLibrary/app/hardware/IPSEDIP/IPSEDIP_Constants.inc.php b/IPSLibrary/app/hardware/IPSEDIP/IPSEDIP_Constants.inc.php index 6e27393..a575304 100644 --- a/IPSLibrary/app/hardware/IPSEDIP/IPSEDIP_Constants.inc.php +++ b/IPSLibrary/app/hardware/IPSEDIP/IPSEDIP_Constants.inc.php @@ -31,6 +31,7 @@ define ('EDIP_CONFIG_NAME', 'Name'); define ('EDIP_CONFIG_REGISTER', 'RegisterVariableId'); + define ('EDIP_CONFIG_IOINSTANCE', 'IO_InstanceId'); define ('EDIP_CONFIG_COMPORT', 'ComPort'); define ('EDIP_CONFIG_ROOT', 'RootId'); define ('EDIP_CONFIG_REFRESHMETHOD', 'RefreshMethod'); diff --git a/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic.inc.php b/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic.inc.php new file mode 100644 index 0000000..f52e22d --- /dev/null +++ b/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic.inc.php @@ -0,0 +1,38 @@ + + * + */ + + IPSUtils_Include ('IPSLogger.inc.php', 'IPSLibrary::app::core::IPSLogger'); + IPSUtils_Include ('IPSHomematic_Constants.inc.php', 'IPSLibrary::app::hardware::IPSHomematic'); + IPSUtils_Include ('IPSHomematic_Configuration.inc.php', 'IPSLibrary::config::hardware::IPSHomematic'); + IPSUtils_Include ('IPSHomematic_Custom.inc.php', 'IPSLibrary::config::hardware::IPSHomematic'); + IPSUtils_Include ('IPSHomematic_Utils.inc.php', 'IPSLibrary::app::hardware::IPSHomematic'); + IPSUtils_Include ('IPSHomematic_Manager.class.php', 'IPSLibrary::app::hardware::IPSHomematic'); + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic_ChangeSettings.ips.php b/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic_ChangeSettings.ips.php new file mode 100644 index 0000000..6693423 --- /dev/null +++ b/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic_ChangeSettings.ips.php @@ -0,0 +1,35 @@ + + * + */ + + $variableId = $_IPS['VARIABLE']; + $variableValue = $_IPS['VALUE']; + + SetValue($variableId, $variableValue); + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic_Constants.inc.php b/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic_Constants.inc.php new file mode 100644 index 0000000..f84a9d5 --- /dev/null +++ b/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic_Constants.inc.php @@ -0,0 +1,53 @@ + + * + */ + + define ('HM_PROPERTY_SERIAL', 0); + define ('HM_PROPERTY_CHANNEL', 1); + define ('HM_PROPERTY_PROTOCOL', 2); + define ('HM_PROPERTY_TYPE', 3); + + define ('HM_PROTOCOL_BIDCOSRF', 'BidCos-RF'); + define ('HM_PROTOCOL_BIDCOSWI', 'BidCos-WI'); + + define ('HM_TYPE_LIGHT', 'Light'); + define ('HM_TYPE_SHUTTER', 'Shutter'); + define ('HM_TYPE_DIMMER', 'Dimmer'); + define ('HM_TYPE_BUTTON', 'Button'); + define ('HM_TYPE_SMOKEDETECTOR', 'SmokeDetector'); + define ('HM_TYPE_SWITCH', 'Switch'); + + define ('HM_CONTROL_RSSI', 'RSSI'); + define ('HM_CONTROL_RSSIDEVICE', 'RSSIDevice'); + define ('HM_CONTROL_RSSIPEER', 'RSSIPeer'); + define ('HM_CONTROL_MESSAGES', 'Messages'); + define ('HM_CONTROL_PRIORITY', 'Priority'); + + define ('HM_TIMEOUT_REFRESH', 10); + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic_Manager.class.php b/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic_Manager.class.php new file mode 100644 index 0000000..94bef0a --- /dev/null +++ b/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic_Manager.class.php @@ -0,0 +1,298 @@ + + * + */ + + /** + * @class IPSHomematic_Manager + * + * Definiert ein IPSHomematic_Manager Objekt + * + * @author Andreas Brauneis + * @version + * Version 2.50.1, 15.07.2012
+ */ + class IPSHomematic_Manager { + + /** + * @public + * + * Initializes the IPSHomematic_Manager + */ + public function __construct() { + } + + /** + * @public + * + * Refreshed alle RSSI Variablen von der CCU + */ + public function RefreshRSSIValues() { + $instanceIdList = $this->GetMaintainanceInstanceList(); + foreach ($instanceIdList as $instanceId) { + $variableId = @IPS_GetVariableIDByName('RSSI_DEVICE', $instanceId); + if ($variableId!==false) { + usleep(100000); + set_time_limit(HM_TIMEOUT_REFRESH); + HM_RequestStatus($instanceId, 'RSSI_DEVICE'); + } + $variableId = @IPS_GetVariableIDByName('RSSI_PEER', $instanceId); + if ($variableId!==false) { + usleep(100000); + set_time_limit(HM_TIMEOUT_REFRESH); + HM_RequestStatus($instanceId, 'RSSI_PEER'); + } + } + } + + /** + * @public + * + * Refreshed alle RSSI HTML Listen + */ + public function RefreshRSSIHtml() { + $instanceIdList = $this->GetMaintainanceInstanceList(); + $rssiDeviceList = array(); + $rssiPeerList = array(); + foreach ($instanceIdList as $instanceId) { + $variableId = @IPS_GetVariableIDByName('RSSI_DEVICE', $instanceId); + if ($variableId!==false) { + $rssiValue = GetValue($variableId); + if ($rssiValue<>-65535) { + $rssiDeviceList[$instanceId] = $rssiValue; + } + } + } + arsort($rssiDeviceList, SORT_NATURAL); + + foreach ($instanceIdList as $instanceId) { + $variableId = @IPS_GetVariableIDByName('RSSI_PEER', $instanceId); + if ($variableId!==false) { + $rssiValue = GetValue($variableId); + if ($rssiValue<>-65535) { + $rssiPeerList[$instanceId] = $rssiValue; + } + } + } + arsort($rssiPeerList, SORT_NATURAL); + + $categoryIdHtml = IPSUtil_ObjectIDByPath('Program.IPSLibrary.data.hardware.IPSHomematic.StatusMessages'); + $categoryIdSettings = IPSUtil_ObjectIDByPath('Program.IPSLibrary.data.hardware.IPSHomematic.Settings'); + + $variableIdRssi = IPS_GetObjectIDByIdent(HM_CONTROL_RSSI, $categoryIdHtml); + $variableIdRssiDevice = IPS_GetObjectIDByIdent(HM_CONTROL_RSSIDEVICE, $categoryIdHtml); + $variableIdRssiPeer = IPS_GetObjectIDByIdent(HM_CONTROL_RSSIPEER, $categoryIdHtml); + + $str = ""; + $str .= ""; + foreach($rssiDeviceList as $instanceId=>$value) { + $str .= ""; + } + $str .= "
GerätnameGeräteIDEmpfangsstärke
".IPS_GetName($instanceId)."".HM_GetAddress($instanceId)."".$value."
"; + SetValue($variableIdRssiDevice, $str); + + $str = ""; + $str .= ""; + foreach($rssiPeerList as $instanceId=>$value) { + $str .= ""; + } + $str .= "
GerätnameGeräteIDEmpfangsstärke
".IPS_GetName($instanceId)."".HM_GetAddress($instanceId)."".$value."
"; + SetValue($variableIdRssiPeer, $str); + + $str = ""; + $str .= ""; + $idx = 0; + foreach($rssiDeviceList as $instanceId=>$value) { + $idx++; + if ($idx<=10) { + $str .= ""; + } + } + $str .= "
GerätnameGeräteIDEmpfangsstärke
".IPS_GetName($instanceId)."".HM_GetAddress($instanceId)."".$value."
"; + SetValue($variableIdRssi, $str); + } + + /** + * @public + * + * Refresh Variablen und HTML der Empfangsstärken + */ + public function RefreshRSSI() { + $this->RefreshRSSIValues(); + $this->RefreshRSSIHtml(); + } + + /** + * @public + * + * Refresh aller Homematic Status Variablen (STATE und LEVEL) + */ + public function RefreshStatusVariables() { + $instanceIdList = IPS_GetInstanceListByModuleID("{EE4A81C6-5C90-4DB7-AD2F-F6BBD521412E}"); + foreach ($instanceIdList as $instanceId) { + $variableId = @IPS_GetVariableIDByName('STATE', $instanceId); + if ($variableId!==false) { + set_time_limit(HM_TIMEOUT_REFRESH); + HM_RequestStatus($instanceId, 'STATE'); + } + //$variableId = @IPS_GetVariableIDByName('LEVEL', $instanceId); + //if ($variableId!==false) { + // HM_RequestStatus($instanceId, 'LEVEL'); + //} + } + } + + /** + * @public + * + * Refresh der Homematic Service Messages + */ + public function RefreshServiceMessages() { + $texte = Array("CONFIG_PENDING" =>"Konfigurationsdaten stehen zur Übertragung an", + "LOWBAT" =>"Batterieladezustand gering", + "STICKY_UNREACH" =>"Gerätekommunikation war gestört", + "UNREACH" =>"Gerätekommunikation aktuell gestört"); + + $str = ""; // Farbe anpassen oder style entfernen + $str .= ""; + $str_log = ""; + $ids = IPS_GetInstanceListByModuleID("{A151ECE9-D733-4FB9-AA15-7F7DD10C58AF}"); + if(sizeof($ids) == 0) die("Keine HomeMatic Socket Instanz gefunden!"); + + $msgs = HM_ReadServiceMessages($ids[0]); + if($msgs === false) die("Verbindung zur CCU fehlgeschlagen"); + + if(sizeof($msgs) == 0) { + $str .= ""; + $str_log .= "Keine Servicemeldungen!"; + } + foreach($msgs as $msg) { + if(array_key_exists($msg['Message'], $texte)) { + $text = $texte[$msg['Message']]; + } else { + $text = $msg['Message']; + } + $id = HM_GetInstanceIDFromHMAddress($msg['Address']); + if(IPS_InstanceExists($id)) { + $name = IPS_GetLocation($id); + } else { + $name = "Gerät nicht in IP-Symcon eingerichtet"; + } + + $str .= ""; + $str_log .= $name." - ".$msg['Address']." - ".$text."\n"; + } + $str .= "
GerätnameGeräteIDMeldung

Keine Servicemeldungen!
".$name."".$msg['Address']."".$text."
"; + + $categoryIdHtml = IPSUtil_ObjectIDByPath('Program.IPSLibrary.data.hardware.IPSHomematic.StatusMessages'); + $categoryIdSettings = IPSUtil_ObjectIDByPath('Program.IPSLibrary.data.hardware.IPSHomematic.Settings'); + $variableIdMessages = IPS_GetObjectIDByIdent(HM_CONTROL_MESSAGES, $categoryIdHtml); + $variableIdPriority = IPS_GetObjectIDByIdent(HM_CONTROL_PRIORITY, $categoryIdSettings); + if (GetValue($variableIdMessages) <> $str) { + SetValue($variableIdMessages, $str); + IPSLogger_Not(__file__, 'New Homematic Service Messages:'.PHP_EOL.$str_log, GetValue($variableIdPriority)); + } + } + + /** + * @public + * + * Reset der Homematic Service Messages + */ + public function ResetServiceMessages() { + $homematicIntanceIdList = IPS_GetInstanceListByModuleID("{A151ECE9-D733-4FB9-AA15-7F7DD10C58AF}"); + if(sizeof($homematicIntanceIdList) == 0) die("Keine HomeMatic Socket Instanz gefunden!"); + + $CCUIPAddress = HM_GetHost($homematicIntanceIdList[0]); + + $HM_Script = " + string itemID; + string address; + object aldp_obj; + + foreach(itemID, dom.GetObject(ID_DEVICES).EnumUsedIDs()) + { + address = dom.GetObject(itemID).Address(); + aldp_obj = dom.GetObject('AL-' # address # ':0.STICKY_UNREACH'); + if (aldp_obj) + { + if (aldp_obj.Value()) + { + aldp_obj.AlReceipt(); + ! dom.GetObject('Kommunikationsstörung').State(dom.GetObject(itemID).Name()); + } + } + }"; + + // Initialisieren der Socket-Verbindung + $fp = fsockopen ($CCUIPAddress, 8181, $errno, $errstr, 2); + $res = ""; + + if (!$fp) { + $res = "$errstr ($errno)
\n"; + } else { + // Zusammenstellen des Header für HTTP-Post + fputs($fp, "POST /Test.exe HTTP/1.1\r\n"); + fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n"); + fputs($fp, "Content-length: ". strlen($HM_Script) ."\r\n"); + fputs($fp, "Connection: close\r\n\r\n"); + fputs($fp, $HM_Script); + while(!feof($fp)) { + $res .= fgets($fp, 500); + } + fclose($fp); + } + return $res; + } + + /** + * @public + * + * Liefert alle Homematic Maintainmance Instance IDs, die in der Konfiguration eingetragen sind + * + * @return array[int] Homematic Instance IDs + */ + public function GetMaintainanceInstanceList() { + $homematicInstanceList = IPS_GetInstanceListByModuleID("{EE4A81C6-5C90-4DB7-AD2F-F6BBD521412E}"); + $homematicAddressList = array(); + $homematicMaintainanceList = array(); + + foreach ($homematicInstanceList as $homematicInstanceId ) { + $homematicAddress = HM_GetAddress($homematicInstanceId); + $homematicAddressList[$homematicAddress] = $homematicInstanceId; + + $pos = strpos($homematicAddress, ':0'); + if ($pos !== false) { + $homematicMaintainanceList[$homematicInstanceId] = $homematicInstanceId; + } + } + + return $homematicMaintainanceList; + } + } + + /** @}*/ +?> diff --git a/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic_RefreshRSSI.ips.php b/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic_RefreshRSSI.ips.php new file mode 100644 index 0000000..ea1a490 --- /dev/null +++ b/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic_RefreshRSSI.ips.php @@ -0,0 +1,35 @@ + + * + */ + + IPSUtils_Include ('IPSHomematic.inc.php', 'IPSLibrary::app::hardware::IPSHomematic'); + + $homematicManager = new IPSHomematic_Manager(); + $homematicManager->RefreshRSSI(); + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic_RefreshServiceMessages.ips.php b/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic_RefreshServiceMessages.ips.php new file mode 100644 index 0000000..942c7d6 --- /dev/null +++ b/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic_RefreshServiceMessages.ips.php @@ -0,0 +1,36 @@ + + * + */ + + + IPSUtils_Include ('IPSHomematic.inc.php', 'IPSLibrary::app::hardware::IPSHomematic'); + + $homematicManager = new IPSHomematic_Manager(); + $homematicManager->RefreshServiceMessages(); + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic_RefreshStatusVariables.ips.php b/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic_RefreshStatusVariables.ips.php new file mode 100644 index 0000000..a397ac4 --- /dev/null +++ b/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic_RefreshStatusVariables.ips.php @@ -0,0 +1,35 @@ + + * + */ + + IPSUtils_Include ('IPSHomematic.inc.php', 'IPSLibrary::app::hardware::IPSHomematic'); + + $homematicManager = new IPSHomematic_Manager(); + $homematicManager->RefreshStatusVariables(); + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic_ResetServiceMessages.ips.php b/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic_ResetServiceMessages.ips.php new file mode 100644 index 0000000..63d03a3 --- /dev/null +++ b/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic_ResetServiceMessages.ips.php @@ -0,0 +1,36 @@ + + * + */ + + IPSUtils_Include ('IPSHomematic.inc.php', 'IPSLibrary::app::hardware::IPSHomematic'); + + $homematicManager = new IPSHomematic_Manager(); + $homematicManager->ResetServiceMessages(); + $homematicManager->RefreshServiceMessages(); + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic_SmokeDetector.ips.php b/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic_SmokeDetector.ips.php new file mode 100644 index 0000000..d733074 --- /dev/null +++ b/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic_SmokeDetector.ips.php @@ -0,0 +1,39 @@ + + * + */ + + IPSUtils_Include ('IPSHomematic.inc.php', 'IPSLibrary::app::hardware::IPSHomematic'); + + $sender = $_IPS['SENDER']; + $variableId = $_IPS['VARIABLE']; + $value = $_IPS['VALUE']; + if ($value) { + IPSHomematic_OnActivateSmokeDetector($variableId); + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic_TimerRefreshRSSI.ips.php b/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic_TimerRefreshRSSI.ips.php new file mode 100644 index 0000000..ea1a490 --- /dev/null +++ b/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic_TimerRefreshRSSI.ips.php @@ -0,0 +1,35 @@ + + * + */ + + IPSUtils_Include ('IPSHomematic.inc.php', 'IPSLibrary::app::hardware::IPSHomematic'); + + $homematicManager = new IPSHomematic_Manager(); + $homematicManager->RefreshRSSI(); + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic_TimerRefreshServiceMessages.ips.php b/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic_TimerRefreshServiceMessages.ips.php new file mode 100644 index 0000000..79f9ae5 --- /dev/null +++ b/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic_TimerRefreshServiceMessages.ips.php @@ -0,0 +1,35 @@ + + * + */ + + IPSUtils_Include ('IPSHomematic.inc.php', 'IPSLibrary::app::hardware::IPSHomematic'); + + $homematicManager = new IPSHomematic_Manager(); + $homematicManager->RefreshServiceMessages(); + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic_Utils.inc.php b/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic_Utils.inc.php new file mode 100644 index 0000000..4f04000 --- /dev/null +++ b/IPSLibrary/app/hardware/IPSHomematic/IPSHomematic_Utils.inc.php @@ -0,0 +1,51 @@ + + * + */ + + // ==================================================================================================== + /** + * @public + * + * Liefert die Instance ID zu einer Homematic Adresse + * + * @param string $sid Homematic Adresse + * @return int ID der Homematic Instance + */ + function HM_GetInstanceIDFromHMAddress($sid) { + $ids = IPS_GetInstanceListByModuleID("{EE4A81C6-5C90-4DB7-AD2F-F6BBD521412E}"); + foreach($ids as $id) { + $a = explode(":", HM_GetAddress($id)); + $b = explode(":", $sid); + if($a[0] == $b[0]) { + return $id; + } + } + return 0; + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/modules/Charts/IPSHighcharts/IPSHighcharts.inc.php b/IPSLibrary/app/modules/Charts/IPSHighcharts/IPSHighcharts.inc.php new file mode 100644 index 0000000..6a31705 --- /dev/null +++ b/IPSLibrary/app/modules/Charts/IPSHighcharts/IPSHighcharts.inc.php @@ -0,0 +1,1792 @@ + + * Version 2.50.1, 05.10.2012 ab: Integration IPSLibrary
+ * + * IPSHighcharts, ermöglich Darstellung von Charts im Webfront mit Hilfe von "Highcharts" (www.highcharts.com) + * + */ + + $version = "2.03"; $versionDate = "05.10.2012"; + + //ToDo: + // FEATURE: Plotbands. Timestamp in From und To + // Fehlerquelle: AggType ist "Größer" als der angezeigte Zeitraum + // vielleicht alles als cfg direkt json_encoden und nicht jedes Teil einzeln + //-------------------------------------------------------------------------------------------------------------------------------- + // Für die Darstellung der Graphen wird das HTML5/JS Framework "Highcharts" der Fa. Highslide Software verwendet (www.highcharts.com) + // Alle Rechte dieses Frameworks liegen bei Highslide Software. + // 'Highcharts' kann unter folgenden Bedinungen kostenlos eingesetzt werden: + // * Namensnennung — Sie müssen den Namen des Autors/Rechteinhabers in der von ihm festgelegten Weise nennen. + // * Keine kommerzielle Nutzung — Dieses Werk bzw. dieser Inhalt darf nicht für kommerzielle Zwecke verwendet werden. + // Download: wwww.highcharts.com/download/ ... und die Dateien einfach in das Webfront (Es sollte ein V 2.2 oder höher verwendet werden. + // Demos: http://www.highcharts.com/demo/ + // API: http://www.highcharts.com/ref/ + //-------------------------------------------------------------------------------------------------------------------------------- + // Changelog: + // --- V2.00 --------------------------------------------------------------------------------------------------------------------- + // 10/2012 AB NEU Integration IPSLibrary + // 04/2012 KHC REFACT Umfangreiches Überarbeiten der Highchart-Script Funktionen. + // bis Integration der meisten Original-Highcharts-Options als PHP-Array (siehe http://www.highcharts.com/ref) + // 05/2012 Highcharts-Options "lang" aus IPS_Template.php in Highcharts-Script verschoben + // --- V2.01 --------------------------------------------------------------------------------------------------------------------- + // 07.05.2012 KHC NEU Test mit Integration Highstock. Neuer Parameter ['Ips']['ChartType'] = 'Highcharts' oder 'Highstock' + // 07.05.2012 KHC NEU IPS_Template.php auf jquery 1.7.2 geändert + // 07.05.2012 KHC FIX krsort durch array_reverse getauscht, da krsort Probleme beim json_encode macht + // 08.05.2012 KHC REFACT intern noch mehr auf Arrays umgestellt und etwas umstrukturiert + // 09.05.2012 KHC NEU über 'CreateConfigFileByPathAndFilename($stringForCfgFile, $path, $filename)' kann eine Tmp_datei mit bel. Namen geschrieben werden + // 10.05.2012 KHC FIX Fehler beim Auswerten der AggregatedValues behoben (ReadDataFromDBAndCreateDataArray) + // 12.05.2012 KHC FIX Tooltip für "ReplaceValues" korrigiert + // 12.05.2012 KHC CHANGE Start- und Endzeitpunkt der X-Achse wurde automatisch um 5 Minuten korrigiert -> dies wurde entfernt + // 12.05.2012 KHC NEU mit ['xAxis']['min']=false und ['xAxis']['min']=false kann festeglegt werden dass Min oder Max nicht autom. festgelegt werden + // --- V2.02 --------------------------------------------------------------------------------------------------------------------- + // 13.05.2012 KHC FIX RunType=file: Wenn Highstock vorgewählt wurde wurde das tmp File nicht in die Highstock-Verzeichnis geschrieben + // 16.05.2012 KHC NEU Integration Highstock: ['Navigator'], ['rangeSelector'] und ['scrollbar'] + // 18.05.2012 KHC FIX Integration Highstock: Zusätzliche series.type 'candlestick' und 'ohlc' erlauben + // 19.05.2012 KHC NEU Neue Parameter ['Ips']['Dashboard'] für die Darstellung im Dashboard + + //-------------------------------------------------------------------------------------------------------------------------------- + + // ------------------------------------------------------------------------ + // WriteContentWithFilename + // Mit dieser Funktion wird der Content-String geschrieben. + // IN: $cfg = .. + // IN: $tmpFilename = Der Dateiname welche die Config Daten enthält + // ------------------------------------------------------------------------ + function WriteContentWithFilename($cfg, $tmpFilename) + { + DebugModuleName($cfg,"WriteContentWithFilename"); + + if ($tmpFilename != "") + { + SetValue($cfg['ContentVarableId'], + GetContentVariableString ($cfg, "CfgFile", $tmpFilename)); + } + else + SetValue($cfg['ContentVarableId'], 'Falsche Parameter beim Funktionsaufruf "WriteContentTextbox"'); + } + + // ------------------------------------------------------------------------ + // WriteContentWithScriptId + // Mit dieser Funktion wird der Content-String geschrieben. + // IN: $cfg = .. + // IN: $scriptId = Die Script Id welche den ConfigString enthält. + // ------------------------------------------------------------------------ + function WriteContentWithScriptId($cfg, $scriptId) + { + DebugModuleName($cfg,"WriteContentWithScriptId"); + + if ($cfg['RunMode'] == "popup") + { + WFC_SendPopup($cfg['WebFrontConfigId'], + $cfg['WFCPopupTitle'] , + GetContentVariableString ($cfg, "ScriptId", $scriptId)); + } + else + { + SetValue($cfg['ContentVarableId'], + GetContentVariableString ($cfg, "ScriptId", $scriptId)); + } + } + + // ------------------------------------------------------------------------ + // 05.10.2012 ab: Adapted Path to Templates + function GetContentVariableString($cfg, $callBy, $callIdent) + { + $chartType = $cfg['Ips']['ChartType']; + $height = $cfg['HighChart']['Height'] + 16; + + if (isset($cfg['Ips']['Dashboard']['Ip']) && isset($cfg['Ips']['Dashboard']['Port'])) + { + $s = "http://" . $cfg['Ips']['Dashboard']['Ip'] . ":" . $cfg['Ips']['Dashboard']['Port'] . + "/User/IPSHighcharts/IPSTemplates/$chartType.php?$callBy=" . $callIdent . " " . + "width='100%' height='". $height ."' frameborder='1' scrolling='no'"; + } + else + { + $s = ""; + } + return $s; + } + + // ------------------------------------------------------------------------ + // CreateConfigFile + // Erzeugt das tmp-Highcharts Config-File mit der $id als Dateinamen + // IN: $stringForCfgFile = String welcher in das File geschrieben wird + // ------------------------------------------------------------------------ + function CreateConfigFile($stringForCfgFile, $id, $charttype = 'Highcharts') + { + $path = "webfront\user\IPSHighcharts\\" . $charttype; + $filename = $charttype . "Cfg$id.tmp"; + + return CreateConfigFileByPathAndFilename($stringForCfgFile, $path, $filename); + } + + // ------------------------------------------------------------------------ + // CreateConfigFileByPathAndFilename + // Erzeugt das tmp-Highcharts Config-File + // IN: $stringForCfgFile = String welcher in das File geschrieben wird + // $path, $filename = Pfad un Name des Tmp-Files welches erzeugt werden soll + // ------------------------------------------------------------------------ + function CreateConfigFileByPathAndFilename($stringForCfgFile, $path, $filename) + { + // Standard-Dateiname ..... + $tmpFilename = IPS_GetKernelDir() . $path . "\\" . $filename; + + // schreiben der Config Daten + $handle = fopen($tmpFilename,"w"); + fwrite($handle, $stringForCfgFile); + fclose($handle); + + return $tmpFilename; + } + + // ------------------------------------------------------------------------ + // CheckCfgDaten + // Aufruf bei jedem Cfg-Start + // IN: $cfg = .. + // OUT: korrigierte cfg + // ------------------------------------------------------------------------ + function CheckCfgDaten($cfg) + { + DebugModuleName($cfg,"CheckCfgDaten"); + + global $_IPS; + + // Debugging + IfNotIssetSetValue($cfg['Ips']['Debug']['Modules'], false); + IfNotIssetSetValue($cfg['Ips']['Debug']['ShowJSON'], false); + IfNotIssetSetValue($cfg['Ips']['Debug']['ShowJSON_Data'], false); + IfNotIssetSetValue($cfg['Ips']['Debug']['ShowCfg'], false); + + // ChartType + IfNotIssetSetValue($cfg['Ips']['ChartType'], 'Highcharts'); + + if ($cfg['Ips']['ChartType'] != 'Highcharts' && $cfg['Ips']['ChartType'] != 'Highstock') + die ("Abbruch! Es sind nur 'Highcharts' oder 'Highstock' als ChartType zulässig"); + + // über WebInterface kommt der Aufruf wenn die Content-Variable aktualisiert wird + if ($_IPS['SENDER'] != "WebInterface" && $cfg['RunMode'] != "popup") + $cfg = Check_ContentVariable($cfg, $_IPS['SELF']); + + return $cfg; + } + + // ------------------------------------------------------------------------ + // CreateConfigString + // Erzeugt den für Higcharts benötigten Config String und gibt diesen als String zurück + // IN: $cfg = .. + // OUT: der erzeugte Config String + // ------------------------------------------------------------------------ + function CreateConfigString($cfg) + { + DebugModuleName($cfg,"CreateConfigString"); + + $cfg = CompatibilityCheck($cfg); + $cfg = CheckCfg($cfg); + + $cfgString = GetHighChartsCfgFile($cfg); + + // Zusätzliche Config in Highchart Config hinzufügen + $cfgString = ReadAdditionalConfigData($cfg) . "\n|||\n" . $cfgString; + + // Language Options aus IPS_Template.php hierher verschoben + $cfgString .= "\n|||\n". GetHighChartsLangOptions($cfg);; + + return $cfgString; + } + + function CompatibilityCheck($cfg) + { + DebugModuleName($cfg,"CompatibilityCheck"); + + // Series + if (isset($cfg['Series']) && isset($cfg['series'])) + die ("Abbruch - Es düfen nicht gleichzeitig 'Series' und 'series' definiert werden."); + if (isset($cfg['Series']) && !isset($cfg['series'])) + $cfg['series'] = $cfg['Series']; + unset ($cfg['Series']); + + // Title + if (isset($cfg['Title']) && !isset($cfg['title']['text'])) + $cfg['title']['text'] = $cfg['Title']; + unset ($cfg['Title']); + + // SubTitle + if (isset($cfg['SubTitle']) && !isset($cfg['subtitle']['text'])) + $cfg['subtitle']['text'] = $cfg['SubTitle']; + unset ($cfg['SubTitle']); + + // SubTitleDateTimeFormat + if (isset($cfg['SubTitleDateTimeFormat']) && !isset($cfg['subtitle']['Ips']['DateTimeFormat'])) + $cfg['subtitle']['Ips']['DateTimeFormat'] = $cfg['SubTitleDateTimeFormat']; + unset ($cfg['SubTitleDateTimeFormat']); + + // yAxis + if (isset($cfg['yAxis'])) + { + $axisArr = array(); + foreach ($cfg['yAxis'] as $Axis) + { + $cfgAxis = $Axis; + + // Name + if (isset($Axis['Name']) && !isset($cfgAxis['title']['text'])) + $cfgAxis['title']['text'] = $Axis['Name']; + unset ($cfgAxis['Name']); + + // TickInterval + if (isset($Axis['TickInterval']) && !isset($cfgAxis['tickinterval'])) + $cfgAxis['tickinterval'] = $Axis['TickInterval']; + unset ($cfgAxis['TickInterval']); + + // Opposite + if (isset($Axis['Opposite']) && !isset($cfgAxis['opposite'])) + $cfgAxis['opposite'] = $Axis['Opposite']; + unset ($cfgAxis['Opposite']); + + $axisArr[] = $cfgAxis; + } + $cfg['yAxis'] = $axisArr; + } + return $cfg; + } + + // ------------------------------------------------------------------------ + // CheckCfg + // Prüft daKonfiguration und korrigiert und Vervollständigtdiese zum Teil + // IN: $cfg = .. + // OUT: der erzeugte Config String + // ------------------------------------------------------------------------ + function CheckCfg($cfg) + { + DebugModuleName($cfg,"CheckCfg"); + + $cfg = CheckCfg_Common($cfg); + $cfg = CheckCfg_AreaHighChart($cfg); + $cfg = CheckCfg_AggregatedValues($cfg); + $cfg = CheckCfg_StartEndTime($cfg); + $cfg = CheckCfg_Series($cfg); + + return $cfg; + } + + // ------------------------------------------------------------------------ + // CheckCfg_Common + // wenn RunMode=Popup, prüfen der dazugehörigen Daten wie WebfrontConfigId, usw. + // und wenn RunMode=Popup, prüfen der dazugehörigen Daten wie WebfrontConfigId, usw. + // IN: $cfg + // OUT: korrigiertes $cfg + // ------------------------------------------------------------------------ + function CheckCfg_Common($cfg) + { + DebugModuleName($cfg,"CheckCfg_Common"); + + if (!isset($cfg['series'])) + die ("Abbruch - Es wurden keine Serien definiert."); + + // Id des ArchiveHandler auslesen + if (!isset($cfg['ArchiveHandlerId']) || $cfg['ArchiveHandlerId'] == -1) + { + $instances = IPS_GetInstanceListByModuleID('{43192F0B-135B-4CE7-A0A7-1475603F3060}'); + $cfg['ArchiveHandlerId'] = $instances[0]; + } + // Prüfen des ArchiveHandlers + $instance = @IPS_GetInstance($cfg['ArchiveHandlerId']); + if ($instance['ModuleInfo']['ModuleID'] != "{43192F0B-135B-4CE7-A0A7-1475603F3060}") + die ("Abbruch - 'ArchiveHandlerId' (".$cfg['ArchiveHandlerId'].") ist keine Instance eines ArchiveHandler."); + + if ($cfg['RunMode'] == "popup") + { + // keine Webfront Id + if (!isset($cfg['WebFrontConfigId'])) + die ("Abbruch - Konfiguration von 'WebFrontConfigId' fehlt."); + + // prüfen ob die übergebene Id ein WebFront ist + $instance = @IPS_GetInstance($cfg['WebFrontConfigId']); + if ($instance['ModuleInfo']['ModuleID'] != "{3565B1F2-8F7B-4311-A4B6-1BF1D868F39E}") + die ("Abbruch - 'WebFrontConfigId' ist keine WebFrontId"); + + IfNotIssetSetValue($cfg['WFCPopupTitle'], ""); + } + + return $cfg; + } + + + // ------------------------------------------------------------------------ + // Check_ContentVariable + // prüfen ob Angaben der Content Variable stimmen oder ob es das übergeordnete Element ist + // IN: $cfg + // OUT: korrigiertes $cfg + // ------------------------------------------------------------------------ + function Check_ContentVariable($cfg, $scriptId) + { + DebugModuleName($cfg,"Check_ContentVariable"); + + // wenn keine Id übergeben wurde wird das übergeordnete Objekt als Content verwendet + if (!isset($cfg['ContentVarableId']) || $cfg['ContentVarableId'] <= 0) + $cfg['ContentVarableId'] = IPS_GetParent($scriptId); + + $variable = @IPS_GetVariable($cfg['ContentVarableId']); + if ($variable == false) + die ("Abbruch - Content-Variable nicht gefunden."); + + if ($variable['VariableValue']['ValueType'] != 3) + die ("Abbruch - Content-Variable ist keine STRING-Variable."); + + if ($variable['VariableCustomProfile'] != "~HTMLBox") + die ("Abbruch - Content-Variable muss als Profil '~HTMLBox' verwenden."); + + return $cfg; + } + + // ------------------------------------------------------------------------ + // CheckCfg_AreaHighChart + // + // IN: $cfg + // OUT: korrigiertes $cfg + // ------------------------------------------------------------------------ + function CheckCfg_AreaHighChart($cfg) + { + DebugModuleName($cfg,"CheckCfg_AreaHighChart"); + + IfNotIssetSetValue($cfg['HighChart']['Theme'], ""); + IfNotIssetSetValue($cfg['HighChart']['Width'], 0); + IfNotIssetSetValue($cfg['HighChart']['Height'], 400); + + return $cfg; + } + + // ------------------------------------------------------------------------ + // CheckCfg_StartEndTime + // Start- und Endzeit des gesamten Charts errechnen, und an jede Serie übergeben + // IN: $cfg + // OUT: korrigiertes $cfg + // ------------------------------------------------------------------------ + function CheckCfg_StartEndTime($cfg) + { + DebugModuleName($cfg,"CheckCfg_StartEndTime"); + + $cfg['Ips']['ChartStartTime'] = $cfg['StartTime']; + $cfg['Ips']['ChartEndTime'] = $cfg['EndTime']; + + $offsetExistsAtSerie = false; + $Count = count($cfg['series']); + + for ($i = 0; $i < $Count; $i++) + { + $Serie = $cfg['series'][$i]; + + // wenn für die Serie keine Start oder Endzeit übergeben würde wird der Standardwert genommen + IfNotIssetSetValue($Serie['StartTime'], $cfg['StartTime']); + IfNotIssetSetValue($Serie['EndTime'], $cfg['EndTime']); + + if ($Serie['StartTime'] < $cfg['Ips']['ChartStartTime']) + $cfg['Ips']['ChartStartTime'] = $Serie['StartTime']; + if ($Serie['EndTime'] > $cfg['Ips']['ChartEndTime']) + $cfg['Ips']['ChartEndTime'] = $Serie['EndTime']; + + $Serie['Ips']['EndTimeString'] = date("/r", $Serie['EndTime']); + $Serie['Ips']['StartTimeString']= date("/r", $Serie['StartTime']); + + $cfg['series'][$i] = $Serie; + + if (isset($Serie['Offset']) && $Serie['Offset'] != 0) + $offsetExistsAtSerie =true; + } + + // wenn ein Offset definiert wurde gilt nur der global eingestellte Start und Endzeitpunkt + if ($offsetExistsAtSerie = true) + { + $cfg['Ips']['ChartStartTime'] = $cfg['StartTime']; + $cfg['Ips']['ChartEndTime'] = $cfg['EndTime']; + } + + return $cfg; + + } + + // ------------------------------------------------------------------------ + // CheckCfg_Series + // prüfen der Serien + // IN: $cfg + // OUT: korrigiertes $cfg + // ------------------------------------------------------------------------ + function CheckCfg_Series($cfg) + { + DebugModuleName($cfg,"CheckCfg_Series"); + + $Id_AH = $cfg['ArchiveHandlerId']; + + $series = array(); + foreach ($cfg['series'] as $Serie) + { + $VariableId = @$Serie['Id']; + + // hier wird nur geprüft ob Wert von Eingabe passen könnte (wenn vorhanden) + if (isset($Serie['AggType']) && ($Serie['AggType']<0 || $Serie['AggType']>4) ) + die ("Abbruch - 'AggType' hat keinen korrekten Wert"); + + $Serie['Ips']['IsCounter'] = $VariableId && (@AC_GetAggregationType($Id_AH, $VariableId) == 1); + + // über AggValue kann Min/Max oder Avg vorgewählt werden (zum Lesen der AggregValues) + IfNotIssetSetValue($Serie['AggValue'], "Avg"); + + if ($Serie['AggValue'] != "Avg" + && $Serie['AggValue'] != "Min" + && $Serie['AggValue'] != "Max") + die ("Abbruch - 'AggValue' hat keinen gültigen Wert"); + + // Offset für Darstellung von z.B. Monate und Vormonat in einem Chart + IfNotIssetSetValue($Serie['Offset'], 0); + + IfNotIssetSetValue($Serie['ReplaceValues'], false); + + // Name (Kompatibilität aus V1.x) + if (isset($Serie['Name']) && !isset($Serie['name'])) + $Serie['name'] = $Serie['Name']; + unset($Serie['Name']); + + IfNotIssetSetValue($Serie['name'], ""); + + // type & Parameter + if (isset($Serie['type']) && isset($Serie['Param'])) + die ("Abbruch - Definition von 'Param' und 'type' in Serie gleichzeitig nicht möglich."); + if (!isset($Serie['type']) && !isset($Serie['Param'])) + die ("Abbruch - Serie muss Definition von 'Param' oder 'type' enthalten."); + + // Mögliche Charttypen + $allowedSeriesTypes = array(); + if ($cfg['Ips']['ChartType'] == 'Highcharts') + $allowedSeriesTypes = array('area','areaspline','bar','column','line','pie','scatter','spline'); + else if ($cfg['Ips']['ChartType'] == 'Highstock') + $allowedSeriesTypes = array('area','areaspline','bar','column','line','pie','scatter','spline','ohlc','candlestick'); + + if (!isset($Serie['type']) && isset($Serie['Param'])) + { + // type aus Param übernehmen + foreach($allowedSeriesTypes as $item) + { + if (strrpos($Serie['Param'],"'$item'") > 0) + $Serie['Ips']['Type'] = $item; + } + } + else + { + if (!in_array($Serie['type'], $allowedSeriesTypes)) + die ("Abbruch - Serien-Type (" . $Serie['type'] . ") nicht erkennbar."); + else + $Serie['Ips']['Type'] = $Serie['type']; + } + if (!isset($Serie['Ips']['Type'])) + die ("Abbruch - Serien-Type nicht erkennbar."); + + // data + if (isset($Serie['Data']) && isset($Serie['data'])) + die ("Abbruch - Definition von 'Data' und 'data' in ein und derselben Serie nicht mölglich."); + if (!isset($Serie['data']) && isset($Serie['Data'])) + { + $Serie['data'] = $Serie['Data']; + unset($Serie['Data']); + } + + // diverse Prüfungen bei PIE-Charts + if ($Serie['Ips']['Type'] == 'pie') + { + if (isset($Serie['Id'])) + { + if (!isset($Serie['AggType'])) + die ("Abbruch - Wird ein Pie über Id definiert muss auch AggType parametriert werden"); + + // wenn nichts angegeben wird 'AggNameFormat: automatisch abhängig vom 'AggType' berechnet + if (!isset($Serie['AggNameFormat'])) + { + if ($Serie['AggType'] == 0) //0=Hour + $Serie['AggNameFormat'] = "d.m.Y H:i"; + else if ($Serie['AggType'] == 1) //1=Day + $Serie['AggNameFormat'] = "d.m.Y"; + else if ($Serie['AggType'] == 2) //2=Week + $Serie['AggNameFormat'] = "\K\WW Y"; + else if ($Serie['AggType'] == 3) //3=Month + $Serie['AggNameFormat'] = "M Y"; + else if ($Serie['AggType'] == 4) //4=Year + $Serie['AggNameFormat'] = "Y"; + } + } + else if (isset($Serie['data'])) + { + foreach($Serie['data'] as $data) + { + if (isset($data['Id']) && isset($data['y'])) + die ("Abbruch - Pie['data']: Id und y sind als gleichzeitige Parameter nicht möglich."); + //if (!isset($data['Id']) && !isset($data['y'])) + // die ("Abbruch - Pie['data']: Id oder y muss definiert sein"); + // kann man so nicht prüfen + } + } + else + { + die ("Abbruch - Pie kann nie Daten besitzen. Es muss entweder über 'Id' oder über 'data' definiert werden."); + } + + } + + // geänderte Werte wieder zurückschreiben + $series[] = $Serie; + } + // geänderte Werte wieder zurückschreiben + + $cfg['series'] = $series; + return $cfg; + } + + // ------------------------------------------------------------------------ + // CheckCfg_AggregatedValues + // prüfen der AggregatedValues und Übernahme dieser in die Serien + // IN: $cfg + // OUT: korrigiertes $cfg + // ------------------------------------------------------------------------ + function CheckCfg_AggregatedValues($cfg) + { + DebugModuleName($cfg,"CheckCfg_AggregatedValues"); + + if (!isset($cfg['AggregatedValues'])) + $cfg['AggregatedValues'] = array(); + + // Default - wenn nichts vorbelegt + IfNotIssetSetValue($cfg['AggregatedValues']['MixedMode'], false); + IfNotIssetSetValue($cfg['AggregatedValues']['HourValues'], -1); + IfNotIssetSetValue($cfg['AggregatedValues']['DayValues'], -1); + IfNotIssetSetValue($cfg['AggregatedValues']['WeekValues'], -1); + IfNotIssetSetValue($cfg['AggregatedValues']['MonthValues'], -1); + IfNotIssetSetValue($cfg['AggregatedValues']['YearValues'], -1); + IfNotIssetSetValue($cfg['AggregatedValues']['NoLoggedValues'], 100); + + $series = array(); + foreach ($cfg['series'] as $Serie) + { + + // prüfen ob für die Serie Einstellungen für AggregatedValues vorhanden sind, + // wenn nicht Übernahme aus cfg + if (isset($Serie['AggregatedValues'])) + { + IfNotIssetSetValue($Serie['AggregatedValues']['MixedMode'], $cfg['AggregatedValues']['MixedMode']); + IfNotIssetSetValue($Serie['AggregatedValues']['HourValues'], $cfg['AggregatedValues']['HourValues']); + IfNotIssetSetValue($Serie['AggregatedValues']['DayValues'], $cfg['AggregatedValues']['DayValues']); + IfNotIssetSetValue($Serie['AggregatedValues']['WeekValues'], $cfg['AggregatedValues']['WeekValues']); + IfNotIssetSetValue($Serie['AggregatedValues']['MonthValues'], $cfg['AggregatedValues']['MonthValues']); + IfNotIssetSetValue($Serie['AggregatedValues']['YearValues'], $cfg['AggregatedValues']['YearValues']); + IfNotIssetSetValue($Serie['AggregatedValues']['NoLoggedValues'], $cfg['AggregatedValues']['NoLoggedValues']); + } + else // nein -> Daten aus übergeordneter cfg übernehmen + $Serie['AggregatedValues'] = $cfg['AggregatedValues']; + + // Umrechnen der Tage in Sekunden ... für direktes addieren zum Timestamp + $MinPerTag = 24*60*60; + + if ($Serie['AggregatedValues']['HourValues'] != -1) + $Serie['AggregatedValues']['HourValues'] *= $MinPerTag; + if ($Serie['AggregatedValues']['DayValues'] != -1) + $Serie['AggregatedValues']['DayValues'] *= $MinPerTag; + if ($Serie['AggregatedValues']['WeekValues'] != -1) + $Serie['AggregatedValues']['WeekValues'] *= $MinPerTag; + if ($Serie['AggregatedValues']['MonthValues'] != -1) + $Serie['AggregatedValues']['MonthValues'] *= $MinPerTag; + if ($Serie['AggregatedValues']['YearValues'] != -1) + $Serie['AggregatedValues']['YearValues'] *= $MinPerTag; + if ($Serie['AggregatedValues']['NoLoggedValues'] != -1) + $Serie['AggregatedValues']['NoLoggedValues'] *= $MinPerTag; + + // geänderte Werte wieder zurückschreiben + $series[] = $Serie; + } + // geänderte Werte wieder zurückschreiben + $cfg['series'] = $series; + + // die sind jetzt nicht mehr nötig..... + unset($cfg['AggregatedValues']); + + return $cfg; + } + + + + // ------------------------------------------------------------------------ + // ReadAdditionalConfigData + // zusätzliche Daten für File (hat jetzt aber nichts mit den eigentlichen Highchart Config String zu tun + // IN: $cfg + // OUT: der String welcher dann in das IPS_Template geschrieben wird. + // ------------------------------------------------------------------------ + function ReadAdditionalConfigData($cfg) + { + DebugModuleName($cfg,"ReadAdditionalConfigData"); + + // z.B.: Breite und Höhe für Container + // Breite und Höhe anpassen für HTML Ausgabe + $s['Theme'] = $cfg['HighChart']['Theme']; + if ($cfg['HighChart']['Width'] == 0) + $s['Width'] = "100%"; + else + $s['Width'] = $cfg['HighChart']['Width']. "px"; + + $s['Height'] = $cfg['HighChart']['Height']. "px"; + + return trim(print_r($s, true), "Array\n()") ; + } + +// *************************************************************************************************************************** + + // ------------------------------------------------------------------------ + // GetHighChartsCfgFile + // Falls nicht konfiguriert, wird dies als Default String genommen + // OUT: natürlich den String .... + // ------------------------------------------------------------------------ + function GetHighChartsCfgFile($cfg) + { + DebugModuleName($cfg,"GetHighChartsCfgFile"); + + $cfgArr['chart'] = CreateArrayForChart($cfg); + + if (isset($cfg['colors'])) + $cfgArr['colors'] = $cfg['colors']; + + $cfgArr['credits'] = CreateArrayForCredits($cfg); + + if (isset($cfg['global'])) + $cfgArr['global'] = $cfg['global']; + + if (isset($cfg['labels'])) + $cfgArr['labels'] = $cfg['labels']; + + // $cfg['lang'])) werden seperat behandelt + + if (isset($cfg['legend'])) + $cfgArr['legend'] = $cfg['legend']; + + if (isset($cfg['loading'])) + $cfgArr['loading'] = $cfg['loading']; + + if (isset($cfg['plotOptions'])) + $cfgArr['plotOptions'] = $cfg['plotOptions']; + + $cfgArr['exporting'] = CreateArrayForExporting($cfg); + + if (isset($cfg['symbols'])) + $cfgArr['symbols'] = $cfg['symbols']; + + $cfgArr['title'] = CreateArrayForTitle($cfg); + $cfgArr['subtitle'] = CreateArrayForSubTitle($cfg); + + $cfgArr['tooltip'] = CreateArrayForTooltip($cfg); + + $cfgArr['xAxis'] = CreateArrayForXAxis($cfg); + $cfgArr['yAxis'] = CreateArrayForYAxis($cfg); + + if ($cfg['Ips']['ChartType'] == 'Highstock') + { + if (isset($cfg['navigator'])) + $cfgArr['navigator'] = $cfg['navigator']; + if (isset($cfg['rangeSelector'])) + $cfgArr['rangeSelector'] = $cfg['rangeSelector']; + if (isset($cfg['scrollbar'])) + $cfgArr['scrollbar'] = $cfg['scrollbar']; + } + + + if ($cfg['Ips']['Debug']['ShowJSON']) + DebugString(my_json_encode($cfgArr)); + + $cfgArr['series'] = CreateArrayForSeries($cfg) ; + + if ($cfg['Ips']['Debug']['ShowJSON_Data']) + DebugString(my_json_encode($cfgArr)); + + // Array in JSON wandeln + $s = my_json_encode($cfgArr); + + // ersetzten des 'Param'-Parameters (Altlast aus V1.x) + $s = str_replace(",Param@@@:",",",$s); + $s = trim($s, "{"); + $s .= ");"; + + return $s; + } + + // ------------------------------------------------------------------------ + // GetHighChartsLangOptions + // + // IN: $cfg + // OUT: JSON Options String für den Bereich 'lang' + // ------------------------------------------------------------------------ + function GetHighChartsLangOptions($cfg) + { + DebugModuleName($cfg,"GetHighChartsLangOptions"); + + // Default + IfNotIssetSetValue($cfg['lang']['decimalPoint'], ","); + IfNotIssetSetValue($cfg['lang']['thousandsSep'], "."); + + IfNotIssetSetValue($cfg['lang']['months'], ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember']); + IfNotIssetSetValue($cfg['lang']['shortMonths'], ['Jan', 'Feb', 'Mär', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez']); + IfNotIssetSetValue($cfg['lang']['weekdays'], ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag']); + + $s = "lang:" . my_json_encode($cfg['lang']); + + return $s; + } + + + // ------------------------------------------------------------------------ + // CreateArrayForSeries + // + // IN: $cfg + // OUT: der String welcher dann in das IPS_Template geschrieben wird. + // ------------------------------------------------------------------------ + function CreateArrayForSeries($cfg) + { + DebugModuleName($cfg,"CreateArrayForSeries"); + + // Daten für einzelne Serien erzeugen + $dataArr = array(); + foreach ($cfg['series'] as $Serie) + { + if ($Serie['Ips']['Type'] == 'pie') + { + $Serie['data'] = CreateDataArrayForPie($cfg, $Serie); + } + else + { + // Daten wurden von extern übergeben + if (isset($Serie['data'])) + { + if (is_array($Serie['data'])) + $Serie['data'] = CreateDataArrayFromExternalData($Serie['data'], $Serie); + else + $Serie['data'] = $Serie['data']; + + } + // Daten werden aus DB gelesen + else + $Serie['data'] = ReadDataFromDBAndCreateDataArray($cfg, $Serie); + } + + // ... aus Serie umkopieren + $serieArr = $Serie; + + // nicht für JSON benötigte Parameter löschen + unset($serieArr['Param']); + unset($serieArr['AggregatedValues']); + unset($serieArr['Unit']); + unset($serieArr['StartTime']); + unset($serieArr['EndTime']); + unset($serieArr['ReplaceValues']); + unset($serieArr['Ips']); + unset($serieArr['Offset']); + unset($serieArr['AggValue']); + unset($serieArr['AggType']); + unset($serieArr['AggNameFormat']); + unset($serieArr['ScaleFactor']); + unset($serieArr['RoundValue']); + + // ersetzten des 'Param'-Parameters (Altlast aus V1.x) + if (isset($Serie['Param'])) + $serieArr['Param@@@'] = "@" . $Serie['Param'] . "@"; + + $dataArr[] = $serieArr; + } + + return $dataArr; + } + + // ------------------------------------------------------------------------ + // PopulateDate + // + // IN: $dt + // $serie + // OUT: Date-Value für Data-String + // ------------------------------------------------------------------------ + function PopulateDate($dt, $serie) + { + if ($dt < $serie['StartTime']) + $dt = $serie['StartTime'] ; + + // z.B.: Date.UTC(2011,4,27,19,42,19),23.4 + return CreateDateUTC($dt + $serie['Offset']); + } + + // ------------------------------------------------------------------------ + // PopulateValue + // + // IN: $val + // $serie + // OUT: korrigiertes $cfg + // ------------------------------------------------------------------------ + function PopulateValue($val, $serie) + { + // Werte ersetzten (sinnvoll für Boolean, oder Integer - z.B.: Tür/Fenster-Kontakt oder Drehgriffkontakt) + if ($serie['ReplaceValues'] != false) + { + if (isset($serie['ReplaceValues'][$val])) + $val = $serie['ReplaceValues'][$val]; + } + + // Skalieren von Loggingdaten + if (isset($serie['ScaleFactor'])) + $val = $val * $serie['ScaleFactor']; + + // Rounden von Nachkommastellen + if (isset($serie['RoundValue'])) + $val = round($val, $serie['RoundValue']); + + + return $val; + } + + // ------------------------------------------------------------------------ + // CreateDataArrayForPie + // Liest die aktuellen Werte aus den übergebenen Variablen und erzeugt die Daten für das PIE + // IN: $cfg, $Serie + // OUT: der Data String + // ------------------------------------------------------------------------ + function CreateDataArrayForPie($cfg, $serie) + { + DebugModuleName($cfg,"CreateDataArrayForPie"); + + if (isset($serie['Id'])) + { + return ReadPieDataById($cfg, $serie); + } + else if (isset($serie['data'])) + { + $result = array(); + foreach($serie['data'] as $item) + { + if (isset($item['Id'])) + { + $currentValue = ReadCurrentValue($item['Id']); + $item['y'] = PopulateValue($currentValue['Value'], $serie) ; + } + $result[] = $item; + } + return $result; + } + else + { + Die ("Abbruch - Pie-Definition nicht korrekt"); + } + return $Data; + } + + // ------------------------------------------------------------------------ + // ReadPieDataById + // liest die Aggregated-Werte einer einer Vriablen aus und erzeugt das entsprechende Array + // IN: $cfg, $serie + // OUT: Config Array + // ------------------------------------------------------------------------ + function ReadPieDataById($cfg, $serie) + { + $id_AH = $cfg['ArchiveHandlerId']; + + $tempData = @AC_GetAggregatedValues($id_AH, $serie['Id'], $serie['AggType'], $serie['StartTime'], $serie['EndTime'], 0); + $tempData = array_reverse($tempData); + + $result = array(); + foreach ($tempData as $ValueItem) + { + $item['name'] = ReplaceToGermanDate(date($serie['AggNameFormat'], $ValueItem['TimeStamp'])); + $item['y'] = PopulateValue($ValueItem[$serie['AggValue']], $serie); + $result[] = $item; + } + unset ($tempData); + + return $result; + } + + // ------------------------------------------------------------------------ + // CalculateStartAndEndTimeForAggreagtedValues + // Liest den Start- und Endzeitpunkt des angefragten Bereiches + // IN: $Serie, $search : "" für alle Werte, "Hour", "Day", usw + // OUT: Array(StartTime,EndTime) + // ------------------------------------------------------------------------ + function CalculateStartAndEndTimeForAggreagtedValues($Serie, $search ="") + { + $start = -1; $ende = -1; + $trap = false; + $sum = 0; + + if ($search == "") + { + $search =="Values"; + $start = 0; + $trap = true; + } + foreach($Serie['AggregatedValues'] as $key => $value) + { + if (strrpos ($key, "Values") != false) + { + if ($value > 0) + $sum += $value; + + if (strrpos ($key, $search) !== false) + { + $trap = true; + if ($value == -1) + return false; + } + + if (!$trap) + continue; + + if ($value < 0) + continue; + + if ($start == -1) + { + $start = $sum; + continue; + } + + if ($start != -1 && $ende ==-1) + { + $ende = $sum; + break; + } + } + } + + $result = false; + if ($start != -1) + { + $result["EndTime"] = $Serie["EndTime"] - $start; + if ($ende == -1) + $result["StartTime"] = $Serie["StartTime"]; + else + $result["StartTime"] = $Serie["EndTime"] - $ende; + + if ($result["StartTime"] < $Serie["StartTime"]) + $result["StartTime"] = $Serie["StartTime"]; + + if ($result["StartTime"] == $Serie["EndTime"]) + $result = false; + } + + return $result; + } + + // ------------------------------------------------------------------------ + // ReadDataFromDBAndCreateDataArray + // Liest die Series-Daten aus der DB und schreibt sie in den DataString + // IN: $cfg, $Serie + // OUT: der Data String + // ------------------------------------------------------------------------ + function ReadDataFromDBAndCreateDataArray($cfg, $Serie) + { + DebugModuleName($cfg,"ReadDataFromDBAndCreateDataArray"); + + if (!isset($Serie['Id'])) + return ""; + + // errechne die Zeitspanne + if ($Serie['EndTime'] > time()) + $Diff = time() - $Serie['StartTime']; + else + $Diff = $Serie['EndTime'] - $Serie['StartTime']; + + + + $Id_AH = $cfg['ArchiveHandlerId']; + $dataArray = array(); + $VariableId = (int)$Serie['Id']; + $Agg = -1; + $ReadCurrentValue = true; + + // wenn ReplaceValues definiert wurden werden nur geloggte und keine Aggregated Werte gelesen + if ($Serie['ReplaceValues'] != false) + { + if ($Diff > $Serie['AggregatedValues']['NoLoggedValues']) + { + $Serie['StartTime'] = $Serie['EndTime'] - $Serie['AggregatedValues']['NoLoggedValues']; + } + + // Einzelwerte lesen + $dataArray = ReadAndAddToLoggedData($dataArray, $Id_AH, $VariableId, -1 , $Serie["StartTime"], $Serie["EndTime"], "Value", $Serie); + } + else if ($Serie['AggregatedValues']['MixedMode']) // im MixedMode werden anfangs alle Werte, dann die Stunden- und zuletzt Tageswerte ausgelesen + { + // zuerst Einzelwerte + $result = CalculateStartAndEndTimeForAggreagtedValues($Serie, ""); + if ($result != false) + { + if ($Serie['Ips']['IsCounter']) // wenn Zähler dann immer Agg.Values + $dataArray = ReadAndAddToLoggedData($dataArray, $Id_AH, $VariableId, 0, $result["StartTime"], $result["EndTime"], $Serie['AggValue'], $Serie); + else + $dataArray = ReadAndAddToLoggedData($dataArray, $Id_AH, $VariableId, -1 , $result["StartTime"], $result["EndTime"], "Value", $Serie); + } + + // -> Stundenwerte + $result = CalculateStartAndEndTimeForAggreagtedValues($Serie,"Hour"); + if ($result != false) + $dataArray = ReadAndAddToLoggedData($dataArray, $Id_AH, $VariableId, 0, $result["StartTime"], $result["EndTime"], $Serie['AggValue'], $Serie); + + // -> Tageswerte + $result = CalculateStartAndEndTimeForAggreagtedValues($Serie,"Day"); + if ($result != false) + $dataArray = ReadAndAddToLoggedData($dataArray, $Id_AH, $VariableId, 1, $result["StartTime"], $result["EndTime"], $Serie['AggValue'], $Serie); + + // -> Wochenwerten + $result = CalculateStartAndEndTimeForAggreagtedValues($Serie,"Week"); + if ($result != false) + $dataArray = ReadAndAddToLoggedData($dataArray, $Id_AH, $VariableId, 2, $result["StartTime"], $result["EndTime"], $Serie['AggValue'], $Serie); + + // -> Monatswerte + $result = CalculateStartAndEndTimeForAggreagtedValues($Serie,"Month"); + if ($result != false) + $dataArray = ReadAndAddToLoggedData($dataArray, $Id_AH, $VariableId, 3, $result["StartTime"], $result["EndTime"], $Serie['AggValue'], $Serie); + + // -> Jahreswerte + $result = CalculateStartAndEndTimeForAggreagtedValues($Serie,"Year"); + if ($result != false) + $dataArray = ReadAndAddToLoggedData($dataArray, $Id_AH, $VariableId, 4, $result["StartTime"], $result["EndTime"], $Serie['AggValue'], $Serie); + } + else + { + $Agg = -1; // -> AC_GetLoggedValues + + if (isset($Serie['AggType'])) // wenn 'AggType' definiert wurde, wird dies vorrangig bearbeitet + { + $Agg = $Serie['AggType']; + } + elseif ($Serie['AggregatedValues']['YearValues']!= -1 && $Diff > $Serie['AggregatedValues']['YearValues']) + $Agg = 4; // -> AC_GetAggregatedValues [0=Hour, 1=Day, 2=Week, 3=Month, 4=Year] + elseif ($Serie['AggregatedValues']['MonthValues']!= -1 && $Diff > $Serie['AggregatedValues']['MonthValues']) + $Agg = 3; // -> AC_GetAggregatedValues [0=Hour, 1=Day, 2=Week, 3=Month, 4=Year] + elseif ($Serie['AggregatedValues']['WeekValues']!= -1 && $Diff > $Serie['AggregatedValues']['WeekValues']) + $Agg = 2; // -> AC_GetAggregatedValues [0=Hour, 1=Day, 2=Week, 3=Month, 4=Year] + elseif ($Serie['AggregatedValues']['DayValues']!= -1 && $Diff > $Serie['AggregatedValues']['DayValues']) + $Agg = 1; // -> AC_GetAggregatedValues [0=Hour, 1=Day, 2=Week, 3=Month, 4=Year] + else if ($Serie['AggregatedValues']['HourValues']!= -1 && $Diff > $Serie['AggregatedValues']['HourValues']) + $Agg = 0; // -> AC_GetAggregatedValues [0=Hour, 1=Day, 2=Week, 3=Month, 4=Year] + + // es wurde noch nichts definiert und es handelt sich um einen Zähler --> Tageswerte + if ($Agg == -1 && $Serie['Ips']['IsCounter']) + $Agg = 0; + + if ($Agg == -1) + { + // Zeitraum ist zu groß -> nur bis max. Zeitraum einlesen + if ($Diff > $Serie['AggregatedValues']['NoLoggedValues']) + $Serie['StartTime'] = $Serie['EndTime'] - $Serie['AggregatedValues']['NoLoggedValues']; + + // Alle Werte + $dataArray = ReadAndAddToLoggedData($dataArray, $Id_AH, $VariableId, -1 , $Serie["StartTime"], $Serie["EndTime"], "Value", $Serie); + } + else + { + $dataArray = ReadAndAddToLoggedData($dataArray, $Id_AH, $VariableId, $Agg, $Serie["StartTime"], $Serie["EndTime"], $Serie['AggValue'], $Serie); + $ReadCurrentValue = false; + } + } + + // sortieren, so , dass der aktuellste Wert zuletzt kommt + $dataArray = array_reverse($dataArray); + + // aktuellen Wert der Variable noch in Array aufnehmen + if ($ReadCurrentValue + //&& $Serie['EndTime'] >= time() // nicht wenn Endzeitpunkt vor NOW ist + && !$Serie['Ips']['IsCounter']) // nicht bei Zählervariablen + { +// $curValue = ReadCurrentValue($VariableId); + $curValue = ReadLoggedValue($Id_AH, $VariableId, $Serie['EndTime']); + $dataArray[] = CreateDataItem($curValue['TimeStamp'], $curValue['Value'], $Serie); + } + + + return $dataArray ; + } + + // ------------------------------------------------------------------------ + // ReadLoggedValue + // IN: $instanceID, $VariableId, $time + // OUT: Aktueller Wert + // ------------------------------------------------------------------------ + function ReadLoggedValue($instanceID, $variableId, $time) + { + if ($time > time()) $time = time(); + $values = AC_GetLoggedValues($instanceID, $variableId, 0, $time+1, 1); + $currentVal['Value']= $values[0]['Value']; + $currentVal['TimeStamp'] = $time; + + return $currentVal; + } + + // ------------------------------------------------------------------------ + // ReadCurrentValue + // IN: $VariableId + // OUT: Aktueller Wert + // ------------------------------------------------------------------------ + function ReadCurrentValue($variableId) + { + $currentVal['Value']= GetValue($variableId); + $currentVal['TimeStamp'] = time(); + + return $currentVal; + } + + // ------------------------------------------------------------------------ + // ReadAndAddToLoggedData + // IN: siehe Parameter + // OUT: Vervollständigte Logged Data + // ------------------------------------------------------------------------ + function ReadAndAddToLoggedData($loggedData, $id_AH, $variableId, $aggType, $startTime, $endTime, $aggValueName, $serie) + { + $cfg['Ips']['Debug']['Modules'] = true; + + if ($aggType >= 0) + $tempData = @AC_GetAggregatedValues($id_AH, $variableId, $aggType, $startTime, $endTime, 0); + else + //$tempData = @AC_GetLoggedValues($id_AH, $variableId, $startTime, $endTime, 0 ); + $tempData = @AC_GetLoggedValuesCompatibility($id_AH, $variableId, $startTime, $endTime, 0 ); + + foreach ($tempData as $item) + { + $loggedData[] = CreateDataItem($item['TimeStamp'], $item[$aggValueName], $serie); + } + + unset ($tempData); + + return $loggedData; + } + + //Hilfsfunktion, die die Funktionsweise von IP-Symcon 2.x nachbildet + function AC_GetLoggedValuesCompatibility($instanceID, $variableID, $startTime, $endTime, $limit) { + $values = AC_GetLoggedValues($instanceID, $variableID, $startTime, $endTime, $limit ); + if((sizeof($values) == 0) || (end($values)['TimeStamp'] > $startTime)) { + $previousRow = AC_GetLoggedValues($instanceID, $variableID, 0, $startTime - 1, 1 ); + $values = array_merge($values, $previousRow); + } + return $values; + } + + function CreateDataItem($dt, $val, $serie) + { + // Wert anpassen (Round, Scale) + $val = PopulateValue($val, $serie); + + // z.B.: Date.UTC(2011,4,27,19,42,19),23.4 + $dtUTC = PopulateDate($dt, $serie); + + return array("@$dtUTC@", $val); + } + + // ------------------------------------------------------------------------ + // CreateDataArrayFromExternalData + // Umwandeln der externen Daten in ein Daten Array + // IN: $arr = Aus IPS-Datenbank ausgelesenen Daten (LoggedData) + // $Serie = Config Daten der aktuellen Serie + // OUT: Highcharts ConfigString für Series-Data + // ------------------------------------------------------------------------ + function CreateDataArrayFromExternalData($arr, $Serie) + { + $result = array(); + foreach($Serie['data'] as $item) + { + if (is_array($item)) + { + if (isset($item['TimeStamp']) && !isset($item['x'])) + { + $item['x'] = "@" . PopulateDate($item['TimeStamp'], $Serie) . "@"; + unset($item['TimeStamp']); + } + if (isset($item['Value']) && !isset($item['y'])) + { + $item['y'] = $item['Value']; + unset($item['Value']); + } + if (isset($item['y'])) + $item['y'] = PopulateValue($item['y'], $Serie); + + $result[] = $item; + } + else + $result[] = $item; + } + + return $result; + } + + // ------------------------------------------------------------------------ + // CreateTooltipFormatter + // Auslesen von immer wieder benötigten Werten aus der Variable + // IN: $cfg = Alle Config Daten + // OUT: Highcharts ConfigString für Tooltip-Formatter (Interaktive Anzeige des Wertes) + // ------------------------------------------------------------------------ + function CreateTooltipFormatter($cfg) + { + DebugModuleName($cfg,"CreateTooltipFormatter"); + + //ToDo: da sollten wir etwas lesbarer arbeiten + $s = ""; + $offset =""; + + foreach ($cfg['series'] as $Serie ) + { + if ($Serie['Ips']['Type'] == 'pie') + { + if (isset($Serie['data'])) + { + $s .= "["; + foreach($Serie['data'] as $data) + { + $unit = @$Serie['Unit']; + if (isset($data['Unit'])) + $unit = $data['Unit']; + + $s .= "this.y +' " . $unit . "',"; + } + $s = trim($s,","); + $s .= "][this.point.x],"; + } + else + { + $unit = @$Serie['Unit']; + $s .= "[this.y + ' " . $unit . "'],"; + } + $offset .= "0,"; // pies haben nie einen Offset + } + else + { + // hier wird das VariableCustomProfile aus IPS übernommen + if (!isset($Serie['Unit'])) + { + // hole das Variablen Profil + $IPSProfil = @GetIPSVariableProfile($Serie['Id']); + if ($IPSProfil != false) + { + if (array_key_exists("Associations",$IPSProfil) && count($IPSProfil['Associations'])>0) + { + $Arr = array(); + foreach($IPSProfil['Associations'] as $Item) + { + $Arr[$Item['Value']] = $Item['Name']; + } + + if (!is_array($Serie['ReplaceValues'])) // erzeuge Tooltips vollständig aus VariablenProfil + $s .= CreateTooltipSubValues($Arr, array_keys($Arr)); + else // oder nehme ReplaceValues zur Hilfe + $s .= CreateTooltipSubValues($Arr, $Serie['ReplaceValues']); + } + else + { + // Suffix als Einheit übernehmen + $Serie['Unit'] = trim($IPSProfil['Suffix'], " "); + $s .= "[this.y + ' ". $Serie['Unit']."'],"; + } + } + else // falls VariablenId nicht existiert + { + $s .= "[this.y ],"; + } + } + // es wurden Unit und ReplaceValues übergeben + else if (is_array($Serie['Unit']) && is_array($Serie['ReplaceValues'])) + { + $s .= CreateTooltipSubValues($Serie['Unit'],$Serie['ReplaceValues']); + } + else // Einheit aus übergebenem Parmeter Unit + { + $s .= "[this.y + ' ". $Serie['Unit']."'],"; + } + $offset .= $Serie['Offset'] . ","; + } + + } + + $s = trim($s , "," ); + $offset = trim($offset , "," ); + + //*1000 da JS in [ms] angebgeben wird un php in [s] +/* $TooltipString="function() { + var serieIndex = this.series.index; + + if (this.series.type == 'pie') + { + var pointIndex = this.point.x; + var unit = [".$s. "][serieIndex][pointIndex]; + + if (!unit) + unit = [".$s. "][serieIndex][0]; + + return '' + this.point.name +': '+ unit +'
= ' + this.percentage.toFixed(1) + ' %'; + } + else + { + var pointIndex = 0; + var unit = [".$s. "][serieIndex][pointIndex]; + var offset = [".$offset. "][serieIndex] * 1000; + + var offsetInfo =''; + if (offset != 0) + offsetInfo = '
(Achtung Zeitwert hat einen Offset)'; + else + offsetInfo =''; + + return '' + this.series.name + ': '+ unit + '
' + + Highcharts.dateFormat('%A %d.%m.%Y %H:%M', this.x - offset) + + offsetInfo; + + + } + } "; +*/ + $TooltipString="function() { + var serieIndex = this.series.index; + var unit = [".$s. "][serieIndex]; + var offset = [".$offset. "][serieIndex] * 1000; + var offsetInfo =''; + + if (offset != 0) + offsetInfo = '
(Achtung Zeitwert hat einen Offset)'; + else + offsetInfo =''; + + if (this.series.type == 'pie') + { + return '' + this.point.name +': '+ unit +'
= ' + this.percentage.toFixed(1) + ' %'; + } + else + { + return '' + this.series.name + ': '+ unit + '
' + + Highcharts.dateFormat('%A %d.%m.%Y %H:%M', this.x - offset) + + offsetInfo; + } + } "; + + + + return $TooltipString; + } + + // ------------------------------------------------------------------------ + // CreateTooltipSubValues + // Erzeugt den Tooltip für Unter-Elemente + // IN: shownTooltipArr = Array der Werte (Synonyme) welche im Tooltip angezeigt werden sollen + // chartValueArr = Array der Werte welche im Chart eingetragen werden + // OUT: Tooltip String + // ------------------------------------------------------------------------ + function CreateTooltipSubValues($shownTooltipArr, $chartValueArr) + { + $s="{"; + $Count = count($shownTooltipArr); + for ($i = 0; $i < $Count ; $i++) + { + if (isset($chartValueArr[$i]) && isset($shownTooltipArr[$i])) + $s .= $chartValueArr[$i] .": '" . $shownTooltipArr[$i] ."'," ; + } + $s = trim($s, ",") . "}"; + + return $s ."[this.y],"; + } + + // ------------------------------------------------------------------------ + // GetIPSVariableProfile + // Liest das Variablen Profil der übergeben Variable aus + // Versucht zuerst das eigene und wenn nicht verfügbar das Standar Profil auszulesen + // IN: variableId = Id der Variablen + // OUT: Variablen Profil + // ------------------------------------------------------------------------ + function GetIPSVariableProfile($variableId) + { + $var = @IPS_GetVariable($variableId); + if ($var == false) // Variabel existiert nicht + return false; + + $profilName = $var['VariableCustomProfile']; // "Eigenes Profil" + + if ($profilName == false) // "Standard" Profil + $profilName = $var['VariableProfile']; + + if ($profilName != false) + return IPS_GetVariableProfile($profilName); // und jetzt die dazugehörigen Daten laden + else + return false; + } + + + + // ------------------------------------------------------------------------ + // CreateArrayForChart + // + // IN: $cfg + // OUT: Config Array für den Bereich 'chart' + // ------------------------------------------------------------------------ + function CreateArrayForChart($cfg) + { + if (!isset($cfg['chart'])) + $cfg['chart'] = array(); + + //Default + IfNotIssetSetValue($cfg['chart']['renderTo'], "container"); + IfNotIssetSetValue($cfg['chart']['zoomType'], "xy"); + + return $cfg['chart']; + } + + // ------------------------------------------------------------------------ + // CreateArrayForCredits + // + // IN: $cfg + // OUT: Config Array für den Bereich 'credits' + // ------------------------------------------------------------------------ + function CreateArrayForCredits($cfg) + { + if (!isset($cfg['credits'])) + $cfg['credits'] = array(); + + //Default + IfNotIssetSetValue($cfg['credits']['enabled'], false); + + return $cfg['credits']; + } + + // ------------------------------------------------------------------------ + // CreateArrayForTitle + // + // IN: $cfg + // OUT: Config Array für den Bereich 'title' + // ------------------------------------------------------------------------ + function CreateArrayForTitle($cfg) + { + if (!isset($cfg['title'])) + $cfg['title'] = array(); + + return $cfg['title']; + } + + // ------------------------------------------------------------------------ + // CreateArrayForExporting + // + // IN: $cfg + // OUT: Config Array für den Bereich 'exporting' + // ------------------------------------------------------------------------ + function CreateArrayForExporting($cfg) + { + if (!isset($cfg['exporting'])) + $cfg['exporting'] = array(); + + //Default + IfNotIssetSetValue($cfg['exporting']['buttons']['printButton']['enabled'], false); + + return $cfg['exporting']; + } + + // ------------------------------------------------------------------------ + // CreateArrayForTooltip + // + // IN: $cfg + // OUT: Config Array für den Bereich 'tooltip' + // ------------------------------------------------------------------------ + function CreateArrayForTooltip($cfg) + { + if (!isset($cfg['tooltip'])) + $cfg['tooltip'] = array(); + + //Default + // wenn not isset -> autom. erzeugen durch IPS + if (!isset($cfg['tooltip']['formatter'])) + $cfg['tooltip']['formatter'] = "@" . CreateTooltipFormatter($cfg) . "@"; + // wenn "" -> default by highcharts + else if ($cfg['tooltip']['formatter'] == "") + { + // do nothing + } + + return $cfg['tooltip']; + } + + // ------------------------------------------------------------------------ + // CreateArrayForSubTitle + // + // IN: $cfg + // OUT: Config Array für den Bereich subtitle + // ------------------------------------------------------------------------ + function CreateArrayForSubTitle($cfg) + { + if (!isset($cfg['subtitle'])) + $cfg['subtitle'] = array(); + + //Default + IfNotIssetSetValue($cfg['subtitle']['text'], "Zeitraum: %STARTTIME% - %ENDTIME%"); + IfNotIssetSetValue($cfg['subtitle']['Ips']['DateTimeFormat'], "(D) d.m.Y H:i"); + + $s = $cfg['subtitle']['text']; + $s = str_ireplace("%STARTTIME%", date($cfg['subtitle']['Ips']['DateTimeFormat'], $cfg['Ips']['ChartStartTime']), $s); + $s = str_ireplace("%ENDTIME%", date($cfg['subtitle']['Ips']['DateTimeFormat'], $cfg['Ips']['ChartEndTime']), $s); + $cfg['subtitle']['text'] = ReplaceToGermanDate($s); + + unset($cfg['subtitle']['Ips']); + + return $cfg['subtitle']; + } + // ------------------------------------------------------------------------ + // CreateArrayForXAxis + // Erzeugen das ArrX-Achsen Strings für Highchart-Config + // IN: $cfg + // es besteht die Möglichkeit den Achsen String bereits im Highchart Format zu hinterlegen + // oder die folgenden Parameter als Array einzustellen: Name, Min, Max, TickInterval, Opposite, Unit + // OUT: Highcharts String für die Achsen + // ------------------------------------------------------------------------ + function CreateArrayForXAxis($cfg) + { + if (!isset($cfg['xAxis'])) + $cfg['xAxis'] = array(); + + //Default + IfNotIssetSetValue($cfg['xAxis']['type'], "datetime"); + IfNotIssetSetValue($cfg['xAxis']['dateTimeLabelFormats']['second'], "%H:%M:%S"); + IfNotIssetSetValue($cfg['xAxis']['dateTimeLabelFormats']['minute'], "%H:%M"); + IfNotIssetSetValue($cfg['xAxis']['dateTimeLabelFormats']['hour'], "%H:%M"); + IfNotIssetSetValue($cfg['xAxis']['dateTimeLabelFormats']['day'], "%e. %b"); + IfNotIssetSetValue($cfg['xAxis']['dateTimeLabelFormats']['week'], "%e. %b"); + IfNotIssetSetValue($cfg['xAxis']['dateTimeLabelFormats']['month'], "%b %y"); + IfNotIssetSetValue($cfg['xAxis']['dateTimeLabelFormats']['year'], "%Y"); + + IfNotIssetSetValue($cfg['xAxis']['allowDecimals'], false); + + if (isset($cfg['xAxis']['min']) && $cfg['xAxis']['min'] == false) + unset($cfg['xAxis']['min']); + else + IfNotIssetSetValue($cfg['xAxis']['min'], "@" . CreateDateUTC($cfg['Ips']['ChartStartTime']) ."@"); + + if (isset($cfg['xAxis']['max']) && $cfg['xAxis']['max'] == false) + unset($cfg['xAxis']['max']); + else + IfNotIssetSetValue($cfg['xAxis']['max'], "@" . CreateDateUTC($cfg['Ips']['ChartEndTime'])."@"); + + + + return $cfg['xAxis']; + } + + // ------------------------------------------------------------------------ + // CreateArrayForYAxis + // Erzeugen der Y-Achsen Strings für Highchart-Config + // IN: $cfg + // es besteht die Möglichkeit den Achsen String bereits im Highchart Format zu hinterlegen + // oder die folgenden Parameter als Array einzustellen: Name, Min, Max, TickInterval, Opposite, Unit + // OUT: Highcharts String für die Achsen + // ------------------------------------------------------------------------ + function CreateArrayForYAxis($cfg) + { + if (!isset($cfg['yAxis'])) + return null; + + $result = array(); + + foreach ($cfg['yAxis'] as $Axis ) + { + // erst mal alles kopieren + $cfgAxis = $Axis; + + if (!isset($cfgAxis['labels']['formatter']) && isset($Axis['Unit'])) + $cfgAxis['labels']['formatter'] ="@function() { return this.value +' ". $Axis['Unit']."'; }@"; + + $result[] = $cfgAxis; + } + + return $result; + } + + // ------------------------------------------------------------------------ + // CreateDateUTC + // Erzeugen des DateTime Strings für Highchart-Config + // IN: $timeStamp = Zeitstempel + // OUT: Highcharts DateTime-Format als UTC String ... Date.UTC(1970, 9, 27, ) + // Achtung! Javascript Monat beginnt bei 0 = Januar + // ------------------------------------------------------------------------ + function CreateDateUTC($timeStamp) + { + $monthForJS = ((int)date("m", $timeStamp))-1 ; // Monat -1 (PHP->JS) + return "Date.UTC(" . date("Y,", $timeStamp) .$monthForJS. date(",j,H,i,s", $timeStamp) .")"; + } + + // ------------------------------------------------------------------------ + // ReplaceToGermanDate + // Falls nicht konfiguriert, wird dies als Default String genommen + // IN: String mit englischen Wochentagen, bzw. Monaten + // OUT: der String übersetzt ins Deutsche + // ------------------------------------------------------------------------ + function ReplaceToGermanDate($value) + { + $trans = array( + 'Monday' => 'Montag', + 'Tuesday' => 'Dienstag', + 'Wednesday' => 'Mittwoch', + 'Thursday' => 'Donnerstag', + 'Friday' => 'Freitag', + 'Saturday' => 'Samstag', + 'Sunday' => 'Sonntag', + 'Mon' => 'Mo', + 'Tue' => 'Di', + 'Wed' => 'Mi', + 'Thu' => 'Do', + 'Fri' => 'Fr', + 'Sat' => 'Sa', + 'Sun' => 'So', + 'January' => 'Januar', + 'February' => 'Februar', + 'March' => 'März', + 'May' => 'Mai', + 'June' => 'Juni', + 'July' => 'Juli', + 'October' => 'Oktober', + 'December' => 'Dezember', + 'Mar' => 'Mär', + 'May' => 'Mai', + 'Oct' => 'Okt', + 'Dec' => 'Dez', + ); + return strtr($value, $trans); + } + + + // ------------------------------------------------------------------------ + // my_json_encode + // + // IN: PHP-Array + // OUT: JSON String + // ------------------------------------------------------------------------ + function my_json_encode($cfgArr) + { + array_walk_recursive($cfgArr, "CheckArrayItems"); + + $s = json_encode($cfgArr); + + // alle " entfernen + $s = str_replace('"', '',$s); + + // Zeilenumbruch, Tabs, etc entfernen ... bin mir nicht so sicher ob das so gut ist + $s = RemoveUnsupportedStrings($s); + + return $s; + } + + // ------------------------------------------------------------------------ + // CheckArrayItems + // + // IN: Array-Item + // OUT: + // ------------------------------------------------------------------------ + function CheckArrayItems(&$item) + { + if (is_string($item)) + { + if ($item == "@" || $item == "@@" ) + { + $item = "'" . $item . "'"; + } + else if ((substr($item,0,1) == "@" && substr($item,-1) == "@")) + { + $item = trim($item, "@"); + } +/* else if ((substr($item,0,1) == "$" && substr($item,-1) == "$")) + { + + $item = trim($item, "$"); + }*/ + else + { + $item = "'" . trim($item, "'") . "'"; + } + $item = utf8_encode($item); + + } + } + + // ------------------------------------------------------------------------ + // RemoveUnsupportedStrings + // Versuchen Sonderzeichen wie Zeilenumbrüche, Tabs, etc. aus dem übergebenen String zu entfernen + // IN: $str + // OUT: $str + // ------------------------------------------------------------------------ + function RemoveUnsupportedStrings($str) + { + + $str = str_replace("\\t","",$str); + $str = str_replace("\\n","",$str); + $str = str_replace("\\r","",$str); + $str = str_ireplace("\\\u00","\\u00",$str); // da muss man nochmals checken + $str = str_replace("\\\\","",$str); + + return $str; + } + + // ------------------------------------------------------------------------ + // IfNotIssetSetValue + // pfüft ob isset($item), wenn nicht wird $value in &$item geschrieben + // IN: &$item, $value + // OUT: &$item + // ------------------------------------------------------------------------ + function IfNotIssetSetValue(&$item, $value ) + { + if (!isset($item) + || (is_string($item) && $item == "")) // zusätzliche Abfrage in 2.01 + { + $item = $value; + return false; + } + + return true; + } + + // ------------------------------------------------------------------------ + // getmicrotime + // + // IN: + // OUT: + // ------------------------------------------------------------------------ + function getmicrotime($short = false) + { + list($usec,$sec)=explode(" ", microtime()); + + if ($short ) + return (float)$usec + (float)substr($sec,-1); + else + return (float)$usec + (float)$sec; + } + + // ------------------------------------------------------------------------ + // DebugString + // + // IN: + // OUT: + // ------------------------------------------------------------------------ + function DebugString($str) + { + $s = RemoveUnsupportedStrings($str); + echo $s; + } + + // ------------------------------------------------------------------------ + // DebugModuleName + // + // IN: + // OUT: + // ------------------------------------------------------------------------ + function DebugModuleName($cfg, $name) + { + if (isset($cfg['Ips']['Debug']['Modules']) && $cfg['Ips']['Debug']['Modules']) + { + global $_IPS, $version, $versionDate; + + IPS_LogMessage($_IPS['SENDER'] ." - " .getmicrotime(true) , "Highcharts $version ($versionDate) - $name"); + } + } +?> \ No newline at end of file diff --git a/IPSLibrary/app/modules/Entertainment/Entertainment.inc.php b/IPSLibrary/app/modules/Entertainment/Entertainment.inc.php index 486174d..650580e 100644 --- a/IPSLibrary/app/modules/Entertainment/Entertainment.inc.php +++ b/IPSLibrary/app/modules/Entertainment/Entertainment.inc.php @@ -18,6 +18,7 @@ */ IPSUtils_Include ("IPSLogger.inc.php", "IPSLibrary::app::core::IPSLogger"); + IPSUtils_Include ('IPSMessageHandler.class.php', 'IPSLibrary::app::core::IPSMessageHandler'); include_once "Entertainment_Constants.inc.php"; IPSUtils_Include ("Entertainment_IDs.inc.php", "IPSLibrary::app::modules::Entertainment"); IPSUtils_Include ("Entertainment_Configuration.inc.php", "IPSLibrary::config::modules::Entertainment"); diff --git a/IPSLibrary/app/modules/Entertainment/Entertainment_Communication.inc.php b/IPSLibrary/app/modules/Entertainment/Entertainment_Communication.inc.php index e0c64a8..79bf579 100644 --- a/IPSLibrary/app/modules/Entertainment/Entertainment_Communication.inc.php +++ b/IPSLibrary/app/modules/Entertainment/Entertainment_Communication.inc.php @@ -20,17 +20,17 @@ function ExtractCommProperties($PropertyData, $CommParams, $ControlData=null) { foreach ($PropertyData as $Idx=>$Property) { $CommParam = $CommParams[$Idx]; - if ($Property==$CommParams[$Idx]) { + if ($Property === $CommParams[$Idx]) { //Ok, Continue - } else if ($Property==c_Template_Value) { + } else if ($Property === c_Template_Value) { $CommProperties[c_Template_Value] = $CommParams[$Idx]; - } else if ($Property==c_Template_Code and + } else if ($Property === c_Template_Code and array_key_exists(c_Property_Codes,$ControlData) and array_key_exists($CommParam, array_flip($ControlData[c_Property_Codes])) ) { $CommProperties[c_Template_Code] = $CommParams[$Idx]; $Codes = array_flip($ControlData[c_Property_Codes]); $CommProperties[c_Template_Value] = $Codes[$CommParams[$Idx]]; - } else if ($Property==c_Template_Code2 and + } else if ($Property === c_Template_Code2 and array_key_exists(c_Property_Codes2,$ControlData) and array_key_exists($CommParam, array_flip($ControlData[c_Property_Codes2])) ) { $CommProperties[c_Template_Code2] = $CommParams[$Idx]; @@ -53,14 +53,14 @@ function get_CommPropertiesSource($CommParams) { foreach ($SourcePropertyData as $DevicePropertyName => $DevicePropertyData) { $CommProperties = ExtractCommProperties($DevicePropertyData, $CommParams); if ($CommProperties !== false) { - $CommProperties[c_Property_Comm] = $DevicePropertyName; + $CommProperties[c_Property_Comm] = $DevicePropertyName; $CommProperties[c_Property_Device] = $SourceConf[$RoomName][$SourceIdx][$SourcePropertyName][c_Property_Device]; $CommProperties[c_Property_Control] = c_Control_Source; $CommProperties[c_Property_Name] = $SourcePropertyName; $CommProperties[c_Property_SourceIdx]= $SourceIdx; $CommProperties[c_Property_Room] = $RoomName; - return $CommProperties; - } + return $CommProperties; + } } } } @@ -94,13 +94,13 @@ function get_CommPropertiesDevice($CommParams) { // --------------------------------------------------------------------------------------------------------------------------- function get_CommProperties($CommParams) { - $CommProperties = get_CommPropertiesDevice($CommParams); - if ($CommProperties !== false) { - return $CommProperties; + $CommProperties = get_CommPropertiesDevice($CommParams); + if ($CommProperties !== false) { + return $CommProperties; } - $CommProperties = get_CommPropertiesSource($CommParams); - if ($CommProperties !== false) { - return $CommProperties; + $CommProperties = get_CommPropertiesSource($CommParams); + if ($CommProperties !== false) { + return $CommProperties; } return false; } @@ -110,139 +110,152 @@ function get_CommProperties($CommParams) { // --------------------------------------------------------------------------------------------------------------------------- function Entertainment_ReceiveData($CommParams, $MessageType=c_MessageType_Action) { if (!Entertainment_Before_ReceiveData($CommParams, $MessageType)) { - return true; + return true; } $CommProperties = get_CommProperties($CommParams); if ($CommProperties !== false) { - $CommType = $CommProperties[c_Property_Comm]; - $DeviceName = $CommProperties[c_Property_Device]; + $CommType = $CommProperties[c_Property_Comm]; + $DeviceName = $CommProperties[c_Property_Device]; IPSLogger_Trc(__File__, 'Received Data "'.implode($CommParams, '.').'" for Device '.$DeviceName); - switch ($CommType) { - case c_Property_CommPower: - case c_Property_CommPower2: - Entertainment_SetDevicePower(get_ControlIdByDeviceName($DeviceName, c_Control_DevicePower), c_Value_Toggle, $MessageType); - break; - case c_Property_CommPowerOn: - case c_Property_CommPowerOn2: - Entertainment_SetDevicePower(get_ControlIdByDeviceName($DeviceName, c_Control_DevicePower), true, $MessageType); - break; - case c_Property_CommPowerOff: - case c_Property_CommPowerOff2: - Entertainment_SetDevicePower(get_ControlIdByDeviceName($DeviceName, c_Control_DevicePower), false, $MessageType); - break; - case c_Property_CommMute: - case c_Property_CommMute2: - Entertainment_SetMuting(get_ControlIdByDeviceName($DeviceName, c_Control_Muting), c_Value_Toggle, $MessageType); - break; - case c_Property_CommMuteOn: - case c_Property_CommMuteOn2: - Entertainment_SetMuting(get_ControlIdByDeviceName($DeviceName, c_Control_Muting), true, $MessageType); - break; - case c_Property_CommMuteOff: - case c_Property_CommMuteOff2: - Entertainment_SetMuting(get_ControlIdByDeviceName($DeviceName, c_Control_Muting), false, $MessageType); - break; - case c_Property_CommVol: - case c_Property_CommVol2: + switch ($CommType) { + case c_Property_CommPower: + case c_Property_CommPower2: + Entertainment_SetDevicePower(get_ControlIdByDeviceName($DeviceName, c_Control_DevicePower), c_Value_Toggle, $MessageType); + break; + case c_Property_CommPowerOn: + case c_Property_CommPowerOn2: + Entertainment_SetDevicePower(get_ControlIdByDeviceName($DeviceName, c_Control_DevicePower), true, $MessageType); + break; + case c_Property_CommPowerOff: + case c_Property_CommPowerOff2: + Entertainment_SetDevicePower(get_ControlIdByDeviceName($DeviceName, c_Control_DevicePower), false, $MessageType); + break; + case c_Property_CommMute: + case c_Property_CommMute2: + Entertainment_SetMuting(get_ControlIdByDeviceName($DeviceName, c_Control_Muting), c_Value_Toggle, $MessageType); + break; + case c_Property_CommMuteOn: + case c_Property_CommMuteOn2: + Entertainment_SetMuting(get_ControlIdByDeviceName($DeviceName, c_Control_Muting), true, $MessageType); + break; + case c_Property_CommMuteOff: + case c_Property_CommMuteOff2: + Entertainment_SetMuting(get_ControlIdByDeviceName($DeviceName, c_Control_Muting), false, $MessageType); + break; + case c_Property_CommVol: + case c_Property_CommVol2: Entertainment_SetVolume(get_ControlIdByDeviceName($DeviceName, c_Control_Volume), (int)$CommProperties[c_Template_Value], $MessageType); - break; - case c_Property_CommBal: - case c_Property_CommBal2: + break; + case c_Property_CommVolPlus: + Entertainment_SetVolumeDiff(get_ControlIdByDeviceName($DeviceName, c_Control_Volume), + 5, $MessageType); + break; + case c_Property_CommVolMinus: + Entertainment_SetVolumeDiff(get_ControlIdByDeviceName($DeviceName, c_Control_Volume), + -5, $MessageType); + break; + case c_Property_CommBal: + case c_Property_CommBal2: Entertainment_SetBalance(get_ControlIdByDeviceName($DeviceName, c_Control_Balance), (int)$CommProperties[c_Template_Value], $MessageType); - break; - case c_Property_CommTre: - case c_Property_CommTre2: + break; + case c_Property_CommTre: + case c_Property_CommTre2: Entertainment_SetTreble(get_ControlIdByDeviceName($DeviceName, c_Control_Treble), (int)$CommProperties[c_Template_Value], $MessageType); - break; - case c_Property_CommMid: - case c_Property_CommMid2: + break; + case c_Property_CommMid: + case c_Property_CommMid2: Entertainment_SetMiddle(get_ControlIdByDeviceName($DeviceName, c_Control_Middle), (int)$CommProperties[c_Template_Value], $MessageType); - break; - case c_Property_CommBas: - case c_Property_CommBas2: + break; + case c_Property_CommBas: + case c_Property_CommBas2: Entertainment_SetBass(get_ControlIdByDeviceName($DeviceName, c_Control_Bass), (int)$CommProperties[c_Template_Value], $MessageType); - break; - case c_Property_CommMode: - case c_Property_CommMode2: - Entertainment_SetMode(get_ControlIdByDeviceName($DeviceName, c_Control_Mode), + break; + case c_Property_CommMode: + case c_Property_CommMode2: + Entertainment_SetMode(get_ControlIdByDeviceName($DeviceName, c_Control_Mode), $CommProperties[c_Template_Value], $MessageType); - break; - case c_Property_CommRemSrc: - $ControlId = get_ControlIdByDeviceName($DeviceName, c_Control_RemoteSourceType); - $Value = $CommProperties[c_Template_Value]; - Entertainment_SetRemoteControlType($ControlId, + break; + case c_Property_CommRemSrc: + $ControlId = get_ControlIdByDeviceName($DeviceName, c_Control_RemoteSourceType); + $Value = $CommProperties[c_Template_Value]; + Entertainment_SetRemoteControlType($ControlId, $Value, c_Control_RemoteSource); - break; - case c_Property_CommRemVol: - Entertainment_SetRemoteControlType(get_ControlIdByDeviceName($DeviceName, c_Control_RemoteVolumeType), + break; + case c_Property_CommRemVol: + Entertainment_SetRemoteControlType(get_ControlIdByDeviceName($DeviceName, c_Control_RemoteVolumeType), $CommProperties[c_Template_Value], c_Control_RemoteVolume); - break; - case c_Property_CommSrc: - case c_Property_CommSrc2: - $SourceIdx = $CommProperties[c_Property_SourceIdx]; - $RoomName = $CommProperties[c_Property_Room]; - IPSLogger_Inf(__file__, "Switch Source for $RoomName to $SourceIdx"); - Entertainment_SetSource(get_ControlIdByRoomId(get_RoomId($RoomName), c_Control_Source), $SourceIdx, $MessageType); - break; - case c_Property_CommPrg: - case c_Property_CommPrg2: - Entertainment_SetProgram(get_ControlIdByDeviceName($DeviceName, c_Control_Program), + break; + case c_Property_CommSrc: + case c_Property_CommSrc2: + $SourceIdx = $CommProperties[c_Property_SourceIdx]; + $RoomName = $CommProperties[c_Property_Room]; + IPSLogger_Inf(__file__, "Switch Source for $RoomName to $SourceIdx"); + Entertainment_SetSource(get_ControlIdByRoomId(get_RoomId($RoomName), c_Control_Source), $SourceIdx, $MessageType); + break; + case c_Property_CommSrcNext: + $RoomName = $CommProperties[c_Property_Room]; + IPSLogger_Inf(__file__, "Switch Next Source for $RoomName"); + Entertainment_SetSourceNext(get_ControlIdByRoomId(get_RoomId($RoomName), c_Control_Source), $MessageType); + break; + case c_Property_CommPrg: + case c_Property_CommPrg2: + Entertainment_SetProgram(get_ControlIdByDeviceName($DeviceName, c_Control_Program), $CommProperties[c_Template_Value], $MessageType); - break; - case c_Property_CommPrgPrev: - case c_Property_CommPrgPrev2: - Entertainment_SetProgramPrev(get_ControlIdByDeviceName($DeviceName, c_Control_Program), $MessageType); - break; - case c_Property_CommPrgNext: - case c_Property_CommPrgNext2: - Entertainment_SetProgramNext(get_ControlIdByDeviceName($DeviceName, c_Control_Program), $MessageType); - break; - default: + break; + case c_Property_CommPrgPrev: + case c_Property_CommPrgPrev2: + Entertainment_SetProgramPrev(get_ControlIdByDeviceName($DeviceName, c_Control_Program), $MessageType); + break; + case c_Property_CommPrgNext: + case c_Property_CommPrgNext2: + Entertainment_SetProgramNext(get_ControlIdByDeviceName($DeviceName, c_Control_Program), $MessageType); + break; + default: IPSLogger_Err(__File__, 'Found unknown CommunicationType "'.$CommType.'"'); - } - Entertainment_After_ReceiveData($CommParams, $MessageType); + } + Entertainment_After_ReceiveData($CommParams, $MessageType); return true; } - Entertainment_After_ReceiveData($CommParams, $MessageType); + Entertainment_After_ReceiveData($CommParams, $MessageType); return false; } // --------------------------------------------------------------------------------------------------------------------------- function Entertainment_SendData($DeviceName, $ControlType, $CommParams, $CommType) { - $CommConfig = get_CommunicationConfiguration(); - $CommInterface = $CommParams[0]; + $CommConfig = get_CommunicationConfiguration(); + $CommInterface = $CommParams[0]; $FunctionName = $CommConfig[$CommInterface][c_Property_FunctionSnd]; $FunctionScript = $CommConfig[$CommInterface][c_Property_ScriptSnd]; $FunctionParameters = array(); - foreach ($CommParams as $CommIdx=>$CommParam) { - if ($CommParam==c_Template_Value) { + foreach ($CommParams as $CommIdx => $CommParam) { + if ($CommParam === c_Template_Value) { $FunctionParameters[] = GetValue(get_ControlIdByDeviceName($DeviceName, $ControlType)); - } else if ($CommParam==c_Template_Code) { + } else if ($CommParam === c_Template_Code) { $DeviceConfig = get_DeviceConfiguration(); $Value = GetValue(get_ControlIdByDeviceName($DeviceName, $ControlType)); $FunctionParameters[] = $DeviceConfig[$DeviceName][$ControlType][c_Property_Codes][$Value]; } else { - $FunctionParameters[] = $CommParam; + $FunctionParameters[] = $CommParam; } } if (!Entertainment_Before_SendData($FunctionParameters)) { - return; + return; } - IPSLogger_Trc(__file__, 'SendData '.$CommInterface.'.'.$FunctionName.'('.implode(',',$FunctionParameters).')'); + IPSLogger_Trc(__file__, 'SendData '.$CommInterface.'.'.$FunctionName.'('.print_r($FunctionParameters, true).')'); try { include_once $FunctionScript; - $Function = new ReflectionFunction($FunctionName); + $Function = new ReflectionFunction($FunctionName); $Function->invoke($FunctionParameters); } catch (Exception $e) { - IPSLogger_Err(__file__, 'Error Executing Function '.$FunctionName.':'.$e->getMessage()); + IPSLogger_Err(__file__, 'Error Executing Function '.$FunctionName.':'.$e->getMessage()); } Entertainment_After_SendData($FunctionParameters); } @@ -268,13 +281,22 @@ function Entertainment_SendDataBySourceIdx($RoomId, $SourceIdx, $MessageType) { return; } $RoomName = IPS_GetName($RoomId); - $DeviceTypes = get_SourceDeviceTypes($RoomId, $SourceIdx); - $SourceConf = get_SourceConfiguration(); - foreach ($DeviceTypes as $DeviceType=>$DeviceName) { - $SourceData = $SourceConf[$RoomName][$SourceIdx][$DeviceType]; - if (array_key_exists(c_Property_CommSrc, $SourceData)) { - Entertainment_SendData($DeviceName, c_Control_Source, $SourceData[c_Property_CommSrc], c_Property_CommSrc); - } + $DeviceTypes = get_SourceDeviceTypes($RoomId, $SourceIdx); + $SourceConf = get_SourceConfiguration(); + foreach ($DeviceTypes as $DeviceType=>$DeviceName) { + $SourcesData = $SourceConf[$RoomName][$SourceIdx][$DeviceType]; + + // wrap older/non array configuration in an array for downward compatibility + if(isset($SourcesData[c_Property_Device])) { + $SourcesData = array($SourcesData); + } + + foreach($SourcesData as $SourceData) { + $DeviceName = $SourceData[c_Property_Device]; + if (array_key_exists(c_Property_CommSrc, $SourceData)) { + Entertainment_SendData($DeviceName, c_Control_Source, $SourceData[c_Property_CommSrc], c_Property_CommSrc); + } + } } } diff --git a/IPSLibrary/app/modules/Entertainment/Entertainment_Constants.inc.php b/IPSLibrary/app/modules/Entertainment/Entertainment_Constants.inc.php index b4adc38..77439c6 100644 --- a/IPSLibrary/app/modules/Entertainment/Entertainment_Constants.inc.php +++ b/IPSLibrary/app/modules/Entertainment/Entertainment_Constants.inc.php @@ -13,17 +13,17 @@ // Control Definition define ("c_Control_RoomPower", "RoomPower"); - define ("c_Control_DevicePower", "DevicePower"); + define ("c_Control_DevicePower", "DevicePower"); define ("c_Control_Muting", "Muting"); define ("c_Control_Source", "Source"); define ("c_Control_Volume", "Volume"); - define ("c_Control_Balance", "Balance"); + define ("c_Control_Balance", "Balance"); define ("c_Control_Treble", "Treble"); define ("c_Control_Middle", "Middle"); - define ("c_Control_Bass", "Bass"); - define ("c_Control_Program", "Program"); - define ("c_Control_Mode", "Mode"); - define ("c_Control_Group", "Group"); + define ("c_Control_Bass", "Bass"); + define ("c_Control_Program", "Program"); + define ("c_Control_Mode", "Mode"); + define ("c_Control_Group", "Group"); define ("c_Control_RemoteVolume", "RemoteVolume"); define ("c_Control_RemoteVolumeType", "RemoteVolumeType"); define ("c_Control_iRemoteVolume", "iRemoteVolume"); @@ -32,20 +32,20 @@ define ("c_Control_iRemoteSource", "iRemoteSource"); // Device Properties - define ("c_Property_Name", "Name"); + define ("c_Property_Name", "Name"); define ("c_Property_Group", "Group"); - define ("c_Property_Icon", "Icon"); + define ("c_Property_Icon", "Icon"); define ("c_Property_Names", "Names"); define ("c_Property_Codes", "Codes"); define ("c_Property_Codes2", "Codes2"); define ("c_Property_MinValue", "MinValue"); define ("c_Property_MaxValue", "MaxValue"); - define ("c_Property_Limit", "Limit"); - define ("c_Property_PowerDelay", "PowerDelay"); - define ("c_Property_Control", "Control"); + define ("c_Property_Limit", "Limit"); + define ("c_Property_PowerDelay", "PowerDelay"); + define ("c_Property_Control", "Control"); define ("c_Property_SourceIdx", "SourceIdx"); define ("c_Property_Device", "Device"); - define ("c_Property_Room", "Room"); + define ("c_Property_Room", "Room"); define ("c_Property_Input", "Input"); define ("c_Property_Output", "Output"); define ("c_Property_Switch", "Switch"); @@ -63,35 +63,38 @@ define ("c_Property_Register", "Register"); define ("c_Property_Variables", "Variables"); define ("c_Property_IPAddress", "IPAddress"); - define ("c_Property_Timeout", "Timeout"); + define ("c_Property_Timeout", "Timeout"); // Communication Properties - define ("c_Property_Comm", "Comm"); - define ("c_Property_CommVol", "CommVol"); + define ("c_Property_Comm", "Comm"); + define ("c_Property_CommVol", "CommVol"); define ("c_Property_CommVol2", "CommVol2"); - define ("c_Property_CommBal", "CommBal"); + define ("c_Property_CommVolPlus", "CommVolPlus"); + define ("c_Property_CommVolMinus", "CommVolMinus"); + define ("c_Property_CommBal", "CommBal"); define ("c_Property_CommBal2", "CommBal2"); - define ("c_Property_CommTre", "CommTre"); + define ("c_Property_CommTre", "CommTre"); define ("c_Property_CommTre2", "CommTre2"); - define ("c_Property_CommMid", "CommMid"); + define ("c_Property_CommMid", "CommMid"); define ("c_Property_CommMid2", "CommMid2"); - define ("c_Property_CommBas", "CommBas"); + define ("c_Property_CommBas", "CommBas"); define ("c_Property_CommBas2", "CommBas2"); - define ("c_Property_CommSrc", "CommSource"); + define ("c_Property_CommSrc", "CommSource"); define ("c_Property_CommSrc2", "CommSource2"); + define ("c_Property_CommSrcNext", "CommSourceNext"); define ("c_Property_CommPower", "CommPower"); - define ("c_Property_CommPower2", "CommPower2"); + define ("c_Property_CommPower2", "CommPower2"); define ("c_Property_CommPowerOn", "CommPowerOn"); define ("c_Property_CommPowerOn2", "CommPowerOn2"); define ("c_Property_CommPowerOff", "CommPowerOff"); define ("c_Property_CommPowerOff2", "CommPowerOff2"); define ("c_Property_CommMute", "CommMute"); define ("c_Property_CommMute2", "CommMute2"); - define ("c_Property_CommMuteOn", "CommMuteOn"); + define ("c_Property_CommMuteOn", "CommMuteOn"); define ("c_Property_CommMuteOn2", "CommMuteOn2"); define ("c_Property_CommMuteOff", "CommMuteOff"); define ("c_Property_CommMuteOff2", "CommMuteOff2"); - define ("c_Property_CommPrg", "CommPrg"); + define ("c_Property_CommPrg", "CommPrg"); define ("c_Property_CommPrg2", "CommPrg2"); define ("c_Property_CommPrgPrev", "CommPrgPrev"); define ("c_Property_CommPrgPrev2", "CommPrgPrev2"); @@ -99,11 +102,11 @@ define ("c_Property_CommPrgNext2", "CommPrgNext2"); define ("c_Property_CommMode", "CommMode"); define ("c_Property_CommMode2", "CommMode2"); - define ("c_Property_CommRemSrc", "CommRemSrc"); - define ("c_Property_CommRemVol", "CommRemVol"); + define ("c_Property_CommRemSrc", "CommRemSrc"); + define ("c_Property_CommRemVol", "CommRemVol"); define ("c_Template_Value", "#Value#"); - define ("c_Template_Code", "#Code#"); + define ("c_Template_Code", "#Code#"); define ("c_Template_Code2", "#Code2#"); define ("c_MessageType_Info", "Info"); diff --git a/IPSLibrary/app/modules/Entertainment/Entertainment_Control.inc.php b/IPSLibrary/app/modules/Entertainment/Entertainment_Control.inc.php index e552b31..9a3ede5 100644 --- a/IPSLibrary/app/modules/Entertainment/Entertainment_Control.inc.php +++ b/IPSLibrary/app/modules/Entertainment/Entertainment_Control.inc.php @@ -165,12 +165,12 @@ function get_ControlType($ControlId) { // --------------------------------------------------------------------------------------------------------------------------- function get_SourceIdxByRoomId($RoomId) { $RoomName = IPS_GetName($RoomId); - $RoomData = get_RoomConfiguration(); + $RoomData = get_RoomConfiguration(); $SourceName = $RoomData[$RoomName][c_Control_Source][c_Property_Name]; - $ChildrenIds = IPS_GetChildrenIDs($RoomId); + $ChildrenIds = IPS_GetChildrenIDs($RoomId); foreach($ChildrenIds as $ChildrenIdx => $ChildrenId) { - if (IPS_GetName($ChildrenId) == $SourceName) { + if (IPS_GetName($ChildrenId) == $SourceName) { return GetValue($ChildrenId); } } @@ -250,8 +250,8 @@ function get_ControlIdByRoomId($RoomId, $ControlType) { // --------------------------------------------------------------------------------------------------------------------------- function get_ActiveRoomIds () { - $RoomIds = IPS_GetChildrenIDs(c_ID_Roomes); - $ActiveRoomIds = array(); + $RoomIds = IPS_GetChildrenIDs(c_ID_Roomes); + $ActiveRoomIds = array(); foreach ($RoomIds as $RoomId) { $PowerId = get_ControlIdByRoomId($RoomId, c_Control_RoomPower); if (GetValue($PowerId)) { @@ -263,8 +263,8 @@ function get_ActiveRoomIds () { // --------------------------------------------------------------------------------------------------------------------------- function get_DeviceNamesByRoomId($RoomId, $SourceIdx=-1, $SourceDeviceTypes=array(c_Property_Input, c_Property_Switch, c_Property_Output)) { - $SourceConf = get_SourceConfiguration(); - if ($SourceIdx==-1) { + $SourceConf = get_SourceConfiguration(); + if ($SourceIdx==-1) { $SourceId = get_ControlIdByRoomId($RoomId, c_Control_Source); $SourceIdx = GetValue($SourceId); } @@ -272,13 +272,32 @@ function get_DeviceNamesByRoomId($RoomId, $SourceIdx=-1, $SourceDeviceTypes=arra $DeviceNames = array(); foreach ($SourceDeviceTypes as $SourceDeviceType) { if (array_key_exists($SourceDeviceType, $SourceConfRoom)) { - $DeviceName = $SourceConfRoom[$SourceDeviceType][c_Property_Device]; - $DeviceNames[$DeviceName] = $DeviceName; + $SourceDevices = $SourceConfRoom[$SourceDeviceType]; + // wrap older/non array configuration in an array for downward compatibility + if(isset($SourceDevices[c_Property_Device])) { + $SourceDevices = array($SourceDevices); + } + + foreach($SourceDevices as $SourceDevice) { + $DeviceName = $SourceDevice[c_Property_Device]; + $DeviceNames[$DeviceName] = $DeviceName; + } } } return $DeviceNames; } - + + // --------------------------------------------------------------------------------------------------------------------------- + function get_SourceDeviceTypeArray($DeviceList) { + $DeviceTypes = array(); + if(isset($DeviceList[c_Property_Device])) { + $DeviceList = array($DeviceList); + } + foreach($DeviceList as $Device) { + array_push($DeviceTypes, $Device[c_Property_Device]); + } + return $DeviceTypes; + } // --------------------------------------------------------------------------------------------------------------------------- function get_SourceDeviceTypes($RoomId, $SourceIdx) { @@ -286,13 +305,13 @@ function get_SourceDeviceTypes($RoomId, $SourceIdx) { $SourceConfRoom = $SourceConf[IPS_GetName($RoomId)][$SourceIdx]; $DeviceTypes = array(); if (array_key_exists(c_Property_Input, $SourceConfRoom)) { - $DeviceTypes[c_Property_Input] = $SourceConfRoom[c_Property_Input][c_Property_Device]; + $DeviceTypes[c_Property_Input] = get_SourceDeviceTypeArray($SourceConfRoom[c_Property_Input]); } if (array_key_exists(c_Property_Switch, $SourceConfRoom)) { - $DeviceTypes[c_Property_Switch] = $SourceConfRoom[c_Property_Switch][c_Property_Device]; + $DeviceTypes[c_Property_Switch] = get_SourceDeviceTypeArray($SourceConfRoom[c_Property_Switch]); } if (array_key_exists(c_Property_Output, $SourceConfRoom)) { - $DeviceTypes[c_Property_Output] = $SourceConfRoom[c_Property_Output][c_Property_Device]; + $DeviceTypes[c_Property_Output] = get_SourceDeviceTypeArray($SourceConfRoom[c_Property_Output]); } return $DeviceTypes; } @@ -325,42 +344,48 @@ function get_RoomId($RoomName) { // Function returns RoomId for Device where Room is active and current Output is equal to specified DeviceName // --------------------------------------------------------------------------------------------------------------------------- function get_RoomIdByOutputDevice($DeviceName) { - $SourceConf = get_SourceConfiguration(); - foreach ($SourceConf as $RoomName=>$RoomSources) { - $RoomId = get_RoomId($RoomName); - $SourceIdx = get_SourceIdxByRoomId($RoomId); - $RoomSource = $RoomSources[$SourceIdx]; + $SourceConf = get_SourceConfiguration(); + foreach ($SourceConf as $RoomName=>$RoomSources) { + $RoomId = get_RoomId($RoomName); + $SourceIdx = get_SourceIdxByRoomId($RoomId); + $RoomSource = $RoomSources[$SourceIdx]; if (array_key_exists(c_Property_Output, $RoomSource)) { - $OutputName= $RoomSource[c_Property_Output][c_Property_Device]; - if ($OutputName==$DeviceName) { - return $RoomId; + $OutputDevices = $RoomSource[c_Property_Output]; + // wrap older/non array configuration in an array for downward compatibility + if(isset($OutputDevices[c_Property_Device])) { + $OutputDevices = array($OutputDevices); + } + + $OutputName = $OutputDevices[0][c_Property_Device]; + if ($OutputName == $DeviceName) { + return $RoomId; } } - } - return false; + } + return false; } // --------------------------------------------------------------------------------------------------------------------------- function get_SourceListByDeviceName($DeviceName) { - $SourceConfig = get_SourceConfiguration(); - $SourceList = array(); - foreach ($SourceConfig as $RoomName=>$RoomSources) { - $RoomId = get_RoomId($RoomName); - $CurrentIdx = get_SourceIdxByRoomId($RoomId); - foreach ($RoomSources as $SourceIdx=>$SourceData) { - $DeviceNames = get_DeviceNamesByRoomId($RoomId, $SourceIdx, array(c_Property_Output)); + $SourceConfig = get_SourceConfiguration(); + $SourceList = array(); + foreach ($SourceConfig as $RoomName=>$RoomSources) { + $RoomId = get_RoomId($RoomName); + $CurrentIdx = get_SourceIdxByRoomId($RoomId); + foreach ($RoomSources as $SourceIdx=>$SourceData) { + $DeviceNames = get_DeviceNamesByRoomId($RoomId, $SourceIdx, array(c_Property_Output)); if (in_array($DeviceName, $DeviceNames)) { - if (!array_key_exists($RoomId, $SourceList)) { - $SourceList[$RoomId] = $SourceIdx; - } + if (!array_key_exists($RoomId, $SourceList)) { + $SourceList[$RoomId] = $SourceIdx; + } if ($CurrentIdx==$SourceIdx) { - $SourceList[$RoomId] = $SourceIdx; - break; + $SourceList[$RoomId] = $SourceIdx; + break; } } - } - } - return $SourceList; + } + } + return $SourceList; } /** @}*/ diff --git a/IPSLibrary/app/modules/Entertainment/Entertainment_Device.inc.php b/IPSLibrary/app/modules/Entertainment/Entertainment_Device.inc.php index f619bc5..18ddec0 100644 --- a/IPSLibrary/app/modules/Entertainment/Entertainment_Device.inc.php +++ b/IPSLibrary/app/modules/Entertainment/Entertainment_Device.inc.php @@ -17,6 +17,9 @@ function get_MaxValueByControlId($ControlId) { $ProfileName = $VariableObject['VariableCustomProfile']; $ProfileObject = IPS_GetVariableProfile($ProfileName); $MaxValue = Count($ProfileObject['Associations']); + if ($MaxValue==0) { + $MaxValue = $ProfileObject['MaxValue']; + } return $MaxValue; } @@ -72,6 +75,20 @@ function Entertainment_SetMode($Id, $Value, $MessageType=c_MessageType_Action) { } } + // --------------------------------------------------------------------------------------------------------------------------- + function Entertainment_SetVolumeDiff($Id, $Diff, $MessageType=c_MessageType_Action) { + $MaxValue = get_MaxValueByControlId($Id); + IPSLogger_Inf(__file__, 'Max='.$MaxValue); + $Value = GetValue($Id) + $Diff; + if ($Value > $MaxValue) { + $Value = $MaxValue; + } + if ($Value < 0) { + $Value = 0; + } + Entertainment_SetVolume($Id, $Value, $MessageType); + } + // --------------------------------------------------------------------------------------------------------------------------- function Entertainment_SetVolume($Id, $Value, $MessageType=c_MessageType_Action) { $DeviceName = IPS_GetName(IPS_GetParent($Id)); diff --git a/IPSLibrary/app/modules/Entertainment/Entertainment_Interface.ips.php b/IPSLibrary/app/modules/Entertainment/Entertainment_Interface.ips.php index e52dbbe..611be55 100644 --- a/IPSLibrary/app/modules/Entertainment/Entertainment_Interface.ips.php +++ b/IPSLibrary/app/modules/Entertainment/Entertainment_Interface.ips.php @@ -22,20 +22,20 @@ // --------------------------------------------------------------------------------------------------------------------------- // WebFront // --------------------------------------------------------------------------------------------------------------------------- - if ($IPS_SENDER == "WebFront") { - $ControlType = get_ControlType($IPS_VARIABLE); + if ($_IPS['SENDER'] == "WebFront") { + $ControlType = get_ControlType($_IPS['VARIABLE']); switch ($ControlType) { case c_Control_RoomPower: - Entertainment_SetRoomPower($IPS_VARIABLE, $IPS_VALUE); + Entertainment_SetRoomPower($_IPS['VARIABLE'], $_IPS['VALUE']); break; case c_Control_DevicePower: - Entertainment_SetDevicePower($IPS_VARIABLE, $IPS_VALUE); + Entertainment_SetDevicePower($_IPS['VARIABLE'], $_IPS['VALUE']); break; case c_Control_Source: - Entertainment_SetSource($IPS_VARIABLE, $IPS_VALUE); + Entertainment_SetSource($_IPS['VARIABLE'], $_IPS['VALUE']); break; case c_Control_Group: - Entertainment_SetGroupControlVisibility($IPS_VARIABLE, $IPS_VALUE); + Entertainment_SetGroupControlVisibility($_IPS['VARIABLE'], $_IPS['VALUE']); break; case c_Control_Muting: case c_Control_Volume: @@ -45,10 +45,10 @@ case c_Control_Bass: case c_Control_Mode: case c_Control_Program: - Entertainment_SetControl($IPS_VARIABLE, $IPS_VALUE); + Entertainment_SetControl($_IPS['VARIABLE'], $_IPS['VALUE']); break; default: - IPSLogger_Err(__file__, 'Unknown Control with ID='.$IPS_VARIABLE.' !'); + IPSLogger_Err(__file__, 'Unknown Control with ID='.$_IPS['VARIABLE'].' !'); } } diff --git a/IPSLibrary/app/modules/Entertainment/Entertainment_InterfaceIPSComponentAVControl.inc.php b/IPSLibrary/app/modules/Entertainment/Entertainment_InterfaceIPSComponentAVControl.inc.php index b9413cf..3059baa 100644 --- a/IPSLibrary/app/modules/Entertainment/Entertainment_InterfaceIPSComponentAVControl.inc.php +++ b/IPSLibrary/app/modules/Entertainment/Entertainment_InterfaceIPSComponentAVControl.inc.php @@ -3,7 +3,7 @@ * @ingroup entertainment * @{ * - * @file Entertainment_InterfaceIPSComponent.inc.php + * @file Entertainment_InterfaceIPSComponentAVControl.inc.php * @author Andreas Brauneis * @version * Version 2.50.1, 31.01.2012
@@ -16,18 +16,17 @@ IPSUtils_Include ('IPSComponent.class.php', 'IPSLibrary::app::core::IPSComponent'); - // --------------------------------------------------------------------------------------------------------------------------- - function Entertainment_AutoConfigureMessageHandler() { - } - // --------------------------------------------------------------------------------------------------------------------------- function Entertainment_IPSComponent_ReceiveData($componentParams, $function, $output, $value) { $interfaceList = get_CommunicationConfiguration(); $interface = ''; foreach ($interfaceList as $interfaceName=>$interfaceData) { - if ($interfaceData[c_Property_ComponentParams]==$componentParams) { - $interface = $interfaceName; + if (array_key_exists(c_Property_ComponentParams, $interfaceData)) { + if ($interfaceData[c_Property_ComponentParams]==$componentParams or + $interfaceData[c_Property_ComponentParams]=='IPSComponentAVControl_AudioMax,null') { + $interface = $interfaceName; + } } } Entertainment_ReceiveData(array($interface, $function, $output, $value), c_MessageType_Info); diff --git a/IPSLibrary/app/modules/Entertainment/Entertainment_InterfaceNetPlayerRcv.ips.php b/IPSLibrary/app/modules/Entertainment/Entertainment_InterfaceNetPlayerRcv.ips.php index 0f1b0c1..3fc08c4 100644 --- a/IPSLibrary/app/modules/Entertainment/Entertainment_InterfaceNetPlayerRcv.ips.php +++ b/IPSLibrary/app/modules/Entertainment/Entertainment_InterfaceNetPlayerRcv.ips.php @@ -22,11 +22,11 @@ IPS_SemaphoreEnter('NetPlayer', 1000); - if($IPS_SENDER == "Variable") { - $variableName = IPS_GetName($IPS_VARIABLE); + if($_IPS['SENDER'] == "Variable") { + $variableName = IPS_GetName($_IPS['VARIABLE']); switch ($variableName) { case 'Power': - if ($IPS_VALUE) { + if ($_IPS['VALUE']) { Entertainment_ReceiveData(array(c_Comm_NetPlayer, 'netplayer', 'poweron'), c_MessageType_Info); } else { Entertainment_ReceiveData(array(c_Comm_NetPlayer, 'netplayer', 'poweroff'), c_MessageType_Info); @@ -45,8 +45,8 @@ //Entertainment_RefreshRemoteControlByDeviceName(c_Device_NetPlayer, c_Control_iRemoteSource); break; case 'ControlType': - //IPSLogger_Com(__file__, "Receive RemoteControlType $IPS_VALUE for NetPlayer"); - //Entertainment_ReceiveData(array(c_Comm_NetPlayer, 'netplayertype', (string)$IPS_VALUE), c_MessageType_Info); + //IPSLogger_Com(__file__, "Receive RemoteControlType $_IPS['VALUE'] for NetPlayer"); + //Entertainment_ReceiveData(array(c_Comm_NetPlayer, 'netplayertype', (string)$_IPS['VALUE']), c_MessageType_Info); break; default: IPSLogger_Err(__file__, "Unknown Variable $variableName"); diff --git a/IPSLibrary/app/modules/Entertainment/Entertainment_InterfaceOnkyoRcv.ips.php b/IPSLibrary/app/modules/Entertainment/Entertainment_InterfaceOnkyoRcv.ips.php index f0ca527..bdc9f02 100644 --- a/IPSLibrary/app/modules/Entertainment/Entertainment_InterfaceOnkyoRcv.ips.php +++ b/IPSLibrary/app/modules/Entertainment/Entertainment_InterfaceOnkyoRcv.ips.php @@ -15,8 +15,8 @@ include_once "Entertainment.inc.php"; - if($IPS_SENDER == "RegisterVariable") { - Onkyo_ReceiveData_Register($IPS_INSTANCE, $IPS_VALUE); + if($_IPS['SENDER'] == "RegisterVariable") { + Onkyo_ReceiveData_Register($_IPS['INSTANCE'], $_IPS['VALUE']); } diff --git a/IPSLibrary/app/modules/Entertainment/Entertainment_Power.inc.php b/IPSLibrary/app/modules/Entertainment/Entertainment_Power.inc.php index b22991e..a83e2eb 100644 --- a/IPSLibrary/app/modules/Entertainment/Entertainment_Power.inc.php +++ b/IPSLibrary/app/modules/Entertainment/Entertainment_Power.inc.php @@ -39,8 +39,8 @@ function Entertainment_PowerOffUnusedDevices() { // --------------------------------------------------------------------------------------------------------------------------- function Entertainment_SetDevicePower($PowerId, $Value, $MessageType=c_MessageType_Action) { - $DeviceName = IPS_GetName(IPS_GetParent($PowerId)); - Entertainment_SetDevicePowerByDeviceName($DeviceName, $Value, $MessageType); + $DeviceName = IPS_GetName(IPS_GetParent($PowerId)); + Entertainment_SetDevicePowerByDeviceName($DeviceName, $Value, $MessageType); } // --------------------------------------------------------------------------------------------------------------------------- @@ -48,10 +48,10 @@ function Entertainment_SetDevicePowerByDeviceName($DeviceName, $Value, $MessageT IPSLogger_Trc(__file__, 'Handle Device Power for "'.$DeviceName.'" '.bool2OnOff($Value)); $PowerId = get_ControlIdByDeviceName($DeviceName, c_Control_DevicePower, false); if ($PowerId!==false) { - if (!is_bool($Value)) { /*Toggle Power Value*/ - $Value = !GetValue($PowerId); + if (!is_bool($Value)) { /*Toggle Power Value*/ + $Value = !GetValue($PowerId); IPSLogger_Dbg(__file__, "Toogle Device Power for '$DeviceName' to ".bool2OnOff($Value)); - } + } if (GetValue($PowerId) <> $Value) { IPSLogger_Inf(__file__, 'Set Device Power for "'.$DeviceName.'" '.bool2OnOff($Value)); if ($Value) { @@ -64,7 +64,7 @@ function Entertainment_SetDevicePowerByDeviceName($DeviceName, $Value, $MessageT SetValue($PowerId, $Value); Entertainment_Connect($DeviceName, $Value, true); Entertainment_SetDeviceControlByDeviceName($DeviceName, c_Control_Muting, false); - Entertainment_SetRoomPowerByDeviceName($DeviceName, $Value); + Entertainment_SetRoomPowerByDeviceName($DeviceName, $Value); } } } @@ -74,8 +74,26 @@ function Entertainment_SetDevicePowerByRoomId($RoomId, $Value=true) { if ($Value) { $RoomName = IPS_GetName($RoomId); $DeviceNames = get_DeviceNamesByRoomId($RoomId); + $DeviceData = get_DeviceConfiguration(); + $first = true; foreach ($DeviceNames as $DeviceName) { - Entertainment_SetDevicePowerByDeviceName($DeviceName, true); + if(isset($DeviceData[$DeviceName][c_Control_DevicePower])) { + $devicePower = $DeviceData[$DeviceName][c_Control_DevicePower]; + if(isset($devicePower[c_Property_PowerDelay])) { + $delaySeconds = $devicePower[c_Property_PowerDelay]; + if(!is_numeric($delaySeconds) || $delaySeconds < 0 || $delaySeconds > 5000) { + IPSLogger_Wrn(__file__, "'c_Property_PowerDelay' for control 'c_Control_DevicePower' for device $DeviceName is not a number ($delaySeconds). Please use a value between 0 and 5000. Using default: 1000 (= 1 second)"); + $delaySeconds = 1000; + } + // no delay for first device + if($first) { + $first = false; + } else { + usleep($delaySeconds * 1000); + } + } + } + Entertainment_SetDevicePowerByDeviceName($DeviceName, true); } } else { Entertainment_PowerOffUnusedDevices(); diff --git a/IPSLibrary/app/modules/Entertainment/Entertainment_Room.inc.php b/IPSLibrary/app/modules/Entertainment/Entertainment_Room.inc.php index 8593d20..899b842 100644 --- a/IPSLibrary/app/modules/Entertainment/Entertainment_Room.inc.php +++ b/IPSLibrary/app/modules/Entertainment/Entertainment_Room.inc.php @@ -38,15 +38,16 @@ function Entertainment_SetRoomVisible($PowerId, $Value) { // --------------------------------------------------------------------------------------------------------------------------- function Entertainment_SetRoomPower($PowerId, $Value, $PowerOnDevices=true) { - if (GetValue($PowerId) <> $Value) { - IPSLogger_Inf(__file__, 'Set Power for Room "'.IPS_GetName(IPS_GetParent($PowerId)).'" '.bool2OnOff($Value)); + if (GetValue($PowerId) <> $Value) { + IPSLogger_Inf(__file__, 'Set Power for Room "'.IPS_GetName(IPS_GetParent($PowerId)).'" '.bool2OnOff($Value)); SetValue($PowerId, $Value); - Entertainment_SetRoomVisible($PowerId, $Value); + IPSMessageHandler_HandleLibraryEvent($PowerId, $Value, 'Entertainment', 'Power'); + Entertainment_SetRoomVisible($PowerId, $Value); if ($PowerOnDevices) { - Entertainment_SetDevicePowerByRoomId(IPS_GetParent($PowerId), $Value); + Entertainment_SetDevicePowerByRoomId(IPS_GetParent($PowerId), $Value); } - Entertainment_SyncRoomControls(IPS_GetParent($PowerId)); - } + Entertainment_SyncRoomControls(IPS_GetParent($PowerId)); + } } // --------------------------------------------------------------------------------------------------------------------------- @@ -80,12 +81,12 @@ function Entertainment_PowerOffUnusedRoomes() { // --------------------------------------------------------------------------------------------------------------------------- function Entertainment_SetRoomPowerByDeviceName($DeviceName, $Value) { if ($Value) { - $SourceList = get_SourceListByDeviceName($DeviceName, $Value); + $SourceList = get_SourceListByDeviceName($DeviceName); if (count($SourceList)==1) { $RoomKeys = array_keys($SourceList); $RoomId = $RoomKeys[0]; - $SourceIdx = $SourceList[$RoomId]; if (!IsRoomPoweredOn($RoomId)) { + $SourceIdx = $SourceList[$RoomId]; Entertainment_SetRoomPowerByRoomId($RoomId, true, false); Entertainment_SetSourceByRoomId($RoomId, $SourceIdx); } diff --git a/IPSLibrary/app/modules/Entertainment/Entertainment_Source.inc.php b/IPSLibrary/app/modules/Entertainment/Entertainment_Source.inc.php index 02abe31..9dc866c 100644 --- a/IPSLibrary/app/modules/Entertainment/Entertainment_Source.inc.php +++ b/IPSLibrary/app/modules/Entertainment/Entertainment_Source.inc.php @@ -15,33 +15,32 @@ // Show/Hide Group // --------------------------------------------------------------------------------------------------------------------------- function Entertainment_SetGroupControlVisibility($GroupSwitchId, $Value) { - $RoomConfig = get_RoomConfiguration(); - $RoomName = IPS_GetName(IPS_GetParent($GroupSwitchId)); - $ControlName = IPS_GetName($GroupSwitchId); - $WFRoomName = $RoomConfig[$RoomName][c_Property_Name]; - $WFRoomId = IPS_GetCategoryIDByName($WFRoomName, c_ID_WebFrontRoomes); - $WFGroupId = IPS_GetInstanceIDByName($ControlName, $WFRoomId); + $RoomConfig = get_RoomConfiguration(); + $RoomName = IPS_GetName(IPS_GetParent($GroupSwitchId)); + $ControlName = IPS_GetName($GroupSwitchId); + $WFRoomName = $RoomConfig[$RoomName][c_Property_Name]; + $WFRoomId = IPS_GetCategoryIDByName($WFRoomName, c_ID_WebFrontRoomes); + $WFGroupId = IPS_GetInstanceIDByName($ControlName, $WFRoomId); IPS_SetHidden($WFGroupId, !$Value); - SetValue($GroupSwitchId, $Value); + SetValue($GroupSwitchId, $Value); } - // --------------------------------------------------------------------------------------------------------------------------- function Entertainment_SetRoomControlVisibility($RoomControlId, $Value) { - $RoomName = IPS_GetName(IPS_GetParent($RoomControlId)); - $RoomConfig = get_RoomConfiguration(); - $ControlName = IPS_GetName($RoomControlId); - $WFRoomName = $RoomConfig[$RoomName][c_Property_Name]; - if ($WFRoomName=="") return; - $WFRoomId = IPS_GetCategoryIDByName($WFRoomName, c_ID_WebFrontRoomes); + $RoomName = IPS_GetName(IPS_GetParent($RoomControlId)); + $RoomConfig = get_RoomConfiguration(); + $ControlName = IPS_GetName($RoomControlId); + $WFRoomName = $RoomConfig[$RoomName][c_Property_Name]; + if ($WFRoomName=="") return; + $WFRoomId = IPS_GetCategoryIDByName($WFRoomName, c_ID_WebFrontRoomes); - $WFControlId = false; + $WFControlId = false; $ChildrenIds = IPS_GetChildrenIDs($WFRoomId); foreach($ChildrenIds as $ChildrenIdx => $ChildrenId) { - if (IPS_LinkExists($ChildrenId)) { - if (IPS_GetName($ChildrenId)==$ControlName) { - $WFControlId = $ChildrenId; - } + if (IPS_LinkExists($ChildrenId)) { + if (IPS_GetName($ChildrenId)==$ControlName) { + $WFControlId = $ChildrenId; + } } else { $WFControlId = @IPS_GetLinkIDByName($ControlName, $WFRoomId); } @@ -53,7 +52,6 @@ function Entertainment_SetRoomControlVisibility($RoomControlId, $Value) { IPS_SetHidden($WFControlId, !$Value); } } - } @@ -69,9 +67,9 @@ function Entertainment_SyncAllRoomControls() { function Entertainment_SyncRoomControls($RoomId) { $RoomName = IPS_GetName($RoomId); $RoomPower = GetValue(get_ControlIdByRoomId($RoomId, c_Control_RoomPower)); - $RoomConfig = get_RoomConfiguration(); - $ControlTypes = $RoomConfig[$RoomName]; - foreach ($ControlTypes as $ControlType=>$ControlData) { + $RoomConfig = get_RoomConfiguration(); + $ControlTypes = $RoomConfig[$RoomName]; + foreach ($ControlTypes as $ControlType=>$ControlData) { if ($ControlType==c_Control_Muting or $ControlType==c_Control_Volume or $ControlType==c_Control_Balance or @@ -79,13 +77,13 @@ function Entertainment_SyncRoomControls($RoomId) { $ControlType==c_Control_Middle or $ControlType==c_Control_Bass or $ControlType==c_Control_Program or - $ControlType==c_Control_RemoteVolume or - $ControlType==c_Control_iRemoteVolume or - $ControlType==c_Control_RemoteSource or - $ControlType==c_Control_iRemoteSource or - $ControlType==c_Control_Mode) { - $RoomControlId = get_ControlIdByRoomId($RoomId, $ControlType); - $DeviceControlId = get_DeviceControlIdByRoomControlId($RoomControlId); + $ControlType==c_Control_RemoteVolume or + $ControlType==c_Control_iRemoteVolume or + $ControlType==c_Control_RemoteSource or + $ControlType==c_Control_iRemoteSource or + $ControlType==c_Control_Mode) { + $RoomControlId = get_ControlIdByRoomId($RoomId, $ControlType); + $DeviceControlId = get_DeviceControlIdByRoomControlId($RoomControlId); if ($DeviceControlId===false and $ControlType==c_Control_iRemoteVolume) { $DeviceControlId = get_DeviceControlIdByRoomControlId($RoomControlId, c_Control_RemoteVolume); @@ -103,30 +101,42 @@ function Entertainment_SyncRoomControls($RoomId) { Entertainment_SetRoomControlVisibility($RoomControlId, false); } } - } + } } + // --------------------------------------------------------------------------------------------------------------------------- + function Entertainment_SetSourceNext($SourceId, $MessageType=c_MessageType_Action) { + $MaxValue = get_MaxValueByControlId($SourceId); + $Value = GetValue($SourceId) + 1; + if ($Value >= $MaxValue) { + $Value = 0; + } + Entertainment_SetSource($SourceId, $Value, $MessageType); + } + // --------------------------------------------------------------------------------------------------------------------------- function Entertainment_SetSource($SourceId, $Value, $MessageType=c_MessageType_Action) { - if (GetValue($SourceId) <> $Value) { - $RoomId = IPS_GetParent($SourceId); - $SourceName = get_SourceName($RoomId, $Value); - IPSLogger_Inf(__file__, 'Set Source "'.$SourceName.'" of Room '.IPS_GetName($RoomId)); + $RoomId = IPS_GetParent($SourceId); + $IsRoomPoweredOn = IsRoomPoweredOn($RoomId); + if (GetValue($SourceId) <> $Value || !$IsRoomPoweredOn) { + $RoomId = IPS_GetParent($SourceId); + $SourceName = get_SourceName($RoomId, $Value); + IPSLogger_Inf(__file__, 'Set Source "'.$SourceName.'" of Room '.IPS_GetName($RoomId)); SetValue($SourceId, $Value); - if (!IsRoomPoweredOn($RoomId)) { + if (!$IsRoomPoweredOn) { Entertainment_SetRoomPowerByRoomId($RoomId, true, false); } Entertainment_SetDeviceControlByRoomId($RoomId, c_Control_Muting, false); - Entertainment_SetDevicePowerByRoomId($RoomId, true); - Entertainment_SendDataBySourceIdx($RoomId, $Value, $MessageType); - Entertainment_SyncRoomControls($RoomId); + Entertainment_SetDevicePowerByRoomId($RoomId, true); + Entertainment_SendDataBySourceIdx($RoomId, $Value, $MessageType); + Entertainment_SyncRoomControls($RoomId); Entertainment_PowerOffUnusedDevices(); } } // --------------------------------------------------------------------------------------------------------------------------- function Entertainment_SetSourceByRoomId($RoomId, $SourceIdx) { - $SourceId = get_ControlIdByRoomId($RoomId, c_Control_Source); + $SourceId = get_ControlIdByRoomId($RoomId, c_Control_Source); Entertainment_SetSource($SourceId, $SourceIdx); } diff --git a/IPSLibrary/app/modules/IPSCam/IPSCam.inc.php b/IPSLibrary/app/modules/IPSCam/IPSCam.inc.php new file mode 100644 index 0000000..4bc55d3 --- /dev/null +++ b/IPSLibrary/app/modules/IPSCam/IPSCam.inc.php @@ -0,0 +1,93 @@ + + * + * IPSCam API + * + */ + + IPSUtils_Include ("IPSLogger.inc.php", "IPSLibrary::app::core::IPSLogger"); + IPSUtils_Include ("IPSComponent.class.php", "IPSLibrary::app::core::IPSComponent"); + IPSUtils_Include ("IPSModule.class.php", "IPSLibrary::app::core::IPSComponent"); + IPSUtils_Include ("IPSCam_Constants.inc.php", "IPSLibrary::app::modules::IPSCam"); + IPSUtils_Include ("IPSCam_Configuration.inc.php", "IPSLibrary::config::modules::IPSCam"); + IPSUtils_Include ("IPSCam_Custom.inc.php", "IPSLibrary::config::modules::IPSCam"); + IPSUtils_Include ("IPSCam_Manager.class.php", "IPSLibrary::app::modules::IPSCam"); + + /** + * Selektiert die spezifizierte Kamera und schaltet auf den gewünschten Mode um + * + * @param int $cameraIdx Index der Kamera + * @param int $mode Kamera Modus + */ + function IPSCam_ActivateCam($cameraIdx, $mode) { + $camManager = new IPSCam_Manager(); + $camManager->ActivateCamera($cameraIdx, $mode); + } + + /** + * Liefert den Camera Index (Position im Konfigurations Array) einer bestimmten Kamera + * Dieser Index wird zur Ansteuerung der meisten IPSCam Funktionen benötigt. + * + * @param string $name Name der Kamera + * @return int Index der Kamera + */ + function IPSCam_IPSCam_GetCamIdxByName($name) { + $config = IPSCam_GetConfiguration(); + foreach ($config as $idx=>$data) { + if ($data[IPSCAM_PROPERTY_NAME]==$name) { + return $idx; + } + } + trigger_error('Camera with Name "'.$name.'" could NOT be found in Configuration Array!!!'); + } + + /** + * Aktualisiert das entsprechende Kamera Bild, wenn der Kamera Index nicht gesetzt wird, + * wird das aktuell gewählte Kamera Bild aktualisiert + * + * @param int $cameraIdx Index der Kamera + */ + function IPSCam_RefreshPicture($cameraIdx=null) { + $camManager = new IPSCam_Manager(); + $camManager->PictureRefresh($cameraIdx); + } + + /** + * Speichert ein Bild der entsprechende Kamera , wenn der Kamera Index nicht gesetzt wird, + * wird das aktuell gewählte Kamera Bild gespeichert + * + * @param int $cameraIdx Index der Kamera + * @return string Name des gespeicherten Bildes bzw. false wenn die Kamera nicht in Betrieb ist. + */ + function IPSCam_StorePicture($cameraIdx=null) { + $camManager = new IPSCam_Manager(); + return $camManager->PictureStore($cameraIdx); + } + + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/modules/IPSCam/IPSCam_ActionScript.ips.php b/IPSLibrary/app/modules/IPSCam/IPSCam_ActionScript.ips.php new file mode 100644 index 0000000..386dc26 --- /dev/null +++ b/IPSLibrary/app/modules/IPSCam/IPSCam_ActionScript.ips.php @@ -0,0 +1,52 @@ + + * + * IPSCam ActionScript + * + */ + + include_once "IPSCam.inc.php"; + + // ---------------------------------------------------------------------------------------------------------------------------- + if ($_IPS['SENDER']=='WebFront') { + $variableId = $_IPS['VARIABLE']; + $value = $_IPS['VALUE']; + + $camManager = new IPSCam_Manager(); + $camManager->ChangeSetting($variableId, $value); + + } elseif ($_IPS['SENDER']=='TimerEvent') { + $eventId = $_IPS['EVENT']; + + $camManager = new IPSCam_Manager(); + $camManager->ActivateTimer($eventId); + + // ---------------------------------------------------------------------------------------------------------------------------- + } else { + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/modules/IPSCam/IPSCam_Constants.inc.php b/IPSLibrary/app/modules/IPSCam/IPSCam_Constants.inc.php new file mode 100644 index 0000000..a81dd47 --- /dev/null +++ b/IPSLibrary/app/modules/IPSCam/IPSCam_Constants.inc.php @@ -0,0 +1,120 @@ + + * + * Definition der Konstanten für IPSCam + * + */ + + // Confguration Property Definition + define ('IPSCAM_PROPERTY_NAME', 'Name'); + define ('IPSCAM_PROPERTY_TYPE', 'Type'); + define ('IPSCAM_PROPERTY_COMPONENT', 'Component'); + define ('IPSCAM_PROPERTY_SWITCHPOWER', 'SwitchPower'); + define ('IPSCAM_PROPERTY_SWITCHWLAN', 'SwitchWLAN'); + define ('IPSCAM_PROPERTY_PREDEFPOS1', 'PredefinedPosition1'); + define ('IPSCAM_PROPERTY_PREDEFPOS2', 'PredefinedPosition2'); + define ('IPSCAM_PROPERTY_PREDEFPOS3', 'PredefinedPosition3'); + define ('IPSCAM_PROPERTY_PREDEFPOS4', 'PredefinedPosition4'); + define ('IPSCAM_PROPERTY_COMMAND1', 'Command1'); + define ('IPSCAM_PROPERTY_COMMAND2', 'Command2'); + define ('IPSCAM_PROPERTY_COMMAND3', 'Command3'); + define ('IPSCAM_PROPERTY_COMMAND4', 'Command4'); + define ('IPSCAM_PROPERTY_ACTION1', 'Action1'); + define ('IPSCAM_PROPERTY_ACTION2', 'Action2'); + define ('IPSCAM_PROPERTY_ACTION3', 'Action3'); + define ('IPSCAM_PROPERTY_ACTION4', 'Action4'); + + define ('IPSCAM_TYPE_FIXEDCAM', 'FixedCam'); + define ('IPSCAM_TYPE_MOVABLECAM', 'MovableCam'); + + define ('IPSCAM_MODE_LIVE', 0); + define ('IPSCAM_MODE_PICTURE', 1); + define ('IPSCAM_MODE_HISTORY', 2); + define ('IPSCAM_MODE_SETTINGS', 3); + + define ('IPSCAM_URL_LIVE', 0); + define ('IPSCAM_URL_PICTURE', 1); + define ('IPSCAM_URL_DISPLAY', 2); + define ('IPSCAM_URL_MOVEUP', 100); + define ('IPSCAM_URL_MOVEDOWN', 101); + define ('IPSCAM_URL_MOVELEFT', 102); + define ('IPSCAM_URL_MOVERIGHT', 103); + define ('IPSCAM_URL_MOVEHOME', 104); + define ('IPSCAM_URL_PREDEFPOS1', 110); + define ('IPSCAM_URL_PREDEFPOS2', 111); + define ('IPSCAM_URL_PREDEFPOS3', 112); + define ('IPSCAM_URL_PREDEFPOS4', 113); + define ('IPSCAM_URL_PREDEFPOS5', 114); + + define ('IPSCAM_VAL_DISABLED', 100000); + + define ('IPSCAM_SIZE_SMALL', 0); + define ('IPSCAM_SIZE_MIDDLE', 1); + define ('IPSCAM_SIZE_LARGE', 2); + + define ('IPSCAM_NAV_BACK', 0); + define ('IPSCAM_NAV_FORWARD', 1); + + define ('IPSCAM_NAV_DATEFORMATFILE', 'Ymd_His'); + define ('IPSCAM_NAV_DATEFORMATDISP', 'Y-m-d H:i'); + + define ('IPSCAM_DAY_BACK', 0); + define ('IPSCAM_DAY_FORWARD', 1); + + // Common Variables + define ('IPSCAM_VAR_CAMSELECT', 'CamSelect'); + define ('IPSCAM_VAR_MODE', 'Mode'); + define ('IPSCAM_VAR_MODELIVE', 'ModeLive'); + define ('IPSCAM_VAR_MODEPICT', 'ModePicture'); + define ('IPSCAM_VAR_MODEHIST', 'ModeHistory'); + define ('IPSCAM_VAR_MODESETT', 'ModeSettings'); + define ('IPSCAM_VAR_NAVPICT', 'NavigatePict'); + define ('IPSCAM_VAR_NAVDAYS', 'NavigateDays'); + define ('IPSCAM_VAR_HTML', 'Html'); + define ('IPSCAM_VAR_IHTML', 'iHtml'); + + // Camera specific Variables + define ('IPSCAM_VAR_CAMPOWER', 'CamPower'); + define ('IPSCAM_VAR_CAMHTML', 'CamHtml'); + define ('IPSCAM_VAR_CAMPICT', 'CamPict'); + define ('IPSCAM_VAR_CAMHIST', 'CamHist'); + define ('IPSCAM_VAR_CAMSTREAM', 'CamStream'); + define ('IPSCAM_VAR_NAVTIME', 'NavigateTime'); + define ('IPSCAM_VAR_NAVFILE', 'NavigateFile'); + define ('IPSCAM_VAR_MOTMODE', 'MotionMode'); + define ('IPSCAM_VAR_MOTTIME', 'MotionTime'); + define ('IPSCAM_VAR_MOTHIST', 'MotionHist'); + define ('IPSCAM_VAR_MOTSIZE', 'MotionSize'); + define ('IPSCAM_VAR_PICTREF', 'PictureRefresh'); + define ('IPSCAM_VAR_PICTSTORE', 'PictureStore'); + define ('IPSCAM_VAR_PICTRESET', 'PictureReset'); + define ('IPSCAM_VAR_PICTHIST', 'PictureHist'); + define ('IPSCAM_VAR_PICTSIZE', 'PictureSize'); + + + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/modules/IPSCam/IPSCam_GenerateMovies.ips.php b/IPSLibrary/app/modules/IPSCam/IPSCam_GenerateMovies.ips.php new file mode 100644 index 0000000..16647ab --- /dev/null +++ b/IPSLibrary/app/modules/IPSCam/IPSCam_GenerateMovies.ips.php @@ -0,0 +1,37 @@ + + * + * Generieren der "Motion Capture" Movies + * + */ + + include_once "IPSCam.inc.php"; + + $camManager = new IPSCam_Manager(); + $camManager->GenerateMovies(); + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/modules/IPSCam/IPSCam_Manager.class.php b/IPSLibrary/app/modules/IPSCam/IPSCam_Manager.class.php new file mode 100644 index 0000000..785b57d --- /dev/null +++ b/IPSLibrary/app/modules/IPSCam/IPSCam_Manager.class.php @@ -0,0 +1,1194 @@ + + * + * IPSCam Kamera Management + */ + + /** + * @class IPSCam_Manager + * + * Definiert ein IPSCam_Manager Objekt + * + * @author Andreas Brauneis + * @version + * Version 2.50.1, 26.07.2012
+ */ + class IPSCam_Manager { + + /** + * @private + * ID Kategorie für Kamera Daten + */ + private $categoryIdCams; + + /** + * @private + * ID Kategorie für allgemeine Steuerungs Daten + */ + private $categoryIdCommon; + + /** + * @private + * ID Kategorie WebFront Navigations Panel + */ + private $categoryIdNavPanel; + + /** + * @private + * ID Kategorie WebFront Camera Panel + */ + private $categoryIdCamPanel; + + /** + * @private + * Konfigurations Daten Array + */ + private $config; + + /** + * @public + * + * Initialisierung des IPSCam_Manager Objektes + * + */ + public function __construct() { + $baseId = IPSUtil_ObjectIDByPath('Program.IPSLibrary.data.modules.IPSCam'); + $displayCategoryId = IPS_GetObjectIDByIdent('Display', $baseId); + $this->categoryIdNavPanel = IPS_GetObjectIDByIdent('NavigationPanel', $displayCategoryId); + $this->categoryIdCamPanel = IPS_GetObjectIDByIdent('CameraPanel', $displayCategoryId); + $this->categoryIdCams = IPS_GetObjectIDByIdent('Cams', $baseId); + $this->categoryIdCommon = IPS_GetObjectIDByIdent('Common', $baseId); + $this->config = IPSCam_GetConfiguration(); + } + + /** + * @public + * + * Modifiziert einen Variablen Wert der Kamera Steuerung + * + * @param integer $variableId ID der Variable die geändert werden soll + * @param variant $value Neuer Wert der Variable + */ + // ---------------------------------------------------------------------------------------------------------------------------- + public function ChangeSetting($variableId, $value) { + $variableIdent = IPS_GetIdent($variableId); + switch ($variableIdent) { + case IPSCAM_VAR_CAMSELECT: + $this->SetCamera($value); + break; + case IPSCAM_VAR_CAMPOWER: + $cameraIdx = (int)IPS_GetName(IPS_GetParent($variableId)); + $this->SetCamera($cameraIdx); + break; + case IPSCAM_VAR_MODE: + $this->SetMode($value); + break; + case IPSCAM_VAR_PICTSIZE: + SetValue($variableId, $value); + $mode = GetValue(IPS_GetObjectIDByIdent(IPSCAM_VAR_MODE, $this->categoryIdCommon)); + $cameraIdx = GetValue(IPS_GetObjectIDByIdent(IPSCAM_VAR_CAMSELECT, $this->categoryIdCommon)); + if ($mode==IPSCAM_MODE_PICTURE) { + $this->PictureRefresh($cameraIdx); + } + $this->RefreshWebFront($cameraIdx); + break; + case IPSCAM_VAR_MODELIVE: + case IPSCAM_VAR_MODEPICT: + case IPSCAM_VAR_MODEHIST: + case IPSCAM_VAR_MODESETT: + if (!$value) { + $this->SetMode(IPSCAM_MODE_PICTURE); + } elseif ($variableIdent==IPSCAM_VAR_MODELIVE) { + $this->SetMode(IPSCAM_MODE_LIVE); + } elseif ($variableIdent==IPSCAM_VAR_MODEPICT) { + $this->SetMode(IPSCAM_MODE_PICTURE); + } elseif ($variableIdent==IPSCAM_VAR_MODEHIST) { + $this->SetMode(IPSCAM_MODE_HISTORY); + } elseif ($variableIdent==IPSCAM_VAR_MODESETT) { + $this->SetMode(IPSCAM_MODE_SETTINGS); + } else { + trigger_error('Unknown Variable'); + } + break; + case IPSCAM_VAR_NAVPICT: + SetValue($variableId, $value); + $this->NavigatePictures($value, 1); + IPS_Sleep(200); + SetValue($variableId, -1); + break; + case IPSCAM_VAR_NAVDAYS: + SetValue($variableId, $value); + $this->NavigateDays($value, 1); + IPS_Sleep(200); + SetValue($variableId, -1); + break; + case IPSCAM_VAR_MOTMODE: + case IPSCAM_VAR_MOTTIME: + SetValue($variableId, $value); + $categoryId = IPS_GetParent($variableId); + $cameraIdx = (int)IPS_GetName($categoryId); + $this->SetTimer ($cameraIdx, 'PictureMotion', + GetValue(IPS_GetObjectIDByIdent(IPSCAM_VAR_MOTMODE, $categoryId)), + GetValue(IPS_GetObjectIDByIdent(IPSCAM_VAR_MOTTIME, $categoryId))); + break; + case IPSCAM_VAR_MOTHIST: + case IPSCAM_VAR_MOTSIZE: + SetValue($variableId, $value); + break; + case IPSCAM_VAR_PICTREF: + SetValue($variableId, $value); + $cameraIdx = (int)IPS_GetName(IPS_GetParent($variableId)); + $this->SetTimer ($cameraIdx, 'PictureRefresh', $value); + break; + case IPSCAM_VAR_PICTSTORE: + SetValue($variableId, $value); + $cameraIdx = (int)IPS_GetName(IPS_GetParent($variableId)); + $this->SetTimer ($cameraIdx, 'PictureStore', $value); + break; + case IPSCAM_VAR_PICTRESET: + SetValue($variableId, $value); + $cameraIdx = (int)IPS_GetName(IPS_GetParent($variableId)); + $this->SetTimer ($cameraIdx, 'PictureReset', $value); + break; + case IPSCAM_VAR_PICTHIST: + SetValue($variableId, $value); + break; + default: + trigger_error('Unknown VariableID'.$variableId); + } + } + + // ---------------------------------------------------------------------------------------------------------------------------- + public function ActivateCamera($cameraIdx, $mode) { + $this->SetCamera($cameraIdx); + $this->SetMode($mode); + } + + // ---------------------------------------------------------------------------------------------------------------------------- + private function SetCamera ($cameraIdx) { + $variableIdCamSelect = IPS_GetObjectIDByIdent(IPSCAM_VAR_CAMSELECT, $this->categoryIdCommon); + if (GetValue($variableIdCamSelect)<>$cameraIdx) { + SetValue($variableIdCamSelect, $cameraIdx); + foreach ($this->config as $idx=>$data) { + $categoryIdCam = IPS_GetObjectIDByIdent($idx, $this->categoryIdCams); + $variableIdCamPower = IPS_GetObjectIDByIdent(IPSCAM_VAR_CAMPOWER, $categoryIdCam); + $valueCamPower = ($idx==$cameraIdx); + SetValue($variableIdCamPower, $valueCamPower); + } + $mode = GetValue(IPS_GetObjectIDByIdent(IPSCAM_VAR_MODE, $this->categoryIdCommon)); + $this->RefreshWebFrontByMode($mode); + if ($mode==IPSCAM_MODE_HISTORY) { + $this->NavigatePictures(IPSCAM_DAY_FORWARD, 1); + } elseif ($mode==IPSCAM_MODE_PICTURE) { + $this->PictureRefresh($cameraIdx); + } else { + } + $this->RefreshWebFront($cameraIdx); + } + } + + // ---------------------------------------------------------------------------------------------------------------------------- + private function SetMode ($mode) { + $variableIdMode = IPS_GetObjectIDByIdent(IPSCAM_VAR_MODE, $this->categoryIdCommon); + if (GetValue($variableIdMode)<>$mode) { + SetValue($variableIdMode, $mode); + $variableIdMode = IPS_GetObjectIDByIdent(IPSCAM_VAR_MODELIVE, $this->categoryIdCommon); + SetValue($variableIdMode, ($mode==IPSCAM_MODE_LIVE)); + $variableIdMode = IPS_GetObjectIDByIdent(IPSCAM_VAR_MODEPICT, $this->categoryIdCommon); + SetValue($variableIdMode, ($mode==IPSCAM_MODE_PICTURE)); + $variableIdMode = IPS_GetObjectIDByIdent(IPSCAM_VAR_MODEHIST, $this->categoryIdCommon); + SetValue($variableIdMode, ($mode==IPSCAM_MODE_HISTORY)); + $variableIdMode = IPS_GetObjectIDByIdent(IPSCAM_VAR_MODESETT, $this->categoryIdCommon); + SetValue($variableIdMode, ($mode==IPSCAM_MODE_SETTINGS)); + + //Reset Timers + $variableIdCamSelect = IPS_GetObjectIDByIdent(IPSCAM_VAR_CAMSELECT, $this->categoryIdCommon); + $cameraIdx = GetValue($variableIdCamSelect); + $categoryIdCam = IPS_GetObjectIDByIdent($cameraIdx, $this->categoryIdCams); + $this->SetTimer ($cameraIdx, 'PictureReset', IPSCAM_VAL_DISABLED); + $this->SetTimer ($cameraIdx, 'PictureReset', GetValue(IPS_GetObjectIDByIdent(IPSCAM_VAR_PICTRESET, $categoryIdCam)), 'Once'); + + // Refresh + $this->RefreshWebFrontByMode($mode); + if ($mode==IPSCAM_MODE_HISTORY) { + $this->NavigatePictures(IPSCAM_DAY_FORWARD, 1); + } elseif ($mode==IPSCAM_MODE_PICTURE) { + $this->PictureRefresh($cameraIdx); + } else { + } + $this->RefreshWebFront($cameraIdx); + } + } + + // ---------------------------------------------------------------------------------------------------------------------------- + private function RefreshWebFront($cameraIdx) { + // Check if Camera is currently selected in WebFront, otherwise nothing has to be refreshed + if (GetValue(IPS_GetObjectIDByIdent(IPSCAM_VAR_CAMSELECT, $this->categoryIdCommon)) <> $cameraIdx) { + return; + } + $mode = GetValue(IPS_GetObjectIDByIdent(IPSCAM_VAR_MODE, $this->categoryIdCommon)); + $variableIdHtml = IPS_GetObjectIDByIdent(IPSCAM_VAR_HTML, $this->categoryIdCommon); + $variableIdHtml2 = IPS_GetObjectIDByIdent(IPSCAM_VAR_IHTML, $this->categoryIdCommon); + + $urlStream = $this->GetURL($cameraIdx, IPSCAM_URL_LIVE); + $urlImage = $this->GetURL($cameraIdx, IPSCAM_URL_PICTURE); + + + $styleImage = 'text-align:center; border:3px solid rgba(255,255,255,0.5);'; + $styleContainer = 'text-align:center; width:100%; display:block; cursor:default;'; + $styleImage2 = 'text-align:center; width:95%; border:3px solid rgba(255,255,255,0.5);'; + $styleContainer2 = 'text-align:center; display:block; cursor:default;'; + + switch ($mode) { + case IPSCAM_MODE_LIVE: + $variableIdCam = IPS_GetObjectIDByIdent(IPSCAM_VAR_CAMHTML, $this->categoryIdCommon); + SetValue($variableIdCam, ''); } - function NetPlayer_SwitchToRadio() { - if (GetValue(NP_ID_CONTROLTYPE)==2) return; + function NetPlayer_SwitchToRadio($forceLoad=false) { + if (GetValue(NP_ID_CONTROLTYPE)==2 and !$forceLoad) return; $radiourl = GetValue(NP_ID_RADIOURL); $radiotitel = GetValue(NP_ID_RADIONAME); IPSLogger_Inf(__file__, "Play RadioStation '$radiotitel', Url='$radiourl'"); @@ -193,21 +201,6 @@ function NetPlayer_PlayDirectory($directory) { NetPlayer_RefreshCDListValue(); } - function NetPlayer_PlayRadio($radiourl, $radiotitel) { - IPSLogger_Inf(__file__, "Play RadioStation '$radiotitel', Url='$radiourl'"); - SetValue(NP_ID_RADIOURL, $radiourl); - SetValue(NP_ID_RADIONAME, $radiotitel); - SetValue(NP_ID_CDINTERPRET, ''); - SetValue(NP_ID_CDALBUM, $radiotitel); - NetPlayer_Power(true); - NetPlayer_SwitchToRadio(); - NetPlayer_RefreshRadioListValue(); - $player = NetPlayer_GetIPSComponentPlayer(); - $player->ClearPlaylist(); - $player->AddPlaylist($radiourl); - $player->Play(); - } - function NetPlayer_NavigateRadioForward($count=NP_COUNT_RADIODEFAULT) { IPSLogger_Trc(__file__, "Navigate Forward Radio, Count=$count"); NetPlayer_NavigateRadio($count-1); @@ -232,20 +225,78 @@ function NetPlayer_Pause() { NetPlayer_GetIPSComponentPlayer()->Pause(); } - function NetPlayer_Prev() { + function NetPlayer_PlayRadio($radiourl, $radiotitel) { + IPSLogger_Inf(__file__, "Play RadioStation '$radiotitel', Url='$radiourl'"); + SetValue(NP_ID_RADIOURL, $radiourl); + SetValue(NP_ID_RADIONAME, $radiotitel); + SetValue(NP_ID_CDINTERPRET, ''); + SetValue(NP_ID_CDALBUM, $radiotitel); + NetPlayer_Power(true); + NetPlayer_SwitchToRadio(); + NetPlayer_RefreshRadioListValue(); + $player = NetPlayer_GetIPSComponentPlayer(); + $player->ClearPlaylist(); + $player->AddPlaylist($radiourl); + $player->Play(); + } + + function NetPlayer_RadioByIndex($radioIdx=0) { + $radioName = GetValue(NP_ID_RADIONAME); + $radioList = NetPlayer_GetRadioList(); + $radioKeys = array_keys($radioList); + if (!array_key_exists($radioIdx, $radioKeys)) { + IPSLogger_Err(__file__, "Unbekannter Sender in der Radioliste -> $radioIdx"); + } else { + $radioName = $radioKeys[$radioIdx]; + $radioUrl = $radioList[$radioKeys[$radioIdx]]; + NetPlayer_PlayRadio($radioUrl, $radioName); + NetPlayer_RefreshRemoteControl(); + } + } + + function NetPlayer_NextRadio($next=1) { + $radioName = GetValue(NP_ID_RADIONAME); + $radioList = NetPlayer_GetRadioList(); + $radioKeys = array_keys($radioList); // 0=>'OE3',... + $radioFlip = array_flip($radioKeys); // 'OE3'=>0 + print_r($radioFlip); + $radioIdx = $radioFlip[$radioName]+$next; + echo $radioIdx; + if (!array_key_exists($radioIdx, $radioKeys)) { + if ($next>0) { + $radioIdx = 0; + } else { + $radioIdx = count($radioKeys)-1; + } + } + $radioName = $radioKeys[$radioIdx]; + $radioUrl = $radioList[$radioName]; + NetPlayer_PlayRadio($radioUrl, $radioName); + NetPlayer_RefreshRemoteControl(); + } + + function NetPlayer_Next() { NetPlayer_Power(true); $plaverState = GetValue(NP_ID_CONTROL); - SetValue(NP_ID_CONTROL, NP_IDX_CONTROLPREV); - NetPlayer_GetIPSComponentPlayer()->Prev(); + SetValue(NP_ID_CONTROL, NP_IDX_CONTROLNEXT); + if (GetValue(NP_ID_CONTROLTYPE)==2) { // Radio + NetPlayer_NextRadio(1); + } else { + NetPlayer_GetIPSComponentPlayer()->Next(); + } IPS_SLEEP(200); SetValue(NP_ID_CONTROL, $plaverState); } - function NetPlayer_Next() { + function NetPlayer_Prev() { NetPlayer_Power(true); $plaverState = GetValue(NP_ID_CONTROL); - SetValue(NP_ID_CONTROL, NP_IDX_CONTROLNEXT); - NetPlayer_GetIPSComponentPlayer()->Next(); + SetValue(NP_ID_CONTROL, NP_IDX_CONTROLPREV); + if (GetValue(NP_ID_CONTROLTYPE)==2) { // Radio + NetPlayer_NextRadio(-1); + } else { + NetPlayer_GetIPSComponentPlayer()->Prev(); + } IPS_SLEEP(200); SetValue(NP_ID_CONTROL, $plaverState); } @@ -257,38 +308,45 @@ function NetPlayer_SetPlayListPosition($position) { } function NetPlayer_SetSource($value) { - if (GetValue(NP_ID_SOURCE)<>$value) { + if (GetValue(NP_ID_SOURCE)<>$value) { switch ($value) { - case NP_IDX_SOURCECD: - NetPlayer_SwitchToMP3Player(true, true); - break; - case NP_IDX_SOURCERADIO: - NetPlayer_SwitchToRadio(); - break; + case NP_IDX_SOURCECD: + NetPlayer_SwitchToMP3Player(true, true); + break; + case NP_IDX_SOURCERADIO: + NetPlayer_SwitchToRadio(); + break; default: - IPSLogger_Err(__file__, "Unknown SourceValue '$value'"); - exit; + IPSLogger_Err(__file__, "Unknown SourceValue '$value'"); + exit; } } } function NetPlayer_Power($value) { - // Set Power State + // Set Power State if ($value != GetValue(NP_ID_POWER)) { - SetValue(NP_ID_POWER, $value); + SetValue(NP_ID_POWER, $value); NetPlayer_RefreshRemoteControl(); } $plaverState = GetValue(NP_ID_CONTROL); // Set Player Control if ($value and $plaverState<>NP_IDX_CONTROLPLAY) { - IPSLogger_Trc(__file__, 'Start Netplayer'); - SetValue(NP_ID_CONTROL, NP_IDX_CONTROLPLAY); - NetPlayer_GetIPSComponentPlayer()->Play(); + IPSLogger_Trc(__file__, 'Start Netplayer'); + SetValue(NP_ID_CONTROL, NP_IDX_CONTROLPLAY); + $player = NetPlayer_GetIPSComponentPlayer(); + if (!$player->Play()) { + if (GetValue(NP_ID_CONTROLTYPE)==2) { + NetPlayer_SwitchToRadio(true); + } else { + NetPlayer_SwitchToMP3Player(true, true); + } + } } if (!$value and $plaverState<>NP_IDX_CONTROLSTOP) { - IPSLogger_Trc(__file__, 'Stop Netplayer'); - SetValue(NP_ID_CONTROL, NP_IDX_CONTROLSTOP); + IPSLogger_Trc(__file__, 'Stop Netplayer'); + SetValue(NP_ID_CONTROL, NP_IDX_CONTROLSTOP); NetPlayer_GetIPSComponentPlayer()->Stop(); } } diff --git a/IPSLibrary/app/modules/NetPlayer/NetPlayer_ActionScript.ips.php b/IPSLibrary/app/modules/NetPlayer/NetPlayer_ActionScript.ips.php index 15ebb1d..75399c1 100644 --- a/IPSLibrary/app/modules/NetPlayer/NetPlayer_ActionScript.ips.php +++ b/IPSLibrary/app/modules/NetPlayer/NetPlayer_ActionScript.ips.php @@ -75,23 +75,23 @@ if ($categoryPath<>"") $basePath = $basePath."\\".$categoryPath; $directory = $basePath . "\\" . $directory; NetPlayer_PlayDirectory($directory); - break; + break; case NP_ID_RADIONAV: SetValue($variable, $value); - if ($value==NP_IDX_RADIOPREV) { + if ($value==NP_IDX_RADIOPREV) { NetPlayer_NavigateRadioBack(NP_COUNT_RADIOVARIABLE); - } else { + } else { NetPlayer_NavigateRadioForward(NP_COUNT_RADIOVARIABLE); - } + } IPS_SLEEP(200); SetValue($variable, -1); - break; + break; case NP_ID_RADIOLIST: $radioName = NetPlayer_GetNameFromProfile($value,'NetPlayer_RadioList'); $radioList = NetPlayer_GetRadioList(); $radioUrl = $radioList[$radioName]; NetPlayer_PlayRadio($radioUrl, $radioName); - break; + break; default: IPSLogger_Err(__file__, 'Unknown ControlID '.$variable); } diff --git a/IPSLibrary/app/modules/NetPlayer/NetPlayer_ListFiles.inc.php b/IPSLibrary/app/modules/NetPlayer/NetPlayer_ListFiles.inc.php index b0206bd..3d43697 100644 --- a/IPSLibrary/app/modules/NetPlayer/NetPlayer_ListFiles.inc.php +++ b/IPSLibrary/app/modules/NetPlayer/NetPlayer_ListFiles.inc.php @@ -12,38 +12,38 @@ // --------------------------------------------------------------------------------------------------------------------------- function NetPlayer_GetCategoryList () { - $basePath = NETPLAYER_DIRECTORY; - $categoryList = array(); - $directoryList = scandir($basePath); - $directoryList = array_diff($directoryList, Array(".","..")); - $idx = 1; - foreach($directoryList as $directory) { + $basePath = NETPLAYER_DIRECTORY; + $categoryList = array(); + $directoryList = scandir($basePath); + $directoryList = array_diff($directoryList, Array(".","..")); + $idx = 1; + foreach($directoryList as $directory) { $fullDirName = $basePath . "\\" . $directory; - if (is_dir($fullDirName) and strpos($directory, '_')===0) { - $categoryList[] = $directory; + if (is_dir($fullDirName) and strpos($directory, '_')===0) { + $categoryList[] = $directory; } - } + } return $categoryList; - } + } // --------------------------------------------------------------------------------------------------------------------------- function NetPlayer_GetDirectoryList () { - $basePath = NETPLAYER_DIRECTORY; - $categoryPath = GetValue(NP_ID_CDCATEGORYNAME); + $basePath = NETPLAYER_DIRECTORY; + $categoryPath = GetValue(NP_ID_CDCATEGORYNAME); if ($categoryPath<>"") $basePath = $basePath."\\".$categoryPath; - $resultList = array(); - $directoryList = scandir($basePath); - $directoryList = array_diff($directoryList, Array(".","..")); + $resultList = array(); + $directoryList = scandir($basePath); + $directoryList = array_diff($directoryList, Array(".","..")); - foreach($directoryList as $directory) { + foreach($directoryList as $directory) { $fullDirName = $basePath . "\\" . $directory; - if (strpos($directory, '_')===0) { + if (strpos($directory, '_')===0) { continue; - } elseif (is_dir($fullDirName)) { - $resultList[] = $directory; + } elseif (is_dir($fullDirName)) { + $resultList[] = $directory; } else { - //ignore + //ignore } } return $resultList; @@ -51,39 +51,41 @@ function NetPlayer_GetDirectoryList () { // --------------------------------------------------------------------------------------------------------------------------- function NetPlayer_FilterDirectoryList ($directoryList, $count) { - $resultList = array(); - $maxIdx = count($directoryList); - $currentIdx = GetValue(NP_ID_CDDIRECTORYIDX); - if ($currentIdx > $maxIdx - $count) $currentIdx = $maxIdx - $count; - if ($currentIdx < 0) $currentIdx = 0; + $resultList = array(); + $maxIdx = count($directoryList); + $currentIdx = GetValue(NP_ID_CDDIRECTORYIDX); + if ($currentIdx > $maxIdx - $count) $currentIdx = $maxIdx - $count; + if ($currentIdx < 0) $currentIdx = 0; for ($idx=0 ; $idx<$count; $idx++) { - if (array_key_exists($currentIdx + $idx, $directoryList)) - $resultList[] = $directoryList[$currentIdx + $idx]; + if (array_key_exists($currentIdx + $idx, $directoryList)) + $resultList[] = $directoryList[$currentIdx + $idx]; } return $resultList; } // --------------------------------------------------------------------------------------------------------------------------- function NetPlayer_GetCDList ($count, &$fullDirNameList, &$interpretList, &$albumList) { - $directoryList = NetPlayer_GetDirectoryList(); - $directoryList = NetPlayer_FilterDirectoryList($directoryList, $count); - $basePath = NETPLAYER_DIRECTORY; - foreach ($directoryList as $idx=>$directory) { - $fullDirNameList[] = $basePath."\\".$directory; - $interpretList[] = substr($directory, 0, strpos($directory, "[")); + $directoryList = NetPlayer_GetDirectoryList(); + $directoryList = NetPlayer_FilterDirectoryList($directoryList, $count); + $basePath = NETPLAYER_DIRECTORY; + $categoryPath = GetValue(NP_ID_CDCATEGORYNAME); + if ($categoryPath<>"") $basePath = $basePath."\\".$categoryPath; + foreach ($directoryList as $idx=>$directory) { + $fullDirNameList[] = $basePath."\\".$directory; + $interpretList[] = substr($directory, 0, strpos($directory, "[")); $albumList[] = substr($directory, strpos($directory, "[")); } } // --------------------------------------------------------------------------------------------------------------------------- function NetPlayer_NavigateCD ($delta) { - $directoryList = NetPlayer_GetDirectoryList(); - $maxIdx = count($directoryList); - $currentIdx = GetValue(NP_ID_CDDIRECTORYIDX); - if ($currentIdx > $maxIdx - $delta) $currentIdx = $maxIdx - $delta; + $directoryList = NetPlayer_GetDirectoryList(); + $maxIdx = count($directoryList); + $currentIdx = GetValue(NP_ID_CDDIRECTORYIDX); + if ($currentIdx > $maxIdx - $delta) $currentIdx = $maxIdx - $delta; $currentIdx = $currentIdx + $delta; - if ($currentIdx < 0) $currentIdx = 0; - SetValue(NP_ID_CDDIRECTORYIDX, $currentIdx); + if ($currentIdx < 0) $currentIdx = 0; + SetValue(NP_ID_CDDIRECTORYIDX, $currentIdx); } /** @}*/ diff --git a/IPSLibrary/app/modules/NetPlayer/NetPlayer_LoadFiles.inc.php b/IPSLibrary/app/modules/NetPlayer/NetPlayer_LoadFiles.inc.php index 8a56cb2..2d7b6bf 100644 --- a/IPSLibrary/app/modules/NetPlayer/NetPlayer_LoadFiles.inc.php +++ b/IPSLibrary/app/modules/NetPlayer/NetPlayer_LoadFiles.inc.php @@ -12,16 +12,17 @@ // --------------------------------------------------------------------------------------------------------------------------- function NetPlayer_CopyCoverFile ($path) { - $files = scandir($path); + $files = scandir($path); foreach ($files as $file) { - $extension = pathinfo($file, PATHINFO_EXTENSION); - $filename = pathinfo($file, PATHINFO_FILENAME); - $cover_jpg = ""; - $cover_front = ""; - if (strtolower($extension)=='jpg') { - $cover_jpg = $path."\\".$file; - if (strpos(strtolower($filename),'front')!==false) { - $cover_front = $path."\\".$file; } + $extension = pathinfo($file, PATHINFO_EXTENSION); + $filename = pathinfo($file, PATHINFO_FILENAME); + $cover_jpg = ""; + $cover_front = ""; + if (strtolower($extension)=='jpg') { + $cover_jpg = $path."\\".$file; + if (strpos(strtolower($filename),'front')!==false) { + $cover_front = $path."\\".$file; + } } } @@ -29,64 +30,64 @@ function NetPlayer_CopyCoverFile ($path) { if ($cover_front != "") { $FileInput = $cover_front; } else if ($cover_jpg != "") { - $FileInput = $cover_jpg; + $FileInput = $cover_jpg; } else { - $FileInput = IPS_GetKernelDir()."\\webfront\\user\\NetPlayer\\NetPlayer_CoverNotFound.jpg"; + $FileInput = IPS_GetKernelDir()."\\webfront\\user\\NetPlayer\\NetPlayer_CoverNotFound.jpg"; } - IPSLogger_Dbg(__file__, "Copy Cover File '$FileInput' to '$FileOutput'"); + IPSLogger_Dbg(__file__, "Copy Cover File '$FileInput' to '$FileOutput'"); copy ($FileInput, $FileOutput); } // --------------------------------------------------------------------------------------------------------------------------- - function NetPlayer_GetPlayList($path, &$playlist) { - $content = scandir($path); - $maindata = array_diff($content, Array(".","..")); - $allowed = Array("mp3", "wma"); + function NetPlayer_GetPlayList($path, &$playlist) { + $content = scandir($path); + $maindata = array_diff($content, Array(".","..")); + $allowed = Array("mp3", "wma"); - foreach($maindata as $d) { - $actpath = $path . "\\" . $d; - if (is_dir($actpath)) { - } else { - $ext = pathinfo($actpath, PATHINFO_EXTENSION); - if (in_array(strtolower($ext), $allowed)) { - $playlist[] = $actpath; - } - } - } - } + foreach($maindata as $d) { + $actpath = $path . "\\" . $d; + if (is_dir($actpath)) { + } else { + $ext = pathinfo($actpath, PATHINFO_EXTENSION); + if (in_array(strtolower($ext), $allowed)) { + $playlist[] = $actpath; + } + } + } + } // --------------------------------------------------------------------------------------------------------------------------- function NetPlayer_LoadFiles ($cd_path) { - //Get Directory to Load - SetValue(NP_ID_CDDIRECTORYPATH, $cd_path); + //Get Directory to Load + SetValue(NP_ID_CDDIRECTORYPATH, $cd_path); - // Get PlayList - $playlist = array(); - NetPlayer_GetPlayList ($cd_path, $playlist); - NetPlayer_CopyCoverFile ($cd_path); + // Get PlayList + $playlist = array(); + NetPlayer_GetPlayList ($cd_path, $playlist); + NetPlayer_CopyCoverFile ($cd_path); - // Leeren der vorher bestehenden Playlist: + // Leeren der vorher bestehenden Playlist: $player = NetPlayer_GetIPSComponentPlayer(); $player->ClearPlaylist(); - $tracklist = ""; + $tracklist = ""; - // Durchlaufen des Playlist-Arrays und anhängen an die Mediaplayer-Instanz-Playlist - $idx = 1; - foreach($playlist as $data) - { - IPSLogger_Dbg(__file__, "Add File=".$data); + // Durchlaufen des Playlist-Arrays und anhängen an die Mediaplayer-Instanz-Playlist + $idx = 1; + foreach($playlist as $data) + { + IPSLogger_Dbg(__file__, "Add File=".$data); $player->AddPlaylist($data); - $tracklist.='
'.convert(basename($data))."
"; - $idx++; - } - SetValue(NP_ID_CDTRACKLISTHTML, $tracklist); + $tracklist.='
'.convert(basename($data))."
"; + $idx++; + } + SetValue(NP_ID_CDTRACKLISTHTML, $tracklist); $player->Play(); - $Directory = basename($cd_path); - SetValue(NP_ID_CDINTERPRET, substr($Directory,0,strpos($Directory, "["))); - SetValue(NP_ID_CDALBUM, substr($Directory,strpos($Directory, "[")+1, strpos($Directory, "]")-strpos($Directory, "[")-1)); + $Directory = basename($cd_path); + SetValue(NP_ID_CDINTERPRET, substr($Directory,0,strpos($Directory, "["))); + SetValue(NP_ID_CDALBUM, substr($Directory,strpos($Directory, "[")+1, strpos($Directory, "]")-strpos($Directory, "[")-1)); } /** @}*/ diff --git a/IPSLibrary/app/modules/NetPlayer/NetPlayer_Utils.inc.php b/IPSLibrary/app/modules/NetPlayer/NetPlayer_Utils.inc.php index d2ff9de..108d555 100644 --- a/IPSLibrary/app/modules/NetPlayer/NetPlayer_Utils.inc.php +++ b/IPSLibrary/app/modules/NetPlayer/NetPlayer_Utils.inc.php @@ -13,7 +13,7 @@ // --------------------------------------------------------------------------------------------------------------------------- function convert($s) { $source = array("&", "ä", "ö", "ü", "Ä", "Ö", "Ü", "ß", "<", ">", "€", "", "¹", "²", "³"); - $dest = array("&", "ä", "ö", "ü", "Ä", "Ö", "Ü", "ß", "<", ">", "¬", "¹", "²", "³"); + $dest = array("&", "ä", "ö", "ü", "Ä", "Ö", "Ü", "ß", "<", ">", "€", "¹", "²", "³"); $s = str_replace($source, $dest, $s); return $s; } @@ -21,7 +21,7 @@ function convert($s) { // --------------------------------------------------------------------------------------------------------------------------- function decode($s) { $dest = array("&", "ä", "ö", "ü", "Ä", "Ö", "Ü", "ß", "<", ">", "€", "", "¹", "²", "³"); - $source = array("&", "ä", "ö", "ü", "Ä", "Ö", "Ü", "ß", "<", ">", "¬", "¹", "²", "³"); + $source = array("&", "ä", "ö", "ü", "Ä", "Ö", "Ü", "ß", "<", ">", "€", "¹", "²", "³"); $s = str_replace($source, $dest, $s); return $s; } @@ -226,19 +226,22 @@ function NetPlayer_RefreshTrackListProfile() { // --------------------------------------------------------------------------------------------------------------------------- function NetPlayer_RefreshTrackListValue() { $currentIdx = -1; - $player = NetPlayer_GetIPSComponentPlayer(); - $currentName = $player->GetTrackName(); - $currentName = NetPlayer_GetTrackName($currentName); - $currentName = str_replace(GetValue(NP_ID_CDINTERPRET).' - ', '', $currentName); - - $profileData = IPS_GetVariableProfile('NetPlayer_CDTrackList'); - $associations = $profileData['Associations']; - foreach ($associations as $idx=>$data) { - IPSLogger_Trc(__file__, "Idx=$idx, '$currentName' --> '".$data['Name']."'"); - if ($currentName == $data['Name']) { - $currentIdx = $data['Value']; + if (GetValue(NP_ID_SOURCE)==NP_IDX_SOURCECD) { + $player = NetPlayer_GetIPSComponentPlayer(); + $currentName = $player->GetTrackName(); + $currentName = NetPlayer_GetTrackName($currentName); + $currentName = str_replace(GetValue(NP_ID_CDINTERPRET).' - ', '', $currentName); + + $profileData = IPS_GetVariableProfile('NetPlayer_CDTrackList'); + $associations = $profileData['Associations']; + foreach ($associations as $idx=>$data) { + IPSLogger_Trc(__file__, "Idx=$idx, '$currentName' --> '".$data['Name']."'"); + if ($currentName == $data['Name']) { + $currentIdx = $data['Value']; + } } } + if (GetValue(NP_ID_CDTRACKLIST)<>$currentIdx ) { SetValue(NP_ID_CDTRACKLIST, $currentIdx); } diff --git a/IPSLibrary/app/modules/NetPlayer2/Default/NetPlayer_IDs.inc.php b/IPSLibrary/app/modules/NetPlayer2/Default/NetPlayer_IDs.inc.php new file mode 100644 index 0000000..550dae6 --- /dev/null +++ b/IPSLibrary/app/modules/NetPlayer2/Default/NetPlayer_IDs.inc.php @@ -0,0 +1,48 @@ + + * + * NetPlayer ID Konstanten + * + */ + + //MediaPlayer + define ("NP_ID_MEDIAPLAYER", 36728); + + //MP3 Player + define ("NP_ID_CDDIRECTORYPATH", 38819); + define ("NP_ID_CDDIRECTORYNAME", 14495); + define ("NP_ID_CDCATEGORYNAME", 21024); + define ("NP_ID_CDDIRECTORYIDX", 29911); + define ("NP_ID_CDTRACKLISTHTML", 35872); + define ("NP_ID_CDTRACKIDX", 57387); + + // Radio Player + define ("NP_ID_RADIOIDX", 44432); + define ("NP_ID_RADIONAME", 35966); + define ("NP_ID_RADIOURL", 22694); + + // NetPlayer Controls + define ("NP_ID_POWER", 53255); + define ("NP_ID_CONTROLTYPE", 24721); + define ("NP_ID_REMOTECONTROL", 45560); + define ("NP_ID_MOBILECONTROL", 26527); + + define ("NP_ID_CATEGORYLIST", 22374); + define ("NP_ID_CDALBUMLIST", 23242); + define ("NP_ID_CDALBUMNAV", 37443); + define ("NP_ID_CDTRACKLIST", 25120); + define ("NP_ID_CDTRACKNAV", 30763); + define ("NP_ID_RADIOLIST", 39608); + define ("NP_ID_RADIONAV", 58362); + define ("NP_ID_SOURCE", 27580); + define ("NP_ID_CONTROL", 28803); + define ("NP_ID_CDINTERPRET", 21144); + define ("NP_ID_CDALBUM", 56777); + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/modules/NetPlayer2/NetPlayer.inc.php b/IPSLibrary/app/modules/NetPlayer2/NetPlayer.inc.php new file mode 100644 index 0000000..7275083 --- /dev/null +++ b/IPSLibrary/app/modules/NetPlayer2/NetPlayer.inc.php @@ -0,0 +1,356 @@ + + * + * NetPlayer API + * + * Dieses File kann von anderen Scripts per INCLUDE eingebunden werden und enthält Funktionen + * um alle Funktionen des NetPlayers bequem per Funktionsaufruf steueren zu können. + * + */ + + IPSUtils_Include ("IPSLogger.inc.php", "IPSLibrary::app::core::IPSLogger"); + IPSUtils_Include ("IPSComponent.class.php", "IPSLibrary::app::core::IPSComponent"); + include_once "NetPlayer_Constants.inc.php"; + IPSUtils_Include ("NetPlayer_Configuration.inc.php", "IPSLibrary::config::modules::NetPlayer2"); + include_once "NetPlayer_Utils.inc.php"; + include_once "NetPlayer_ListFiles.inc.php"; + include_once "NetPlayer_LoadFiles.inc.php"; + + + function NetPlayer_GetIPSComponentPlayer() { + $player = IPSComponent::CreateObjectByParams(NETPLAYER_COMPONENT); + return $player ; + } + + function NetPlayer_Switch() { + if (GetValue(NP_ID_CONTROLTYPE)==2) { + NetPlayer_SwitchToMP3Player(); + } else { + NetPlayer_SwitchToRadio(); + } + } + + function NetPlayer_SwitchToMP3Player($loadDirectory=true,$forceLoad=false) { + if (GetValue(NP_ID_CONTROLTYPE)==0 and !$forceLoad) return; + if ($loadDirectory) { + $directory = GetValue(NP_ID_CDDIRECTORYPATH); + IPSLogger_Inf(__file__, "Play MP3 '$directory'"); + NetPlayer_Power(true); + NetPlayer_LoadFiles ($directory); + SetValue(NP_ID_CDTRACKIDX, 0); + NetPlayer_RefreshTrackListProfile(); + NetPlayer_RefreshTrackListValue(); + } + SetValue(NP_ID_SOURCE, NP_IDX_SOURCECD); + SetValue(NP_ID_CONTROLTYPE, 0); + SetValue(NP_ID_REMOTECONTROL, ''); + } + + function NetPlayer_SwitchToMP3Selection() { + if (GetValue(NP_ID_CONTROLTYPE)==1) return; + SetValue(NP_ID_CONTROLTYPE, 1); + SetValue(NP_ID_REMOTECONTROL, ''); + } + + function NetPlayer_SwitchToRadio($forceLoad=false) { + if (GetValue(NP_ID_CONTROLTYPE)==2 and !$forceLoad) return; + $radiourl = GetValue(NP_ID_RADIOURL); + $radiotitel = GetValue(NP_ID_RADIONAME); + IPSLogger_Inf(__file__, "Play RadioStation '$radiotitel', Url='$radiourl'"); + NetPlayer_Power(true); + $player = NetPlayer_GetIPSComponentPlayer(); + $player->ClearPlaylist(); + $player->AddPlaylist($radiourl); + $player->Play(); + SetValue(NP_ID_SOURCE, NP_IDX_SOURCERADIO); + + SetValue(NP_ID_CDINTERPRET, ''); + SetValue(NP_ID_CDALBUM, $radiotitel); + + SetValue(NP_ID_CONTROLTYPE, 2); + SetValue(NP_ID_REMOTECONTROL, ''); + } + + function NetPlayer_RefreshRemoteControl() { + SetValue(NP_ID_REMOTECONTROL, GetValue(NP_ID_REMOTECONTROL)); + } + + function NetPlayer_NavigateTrackForward($count=10) { + IPSLogger_Trc(__file__, "Navigate Forward Track, Count=$count"); + NetPlayer_NavigateTrack($count-1); + NetPlayer_RefreshTrackListProfile(); + NetPlayer_RefreshTrackListValue(); + } + + function NetPlayer_NavigateTrackBack($count=10) { + IPSLogger_Trc(__file__, "Navigate Back Track, Count=$count"); + NetPlayer_NavigateTrack($count*-1+1); + NetPlayer_RefreshTrackListProfile(); + NetPlayer_RefreshTrackListValue(); + } + + function NetPlayer_NavigateCDForward($count=10) { + IPSLogger_Trc(__file__, "Navigate Forward CD, Count=$count"); + NetPlayer_NavigateCD($count-1); + NetPlayer_RefreshCategoryProfile(); + NetPlayer_RefreshCDListProfile(); + NetPlayer_RefreshCDListValue(); + NetPlayer_SwitchToMP3Selection(); + NetPlayer_RefreshRemoteControl(); + } + + function NetPlayer_NavigateCDBack($count=10) { + IPSLogger_Trc(__file__, "Navigate Back CD, Count=$count"); + NetPlayer_NavigateCD($count*-1+1); + NetPlayer_RefreshCategoryProfile(); + NetPlayer_RefreshCDListProfile(); + NetPlayer_RefreshCDListValue(); + NetPlayer_SwitchToMP3Selection(); + NetPlayer_RefreshRemoteControl(); + } + + function NetPlayer_SetCategory($category) { + IPSLogger_Trc(__file__, "Set NetPlayer Category '$category'"); + SetValue(NP_ID_CDCATEGORYNAME, $category); + SetValue(NP_ID_CDDIRECTORYIDX, 0); + NetPlayer_RefreshCategoryProfile(); + NetPlayer_RefreshCDListProfile(); + NetPlayer_RefreshCDListValue(); + NetPlayer_SwitchToMP3Selection(); + NetPlayer_NavigateCDBack(); + } + + function NetPlayer_PlayDirectory($directory) { + IPSLogger_Inf(__file__, "Load MusicFiles from Directory '$directory'"); + SetValue(NP_ID_CDDIRECTORYPATH,$directory); + SetValue(NP_ID_CDDIRECTORYNAME, pathinfo($directory, PATHINFO_FILENAME)); + NetPlayer_SwitchToMP3Player(true, true); + NetPlayer_RefreshCDListValue(); + } + + function NetPlayer_NavigateRadioForward($count=NP_COUNT_RADIODEFAULT) { + IPSLogger_Trc(__file__, "Navigate Forward Radio, Count=$count"); + NetPlayer_NavigateRadio($count-1); + NetPlayer_RefreshRadioListProfile(); + NetPlayer_RefreshRadioListValue(); + NetPlayer_SwitchToRadio(); + NetPlayer_RefreshRemoteControl(); + } + + function NetPlayer_NavigateRadioBack($count=NP_COUNT_RADIODEFAULT) { + IPSLogger_Trc(__file__, "Navigate Back Radio, Count=$count"); + NetPlayer_NavigateRadio($count*-1+1); + NetPlayer_RefreshRadioListProfile(); + NetPlayer_RefreshRadioListValue(); + NetPlayer_SwitchToRadio(); + NetPlayer_RefreshRemoteControl(); + } + + function NetPlayer_Pause() { + NetPlayer_Power(true); + SetValue(NP_ID_CONTROL, NP_IDX_CONTROLPAUSE); + NetPlayer_GetIPSComponentPlayer()->Pause(); + } + + function NetPlayer_PlayRadio($radiourl, $radiotitel) { + IPSLogger_Inf(__file__, "Play RadioStation '$radiotitel', Url='$radiourl'"); + SetValue(NP_ID_RADIOURL, $radiourl); + SetValue(NP_ID_RADIONAME, $radiotitel); + SetValue(NP_ID_CDINTERPRET, ''); + SetValue(NP_ID_CDALBUM, $radiotitel); + NetPlayer_Power(true); + NetPlayer_SwitchToRadio(); + NetPlayer_RefreshRadioListValue(); + $player = NetPlayer_GetIPSComponentPlayer(); + $player->ClearPlaylist(); + $player->AddPlaylist($radiourl); + $player->Play(); + } + + function NetPlayer_RadioByIndex($radioIdx=0) { + $radioName = GetValue(NP_ID_RADIONAME); + $radioList = NetPlayer_GetRadioList(); + $radioKeys = array_keys($radioList); + if (!array_key_exists($radioIdx, $radioKeys)) { + IPSLogger_Err(__file__, "Unbekannter Sender in der Radioliste -> $radioIdx"); + } else { + $radioName = $radioKeys[$radioIdx]; + $radioUrl = $radioList[$radioKeys[$radioIdx]]; + NetPlayer_PlayRadio($radioUrl, $radioName); + NetPlayer_RefreshRemoteControl(); + } + } + + function NetPlayer_NextRadio($next=1) { + $radioName = GetValue(NP_ID_RADIONAME); + $radioList = NetPlayer_GetRadioList(); + $radioKeys = array_keys($radioList); // 0=>'OE3',... + $radioFlip = array_flip($radioKeys); // 'OE3'=>0 + print_r($radioFlip); + $radioIdx = $radioFlip[$radioName]+$next; + echo $radioIdx; + if (!array_key_exists($radioIdx, $radioKeys)) { + if ($next>0) { + $radioIdx = 0; + } else { + $radioIdx = count($radioKeys)-1; + } + } + $radioName = $radioKeys[$radioIdx]; + $radioUrl = $radioList[$radioName]; + NetPlayer_PlayRadio($radioUrl, $radioName); + NetPlayer_RefreshRemoteControl(); + } + + function NetPlayer_Next() { + NetPlayer_Power(true); + $plaverState = GetValue(NP_ID_CONTROL); + SetValue(NP_ID_CONTROL, NP_IDX_CONTROLNEXT); + if (GetValue(NP_ID_CONTROLTYPE)==2) { // Radio + NetPlayer_NextRadio(1); + } else { + NetPlayer_GetIPSComponentPlayer()->Next(); + } + IPS_SLEEP(200); + SetValue(NP_ID_CONTROL, $plaverState); + } + + function NetPlayer_Prev() { + NetPlayer_Power(true); + $plaverState = GetValue(NP_ID_CONTROL); + SetValue(NP_ID_CONTROL, NP_IDX_CONTROLPREV); + if (GetValue(NP_ID_CONTROLTYPE)==2) { // Radio + NetPlayer_NextRadio(-1); + } else { + NetPlayer_GetIPSComponentPlayer()->Prev(); + } + IPS_SLEEP(200); + SetValue(NP_ID_CONTROL, $plaverState); + } + + function NetPlayer_SetPlayListPosition($position) { + IPSLogger_Inf(__file__, "Set NetPlayer PlayListPosition=$position"); + NetPlayer_SwitchToMP3Player(); + NetPlayer_GetIPSComponentPlayer()->SetPlaylistPosition((int)$position); + } + + function NetPlayer_SetSource($value) { + if (GetValue(NP_ID_SOURCE)<>$value) { + switch ($value) { + case NP_IDX_SOURCECD: + NetPlayer_SwitchToMP3Player(true, true); + break; + case NP_IDX_SOURCERADIO: + NetPlayer_SwitchToRadio(); + break; + default: + IPSLogger_Err(__file__, "Unknown SourceValue '$value'"); + exit; + } + } + } + + function NetPlayer_Power($value) { + // Set Power State + if ($value != GetValue(NP_ID_POWER)) { + SetValue(NP_ID_POWER, $value); + NetPlayer_RefreshRemoteControl(); + } + $plaverState = GetValue(NP_ID_CONTROL); + + // Set Player Control + if ($value and $plaverState<>NP_IDX_CONTROLPLAY) { + IPSLogger_Trc(__file__, 'Start Netplayer'); + SetValue(NP_ID_CONTROL, NP_IDX_CONTROLPLAY); + $player = NetPlayer_GetIPSComponentPlayer(); + if (!$player->Play()) { + if (GetValue(NP_ID_CONTROLTYPE)==2) { + NetPlayer_SwitchToRadio(true); + } else { + NetPlayer_SwitchToMP3Player(true, true); + } + } + } + if (!$value and $plaverState<>NP_IDX_CONTROLSTOP) { + IPSLogger_Trc(__file__, 'Stop Netplayer'); + SetValue(NP_ID_CONTROL, NP_IDX_CONTROLSTOP); + NetPlayer_GetIPSComponentPlayer()->Stop(); + } + } + + /** @}*/ + +?> \ No newline at end of file diff --git a/IPSLibrary/app/modules/NetPlayer2/NetPlayer_ActionScript.ips.php b/IPSLibrary/app/modules/NetPlayer2/NetPlayer_ActionScript.ips.php new file mode 100644 index 0000000..75399c1 --- /dev/null +++ b/IPSLibrary/app/modules/NetPlayer2/NetPlayer_ActionScript.ips.php @@ -0,0 +1,115 @@ + + * + * Action Script, um die Änderung diverser NetPlayer Variablen über das WebFront zu + * ermöglichen. + */ + + include_once "NetPlayer.inc.php"; + + if ($_IPS['SENDER'] == 'WebFront') { + $variable = $_IPS['VARIABLE']; + $value = $_IPS['VALUE']; + switch ($variable) { + case NP_ID_POWER: + NetPlayer_Power($value); + break; + case NP_ID_CONTROL: + if ($value==NP_IDX_CONTROLPLAY) { + NetPlayer_Power(true); + } elseif ($value==NP_IDX_CONTROLPAUSE) { + NetPlayer_Pause(); + } elseif ($value==NP_IDX_CONTROLSTOP) { + NetPlayer_Power(false); + } elseif ($value==NP_IDX_CONTROLPREV) { + NetPlayer_Prev(); + } elseif ($value==NP_IDX_CONTROLNEXT) { + NetPlayer_Next(); + } else { + IPSLogger_Err(__file__, 'Unknown ControlValue '.$value); + } + break; + case NP_ID_SOURCE: + NetPlayer_SetSource($value); + break; + case NP_ID_CATEGORYLIST: + if ($value==NP_IDX_CATEGORYROOT) { + NetPlayer_SetCategory(''); + } else { + NetPlayer_SetCategory('_'.NetPlayer_GetNameFromProfile($value,'NetPlayer_Category')); + } + break; + case NP_ID_CDTRACKNAV: + SetValue($variable, $value); + if ($value==NP_IDX_CDPREV) { + NetPlayer_NavigateTrackBack(NP_COUNT_TRACKVARIABLE); + } else { + NetPlayer_NavigateTrackForward(NP_COUNT_TRACKVARIABLE); + } + IPS_SLEEP(200); + SetValue($variable, -1); + break; + case NP_ID_CDTRACKLIST: + NetPlayer_SetPlayListPosition($value+1); + break; + case NP_ID_CDALBUMNAV: + SetValue($variable, $value); + if ($value==NP_IDX_CDPREV) { + NetPlayer_NavigateCDBack(NP_COUNT_CDVARIABLE); + } else { + NetPlayer_NavigateCDForward(NP_COUNT_CDVARIABLE); + } + IPS_SLEEP(200); + SetValue($variable, -1); + break; + case NP_ID_CDALBUMLIST: + $directory = NetPlayer_GetNameFromProfile($value,'NetPlayer_CDAlbumList'); + $basePath = NETPLAYER_DIRECTORY; + $categoryPath = GetValue(NP_ID_CDCATEGORYNAME); + if ($categoryPath<>"") $basePath = $basePath."\\".$categoryPath; + $directory = $basePath . "\\" . $directory; + NetPlayer_PlayDirectory($directory); + break; + case NP_ID_RADIONAV: + SetValue($variable, $value); + if ($value==NP_IDX_RADIOPREV) { + NetPlayer_NavigateRadioBack(NP_COUNT_RADIOVARIABLE); + } else { + NetPlayer_NavigateRadioForward(NP_COUNT_RADIOVARIABLE); + } + IPS_SLEEP(200); + SetValue($variable, -1); + break; + case NP_ID_RADIOLIST: + $radioName = NetPlayer_GetNameFromProfile($value,'NetPlayer_RadioList'); + $radioList = NetPlayer_GetRadioList(); + $radioUrl = $radioList[$radioName]; + NetPlayer_PlayRadio($radioUrl, $radioName); + break; + default: + IPSLogger_Err(__file__, 'Unknown ControlID '.$variable); + } + + } elseif ($_IPS['SENDER'] == 'Execute') { + } + + function NetPlayer_GetNameFromProfile($value, $name) { + $profileData = IPS_GetVariableProfile($name); + $associations = $profileData['Associations']; + foreach ($associations as $idx=>$association) { + if ($association['Value']==$value) { + $name = $association['Name']; + } + } + return $name; + } + + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/modules/NetPlayer2/NetPlayer_Constants.inc.php b/IPSLibrary/app/modules/NetPlayer2/NetPlayer_Constants.inc.php new file mode 100644 index 0000000..5ef7263 --- /dev/null +++ b/IPSLibrary/app/modules/NetPlayer2/NetPlayer_Constants.inc.php @@ -0,0 +1,34 @@ + + * + * NetPlayer Konstanten + * + */ + + include "NetPlayer_IDs.inc.php"; + + // NetPlayer Value Constants + define ("NP_IDX_CONTROLPLAY", 0); + define ("NP_IDX_CONTROLPAUSE", 1); + define ("NP_IDX_CONTROLSTOP", 2); + define ("NP_IDX_CONTROLPREV", 3); + define ("NP_IDX_CONTROLNEXT", 4); + + define ("NP_IDX_RADIOPREV", 0); + define ("NP_IDX_RADIONEXT", 1); + + define ("NP_IDX_CDPREV", 0); + define ("NP_IDX_CDNEXT", 1); + + define ("NP_IDX_CATEGORYROOT", 0); + define ("NP_IDX_CATEGORYBACK", 1); + + define ("NP_IDX_SOURCECD", 0); + define ("NP_IDX_SOURCERADIO", 1); + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/modules/NetPlayer2/NetPlayer_EventScript.ips.php b/IPSLibrary/app/modules/NetPlayer2/NetPlayer_EventScript.ips.php new file mode 100644 index 0000000..0e3bbef --- /dev/null +++ b/IPSLibrary/app/modules/NetPlayer2/NetPlayer_EventScript.ips.php @@ -0,0 +1,24 @@ + + * + * Event Script, wird bei Änderung der aktuellen Titeldatei des MediaPlayers ausgelöst. + */ + + include_once "NetPlayer.inc.php"; + + + if ($_IPS['SENDER'] == 'Variable') { + $value = $_IPS['VALUE']; + + NetPlayer_RefreshTrackListValue(); + } + + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/modules/NetPlayer2/NetPlayer_ListFiles.inc.php b/IPSLibrary/app/modules/NetPlayer2/NetPlayer_ListFiles.inc.php new file mode 100644 index 0000000..3d43697 --- /dev/null +++ b/IPSLibrary/app/modules/NetPlayer2/NetPlayer_ListFiles.inc.php @@ -0,0 +1,92 @@ + + * + * Anzeige von Verzeichnissen mit MP3 Files + */ + + // --------------------------------------------------------------------------------------------------------------------------- + function NetPlayer_GetCategoryList () { + $basePath = NETPLAYER_DIRECTORY; + $categoryList = array(); + $directoryList = scandir($basePath); + $directoryList = array_diff($directoryList, Array(".","..")); + $idx = 1; + foreach($directoryList as $directory) { + $fullDirName = $basePath . "\\" . $directory; + if (is_dir($fullDirName) and strpos($directory, '_')===0) { + $categoryList[] = $directory; + } + } + return $categoryList; + } + + // --------------------------------------------------------------------------------------------------------------------------- + function NetPlayer_GetDirectoryList () { + $basePath = NETPLAYER_DIRECTORY; + $categoryPath = GetValue(NP_ID_CDCATEGORYNAME); + if ($categoryPath<>"") $basePath = $basePath."\\".$categoryPath; + + $resultList = array(); + $directoryList = scandir($basePath); + $directoryList = array_diff($directoryList, Array(".","..")); + + foreach($directoryList as $directory) { + $fullDirName = $basePath . "\\" . $directory; + if (strpos($directory, '_')===0) { + continue; + } elseif (is_dir($fullDirName)) { + $resultList[] = $directory; + } else { + //ignore + } + } + return $resultList; + } + + // --------------------------------------------------------------------------------------------------------------------------- + function NetPlayer_FilterDirectoryList ($directoryList, $count) { + $resultList = array(); + $maxIdx = count($directoryList); + $currentIdx = GetValue(NP_ID_CDDIRECTORYIDX); + if ($currentIdx > $maxIdx - $count) $currentIdx = $maxIdx - $count; + if ($currentIdx < 0) $currentIdx = 0; + for ($idx=0 ; $idx<$count; $idx++) { + if (array_key_exists($currentIdx + $idx, $directoryList)) + $resultList[] = $directoryList[$currentIdx + $idx]; + } + return $resultList; + } + + // --------------------------------------------------------------------------------------------------------------------------- + function NetPlayer_GetCDList ($count, &$fullDirNameList, &$interpretList, &$albumList) { + $directoryList = NetPlayer_GetDirectoryList(); + $directoryList = NetPlayer_FilterDirectoryList($directoryList, $count); + $basePath = NETPLAYER_DIRECTORY; + $categoryPath = GetValue(NP_ID_CDCATEGORYNAME); + if ($categoryPath<>"") $basePath = $basePath."\\".$categoryPath; + foreach ($directoryList as $idx=>$directory) { + $fullDirNameList[] = $basePath."\\".$directory; + $interpretList[] = substr($directory, 0, strpos($directory, "[")); + $albumList[] = substr($directory, strpos($directory, "[")); + } + } + + // --------------------------------------------------------------------------------------------------------------------------- + function NetPlayer_NavigateCD ($delta) { + $directoryList = NetPlayer_GetDirectoryList(); + $maxIdx = count($directoryList); + $currentIdx = GetValue(NP_ID_CDDIRECTORYIDX); + if ($currentIdx > $maxIdx - $delta) $currentIdx = $maxIdx - $delta; + $currentIdx = $currentIdx + $delta; + if ($currentIdx < 0) $currentIdx = 0; + SetValue(NP_ID_CDDIRECTORYIDX, $currentIdx); + } + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/modules/NetPlayer2/NetPlayer_LoadFiles.inc.php b/IPSLibrary/app/modules/NetPlayer2/NetPlayer_LoadFiles.inc.php new file mode 100644 index 0000000..2d7b6bf --- /dev/null +++ b/IPSLibrary/app/modules/NetPlayer2/NetPlayer_LoadFiles.inc.php @@ -0,0 +1,94 @@ + + * + * Laden eines Verzeichnisses in den Player + */ + + // --------------------------------------------------------------------------------------------------------------------------- + function NetPlayer_CopyCoverFile ($path) { + $files = scandir($path); + foreach ($files as $file) { + $extension = pathinfo($file, PATHINFO_EXTENSION); + $filename = pathinfo($file, PATHINFO_FILENAME); + $cover_jpg = ""; + $cover_front = ""; + if (strtolower($extension)=='jpg') { + $cover_jpg = $path."\\".$file; + if (strpos(strtolower($filename),'front')!==false) { + $cover_front = $path."\\".$file; + } + } + } + + $FileOutput = IPS_GetKernelDir()."\\webfront\\user\\NetPlayer\\NetPlayer_Cover.jpg"; + if ($cover_front != "") { + $FileInput = $cover_front; + } else if ($cover_jpg != "") { + $FileInput = $cover_jpg; + } else { + $FileInput = IPS_GetKernelDir()."\\webfront\\user\\NetPlayer\\NetPlayer_CoverNotFound.jpg"; + } + IPSLogger_Dbg(__file__, "Copy Cover File '$FileInput' to '$FileOutput'"); + copy ($FileInput, $FileOutput); + + } + + + // --------------------------------------------------------------------------------------------------------------------------- + function NetPlayer_GetPlayList($path, &$playlist) { + $content = scandir($path); + $maindata = array_diff($content, Array(".","..")); + $allowed = Array("mp3", "wma"); + + foreach($maindata as $d) { + $actpath = $path . "\\" . $d; + if (is_dir($actpath)) { + } else { + $ext = pathinfo($actpath, PATHINFO_EXTENSION); + if (in_array(strtolower($ext), $allowed)) { + $playlist[] = $actpath; + } + } + } + } + + // --------------------------------------------------------------------------------------------------------------------------- + function NetPlayer_LoadFiles ($cd_path) { + //Get Directory to Load + SetValue(NP_ID_CDDIRECTORYPATH, $cd_path); + + // Get PlayList + $playlist = array(); + NetPlayer_GetPlayList ($cd_path, $playlist); + NetPlayer_CopyCoverFile ($cd_path); + + // Leeren der vorher bestehenden Playlist: + $player = NetPlayer_GetIPSComponentPlayer(); + $player->ClearPlaylist(); + $tracklist = ""; + + // Durchlaufen des Playlist-Arrays und anhängen an die Mediaplayer-Instanz-Playlist + $idx = 1; + foreach($playlist as $data) + { + IPSLogger_Dbg(__file__, "Add File=".$data); + $player->AddPlaylist($data); + $tracklist.='
'.convert(basename($data))."
"; + $idx++; + } + SetValue(NP_ID_CDTRACKLISTHTML, $tracklist); + $player->Play(); + + $Directory = basename($cd_path); + SetValue(NP_ID_CDINTERPRET, substr($Directory,0,strpos($Directory, "["))); + SetValue(NP_ID_CDALBUM, substr($Directory,strpos($Directory, "[")+1, strpos($Directory, "]")-strpos($Directory, "[")-1)); + } + + /** @}*/ + ?> \ No newline at end of file diff --git a/IPSLibrary/app/modules/NetPlayer2/NetPlayer_Utils.inc.php b/IPSLibrary/app/modules/NetPlayer2/NetPlayer_Utils.inc.php new file mode 100644 index 0000000..108d555 --- /dev/null +++ b/IPSLibrary/app/modules/NetPlayer2/NetPlayer_Utils.inc.php @@ -0,0 +1,252 @@ + + * + * NetPlayer Utility Funktionen + */ + + // --------------------------------------------------------------------------------------------------------------------------- + function convert($s) { + $source = array("&", "ä", "ö", "ü", "Ä", "Ö", "Ü", "ß", "<", ">", "€", "", "¹", "²", "³"); + $dest = array("&", "ä", "ö", "ü", "Ä", "Ö", "Ü", "ß", "<", ">", "€", "¹", "²", "³"); + $s = str_replace($source, $dest, $s); + return $s; + } + + // --------------------------------------------------------------------------------------------------------------------------- + function decode($s) { + $dest = array("&", "ä", "ö", "ü", "Ä", "Ö", "Ü", "ß", "<", ">", "€", "", "¹", "²", "³"); + $source = array("&", "ä", "ö", "ü", "Ä", "Ö", "Ü", "ß", "<", ">", "€", "¹", "²", "³"); + $s = str_replace($source, $dest, $s); + return $s; + } + + // --------------------------------------------------------------------------------------------------------------------------- + function NetPlayer_NavigateRadio ($delta) { + $maxIdx = count(NetPlayer_GetRadioList()); + $currentIdx = GetValue(NP_ID_RADIOIDX); + if ($currentIdx > $maxIdx - $delta) $currentIdx = $maxIdx - $delta; + $currentIdx = $currentIdx + $delta; + if ($currentIdx < 0) $currentIdx = 0; + SetValue(NP_ID_RADIOIDX, $currentIdx); + } + + // --------------------------------------------------------------------------------------------------------------------------- + function NetPlayer_FilterRadioList ($radioList, $count) { + $resultList = array(); + $maxIdx = count($radioList); + $currentIdx = GetValue(NP_ID_RADIOIDX); + if ($currentIdx > $maxIdx - $count) $currentIdx = $maxIdx - $count; + if ($currentIdx < 0) $currentIdx = 0; + for ($idx=0 ; $idx<$count; $idx++) { + if (array_key_exists($currentIdx + $idx, $radioList)) + $resultList[] = $radioList[$currentIdx + $idx]; + } + $idx = 0; + $radioIdx = 0; + foreach ($radioList as $radioName=>$radioUrl) { + if ($idx>=$currentIdx and $idx<=$currentIdx+$count) { + $resultList[$radioIdx] = $radioName; + $radioIdx++; + } + $idx++; + } + + return $resultList; + } + + // --------------------------------------------------------------------------------------------------------------------------- + function NetPlayer_RefreshCategoryProfile() { + $categoryList = NetPlayer_GetCategoryList(); + $categoryCurr = GetValue(NP_ID_CDCATEGORYNAME); + $categoryCurrIdx = 0; /*Root*/ + $profileData = IPS_GetVariableProfile('NetPlayer_Category'); + $associations = $profileData['Associations']; + foreach ($categoryList as $idx=>$category) { + $profileIdx = $idx + 2; + if ($categoryCurr==$category) $categoryCurrIdx = $profileIdx; + $category = substr($category, 1); + if ((array_key_exists($profileIdx, $associations) and $associations[$profileIdx]<>$category) or + !array_key_exists($profileIdx, $associations)) { + IPS_SetVariableProfileAssociation('NetPlayer_Category', $profileIdx, $category, '', -1); + } + } + foreach ($associations as $idx=>$name) { + $categoryIdx = $idx - 2; + if ($categoryIdx >= 0 and !array_key_exists($categoryIdx, $categoryList)) { + IPS_SetVariableProfileAssociation('NetPlayer_Category', $idx, '', '', -1); + } + } + if (GetValue(NP_ID_CATEGORYLIST) <> $categoryCurrIdx) { + SetValue(NP_ID_CATEGORYLIST, $categoryCurrIdx); + } + } + + // --------------------------------------------------------------------------------------------------------------------------- + function NetPlayer_RefreshRadioListProfile() { + $currentName = GetValue(NP_ID_RADIONAME); + $currentIdx = GetValue(NP_ID_RADIOIDX); + $radioList = NetPlayer_FilterRadioList(NetPlayer_GetRadioList(), NP_COUNT_RADIOVARIABLE); + $profileData = IPS_GetVariableProfile('NetPlayer_RadioList'); + $associations = $profileData['Associations']; + foreach ($associations as $idx=>$data) { + IPS_SetVariableProfileAssociation('NetPlayer_RadioList', $idx, '', '', -1); + } + foreach ($radioList as $idx=>$radio) { + IPS_SetVariableProfileAssociation('NetPlayer_RadioList', $idx, $radio, '', -1); + } + } + + // --------------------------------------------------------------------------------------------------------------------------- + function NetPlayer_RefreshRadioListValue() { + $currentIdx = -1; + $currentName = GetValue(NP_ID_RADIONAME); + $profileData = IPS_GetVariableProfile('NetPlayer_RadioList'); + $associations = $profileData['Associations']; + foreach ($associations as $idx=>$data) { + if ($currentName == $data['Name']) { + $currentIdx = $idx; + } + } + if (GetValue(NP_ID_RADIOLIST)<>$currentIdx ) { + SetValue(NP_ID_RADIOLIST,$currentIdx); + } + } + + + // --------------------------------------------------------------------------------------------------------------------------- + function NetPlayer_RefreshCDListProfile() { + $currentIdx = GetValue(NP_ID_CDDIRECTORYIDX); + $directoryList = NetPlayer_GetDirectoryList(); + $directoryList = NetPlayer_FilterDirectoryList($directoryList, NP_COUNT_CDVARIABLE); + $profileData = IPS_GetVariableProfile('NetPlayer_CDAlbumList'); + $associations = $profileData['Associations']; + foreach ($associations as $idx=>$data) { + IPS_SetVariableProfileAssociation('NetPlayer_CDAlbumList', $idx, '', '', -1); + } + foreach ($directoryList as $idx=>$directory) { + IPS_SetVariableProfileAssociation('NetPlayer_CDAlbumList', $idx, $directory, '', -1); + } + } + + // --------------------------------------------------------------------------------------------------------------------------- + function NetPlayer_RefreshCDListValue() { + $currentIdx = -1; + $currentName = GetValue(NP_ID_CDDIRECTORYNAME); + $profileData = IPS_GetVariableProfile('NetPlayer_CDAlbumList'); + $associations = $profileData['Associations']; + foreach ($associations as $idx=>$data) { + if ($currentName == $data['Name']) { + $currentIdx = $idx; + } + } + if (GetValue(NP_ID_CDALBUMLIST)<>$currentIdx ) { + SetValue(NP_ID_CDALBUMLIST,$currentIdx); + } + } + + // --------------------------------------------------------------------------------------------------------------------------- + function NetPlayer_GetTrackName($file) { + $trackName = pathinfo($file, PATHINFO_FILENAME); + $trackName = str_replace('.mp3', '', $trackName); + $trackName = str_replace('.wma', '', $trackName); + if (substr($trackName,3,1)=='-' and substr($trackName,4,1)==' ') { + $trackName = substr($trackName,5); + } + + return $trackName; + } + + // --------------------------------------------------------------------------------------------------------------------------- + function NetPlayer_GetTrackList() { + $directory = GetValue(NP_ID_CDDIRECTORYPATH); + $fileList = array(); + NetPlayer_GetPlayList($directory, $fileList); + $trackList = array(); + foreach ($fileList as $idx=>$file) { + $trackList[] = NetPlayer_GetTrackName($file); + } + + return $trackList; + } + + // --------------------------------------------------------------------------------------------------------------------------- + function NetPlayer_FilterTrackList ($trackList, $count) { + $maxIdx = count($trackList); + $currentIdx = GetValue(NP_ID_CDTRACKIDX); + if ($currentIdx > $maxIdx - $count) $currentIdx = $maxIdx - $count; + if ($currentIdx < 0) $currentIdx = 0; + +// for ($idx=0 ; $idx<$count; $idx++) { +// if (array_key_exists($currentIdx + $idx, $trackList)) +// $trackList[] = $trackList[$currentIdx + $idx]; +// } + + $resultList = array(); + $idx = 0; + foreach ($trackList as $trackIdx=>$trackName) { + if ($idx>=$currentIdx and $idx<=$currentIdx+$count) { + $resultList[$trackIdx] = $trackName; + } + $idx++; + } + + return $resultList; + } + + // --------------------------------------------------------------------------------------------------------------------------- + function NetPlayer_NavigateTrack($delta) { + $maxIdx = count(NetPlayer_GetTrackList()); + $currentIdx = GetValue(NP_ID_CDTRACKIDX); + if ($currentIdx > $maxIdx - $delta) $currentIdx = $maxIdx - $delta; + $currentIdx = $currentIdx + $delta; + if ($currentIdx < 0) $currentIdx = 0; + SetValue(NP_ID_CDTRACKIDX, $currentIdx); + } + + // --------------------------------------------------------------------------------------------------------------------------- + function NetPlayer_RefreshTrackListProfile() { + $currentIdx = GetValue(NP_ID_CDTRACKIDX); + $trackList = NetPlayer_FilterTrackList(NetPlayer_GetTrackList(), NP_COUNT_TRACKVARIABLE); + $profileData = IPS_GetVariableProfile('NetPlayer_CDTrackList'); + $associations = $profileData['Associations']; + foreach ($associations as $idx=>$data) { + IPS_SetVariableProfileAssociation('NetPlayer_CDTrackList', $data['Value'], '', '', -1); + } + foreach ($trackList as $idx=>$track) { + IPS_SetVariableProfileAssociation('NetPlayer_CDTrackList', $idx, $track, '', -1); + } + } + + // --------------------------------------------------------------------------------------------------------------------------- + function NetPlayer_RefreshTrackListValue() { + $currentIdx = -1; + if (GetValue(NP_ID_SOURCE)==NP_IDX_SOURCECD) { + $player = NetPlayer_GetIPSComponentPlayer(); + $currentName = $player->GetTrackName(); + $currentName = NetPlayer_GetTrackName($currentName); + $currentName = str_replace(GetValue(NP_ID_CDINTERPRET).' - ', '', $currentName); + + $profileData = IPS_GetVariableProfile('NetPlayer_CDTrackList'); + $associations = $profileData['Associations']; + foreach ($associations as $idx=>$data) { + IPSLogger_Trc(__file__, "Idx=$idx, '$currentName' --> '".$data['Name']."'"); + if ($currentName == $data['Name']) { + $currentIdx = $data['Value']; + } + } + } + + if (GetValue(NP_ID_CDTRACKLIST)<>$currentIdx ) { + SetValue(NP_ID_CDTRACKLIST, $currentIdx); + } + } + + + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/app/modules/Weather/IPSTwilight/IPSTwilight.ips.php b/IPSLibrary/app/modules/Weather/IPSTwilight/IPSTwilight.ips.php index f2d0bfa..896547e 100644 --- a/IPSLibrary/app/modules/Weather/IPSTwilight/IPSTwilight.ips.php +++ b/IPSLibrary/app/modules/Weather/IPSTwilight/IPSTwilight.ips.php @@ -65,7 +65,7 @@ switch ($_IPS['SENDER']) { case 'WebFront': SetValue($_IPS['VARIABLE'], $_IPS['VALUE']); - if ($IPS_VARIABLE==$variableId_Display) { + if ($_IPS['VARIABLE']==$variableId_Display) { CopyGraphics($variableId_Display); } else { IPS_RunScript ($_IPS['SELF']); @@ -82,6 +82,7 @@ break; case 'Execute': case 'RunScript': + case 'WebInterface': CalculateCurrentValues($categoryId_Values, $scriptId_Refresh); GenerateGraphics($variableId_Display); break; @@ -112,8 +113,8 @@ function CopyGraphics($variableId_Display) { function GenerateGraphics($variableId_Display) { GenerateTwilightGraphic('IPSTwilight_YearUnlimited', false, 4.4, 1.8); GenerateTwilightGraphic('IPSTwilight_YearLimited', true, 4.4, 1.8); - GenerateClockGraphic('IPSTwilight_DayUnlimited', false); - GenerateClockGraphic('IPSTwilight_DayLimited', true); + GenerateClockGraphic('IPSTwilight_DayUnlimited', false); + GenerateClockGraphic('IPSTwilight_DayLimited', true); CopyGraphics($variableId_Display); } @@ -131,8 +132,8 @@ function CreateTimer($date, $function, $scriptId_Refresh) { // ---------------------------------------------------------------------------------------------------------------------------- function SetLimitedValues($NameLimits, $NameBegin, $NameEnd, $TimeStart, $TimeEnd, $categoryId_Values, $scriptId_Refresh) { - CreateTimer($TimeStart, 'IPSTwilight_'.$NameBegin, $scriptId_Refresh); - CreateTimer($TimeEnd, 'IPSTwilight_'.$NameEnd, $scriptId_Refresh); + CreateTimer($TimeStart, 'IPSTwilight_'.str_replace('Limited', '', $NameBegin), $scriptId_Refresh); + CreateTimer($TimeEnd, 'IPSTwilight_'.str_replace('Limited', '', $NameEnd), $scriptId_Refresh); $Limits = GetValue(IPS_GetVariableIDByName($NameLimits, $categoryId_Values)); // 01234567890123456789012 @@ -149,8 +150,8 @@ function SetLimitedValues($NameLimits, $NameBegin, $NameEnd, $TimeStart, $TimeEn SetValue(IPS_GetVariableIDByName($NameBegin, $categoryId_Values), date("H:i",$TimeStart)); SetValue(IPS_GetVariableIDByName($NameEnd, $categoryId_Values), date("H:i",$TimeEnd)); - CreateTimer($TimeStart, 'IPSTwilight_'.str_replace('Limited', '', $NameBegin), $scriptId_Refresh); - CreateTimer($TimeEnd, 'IPSTwilight_'.str_replace('Limited', '', $NameEnd), $scriptId_Refresh); + CreateTimer($TimeStart, 'IPSTwilight_'.$NameBegin, $scriptId_Refresh); + CreateTimer($TimeEnd, 'IPSTwilight_'.$NameEnd, $scriptId_Refresh); } // ---------------------------------------------------------------------------------------------------------------------------- diff --git a/IPSLibrary/app/modules/Weather/IPSWeatherForcastAT/IPSWeatherForcastAT_Refresh.ips.php b/IPSLibrary/app/modules/Weather/IPSWeatherForcastAT/IPSWeatherForcastAT_Refresh.ips.php index 191991b..3928c53 100644 --- a/IPSLibrary/app/modules/Weather/IPSWeatherForcastAT/IPSWeatherForcastAT_Refresh.ips.php +++ b/IPSLibrary/app/modules/Weather/IPSWeatherForcastAT/IPSWeatherForcastAT_Refresh.ips.php @@ -30,7 +30,6 @@ * */ - IPSUtils_Include ("IPSWeatherForcastAT_Constants.inc.php", "IPSLibrary::app::modules::Weather::IPSWeatherForcastAT"); IPSUtils_Include ("IPSWeatherForcastAT_Configuration.inc.php", "IPSLibrary::config::modules::Weather::IPSWeatherForcastAT"); IPSUtils_Include ("IPSWeatherForcastAT_Utils.inc.php", "IPSLibrary::app::modules::Weather::IPSWeatherForcastAT"); @@ -38,98 +37,22 @@ if (Sys_Ping(IPSWEATHERFAT_EXTERNAL_IP, 100)) { IPSLogger_Trc(__file__, "Refresh Weather Data"); - - $stationGoogle = IPSWEATHERFAT_GOOGLE_PLACE."-".IPSWEATHERFAT_GOOGLE_COUNTRY; - $urlGoogle = "http://www.google.com/ig/api?weather=".$stationGoogle."&hl=".IPSWEATHERFAT_GOOGLE_LANG; - $DaySourceArray = array('Mo.','Di.','Mi.','Do.','Fr.','Sa.','So.'); - $DayDisplayArray = array('Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag','Sonntag'); - - $api = simplexml_load_string(utf8_encode(@Sys_GetURLContent($urlGoogle))); - echo $urlGoogle; - - IPSWeatherFAT_SetValue('LastRefreshDateTime', date("Y-m-j H:i:s")); - IPSWeatherFAT_SetValue('LastRefreshTime', date("H:i")); - - // Aktuelles Wetter - IPSWeatherFAT_SetValue('TodayForecastShort', (string)$api->weather->current_conditions->condition->attributes()->data); - IPSWeatherFAT_SetValue('TodayTempCurrent', (string)$api->weather->current_conditions->temp_c->attributes()->data); - IPSWeatherFAT_SetValue('AirHumidity', str_replace("Feuchtigkeit", "rel.Luftfeuchte", $api->weather->current_conditions->humidity->attributes()->data)); - IPSWeatherFAT_SetValue('Wind', (string)$api->weather->current_conditions->wind_condition->attributes()->data); - IPSWeatherFAT_SetValue('TodayIcon', str_replace(".gif", ".png", str_replace(IPSWEATHERFAT_ICONS_GOOGLE1, IPSWEATHERFAT_ICONS_LARGE, $api->weather->current_conditions->icon->attributes()->data))); - // Wettervorhersage heute, morgen, in zwei und in drei Tagen ($wetter[1] bis $wetter[4]) - $i = 1; - foreach($api->weather->forecast_conditions as $weather) - { - if ($i==1) { - IPSWeatherFAT_SetValue('TodayDay', str_replace($DaySourceArray, $DayDisplayArray, $weather->day_of_week->attributes()->data)); - IPSWeatherFAT_SetValue('TodayForecastShort', (string)$weather->condition->attributes()->data); - IPSWeatherFAT_SetValue('TodayTempMin', (string)$weather->low->attributes()->data); - IPSWeatherFAT_SetValue('TodayTempMax', (string)$weather->high->attributes()->data); - IPSWeatherFAT_SetValue('TodayIcon', str_replace(".gif", ".png", str_replace(IPSWEATHERFAT_ICONS_GOOGLE1, IPSWEATHERFAT_ICONS_LARGE, $weather->icon->attributes()->data))); - } else if ($i==2) { - IPSWeatherFAT_SetValue('TomorrowDay', str_replace($DaySourceArray, $DayDisplayArray, $weather->day_of_week->attributes()->data)); - IPSWeatherFAT_SetValue('TomorrowForecastShort', (string)$weather->condition->attributes()->data); - IPSWeatherFAT_SetValue('TomorrowTempMin', (string)$weather->low->attributes()->data); - IPSWeatherFAT_SetValue('TomorrowTempMax', (string)$weather->high->attributes()->data); - IPSWeatherFAT_SetValue('TomorrowIcon', str_replace(".gif", ".png", str_replace(IPSWEATHERFAT_ICONS_GOOGLE1, IPSWEATHERFAT_ICONS_SMALL, $weather->icon->attributes()->data))); - } else if ($i==3) { - IPSWeatherFAT_SetValue('Tomorrow1Day', str_replace($DaySourceArray, $DayDisplayArray, $weather->day_of_week->attributes()->data)); - IPSWeatherFAT_SetValue('Tomorrow1ForecastShort', (string)$weather->condition->attributes()->data); - IPSWeatherFAT_SetValue('Tomorrow1TempMin', (string)$weather->low->attributes()->data); - IPSWeatherFAT_SetValue('Tomorrow1TempMax', (string)$weather->high->attributes()->data); - IPSWeatherFAT_SetValue('Tomorrow1Icon', str_replace(".gif", ".png", str_replace(IPSWEATHERFAT_ICONS_GOOGLE1, IPSWEATHERFAT_ICONS_SMALL, $weather->icon->attributes()->data))); - } else if ($i==4) { - IPSWeatherFAT_SetValue('Tomorrow2Day', str_replace($DaySourceArray, $DayDisplayArray, $weather->day_of_week->attributes()->data)); - IPSWeatherFAT_SetValue('Tomorrow2ForecastShort', (string)$weather->condition->attributes()->data); - IPSWeatherFAT_SetValue('Tomorrow2TempMin', (string)$weather->low->attributes()->data); - IPSWeatherFAT_SetValue('Tomorrow2TempMax', (string)$weather->high->attributes()->data); - IPSWeatherFAT_SetValue('Tomorrow2Icon', str_replace(".gif", ".png", str_replace(IPSWEATHERFAT_ICONS_GOOGLE1, IPSWEATHERFAT_ICONS_SMALL, $weather->icon->attributes()->data))); - } else { - IPSLogger_Err(__file__, "Receive unknown Weather Forecast Condition"); - } - $i++; + $refreshWunderground = false; + if (IPSWEATHERFAT_WUNDERGROUND_KEY<>'') { + IPSUtils_Include ("IPSWeatherForcastAT_RefreshWunderground.inc.php", "IPSLibrary::app::modules::Weather::IPSWeatherForcastAT"); + $refreshWunderground = IPSWeatherFAT_RefreshWunderground(); } - // Wetter für Niederösterreich von ORF auslesen - $lHTML=file_get_contents(IPSWEATHERFAT_ORF_URL); - - $forcast = ExtractData($lHTML, '
', ' = 1 or $mobile) { + echo '
'.IPSWeatherFAT_GetValue('TomorrowForecastLong').'
'; + } + if (IPSWEATHERFAT_COUNT_DETAILS >= 2 or $mobile) { + echo '
'.IPSWeatherFAT_GetValue('Tomorrow1ForecastLong').'
'; + } + if (IPSWEATHERFAT_COUNT_DETAILS >= 3 or $mobile) { echo '
'.IPSWeatherFAT_GetValue('Tomorrow2ForecastLong').'
'; } ?> diff --git a/IPSLibrary/webfront/NetPlayer/NetPlayer.css b/IPSLibrary/webfront/NetPlayer/NetPlayer.css index 767a05c..21e3813 100644 --- a/IPSLibrary/webfront/NetPlayer/NetPlayer.css +++ b/IPSLibrary/webfront/NetPlayer/NetPlayer.css @@ -1,26 +1,26 @@ -body {color:#fff;font-size:17px;font-family:arial,sans-serif;margin:0;padding:0;overflow:hidden} +body {font-size:17px;font-family:arial,sans-serif;margin:0;padding:0;overflow:hidden} -.containerPlayList{position:absolute; left:0px; right:566; top:0px; float:left; width=100%; border: 1px solid rgba(255,255,255,0.25); height:258px;overflow:auto;} -.containerCover{position:absolute; right:406px; top:0px; width:154px; float:left; border:1px solid rgba(255,255,255,0.25); height:258px;} -.containerControl{position:absolute; right:0px; width:400px; top:0px; float:left;height:258px; border: 1px solid rgba(255,255,255,0.25); background:rgba(0, 0, 0, 0.25);} +.containerPlayList{position:absolute; left:0px; right:566; top:0px; float:left; width=100%; border: 1px solid; height:258px;overflow:auto;} +.containerCover{position:absolute; right:406px; top:0px; width:154px; float:left; border:1px solid ; height:258px;} +.containerControl{position:absolute; right:0px; width:400px; top:0px; float:left;height:258px; border: 1px solid ; } -.containerRadioSelect{position:absolute; left:0px; right:306px; top:0px; float:left; height:180px; border: 1px solid rgba(255,255,255,0.25); background:rgba(0,0,0,0.25); overflow:auto;} -.containerRadioInfo{ position:absolute; right:0px; width:300px; top:0px; float:left; height:180px; border: 1px solid rgba(255,255,255,0.25); background:rgba(0,0,0,0.25);} +.containerRadioSelect{position:absolute; left:0px; right:306px; top:0px; float:left; height:180px; border: 1px solid ; overflow:auto;} +.containerRadioInfo{ position:absolute; right:0px; width:300px; top:0px; float:left; height:180px; border: 1px solid ; } -.containerSelection {position:absolute; right:0px; width:100%; top:0px; float:left; height:250px; border: 0px solid rgba(255,255,255,0.25);} +.containerSelection {position:absolute; right:0px; width:100%; top:0px; float:left; height:250px; border: 0px solid ;} .containerControlLine{position:relative; width:100%; margin:auto; text-align:center; float:left; } .containerControlLineBottom{ position:absolute; width:100%; margin:auto; bottom:3px; display:block; vertical-align:middle; text-align:center; float:left; } .containerControlLineTop{ position:absolute; width:100%; top:3px; display:block; vertical-align:middle; text-align:center; float:left; } .containerControlLineSeparator{ display:none;} -.containerControlButton{ display:inline-block; color:rgba(255,255,255,0.3); line-height:28px; border-width: 1px 0; border-style:solid; border-color:transparent; height:28px; float:left; padding: 0px 10px; margin: 3px 0 0 3px; +.containerControlButton{ display:inline-block; line-height:28px; border-width: 1px 0; border-style:solid; border-color:transparent; height:28px; float:left; padding: 0px 10px; margin: 3px 0 0 3px; background-color:rgba(255,255,255,0.1); background-image:url(../../img/bgCategoryElement.png); background-repeat: repeat;background-position:center top;} -.containerControlButtonSelected{ background-color:rgba(255,255,255,0.3); color:white; } -.containerControlButtonActive{ background-color:rgba(255,255,255,0.3); color:white; } -.containerControlDescr{display:inline-block; color:white; line-height:20px; border-width: 0 0 0 0; height:20px; width:100px; text-align:right; float:left; padding: 0 10px; margin: 3px 0 0 3px;} -.containerControlData{display:inline-block; color:white; line-height:20px; border-width: 0 0 0 0; height:20px; width:250px; text-align:left; float:left; padding: 0 10px; margin: 3px 0 0 3px; overflow:hidden} -.containerControlTrack{display:inline-block; color:white; border-width:0; text-align:left; float:left; padding:0; padding:0px 10px ; margin: 3px; overflow:hidden; font-size:14px;font-family:arial,sans-serif;} +.containerControlButtonSelected{ background-color:rgba(255,255,255,0.3); } +.containerControlButtonActive{ background-color:rgba(255,255,255,0.3); } +.containerControlDescr{display:inline-block; line-height:20px; border-width: 0 0 0 0; height:20px; width:100px; text-align:right; float:left; padding: 0 10px; margin: 3px 0 0 3px;} +.containerControlData{display:inline-block; line-height:20px; border-width: 0 0 0 0; height:20px; width:250px; text-align:left; float:left; padding: 0 10px; margin: 3px 0 0 3px; overflow:hidden} +.containerControlTrack{display:inline-block; border-width:0; text-align:left; float:left; padding:0; padding:0px 10px ; margin: 3px; overflow:hidden; font-size:14px;font-family:arial,sans-serif;} .containerControlTrackActive{font-size:16px;font-family:arial,sans-serif; background:rgba(255,255,255,0.3); width:100%;} .containerControlSelect{height:40px; width:200px; background-image:url(http://localhost:7001/img/bg.png)} .containerControlSelectInterpret{font:bold 14px verdana; height:18px; overflow:hidden;} diff --git a/IPSLibrary/webfront/NetPlayer/NetPlayer_MP3Selection.php b/IPSLibrary/webfront/NetPlayer/NetPlayer_MP3Selection.php index 2ad3c45..ba519e4 100644 --- a/IPSLibrary/webfront/NetPlayer/NetPlayer_MP3Selection.php +++ b/IPSLibrary/webfront/NetPlayer/NetPlayer_MP3Selection.php @@ -56,8 +56,8 @@
-
<<
-
>>
+
<<
+
>>
back
"") echo '
Root
'; diff --git a/IPSLibrary/webfront/NetPlayer/NetPlayer_MobileSelection.php b/IPSLibrary/webfront/NetPlayer/NetPlayer_MobileSelection.php index 68c87b1..2e076ac 100644 --- a/IPSLibrary/webfront/NetPlayer/NetPlayer_MobileSelection.php +++ b/IPSLibrary/webfront/NetPlayer/NetPlayer_MobileSelection.php @@ -60,8 +60,8 @@
-
<<
-
>>
+
<<
+
>>
back
"") echo '
Root
'; diff --git a/IPSLibrary/webfront/NetPlayer/NetPlayer_Sender.php b/IPSLibrary/webfront/NetPlayer/NetPlayer_Sender.php index cf7a18f..ab9fbf2 100644 --- a/IPSLibrary/webfront/NetPlayer/NetPlayer_Sender.php +++ b/IPSLibrary/webfront/NetPlayer/NetPlayer_Sender.php @@ -22,10 +22,31 @@ ?> + + + + + + +
+
+
+
+
+
+
+
+
Last
+
Play
+
Next
+
+
+
Pause
+
Stop
+
+
+
Interpret
+
+
+
+
Album
+
+
+
+
Titel
+
+
+
+
Titellänge
+
+
+
+
Aktuell
+
+
+
+
Musik Auswahl
+
Internet Radio
+
+
+ + + diff --git a/IPSLibrary/webfront/NetPlayer2/NetPlayer_MP3Selection.php b/IPSLibrary/webfront/NetPlayer2/NetPlayer_MP3Selection.php new file mode 100644 index 0000000..53d69b5 --- /dev/null +++ b/IPSLibrary/webfront/NetPlayer2/NetPlayer_MP3Selection.php @@ -0,0 +1,72 @@ + + * + * File kann in das WebFront eingebunden werden (zB per iFrame) und ermöglicht die Navigation durch + * Verzeichnisse mit MP3 Files. + * + */ + /** @}*/ +?> + + + + + + + + + + + + + + +
+
+ $directory) { + echo '
'; + echo '
'.convert($interpretList[$idx]).'
'; + echo '
'.convert($albumList[$idx]).'
'; + echo '
'; + } + ?> +
+ +
+ +
+
<<
+
>>
+
back
+ "") echo '
Root
'; + $categoryList = NetPlayer_GetCategoryList(); + foreach ($categoryList as $idx=>$category) { + echo '
'.str_replace('_','',$category).'
'; + } + ?> +
+
+ + diff --git a/IPSLibrary/webfront/NetPlayer2/NetPlayer_Mobile.php b/IPSLibrary/webfront/NetPlayer2/NetPlayer_Mobile.php new file mode 100644 index 0000000..ed47d08 --- /dev/null +++ b/IPSLibrary/webfront/NetPlayer2/NetPlayer_Mobile.php @@ -0,0 +1,37 @@ + + * + * File kann in das Mobil Frontend eingebunden werden (zB per iFrame) und ermöglicht das Steuern + * des Netplayers. + * + */ + + IPSUtils_Include ("NetPlayer.inc.php", "IPSLibrary::app::modules::NetPlayer2"); + + IPSLogger_Inf(__file__,'Load Mobile GUI ...'); + + $RemoteControlType = GetValue(NP_ID_CONTROLTYPE); + + switch($RemoteControlType) { + case 0: + include "NetPlayer_MobilePlayer.php"; + break; + case 1: + include "NetPlayer_MobileSelection.php"; + break; + case 2: + include "NetPlayer_MobileRadio.php"; + break; + default: + echo "Unknown RemoteControlType $RemoteControlType"; + } + + + /** @}*/ +?> diff --git a/IPSLibrary/webfront/NetPlayer2/NetPlayer_MobilePlayer.php b/IPSLibrary/webfront/NetPlayer2/NetPlayer_MobilePlayer.php new file mode 100644 index 0000000..8355682 --- /dev/null +++ b/IPSLibrary/webfront/NetPlayer2/NetPlayer_MobilePlayer.php @@ -0,0 +1,98 @@ + + * + * File kann in das WebFront eingebunden werden (zB per iFrame) und ermöglicht das Steuern + * des MP3 Players. + * + */ + /** @}*/ +?> + + + + + + + + + + + + + + +
+
+
Play
+
+
+
Last
+
+
+
Next
+
+
+
Pause
+
+
+
Stop
+
+
+
Interpret
+
+
+
+
Album
+
+
+
+
Titel
+
+
+
+
Titellänge
+
+
+
+
Aktuell
+
+
+ +
+ +
+
+
+
+
+
+
+
Musik Auswahl
+
+
+
Internet Radio
+
+
+
+
+
+
+ + + diff --git a/IPSLibrary/webfront/NetPlayer2/NetPlayer_MobileRadio.php b/IPSLibrary/webfront/NetPlayer2/NetPlayer_MobileRadio.php new file mode 100644 index 0000000..cd2464a --- /dev/null +++ b/IPSLibrary/webfront/NetPlayer2/NetPlayer_MobileRadio.php @@ -0,0 +1,83 @@ + + * + * File kann in das WebFront eingebunden werden (zB. per iFrame) und ermöglicht das Abspielen diverser + * Web Radios. + * + * Die Definition der Radio Sender mit zugehöriger URL wird im File NetPlayer_Configuration.ips.php vorgenommen. + * + */ + IPSUtils_Include ("NetPlayer.inc.php", "IPSLibrary::app::modules::NetPlayer2"); + + /** @}*/ +?> + + + + + + + + + + + + + + +
+
+
Play
+
+
+
Pause
+
+
+
Stop
+
+
+
Radio
+
+
+
+
Musik Player
+
+ +
+
+ +
+ + $radioURL) { + echo '
'; + if ($left) { + echo '
'.$radioName.'
'; + } else { + echo '
'.$radioName.'
'; + } + echo '
'; + $idx++; + $left = !$left; + } + ?> +
+
+ + + + diff --git a/IPSLibrary/webfront/NetPlayer2/NetPlayer_MobileSelection.php b/IPSLibrary/webfront/NetPlayer2/NetPlayer_MobileSelection.php new file mode 100644 index 0000000..c6ba508 --- /dev/null +++ b/IPSLibrary/webfront/NetPlayer2/NetPlayer_MobileSelection.php @@ -0,0 +1,76 @@ + + * + * File kann in das WebFront eingebunden werden (zB per iFrame) und ermöglicht die Navigation durch + * Verzeichnisse mit MP3 Files. + * + */ + /** @}*/ +?> + + + + + + + + + + + + + + + +
+
+ $directory) { + echo '
'; + echo '
'.convert($interpretList[$idx]).'
'; + echo '
'.convert($albumList[$idx]).'
'; + echo '
'; + } + ?> +
+ +
+ +
+
<<
+
>>
+
back
+ "") echo '
Root
'; + $categoryList = NetPlayer_GetCategoryList(); + foreach ($categoryList as $idx=>$category) { + echo '
'.str_replace('_','',$category).'
'; + } + ?> +
+
+ + diff --git a/IPSLibrary/webfront/NetPlayer2/NetPlayer_RadioControl.php b/IPSLibrary/webfront/NetPlayer2/NetPlayer_RadioControl.php new file mode 100644 index 0000000..12dcaa3 --- /dev/null +++ b/IPSLibrary/webfront/NetPlayer2/NetPlayer_RadioControl.php @@ -0,0 +1,71 @@ + + * + * File kann in das WebFront eingebunden werden (zB. per iFrame) und ermöglicht das Abspielen diverser + * Web Radios. + * + * Die Definition der Radio Sender mit zugehöriger URL wird im File NetPlayer_Configuration.ips.php vorgenommen. + * + */ + /** @}*/ +?> + + + + + + + + + + + + + + +
+
+ $radioURL) { + echo '
'.$radioName.'
'; + $idx++; + $left = !$left; + } + ?> +
+
+ +
+
+
Play
+
Stop
+
+
+
Pause
+
+
+
+
+
+
Musik Player
+
+
+ + + + diff --git a/IPSLibrary/webfront/NetPlayer2/NetPlayer_Receiver.php b/IPSLibrary/webfront/NetPlayer2/NetPlayer_Receiver.php new file mode 100644 index 0000000..62f416f --- /dev/null +++ b/IPSLibrary/webfront/NetPlayer2/NetPlayer_Receiver.php @@ -0,0 +1,95 @@ + + * + * Empfangs Script um Requests (JQuery) der HTML Seiten zu bearbeiten. + * Das Script wird durch die Java Script Funktionen im File NetPlayer_Sender.php getriggert. + * + */ + + $id = $_GET['id']; + IPSUtils_Include ("NetPlayer.inc.php", "IPSLibrary::app::modules::NetPlayer2"); + + if ($id<>"rc_mp_current" and $id<>"rc_mp_status" and $id<>"rc_mp_length" and $id<>"rc_mp_interpret" and $id<>"rc_mp_album" and $id<>"rc_mp_titel") { + IPSLogger_Trc(__file__, "RECEIVED Command '$id'"); + } + + // Player Control + if ($id=="rc_mp_play") { + NetPlayer_Power(true); + } else if ($id=="rc_mp_last") { + NetPlayer_Prev(); + } else if ($id=="rc_mp_next") { + NetPlayer_Next(); + } else if ($id=="rc_mp_pause") { + NetPlayer_Pause(); + } else if ($id=="rc_mp_stop") { + NetPlayer_Power(false); + + // Player State and Data + } else if ($id=="rc_mp_titel") { + $player = NetPlayer_GetIPSComponentPlayer(); + $titel = $player->GetTrackName(); + //$titel = NetPlayer_GetMediaPlayerValue("Titel"); + $Interpret = GetValue(NP_ID_CDINTERPRET); + $titel = str_replace(trim($Interpret, " "), "", $titel); + $titel = trim ($titel,"? -"); + $titel = trim ($titel," -"); + echo htmlentities(html_entity_decode($titel), ENT_COMPAT, 'ISO-8859-1'); + } else if ($id=="rc_mp_current") { + echo NetPlayer_GetIPSComponentPlayer()->GetTrackPosition(); + //echo NetPlayer_GetMediaPlayerValue('Titelposition'); + } else if ($id=="rc_mp_status") { + echo GetValue(NP_ID_CONTROL); + //echo NetPlayer_GetMediaPlayerValue('Status'); + } else if ($id=="rc_mp_length") { + echo NetPlayer_GetIPSComponentPlayer()->GetTrackLength(); + //echo NetPlayer_GetMediaPlayerValue('Titellänge'); + } else if ($id=="rc_mp_interpret") { + echo htmlentities(GetValue(NP_ID_CDINTERPRET), ENT_COMPAT, 'ISO-8859-1'); + } else if ($id=="rc_mp_album") { + echo htmlentities(GetValue(NP_ID_CDALBUM), ENT_COMPAT, 'ISO-8859-1'); + + // Mediaplayer Source + } else if ($id=="rc_mp_player") { + NetPlayer_SwitchToMP3Player(); + } else if ($id=="rc_mp_select") { + NetPlayer_SwitchToMP3Selection(); + } else if ($id=="rc_mp_radio") { + NetPlayer_SwitchToRadio(); + + // CD Selection - List CDs in MP3 Repository + } else if (substr($id,0,5)=="rc_cd") { + NetPlayer_PlayDirectory($_GET['cd_path']); + } else if ($id=="rc_mp_cdselectprev") { + NetPlayer_NavigateCDBack(NP_COUNT_CDHTML); + } else if ($id=="rc_mp_cdselectnext") { + NetPlayer_NavigateCDForward(NP_COUNT_CDHTML); + } else if (substr($id,0,6)=="rc_cat") { + NetPlayer_SetCategory($_GET['cd_cat']); + } else if ($id=="rc_mp_cdselectroot") { + NetPlayer_SetCategory(''); + } else if ($id=="rc_mp_cdselectback") { + NetPlayer_SwitchToMP3Player(false); + } else if (substr($id,0,11)=="rc_mp_track") { + NetPlayer_SetPlayListPosition((int)$_GET['track']); + + // Mediaplayer Set Webradio Station + } else if (substr($id,0,11)=="rc_mp_radio") { + NetPlayer_PlayRadio($_GET['radiourl'], $_GET['radiotitel']); + } else if ($id=="rc_mp_radioselectprev") { + NetPlayer_NavigateRadioBack(NP_COUNT_RADIOHTML); + } else if ($id=="rc_mp_radioselectnext") { + NetPlayer_NavigateRadioForward(NP_COUNT_RADIOHTML); + + } else { + IPSLogger_Err(__file__, "Received Unknown Netplayer ObjID=".$id); + } + ; + /** @}*/ +?> \ No newline at end of file diff --git a/IPSLibrary/webfront/NetPlayer2/NetPlayer_Sender.php b/IPSLibrary/webfront/NetPlayer2/NetPlayer_Sender.php new file mode 100644 index 0000000..dd0495c --- /dev/null +++ b/IPSLibrary/webfront/NetPlayer2/NetPlayer_Sender.php @@ -0,0 +1,101 @@ + + * + * Java Script Funktionen (JQuery) zum Senden und Empfangen. + * + * Dieses Script File wird von den diversen HTML Seiten per INCLUDE eingebunden und ermöglicht + * das Senden und Empfangen von Daten ohne die Seite neu Laden zu müssen. + * + * Auf der IPS Seite werden die Requests vom File NetPlayer_Receiver.php verarbeitet. + * + */ + IPSUtils_Include ("NetPlayer.inc.php", "IPSLibrary::app::modules::NetPlayer2"); + + $agent = $_SERVER['HTTP_USER_AGENT']; + $mobile = (preg_match("@ipod@i", $agent) || preg_match("@iphone@i",$agent)); + + ?> + + + + + + + diff --git a/IPSLibrary/webfront/NetPlayer2/NetPlayer_Utils.php b/IPSLibrary/webfront/NetPlayer2/NetPlayer_Utils.php new file mode 100644 index 0000000..9c7f6c4 --- /dev/null +++ b/IPSLibrary/webfront/NetPlayer2/NetPlayer_Utils.php @@ -0,0 +1,154 @@ + + * + * Diverse Funktionen um die Daten von MP3 Player und Radio zu aktualisieren + * + */ + IPSUtils_Include ("NetPlayer.inc.php", "IPSLibrary::app::modules::NetPlayer2"); +?> + + diff --git a/IPSLibrary/webfront/NetPlayer2/jquery.min.js b/IPSLibrary/webfront/NetPlayer2/jquery.min.js new file mode 100644 index 0000000..b1ae21d --- /dev/null +++ b/IPSLibrary/webfront/NetPlayer2/jquery.min.js @@ -0,0 +1,19 @@ +/* + * jQuery JavaScript Library v1.3.2 + * http://jquery.com/ + * + * Copyright (c) 2009 John Resig + * Dual licensed under the MIT and GPL licenses. + * http://docs.jquery.com/License + * + * Date: 2009-02-19 17:34:21 -0500 (Thu, 19 Feb 2009) + * Revision: 6246 + */ +(function(){var l=this,g,y=l.jQuery,p=l.$,o=l.jQuery=l.$=function(E,F){return new o.fn.init(E,F)},D=/^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/,f=/^.[^:#\[\.,]*$/;o.fn=o.prototype={init:function(E,H){E=E||document;if(E.nodeType){this[0]=E;this.length=1;this.context=E;return this}if(typeof E==="string"){var G=D.exec(E);if(G&&(G[1]||!H)){if(G[1]){E=o.clean([G[1]],H)}else{var I=document.getElementById(G[3]);if(I&&I.id!=G[3]){return o().find(E)}var F=o(I||[]);F.context=document;F.selector=E;return F}}else{return o(H).find(E)}}else{if(o.isFunction(E)){return o(document).ready(E)}}if(E.selector&&E.context){this.selector=E.selector;this.context=E.context}return this.setArray(o.isArray(E)?E:o.makeArray(E))},selector:"",jquery:"1.3.2",size:function(){return this.length},get:function(E){return E===g?Array.prototype.slice.call(this):this[E]},pushStack:function(F,H,E){var G=o(F);G.prevObject=this;G.context=this.context;if(H==="find"){G.selector=this.selector+(this.selector?" ":"")+E}else{if(H){G.selector=this.selector+"."+H+"("+E+")"}}return G},setArray:function(E){this.length=0;Array.prototype.push.apply(this,E);return this},each:function(F,E){return o.each(this,F,E)},index:function(E){return o.inArray(E&&E.jquery?E[0]:E,this)},attr:function(F,H,G){var E=F;if(typeof F==="string"){if(H===g){return this[0]&&o[G||"attr"](this[0],F)}else{E={};E[F]=H}}return this.each(function(I){for(F in E){o.attr(G?this.style:this,F,o.prop(this,E[F],G,I,F))}})},css:function(E,F){if((E=="width"||E=="height")&&parseFloat(F)<0){F=g}return this.attr(E,F,"curCSS")},text:function(F){if(typeof F!=="object"&&F!=null){return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(F))}var E="";o.each(F||this,function(){o.each(this.childNodes,function(){if(this.nodeType!=8){E+=this.nodeType!=1?this.nodeValue:o.fn.text([this])}})});return E},wrapAll:function(E){if(this[0]){var F=o(E,this[0].ownerDocument).clone();if(this[0].parentNode){F.insertBefore(this[0])}F.map(function(){var G=this;while(G.firstChild){G=G.firstChild}return G}).append(this)}return this},wrapInner:function(E){return this.each(function(){o(this).contents().wrapAll(E)})},wrap:function(E){return this.each(function(){o(this).wrapAll(E)})},append:function(){return this.domManip(arguments,true,function(E){if(this.nodeType==1){this.appendChild(E)}})},prepend:function(){return this.domManip(arguments,true,function(E){if(this.nodeType==1){this.insertBefore(E,this.firstChild)}})},before:function(){return this.domManip(arguments,false,function(E){this.parentNode.insertBefore(E,this)})},after:function(){return this.domManip(arguments,false,function(E){this.parentNode.insertBefore(E,this.nextSibling)})},end:function(){return this.prevObject||o([])},push:[].push,sort:[].sort,splice:[].splice,find:function(E){if(this.length===1){var F=this.pushStack([],"find",E);F.length=0;o.find(E,this[0],F);return F}else{return this.pushStack(o.unique(o.map(this,function(G){return o.find(E,G)})),"find",E)}},clone:function(G){var E=this.map(function(){if(!o.support.noCloneEvent&&!o.isXMLDoc(this)){var I=this.outerHTML;if(!I){var J=this.ownerDocument.createElement("div");J.appendChild(this.cloneNode(true));I=J.innerHTML}return o.clean([I.replace(/ jQuery\d+="(?:\d+|null)"/g,"").replace(/^\s*/,"")])[0]}else{return this.cloneNode(true)}});if(G===true){var H=this.find("*").andSelf(),F=0;E.find("*").andSelf().each(function(){if(this.nodeName!==H[F].nodeName){return}var I=o.data(H[F],"events");for(var K in I){for(var J in I[K]){o.event.add(this,K,I[K][J],I[K][J].data)}}F++})}return E},filter:function(E){return this.pushStack(o.isFunction(E)&&o.grep(this,function(G,F){return E.call(G,F)})||o.multiFilter(E,o.grep(this,function(F){return F.nodeType===1})),"filter",E)},closest:function(E){var G=o.expr.match.POS.test(E)?o(E):null,F=0;return this.map(function(){var H=this;while(H&&H.ownerDocument){if(G?G.index(H)>-1:o(H).is(E)){o.data(H,"closest",F);return H}H=H.parentNode;F++}})},not:function(E){if(typeof E==="string"){if(f.test(E)){return this.pushStack(o.multiFilter(E,this,true),"not",E)}else{E=o.multiFilter(E,this)}}var F=E.length&&E[E.length-1]!==g&&!E.nodeType;return this.filter(function(){return F?o.inArray(this,E)<0:this!=E})},add:function(E){return this.pushStack(o.unique(o.merge(this.get(),typeof E==="string"?o(E):o.makeArray(E))))},is:function(E){return !!E&&o.multiFilter(E,this).length>0},hasClass:function(E){return !!E&&this.is("."+E)},val:function(K){if(K===g){var E=this[0];if(E){if(o.nodeName(E,"option")){return(E.attributes.value||{}).specified?E.value:E.text}if(o.nodeName(E,"select")){var I=E.selectedIndex,L=[],M=E.options,H=E.type=="select-one";if(I<0){return null}for(var F=H?I:0,J=H?I+1:M.length;F=0||o.inArray(this.name,K)>=0)}else{if(o.nodeName(this,"select")){var N=o.makeArray(K);o("option",this).each(function(){this.selected=(o.inArray(this.value,N)>=0||o.inArray(this.text,N)>=0)});if(!N.length){this.selectedIndex=-1}}else{this.value=K}}})},html:function(E){return E===g?(this[0]?this[0].innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g,""):null):this.empty().append(E)},replaceWith:function(E){return this.after(E).remove()},eq:function(E){return this.slice(E,+E+1)},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,arguments),"slice",Array.prototype.slice.call(arguments).join(","))},map:function(E){return this.pushStack(o.map(this,function(G,F){return E.call(G,F,G)}))},andSelf:function(){return this.add(this.prevObject)},domManip:function(J,M,L){if(this[0]){var I=(this[0].ownerDocument||this[0]).createDocumentFragment(),F=o.clean(J,(this[0].ownerDocument||this[0]),I),H=I.firstChild;if(H){for(var G=0,E=this.length;G1||G>0?I.cloneNode(true):I)}}if(F){o.each(F,z)}}return this;function K(N,O){return M&&o.nodeName(N,"table")&&o.nodeName(O,"tr")?(N.getElementsByTagName("tbody")[0]||N.appendChild(N.ownerDocument.createElement("tbody"))):N}}};o.fn.init.prototype=o.fn;function z(E,F){if(F.src){o.ajax({url:F.src,async:false,dataType:"script"})}else{o.globalEval(F.text||F.textContent||F.innerHTML||"")}if(F.parentNode){F.parentNode.removeChild(F)}}function e(){return +new Date}o.extend=o.fn.extend=function(){var J=arguments[0]||{},H=1,I=arguments.length,E=false,G;if(typeof J==="boolean"){E=J;J=arguments[1]||{};H=2}if(typeof J!=="object"&&!o.isFunction(J)){J={}}if(I==H){J=this;--H}for(;H-1}},swap:function(H,G,I){var E={};for(var F in G){E[F]=H.style[F];H.style[F]=G[F]}I.call(H);for(var F in G){H.style[F]=E[F]}},css:function(H,F,J,E){if(F=="width"||F=="height"){var L,G={position:"absolute",visibility:"hidden",display:"block"},K=F=="width"?["Left","Right"]:["Top","Bottom"];function I(){L=F=="width"?H.offsetWidth:H.offsetHeight;if(E==="border"){return}o.each(K,function(){if(!E){L-=parseFloat(o.curCSS(H,"padding"+this,true))||0}if(E==="margin"){L+=parseFloat(o.curCSS(H,"margin"+this,true))||0}else{L-=parseFloat(o.curCSS(H,"border"+this+"Width",true))||0}})}if(H.offsetWidth!==0){I()}else{o.swap(H,G,I)}return Math.max(0,Math.round(L))}return o.curCSS(H,F,J)},curCSS:function(I,F,G){var L,E=I.style;if(F=="opacity"&&!o.support.opacity){L=o.attr(E,"opacity");return L==""?"1":L}if(F.match(/float/i)){F=w}if(!G&&E&&E[F]){L=E[F]}else{if(q.getComputedStyle){if(F.match(/float/i)){F="float"}F=F.replace(/([A-Z])/g,"-$1").toLowerCase();var M=q.getComputedStyle(I,null);if(M){L=M.getPropertyValue(F)}if(F=="opacity"&&L==""){L="1"}}else{if(I.currentStyle){var J=F.replace(/\-(\w)/g,function(N,O){return O.toUpperCase()});L=I.currentStyle[F]||I.currentStyle[J];if(!/^\d+(px)?$/i.test(L)&&/^\d/.test(L)){var H=E.left,K=I.runtimeStyle.left;I.runtimeStyle.left=I.currentStyle.left;E.left=L||0;L=E.pixelLeft+"px";E.left=H;I.runtimeStyle.left=K}}}}return L},clean:function(F,K,I){K=K||document;if(typeof K.createElement==="undefined"){K=K.ownerDocument||K[0]&&K[0].ownerDocument||document}if(!I&&F.length===1&&typeof F[0]==="string"){var H=/^<(\w+)\s*\/?>$/.exec(F[0]);if(H){return[K.createElement(H[1])]}}var G=[],E=[],L=K.createElement("div");o.each(F,function(P,S){if(typeof S==="number"){S+=""}if(!S){return}if(typeof S==="string"){S=S.replace(/(<(\w+)[^>]*?)\/>/g,function(U,V,T){return T.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i)?U:V+">"});var O=S.replace(/^\s+/,"").substring(0,10).toLowerCase();var Q=!O.indexOf("",""]||!O.indexOf("",""]||O.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"","
"]||!O.indexOf("",""]||(!O.indexOf("",""]||!O.indexOf("",""]||!o.support.htmlSerialize&&[1,"div
","
"]||[0,"",""];L.innerHTML=Q[1]+S+Q[2];while(Q[0]--){L=L.lastChild}if(!o.support.tbody){var R=/"&&!R?L.childNodes:[];for(var M=N.length-1;M>=0;--M){if(o.nodeName(N[M],"tbody")&&!N[M].childNodes.length){N[M].parentNode.removeChild(N[M])}}}if(!o.support.leadingWhitespace&&/^\s/.test(S)){L.insertBefore(K.createTextNode(S.match(/^\s*/)[0]),L.firstChild)}S=o.makeArray(L.childNodes)}if(S.nodeType){G.push(S)}else{G=o.merge(G,S)}});if(I){for(var J=0;G[J];J++){if(o.nodeName(G[J],"script")&&(!G[J].type||G[J].type.toLowerCase()==="text/javascript")){E.push(G[J].parentNode?G[J].parentNode.removeChild(G[J]):G[J])}else{if(G[J].nodeType===1){G.splice.apply(G,[J+1,0].concat(o.makeArray(G[J].getElementsByTagName("script"))))}I.appendChild(G[J])}}return E}return G},attr:function(J,G,K){if(!J||J.nodeType==3||J.nodeType==8){return g}var H=!o.isXMLDoc(J),L=K!==g;G=H&&o.props[G]||G;if(J.tagName){var F=/href|src|style/.test(G);if(G=="selected"&&J.parentNode){J.parentNode.selectedIndex}if(G in J&&H&&!F){if(L){if(G=="type"&&o.nodeName(J,"input")&&J.parentNode){throw"type property can't be changed"}J[G]=K}if(o.nodeName(J,"form")&&J.getAttributeNode(G)){return J.getAttributeNode(G).nodeValue}if(G=="tabIndex"){var I=J.getAttributeNode("tabIndex");return I&&I.specified?I.value:J.nodeName.match(/(button|input|object|select|textarea)/i)?0:J.nodeName.match(/^(a|area)$/i)&&J.href?0:g}return J[G]}if(!o.support.style&&H&&G=="style"){return o.attr(J.style,"cssText",K)}if(L){J.setAttribute(G,""+K)}var E=!o.support.hrefNormalized&&H&&F?J.getAttribute(G,2):J.getAttribute(G);return E===null?g:E}if(!o.support.opacity&&G=="opacity"){if(L){J.zoom=1;J.filter=(J.filter||"").replace(/alpha\([^)]*\)/,"")+(parseInt(K)+""=="NaN"?"":"alpha(opacity="+K*100+")")}return J.filter&&J.filter.indexOf("opacity=")>=0?(parseFloat(J.filter.match(/opacity=([^)]*)/)[1])/100)+"":""}G=G.replace(/-([a-z])/ig,function(M,N){return N.toUpperCase()});if(L){J[G]=K}return J[G]},trim:function(E){return(E||"").replace(/^\s+|\s+$/g,"")},makeArray:function(G){var E=[];if(G!=null){var F=G.length;if(F==null||typeof G==="string"||o.isFunction(G)||G.setInterval){E[0]=G}else{while(F){E[--F]=G[F]}}}return E},inArray:function(G,H){for(var E=0,F=H.length;E0?this.clone(true):this).get();o.fn[F].apply(o(L[K]),I);J=J.concat(I)}return this.pushStack(J,E,G)}});o.each({removeAttr:function(E){o.attr(this,E,"");if(this.nodeType==1){this.removeAttribute(E)}},addClass:function(E){o.className.add(this,E)},removeClass:function(E){o.className.remove(this,E)},toggleClass:function(F,E){if(typeof E!=="boolean"){E=!o.className.has(this,F)}o.className[E?"add":"remove"](this,F)},remove:function(E){if(!E||o.filter(E,[this]).length){o("*",this).add([this]).each(function(){o.event.remove(this);o.removeData(this)});if(this.parentNode){this.parentNode.removeChild(this)}}},empty:function(){o(this).children().remove();while(this.firstChild){this.removeChild(this.firstChild)}}},function(E,F){o.fn[E]=function(){return this.each(F,arguments)}});function j(E,F){return E[0]&&parseInt(o.curCSS(E[0],F,true),10)||0}var h="jQuery"+e(),v=0,A={};o.extend({cache:{},data:function(F,E,G){F=F==l?A:F;var H=F[h];if(!H){H=F[h]=++v}if(E&&!o.cache[H]){o.cache[H]={}}if(G!==g){o.cache[H][E]=G}return E?o.cache[H][E]:H},removeData:function(F,E){F=F==l?A:F;var H=F[h];if(E){if(o.cache[H]){delete o.cache[H][E];E="";for(E in o.cache[H]){break}if(!E){o.removeData(F)}}}else{try{delete F[h]}catch(G){if(F.removeAttribute){F.removeAttribute(h)}}delete o.cache[H]}},queue:function(F,E,H){if(F){E=(E||"fx")+"queue";var G=o.data(F,E);if(!G||o.isArray(H)){G=o.data(F,E,o.makeArray(H))}else{if(H){G.push(H)}}}return G},dequeue:function(H,G){var E=o.queue(H,G),F=E.shift();if(!G||G==="fx"){F=E[0]}if(F!==g){F.call(H)}}});o.fn.extend({data:function(E,G){var H=E.split(".");H[1]=H[1]?"."+H[1]:"";if(G===g){var F=this.triggerHandler("getData"+H[1]+"!",[H[0]]);if(F===g&&this.length){F=o.data(this[0],E)}return F===g&&H[1]?this.data(H[0]):F}else{return this.trigger("setData"+H[1]+"!",[H[0],G]).each(function(){o.data(this,E,G)})}},removeData:function(E){return this.each(function(){o.removeData(this,E)})},queue:function(E,F){if(typeof E!=="string"){F=E;E="fx"}if(F===g){return o.queue(this[0],E)}return this.each(function(){var G=o.queue(this,E,F);if(E=="fx"&&G.length==1){G[0].call(this)}})},dequeue:function(E){return this.each(function(){o.dequeue(this,E)})}}); +/* + * Sizzle CSS Selector Engine - v0.9.3 + * Copyright 2009, The Dojo Foundation + * Released under the MIT, BSD, and GPL Licenses. + * More information: http://sizzlejs.com/ + */ +(function(){var R=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g,L=0,H=Object.prototype.toString;var F=function(Y,U,ab,ac){ab=ab||[];U=U||document;if(U.nodeType!==1&&U.nodeType!==9){return[]}if(!Y||typeof Y!=="string"){return ab}var Z=[],W,af,ai,T,ad,V,X=true;R.lastIndex=0;while((W=R.exec(Y))!==null){Z.push(W[1]);if(W[2]){V=RegExp.rightContext;break}}if(Z.length>1&&M.exec(Y)){if(Z.length===2&&I.relative[Z[0]]){af=J(Z[0]+Z[1],U)}else{af=I.relative[Z[0]]?[U]:F(Z.shift(),U);while(Z.length){Y=Z.shift();if(I.relative[Y]){Y+=Z.shift()}af=J(Y,af)}}}else{var ae=ac?{expr:Z.pop(),set:E(ac)}:F.find(Z.pop(),Z.length===1&&U.parentNode?U.parentNode:U,Q(U));af=F.filter(ae.expr,ae.set);if(Z.length>0){ai=E(af)}else{X=false}while(Z.length){var ah=Z.pop(),ag=ah;if(!I.relative[ah]){ah=""}else{ag=Z.pop()}if(ag==null){ag=U}I.relative[ah](ai,ag,Q(U))}}if(!ai){ai=af}if(!ai){throw"Syntax error, unrecognized expression: "+(ah||Y)}if(H.call(ai)==="[object Array]"){if(!X){ab.push.apply(ab,ai)}else{if(U.nodeType===1){for(var aa=0;ai[aa]!=null;aa++){if(ai[aa]&&(ai[aa]===true||ai[aa].nodeType===1&&K(U,ai[aa]))){ab.push(af[aa])}}}else{for(var aa=0;ai[aa]!=null;aa++){if(ai[aa]&&ai[aa].nodeType===1){ab.push(af[aa])}}}}}else{E(ai,ab)}if(V){F(V,U,ab,ac);if(G){hasDuplicate=false;ab.sort(G);if(hasDuplicate){for(var aa=1;aa":function(Z,U,aa){var X=typeof U==="string";if(X&&!/\W/.test(U)){U=aa?U:U.toUpperCase();for(var V=0,T=Z.length;V=0)){if(!V){T.push(Y)}}else{if(V){U[X]=false}}}}return false},ID:function(T){return T[1].replace(/\\/g,"")},TAG:function(U,T){for(var V=0;T[V]===false;V++){}return T[V]&&Q(T[V])?U[1]:U[1].toUpperCase()},CHILD:function(T){if(T[1]=="nth"){var U=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(T[2]=="even"&&"2n"||T[2]=="odd"&&"2n+1"||!/\D/.test(T[2])&&"0n+"+T[2]||T[2]);T[2]=(U[1]+(U[2]||1))-0;T[3]=U[3]-0}T[0]=L++;return T},ATTR:function(X,U,V,T,Y,Z){var W=X[1].replace(/\\/g,"");if(!Z&&I.attrMap[W]){X[1]=I.attrMap[W]}if(X[2]==="~="){X[4]=" "+X[4]+" "}return X},PSEUDO:function(X,U,V,T,Y){if(X[1]==="not"){if(X[3].match(R).length>1||/^\w/.test(X[3])){X[3]=F(X[3],null,null,U)}else{var W=F.filter(X[3],U,V,true^Y);if(!V){T.push.apply(T,W)}return false}}else{if(I.match.POS.test(X[0])||I.match.CHILD.test(X[0])){return true}}return X},POS:function(T){T.unshift(true);return T}},filters:{enabled:function(T){return T.disabled===false&&T.type!=="hidden"},disabled:function(T){return T.disabled===true},checked:function(T){return T.checked===true},selected:function(T){T.parentNode.selectedIndex;return T.selected===true},parent:function(T){return !!T.firstChild},empty:function(T){return !T.firstChild},has:function(V,U,T){return !!F(T[3],V).length},header:function(T){return/h\d/i.test(T.nodeName)},text:function(T){return"text"===T.type},radio:function(T){return"radio"===T.type},checkbox:function(T){return"checkbox"===T.type},file:function(T){return"file"===T.type},password:function(T){return"password"===T.type},submit:function(T){return"submit"===T.type},image:function(T){return"image"===T.type},reset:function(T){return"reset"===T.type},button:function(T){return"button"===T.type||T.nodeName.toUpperCase()==="BUTTON"},input:function(T){return/input|select|textarea|button/i.test(T.nodeName)}},setFilters:{first:function(U,T){return T===0},last:function(V,U,T,W){return U===W.length-1},even:function(U,T){return T%2===0},odd:function(U,T){return T%2===1},lt:function(V,U,T){return UT[3]-0},nth:function(V,U,T){return T[3]-0==U},eq:function(V,U,T){return T[3]-0==U}},filter:{PSEUDO:function(Z,V,W,aa){var U=V[1],X=I.filters[U];if(X){return X(Z,W,V,aa)}else{if(U==="contains"){return(Z.textContent||Z.innerText||"").indexOf(V[3])>=0}else{if(U==="not"){var Y=V[3];for(var W=0,T=Y.length;W=0)}}},ID:function(U,T){return U.nodeType===1&&U.getAttribute("id")===T},TAG:function(U,T){return(T==="*"&&U.nodeType===1)||U.nodeName===T},CLASS:function(U,T){return(" "+(U.className||U.getAttribute("class"))+" ").indexOf(T)>-1},ATTR:function(Y,W){var V=W[1],T=I.attrHandle[V]?I.attrHandle[V](Y):Y[V]!=null?Y[V]:Y.getAttribute(V),Z=T+"",X=W[2],U=W[4];return T==null?X==="!=":X==="="?Z===U:X==="*="?Z.indexOf(U)>=0:X==="~="?(" "+Z+" ").indexOf(U)>=0:!U?Z&&T!==false:X==="!="?Z!=U:X==="^="?Z.indexOf(U)===0:X==="$="?Z.substr(Z.length-U.length)===U:X==="|="?Z===U||Z.substr(0,U.length+1)===U+"-":false},POS:function(X,U,V,Y){var T=U[2],W=I.setFilters[T];if(W){return W(X,V,U,Y)}}}};var M=I.match.POS;for(var O in I.match){I.match[O]=RegExp(I.match[O].source+/(?![^\[]*\])(?![^\(]*\))/.source)}var E=function(U,T){U=Array.prototype.slice.call(U);if(T){T.push.apply(T,U);return T}return U};try{Array.prototype.slice.call(document.documentElement.childNodes)}catch(N){E=function(X,W){var U=W||[];if(H.call(X)==="[object Array]"){Array.prototype.push.apply(U,X)}else{if(typeof X.length==="number"){for(var V=0,T=X.length;V";var T=document.documentElement;T.insertBefore(U,T.firstChild);if(!!document.getElementById(V)){I.find.ID=function(X,Y,Z){if(typeof Y.getElementById!=="undefined"&&!Z){var W=Y.getElementById(X[1]);return W?W.id===X[1]||typeof W.getAttributeNode!=="undefined"&&W.getAttributeNode("id").nodeValue===X[1]?[W]:g:[]}};I.filter.ID=function(Y,W){var X=typeof Y.getAttributeNode!=="undefined"&&Y.getAttributeNode("id");return Y.nodeType===1&&X&&X.nodeValue===W}}T.removeChild(U)})();(function(){var T=document.createElement("div");T.appendChild(document.createComment(""));if(T.getElementsByTagName("*").length>0){I.find.TAG=function(U,Y){var X=Y.getElementsByTagName(U[1]);if(U[1]==="*"){var W=[];for(var V=0;X[V];V++){if(X[V].nodeType===1){W.push(X[V])}}X=W}return X}}T.innerHTML="";if(T.firstChild&&typeof T.firstChild.getAttribute!=="undefined"&&T.firstChild.getAttribute("href")!=="#"){I.attrHandle.href=function(U){return U.getAttribute("href",2)}}})();if(document.querySelectorAll){(function(){var T=F,U=document.createElement("div");U.innerHTML="

";if(U.querySelectorAll&&U.querySelectorAll(".TEST").length===0){return}F=function(Y,X,V,W){X=X||document;if(!W&&X.nodeType===9&&!Q(X)){try{return E(X.querySelectorAll(Y),V)}catch(Z){}}return T(Y,X,V,W)};F.find=T.find;F.filter=T.filter;F.selectors=T.selectors;F.matches=T.matches})()}if(document.getElementsByClassName&&document.documentElement.getElementsByClassName){(function(){var T=document.createElement("div");T.innerHTML="
";if(T.getElementsByClassName("e").length===0){return}T.lastChild.className="e";if(T.getElementsByClassName("e").length===1){return}I.order.splice(1,0,"CLASS");I.find.CLASS=function(U,V,W){if(typeof V.getElementsByClassName!=="undefined"&&!W){return V.getElementsByClassName(U[1])}}})()}function P(U,Z,Y,ad,aa,ac){var ab=U=="previousSibling"&&!ac;for(var W=0,V=ad.length;W0){X=T;break}}}T=T[U]}ad[W]=X}}}var K=document.compareDocumentPosition?function(U,T){return U.compareDocumentPosition(T)&16}:function(U,T){return U!==T&&(U.contains?U.contains(T):true)};var Q=function(T){return T.nodeType===9&&T.documentElement.nodeName!=="HTML"||!!T.ownerDocument&&Q(T.ownerDocument)};var J=function(T,aa){var W=[],X="",Y,V=aa.nodeType?[aa]:aa;while((Y=I.match.PSEUDO.exec(T))){X+=Y[0];T=T.replace(I.match.PSEUDO,"")}T=I.relative[T]?T+"*":T;for(var Z=0,U=V.length;Z0||T.offsetHeight>0};F.selectors.filters.animated=function(T){return o.grep(o.timers,function(U){return T===U.elem}).length};o.multiFilter=function(V,T,U){if(U){V=":not("+V+")"}return F.matches(V,T)};o.dir=function(V,U){var T=[],W=V[U];while(W&&W!=document){if(W.nodeType==1){T.push(W)}W=W[U]}return T};o.nth=function(X,T,V,W){T=T||1;var U=0;for(;X;X=X[V]){if(X.nodeType==1&&++U==T){break}}return X};o.sibling=function(V,U){var T=[];for(;V;V=V.nextSibling){if(V.nodeType==1&&V!=U){T.push(V)}}return T};return;l.Sizzle=F})();o.event={add:function(I,F,H,K){if(I.nodeType==3||I.nodeType==8){return}if(I.setInterval&&I!=l){I=l}if(!H.guid){H.guid=this.guid++}if(K!==g){var G=H;H=this.proxy(G);H.data=K}var E=o.data(I,"events")||o.data(I,"events",{}),J=o.data(I,"handle")||o.data(I,"handle",function(){return typeof o!=="undefined"&&!o.event.triggered?o.event.handle.apply(arguments.callee.elem,arguments):g});J.elem=I;o.each(F.split(/\s+/),function(M,N){var O=N.split(".");N=O.shift();H.type=O.slice().sort().join(".");var L=E[N];if(o.event.specialAll[N]){o.event.specialAll[N].setup.call(I,K,O)}if(!L){L=E[N]={};if(!o.event.special[N]||o.event.special[N].setup.call(I,K,O)===false){if(I.addEventListener){I.addEventListener(N,J,false)}else{if(I.attachEvent){I.attachEvent("on"+N,J)}}}}L[H.guid]=H;o.event.global[N]=true});I=null},guid:1,global:{},remove:function(K,H,J){if(K.nodeType==3||K.nodeType==8){return}var G=o.data(K,"events"),F,E;if(G){if(H===g||(typeof H==="string"&&H.charAt(0)==".")){for(var I in G){this.remove(K,I+(H||""))}}else{if(H.type){J=H.handler;H=H.type}o.each(H.split(/\s+/),function(M,O){var Q=O.split(".");O=Q.shift();var N=RegExp("(^|\\.)"+Q.slice().sort().join(".*\\.")+"(\\.|$)");if(G[O]){if(J){delete G[O][J.guid]}else{for(var P in G[O]){if(N.test(G[O][P].type)){delete G[O][P]}}}if(o.event.specialAll[O]){o.event.specialAll[O].teardown.call(K,Q)}for(F in G[O]){break}if(!F){if(!o.event.special[O]||o.event.special[O].teardown.call(K,Q)===false){if(K.removeEventListener){K.removeEventListener(O,o.data(K,"handle"),false)}else{if(K.detachEvent){K.detachEvent("on"+O,o.data(K,"handle"))}}}F=null;delete G[O]}}})}for(F in G){break}if(!F){var L=o.data(K,"handle");if(L){L.elem=null}o.removeData(K,"events");o.removeData(K,"handle")}}},trigger:function(I,K,H,E){var G=I.type||I;if(!E){I=typeof I==="object"?I[h]?I:o.extend(o.Event(G),I):o.Event(G);if(G.indexOf("!")>=0){I.type=G=G.slice(0,-1);I.exclusive=true}if(!H){I.stopPropagation();if(this.global[G]){o.each(o.cache,function(){if(this.events&&this.events[G]){o.event.trigger(I,K,this.handle.elem)}})}}if(!H||H.nodeType==3||H.nodeType==8){return g}I.result=g;I.target=H;K=o.makeArray(K);K.unshift(I)}I.currentTarget=H;var J=o.data(H,"handle");if(J){J.apply(H,K)}if((!H[G]||(o.nodeName(H,"a")&&G=="click"))&&H["on"+G]&&H["on"+G].apply(H,K)===false){I.result=false}if(!E&&H[G]&&!I.isDefaultPrevented()&&!(o.nodeName(H,"a")&&G=="click")){this.triggered=true;try{H[G]()}catch(L){}}this.triggered=false;if(!I.isPropagationStopped()){var F=H.parentNode||H.ownerDocument;if(F){o.event.trigger(I,K,F,true)}}},handle:function(K){var J,E;K=arguments[0]=o.event.fix(K||l.event);K.currentTarget=this;var L=K.type.split(".");K.type=L.shift();J=!L.length&&!K.exclusive;var I=RegExp("(^|\\.)"+L.slice().sort().join(".*\\.")+"(\\.|$)");E=(o.data(this,"events")||{})[K.type];for(var G in E){var H=E[G];if(J||I.test(H.type)){K.handler=H;K.data=H.data;var F=H.apply(this,arguments);if(F!==g){K.result=F;if(F===false){K.preventDefault();K.stopPropagation()}}if(K.isImmediatePropagationStopped()){break}}}},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),fix:function(H){if(H[h]){return H}var F=H;H=o.Event(F);for(var G=this.props.length,J;G;){J=this.props[--G];H[J]=F[J]}if(!H.target){H.target=H.srcElement||document}if(H.target.nodeType==3){H.target=H.target.parentNode}if(!H.relatedTarget&&H.fromElement){H.relatedTarget=H.fromElement==H.target?H.toElement:H.fromElement}if(H.pageX==null&&H.clientX!=null){var I=document.documentElement,E=document.body;H.pageX=H.clientX+(I&&I.scrollLeft||E&&E.scrollLeft||0)-(I.clientLeft||0);H.pageY=H.clientY+(I&&I.scrollTop||E&&E.scrollTop||0)-(I.clientTop||0)}if(!H.which&&((H.charCode||H.charCode===0)?H.charCode:H.keyCode)){H.which=H.charCode||H.keyCode}if(!H.metaKey&&H.ctrlKey){H.metaKey=H.ctrlKey}if(!H.which&&H.button){H.which=(H.button&1?1:(H.button&2?3:(H.button&4?2:0)))}return H},proxy:function(F,E){E=E||function(){return F.apply(this,arguments)};E.guid=F.guid=F.guid||E.guid||this.guid++;return E},special:{ready:{setup:B,teardown:function(){}}},specialAll:{live:{setup:function(E,F){o.event.add(this,F[0],c)},teardown:function(G){if(G.length){var E=0,F=RegExp("(^|\\.)"+G[0]+"(\\.|$)");o.each((o.data(this,"events").live||{}),function(){if(F.test(this.type)){E++}});if(E<1){o.event.remove(this,G[0],c)}}}}}};o.Event=function(E){if(!this.preventDefault){return new o.Event(E)}if(E&&E.type){this.originalEvent=E;this.type=E.type}else{this.type=E}this.timeStamp=e();this[h]=true};function k(){return false}function u(){return true}o.Event.prototype={preventDefault:function(){this.isDefaultPrevented=u;var E=this.originalEvent;if(!E){return}if(E.preventDefault){E.preventDefault()}E.returnValue=false},stopPropagation:function(){this.isPropagationStopped=u;var E=this.originalEvent;if(!E){return}if(E.stopPropagation){E.stopPropagation()}E.cancelBubble=true},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=u;this.stopPropagation()},isDefaultPrevented:k,isPropagationStopped:k,isImmediatePropagationStopped:k};var a=function(F){var E=F.relatedTarget;while(E&&E!=this){try{E=E.parentNode}catch(G){E=this}}if(E!=this){F.type=F.data;o.event.handle.apply(this,arguments)}};o.each({mouseover:"mouseenter",mouseout:"mouseleave"},function(F,E){o.event.special[E]={setup:function(){o.event.add(this,F,a,E)},teardown:function(){o.event.remove(this,F,a)}}});o.fn.extend({bind:function(F,G,E){return F=="unload"?this.one(F,G,E):this.each(function(){o.event.add(this,F,E||G,E&&G)})},one:function(G,H,F){var E=o.event.proxy(F||H,function(I){o(this).unbind(I,E);return(F||H).apply(this,arguments)});return this.each(function(){o.event.add(this,G,E,F&&H)})},unbind:function(F,E){return this.each(function(){o.event.remove(this,F,E)})},trigger:function(E,F){return this.each(function(){o.event.trigger(E,F,this)})},triggerHandler:function(E,G){if(this[0]){var F=o.Event(E);F.preventDefault();F.stopPropagation();o.event.trigger(F,G,this[0]);return F.result}},toggle:function(G){var E=arguments,F=1;while(F=0){var E=G.slice(I,G.length);G=G.slice(0,I)}var H="GET";if(J){if(o.isFunction(J)){K=J;J=null}else{if(typeof J==="object"){J=o.param(J);H="POST"}}}var F=this;o.ajax({url:G,type:H,dataType:"html",data:J,complete:function(M,L){if(L=="success"||L=="notmodified"){F.html(E?o("
").append(M.responseText.replace(//g,"")).find(E):M.responseText)}if(K){F.each(K,[M.responseText,L,M])}}});return this},serialize:function(){return o.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?o.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password|search/i.test(this.type))}).map(function(E,F){var G=o(this).val();return G==null?null:o.isArray(G)?o.map(G,function(I,H){return{name:F.name,value:I}}):{name:F.name,value:G}}).get()}});o.each("ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","),function(E,F){o.fn[F]=function(G){return this.bind(F,G)}});var r=e();o.extend({get:function(E,G,H,F){if(o.isFunction(G)){H=G;G=null}return o.ajax({type:"GET",url:E,data:G,success:H,dataType:F})},getScript:function(E,F){return o.get(E,null,F,"script")},getJSON:function(E,F,G){return o.get(E,F,G,"json")},post:function(E,G,H,F){if(o.isFunction(G)){H=G;G={}}return o.ajax({type:"POST",url:E,data:G,success:H,dataType:F})},ajaxSetup:function(E){o.extend(o.ajaxSettings,E)},ajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:function(){return l.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest()},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},ajax:function(M){M=o.extend(true,M,o.extend(true,{},o.ajaxSettings,M));var W,F=/=\?(&|$)/g,R,V,G=M.type.toUpperCase();if(M.data&&M.processData&&typeof M.data!=="string"){M.data=o.param(M.data)}if(M.dataType=="jsonp"){if(G=="GET"){if(!M.url.match(F)){M.url+=(M.url.match(/\?/)?"&":"?")+(M.jsonp||"callback")+"=?"}}else{if(!M.data||!M.data.match(F)){M.data=(M.data?M.data+"&":"")+(M.jsonp||"callback")+"=?"}}M.dataType="json"}if(M.dataType=="json"&&(M.data&&M.data.match(F)||M.url.match(F))){W="jsonp"+r++;if(M.data){M.data=(M.data+"").replace(F,"="+W+"$1")}M.url=M.url.replace(F,"="+W+"$1");M.dataType="script";l[W]=function(X){V=X;I();L();l[W]=g;try{delete l[W]}catch(Y){}if(H){H.removeChild(T)}}}if(M.dataType=="script"&&M.cache==null){M.cache=false}if(M.cache===false&&G=="GET"){var E=e();var U=M.url.replace(/(\?|&)_=.*?(&|$)/,"$1_="+E+"$2");M.url=U+((U==M.url)?(M.url.match(/\?/)?"&":"?")+"_="+E:"")}if(M.data&&G=="GET"){M.url+=(M.url.match(/\?/)?"&":"?")+M.data;M.data=null}if(M.global&&!o.active++){o.event.trigger("ajaxStart")}var Q=/^(\w+:)?\/\/([^\/?#]+)/.exec(M.url);if(M.dataType=="script"&&G=="GET"&&Q&&(Q[1]&&Q[1]!=location.protocol||Q[2]!=location.host)){var H=document.getElementsByTagName("head")[0];var T=document.createElement("script");T.src=M.url;if(M.scriptCharset){T.charset=M.scriptCharset}if(!W){var O=false;T.onload=T.onreadystatechange=function(){if(!O&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){O=true;I();L();T.onload=T.onreadystatechange=null;H.removeChild(T)}}}H.appendChild(T);return g}var K=false;var J=M.xhr();if(M.username){J.open(G,M.url,M.async,M.username,M.password)}else{J.open(G,M.url,M.async)}try{if(M.data){J.setRequestHeader("Content-Type",M.contentType)}if(M.ifModified){J.setRequestHeader("If-Modified-Since",o.lastModified[M.url]||"Thu, 01 Jan 1970 00:00:00 GMT")}J.setRequestHeader("X-Requested-With","XMLHttpRequest");J.setRequestHeader("Accept",M.dataType&&M.accepts[M.dataType]?M.accepts[M.dataType]+", */*":M.accepts._default)}catch(S){}if(M.beforeSend&&M.beforeSend(J,M)===false){if(M.global&&!--o.active){o.event.trigger("ajaxStop")}J.abort();return false}if(M.global){o.event.trigger("ajaxSend",[J,M])}var N=function(X){if(J.readyState==0){if(P){clearInterval(P);P=null;if(M.global&&!--o.active){o.event.trigger("ajaxStop")}}}else{if(!K&&J&&(J.readyState==4||X=="timeout")){K=true;if(P){clearInterval(P);P=null}R=X=="timeout"?"timeout":!o.httpSuccess(J)?"error":M.ifModified&&o.httpNotModified(J,M.url)?"notmodified":"success";if(R=="success"){try{V=o.httpData(J,M.dataType,M)}catch(Z){R="parsererror"}}if(R=="success"){var Y;try{Y=J.getResponseHeader("Last-Modified")}catch(Z){}if(M.ifModified&&Y){o.lastModified[M.url]=Y}if(!W){I()}}else{o.handleError(M,J,R)}L();if(X){J.abort()}if(M.async){J=null}}}};if(M.async){var P=setInterval(N,13);if(M.timeout>0){setTimeout(function(){if(J&&!K){N("timeout")}},M.timeout)}}try{J.send(M.data)}catch(S){o.handleError(M,J,null,S)}if(!M.async){N()}function I(){if(M.success){M.success(V,R)}if(M.global){o.event.trigger("ajaxSuccess",[J,M])}}function L(){if(M.complete){M.complete(J,R)}if(M.global){o.event.trigger("ajaxComplete",[J,M])}if(M.global&&!--o.active){o.event.trigger("ajaxStop")}}return J},handleError:function(F,H,E,G){if(F.error){F.error(H,E,G)}if(F.global){o.event.trigger("ajaxError",[H,F,G])}},active:0,httpSuccess:function(F){try{return !F.status&&location.protocol=="file:"||(F.status>=200&&F.status<300)||F.status==304||F.status==1223}catch(E){}return false},httpNotModified:function(G,E){try{var H=G.getResponseHeader("Last-Modified");return G.status==304||H==o.lastModified[E]}catch(F){}return false},httpData:function(J,H,G){var F=J.getResponseHeader("content-type"),E=H=="xml"||!H&&F&&F.indexOf("xml")>=0,I=E?J.responseXML:J.responseText;if(E&&I.documentElement.tagName=="parsererror"){throw"parsererror"}if(G&&G.dataFilter){I=G.dataFilter(I,H)}if(typeof I==="string"){if(H=="script"){o.globalEval(I)}if(H=="json"){I=l["eval"]("("+I+")")}}return I},param:function(E){var G=[];function H(I,J){G[G.length]=encodeURIComponent(I)+"="+encodeURIComponent(J)}if(o.isArray(E)||E.jquery){o.each(E,function(){H(this.name,this.value)})}else{for(var F in E){if(o.isArray(E[F])){o.each(E[F],function(){H(F,this)})}else{H(F,o.isFunction(E[F])?E[F]():E[F])}}}return G.join("&").replace(/%20/g,"+")}});var m={},n,d=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];function t(F,E){var G={};o.each(d.concat.apply([],d.slice(0,E)),function(){G[this]=F});return G}o.fn.extend({show:function(J,L){if(J){return this.animate(t("show",3),J,L)}else{for(var H=0,F=this.length;H").appendTo("body");K=I.css("display");if(K==="none"){K="block"}I.remove();m[G]=K}o.data(this[H],"olddisplay",K)}}for(var H=0,F=this.length;H=0;H--){if(G[H].elem==this){if(E){G[H](true)}G.splice(H,1)}}});if(!E){this.dequeue()}return this}});o.each({slideDown:t("show",1),slideUp:t("hide",1),slideToggle:t("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(E,F){o.fn[E]=function(G,H){return this.animate(F,G,H)}});o.extend({speed:function(G,H,F){var E=typeof G==="object"?G:{complete:F||!F&&H||o.isFunction(G)&&G,duration:G,easing:F&&H||H&&!o.isFunction(H)&&H};E.duration=o.fx.off?0:typeof E.duration==="number"?E.duration:o.fx.speeds[E.duration]||o.fx.speeds._default;E.old=E.complete;E.complete=function(){if(E.queue!==false){o(this).dequeue()}if(o.isFunction(E.old)){E.old.call(this)}};return E},easing:{linear:function(G,H,E,F){return E+F*G},swing:function(G,H,E,F){return((-Math.cos(G*Math.PI)/2)+0.5)*F+E}},timers:[],fx:function(F,E,G){this.options=E;this.elem=F;this.prop=G;if(!E.orig){E.orig={}}}});o.fx.prototype={update:function(){if(this.options.step){this.options.step.call(this.elem,this.now,this)}(o.fx.step[this.prop]||o.fx.step._default)(this);if((this.prop=="height"||this.prop=="width")&&this.elem.style){this.elem.style.display="block"}},cur:function(F){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null)){return this.elem[this.prop]}var E=parseFloat(o.css(this.elem,this.prop,F));return E&&E>-10000?E:parseFloat(o.curCSS(this.elem,this.prop))||0},custom:function(I,H,G){this.startTime=e();this.start=I;this.end=H;this.unit=G||this.unit||"px";this.now=this.start;this.pos=this.state=0;var E=this;function F(J){return E.step(J)}F.elem=this.elem;if(F()&&o.timers.push(F)&&!n){n=setInterval(function(){var K=o.timers;for(var J=0;J=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;var E=true;for(var F in this.options.curAnim){if(this.options.curAnim[F]!==true){E=false}}if(E){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;this.elem.style.display=this.options.display;if(o.css(this.elem,"display")=="none"){this.elem.style.display="block"}}if(this.options.hide){o(this.elem).hide()}if(this.options.hide||this.options.show){for(var I in this.options.curAnim){o.attr(this.elem.style,I,this.options.orig[I])}}this.options.complete.call(this.elem)}return false}else{var J=G-this.startTime;this.state=J/this.options.duration;this.pos=o.easing[this.options.easing||(o.easing.swing?"swing":"linear")](this.state,J,0,1,this.options.duration);this.now=this.start+((this.end-this.start)*this.pos);this.update()}return true}};o.extend(o.fx,{speeds:{slow:600,fast:200,_default:400},step:{opacity:function(E){o.attr(E.elem.style,"opacity",E.now)},_default:function(E){if(E.elem.style&&E.elem.style[E.prop]!=null){E.elem.style[E.prop]=E.now+E.unit}else{E.elem[E.prop]=E.now}}}});if(document.documentElement.getBoundingClientRect){o.fn.offset=function(){if(!this[0]){return{top:0,left:0}}if(this[0]===this[0].ownerDocument.body){return o.offset.bodyOffset(this[0])}var G=this[0].getBoundingClientRect(),J=this[0].ownerDocument,F=J.body,E=J.documentElement,L=E.clientTop||F.clientTop||0,K=E.clientLeft||F.clientLeft||0,I=G.top+(self.pageYOffset||o.boxModel&&E.scrollTop||F.scrollTop)-L,H=G.left+(self.pageXOffset||o.boxModel&&E.scrollLeft||F.scrollLeft)-K;return{top:I,left:H}}}else{o.fn.offset=function(){if(!this[0]){return{top:0,left:0}}if(this[0]===this[0].ownerDocument.body){return o.offset.bodyOffset(this[0])}o.offset.initialized||o.offset.initialize();var J=this[0],G=J.offsetParent,F=J,O=J.ownerDocument,M,H=O.documentElement,K=O.body,L=O.defaultView,E=L.getComputedStyle(J,null),N=J.offsetTop,I=J.offsetLeft;while((J=J.parentNode)&&J!==K&&J!==H){M=L.getComputedStyle(J,null);N-=J.scrollTop,I-=J.scrollLeft;if(J===G){N+=J.offsetTop,I+=J.offsetLeft;if(o.offset.doesNotAddBorder&&!(o.offset.doesAddBorderForTableAndCells&&/^t(able|d|h)$/i.test(J.tagName))){N+=parseInt(M.borderTopWidth,10)||0,I+=parseInt(M.borderLeftWidth,10)||0}F=G,G=J.offsetParent}if(o.offset.subtractsBorderForOverflowNotVisible&&M.overflow!=="visible"){N+=parseInt(M.borderTopWidth,10)||0,I+=parseInt(M.borderLeftWidth,10)||0}E=M}if(E.position==="relative"||E.position==="static"){N+=K.offsetTop,I+=K.offsetLeft}if(E.position==="fixed"){N+=Math.max(H.scrollTop,K.scrollTop),I+=Math.max(H.scrollLeft,K.scrollLeft)}return{top:N,left:I}}}o.offset={initialize:function(){if(this.initialized){return}var L=document.body,F=document.createElement("div"),H,G,N,I,M,E,J=L.style.marginTop,K='
';M={position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"};for(E in M){F.style[E]=M[E]}F.innerHTML=K;L.insertBefore(F,L.firstChild);H=F.firstChild,G=H.firstChild,I=H.nextSibling.firstChild.firstChild;this.doesNotAddBorder=(G.offsetTop!==5);this.doesAddBorderForTableAndCells=(I.offsetTop===5);H.style.overflow="hidden",H.style.position="relative";this.subtractsBorderForOverflowNotVisible=(G.offsetTop===-5);L.style.marginTop="1px";this.doesNotIncludeMarginInBodyOffset=(L.offsetTop===0);L.style.marginTop=J;L.removeChild(F);this.initialized=true},bodyOffset:function(E){o.offset.initialized||o.offset.initialize();var G=E.offsetTop,F=E.offsetLeft;if(o.offset.doesNotIncludeMarginInBodyOffset){G+=parseInt(o.curCSS(E,"marginTop",true),10)||0,F+=parseInt(o.curCSS(E,"marginLeft",true),10)||0}return{top:G,left:F}}};o.fn.extend({position:function(){var I=0,H=0,F;if(this[0]){var G=this.offsetParent(),J=this.offset(),E=/^body|html$/i.test(G[0].tagName)?{top:0,left:0}:G.offset();J.top-=j(this,"marginTop");J.left-=j(this,"marginLeft");E.top+=j(G,"borderTopWidth");E.left+=j(G,"borderLeftWidth");F={top:J.top-E.top,left:J.left-E.left}}return F},offsetParent:function(){var E=this[0].offsetParent||document.body;while(E&&(!/^body|html$/i.test(E.tagName)&&o.css(E,"position")=="static")){E=E.offsetParent}return o(E)}});o.each(["Left","Top"],function(F,E){var G="scroll"+E;o.fn[G]=function(H){if(!this[0]){return null}return H!==g?this.each(function(){this==l||this==document?l.scrollTo(!F?H:o(l).scrollLeft(),F?H:o(l).scrollTop()):this[G]=H}):this[0]==l||this[0]==document?self[F?"pageYOffset":"pageXOffset"]||o.boxModel&&document.documentElement[G]||document.body[G]:this[0][G]}});o.each(["Height","Width"],function(I,G){var E=I?"Left":"Top",H=I?"Right":"Bottom",F=G.toLowerCase();o.fn["inner"+G]=function(){return this[0]?o.css(this[0],F,false,"padding"):null};o.fn["outer"+G]=function(K){return this[0]?o.css(this[0],F,false,K?"margin":"border"):null};var J=G.toLowerCase();o.fn[J]=function(K){return this[0]==l?document.compatMode=="CSS1Compat"&&document.documentElement["client"+G]||document.body["client"+G]:this[0]==document?Math.max(document.documentElement["client"+G],document.body["scroll"+G],document.documentElement["scroll"+G],document.body["offset"+G],document.documentElement["offset"+G]):K===g?(this.length?o.css(this[0],J):null):this.css(J,typeof K==="string"?K:K+"px")}})})(); \ No newline at end of file diff --git a/IPSLibrary/webfront/NetPlayer2/mNetPlayer.css b/IPSLibrary/webfront/NetPlayer2/mNetPlayer.css new file mode 100644 index 0000000..81fc21f --- /dev/null +++ b/IPSLibrary/webfront/NetPlayer2/mNetPlayer.css @@ -0,0 +1,32 @@ +body {color:#fff;font-size:56px;font-family:arial,sans-serif;margin:0;padding:0;overflow:hidden} + +.containerPlayList{ width:100%; float:left; border: 0px solid rgba(255,255,255,0.25); overflow:auto;} +.containerCover{ width:100%; float:left; border: 0px solid rgba(255,255,255,0.25); } +.containerControl{ width:100%; float:left; border: 0px solid rgba(255,255,255,0.25); overflow:hidden; font-size:36px;} + +.containerRadioSelect{ width:100%; float:left; border: 0px solid rgba(255,255,255,0.25); overflow:hidden; font-size:36px;} +.containerRadioInfo{ width:100%; float:left; border: 0px solid rgba(255,255,255,0.25); overflow:hidden; font-size:36px;} +.containerSelection{ width:100%; float:left; border: 0px solid rgba(255,255,255,0.25); overflow:hidden; font-size:36px;} + +.containerControlLine{ display:table-row; position:relative; width:100%; vertical-align:middle; text-align:center; float:left; } +.containerControlLine100{ display:table-row; position:relative; width:100%; padding:0; margin:3px 0; border:0; float:left} +.containerControlLine50{ display:table-row; position:relative; width:50%; padding:0; margin:3px 0; border:0; float:left } +.containerControlLineBottom{ display:table-row; position:relative; width:100%; vertical-align:middle; text-align:center; float:left; } +.containerControlLineTop{ display:table-row; position:relative; width:100%; vertical-align:middle; text-align:center; float:left; } +.containerControlLineSeparator{ display:table-row; position:relative; width:100%; vertical-align:middle; text-align:center; float:left; margin:15px 0 15px 0; border-width:1px 0px; border-style:solid; border-color:#617285; border-color:white; } + +.containerControlButton{ display:table-cell; width:100%; + line-height:100px; height:100px; background-color:rgba(255,255,255,0.1); color:rgba(255,255,255,0.3); + position:relative; vertical-align:middle; text-align:center; + border-width: 0px; border-style:solid; border-color:transparent; float:left; + background-image:url(http://localhost:7001/img/bg.png); background-repeat:repeat; background-position:center top;} +.containerControlButtonSelected{ background-color:rgba(255,255,255,0.3); color:white; } +.containerControlButtonActive{ background-color:rgba(255,255,255,0.3); color:white; } +.containerControlDescr{display:inline-block; font-size:36px; color:white; line-height:60px; border-width: 0 0 0 0; height:60px; width:300px; text-align:right; float:left; padding: 0 10px; margin: 3px 0 0 3px;} +.containerControlData{display:inline-block; font-size:36px; color:white; line-height:60px; border-width: 0 0 0 0; height:60px; width:600px; text-align:left; float:left; padding: 0 10px; margin: 3px 0 0 3px; overflow:hidden} +.containerControlSelect{display:table-row; height:100px; width:100%; background-image:url(http://localhost:7001/img/bg.png)} +.containerControlTrack{display:inline-block; color:white; border-width:0; text-align:left; float:left; padding:0; padding:0px 10px ; margin: 3px; overflow:hidden; font-size:24px;font-family:arial,sans-serif;} +.containerControlTrackActive{font-size:28px;font-family:arial,sans-serif; background:rgba(255,255,255,0.3); width:100%;} +.containerControlSelectInterpret{font:bold 32px verdana; height:50px; line-height:50px; overflow:hidden;} +.containerControlSelectAlbum{font:normal 24px verdana; height:50px; line-height:50px; overflow:hidden;} + diff --git a/README b/README index 60b71c3..de4a33c 100644 --- a/README +++ b/README @@ -10,3 +10,14 @@ Find support and lots more on [www.ip-symcon.de] (http://www.ip-symcon.de/forum/ [GNU General Public License v3] (http://www.gnu.org/licenses/gpl.txt.) +## Important Note About Licensing for Highcharts + +Highcharts is licensed by Highsoft Solutions AS and can be obtained here: + +[http://www.highcharts.com/products/highcharts] (http://www.highcharts.com/products/highcharts). + +Highcharts is licensed for free for any personal or non-profit projects under the [Creative Commons Attribution-NonCommercial +3.0 License] (http://creativecommons.org/licenses/by-nc/3.0/). + +[See the license and pricing details directly on the Highcharts.com site for more details.] (http://www.highcharts.com/license) + diff --git a/tools/net/IPSTools/IPSTools.suo b/tools/net/IPSTools/IPSTools.suo index 56d672e..e747a0a 100644 Binary files a/tools/net/IPSTools/IPSTools.suo and b/tools/net/IPSTools/IPSTools.suo differ diff --git a/tools/net/IPSTools/IPSTools/IPSTools.cs b/tools/net/IPSTools/IPSTools/IPSTools.cs index 4cdb3d0..caa516a 100644 --- a/tools/net/IPSTools/IPSTools/IPSTools.cs +++ b/tools/net/IPSTools/IPSTools/IPSTools.cs @@ -37,7 +37,7 @@ public partial class IPSTools : Form public IPSTools() { InitializeComponent(); - tcpServer = new TcpServer((int)tcpPort.Value, this.Handle, this.notifyIcon); + tcpServer = new TcpServer((int)tcpPort.Value, this.Handle); tcpServer.AutoSendInterval = (int)autoSendInterval.Value; tcpServer.AutoSendIdle = autoSendIdle.Checked; if (checkBox_AutoStart.Checked) diff --git a/tools/net/IPSTools/IPSTools/bin/Debug/IPSToolLibrary.dll b/tools/net/IPSTools/IPSTools/bin/Debug/IPSToolLibrary.dll index 3954896..7b2a29e 100644 Binary files a/tools/net/IPSTools/IPSTools/bin/Debug/IPSToolLibrary.dll and b/tools/net/IPSTools/IPSTools/bin/Debug/IPSToolLibrary.dll differ diff --git a/tools/net/IPSTools/IPSTools/bin/Debug/IPSToolLibrary.pdb b/tools/net/IPSTools/IPSTools/bin/Debug/IPSToolLibrary.pdb index 873bfe3..ad6edaa 100644 Binary files a/tools/net/IPSTools/IPSTools/bin/Debug/IPSToolLibrary.pdb and b/tools/net/IPSTools/IPSTools/bin/Debug/IPSToolLibrary.pdb differ diff --git a/tools/net/IPSTools/IPSTools/bin/Debug/IPSTools.exe b/tools/net/IPSTools/IPSTools/bin/Debug/IPSTools.exe index ee91d88..84a9dd5 100644 Binary files a/tools/net/IPSTools/IPSTools/bin/Debug/IPSTools.exe and b/tools/net/IPSTools/IPSTools/bin/Debug/IPSTools.exe differ diff --git a/tools/net/IPSTools/IPSTools/bin/Debug/IPSTools.pdb b/tools/net/IPSTools/IPSTools/bin/Debug/IPSTools.pdb index 8855620..9212c11 100644 Binary files a/tools/net/IPSTools/IPSTools/bin/Debug/IPSTools.pdb and b/tools/net/IPSTools/IPSTools/bin/Debug/IPSTools.pdb differ diff --git a/tools/net/IPSTools/IPSTools/bin/Debug/ccmperf.log b/tools/net/IPSTools/IPSTools/bin/Debug/ccmperf.log new file mode 100644 index 0000000..31a50c9 --- /dev/null +++ b/tools/net/IPSTools/IPSTools/bin/Debug/ccmperf.log @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/tools/net/IPSTools/IPSTools/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/tools/net/IPSTools/IPSTools/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache index 5adc75c..075f1a8 100644 Binary files a/tools/net/IPSTools/IPSTools/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/tools/net/IPSTools/IPSTools/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/tools/net/IPSTools/IPSTools/obj/x86/Debug/GenerateResource.read.1.tlog b/tools/net/IPSTools/IPSTools/obj/x86/Debug/GenerateResource.read.1.tlog index 2758866..3524541 100644 Binary files a/tools/net/IPSTools/IPSTools/obj/x86/Debug/GenerateResource.read.1.tlog and b/tools/net/IPSTools/IPSTools/obj/x86/Debug/GenerateResource.read.1.tlog differ diff --git a/tools/net/IPSTools/IPSTools/obj/x86/Debug/GenerateResource.write.1.tlog b/tools/net/IPSTools/IPSTools/obj/x86/Debug/GenerateResource.write.1.tlog index 57fcdc4..1ffffc9 100644 Binary files a/tools/net/IPSTools/IPSTools/obj/x86/Debug/GenerateResource.write.1.tlog and b/tools/net/IPSTools/IPSTools/obj/x86/Debug/GenerateResource.write.1.tlog differ diff --git a/tools/net/IPSTools/IPSTools/obj/x86/Debug/IPSTools.csproj.FileListAbsolute.txt b/tools/net/IPSTools/IPSTools/obj/x86/Debug/IPSTools.csproj.FileListAbsolute.txt index dd73101..219481e 100644 --- a/tools/net/IPSTools/IPSTools/obj/x86/Debug/IPSTools.csproj.FileListAbsolute.txt +++ b/tools/net/IPSTools/IPSTools/obj/x86/Debug/IPSTools.csproj.FileListAbsolute.txt @@ -46,3 +46,15 @@ C:\ab\IPS\Projects.Net\_Development\IP-SymconTools\IPSTools\obj\x86\Debug\Browns C:\ab\IPS\Projects.Net\_Development\IP-SymconTools\IPSTools\obj\x86\Debug\IPSTool.Properties.Resources.resources C:\ab\IPS\Projects.Net\_Development\IP-SymconTools\IPSTools\obj\x86\Debug\GenerateResource.read.1.tlog C:\ab\IPS\Projects.Net\_Development\IP-SymconTools\IPSTools\obj\x86\Debug\GenerateResource.write.1.tlog +C:\ab\IPS\GIT\IPSLibrary\tools\net\IPSTools\IPSTools\bin\Debug\IPSTools.exe.config +C:\ab\IPS\GIT\IPSLibrary\tools\net\IPSTools\IPSTools\obj\x86\Debug\IPSTools.exe +C:\ab\IPS\GIT\IPSLibrary\tools\net\IPSTools\IPSTools\obj\x86\Debug\IPSTools.pdb +C:\ab\IPS\GIT\IPSLibrary\tools\net\IPSTools\IPSTools\obj\x86\Debug\ResolveAssemblyReference.cache +C:\ab\IPS\GIT\IPSLibrary\tools\net\IPSTools\IPSTools\obj\x86\Debug\BrownsonTool.IPSTools.resources +C:\ab\IPS\GIT\IPSLibrary\tools\net\IPSTools\IPSTools\obj\x86\Debug\IPSTool.Properties.Resources.resources +C:\ab\IPS\GIT\IPSLibrary\tools\net\IPSTools\IPSTools\obj\x86\Debug\GenerateResource.read.1.tlog +C:\ab\IPS\GIT\IPSLibrary\tools\net\IPSTools\IPSTools\obj\x86\Debug\GenerateResource.write.1.tlog +C:\ab\IPS\GIT\IPSLibrary\tools\net\IPSTools\IPSTools\bin\Debug\IPSTools.exe +C:\ab\IPS\GIT\IPSLibrary\tools\net\IPSTools\IPSTools\bin\Debug\IPSTools.pdb +C:\ab\IPS\GIT\IPSLibrary\tools\net\IPSTools\IPSTools\bin\Debug\IPSToolLibrary.dll +C:\ab\IPS\GIT\IPSLibrary\tools\net\IPSTools\IPSTools\bin\Debug\IPSToolLibrary.pdb diff --git a/tools/net/IPSTools/IPSTools/obj/x86/Debug/IPSTools.exe b/tools/net/IPSTools/IPSTools/obj/x86/Debug/IPSTools.exe index ee91d88..84a9dd5 100644 Binary files a/tools/net/IPSTools/IPSTools/obj/x86/Debug/IPSTools.exe and b/tools/net/IPSTools/IPSTools/obj/x86/Debug/IPSTools.exe differ diff --git a/tools/net/IPSTools/IPSTools/obj/x86/Debug/IPSTools.pdb b/tools/net/IPSTools/IPSTools/obj/x86/Debug/IPSTools.pdb index 8855620..9212c11 100644 Binary files a/tools/net/IPSTools/IPSTools/obj/x86/Debug/IPSTools.pdb and b/tools/net/IPSTools/IPSTools/obj/x86/Debug/IPSTools.pdb differ diff --git a/tools/net/IPSTools/IPSTools/obj/x86/Debug/ResolveAssemblyReference.cache b/tools/net/IPSTools/IPSTools/obj/x86/Debug/ResolveAssemblyReference.cache index ff0f775..3260c53 100644 Binary files a/tools/net/IPSTools/IPSTools/obj/x86/Debug/ResolveAssemblyReference.cache and b/tools/net/IPSTools/IPSTools/obj/x86/Debug/ResolveAssemblyReference.cache differ diff --git a/tools/net/IPSTools/IPSToolsLibrary/MonitorUtils.cs b/tools/net/IPSTools/IPSToolsLibrary/MonitorUtils.cs index a58e26a..cf1504e 100644 --- a/tools/net/IPSTools/IPSToolsLibrary/MonitorUtils.cs +++ b/tools/net/IPSTools/IPSToolsLibrary/MonitorUtils.cs @@ -1,21 +1,4 @@ -/** - * This file is part of the IPSLibrary. - * - * The IPSLibrary is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * The IPSLibrary is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with the IPSLibrary. If not, see http://www.gnu.org/licenses/gpl.txt. - */ - -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -39,6 +22,31 @@ class MonitorUtils [DllImport("user32.dll")] private static extern int ShowWindow(int hwnd, int command); + + + [DllImport("user32.dll")] + private static extern bool SystemParametersInfo(int uAction, int uParam, ref bool lpvParam, int flags); + + [DllImport("user32.dll")] + private static extern IntPtr OpenDesktop(string hDesktop, int Flags, bool Inherit, uint DesiredAccess); + + [DllImport("user32.dll")] + private static extern bool CloseDesktop(IntPtr hDesktop); + + [DllImport("user32.dll")] + private static extern bool EnumDesktopWindows(IntPtr hDesktop, EnumDesktopWindowsProc callback, IntPtr lParam); + + [DllImport("user32.dll")] + private static extern bool IsWindowVisible(IntPtr hWnd); + + [DllImport("user32.dll")] + private static extern IntPtr GetForegroundWindow(); + + [DllImport("user32.dll")] + private static extern int PostMessage(IntPtr hWnd, int wMsg, int wParam, int lParam); + + private delegate bool EnumDesktopWindowsProc(IntPtr hDesktop, IntPtr lParam); + private const int WM_SYSCOMMAND = 0x0112; private const int SC_SCREENSAVER = 0xF140; @@ -51,6 +59,12 @@ class MonitorUtils private const int TASKBAR_HIDE = 0; private const int TASKBAR_SHOW = 1; + private const int SPI_GETSCREENSAVERRUNNING = 114; + private const uint DESKTOP_WRITEOBJECTS = 0x0080; + private const uint DESKTOP_READOBJECTS = 0x0001; + private const int WM_CLOSE = 16; + + private IntPtr handle; public MonitorUtils(IntPtr gui) @@ -63,33 +77,42 @@ public void StartScreenSaver() SendMessage(GetDesktopWindow(), WM_SYSCOMMAND, SC_SCREENSAVER, 0); } - public void ScreenPowerOff() + public void StopScreenSaver() { - SendMessage(handle, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF); - } - - public void ScreenPowerOn() - { - SendMessage(handle, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_ON); - } - - public void WindowsTaskBarVisible(bool isVisible) - { - //try - //{ - int hWnd = FindWindow("Shell_traywnd", ""); - if (isVisible) + bool isActive = false; + SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, ref isActive, 0); + if (isActive) + { + IntPtr hDesktop = OpenDesktop("Screen-saver", 0, false, DESKTOP_READOBJECTS | DESKTOP_WRITEOBJECTS); + if (hDesktop != IntPtr.Zero) { - ShowWindow(hWnd, TASKBAR_SHOW); + EnumDesktopWindows(hDesktop, new EnumDesktopWindowsProc(KillScreenSaverFunc), IntPtr.Zero); + CloseDesktop(hDesktop); + } else { - ShowWindow(hWnd, TASKBAR_HIDE); + PostMessage(GetForegroundWindow(), WM_CLOSE, 0, 0); + } - //} - //catch (Win32Exception ex) { } + } + } + private static bool KillScreenSaverFunc(IntPtr hWnd, IntPtr lParam) + { + if (IsWindowVisible(hWnd)) PostMessage(hWnd, WM_CLOSE, 0, 0); + return true; + } + + + public void ScreenPowerOff() + { + SendMessage(handle, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF); } + public void ScreenPowerOn() + { + SendMessage(handle, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_ON); + } } } diff --git a/tools/net/IPSTools/IPSToolsLibrary/MouseUtils.cs b/tools/net/IPSTools/IPSToolsLibrary/MouseUtils.cs index a598f55..02d5fac 100644 --- a/tools/net/IPSTools/IPSToolsLibrary/MouseUtils.cs +++ b/tools/net/IPSTools/IPSToolsLibrary/MouseUtils.cs @@ -65,6 +65,11 @@ public static Point GetMousePosition() return Cursor.Position; } + public static void SetMousePosition(int x, int y) + { + Cursor.Position = new Point(x, y); + } + public int GetMouseIdleSince() { return mouseIdleSince; diff --git a/tools/net/IPSTools/IPSToolsLibrary/TcpServer.cs b/tools/net/IPSTools/IPSToolsLibrary/TcpServer.cs index 7d29c33..8ae9f5e 100644 --- a/tools/net/IPSTools/IPSToolsLibrary/TcpServer.cs +++ b/tools/net/IPSTools/IPSToolsLibrary/TcpServer.cs @@ -1,21 +1,4 @@ -/** - * This file is part of the IPSLibrary. - * - * The IPSLibrary is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * The IPSLibrary is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with the IPSLibrary. If not, see http://www.gnu.org/licenses/gpl.txt. - */ - -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -26,6 +9,7 @@ using System.Windows.Forms; using System.Diagnostics; + namespace IPSToolLibrary { @@ -41,7 +25,6 @@ public class TcpServer private int tcpPort; private IntPtr guiHandle; - private NotifyIcon notifyIcon; private System.Windows.Forms.Timer autoSendTimer; private int autoSendInterval; @@ -52,11 +35,10 @@ public int AutoSendInterval set { this.autoSendInterval = value; if (autoSendTimer != null) autoSendTimer.Interval = AutoSendInterval; } } - public TcpServer(int port, IntPtr guiHandle, NotifyIcon notifyIcon) + public TcpServer(int port, IntPtr guiHandle) { this.tcpPort = port; this.guiHandle = guiHandle; - this.notifyIcon = notifyIcon; this.clients = new List(); this.mouseUtils = new MouseUtils(); this.monitorUtils = new MonitorUtils(guiHandle); @@ -69,6 +51,9 @@ public TcpServer(int port, IntPtr guiHandle, NotifyIcon notifyIcon) autoSendTimer.Enabled = true; } + public TcpServer(IntPtr guiHandle) : this(0, guiHandle) { } + + public int GetPort() { return tcpPort; @@ -198,18 +183,18 @@ private void HandleClientComm(object client) case "GetMousePosition": outputString = string.Format("MousePosition;{0};{1}", MouseUtils.GetMousePosition().X.ToString(), MouseUtils.GetMousePosition().Y.ToString()); break; + case "SetMousePosition": + MouseUtils.SetMousePosition(int.Parse(inputParams[1]), int.Parse(inputParams[2])); + break; case "GetMouseIdleSince": outputString = string.Format("MouseIdleSince;{0}", mouseUtils.GetMouseIdleSince()); break; - case "CursorShow": - MouseUtils.SetCursorVisible(true); - break; - case "CursorHide": - MouseUtils.SetCursorVisible(false); - break; case "StartScreenSaver": monitorUtils.StartScreenSaver(); break; + case "StopScreenSaver": + monitorUtils.StopScreenSaver(); + break; case "ScreenPowerOff": monitorUtils.ScreenPowerOff(); break; @@ -247,15 +232,10 @@ private void HandleClientComm(object client) Process.Start(inputParams[1], inputParams[2]); outputString = string.Format("{0};{1};{2}", inputParams[0], inputParams[1], inputParams[2]); break; - case "NotifyInfo": - notifyIcon.ShowBalloonTip(int.Parse(inputParams[1]), inputParams[2], inputParams[3],ToolTipIcon.Info); - break; case "TaskBarHide": - //monitorUtils.WindowsTaskBarVisible(false); Taskbar.Hide(); break; case "TaskBarShow": - //monitorUtils.WindowsTaskBarVisible(true); Taskbar.Show(); break; default: diff --git a/tools/net/IPSTools/IPSToolsLibrary/bin/Debug/IPSToolLibrary.dll b/tools/net/IPSTools/IPSToolsLibrary/bin/Debug/IPSToolLibrary.dll index 3954896..7b2a29e 100644 Binary files a/tools/net/IPSTools/IPSToolsLibrary/bin/Debug/IPSToolLibrary.dll and b/tools/net/IPSTools/IPSToolsLibrary/bin/Debug/IPSToolLibrary.dll differ diff --git a/tools/net/IPSTools/IPSToolsLibrary/bin/Debug/IPSToolLibrary.pdb b/tools/net/IPSTools/IPSToolsLibrary/bin/Debug/IPSToolLibrary.pdb index 873bfe3..ad6edaa 100644 Binary files a/tools/net/IPSTools/IPSToolsLibrary/bin/Debug/IPSToolLibrary.pdb and b/tools/net/IPSTools/IPSToolsLibrary/bin/Debug/IPSToolLibrary.pdb differ diff --git a/tools/net/IPSTools/IPSToolsLibrary/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/tools/net/IPSTools/IPSToolsLibrary/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache index 479265f..09ae317 100644 Binary files a/tools/net/IPSTools/IPSToolsLibrary/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/tools/net/IPSTools/IPSToolsLibrary/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/tools/net/IPSTools/IPSToolsLibrary/obj/Debug/IPSToolLibrary.dll b/tools/net/IPSTools/IPSToolsLibrary/obj/Debug/IPSToolLibrary.dll index 3954896..7b2a29e 100644 Binary files a/tools/net/IPSTools/IPSToolsLibrary/obj/Debug/IPSToolLibrary.dll and b/tools/net/IPSTools/IPSToolsLibrary/obj/Debug/IPSToolLibrary.dll differ diff --git a/tools/net/IPSTools/IPSToolsLibrary/obj/Debug/IPSToolLibrary.pdb b/tools/net/IPSTools/IPSToolsLibrary/obj/Debug/IPSToolLibrary.pdb index 873bfe3..ad6edaa 100644 Binary files a/tools/net/IPSTools/IPSToolsLibrary/obj/Debug/IPSToolLibrary.pdb and b/tools/net/IPSTools/IPSToolsLibrary/obj/Debug/IPSToolLibrary.pdb differ diff --git a/tools/net/IPSTools/IPSToolsLibrary/obj/Debug/IPSToolsLibrary.csproj.FileListAbsolute.txt b/tools/net/IPSTools/IPSToolsLibrary/obj/Debug/IPSToolsLibrary.csproj.FileListAbsolute.txt index 9fbbaf6..bc6f4cc 100644 --- a/tools/net/IPSTools/IPSToolsLibrary/obj/Debug/IPSToolsLibrary.csproj.FileListAbsolute.txt +++ b/tools/net/IPSTools/IPSToolsLibrary/obj/Debug/IPSToolsLibrary.csproj.FileListAbsolute.txt @@ -18,3 +18,8 @@ C:\ab\IPS\Projects.Net\_Development\IP-SymconTools\IPSToolsLibrary\bin\Debug\IPS C:\ab\IPS\Projects.Net\_Development\IP-SymconTools\IPSToolsLibrary\obj\Debug\ResolveAssemblyReference.cache C:\ab\IPS\Projects.Net\_Development\IP-SymconTools\IPSToolsLibrary\obj\Debug\IPSToolLibrary.dll C:\ab\IPS\Projects.Net\_Development\IP-SymconTools\IPSToolsLibrary\obj\Debug\IPSToolLibrary.pdb +C:\ab\IPS\GIT\IPSLibrary\tools\net\IPSTools\IPSToolsLibrary\bin\Debug\IPSToolLibrary.dll +C:\ab\IPS\GIT\IPSLibrary\tools\net\IPSTools\IPSToolsLibrary\bin\Debug\IPSToolLibrary.pdb +C:\ab\IPS\GIT\IPSLibrary\tools\net\IPSTools\IPSToolsLibrary\obj\Debug\ResolveAssemblyReference.cache +C:\ab\IPS\GIT\IPSLibrary\tools\net\IPSTools\IPSToolsLibrary\obj\Debug\IPSToolLibrary.dll +C:\ab\IPS\GIT\IPSLibrary\tools\net\IPSTools\IPSToolsLibrary\obj\Debug\IPSToolLibrary.pdb