作者:Spoosi
项目:KH_UniF
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);
}
作者:Nall-cha
项目:IPSVoiceRS
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;
}
作者:Vansda
项目:SymconHU
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);
}
}
作者:KOS-C
项目:IPSLibrar
/**
* @public
*
* Ermöglicht das Verarbeiten eines Taster Signals
*
*/
public function ExecuteButton () {
$device = new IPSShadowing_Device($this->instanceId);
$movementId = GetValue(IPS_GetObjectIDByIdent(c_Control_Movement, $this->instanceId));
if ($movementId==c_MovementId_MovingIn or $movementId==c_MovementId_MovingOut or $movementId==c_MovementId_Up or $movementId==c_MovementId_Down) {
$device->MoveByControl(c_MovementId_Stop);
} else {
$device->MoveByControl($this->movementId);
}
}
作者:Seb081
项目:ips4Window
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;
}
作者:KOS-C
项目:IPSLibrar
/**
* @public
*
* Ermöglicht die Synchronisation der aktuellen Position der Beschattung
*
* @param string $position Aktuelle Position der Beschattung (Wertebereich 0-100)
*/
public function SyncPosition($position, IPSComponentShutter $componentToSync) {
$componentParamsToSync = $componentToSync->GetComponentParams();
$deviceConfig = get_ShadowingConfiguration();
foreach ($deviceConfig as $deviceIdent=>$deviceData) {
$componentConfig = IPSComponent::CreateObjectByParams($deviceData[c_Property_Component]);
$componentParamsConfig = $componentConfig->GetComponentParams();
if ($componentParamsConfig==$componentParamsToSync) {
$categoryIdDevices = IPSUtil_ObjectIDByPath('Program.IPSLibrary.data.modules.IPSShadowing.Devices');
$deviceId = IPS_GetObjectIDByIdent($deviceIdent, $categoryIdDevices);
$device = new IPSShadowing_Device($deviceId);
$device->MoveByEvent($position);
}
}
}
作者:KOS-C
项目:IPSLibrar
/** ObjektId aus Pfad ermittlen
*
* Der Befehl ermittelt aus einer Pfadangabe (zB. "IPSLibrary.IPSUtils.IPSUtils.inc.php") die ID des Scriptes
*
* @param string $path Pfadangabe
* @param string $returnFalse wenn true, retouniert die Funktion false wenn das übergebene Object nicht gefunden wurde
* @return integer ID des Objektes
*
*/
function IPSUtil_ObjectIDByPath($path, $returnFalse=false) {
$categoryList = explode('.',$path);
if (count($categoryList)==1 and is_numeric($categoryList[0])) {
return (int)$categoryList[0];
}
$objId = 0;
$parentId = 0;
foreach ($categoryList as $idx=>$category) {
$objId = @IPS_GetObjectIDByIdent($category, $parentId);
if ($objId===false) {
$objId=@IPS_GetObjectIDByName($category, $parentId);
}
if ($objId===false) {
if ($returnFalse) {
return false;
} else {
throw new IPSUtilException('"'.$category.'" could NOT be found while searching for Path '.$path);
}
}
$parentId = $objId;
}
return $objId;
}
作者:KOS-C
项目:IPSLibrar
/**
* @public
*
* Liefert aktuellen Zustand
*
* @return boolean aktueller Schaltzustand
*/
public function GetState() {
if ($this->b_class_multi and ($this->channel > 0))
$id = @IPS_GetObjectIDByIdent("MultiInstance".$this->channel."Variable",(int)$this->instanceId);
else
$id = @IPS_GetObjectIDByIdent("DataVariableBoolean",(int)$this->instanceId);
if ($id > 0)
return GetValue($id);
else
return false;
}
作者:Tommi2Da
项目:ipsymcon-phpmodule-by-Tomm
/**
* Create a new EneryDev 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;
$class = $data['Class'];
$Device = $data['Id'];
$typ = $data['Typ'];
$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, "{$typ} Device " . $Device);
$ident = $class . "_" . $typ . "_" . $Device;
$ident = preg_replace("/\\W/", "_", $ident);
//nicht-Buchstaben/zahlen entfernen
IPS_SetIdent($instID, $ident);
IPS_ConnectInstance($instID, $this->InstanceID);
IPS_ApplyChanges($instID);
//set factor
if (isset($data['CounterFactor'])) {
IPS_SetProperty($instID, 'CounterFactor', floatval($data['CounterFactor']));
$this->debug(__FUNCTION__, 'Set Counterfactor=' . $data['CounterFactor']);
}
//set category
$cat = $this->GetCategory();
$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);
}
//parent
if (IPS_HasChanges($instID)) {
IPS_ApplyChanges($instID);
}
} else {
$this->debug(__FUNCTION__, 'Instance is not created!');
}
//if instID
}
//module exists
return $instID;
}
作者:TierFreun
项目:Ips2rp
protected function UnregisterTimer($Name)
{
$id = @IPS_GetObjectIDByIdent($Name, $this->InstanceID);
if ($id > 0) {
if (!IPS_EventExists($id)) {
throw new Exception('Timer not present', E_USER_NOTICE);
}
IPS_DeleteEvent($id);
}
}
作者:KOS-C
项目:IPSLibrar
private function HandleError($result) {
if ($result==false) {
$errorMessage = GetValue(IPS_GetObjectIDByIdent(AM_VAR_LASTERROR, $this->instanceId));
trigger_error($errorMessage);
}
}
作者:Nall-cha
项目:IPSDynamicVisuContro
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);
}
}
}
作者:KOS-C
项目:IPSLibrar
</head>
<body >
<a href="#" onClick=trigger_button('Refresh','','')>Refresh</a> |
<a href="#" onClick=trigger_button('Overview','','')>Übersicht</a> |
<a href="#" onClick=trigger_button('Logs','','')>Log File's</a> |
<a href="#" onClick=trigger_button('Updates','','')>Update's</a> |
<a href="#" onClick=trigger_button('NewModule','','')>Neues Modul</a>
<BR>
<BR>
<?php
IPSUtils_Include("IPSModuleManagerGUI.inc.php", "IPSLibrary::app::modules::IPSModuleManagerGUI");
$baseId = IPSUtil_ObjectIDByPath('Program.IPSLibrary.data.modules.IPSModuleManagerGUI');
$action = GetValue(IPS_GetObjectIDByIdent(IPSMMG_VAR_ACTION, $baseId));
$module = GetValue(IPS_GetObjectIDByIdent(IPSMMG_VAR_MODULE, $baseId));
$info = GetValue(IPS_GetObjectIDByIdent(IPSMMG_VAR_INFO, $baseId));
$processing = !IPSModuleManagerGUI_GetLock();
if (!$processing) {
IPSModuleManagerGUI_ReleaseLock();
}
switch ($action) {
case IPSMMG_ACTION_OVERVIEW:
include 'IPSModuleManagerGUI_Overview.php';
break;
case IPSMMG_ACTION_UPDATES:
include 'IPSModuleManagerGUI_Updates.php';
break;
case IPSMMG_ACTION_MODULE:
include 'IPSModuleManagerGUI_Module.php';
break;
case IPSMMG_ACTION_WIZARD:
作者:mcbeye
项目:IPSLocativ
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;
}
作者:Nall-cha
项目:IPSSqueezeBo
protected function SetTimerInterval($Name, $Interval)
{
$id = @IPS_GetObjectIDByIdent($Name, $this->InstanceID);
if ($id === false) {
throw new Exception('Timer not present');
}
if (!IPS_EventExists($id)) {
throw new Exception('Timer not present');
}
$Event = IPS_GetEvent($id);
if ($Interval < 1) {
if ($Event['EventActive']) {
IPS_SetEventActive($id, false);
}
} else {
if ($Event['CyclicTimeValue'] != $Interval) {
IPS_SetEventCyclic($id, 0, 0, 0, 0, 1, $Interval);
}
if (!$Event['EventActive']) {
IPS_SetEventActive($id, true);
}
}
}
作者:Tommi2Da
项目:ipsymcon-phpmodule-by-Tomm
/**
* 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;
}
作者:KOS-C
项目:IPSLibrar
/**
* Schreiben von Wetterdaten anhand des Namens
*
* @param string $name Name der Variablen
* @param string $value Wert der geschrieben werden soll
*/
function IPSWeatherFAT_SetValue($name, $value) {
$categoryId_Weather = IPSUtil_ObjectIDByPath('Program.IPSLibrary.data.modules.Weather.IPSWeatherForcastAT');
$variableId = IPS_GetObjectIDByIdent($name, $categoryId_Weather);
SetValue($variableId, $value);
}
作者:Vansda
项目:SymconHU
public function SetValue($key, $value) {
$stateId = IPS_GetObjectIDByIdent('STATE', $this->InstanceID);
$cmId = IPS_GetObjectIDByIdent('COLOR_MODE', $this->InstanceID);
$ctId = @IPS_GetObjectIDByIdent('COLOR_TEMPERATURE', $this->InstanceID);
$briId = IPS_GetObjectIDByIdent('BRIGHTNESS', $this->InstanceID);
$satId = @IPS_GetObjectIDByIdent('SATURATION', $this->InstanceID);
$hueId = @IPS_GetObjectIDByIdent('HUE', $this->InstanceID);
$colorId = @IPS_GetObjectIDByIdent('COLOR', $this->InstanceID);
$stateValue = GetValueBoolean($stateId);
$cmValue = $cmId ? GetValueInteger($cmId) : 0;
$ctValue = $ctId ? (500 - round(347 * GetValueInteger($ctId) / 100)) : 0;
$briValue = round(GetValueInteger($briId)*2.54);
$satValue = $satId ? round(GetValueInteger($satId)*2.54) : 0;
$hueValue = $hueId ? GetValueInteger($hueId) : 0;
$colorValue = $colorId ? GetValueInteger($colorId) : 0;
switch ($key) {
case 'STATE':
$stateNewValue = $value;
break;
case 'COLOR':
$colorNewValue = $value;
$stateNewValue = true;
$hex = str_pad(dechex($value), 6, 0, STR_PAD_LEFT);
$hsv = $this->HEX2HSV($hex);
SetValueInteger($colorId, $value);
$hueNewValue = $hsv['h'];
$briNewValue = $hsv['v'];
$satNewValue = $hsv['s'];
$cmNewValue = 0;
break;
case 'BRIGHTNESS':
$briNewValue = $value;
$stateNewValue = true;
if (IPS_GetProperty($this->InstanceID, 'LightFeatures') != 3) {
if ($cmValue == '0') {
$newHex = $this->HSV2HEX($hueValue, $satValue, $briNewValue);
SetValueInteger($colorId, hexdec($newHex));
$hueNewValue = $hueValue;
$satNewValue = $satValue;
} else {
$ctNewValue = $ctValue;
}
}
break;
case 'SATURATION':
$cmNewValue = 0;
$satNewValue = $value;
$stateNewValue = true;
$newHex = $this->HSV2HEX($hueValue, $satNewValue, $briValue);
SetValueInteger($colorId, hexdec($newHex));
$hueNewValue = $hueValue;
$briNewValue = $briValue;
break;
case 'COLOR_TEMPERATURE':
$cmNewValue = 1;
$ctNewValue = $value;
$briNewValue = $briValue;
break;
case 'COLOR_MODE':
$cmNewValue = $value;
$stateNewValue = true;
if ($cmNewValue == 1) {
$ctNewValue = $ctValue;
IPS_SetHidden($colorId, true);
IPS_SetHidden($ctId, false);
IPS_SetHidden($satId, true);
} else {
$hueNewValue = $hueValue;
$satNewValue = $satValue;
$briNewValue = $briValue;
$newHex = $this->HSV2HEX($hueValue, $satValue, $briValue);
SetValueInteger($colorId, hexdec($newHex));
IPS_SetHidden($colorId, false);
IPS_SetHidden($ctId, true);
IPS_SetHidden($satId, false);
}
break;
}
$changes = array();
if (isset($stateNewValue)) {
SetValueBoolean($stateId, $stateNewValue);
$changes['on'] = $stateNewValue;
}
if (isset($hueNewValue)) {
SetValueInteger($hueId, $hueNewValue);
$changes['hue'] = $hueNewValue;
}
if (isset($satNewValue)) {
SetValueInteger($satId, round($satNewValue * 100 / 254));
$changes['sat'] = $satNewValue;
}
if (isset($briNewValue)) {
SetValueInteger($briId, round($briNewValue * 100 / 254));
$changes['bri'] = $briNewValue;
}
if (isset($ctNewValue)) {
SetValueInteger($ctId, 100 - round(($ctNewValue - 153) * 100 / 347));
//.........这里部分代码省略.........
作者:KOS-C
项目:IPSLibrar
/**
* @public
*
* Die Funktion registriert ein ScriptFile anhand des Filenames und Directory Pfades in IPS
*
* @param string $file Name des Script Files
*/
public function UnregisterScriptByFilename($file) {
$scriptPath = $this->GetScriptPathByFileName($file);
$scriptName = $this->GetScriptNameByFileName($file);
$this->logHandler->Debug("Search Script $scriptPath.$scriptName");
$pathId = IPSUtil_ObjectIDByPath($scriptPath, true);
$scriptId = @IPS_GetObjectIDByIdent(Get_IdentByName($scriptName), $pathId);
if ($scriptId!==false) {
$this->logHandler->Debug("Unegister Script $scriptName in $scriptPath (File=$file)");
IPS_DeleteScript($scriptId, true);
}
}
作者:geelif
项目:IPS_NZBGe
public function ImportVersionInfo()
{
if (!$this->VariableExists("Version")) {
$createdVariableId = $this->RegisterVariableString($this->ReadPropertyString("NzbIdentPrefix") . "Version", "Version");
}
SetValueString(IPS_GetObjectIDByIdent($this->ReadPropertyString("NzbIdentPrefix") . "Version", $this->InstanceID), $this->GetVersion());
}