本文整理汇总了PHP中IPS_SetIdent函数的典型用法代码示例。如果您正苦于以下问题:PHP IPS_SetIdent函数的具体用法?PHP IPS_SetIdent怎么用?PHP IPS_SetIdent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IPS_SetIdent函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
}
示例2: 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;
}
示例3: 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);
}
示例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: 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;
}
示例6: 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);
}
}
示例7: CreateLink
protected function CreateLink($Ident, $Name, $Target = 0)
{
if (!($LinkID = @IPS_GetObjectIdByIdent($Ident, $this->InstanceID))) {
$LinkID = IPS_CreateLink();
IPS_SetName($LinkID, $Name);
IPS_SetParent($LinkID, $this->InstanceID);
IPS_SetIdent($LinkID, $Ident);
if ($Target) {
IPS_SetLinkTargetID($LinkID, $Target);
$EventID = IPS_CreateEvent(0);
IPS_SetParent($EventID, $this->InstanceID);
// $LinkID);
IPS_SetEventTrigger($EventID, 1, $Target);
IPS_SetEventScript($EventID, 'PJ_UpdateColor($_IPS[\'TARGET\']);');
}
}
}
示例8: GenerateMediaObjectEx
public function GenerateMediaObjectEx(string $Text, int $MediaID, string $Format, string $Codec, string $Language)
{
if ($MediaID == 0) {
$MediaID = @IPS_GetObjectIDByIdent('Voice', $this->InstanceID);
}
if ($MediaID > 0) {
if (IPS_MediaExists($MediaID) === false) {
trigger_error('MediaObject not exists.', E_USER_NOTICE);
}
return false;
if (IPS_GetMedia($MediaID)['MediaType'] != 2) {
trigger_error('Wrong MediaType', E_USER_NOTICE);
}
return false;
}
$raw = $this->LoadTTSFile($Text, '', 0, $Format, $Codec, $Language, true);
if ($raw === false) {
return false;
}
if ($MediaID === false) {
$MediaID = IPS_CreateMedia(2);
IPS_SetMediaCached($MediaID, true);
IPS_SetName($MediaID, 'Voice');
IPS_SetParent($MediaID, $this->InstanceID);
IPS_SetIdent($MediaID, 'Voice');
}
$Filename = 'media' . DIRECTORY_SEPARATOR . $MediaID . '.' . strtolower($Codec);
IPS_SetMediaFile($MediaID, $Filename, False);
IPS_SetMediaContent($MediaID, base64_encode($raw));
IPS_SetInfo($MediaID, $Text);
return $MediaID;
}
示例9: RegisterVariableByParent
/**
* RegisterVariableByParent
* @param integer $ParentID
* @param string $Ident
* @param string $Name
* @param integer $Type
* @param string $Profile
* @param integer $Position
* @return integer
*/
private function RegisterVariableByParent($ParentID, $Ident, $Name, $Type, $Profile = "", $Position = 0)
{
if ($Profile !== "") {
//prefer system profiles
if (IPS_VariableProfileExists("~" . $Profile)) {
$Profile = "~" . $Profile;
}
if (!IPS_VariableProfileExists($Profile)) {
throw new Exception("Profile with name " . $Profile . " does not exist");
}
}
//search for already available variables with proper ident
$vid = @IPS_GetObjectIDByIdent($Ident, $ParentID);
//properly update variableID
if ($vid === false) {
$vid = 0;
}
//we have a variable with the proper ident. check if it fits
if ($vid > 0) {
//check if we really have a variable
if (!IPS_VariableExists($vid)) {
throw new Exception("Ident with name " . $Ident . " is used for wrong object type");
}
//bail out
//check for type mismatch
if (IPS_GetVariable($vid)["VariableType"] != $Type) {
//mismatch detected. delete this one. we will create a new below
IPS_DeleteVariable($vid);
//this will ensure, that a new one is created
$vid = 0;
}
}
//we need to create one
if ($vid === 0) {
$vid = IPS_CreateVariable($Type);
//configure it
IPS_SetParent($vid, $ParentID);
IPS_SetIdent($vid, $Ident);
IPS_SetName($vid, $Name);
IPS_SetPosition($vid, $Position);
//IPS_SetReadOnly($vid, true);
}
//update variable profile. profiles may be changed in module development.
//this update does not affect any custom profile choices
IPS_SetVariableCustomProfile($vid, $Profile);
return $vid;
}
示例10: WriteCoil
/**
* ModBusMaster_WriteCoil
* @param boolean $Value
* @return boolean
*/
public function WriteCoil($Value)
{
if ($this->ReadPropertyBoolean("ReadOnly")) {
trigger_error("Address is marked as read-only!", E_USER_WARNING);
return;
}
if ($this->ReadPropertyInteger("DataType") === 0) {
$resultat = $this->SendDataToParent(json_encode(array("DataID" => "{A3419A88-C83B-49D7-8706-D3AFD596DFBB}", "FC" => "5", "Address" => $this->ReadPropertyInteger("Address"), "Data" => $Value)));
if ($this->ReadPropertyInteger("SwitchDuration") > 0 and $Value) {
$eid = @IPS_GetObjectIDByIdent("SwitchDuration", $this->InstanceID);
if ($eid === false) {
$eid = 0;
} else {
if (IPS_GetEvent($eid)['EventType'] != 1) {
IPS_DeleteEvent($eid);
$eid = 0;
}
}
if ($eid == 0) {
$eid = IPS_CreateEvent(1);
IPS_SetParent($eid, $this->InstanceID);
IPS_SetIdent($eid, "SwitchDuration");
IPS_SetName($eid, "SwitchDuration");
IPS_SetHidden($eid, true);
IPS_SetEventScript($eid, "ModBusMaster_WriteCoil(\$_IPS['TARGET'], false);IPS_SetEventActive(\$_IPS['EVENT'],false);");
}
IPS_SetEventCyclicTimeFrom($eid, date("H"), date("i"), date("s"));
IPS_SetEventCyclic($eid, 0, 0, 0, 0, 1, $this->ReadPropertyInteger("SwitchDuration"));
IPS_SetEventActive($eid, true);
}
return $resultat;
} else {
trigger_error("Invalid DataType!", E_USER_WARNING);
}
}
示例11: GenerateShutter
/**
* This function will be available automatically after the module is imported with the module control.
* Using the custom prefix this function will be callable from PHP and JSON-RPC through:
*
* LJ_GenerateShutter($id, $Start, $End);
*
*/
public function GenerateShutter($Start, $End)
{
$qid = @IPS_GetObjectIDByIdent("KNXQuick", 0);
if($qid === false) {
$qid = IPS_CreateCategory();
IPS_SetName($qid, "KNX quick");
IPS_SetIdent($qid, "KNXQuick");
}
$sid = @IPS_GetObjectIDByIdent("Shutter", $qid);
if($sid === false) {
$sid = IPS_CreateCategory();
IPS_SetName($sid, "Shutter");
IPS_SetIdent($sid, "Shutter");
IPS_SetParent($sid, $qid);
IPS_SetPosition($sid, 2);
}
for($i=$Start; $i<=$End; $i++) {
for($j=0; $j<=9; $j++) {
$iid = @IPS_GetObjectIDByIdent("Shutter".strtoupper(dechex($i).$j), $sid);
if($iid === false) {
$iid = IPS_CreateInstance("{24A9D68D-7B98-4D74-9BAE-3645D435A9EF}");
IPS_SetName($iid, "Shutter (Group ".strtoupper(dechex($i)).", Channel ".$j.")");
IPS_SetIdent($iid, "Shutter".strtoupper(dechex($i)).$j);
IPS_SetParent($iid, $sid);
IPS_SetProperty($iid, "GroupMoveAddress1", 14);
IPS_SetProperty($iid, "GroupMoveAddress2", 0);
IPS_SetProperty($iid, "GroupMoveAddress3", ($i*16)+$j);
IPS_SetProperty($iid, "GroupStopAddress1", 14);
IPS_SetProperty($iid, "GroupStopAddress2", 1);
IPS_SetProperty($iid, "GroupStopAddress3", ($i*16)+$j);
if($j > 0) {
$mapping = Array();
$mapping[] = Array(
"GroupAddress1" => 14,
"GroupAddress2" => 0,
"GroupAddress3" => $i*16
);
$mapping[] = Array(
"GroupAddress1" => 14,
"GroupAddress2" => 0,
"GroupAddress3" => 240
);
$mapping[] = Array(
"GroupAddress1" => 14,
"GroupAddress2" => 0,
"GroupAddress3" => 240+$j
);
IPS_SetProperty($iid, "GroupMoveMapping", json_encode($mapping));
$mapping = Array();
$mapping[] = Array(
"GroupAddress1" => 14,
"GroupAddress2" => 1,
"GroupAddress3" => $i*16
);
$mapping[] = Array(
"GroupAddress1" => 14,
"GroupAddress2" => 1,
"GroupAddress3" => 240
);
$mapping[] = Array(
"GroupAddress1" => 14,
"GroupAddress2" => 1,
"GroupAddress3" => 240+$j
);
IPS_SetProperty($iid, "GroupStopMapping", json_encode($mapping));
}
IPS_ApplyChanges($iid);
}
}
}
echo "Done.";
}
示例12: GetOrCreateScript
function GetOrCreateScript($parent, $ident)
{
$ObjId = @IPS_GetObjectIDByIdent($ident, $parent);
if ($ObjId === false) {
$ObjId = IPS_CreateScript(0);
IPS_SetParent($ObjId, $parent);
IPS_SetIdent($ObjId, $ident);
IPS_SetName($ObjId, $ident);
IPS_SetScriptContent($ObjId, ScriptContent($ident));
}
return $ObjId;
}
示例13: SetTimerByIdent_InSekunden
protected function SetTimerByIdent_InSekunden($ident, $Sekunden)
{
$eid = @IPS_GetObjectIDByIdent($ident, $this->InstanceID);
if ($eid === false) {
$eid = IPS_CreateEvent(1);
IPS_SetParent($eid, $this->InstanceID);
IPS_SetName($eid, $ident);
IPS_SetIdent($eid, $ident);
IPS_SetEventScript($eid, 'HMON_Benachrichtigung($_IPS[\'TARGET\'], false, true);');
IPS_SetInfo($eid, "this timer was created by script #" . $_IPS['SELF']);
}
if ($Sekunden === false) {
IPS_SetEventActive($eid, false);
return $eid;
} else {
IPS_SetEventCyclicTimeFrom($eid, intval(date("H", time() + $Sekunden)), intval(date("i", time() + $Sekunden)), intval(date("s", time() + $Sekunden)));
IPS_SetEventActive($eid, true);
return $eid;
}
}
示例14: RegisterEvent
protected function RegisterEvent($Name, $Source, $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", E_USER_WARNING);
}
if (IPS_GetEvent($id)['EventType'] != 0) {
IPS_DeleteEvent($id);
$id = 0;
}
}
if ($id == 0) {
$id = IPS_CreateEvent(0);
IPS_SetParent($id, $this->InstanceID);
IPS_SetIdent($id, $Name);
}
IPS_SetName($id, $Name);
IPS_SetHidden($id, true);
IPS_SetEventScript($id, $Script);
if ($Source > 0) {
IPS_SetEventTrigger($id, 0, $Source);
if (!IPS_GetEvent($id)['EventActive']) {
IPS_SetEventActive($id, true);
}
} else {
IPS_SetEventTrigger($id, 0, 0);
if (IPS_GetEvent($id)['EventActive']) {
IPS_SetEventActive($id, false);
}
}
}
示例15: CreateVariableByIdent
private function CreateVariableByIdent($id, $ident, $name, $type, $profile = "")
{
$vid = @IPS_GetObjectIDByIdent($ident, $id);
if ($vid === false) {
$vid = IPS_CreateVariable($type);
IPS_SetParent($vid, $id);
IPS_SetName($vid, $name);
IPS_SetIdent($vid, $ident);
if ($profile != "") {
IPS_SetVariableCustomProfile($vid, $profile);
}
}
return $vid;
}