Add files via upload
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"elements":
|
||||
[
|
||||
{ "type": "SelectCategory", "name": "PropertyCategoryID", "caption": "Target" },
|
||||
{ "type": "SelectInstance", "name": "PropertyGatewayID", "caption": "Gateway" },
|
||||
{ "type": "SelectMedia", "name": "PropertyMediaID", "caption": "CSV" },
|
||||
{ "type": "NumberSpinner", "name": "PropertyObjectSortOffset", "caption": "Sort-Offset" }
|
||||
|
||||
],
|
||||
"actions":
|
||||
[
|
||||
|
||||
{ "type": "Button", "label": "Create", "onClick": "VTMC_createModobjects($id);" }
|
||||
],
|
||||
"status":
|
||||
[
|
||||
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"id": "{C3286C5E-8AAB-15C8-6662-13CE28C0C85C}",
|
||||
"name": "ModCreator",
|
||||
"type": 3,
|
||||
"vendor": "J.H. Artworks",
|
||||
"aliases":
|
||||
[
|
||||
],
|
||||
"url": "https://jh-artworks.com",
|
||||
"parentRequirements": [],
|
||||
"childRequirements": [],
|
||||
"implemented": [],
|
||||
"prefix": "VTMC"
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<?
|
||||
// Klassendefinition
|
||||
class ModCreator extends IPSModule {
|
||||
// Überschreibt die interne IPS_Create($id) Funktion
|
||||
public function Create() {
|
||||
// Diese Zeile nicht löschen.
|
||||
parent::Create();
|
||||
|
||||
$this->RegisterPropertyInteger("PropertyCategoryID",0);
|
||||
$this->RegisterPropertyInteger("PropertyGatewayID",0);
|
||||
$this->RegisterPropertyInteger("PropertyMediaID",0);
|
||||
$this->RegisterPropertyInteger("PropertyObjectSortOffset",0);
|
||||
|
||||
}
|
||||
|
||||
// Überschreibt die intere IPS_ApplyChanges($id) Funktion
|
||||
public function ApplyChanges() {
|
||||
// Diese Zeile nicht löschen
|
||||
parent::ApplyChanges();
|
||||
}
|
||||
/**
|
||||
* Die folgenden Funktionen stehen automatisch zur Verfügung, wenn das Modul über die "Module Control" eingefügt wurden.
|
||||
* Die Funktionen werden, mit dem selbst eingerichteten Prefix, in PHP und JSON-RPC wiefolgt zur Verfügung gestellt:
|
||||
*
|
||||
*
|
||||
*/
|
||||
private function createModobject($socket, $catId, $pos, $objectName,$adressread,$fcread, $adresswrite, $fcwrite, $datatype,$factor,$byteorder) {
|
||||
|
||||
|
||||
$newInstance = IPS_CreateInstance("{CB197E50-273D-4535-8C91-BB35273E3CA5}");
|
||||
IPS_DisconnectInstance($newInstance);
|
||||
IPS_ConnectInstance($newInstance, $socket);
|
||||
IPS_SetName($newInstance, $objectName);
|
||||
|
||||
IPS_SetConfiguration($newInstance, '{"ByteOrder":'.$byteorder.',"DataType":'.$datatype.',"EmulateStatus":true,"Factor":'.$factor.',"Poller":1000,"ReadAddress":'.$adressread.',"ReadFunctionCode":'.$fcread.',"WriteAddress":'.$adresswrite.',"WriteFunctionCode":'.$fcwrite.'}');
|
||||
IPS_SetPosition($newInstance,$pos);
|
||||
IPS_ApplyChanges($newInstance);
|
||||
|
||||
IPS_SetParent($newInstance, $catId);
|
||||
IPS_ApplyChanges($newInstance);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function createModobjects(){
|
||||
|
||||
$idCat = $this->ReadPropertyInteger("PropertyCategoryID");
|
||||
$idGw = $this->ReadPropertyInteger("PropertyGatewayID");
|
||||
$idMedia = $this->ReadPropertyInteger("PropertyMediaID");
|
||||
$sortoffset = $this->ReadPropertyInteger("PropertyObjectSortOffset");
|
||||
|
||||
$csv = base64_decode(IPS_GetMediaContent($idMedia));
|
||||
// Zeilen in ein Array aufteilen
|
||||
$lines = explode(PHP_EOL, $csv);
|
||||
|
||||
// Anzahl der Zeilen ermitteln
|
||||
$totalLines = count($lines);
|
||||
// echo $totalLines;
|
||||
// Durch jede Zeile der CSV-Datei iterieren mit einem for loop
|
||||
for ($row = 1; $row < $totalLines-1; $row++) {
|
||||
// CSV-Zeile in ein Array von Daten aufteilen
|
||||
$data = str_getcsv($lines[$row], ";", "\"", "\\");
|
||||
|
||||
// Überprüfen, ob es sich um die Kopfzeile oder eine Datenzeile handelt
|
||||
if ($row > 0) {
|
||||
// Hier kannst du die Modobject-Funktion mit den entsprechenden Indizes aus dem $data-Array aufrufen
|
||||
//error_reporting(0);
|
||||
$this->createModobject($idGw, $idCat, $row + $sortoffset, $data[0], $data[1], $data[2], $data[3], $data[4], $data[5], $data[6],$data[7]);
|
||||
|
||||
// Beispiel-Ausgabe des ersten Elements in jeder Zeile
|
||||
// print_r($data[7]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"elements":
|
||||
[
|
||||
{ "type": "SelectCategory", "name": "PropertyCategoryID", "caption": "Target" },
|
||||
{ "type": "SelectProfile", "name": "PropertyProfileNameBool", "caption": "Profil - Bool" , "profileType": 0},
|
||||
{ "type": "SelectProfile", "name": "PropertyProfileNameInt", "caption": "Profil - Integer" , "profileType": 1},
|
||||
{ "type": "SelectProfile", "name": "PropertyProfileNameFloat", "caption": "Profil - Float" , "profileType": 2},
|
||||
{ "type": "SelectProfile", "name": "PropertyProfileNameString", "caption": "Profil - String" , "profileType": 3}
|
||||
],
|
||||
"actions":
|
||||
[
|
||||
|
||||
{ "type": "Button", "label": "Set selected Profiles", "onClick": "VTPS_setProfile($id);" }
|
||||
],
|
||||
"status":
|
||||
[
|
||||
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"id": "{74DEF544-0497-69C8-9802-00F641E279D9}",
|
||||
"name": "ProfileSetter",
|
||||
"type": 3,
|
||||
"vendor": "J.H. Artworks",
|
||||
"aliases":
|
||||
[
|
||||
],
|
||||
"url": "https://jh-artworks.com",
|
||||
"parentRequirements": [],
|
||||
"childRequirements": [],
|
||||
"implemented": [],
|
||||
"prefix": "VTPS"
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?
|
||||
// Klassendefinition
|
||||
class ProfileSetter extends IPSModule {
|
||||
// Überschreibt die interne IPS_Create($id) Funktion
|
||||
public function Create() {
|
||||
// Diese Zeile nicht löschen.
|
||||
parent::Create();
|
||||
|
||||
$this->RegisterPropertyInteger("PropertyCategoryID",0);
|
||||
$this->RegisterPropertyString("PropertyProfileNameBool","~Switch");
|
||||
$this->RegisterPropertyString("PropertyProfileNameInt","~Intensity.100");
|
||||
$this->RegisterPropertyString("PropertyProfileNameFloat","~Temperature");
|
||||
$this->RegisterPropertyString("PropertyProfileNameString","~TextBox");
|
||||
|
||||
}
|
||||
|
||||
// Überschreibt die intere IPS_ApplyChanges($id) Funktion
|
||||
public function ApplyChanges() {
|
||||
// Diese Zeile nicht löschen
|
||||
parent::ApplyChanges();
|
||||
}
|
||||
/**
|
||||
* Die folgenden Funktionen stehen automatisch zur Verfügung, wenn das Modul über die "Module Control" eingefügt wurden.
|
||||
* Die Funktionen werden, mit dem selbst eingerichteten Prefix, in PHP und JSON-RPC wiefolgt zur Verfügung gestellt:
|
||||
*
|
||||
*
|
||||
*/
|
||||
public function setProfile() {
|
||||
|
||||
$idKat = $this->ReadPropertyInteger("PropertyCategoryID");
|
||||
$katChilds = IPS_GetChildrenIDs($idKat);
|
||||
|
||||
foreach ($katChilds as $katChild) {
|
||||
$chilid = IPS_GetChildrenIDs($katChild)[0];
|
||||
$parentname = IPS_GetName($katChild);
|
||||
|
||||
$payload = GetValue($chilid);
|
||||
// determine data type
|
||||
if(is_string($payload)) {
|
||||
$ips_var_type = 3;
|
||||
$profile = $this->ReadPropertyString("PropertyProfileNameString");
|
||||
} else if(is_float($payload)) {
|
||||
$ips_var_type = 2;
|
||||
$profile = $this->ReadPropertyString("PropertyProfileNameFloat");
|
||||
} else if(is_int($payload)) {
|
||||
$ips_var_type = 1;
|
||||
$profile = $this->ReadPropertyString("PropertyProfileNameInt");
|
||||
} else if(is_bool($payload)) {
|
||||
$ips_var_type = 0;
|
||||
$profile = $this->ReadPropertyString("PropertyProfileNameBool");
|
||||
} else { // unsupported
|
||||
return false;
|
||||
}
|
||||
|
||||
IPS_SetVariableCustomProfile($chilid, $profile);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"elements":
|
||||
[
|
||||
{ "type": "SelectCategory", "name": "PropertyCategoryID", "caption": "Target" }
|
||||
],
|
||||
"actions":
|
||||
[
|
||||
|
||||
{ "type": "Button", "label": "Rename", "onClick": "VTRN_rename($id);" }
|
||||
],
|
||||
"status":
|
||||
[
|
||||
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"id": "{97873A1E-70E1-9AB9-0CA1-812C762E68FC}",
|
||||
"name": "Renamer",
|
||||
"type": 3,
|
||||
"vendor": "J.H. Artworks",
|
||||
"aliases":
|
||||
[
|
||||
],
|
||||
"url": "https://jh-artworks.com",
|
||||
"parentRequirements": [],
|
||||
"childRequirements": [],
|
||||
"implemented": [],
|
||||
"prefix": "VTRN"
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?
|
||||
// Klassendefinition
|
||||
class Renamer extends IPSModule {
|
||||
// Überschreibt die interne IPS_Create($id) Funktion
|
||||
public function Create() {
|
||||
// Diese Zeile nicht löschen.
|
||||
parent::Create();
|
||||
|
||||
$this->RegisterPropertyInteger("PropertyCategoryID",0);
|
||||
}
|
||||
|
||||
// Überschreibt die intere IPS_ApplyChanges($id) Funktion
|
||||
public function ApplyChanges() {
|
||||
// Diese Zeile nicht löschen
|
||||
parent::ApplyChanges();
|
||||
}
|
||||
/**
|
||||
* Die folgenden Funktionen stehen automatisch zur Verfügung, wenn das Modul über die "Module Control" eingefügt wurden.
|
||||
* Die Funktionen werden, mit dem selbst eingerichteten Prefix, in PHP und JSON-RPC wiefolgt zur Verfügung gestellt:
|
||||
*
|
||||
*
|
||||
*/
|
||||
public function rename() {
|
||||
|
||||
$idKat = $this->ReadPropertyInteger("PropertyCategoryID");
|
||||
$katChilds = IPS_GetChildrenIDs($idKat);
|
||||
|
||||
foreach ($katChilds as $katChild) {
|
||||
$chilid = IPS_GetChildrenIDs($katChild)[0];
|
||||
$parentname = IPS_GetName($katChild);
|
||||
$childname = $parentname;
|
||||
IPS_SetName($chilid,$childname);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"id": "{34065973-58B9-07E5-9FF2-09964F230304}",
|
||||
"author": "J.H. Artworks",
|
||||
"name": "VariableTools",
|
||||
"url": "https://jh-artworks.com",
|
||||
"compatibility": {
|
||||
"version": "6.0",
|
||||
"date": 1491343200
|
||||
},
|
||||
"version": "1.0",
|
||||
"build": 1,
|
||||
"date": 0
|
||||
}
|
||||
Reference in New Issue
Block a user