function Entertainment_NetPlayer_SendData($Data) { $Control = $Data[1]; $Command = $Data[2]; IPSLogger_Com(__file__, "Send Data to NetPlayer, Control='$Control', Command='$Command'"); if ($Command=='poweron') { NetPlayer_Power(true); } else if ($Command=='poweroff') { NetPlayer_Power(false); } else { IPSLogger_Err(__file__, "Received unknown Command '$Command' from Entertainment-->Check Configuration!"); } }
function Onkyo_ReceiveData_Register($RegisterId, $Value) { $Data = substr($Value,18); $Command = substr($Data,0,3); $Param = substr($Data,3,2); IPSLogger_Com(__file__, 'Received Message from Onkyo: '.$Data.' (Command='.$Command.', Param='.$Param.')'); if ($Command=='MVL' or $Command=='ZVL') { $Param = hexdec($Param); } Entertainment_ReceiveData(array(c_Comm_Onkyo, $Command, $Param), c_MessageType_Info); }
function WinLIRC_ReceiveData_Variable($VariableId, $Value) { if ($Value == "") { return; } $Button = $Value; $InstanceId = IPS_GetParent($VariableId); $ChildrenIds = IPS_GetChildrenIDs($InstanceId); foreach ($ChildrenIds as $Id) { if ($Id <> $VariableId) { $RemoteControl = GetValue($Id); } } IPSLogger_Com(__file__, "Received Data from WinLIRC-Variable, Control='$RemoteControl', Command='$Button'"); $MessageType = get_MessageTypeByControl($RemoteControl); WinLIRC_ReceiveData($RemoteControl, $Button, $MessageType); }
function WinLIRC_ReceiveData_Program($Program, $DeviceName) { IPSLogger_Com(__file__, "Received Program '$Program' from WinLIRC-Webfront, Device='$DeviceName'"); $ControlId = get_ControlIdByDeviceName($DeviceName, c_Control_Program); if ($Program=='next') { Entertainment_SetProgramNext($ControlId); } else if ($Program=='prev') { Entertainment_SetProgramPrev($ControlId); } else { Entertainment_SetProgram($ControlId, $Program); } return GetValue($ControlId); }
/** * @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); } } }
// ---------------------------------------------------------------------------------------------------------------------------- // 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'); if ($pos === false) {
IPS_SemaphoreEnter('NetPlayer', 1000); if($IPS_SENDER == "Variable") { $variableName = IPS_GetName($IPS_VARIABLE); switch ($variableName) { case 'Power': 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); } break; case 'RemoteControl': $ControlId = get_ControlIdByDeviceName(c_Device_NetPlayer, c_Control_RemoteSourceType); if (GetValue(NP_ID_CONTROLTYPE) <> GetValue($ControlId)) { IPSLogger_Com(__file__, "Receive RemoteControlType ".GetValue(NP_ID_CONTROLTYPE)." for NetPlayer"); Entertainment_ReceiveData(array(c_Comm_NetPlayer, 'netplayertype', (string)GetValue(NP_ID_CONTROLTYPE)), c_MessageType_Info); } else { Entertainment_RefreshRemoteControlByDeviceName(c_Device_NetPlayer); } break; case 'MobileControl': //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); break; default: IPSLogger_Err(__file__, "Unknown Variable $variableName"); Exit;