Version 2.0.0 Beta
This commit is contained in:
67
Verbraucher_extern/README.md
Normal file
67
Verbraucher_extern/README.md
Normal file
@@ -0,0 +1,67 @@
|
||||
# Manager_1
|
||||
Beschreibung des Moduls.
|
||||
|
||||
### Inhaltsverzeichnis
|
||||
|
||||
1. [Funktionsumfang](#1-funktionsumfang)
|
||||
2. [Voraussetzungen](#2-voraussetzungen)
|
||||
3. [Software-Installation](#3-software-installation)
|
||||
4. [Einrichten der Instanzen in IP-Symcon](#4-einrichten-der-instanzen-in-ip-symcon)
|
||||
5. [Statusvariablen und Profile](#5-statusvariablen-und-profile)
|
||||
6. [WebFront](#6-webfront)
|
||||
7. [PHP-Befehlsreferenz](#7-php-befehlsreferenz)
|
||||
|
||||
### 1. Funktionsumfang
|
||||
|
||||
*
|
||||
|
||||
### 2. Voraussetzungen
|
||||
|
||||
- IP-Symcon ab Version 7.1
|
||||
|
||||
### 3. Software-Installation
|
||||
|
||||
* Über den Module Store das 'Manager_1'-Modul installieren.
|
||||
* Alternativ über das Module Control folgende URL hinzufügen
|
||||
|
||||
### 4. Einrichten der Instanzen in IP-Symcon
|
||||
|
||||
Unter 'Instanz hinzufügen' kann das 'Manager_1'-Modul mithilfe des Schnellfilters gefunden werden.
|
||||
- Weitere Informationen zum Hinzufügen von Instanzen in der [Dokumentation der Instanzen](https://www.symcon.de/service/dokumentation/konzepte/instanzen/#Instanz_hinzufügen)
|
||||
|
||||
__Konfigurationsseite__:
|
||||
|
||||
Name | Beschreibung
|
||||
-------- | ------------------
|
||||
|
|
||||
|
|
||||
|
||||
### 5. Statusvariablen und Profile
|
||||
|
||||
Die Statusvariablen/Kategorien werden automatisch angelegt. Das Löschen einzelner kann zu Fehlfunktionen führen.
|
||||
|
||||
#### Statusvariablen
|
||||
|
||||
Name | Typ | Beschreibung
|
||||
------ | ------- | ------------
|
||||
| |
|
||||
| |
|
||||
|
||||
#### Profile
|
||||
|
||||
Name | Typ
|
||||
------ | -------
|
||||
|
|
||||
|
|
||||
|
||||
### 6. WebFront
|
||||
|
||||
Die Funktionalität, die das Modul im WebFront bietet.
|
||||
|
||||
### 7. PHP-Befehlsreferenz
|
||||
|
||||
`boolean GEF_BeispielFunktion(integer $InstanzID);`
|
||||
Erklärung der Funktion.
|
||||
|
||||
Beispiel:
|
||||
`GEF_BeispielFunktion(12345);`
|
||||
76
Verbraucher_extern/form.json
Normal file
76
Verbraucher_extern/form.json
Normal file
@@ -0,0 +1,76 @@
|
||||
{
|
||||
"elements": [
|
||||
{
|
||||
"type": "Label",
|
||||
"caption": "Einstellungen für einstufigen Verbruacher Ein-Aus"
|
||||
},
|
||||
|
||||
{
|
||||
"type": "NumberSpinner",
|
||||
"name": "IdleCounterMax",
|
||||
"caption": "Zyklen zwischen zwei Leistungsänderungen (Multipliziert sich mit Interval)",
|
||||
"suffix": ""
|
||||
},
|
||||
{
|
||||
"type": "NumberSpinner",
|
||||
"name": "Interval",
|
||||
"caption": "Intervall Neuberechnung der Werte Erst für spätere Versionen",
|
||||
"suffix": "Sekunden"
|
||||
},
|
||||
{
|
||||
"type": "SelectVariable",
|
||||
"name": "Is_Peak",
|
||||
"caption": "Variable zur Signalisierung der Peakleistung",
|
||||
"suffix": ""
|
||||
},
|
||||
{
|
||||
"type": "SelectVariable",
|
||||
"name": "delta_power",
|
||||
"caption": "Variable mit dem Leistungsunterschied",
|
||||
"suffix": ""
|
||||
},
|
||||
{
|
||||
"type": "List",
|
||||
"name": "Verbraucher_Liste",
|
||||
"caption": "Verbraucher, die gemanagt werden sollen.",
|
||||
"add": true,
|
||||
"delete": true,
|
||||
"sortable": true,
|
||||
"columns": [
|
||||
{
|
||||
"caption": "Anfragende Variable",
|
||||
"name": "Read_Var",
|
||||
"width": "auto",
|
||||
"add": 0,
|
||||
"edit": {
|
||||
"type": "SelectVariable",
|
||||
"filter": "Verbraucher"
|
||||
}
|
||||
},
|
||||
{
|
||||
"caption": "Zu schreibende Variable",
|
||||
"name": "Write_Var",
|
||||
"width": "auto",
|
||||
"add": 0,
|
||||
"edit": {
|
||||
"type": "SelectVariable",
|
||||
"filter": "Verbraucher"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "NumberSpinner",
|
||||
"name": "P_Nenn",
|
||||
"width": "auto",
|
||||
"add": 0,
|
||||
"edit": {
|
||||
"type": "NumberSpinner"
|
||||
},
|
||||
"caption": "Nennleistung des Verbrauchers",
|
||||
"test": true
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
12
Verbraucher_extern/module.json
Normal file
12
Verbraucher_extern/module.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"id": "{E3D14937-80F8-5728-A3D7-991EA2DBC2D4}",
|
||||
"name": "Verbraucher_extern",
|
||||
"type": 3,
|
||||
"vendor": "Belevo AG",
|
||||
"aliases": [],
|
||||
"parentRequirements": [],
|
||||
"childRequirements": [],
|
||||
"implemented": [],
|
||||
"prefix": "GEF",
|
||||
"url": ""
|
||||
}
|
||||
173
Verbraucher_extern/module.php
Normal file
173
Verbraucher_extern/module.php
Normal file
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
class Verbraucher_extern extends IPSModule
|
||||
{
|
||||
private $timerID;
|
||||
|
||||
public function Create()
|
||||
{
|
||||
parent::Create();
|
||||
|
||||
// Verbraucherspezifische Properties
|
||||
$this->RegisterPropertyString("Verbraucher_Liste", "[]");
|
||||
$this->RegisterPropertyInteger("Is_Peak", 0);
|
||||
$this->RegisterPropertyInteger("delta_power", 0);
|
||||
$this->RegisterPropertyInteger("Interval", 5); // Recheninterval
|
||||
|
||||
// Variabeln für Kommunkation mit Manager
|
||||
$this->RegisterVariableInteger("Sperre_Prio", "Sperre_Prio");
|
||||
$this->RegisterVariableInteger("PV_Prio", "PV_Prio");
|
||||
$this->RegisterVariableBoolean("Idle", "Idle", "", 0);
|
||||
$this->RegisterVariableInteger("Aktuelle_Leistung", "Aktuelle_Leistung", "", 0);
|
||||
$this->RegisterVariableFloat("Bezogene_Energie", "Bezogene_Energie", "", 0);
|
||||
$this->RegisterVariableString("PowerSteps", "PowerSteps");
|
||||
$this->RegisterVariableInteger("Power", "Power");
|
||||
$this->RegisterVariableBoolean("Is_Peak_Shaving", "Is_Peak_Shaving");
|
||||
$this->RegisterVariableInteger("Leistung_Delta", "Leistung_Delta", "", 0);
|
||||
|
||||
|
||||
// Hilfsvariabeln für Idle zustand
|
||||
$this->RegisterPropertyInteger("IdleCounterMax", 2);
|
||||
$this->RegisterVariableInteger("IdleCounter", "IdleCounter", "", 0);
|
||||
$this->SetValue("IdleCounter", 0);
|
||||
|
||||
// Initialisiere Idle
|
||||
$this->SetValue("Idle", true);
|
||||
|
||||
$this->RegisterTimer("Timer_Do_UserCalc_Verb",$this->ReadPropertyInteger("Interval")*1000,"IPS_RequestAction(" .$this->InstanceID .', "Do_UserCalc", "");');
|
||||
|
||||
}
|
||||
|
||||
public function ApplyChanges()
|
||||
{
|
||||
parent::ApplyChanges();
|
||||
$this->SetTimerInterval("Timer_Do_UserCalc_Verb",$this->ReadPropertyInteger("Interval")*1000);
|
||||
|
||||
}
|
||||
|
||||
public function RequestAction($Ident, $Value)
|
||||
{
|
||||
switch ($Ident) {
|
||||
|
||||
case "SetAktuelle_Leistung":
|
||||
$this->SetValue("Power", (int)$Value);
|
||||
break;
|
||||
|
||||
case "GetCurrentData":
|
||||
$this->SetValue("Is_Peak_Shaving", (bool)$Value);
|
||||
break;
|
||||
|
||||
case "Do_UserCalc":
|
||||
$this->SetAktuelle_Leistung($this->GetValue("Power"));
|
||||
$this->GetCurrentData($this->GetValue("Is_Peak_Shaving"));
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Exception("Invalid Ident");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function berechneKombinationen(array $verbraucherListe){
|
||||
$kombinationen = [];
|
||||
foreach ($verbraucherListe as $verbraucher) {
|
||||
|
||||
if (GetValue($verbraucher['Read_Var']) == 1) {
|
||||
$tempListe = [];
|
||||
if(empty($kombinationen)){
|
||||
$kombinationen[] = $verbraucher['P_Nenn'];
|
||||
}else{
|
||||
foreach ($kombinationen as $wert) {
|
||||
$tempListe[] = $wert + $verbraucher['P_Nenn'];
|
||||
}
|
||||
$kombinationen = array_merge($kombinationen, $tempListe);
|
||||
}
|
||||
}
|
||||
}
|
||||
sort($kombinationen);
|
||||
return array_values(array_unique($kombinationen));
|
||||
}
|
||||
|
||||
|
||||
private function find($target, $values, $current, &$result) {
|
||||
if ($target == 0) {
|
||||
$result[] = $current;
|
||||
return;
|
||||
}
|
||||
if ($target < 0) {
|
||||
return;
|
||||
}
|
||||
for ($i = 0; $i < count($values); $i++) {
|
||||
$newValues = array_slice($values, $i + 1);
|
||||
$this->find($target - $values[$i], $newValues, array_merge($current, [$values[$i]]), $result);
|
||||
}
|
||||
}
|
||||
|
||||
private function berechneInverseKombinationen()
|
||||
{
|
||||
$values = json_decode($this->GetValue("PowerSteps"));
|
||||
$result = [];
|
||||
|
||||
$this->find($this->GetValue("Power"), $values, [], $result);
|
||||
|
||||
$verbraucherListe = json_decode($this->ReadPropertyString("Verbraucher_Liste"), true);
|
||||
|
||||
|
||||
$firstCombination = $result[0];
|
||||
|
||||
foreach ($verbraucherListe as &$verbraucher) {
|
||||
if (in_array($verbraucher['P_Nenn'], $firstCombination)) {
|
||||
SetValue($verbraucher['Write_Var'], 1);
|
||||
} else {
|
||||
SetValue($verbraucher['Write_Var'], 0);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function SetAktuelle_Leistung(float $power) {
|
||||
$this->CheckIdle($power);
|
||||
$this->SetValue("Aktuelle_Leistung", $power);
|
||||
$this->SetValue("Bezogene_Energie", ($this->GetValue("Bezogene_Energie") + ($this->GetValue("Aktuelle_Leistung")*($this->ReadPropertyInteger("Interval")/3600))));
|
||||
|
||||
$verbraucherListe = json_decode($this->ReadPropertyString("Verbraucher_Liste"), true);
|
||||
|
||||
$this->berechneInverseKombinationen();
|
||||
$this->SetValue("Leistung_Delta", GetValue($this->ReadPropertyInteger("delta_power")));
|
||||
}
|
||||
|
||||
public function GetCurrentData(bool $Peak)
|
||||
{
|
||||
$this->SetValue("Is_Peak_Shaving", $Peak);
|
||||
SetValue($this->ReadPropertyInteger("Is_Peak"), $Peak);
|
||||
|
||||
$verbraucherListe = json_decode($this->ReadPropertyString("Verbraucher_Liste"), true);
|
||||
$kombinationen = $this->berechneKombinationen($verbraucherListe);
|
||||
$this->SetValue("PowerSteps", json_encode($kombinationen));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function CheckIdle($power)
|
||||
{
|
||||
$lastpower = GetValue($this->GetIDForIdent("Aktuelle_Leistung"));
|
||||
if ($lastpower != $power) {
|
||||
$this->SetValue("Idle", false);
|
||||
$this->SetValue("IdleCounter",$this->ReadPropertyInteger("IdleCounterMax"));
|
||||
}
|
||||
$idleCounter = $this->GetValue("IdleCounter");
|
||||
if ($idleCounter > 0) {
|
||||
$this->SetValue("Idle", false);
|
||||
$this->SetValue("IdleCounter", $idleCounter - 1);
|
||||
} else {
|
||||
$this->SetValue("Idle", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user