|
@@ -26,7 +26,7 @@ class FindBoxService
|
|
|
try {
|
|
try {
|
|
|
$this->findBoxCore = new FindBoxCoreSystem(...array_values($f3->get('CORE.fb')));
|
|
$this->findBoxCore = new FindBoxCoreSystem(...array_values($f3->get('CORE.fb')));
|
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
|
- echo $this->getStrTime() . "Can't find FindBoxCore, retry in 1 second..\n";
|
|
|
|
|
|
|
+ $this->log2console("Can't find FindBoxCore, retry in 1 second..\n");
|
|
|
ob_flush();
|
|
ob_flush();
|
|
|
flush();
|
|
flush();
|
|
|
sleep(1);
|
|
sleep(1);
|
|
@@ -34,9 +34,11 @@ class FindBoxService
|
|
|
$this->labelToBlink = [];
|
|
$this->labelToBlink = [];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private function getStrTime()
|
|
|
|
|
|
|
+ private function log2console(string $msg)
|
|
|
{
|
|
{
|
|
|
- return '[' . date("d/m/Y H:i:s") . '] ';
|
|
|
|
|
|
|
+ echo '[' . date("d/m/Y H:i:s") . "] FindBoxService: $msg";
|
|
|
|
|
+ ob_flush();
|
|
|
|
|
+ flush();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private function updateServiceStatus()
|
|
private function updateServiceStatus()
|
|
@@ -69,13 +71,13 @@ class FindBoxService
|
|
|
$this->labelToBlink[$qCommand->id] = $qCommand;
|
|
$this->labelToBlink[$qCommand->id] = $qCommand;
|
|
|
break;
|
|
break;
|
|
|
case Q_BLINK_OFF:
|
|
case Q_BLINK_OFF:
|
|
|
- echo $this->getStrTime() . "BlinkOff for label {$qCommand->id} requested\n";
|
|
|
|
|
|
|
+ $this->log2console("BlinkOff for label {$qCommand->id} requested\n");
|
|
|
$esl = new SmartESL($this->findBoxCore, [$qCommand->id]);
|
|
$esl = new SmartESL($this->findBoxCore, [$qCommand->id]);
|
|
|
$esl->BlinkOff();
|
|
$esl->BlinkOff();
|
|
|
unset($this->labelToBlink[$qCommand->id]);
|
|
unset($this->labelToBlink[$qCommand->id]);
|
|
|
break;
|
|
break;
|
|
|
case Q_DISPLAY:
|
|
case Q_DISPLAY:
|
|
|
- echo $this->getStrTime() . "Change display for label {$qCommand->id} requested\n";
|
|
|
|
|
|
|
+ $this->log2console("Change display for label {$qCommand->id} requested\n");
|
|
|
$esl = new SmartESL($this->findBoxCore, [$qCommand->id]);
|
|
$esl = new SmartESL($this->findBoxCore, [$qCommand->id]);
|
|
|
$esl->Display($qCommand->params['templateId'], $qCommand->params['barcode']);
|
|
$esl->Display($qCommand->params['templateId'], $qCommand->params['barcode']);
|
|
|
unset($this->labelToBlink[$qCommand->id]);
|
|
unset($this->labelToBlink[$qCommand->id]);
|
|
@@ -83,7 +85,7 @@ class FindBoxService
|
|
|
}
|
|
}
|
|
|
$table->erase();
|
|
$table->erase();
|
|
|
$table->next();
|
|
$table->next();
|
|
|
- echo $this->getStrTime() . "Label {$qCommand->id} readed\n";
|
|
|
|
|
|
|
+ $this->log2console("Label {$qCommand->id} readed\n");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -97,7 +99,7 @@ class FindBoxService
|
|
|
{
|
|
{
|
|
|
if ($label->operation == Q_SAVEPRODUCT) {
|
|
if ($label->operation == Q_SAVEPRODUCT) {
|
|
|
$this->findBoxCore->SaveProducts($label->id, $label->description, $label->params['dataFields']);
|
|
$this->findBoxCore->SaveProducts($label->id, $label->description, $label->params['dataFields']);
|
|
|
- echo $this->getStrTime() . "Save product {$label->id}\n";
|
|
|
|
|
|
|
+ $this->log2console("Save product {$label->id}\n");
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
return false;
|
|
return false;
|
|
@@ -112,7 +114,7 @@ class FindBoxService
|
|
|
*/
|
|
*/
|
|
|
public function Main($f3)
|
|
public function Main($f3)
|
|
|
{
|
|
{
|
|
|
- echo $this->getStrTime() . "Starting FindBoxService main loop\n";
|
|
|
|
|
|
|
+ $this->log2console("Starting FindBoxService main loop\n");
|
|
|
while (true) {
|
|
while (true) {
|
|
|
|
|
|
|
|
$this->updateServiceStatus();
|
|
$this->updateServiceStatus();
|
|
@@ -120,14 +122,14 @@ class FindBoxService
|
|
|
$this->getCurrentQueue();
|
|
$this->getCurrentQueue();
|
|
|
|
|
|
|
|
//echo $this->getStrTime() . 'Label in cache: ' . count($this->labelToBlink) . " \n";
|
|
//echo $this->getStrTime() . 'Label in cache: ' . count($this->labelToBlink) . " \n";
|
|
|
- foreach ($this->labelToBlink as $labelId => $label) {
|
|
|
|
|
|
|
+ foreach($this->labelToBlink as $labelId => $label) {
|
|
|
|
|
|
|
|
// Priority 1
|
|
// Priority 1
|
|
|
// ----------
|
|
// ----------
|
|
|
// Force exit and blink off if run time script > MAX_BLINK_TIME_SEC
|
|
// Force exit and blink off if run time script > MAX_BLINK_TIME_SEC
|
|
|
$now = time() - $label->tsFirstBlink;
|
|
$now = time() - $label->tsFirstBlink;
|
|
|
if ($now > $f3->get('MAX_BLINK_TIME_SEC')) {
|
|
if ($now > $f3->get('MAX_BLINK_TIME_SEC')) {
|
|
|
- echo $this->getStrTime() . "Stop label {$label->id} for timeout\n";
|
|
|
|
|
|
|
+ $this->log2console("Stop label {$label->id} for timeout\n");
|
|
|
$esl = new SmartESL($this->findBoxCore, [$label->id]);
|
|
$esl = new SmartESL($this->findBoxCore, [$label->id]);
|
|
|
$esl->BlinkOff();
|
|
$esl->BlinkOff();
|
|
|
unset($this->labelToBlink[$labelId]);
|
|
unset($this->labelToBlink[$labelId]);
|
|
@@ -141,7 +143,7 @@ class FindBoxService
|
|
|
/** @var QueueCommand $label */
|
|
/** @var QueueCommand $label */
|
|
|
$calcDuration = $label->getBlinkDuration();
|
|
$calcDuration = $label->getBlinkDuration();
|
|
|
if ($blinkEndTime > $calcDuration) {
|
|
if ($blinkEndTime > $calcDuration) {
|
|
|
- echo $this->getStrTime() . "Auto restart blinking for label $label->id\n";
|
|
|
|
|
|
|
+ $this->log2console("Auto restart blinking for label $label->id\n");
|
|
|
|
|
|
|
|
$esl = new SmartESL($this->findBoxCore, [$label->id]);
|
|
$esl = new SmartESL($this->findBoxCore, [$label->id]);
|
|
|
$ledParams = $label->params;
|
|
$ledParams = $label->params;
|
|
@@ -154,7 +156,6 @@ class FindBoxService
|
|
|
//echo $this->getStrTime() . "Restart loop \n";
|
|
//echo $this->getStrTime() . "Restart loop \n";
|
|
|
ob_flush();
|
|
ob_flush();
|
|
|
flush();
|
|
flush();
|
|
|
- //echo $this->getStrTime() . memory_get_usage() . PHP_EOL;
|
|
|
|
|
usleep($f3->get('FINDBOXSERVICE.SLEEPTIME') * 1000);
|
|
usleep($f3->get('FINDBOXSERVICE.SLEEPTIME') * 1000);
|
|
|
}
|
|
}
|
|
|
|
|
|