-
Notifications
You must be signed in to change notification settings - Fork 0
/
BrownsonBase.php
61 lines (49 loc) · 1.62 KB
/
BrownsonBase.php
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
<?
class BrownsonBase extends IPSModule
{
protected $showMemoryUsage = false;
public function Create()
{
parent::Create();
}
public function ApplyChanges()
{
parent::ApplyChanges();
}
################## PRIVATE ##################
// -------------------------------------------------------------------------
protected function IsInstancePropertiesValid()
{
$instance = IPS_GetInstance($this->InstanceID);
$status = $instance['InstanceStatus'];
return ($status == 102 || $status == 104);
}
// -------------------------------------------------------------------------
protected function ShowMemoryUsage($statusMessage) {
if ($this->showMemoryUsage) {
$memory = round(memory_get_usage() / 1024 / 1024, 2);
$this->SendDebug("ShowMemoryUsage", $statusMessage . ', UsedMemory='.$memory. " MB", 0);
}
}
// -------------------------------------------------------------------------
protected function ShowMemoryAvailable($statusMessage) {
if ($this->showMemoryUsage) {
$memory = ini_get('memory_limit');
$this->SendDebug("ShowMemoryAvailable", $statusMessage . ', AvailableMemory='.$memory. " MB", 0);
}
}
// -------------------------------------------------------------------------
protected function RegisterMedia ($ident, $name, $fileName) {
$mediaId = @IPS_GetObjectIDByIdent($ident, $this->InstanceID);
if ($mediaId === false) {
$mediaId = IPS_CreateMedia(1);
IPS_SetParent($mediaId, $this->InstanceID);
IPS_SetIdent($mediaId, $ident);
IPS_SetName($mediaId, $name);
IPS_SetPosition($mediaId, 0);
IPS_SetMediaFile($mediaId, $fileName, false);
}
return $mediaId;
}
}
?>