本文整理汇总了PHP中IPS_SetName函数的典型用法代码示例。如果您正苦于以下问题:PHP IPS_SetName函数的具体用法?PHP IPS_SetName怎么用?PHP IPS_SetName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IPS_SetName函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CreateVariable
function CreateVariable($Name, $Type, $Value, $Ident = '', $ParentID = 0)
{
echo "CreateVariable: ( {$Name}, {$Type}, {$Value}, {$Ident}, {$ParentID} ) \n";
if ('' != $Ident) {
$VarID = @IPS_GetObjectIDByIdent($Ident, $ParentID);
if (false !== $VarID) {
SetVariable($VarID, $Type, $Value);
return;
}
}
$VarID = @IPS_GetObjectIDByName($Name, $ParentID);
if (false !== $VarID) {
$Obj = IPS_GetObject($VarID);
if (2 == $Obj['ObjectType']) {
$Var = IPS_GetVariable($VarID);
if ($Type == $Var['VariableValue']['ValueType']) {
SetVariable($VarID, $Type, $Value);
return;
}
}
}
$VarID = IPS_CreateVariable($Type);
IPS_SetParent($VarID, $ParentID);
IPS_SetName($VarID, $Name);
if ('' != $Ident) {
IPS_SetIdent($VarID, $Ident);
}
SetVariable($VarID, $Type, $Value);
}
示例2: RefreshLinks
private function RefreshLinks()
{
if ($this->ReadPropertyInteger("LinkSource") == 0) {
foreach (IPS_GetChildrenIDs($this->InstanceID) as $Child) {
if (IPS_GetObject($Child)['ObjectType'] == 6) {
IPS_DeleteLink($Child);
}
}
return;
}
$present = array();
foreach (IPS_GetChildrenIDs($this->InstanceID) as $Child) {
if (IPS_GetObject($Child)['ObjectType'] == 6) {
$present[] = IPS_GetLink($Child)['TargetID'];
}
}
$create = array_diff(IPS_GetChildrenIDs($this->ReadPropertyInteger("LinkSource")), $present);
foreach ($create as $Target) {
if (IPS_GetObject($Target)["ObjectIsHidden"]) {
continue;
}
$Link = IPS_CreateLink();
IPS_SetParent($Link, $this->InstanceID);
IPS_SetName($Link, IPS_GetName($Target));
IPS_SetLinkTargetID($Link, $Target);
}
}
示例3: createGroupWithID
public function createGroupWithID($name, $id, $parentID)
{
$group = @IPS_GetObjectIDByIdent($id, $parentID);
if (!$group) {
$group = IPS_CreateCategory();
IPS_SetName($group, $name);
IPS_SetParent($group, $parentID);
IPS_SetIdent($group, $id);
$variable = IPS_CreateVariable(0);
IPS_SetParent($variable, $group);
IPS_SetName($variable, "Turn on");
IPS_SetIdent($variable, "state_" . $id);
SetValue($variable, true);
$variable = IPS_CreateVariable(1);
IPS_SetParent($variable, $group);
IPS_SetName($variable, "Delay");
IPS_SetIdent($variable, "delay_" . $id);
SetValue($variable, 3600);
$childs = IPS_CreateCategory();
IPS_SetName($childs, "Links");
IPS_SetParent($childs, $group);
IPS_SetIdent($childs, "childs_" . $id);
}
return $group;
}
示例4: __construct
/**
* @public
*
* Initialisierung eines IPSComponentShutter_FS20 Objektes
*
* @param integer $instanceId InstanceId des FS20 Devices
*/
public function __construct($instanceId) {
$this->instanceId = IPSUtil_ObjectIDByPath($instanceId);
$this->isRunningId = @IPS_GetObjectIDByIdent('isrunning', $this->instanceId);
if($this->isRunningId===false) {
$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");
}
}
示例5: CheckVariable
function CheckVariable($name, $vartyp, $profile, $parentID)
{
$InstanzID = @IPS_GetVariableIDByName($name, $parentID);
if ($InstanzID === false) {
$InstanzID = IPS_CreateVariable($vartyp);
IPS_SetName($InstanzID, $name);
// Instanz benennen
IPS_SetParent($InstanzID, $parentID);
IPS_SetVariableCustomProfile($InstanzID, $profile);
}
//echo "ID: ".$InstanzID." ".$name."\n";
return $InstanzID;
}
示例6: __construct
/**
* constructor
*
* @throws Exception if $type is not valid
* @access public
*/
public function __construct($parentId, $name, $content, $debug = false)
{
$this->parentId = $parentId;
$this->name = $name;
$this->content = $content;
$this->debug = $debug;
$this->id = @IPS_GetScriptIDByName($this->name, $this->parentId);
//check if event does already exist
if ($this->id == false) {
if ($this->debug) {
echo "INFO - create IPS script {$name}\n";
}
$this->id = IPS_CreateScript(0);
IPS_SetName($this->id, $this->name);
IPS_SetParent($this->id, $this->parentId);
IPS_SetScriptContent($this->id, $this->content);
IPS_SetInfo($this->id, "this script was created by script " . $_IPS['SELF'] . " which is part of the ips-library (https://github.com/florianprobst/ips-library)");
}
}
示例7: RegisterTimer
protected function RegisterTimer($ident, $interval, $script) {
$id = @IPS_GetObjectIDByIdent($ident, $this->InstanceID);
if ($id && IPS_GetEvent($id)['EventType'] <> 1) {
IPS_DeleteEvent($id);
$id = 0;
}
if (!$id) {
$id = IPS_CreateEvent(1);
IPS_SetParent($id, $this->InstanceID);
IPS_SetIdent($id, $ident);
}
IPS_SetName($id, $ident);
IPS_SetHidden($id, true);
IPS_SetEventScript($id, "\$id = \$_IPS['TARGET'];\n$script;");
if (!IPS_EventExists($id)) throw new Exception("Ident with name $ident is used for wrong object type");
if (!($interval > 0)) {
IPS_SetEventCyclic($id, 0, 0, 0, 0, 1, 1);
IPS_SetEventActive($id, false);
} else {
IPS_SetEventCyclic($id, 0, 0, 0, 0, 1, $interval);
IPS_SetEventActive($id, true);
}
}
示例8: __construct
/**
* constructor
*
* @throws Exception if $type is not valid
* @access public
*/
public function __construct($parentId, $name, $cycle, $debug = false)
{
$this->parentId = $parentId;
$this->name = $name;
$this->cycle = $cycle;
$this->debug = $debug;
$this->id = @IPS_GetEventIDByName($this->name, $this->parentId);
//check if event does already exist
if ($this->id == false) {
if ($this->debug) {
echo "INFO - create IPS event {$name}\n";
}
$this->id = IPS_CreateEvent(1);
//create trigger event and store id
IPS_SetName($this->id, $this->name);
//set event name
IPS_SetParent($this->id, $this->parentId);
//move event to parent (this will be called when trigger occurs)
IPS_SetEventCyclic($this->id, 0, 1, 0, 0, 1, $cycle);
//every $cycle seconds
IPS_SetInfo($this->id, "this event was created by script " . $_IPS['SELF'] . " which is part of the ips-library (https://github.com/florianprobst/ips-library)");
$this->activate();
}
}
示例9: ApplyData
public function ApplyData($data) {
$data = (array)$data;
$state = (array)$data['state'];
/*
* Properties
*/
$dirty = false;
$modelid = utf8_decode((string)$data['modelid']);
$type = utf8_decode((string)$data['type']);
$name = utf8_decode((string)$data['name']);
if (IPS_GetProperty($this->InstanceID, 'ModelId') != $modelid) {
IPS_SetProperty($this->InstanceID, 'ModelId', $modelid);
$dirty = true;
}
if (IPS_GetProperty($this->InstanceID, 'Type') != $type) {
IPS_SetProperty($this->InstanceID, 'Type', $type);
$dirty = true;
}
if (IPS_GetName($this->InstanceID) != $name) {
IPS_SetName($this->InstanceID, $name);
$dirty = true;
}
// Setze den Modus
if (isset($state['ct']) && isset($state['hue'])) {
// HUE+CT Lamp
$lightFeature = 0;
} elseif(isset($state['hue'])) {
// HUE Lamp
$lightFeature = 1;
} elseif(isset($state['ct'])) {
// CT Lamp
$lightFeature = 2;
} else {
// Lux Lamp
$lightFeature = 3;
}
if (IPS_GetProperty($this->InstanceID, 'LightFeatures') != $lightFeature) {
IPS_SetProperty($this->InstanceID, 'LightFeatures', $lightFeature);
$dirty = true;
}
if ($dirty) IPS_ApplyChanges($this->InstanceID);
/*
* Variables
*/
$stateId = $this->RegisterVariableBoolean("STATE", "Zustand", "~Switch");
$this->EnableAction("STATE");
IPS_SetPosition($stateId, 1);
$cmId = $this->RegisterVariableInteger("COLOR_MODE", "Modus", "ColorModeSelect.Hue");
$this->EnableAction("COLOR_MODE");
IPS_SetPosition($cmId, 2);
IPS_SetIcon($cmId, 'ArrowRight');
$briId = $this->RegisterVariableInteger("BRIGHTNESS", "Helligkeit", "~Intensity.100");
$this->EnableAction("BRIGHTNESS");
IPS_SetIcon($briId, 'Sun');
IPS_SetPosition($briId, 5);
if ($lightFeature == 0 || $lightFeature == 1) {
$hueId = $this->RegisterVariableInteger("HUE", "Hue");
IPS_SetHidden($hueId, true);
} else {
$delete = @IPS_GetObjectIDByIdent("HUE", $this->InstanceID);
if ($delete !== false) IPS_DeleteVariable($delete);
}
if ($lightFeature == 0) {
IPS_SetVariableCustomProfile($cmId, 'ColorModeSelect.Hue');
IPS_SetHidden($cmId, false);
} else {
IPS_SetHidden($cmId, true);
}
if ($lightFeature == 0 || $lightFeature == 2) {
$ctId = $this->RegisterVariableInteger("COLOR_TEMPERATURE", "Farbtemperatur", "~Intensity.100");
$this->EnableAction("COLOR_TEMPERATURE");
IPS_SetIcon($ctId, 'Bulb');
IPS_SetPosition($ctId, 4);
} else {
$delete = @IPS_GetObjectIDByIdent("COLOR_TEMPERATURE", $this->InstanceID);
if ($delete !== false) IPS_DeleteVariable($delete);
}
if ($lightFeature == 0 || $lightFeature == 1) {
$colorId = $this->RegisterVariableInteger("COLOR", "Farbe", "~HexColor");
$this->EnableAction("COLOR");
IPS_SetPosition($colorId, 3);
IPS_SetIcon($colorId, 'Bulb');
$satId = $this->RegisterVariableInteger("SATURATION", utf8_decode("Sättigung"), "~Intensity.100");
$this->EnableAction("SATURATION");
IPS_SetIcon($satId, 'Intensity');
//.........这里部分代码省略.........
示例10: CreateEnergyDevice
/**
* Create a new EnergyDev instance and set its properties
* @param array $data parsed record
* @param String $caps String semicolon seperated capabilities of this device
* @return int new Instance ID
*/
private function CreateEnergyDevice($data, $caps)
{
$instID = 0;
$Device = $data['Id'];
$typ = $data['Typ'];
$name = $data['Name'];
$branch = $data['Branch'];
unset($data['Branch']);
if (!$name) {
$name = "XS1 {$branch} {$Device}";
}
$class = __CLASS__ . "-EN";
//$host = $this->GetHost();
$ModuleID = $this->module_interfaces['EnergyDev'];
if (IPS_ModuleExists($ModuleID)) {
//return $result;
$this->debug(__FUNCTION__, 'Device:' . $Device);
$instID = IPS_CreateInstance($ModuleID);
if ($instID > 0) {
IPS_SetProperty($instID, 'DeviceID', $Device);
IPS_SetProperty($instID, 'Class', $class);
IPS_SetProperty($instID, 'Typ', $typ);
IPS_SetProperty($instID, 'CapList', $caps);
IPS_SetProperty($instID, 'Debug', $this->isDebug());
//follow debug settings from splitter
IPS_SetName($instID, "XS1 {$branch} '{$name}'");
$ident = $class . "_" . $branch . "_{$Device}";
$ident = preg_replace("/\\W/", "_", $ident);
//nicht-Buchstaben/zahlen entfernen
IPS_SetIdent($instID, $ident);
IPS_ConnectInstance($instID, $this->InstanceID);
IPS_ApplyChanges($instID);
//set category
$cat = $this->GetCategory() . " {$branch}" . "s";
$pcat = $this->GetParentCategory();
$ident = preg_replace("/\\W/", "_", $cat);
//fix naming
$catid = @IPS_GetObjectIDByIdent($ident, $pcat);
if ($catid == 0) {
$catid = IPS_CreateCategory();
IPS_SetName($catid, $cat);
if (IPS_SetIdent($catid, $ident) && IPS_SetParent($catid, $pcat)) {
IPS_LogMessage($class, "Category {$cat} Ident {$ident} ({$catid}) created");
} else {
IPS_LogMessage($class, "Category {$cat} Ident {$ident} ({$catid}) FAILED");
}
}
$this->debug(__FUNCTION__, "Category:{$catid}");
if (!IPS_SetParent($instID, $catid)) {
$this->debug(__FUNCTION__, "SetParent Instance {$instID} to Cat {$catid} failed, Dropping instance");
IPS_DeleteInstance($instID);
$instID = 0;
} else {
$this->debug(__FUNCTION__, 'New ID:' . $instID);
}
//if instID
} else {
$this->debug(__FUNCTION__, 'Instance is not created!');
}
}
//module exists
return $instID;
}
示例11: RegisterTimer
protected function RegisterTimer($Name, $Interval, $Script)
{
$id = @IPS_GetObjectIDByIdent($Name, $this->InstanceID);
if ($id === false) {
$id = IPS_CreateEvent(1);
IPS_SetParent($id, $this->InstanceID);
IPS_SetIdent($id, $Name);
}
IPS_SetName($id, $Name);
IPS_SetHidden($id, true);
IPS_SetEventScript($id, $Script);
if ($Interval > 0) {
IPS_SetEventCyclic($id, 0, 0, 0, 0, 1, $Interval);
IPS_SetEventActive($id, true);
} else {
IPS_SetEventCyclic($id, 0, 0, 0, 0, 1, 1);
IPS_SetEventActive($id, false);
}
}
示例12: CreateWSDevice
/**
* Create a new WSDev instance and set its properties
* @param array $data parsed record
* @param String $caps String semicolon seperated capabilities of this device
* @return int new Instance ID
*/
private function CreateWSDevice($data, $caps)
{
$instID = 0;
$Device = $data['Id'];
$typ = $data['Typ'];
$ModuleID = $this->module_interfaces['WSDEV'];
if (IPS_ModuleExists($ModuleID)) {
//return $result;
$this->debug(__FUNCTION__, "Create Device {$Device},Type {$typ}");
$instID = IPS_CreateInstance($ModuleID);
if ($instID > 0) {
IPS_ConnectInstance($instID, $this->InstanceID);
//Parents are ourself!
IPS_SetProperty($instID, 'DeviceID', $Device);
IPS_SetProperty($instID, 'Class', __CLASS__);
IPS_SetProperty($instID, 'Typ', $typ);
IPS_SetProperty($instID, 'CapList', $caps);
IPS_SetProperty($instID, 'Debug', $this->isDebug());
//follow debug settings from splitter
switch ($Device) {
case 0:
case $Device < 8:
IPS_SetName($instID, 'Sensor ' . $Device);
break;
case 8:
IPS_SetName($instID, 'KombiSensor');
break;
case 9:
IPS_SetName($instID, 'InnenSensor');
break;
default:
IPS_SetName($instID, "unknown Sensor('" . strToHex($Device) . "')");
break;
}
//switch
$ident = __CLASS__ . "_WS_{$Device}";
$ident = preg_replace("/\\W/", "_", $ident);
//nicht-Buchstaben/zahlen entfernen
IPS_SetIdent($instID, $ident);
IPS_ApplyChanges($instID);
$cat = $this->GetCategory();
$pcat = $this->GetParentCategory();
$ident = preg_replace("/\\W/", "_", $cat);
//nicht-Buchstaben/zahlen entfernen
$catid = @IPS_GetObjectIDByIdent($ident, $pcat);
if ($catid == 0) {
$catid = IPS_CreateCategory();
IPS_SetName($catid, $cat);
if (IPS_SetIdent($catid, $ident) && IPS_SetParent($catid, $pcat)) {
IPS_LogMessage(__CLASS__, "Category {$cat} Ident {$ident} ({$catid}) created");
} else {
IPS_LogMessage(__CLASS__, "Category {$cat} Ident {$ident} ({$catid}) FAILED");
}
}
$this->debug(__FUNCTION__, "Category:{$catid}");
if (!IPS_SetParent($instID, $catid)) {
$this->debug(__FUNCTION__, "SetParent to Cat {$catid} failed");
}
$this->debug(__FUNCTION__, 'New ID:' . $instID);
//if instID
//set willi profile for forecast
$vid = @IPS_GetObjectIDByIdent('Forecast', $instID);
if ($vid > 0) {
IPS_SetVariableCustomProfile($vid, "WS300_Willi");
}
} else {
$this->debug(__FUNCTION__, 'Instance is not created!');
}
}
//module exists
return $instID;
}
示例13: RegisterTimer
protected function RegisterTimer($Name, $Interval, $Script)
{
$id = @IPS_GetObjectIDByIdent($Name, $this->InstanceID);
if ($id === false) {
$id = 0;
}
if ($id > 0) {
if (!IPS_EventExists($id)) {
throw new Exception("Ident with name " . $Name . " is used for wrong object type");
}
if (IPS_GetEvent($id)['EventType'] != 1) {
IPS_DeleteEvent($id);
$id = 0;
}
}
if ($id == 0) {
$id = IPS_CreateEvent(1);
IPS_SetParent($id, $this->InstanceID);
IPS_SetIdent($id, $Name);
}
IPS_SetName($id, $Name);
IPS_SetHidden($id, true);
IPS_SetEventScript($id, $Script);
if ($Interval > 0) {
IPS_SetEventCyclic($id, 0, 0, 0, 0, 1, $Interval);
IPS_SetEventActive($id, true);
} else {
IPS_SetEventCyclic($id, 0, 0, 0, 0, 1, 1);
IPS_SetEventActive($id, false);
}
}
示例14: CreateInstanceByIdent
private function CreateInstanceByIdent($id, $ident, $name, $moduleid = "{485D0419-BE97-4548-AA9C-C083EB82E61E}")
{
$iid = @IPS_GetObjectIDByIdent($ident, $id);
if ($iid === false) {
$iid = IPS_CreateInstance($moduleid);
IPS_SetParent($iid, $id);
IPS_SetName($iid, $name);
IPS_SetIdent($iid, $ident);
}
return $iid;
}
示例15: CreateENDevice
/**
* Create a new EnergyDev instance and set its properties
* @param array $data parsed record
* @param String $caps String semicolon seperated capabilities of this device
* @return int new Instance ID
*/
private function CreateENDevice($data, $caps)
{
$instID = 0;
$Device = $data['Id'];
$typ = $data['Typ'];
$ModuleID = $this->module_interfaces['EnergyDev'];
if (IPS_ModuleExists($ModuleID)) {
//return $result;
$this->debug(__FUNCTION__, "Create Device {$Device},Type {$typ}");
$instID = IPS_CreateInstance($ModuleID);
if ($instID > 0) {
IPS_ConnectInstance($instID, $this->InstanceID);
//Parents are ourself!
IPS_SetProperty($instID, 'DeviceID', $Device);
IPS_SetProperty($instID, 'Class', __CLASS__);
IPS_SetProperty($instID, 'Typ', $typ);
IPS_SetProperty($instID, 'CapList', $caps);
IPS_SetProperty($instID, 'Debug', $this->isDebug());
//follow debug settings from splitter
IPS_SetName($instID, "{$typ} ID {$Device}");
$ident = __CLASS__ . "_EN_{$Device}";
$ident = preg_replace("/\\W/", "_", $ident);
//nicht-Buchstaben/zahlen entfernen
IPS_SetIdent($instID, $ident);
IPS_ApplyChanges($instID);
$cat = $this->GetCategory();
$pcat = $this->GetParentCategory();
$ident = preg_replace("/\\W/", "_", $cat);
//nicht-Buchstaben/zahlen entfernen
$catid = @IPS_GetObjectIDByIdent($ident, $pcat);
if ($catid == 0) {
$catid = IPS_CreateCategory();
IPS_SetName($catid, $cat);
if (IPS_SetIdent($catid, $ident) && IPS_SetParent($catid, $pcat)) {
IPS_LogMessage(__CLASS__, "Category {$cat} Ident {$ident} ({$catid}) created");
} else {
IPS_LogMessage(__CLASS__, "Category {$cat} Ident {$ident} ({$catid}) FAILED");
}
}
$this->debug(__FUNCTION__, "Category:{$catid}");
if (!IPS_SetParent($instID, $catid)) {
$this->debug(__FUNCTION__, "SetParent to Cat {$catid} failed");
}
$this->debug(__FUNCTION__, 'New ID:' . $instID);
//if instID
} else {
$this->debug(__FUNCTION__, 'Instance is not created!');
}
}
//module exists
return $instID;
}