Add files via upload
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"elements":
|
||||
[
|
||||
{ "type": "SelectCategory", "name": "PropertyCategoryID", "caption": "Target" },
|
||||
{ "type": "SelectInstance", "name": "PropertyGatewayID", "caption": "Gateway" },
|
||||
{ "type": "SelectMedia", "name": "PropertyMediaID", "caption": "Media / CSV" }
|
||||
],
|
||||
"actions":
|
||||
[
|
||||
|
||||
{ "type": "Button", "label": "Create", "onClick": "VTMC_createObjects($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": "VLS"
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?
|
||||
// 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");
|
||||
$this->RegisterPropertyInteger("PropertyGatewayID");
|
||||
$this->RegisterPropertyInteger("PropertyMediaID");
|
||||
|
||||
}
|
||||
|
||||
// Ü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, $objectName,$adressread,$fcread, $adresswrite, $fcwrite, $datatype,$factor) {
|
||||
|
||||
|
||||
$newInstance = IPS_CreateInstance("{CB197E50-273D-4535-8C91-BB35273E3CA5}");
|
||||
IPS_DisconnectInstance($newInstance);
|
||||
IPS_ConnectInstance($newInstance, $socket);
|
||||
IPS_SetName($newInstance, $objectName);
|
||||
|
||||
IPS_SetConfiguration($newInstance, '{"ReadFunctionCode":'.$fcread.',"WriteFunctionCode":'.$fcwrite.',"Factor":'.$factor.',"DataType":'.$datatype.',"WriteAddress":'.$adresswrite.',"ReadAddress":'.$adressread.'}');
|
||||
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");
|
||||
|
||||
$csv = base64_decode(IPS_GetMediaContent($idMedia));
|
||||
|
||||
|
||||
while (($data = str_getcsv($csv)) !== FALSE) {
|
||||
|
||||
$row++;
|
||||
|
||||
|
||||
if ($row>2){
|
||||
//createModobject($socket, $catId, $objectName,$adressread, $fcread, $adresswrite, $fcwrite, $datatype, $factor)
|
||||
createModobject($idGw, $idCat, $data[0], $data[1], $data[2], $data[3], $data[4], $data[5], $data[6]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user