|
@@ -21,6 +21,7 @@ class FindBoxService
|
|
|
private $findBoxCore = null;
|
|
private $findBoxCore = null;
|
|
|
private $labelToBlink;
|
|
private $labelToBlink;
|
|
|
private $ServiceLogger;
|
|
private $ServiceLogger;
|
|
|
|
|
+ private $qs_Server;
|
|
|
|
|
|
|
|
public function __construct()
|
|
public function __construct()
|
|
|
{
|
|
{
|
|
@@ -37,6 +38,10 @@ class FindBoxService
|
|
|
sleep(1);
|
|
sleep(1);
|
|
|
}
|
|
}
|
|
|
$this->labelToBlink = [];
|
|
$this->labelToBlink = [];
|
|
|
|
|
+
|
|
|
|
|
+ $this->qs_Server = new QueueSystem();
|
|
|
|
|
+
|
|
|
|
|
+ $this->qs_Server->CreateService();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -47,17 +52,16 @@ class FindBoxService
|
|
|
public function Main($f3)
|
|
public function Main($f3)
|
|
|
{
|
|
{
|
|
|
$this->ServiceLogger->write("Starting FindBoxService main loop", 'd/m/Y H:i:s');
|
|
$this->ServiceLogger->write("Starting FindBoxService main loop", 'd/m/Y H:i:s');
|
|
|
|
|
+ $this->ServiceLogger->write("Opening socket listen {$f3->get('FINDBOXSERVICE.PORT')}", 'd/m/Y H:i:s');
|
|
|
|
|
|
|
|
while (true) {
|
|
while (true) {
|
|
|
|
|
|
|
|
- $this->updateServiceStatus();
|
|
|
|
|
-
|
|
|
|
|
$this->getCurrentQueue();
|
|
$this->getCurrentQueue();
|
|
|
|
|
|
|
|
foreach($this->labelToBlink as $labelId => &$label) {
|
|
foreach($this->labelToBlink as $labelId => &$label) {
|
|
|
switch ($label->operation) {
|
|
switch ($label->operation) {
|
|
|
|
|
|
|
|
- case Q_BLINK_OFF:
|
|
|
|
|
|
|
+ case QueueCommand::$Q_BLINK_OFF:
|
|
|
$this->ServiceLogger->write("BlinkOff for label {$label->id} requested", 'd/m/Y H:i:s');
|
|
$this->ServiceLogger->write("BlinkOff for label {$label->id} requested", 'd/m/Y H:i:s');
|
|
|
|
|
|
|
|
$esl = new SmartESL($this->findBoxCore, [$label->id]);
|
|
$esl = new SmartESL($this->findBoxCore, [$label->id]);
|
|
@@ -68,7 +72,7 @@ class FindBoxService
|
|
|
|
|
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
- case Q_BLINK_ON:
|
|
|
|
|
|
|
+ case QueueCommand::$Q_BLINK_ON:
|
|
|
// 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
|
|
@@ -101,53 +105,34 @@ class FindBoxService
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- usleep($f3->get('FINDBOXSERVICE.SLEEPTIME') * 1000);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private function updateServiceStatus()
|
|
|
|
|
- {
|
|
|
|
|
- $qs = new QueueSystem('FindBoxService_isAlive');
|
|
|
|
|
- if ($qs->check()) {
|
|
|
|
|
- $qs->reset();
|
|
|
|
|
- $qs->command = time();
|
|
|
|
|
- $qs->servicename = 'FindBoxService_isAlive';
|
|
|
|
|
- $qs->save();
|
|
|
|
|
- } else {
|
|
|
|
|
- $qs->command = time();
|
|
|
|
|
- }
|
|
|
|
|
- $qs->update();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
private function getCurrentQueue()
|
|
private function getCurrentQueue()
|
|
|
{
|
|
{
|
|
|
global $f3;
|
|
global $f3;
|
|
|
- $table = new QueueSystem('FindBoxService');
|
|
|
|
|
- while (!$table->check()) {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if ($this->qs_Server->check()) {
|
|
|
|
|
|
|
|
/** @var QueueCommand $qCommand */
|
|
/** @var QueueCommand $qCommand */
|
|
|
- $qCommand = $table->getCommandObject();
|
|
|
|
|
|
|
+ $qCommand = $this->qs_Server->getCommandObject();
|
|
|
switch ($qCommand->operation) {
|
|
switch ($qCommand->operation) {
|
|
|
- case Q_SAVEPRODUCT:
|
|
|
|
|
|
|
+ case QueueCommand::$Q_SAVEPRODUCT:
|
|
|
$this->saveProduct($qCommand);
|
|
$this->saveProduct($qCommand);
|
|
|
break;
|
|
break;
|
|
|
- case Q_BLINK_ON:
|
|
|
|
|
- case Q_BLINK_OFF:
|
|
|
|
|
|
|
+ case QueueCommand::$Q_BLINK_ON:
|
|
|
|
|
+ case QueueCommand::$Q_BLINK_OFF:
|
|
|
$this->labelToBlink[$qCommand->id] = $qCommand;
|
|
$this->labelToBlink[$qCommand->id] = $qCommand;
|
|
|
$this->labelToBlink[$qCommand->id]->retryForFault = $f3->get('MAX_RETRY_FOR_FAULT');
|
|
$this->labelToBlink[$qCommand->id]->retryForFault = $f3->get('MAX_RETRY_FOR_FAULT');
|
|
|
break;
|
|
break;
|
|
|
- case Q_DISPLAY:
|
|
|
|
|
|
|
+ case QueueCommand::$Q_DISPLAY:
|
|
|
$this->ServiceLogger->write("Change display for label {$qCommand->id} requested", 'd/m/Y H:i:s');
|
|
$this->ServiceLogger->write("Change display for label {$qCommand->id} requested", 'd/m/Y H:i:s');
|
|
|
$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']);
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- $table->erase();
|
|
|
|
|
- $table->next();
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|