|
|
@@ -24,6 +24,11 @@ class FindBoxService
|
|
|
$this->labelToBlink = [];
|
|
|
}
|
|
|
|
|
|
+ private function getStrTime()
|
|
|
+ {
|
|
|
+ return '[' . date("d/m/Y H:i:s") . '] ';
|
|
|
+ }
|
|
|
+
|
|
|
private function updateServiceStatus()
|
|
|
{
|
|
|
$qs = new QueueSystem('FindBoxService_isAlive');
|
|
|
@@ -39,7 +44,7 @@ class FindBoxService
|
|
|
|
|
|
private function getCurrentQueue()
|
|
|
{
|
|
|
- //echo "Checking QueueSystem \n";
|
|
|
+ //echo $this->getStrTime() . "Checking QueueSystem \n";
|
|
|
$table = new QueueSystem('FindBoxService');
|
|
|
while (!$table->check()) {
|
|
|
|
|
|
@@ -53,13 +58,13 @@ class FindBoxService
|
|
|
$this->labelToBlink[$qCommand->id] = $qCommand;
|
|
|
break;
|
|
|
case Q_BLINK_OFF:
|
|
|
- echo "BlinkOff for label {$qCommand->id} requested\n";
|
|
|
+ echo $this->getStrTime() . "BlinkOff for label {$qCommand->id} requested\n";
|
|
|
$esl = new SmartESL($this->findBoxCore, [$qCommand->id]);
|
|
|
$esl->BlinkOff();
|
|
|
unset($this->labelToBlink[$qCommand->id]);
|
|
|
break;
|
|
|
case Q_DISPLAY:
|
|
|
- echo "Change display for label {$qCommand->id} requested\n";
|
|
|
+ echo $this->getStrTime() ."Change display for label {$qCommand->id} requested\n";
|
|
|
$esl = new SmartESL($this->findBoxCore, [$qCommand->id]);
|
|
|
$esl->Display($qCommand->params['templateId'], $qCommand->params['barcode']);
|
|
|
unset($this->labelToBlink[$qCommand->id]);
|
|
|
@@ -67,7 +72,7 @@ class FindBoxService
|
|
|
}
|
|
|
$table->erase();
|
|
|
$table->next();
|
|
|
- echo "Label {$qCommand->id} readed\n";
|
|
|
+ echo $this->getStrTime() . "Label {$qCommand->id} readed\n";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -81,7 +86,7 @@ class FindBoxService
|
|
|
{
|
|
|
if ($label->operation == Q_SAVEPRODUCT) {
|
|
|
$this->findBoxCore->SaveProducts($label->id, $label->description, $label->params['dataFields']);
|
|
|
- echo "Save product {$label->id}\n";
|
|
|
+ echo $this->getStrTime() . "Save product {$label->id}\n";
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
@@ -96,14 +101,14 @@ class FindBoxService
|
|
|
*/
|
|
|
public function Main($f3)
|
|
|
{
|
|
|
- echo "Starting FindBoxService main loop\n";
|
|
|
+ echo $this->getStrTime() . "Starting FindBoxService main loop\n";
|
|
|
while (true) {
|
|
|
|
|
|
$this->updateServiceStatus();
|
|
|
|
|
|
$this->getCurrentQueue();
|
|
|
|
|
|
- //echo 'Label in cache: ' . count($this->labelToBlink) . " \n";
|
|
|
+ //echo $this->getStrTime() . 'Label in cache: ' . count($this->labelToBlink) . " \n";
|
|
|
foreach($this->labelToBlink as $labelId => $label) {
|
|
|
|
|
|
// Priority 1
|
|
|
@@ -111,7 +116,7 @@ class FindBoxService
|
|
|
// Force exit and blink off if run time script > MAX_BLINK_TIME_SEC
|
|
|
$now = time() - $label->tsFirstBlink;
|
|
|
if ($now > $f3->get('MAX_BLINK_TIME_SEC')) {
|
|
|
- echo "Stop label {$label->id} for timeout\n";
|
|
|
+ echo $this->getStrTime() . "Stop label {$label->id} for timeout\n";
|
|
|
$esl = new SmartESL($this->findBoxCore, [$label->id]);
|
|
|
$esl->BlinkOff();
|
|
|
unset($this->labelToBlink[$labelId]);
|
|
|
@@ -124,7 +129,7 @@ class FindBoxService
|
|
|
$blinkEndTime = time() - $label->tsLastLongBlink;
|
|
|
$calcDuration = $label->getBlinkDuration();
|
|
|
if ($blinkEndTime > $calcDuration) {
|
|
|
- echo "Auto restart blinking for label $label->id\n";
|
|
|
+ echo $this->getStrTime() . "Auto restart blinking for label $label->id\n";
|
|
|
|
|
|
$esl = new SmartESL($this->findBoxCore, [$label->id]);
|
|
|
$ledParams = $label->params;
|
|
|
@@ -134,7 +139,7 @@ class FindBoxService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //echo "Restart loop \n";
|
|
|
+ //echo $this->getStrTime() . "Restart loop \n";
|
|
|
ob_flush();
|
|
|
flush();
|
|
|
sleep($f3->get('FINDBOXSERVICE.SLEEPTIME'));
|