function IPSWatering_LogActivate($CircleId, $Value, $Mode) { $CircleName = get_CirclyNameByID($CircleId); IPSLogger_Inf(__file__, bool2Activation($Value)." Watering ($Mode) for Circle '$CircleName'"); if ($Value) { IPSWatering_Log("Aktiviere Beregnung ($Mode) für '$CircleName'"); } }
function PurgeLogFiles($Directory, $Extension, $ID_OutSwitch, $ID_OutDays) { if (GetValue($ID_OutSwitch)) { IPSLogger_Dbg(c_LogId, 'Purging *.'.$Extension.' LogFiles in Directory '.$Directory); $Days = GetValue($ID_OutDays); $ReferenceDate=Date('Ymd', strtotime("-".$Days." days")); if ($Directory == "") { $Directory = IPS_GetKernelDir().'logs\\'; } if (($handle=opendir($Directory))===false) { IPSLogger_Err(c_LogId, 'Error Opening Directory '.$Directory); Exit; } while (($File = readdir($handle))!==false) { $FileDate = substr($File, strlen('IPSLogger_'), 8); $FileExtension = substr($File, strlen('IPSLogger_')+8+1, 3); if ($Extension==$FileExtension) { IPSLogger_Trc(c_LogId, 'Found File: '.$File.', FileDate='.$FileDate.', RefDate='.$ReferenceDate); if ($FileDate < $ReferenceDate) { IPSLogger_Inf(c_LogId, 'Delete LogFile: '.$Directory.$File); unlink($Directory.$File); } } } closedir($handle); } }
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)); SetValue($PowerId, $Value); Entertainment_SetRoomVisible($PowerId, $Value); if ($PowerOnDevices) { Entertainment_SetDevicePowerByRoomId(IPS_GetParent($PowerId), $Value); } Entertainment_SyncRoomControls(IPS_GetParent($PowerId)); } }
function Entertainment_SetRemoteControlType($Id, $Value, $ControlType) { $DeviceName = IPS_GetName(IPS_GetParent($Id)); IPSLogger_Inf(__file__, 'Set RemoteControlType "'.$Value.'" for Device "'.$DeviceName.'"'); if (GetValue($Id) <> $Value) { SetValue($Id, $Value); $DeviceConfig = get_DeviceConfiguration(); $Remote = c_RemoteControlHtmlPrefix.$DeviceConfig[$DeviceName][$ControlType][c_Property_Names][$Value].c_RemoteControlHtmlSuffix; Entertainment_SetRemoteControl(get_ControlIdByDeviceName($DeviceName, $ControlType), $Remote); } }
function Entertainment_SetDevicePowerByDeviceName($DeviceName, $Value, $MessageType=c_MessageType_Action) { 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); 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) { Entertainment_SendDataByDeviceName($DeviceName, c_Control_DevicePower, array(c_Property_CommPowerOn, c_Property_CommPower), $MessageType); } else { Entertainment_SendDataByDeviceName($DeviceName, c_Control_DevicePower, array(c_Property_CommPowerOff, c_Property_CommPower), $MessageType); } SetValue($PowerId, $Value); Entertainment_Connect($DeviceName, $Value, true); Entertainment_SetDeviceControlByDeviceName($DeviceName, c_Control_Muting, false); Entertainment_SetRoomPowerByDeviceName($DeviceName, $Value); } } }
function Entertainment_ReceiveData($CommParams, $MessageType=c_MessageType_Action) { if (!Entertainment_Before_ReceiveData($CommParams, $MessageType)) { return true; } $CommProperties = get_CommProperties($CommParams); if ($CommProperties !== false) { $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: Entertainment_SetVolume(get_ControlIdByDeviceName($DeviceName, c_Control_Volume), (int)$CommProperties[c_Template_Value], $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: Entertainment_SetTreble(get_ControlIdByDeviceName($DeviceName, c_Control_Treble), (int)$CommProperties[c_Template_Value], $MessageType); 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: 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), $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, $Value, c_Control_RemoteSource); 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), $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: IPSLogger_Err(__File__, 'Found unknown CommunicationType "'.$CommType.'"'); } Entertainment_After_ReceiveData($CommParams, $MessageType); return true; } Entertainment_After_ReceiveData($CommParams, $MessageType); return false; }
<?php /**@addtogroup netplayer * @{ * * @file NetPlayer_Mobile.php * @author Andreas Brauneis * @version * Version 2.50.1, 31.01.2012<br/> * * 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::NetPlayer"); 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}"; } /** @}*/
case 'Install': if (IPSModuleManagerGUI_GetLock($action, true)) { IPSLogger_Inf(__file__, 'IPSModuleManagerGUI - Installation of Module '.$module); $moduleManager = new IPSModuleManager($module); $moduleManager->InstallModule(); } break; case 'Load': if (IPSModuleManagerGUI_GetLock($action, true)) { IPSLogger_Inf(__file__, 'IPSModuleManagerGUI - Load Files of Module '.$module.' from Repository "'.$repository.'"'); $moduleManager = new IPSModuleManager($module, $repository); $moduleManager->LoadModule(); } IPSModuleManagerGUI_SetPage(IPSMMG_ACTION_MODULE, $module); break; case 'Delete': if (IPSModuleManagerGUI_GetLock($action, true)) { IPSLogger_Inf(__file__, 'IPSModuleManagerGUI - Delete of Module '.$module); $moduleManager = new IPSModuleManager($module); $moduleManager->DeleteModule(); } IPSModuleManagerGUI_SetPage(IPSMMG_ACTION_OVERVIEW, $module); break; default: IPSModuleManagerGUI_SetPage($action, $module, $info); } IPSModuleManagerGUI_Refresh(); /** @}*/ ?>
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)); SetValue($SourceId, $Value); if (!IsRoomPoweredOn($RoomId)) { 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_PowerOffUnusedDevices(); } }
function NetPlayer_SetPlayListPosition($position) { IPSLogger_Inf(__file__, "Set NetPlayer PlayListPosition=$position"); NetPlayer_SwitchToMP3Player(); NetPlayer_GetIPSComponentPlayer()->SetPlaylistPosition((int)$position); }
Register_PhpErrorHandler($moduleManager); // ---------------------------------------------------------------------------------------------------------------------------- // Some Tests // ---------------------------------------------------------------------------------------------------------------------------- IPSUtils_Include ("IPSLogger.inc.php", "IPSLibrary::app::core::IPSLogger"); // Some Test Messages IPSLogger_Fat(__file__, 'Test for a Fatal Error'); IPSLogger_Err(__file__, 'Test for a Error ...'); IPSLogger_Wrn(__file__, 'Test for a Warning'); IPSLogger_Not(__file__, 'Test for a Notification with Priority 0 (High)'); IPSLogger_Not(__file__, 'Test for a Notification with Priority 10 (Low)'); IPSLogger_Inf(__file__, 'Test for a Information Message ...'); IPSLogger_Dbg(__file__, 'Test for a Debug Message ...'); IPSLogger_Com(__file__, 'Test for a Communication Message ...'); IPSLogger_Trc(__file__, 'Test for a Trace Message ...'); IPSLogger_Tst(__file__, 'Test for a Test Message ...'); // ------------------------------------------------------------------------------------------------ function Register_PhpErrorHandler($moduleManager) { $file = IPS_GetKernelDir().'scripts\\__autoload.php'; if (!file_exists($file)) { throw new Exception($file.' could NOT be found!', E_USER_ERROR); } $FileContent = file_get_contents($file); $pos = strpos($FileContent, 'IPSLogger_PhpErrorHandler.inc.php');
function Entertainment_SetMuting($Id, $Value, $MessageType=c_MessageType_Action) { $DeviceName = IPS_GetName(IPS_GetParent($Id)); if (!isDevicePoweredOnByDeviceName($DeviceName)) { return; } if (!is_bool($Value)) { /*Toggle Power Value*/ $Value = !GetValue($Id); } if (GetValue($Id) <> $Value) { IPSLogger_Inf(__file__, 'Set Muting "'.bool2OnOff($Value).'" for Device "'.$DeviceName.'"'); SetValue($Id, $Value); if ($Value) { Entertainment_SendDataByDeviceName($DeviceName, c_Control_Muting, array(c_Property_CommMuteOn, c_Property_CommMute), $MessageType); } else { Entertainment_SendDataByDeviceName($DeviceName, c_Control_Muting, array(c_Property_CommMuteOff, c_Property_CommMute), $MessageType); } Entertainment_SetRoomControlByDeviceControlId($Id, $Value); } }