|
@@ -37,11 +37,6 @@ class JobManager
|
|
|
$this->jobs = [];
|
|
$this->jobs = [];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private function array_diff_symmetric(array $ar1, array $ar2): array
|
|
|
|
|
- {
|
|
|
|
|
- return array_merge(array_diff($ar1, $ar2), array_diff($ar2, $ar1));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
public function AggregateBlinkByParams()
|
|
public function AggregateBlinkByParams()
|
|
|
{
|
|
{
|
|
|
global $f3;
|
|
global $f3;
|
|
@@ -85,6 +80,11 @@ class JobManager
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private function array_diff_symmetric(array $ar1, array $ar2): array
|
|
|
|
|
+ {
|
|
|
|
|
+ return array_merge(array_diff($ar1, $ar2), array_diff($ar2, $ar1));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public function count()
|
|
public function count()
|
|
|
{
|
|
{
|
|
|
return count($this->jobs);
|
|
return count($this->jobs);
|
|
@@ -307,6 +307,8 @@ class FindBoxService
|
|
|
|
|
|
|
|
if ($isTimeToAggregateCommands && (count($this->labelToBlink) > 0)) {
|
|
if ($isTimeToAggregateCommands && (count($this->labelToBlink) > 0)) {
|
|
|
|
|
|
|
|
|
|
+ $this->SplitBeforeAggregation();
|
|
|
|
|
+
|
|
|
foreach($this->labelToBlink as $commandID => &$label) {
|
|
foreach($this->labelToBlink as $commandID => &$label) {
|
|
|
switch ($label->operation) {
|
|
switch ($label->operation) {
|
|
|
|
|
|
|
@@ -316,7 +318,6 @@ class FindBoxService
|
|
|
|
|
|
|
|
// Rimuove il JOB se esiste
|
|
// Rimuove il JOB se esiste
|
|
|
$asyncBlinkOFF = new AsyncJobClass($this->findBoxCore, $label->id);
|
|
$asyncBlinkOFF = new AsyncJobClass($this->findBoxCore, $label->id);
|
|
|
-// $asyncBlinkOFF->BlinkOFF();
|
|
|
|
|
$this->jobManager->add($asyncBlinkOFF);
|
|
$this->jobManager->add($asyncBlinkOFF);
|
|
|
|
|
|
|
|
unset($this->labelToBlink[$commandID]);
|
|
unset($this->labelToBlink[$commandID]);
|
|
@@ -328,7 +329,6 @@ class FindBoxService
|
|
|
$this->ServiceLogger->write("BlinkOn for label(s) {$labelJ} requested", 'd/m/Y H:i:s');
|
|
$this->ServiceLogger->write("BlinkOn for label(s) {$labelJ} requested", 'd/m/Y H:i:s');
|
|
|
|
|
|
|
|
$asyncBlink = new AsyncJobClass($this->findBoxCore, $label->id, $label->params);
|
|
$asyncBlink = new AsyncJobClass($this->findBoxCore, $label->id, $label->params);
|
|
|
-// $asyncBlink->BlinkON();
|
|
|
|
|
$this->jobManager->add($asyncBlink);
|
|
$this->jobManager->add($asyncBlink);
|
|
|
|
|
|
|
|
unset($this->labelToBlink[$commandID]);
|
|
unset($this->labelToBlink[$commandID]);
|
|
@@ -339,9 +339,6 @@ class FindBoxService
|
|
|
$this->ts_ms = NULL;
|
|
$this->ts_ms = NULL;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// if ($this->jobManager->count() < 1)
|
|
|
|
|
-// continue;
|
|
|
|
|
-
|
|
|
|
|
$this->jobManager->AggregateBlinkByParams();
|
|
$this->jobManager->AggregateBlinkByParams();
|
|
|
|
|
|
|
|
// Async check on JOBS
|
|
// Async check on JOBS
|
|
@@ -500,6 +497,11 @@ class FindBoxService
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * If a command come with more than 9 label ids, it split command in multiple commands
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param QueueCommand $command
|
|
|
|
|
+ */
|
|
|
private function SplitArrayIn9Parts(QueueCommand $command)
|
|
private function SplitArrayIn9Parts(QueueCommand $command)
|
|
|
{
|
|
{
|
|
|
// Split blink list by 9 items each array
|
|
// Split blink list by 9 items each array
|
|
@@ -511,6 +513,20 @@ class FindBoxService
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private function SplitBeforeAggregation()
|
|
|
|
|
+ {
|
|
|
|
|
+ $newLabelToBlink = [];
|
|
|
|
|
+ foreach($this->labelToBlink as $commandID => &$label) {
|
|
|
|
|
+ $labelsSplitted = array_chunk($label->id, 9);
|
|
|
|
|
+ foreach($labelsSplitted as $labels) {
|
|
|
|
|
+ $cmd = clone $label;
|
|
|
|
|
+ $cmd->id = $labels;
|
|
|
|
|
+ $newLabelToBlink[rand(0, 60000)] = $cmd;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $this->labelToBlink = $newLabelToBlink;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @param AsyncJobClass $job
|
|
* @param AsyncJobClass $job
|
|
|
* @param array $labels
|
|
* @param array $labels
|