-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEntertainment_InterfaceWinLIRC.ips.php
More file actions
132 lines (119 loc) · 5.93 KB
/
Copy pathEntertainment_InterfaceWinLIRC.ips.php
File metadata and controls
132 lines (119 loc) · 5.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?
include_once "Entertainment.ips.php";
// ---------------------------------------------------------------------------------------------------------------------------
function get_MessageTypeByControl($Control) {
$CommConfig = get_CommunicationConfiguration();
$MessageTypes = $CommConfig[c_Comm_WinLIRC][c_Property_MessageTypes];
if (array_key_exists($Control, $MessageTypes)) {
return $MessageTypes[$Control];
} else {
return c_MessageType_Action;
}
}
// ---------------------------------------------------------------------------------------------------------------------------
function WinLIRC_SendData_doTranslation($Control, $Button, $TranslationListItems) {
foreach ($TranslationListItems as $Item) {
$Data = explode('.', $Item);
if ($Data[0]=='*') { $ControlNew=$Control;} else { $ControlNew = $Data[0];}
if ($Data[1]=='*') { $ButtonNew=$Button;} else { $ButtonNew = $Data[1];}
IPSLogger_Trc(__file__, "Translate RemoteMessage $Control.$Button -> $ControlNew.$ButtonNew");
WinLIRC_doSendData($ControlNew,$ButtonNew);
}
}
// ---------------------------------------------------------------------------------------------------------------------------
function WinLIRC_SendData_Translation($Control, $Button) {
$CommConfig = get_CommunicationConfiguration();
$TranslationList = $CommConfig[c_Comm_WinLIRC][c_Property_OutTranslationList];
if (array_key_exists($Control.'.'.$Button, $TranslationList)) {
$TranslationListItems = $TranslationList[$Control.'.'.$Button];
WinLIRC_SendData_doTranslation($Control, $Button, $TranslationListItems);
return true;
} else if (array_key_exists($Control, $TranslationList)) {
$TranslationListItems = $TranslationList[$Control];
WinLIRC_SendData_doTranslation($Control, $Button, $TranslationListItems);
return true;
} else {
return false;
}
}
// ---------------------------------------------------------------------------------------------------------------------------
function WinLIRC_doSendData($Control, $Button) {
$ModuleId = get_CommConfigValue(c_Comm_WinLIRC, c_Property_ModuleId);
IPSLogger_Com(__file__, "Send Data to WinLIRC, Control='$Control', Command='$Button' (Module=$ModuleId)");
if ($ModuleId!==false and $ModuleId<>"") {
if (@IRT_SendOnce($ModuleId, $Control, $Button)==false) {
IPSLogger_Wrn(__file__, "Unknown IRTrans Message, Control='$Control', Command='$Button' (Module=$ModuleId)");
};
}
}
// ---------------------------------------------------------------------------------------------------------------------------
function WinLIRC_SendData($Parameters) {
$Control = $Parameters[1];
$Button = $Parameters[2];
if (!WinLIRC_SendData_Translation($Control, $Button)) {
WinLIRC_doSendData($Control, $Button);
}
}
// ---------------------------------------------------------------------------------------------------------------------------
function WinLIRC_ReceiveData_Translation($Control, $Button) {
$CommConfig = get_CommunicationConfiguration();
$TranslationList = $CommConfig[c_Comm_WinLIRC][c_Property_InpTranslationList];
if (array_key_exists($Control.'.'.$Button, $TranslationList)) {
$Data = explode('.', $TranslationList[$Control.'.'.$Button]);
IPSLogger_Trc(__file__, "Translate RemoteMessage $Control.$Button -> $Data[0].$Data[1]");
$Control = $Data[0];
$Button = $Data[1];
} else if (array_key_exists($Control, $TranslationList)) {
$ControlNew = $TranslationList[$Control];
IPSLogger_Trc(__file__, "Translate RemoteMessage $Control.$Button -> $ControlNew.$Button");
$Control = $TranslationList[$Control];
} else {
// Nothing to Translate ...
}
}
// ---------------------------------------------------------------------------------------------------------------------------
function WinLIRC_ReceiveData($RemoteControl, $Button, $MessageType) {
WinLIRC_ReceiveData_Translation(&$RemoteControl, &$Button);
$Parameters = array(c_Comm_WinLIRC, $RemoteControl, $Button);
if (!Entertainment_ReceiveData($Parameters, $MessageType)) {
if ($MessageType==c_MessageType_Action) {
WinLIRC_SendData($Parameters);
}
}
}
// ---------------------------------------------------------------------------------------------------------------------------
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_Webfront($RemoteControl, $Button) {
IPSLogger_Com(__file__, "Received Data from WinLIRC-Webfront, Control='$RemoteControl', Command='$Button'");
WinLIRC_ReceiveData($RemoteControl, $Button, c_MessageType_Action);
}
// ---------------------------------------------------------------------------------------------------------------------------
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);
}
?>