Browse Source

UPD: aligned with latest OMLink Engine changes
FIX: restart to blink if label is in warning status

Giancarlo Voci 7 years ago
parent
commit
0d56fad849

+ 1 - 0
.gitignore

@@ -57,5 +57,6 @@ import
 /cfg/*.bin
 /cfg/*.bin
 omlink.css
 omlink.css
 omlink.min.js
 omlink.min.js
+inport.json
 admin.css
 admin.css
 admin.min.js
 admin.min.js

+ 12 - 0
src/OpenMind/FindBox/FindBoxCoreSystem.php

@@ -175,4 +175,16 @@ class FindBoxCoreSystem
       return $this->returnCode(1, 'No label exist on Findbox');
       return $this->returnCode(1, 'No label exist on Findbox');
   }
   }
 
 
+  /**
+   * @param array $fbOS_Response
+   * @return array|null
+   */
+  public function getLabelsFromResponse(array $fbOS_Response): ?array
+  {
+    if (($fbOS_Response['value']['code'] != 0) || ($fbOS_Response['value']['value'] == false))
+      return NULL;
+
+    return $fbOS_Response['value']['value'];
+  }
+
 }
 }

+ 30 - 4
src/OpenMind/FindBox/FindBoxService.php

@@ -63,6 +63,7 @@ class FindBoxService
 
 
       /** @var QueueCommand $qCommand */
       /** @var QueueCommand $qCommand */
       $qCommand = $table->getCommandObject();
       $qCommand = $table->getCommandObject();
+      $eraseRecord = true;
       switch ($qCommand->operation) {
       switch ($qCommand->operation) {
         case Q_SAVEPRODUCT:
         case Q_SAVEPRODUCT:
           $this->saveProduct($qCommand);
           $this->saveProduct($qCommand);
@@ -72,8 +73,17 @@ class FindBoxService
           break;
           break;
         case Q_BLINK_OFF:
         case Q_BLINK_OFF:
           $this->log2console("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();
+          $err = $esl->BlinkOff();
+
+          $labelResponses = $this->findBoxCore->getLabelsFromResponse($err);
+          if ($labelResponses === NULL) {
+            $this->log2console("Label {$qCommand->id} fatal error. Removing from queue\n");
+          } else {
+            $eraseRecord = $labelResponses[$qCommand->id];
+          }
+
           unset($this->labelToBlink[$qCommand->id]);
           unset($this->labelToBlink[$qCommand->id]);
           break;
           break;
         case Q_DISPLAY:
         case Q_DISPLAY:
@@ -83,7 +93,10 @@ class FindBoxService
           unset($this->labelToBlink[$qCommand->id]);
           unset($this->labelToBlink[$qCommand->id]);
           break;
           break;
       }
       }
-      $table->erase();
+
+      if ($eraseRecord)
+        $table->erase();
+
       $table->next();
       $table->next();
       $this->log2console("Label {$qCommand->id} readed\n");
       $this->log2console("Label {$qCommand->id} readed\n");
     }
     }
@@ -148,8 +161,21 @@ class FindBoxService
           $esl = new SmartESL($this->findBoxCore, [$label->id]);
           $esl = new SmartESL($this->findBoxCore, [$label->id]);
           $ledParams = $label->params;
           $ledParams = $label->params;
 
 
-          $esl->BlinkSpecial($ledParams['pattern'], $ledParams['repeat'], $ledParams['iter_time'], $ledParams['iterations'], $ledParams['color']);
-          $label->tsLastLongBlink = time();
+          $err = $esl->BlinkSpecial($ledParams['pattern'], $ledParams['repeat'], $ledParams['iter_time'], $ledParams['iterations'], $ledParams['color']);
+
+          $labelResponses = $this->findBoxCore->getLabelsFromResponse($err);
+          if ($labelResponses === NULL) {
+            $this->log2console("Label {$label->id} fatal error. Removing from queue\n");
+            unset($this->labelToBlink[$labelId]);
+          } else {
+            if ($labelResponses[$label->id])
+              $label->tsLastLongBlink = time();
+            else { // Retry to blink to next cycle
+              $this->log2console("Label {$label->id} blink error. Try next cycle...\n");
+              $label->tsLastLongBlink = 0;
+            }
+          }
+
         }
         }
       }
       }
 
 

+ 2 - 2
src/OpenMind/FindBox/SmartESL.php

@@ -108,7 +108,7 @@ class SmartESL
       $params[$version]));
       $params[$version]));
 
 
     $URI = "/1.0.0/index.php/smartesl.blink_special/{$strFWVer}/";
     $URI = "/1.0.0/index.php/smartesl.blink_special/{$strFWVer}/";
-    $this->core->CallAPI($URI, $uriParams, true);
+    return $this->core->CallAPI($URI, $uriParams);
   }
   }
 
 
   /**
   /**
@@ -117,7 +117,7 @@ class SmartESL
   public function BlinkOff()
   public function BlinkOff()
   {
   {
     $URI = "/1.0.0/index.php/smartesl.blink_special/2.0.0/";
     $URI = "/1.0.0/index.php/smartesl.blink_special/2.0.0/";
-    $this->core->CallAPI($URI, "[[\"{$this->labels[0]}\"],0,0,0,0,0]", true);
+    return $this->core->CallAPI($URI, "[[\"{$this->labels[0]}\"],0,0,0,0,0,1]");
   }
   }
 
 
   public function Display(string $templateId, string $barcode)
   public function Display(string $templateId, string $barcode)

+ 1 - 0
src/OpenMind/System/Notifications.php

@@ -19,6 +19,7 @@ class Notifications extends Mapper
    * If you need custom notification or to simply send a command to client use FB_CUSTOM_NOTIFICATION+xxx where xxx is a number that identify your notification
    * If you need custom notification or to simply send a command to client use FB_CUSTOM_NOTIFICATION+xxx where xxx is a number that identify your notification
    */
    */
   const FB_CUSTOM_NOTIFICATION = 0x4000;
   const FB_CUSTOM_NOTIFICATION = 0x4000;
+  const FB_REFRESH_FILTERS = Notifications::FB_CUSTOM_NOTIFICATION + 1;
 
 
   public function __construct()
   public function __construct()
   {
   {

+ 0 - 1
src/OpenMind/Web/Web.php

@@ -8,7 +8,6 @@
 namespace OpenMind\Web;
 namespace OpenMind\Web;
 
 
 use OpenMind\System\PluginStrategy;
 use OpenMind\System\PluginStrategy;
-use OpenMind\System\UserRoles;
 
 
 class Pages extends Controller
 class Pages extends Controller
 {
 {

+ 1 - 1
ui/js/omlink.js

@@ -7,7 +7,7 @@
  */
  */
 
 
 let CUSTOM_NOTIFY = 0x4000;
 let CUSTOM_NOTIFY = 0x4000;
-
+let REFRESH_FILTERS = CUSTOM_NOTIFY + 1;
 
 
 var fetchHeaders = {
 var fetchHeaders = {
   'Accept': 'text/html',
   'Accept': 'text/html',