no message
This commit is contained in:
@@ -88,6 +88,20 @@ class Verbraucher_extern extends IPSModule
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private function findCombination($power, $values) {
|
||||||
|
$result = [];
|
||||||
|
$found = findCombinationRecursive($power, $values, [], 0, $result);
|
||||||
|
return $found ? $result : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function findCombinationRecursive($power, $values, $currentCombination, $startIndex, &$result) {
|
||||||
|
if ($power == 0) {
|
||||||
|
$result = $currentCombination;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if ($power < 0) {
|
||||||
|
return false;
|
||||||
|
|
||||||
private function find($target, $values, $current, &$result) {
|
private function find($target, $values, $current, &$result) {
|
||||||
if ($target == 0) {
|
if ($target == 0) {
|
||||||
$result[] = $current;
|
$result[] = $current;
|
||||||
@@ -106,15 +120,17 @@ class Verbraucher_extern extends IPSModule
|
|||||||
{
|
{
|
||||||
$values = json_decode($this->GetValue("PowerSteps"));
|
$values = json_decode($this->GetValue("PowerSteps"));
|
||||||
$result = [];
|
$result = [];
|
||||||
|
|
||||||
$this->find($this->GetValue("Power"), $values, [], $result);
|
$firstCombination = $this->findCombination($this->GetValue("Power"), $this->GetValue("PowerSteps"));
|
||||||
|
|
||||||
|
//$this->find($this->GetValue("Power"), $values, [], $result);
|
||||||
|
|
||||||
$verbraucherListe = json_decode($this->ReadPropertyString("Verbraucher_Liste"), true);
|
$verbraucherListe = json_decode($this->ReadPropertyString("Verbraucher_Liste"), true);
|
||||||
|
|
||||||
|
|
||||||
$firstCombination = $result[0];
|
//$firstCombination = $result[0];
|
||||||
|
|
||||||
foreach ($verbraucherListe as &$verbraucher) {
|
foreach ($verbraucherListe as $verbraucher) {
|
||||||
if (in_array($verbraucher['P_Nenn'], $firstCombination)) {
|
if (in_array($verbraucher['P_Nenn'], $firstCombination)) {
|
||||||
RequestAction($verbraucher['Write_Var'], false);
|
RequestAction($verbraucher['Write_Var'], false);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user