Browse Source

- Rimosse chiamate Display
- Cambiati i parametri dei timings blink dei led
- Aggiunta funzionalità di Reset carrello nella prima fase di creazione picking
- Spostata a fine picking list, la creazioe della lista per l'etichetta del carrello, vine quindi inviata in questa fase non più dopo la crezione della picking
- Reset Label 2.2"
- Nel BlinkOFF delle api, ora viene utilizzata la versione 1.1.0 con template 3
- Rimossa la logica BlinkOFF/wait 3 secs/BlinkOFF dopo ogni picking, ora c'è solamente un BlinkOFF

Giancarlo Voci 8 years ago
parent
commit
b06cd45fec
8 changed files with 177 additions and 171 deletions
  1. 1 1
      config.ini
  2. 0 22
      index.php
  3. 1 1
      labels.ini
  4. 1 1
      package.json
  5. 50 21
      src/Distinta.php
  6. 12 15
      src/Modules/Pages.php
  7. 111 109
      src/SmartESL.php
  8. 1 1
      ui/pick2light_savingproducts.tpl

+ 1 - 1
config.ini

@@ -15,7 +15,7 @@ HIGHLIGHT = false
 JAR.expire = {{time()+31536000}}
 
 [CORE.fb]
-host=192.168.1.193
+host=127.0.0.1
 port=50443
 key=C0000000000011474023057
 pass=ZrgzkvJrOKnNSCnPnGz3u{A6eHSNXVvs

+ 0 - 22
index.php

@@ -25,28 +25,6 @@ $f3->set('DB',
     array(\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, \PDO::ATTR_PERSISTENT => TRUE))
 );
 
-//// TODO: per testare le api
-//$CORE_SETTINGS = $f3->get('CORE.fb');
-//$findBoxCore = new \FindBoxCoreSystem(...array_values($CORE_SETTINGS));
-//$label = new \SmartESL($findBoxCore, ['01076733']);
-//$label->Display(1004, '1111');
-//sleep(1);
-//$label->BlinkSpecial(0, 1, 1000, 20, 0);
-//sleep(1);
-//$label->BlinkOff();
-
-//
-//$f3->set('USERID', 0);
-//$CORE_SETTINGS = $f3->get('CORE.fb');
-//$findBoxCore = new \FindBoxCoreSystem(...array_values($CORE_SETTINGS));
-//$label = new \SmartESL($findBoxCore, ['010A19ED']);
-//$label->BlinkSpecial(0, 1, 1000, 20, 0);
-//$distinta = new \Distinta($f3);
-//$ret = $distinta->SaveProductsForLabel7('010A19ED', '81891252');
-//$ret = $label->Display(1017, '010A19ED');
-//
-//
-
 // Pages
 $f3->route('GET /', "Modules\Pages->Login", $f3->get('CACHE_TTL'));
 $f3->route('GET /homemenu', "Modules\Pages->HomeMenu", $f3->get('CACHE_TTL'));

+ 1 - 1
labels.ini

@@ -1,6 +1,6 @@
 [LABELS.TEMPLATES]
 DT31=1004,1009,1019
-DT79=1002,1001,1017
+DT79=1017,1001,1002
 
 [BARCODE_COMMANDS]
 ANOMALIACODE=5

+ 1 - 1
package.json

@@ -5,7 +5,7 @@
   "main": "index.js",
   "scripts": {
     "build": "node build.js",
-    "deploy": "zip -9 -r deploy.zip config.bin labels.ini *.php bundle.* src ui vendor"
+    "deploy": "zip -9 -r deploy.zip favicon.ico config.bin labels.ini *.php bundle.* src ui vendor"
   },
   "author": "Open Mind",
   "license": "ISC",

+ 50 - 21
src/Distinta.php

@@ -5,6 +5,8 @@
  * @time 11:43
  */
 
+define('MAX_RIGHE_CAMPI_CARRELLO', 22);
+
 class Distinta
 {
   private $dbHandle;
@@ -64,16 +66,16 @@ EOF;
           'qta_prelevare' => $row['qta_prelevare']
         );
 
-        $label = new \SmartESL($findBoxCore, [$labelId]);
-        $sql = "SELECT template_id FROM label_bindings WHERE label_id='{$labelId}'";
-        $tplId = $this->dbHandle->exec($sql);
-
+//        $label = new \SmartESL($findBoxCore, [$labelId]);
+//        $sql = "SELECT template_id FROM label_bindings WHERE label_id='{$labelId}'";
+//        $tplId = $this->dbHandle->exec($sql);
 
         $findBoxCore->SaveProducts($row['barcode'], $row['descrizione'], $dataFields);
-        $label->Display($tplId[0]['template_id'], $row['barcode']);
-        if ($blink) {
-          $label->BlinkSpecial(0, 1, 1000, $iterations, 0);
-        }
+        // TODO #NODISPLAY da testare, rimuovere se è ok
+//        $label->Display($tplId[0]['template_id'], $row['barcode']);
+//        if ($blink) {
+//          $label->BlinkSpecial(0, 1, 1000, $iterations, 0);
+//        }
       }
     }
   }
@@ -93,7 +95,7 @@ EOF;
     $CORE_SETTINGS = \F3::get('CORE.fb');
     $findBoxCore = new \FindBoxCoreSystem(...array_values($CORE_SETTINGS));
     $label = new \SmartESL($findBoxCore, [$labelId]);
-    $label->BlinkSpecial(0, 1, 1000, 50, 0);
+    $label->BlinkSpecial(0, 1, 5000, 20, 0);
 
     $sql = "UPDATE distinta_esplosa d JOIN label_bindings b ON d.barcode = b.barcode SET anomalie=1 WHERE idutente={$this->userId} AND b.label_id='{$labelId}'";
     return $this->dbHandle->exec($sql);
@@ -127,6 +129,26 @@ EOF;
     return $this->dbHandle->exec($sqlCommesse);
   }
 
+  public function ResetLabelCarrello(string $labelId)
+  {
+    $CORE_SETTINGS = \F3::get('CORE.fb');
+    $findBoxCore = new \FindBoxCoreSystem(...array_values($CORE_SETTINGS));
+    $elenco = [];
+    for($i = 1; $i <= MAX_RIGHE_CAMPI_CARRELLO; $i++) {
+      $fieldName = 'campo' . str_pad($i, 2, '0', STR_PAD_LEFT);
+      $elenco[$fieldName] = '';
+    }
+
+    $dataFields = array_merge($elenco, array(
+      'end_operations' => '',
+      'origine' => '',
+      'commessa' => '',
+      'ordine_produzione' => '',
+      'data_creazione' => ''));
+
+    $findBoxCore->SaveProducts($labelId, '', $dataFields);
+  }
+
   /**
    * Salva i dati per l'etichetta del carrello
    *
@@ -161,12 +183,13 @@ EOF;
     $dataFields['end_operations'] = $consegna;
 
     $label = new \SmartESL($findBoxCore, [$labelId]);
-    $devType = 79;
-    $dt = \F3::get("LABELS.TEMPLATES.DT{$devType}");
+//    $devType = 79;
+//    $dt = \F3::get("LABELS.TEMPLATES.DT{$devType}");
 
     $findBoxCore->SaveProducts($barcode, $consegna, $dataFields);
-    $label->Display($dt[1], $barcode);
-    $label->BlinkSpecial(0, 1, 1000, 2, 0);
+    // TODO #NODISPLAY da testare, rimuovere se è ok
+//    $label->Display($dt[1], $barcode);
+    $label->BlinkSpecial(0, 1, 1000, 8, 0);
   }
 
   public function SaveProductsForLabel7(string $barcode, string $consegna)
@@ -182,7 +205,7 @@ EOF;
     $articles = $this->getArticoliByConsegna($consegna);
     $joinFields = array_map('array_shift', $articles);
     $elenco = [];
-    for($i = 1; $i <= 22; $i++) {
+    for($i = 1; $i <= MAX_RIGHE_CAMPI_CARRELLO; $i++) {
       $fieldName = 'campo' . str_pad($i, 2, '0', STR_PAD_LEFT);
       $elenco[$fieldName] = '';
     }
@@ -198,19 +221,25 @@ EOF;
 
   public function ResetDistintaLabels(string $commessa, string $label7Id)
   {
-    $sql = "SELECT label_id, anomalie, b.barcode FROM distinta_esplosa d JOIN label_bindings b ON d.barcode=b.barcode WHERE idutente={$this->userId} AND commessa='{$commessa}'";
+    $sql = "SELECT label_id, anomalie, b.barcode, d.descrizione FROM distinta_esplosa d JOIN label_bindings b ON d.barcode=b.barcode WHERE idutente={$this->userId} AND commessa='{$commessa}'";
     $dataset = $this->dbHandle->exec($sql);
 
     $CORE_SETTINGS = \F3::get('CORE.fb');
     $findBoxCore = new \FindBoxCoreSystem(...array_values($CORE_SETTINGS));
 
     foreach($dataset as $row) {
-      $label = new \SmartESL($findBoxCore, [$row['label_id']]);
-//      $details = $label->getDetails();
-//      $devType = $details[$row['label_id']]['status']['dev_type'];
-      $devType = 31;
-      $labelTemplateId = \F3::get("LABELS.TEMPLATES.DT{$devType}");
-      $label->Display($labelTemplateId[0], $row['barcode']);
+      $dataFields = array(
+        'qr_code' => $row['barcode'],
+        'qta_prelevare' => ''
+      );
+
+      // TODO #NODISPLAY da testare, rimuovere se è ok
+      $findBoxCore->SaveProducts($row['barcode'], $row['descrizione'], $dataFields);
+
+//      $label = new \SmartESL($findBoxCore, [$row['label_id']]);
+//      $devType = 31;
+//      $labelTemplateId = \F3::get("LABELS.TEMPLATES.DT{$devType}");
+//      $label->Display($labelTemplateId[0], $row['barcode']);
     }
   }
 

+ 12 - 15
src/Modules/Pages.php

@@ -14,8 +14,7 @@ class Pages extends BaseController
     if (!is_null($this->userId)) {
       $f3->reroute('/homemenu');
       return;
-    }
-    else
+    } else
       $f3->set('CONTENT', 'login.tpl');
 
     echo \Template::instance()->render('masterpage.tpl');
@@ -39,13 +38,12 @@ class Pages extends BaseController
         $stepValues = json_decode($f3->get('COOKIE.p2l'), true);
     }
 
-
     switch ($args['step']) {
       case 3:
         $distinta = new \Distinta($f3);
         $distinta->CleanDistintaTable();
         $distinta->CopyDistinta($stepValues['consegna']);
-        $distinta->SaveLabelCarrello($stepValues['labelid'], $stepValues['labelid'], $stepValues['consegna']);
+        $distinta->ResetLabelCarrello($stepValues['labelid']);
         $distinta->SaveProductsToFindBox('3', true, 50); // prende soltanto i primi 3 dalla tabella copia delle distinte
 
         $f3->set('COOKIE.p2l', json_encode($stepValues));
@@ -87,17 +85,17 @@ class Pages extends BaseController
               $findBoxCore = new \FindBoxCoreSystem(...array_values($CORE_SETTINGS));
               $label = new \SmartESL($findBoxCore, [$distinta->GetLabelIdFromBarcode($pickedBarcode)]);
               $label->BlinkOff();
-              sleep(3);
-              $label->BlinkOff();
+//              sleep(3);
+//              $label->BlinkOff();
 //              }
             } else
-              $f3->set('INFOTEXT', 'Barcode non riconosciuto o non associato a nessuna etichetta elettronica arcode selezionato');
+              $f3->set('INFOTEXT', 'Barcode non riconosciuto o non associato ad alcuna etichetta elettronica');
           }
         }
 
         $rowsDistinta = $distinta->getDistinta();
         $f3->set('PRODUCTS', $rowsDistinta);
-        // End Picking
+        // End Picking List
         if (count($rowsDistinta) == 0) {
           $distinta->ResetDistintaLabels($datiCommessa['consegna'], $datiCommessa['labelid']);
           $anomalie = $distinta->getAnomalieFromConsegne($datiCommessa['consegna']);
@@ -106,9 +104,11 @@ class Pages extends BaseController
           $CORE_SETTINGS = $f3->get('CORE.fb');
           $findBoxCore = new \FindBoxCoreSystem(...array_values($CORE_SETTINGS));
           $label = new \SmartESL($findBoxCore, [$datiCommessa['labelid']]);
-          $label->BlinkSpecial(0, 1, 5000, 20, 0);
+          $label->BlinkSpecial(0, 1, 5000, 8, 0);
           $distinta->SaveProductsForLabel7($datiCommessa['labelid'], $datiCommessa['consegna']);
-          $label->Display(1017, $datiCommessa['labelid']);
+          $distinta->SaveLabelCarrello($datiCommessa['labelid'], $datiCommessa['labelid'], $datiCommessa['consegna']);
+          // TODO #NODISPLAY da testare, rimuovere se è ok
+          //$label->Display(1017, $datiCommessa['labelid']);
 
           // Se non ci sono anomalie torna alla homepage
           if (count($anomalie) == 0) {
@@ -135,7 +135,7 @@ class Pages extends BaseController
 
     $f3->set('COOKIE.p2l', json_encode($stepValues));
 
-    $f3->set('DISTINTE', $f3->Get('DB')->exec('SELECT DISTINCT consegna, time_creazione, destinazione_merci FROM distinte ORDER BY data_creazione, time_creazione'));
+    $f3->set('DISTINTE', $f3->Get('DB')->exec('SELECT DISTINCT consegna, time_creazione, destinazione_merci FROM `distinte` d JOIN articles a ON a.materiale=d.barcode ORDER BY time_creazione, destinazione_merci'));
     $f3->set('STEP', $args['step']);
     $f3->set('PAGEVALUES', $stepValues);
 
@@ -161,9 +161,6 @@ class Pages extends BaseController
       $findBoxCore->Bind($stepValues['labelid'], $stepValues['barcode']);
       $label = new \SmartESL($findBoxCore, [$stepValues['labelid']]);
 
-      // Get template from field dev_type o label details
-//      $details = $label->getDetails();
-//      $devType = $details[$stepValues['labelid']]['status']['dev_type'];
       if ($stepValues['labelid'] == $stepValues['barcode'])
         $devType = 79;
       else
@@ -180,7 +177,7 @@ class Pages extends BaseController
           'ubicazione' => $articles['ubicazione'],
           'incc_intr' => $articles['incc_intr']
         );
-        $err = $findBoxCore->SaveProducts($stepValues['barcode'], $articles['descrizione'], $dataFields);
+        $findBoxCore->SaveProducts($stepValues['barcode'], $articles['descrizione'], $dataFields);
         $dataFields = array_merge($dataFields, array(
           'quantita_contenitore' => $articles['qta_contenitore'],
           'quantita_magazzino' => $articles['qta_riordino']

+ 111 - 109
src/SmartESL.php

@@ -7,115 +7,117 @@
 
 class SmartESL
 {
-    private $core;
-    private $labels;
-    private $labelProperties;
-
-    public function __construct(FindBoxCoreSystem $coreL, array $LabelID)
-    {
-        $this->core = $coreL;
-        $this->labels = $LabelID;
-        $this->labelProperties = $this->GetStatus();
-    }
-
-    /**
-     * Retrieve cached label properties
-     *
-     * @return null|object
-     */
-    public function getDetails()
-    {
-        return $this->labelProperties;
-    }
-
-    /**
-     * Get label version splitted into the three components major, minor, patch
-     *
-     * @return array
-     */
-    public function GetVersion()
-    {
-        $softVersion = $this->labelProperties[array_keys($this->labelProperties)[0]]['status'];
-        return array_values(array_filter_keys($softVersion, ['soft_major', 'soft_minor', 'soft_patch']));
-    }
-
-    /**
-     * Blink the label. If old version found, skip automatically useless parameter
-     *
-     * @param int $pattern
-     * @param int $repeat
-     * @param int $iter_time
-     * @param int $iterations
-     * @param int|null $ledColor
-     */
-    public function BlinkSpecial(int $pattern, int $repeat, int $iter_time, int $iterations, int $ledColor = null)
-    {
-        $firmwareStringVersion = array(
-            '3' => '1.0.0',
-            '4' => '1.1.0',
-            '6' => '2.0.0'
-        );
-
-        $params = array(
-            '3' => array($pattern, $repeat, $iter_time, $iterations, 1),
-            '4' => array($pattern, $repeat, $iter_time, $iterations, 1),
-            '6' => array($pattern, $ledColor, $repeat, $iter_time, $iterations, 1)
-
-        );
-
-        // TODO: da sistemare
+  private $core;
+  private $labels;
+  private $labelProperties;
+
+  public function __construct(FindBoxCoreSystem $coreL, array $LabelID)
+  {
+    $this->core = $coreL;
+    $this->labels = $LabelID;
+    $this->labelProperties = $this->GetStatus();
+  }
+
+  /**
+   * Retrieve cached label properties
+   *
+   * @return null|object
+   */
+  public function getDetails()
+  {
+    return $this->labelProperties;
+  }
+
+  /**
+   * Get label version splitted into the three components major, minor, patch
+   *
+   * @return array
+   */
+  public function GetVersion()
+  {
+    $softVersion = $this->labelProperties[array_keys($this->labelProperties)[0]]['status'];
+    return array_values(array_filter_keys($softVersion, ['soft_major', 'soft_minor', 'soft_patch']));
+  }
+
+  /**
+   * Blink the label. If old version found, skip automatically useless parameter
+   *
+   * @param int $pattern
+   * @param int $repeat
+   * @param int $iter_time
+   * @param int $iterations
+   * @param int|null $ledColor
+   */
+  public function BlinkSpecial(int $pattern, int $repeat, int $iter_time, int $iterations, int $ledColor = null)
+  {
+    $firmwareStringVersion = array(
+      '3' => '1.0.0',
+      '4' => '1.1.0',
+      '6' => '2.0.0'
+    );
+
+    $params = array(
+      '3' => array($pattern, $repeat, $iter_time, $iterations, 1),
+      '4' => array($pattern, $repeat, $iter_time, $iterations, 1),
+      '6' => array($pattern, $ledColor, $repeat, $iter_time, $iterations, 1)
+
+    );
+
+    // TODO #NODISPLAY da sistemare
 //        $ver = $this->GetVersion();
-        $strFWVer = $firmwareStringVersion[6/*$ver[0]*/];
-
-        $uriParams = json_encode(array_merge(
-            array($this->labels),
-            $params[6/*$ver[0]*/]));
-
-        $URI = "/1.0.0/index.php/smartesl.blink_special/{$strFWVer}/";
-        $this->core->CallAPI("GET", $URI, $uriParams, true);
-    }
-
-    /**
-     * Turn off led(s)
-     */
-    public function BlinkOff()
-    {
-        $URI = "/1.0.0/index.php/smartesl.blink_special/2.0.0/";
-        $this->core->CallAPI("GET", $URI, "[[\"{$this->labels[0]}\"],0,1,1,500,1,1]", true);
-    }
-
-    /**
-     * Request to label(s) its properties
-     * @return null|object Details
-     */
-    public function GetStatus()
-    {
-        $labels = json_encode(array($this->labels));
-        $URI = "/1.0.0/index.php/smartesl.getstatus/3.1.0/";
-        $ret = $this->core->CallAPI("GET", $URI, $labels);
-        if ($ret['err'] == 0 && $ret['value']['code'] == 0) {
-            return $ret['value']['value'];
-        }
-        return null;
-    }
-
-    public function Display(int $templateId, string $barcode)
-    {
-        $URI = "/1.0.0/index.php/smartesl.display/2.3.0/";
-        $params = json_encode(array(
-            $this->labels[0],
-            $barcode,
-            [],
-            $templateId,
-            1, 1));
-
-        return $this->core->CallAPI("POST", $URI, $params);
-
-    }
-
-    public function GetLabelMatch()
-    {
-        $URI = "/1.0.0/index.php/smartesl.getlabelmatch/1.2.0/";
-        return $this->core->CallAPI("GET", $URI, json_encode(array($this->labels)));
+    $strFWVer = $firmwareStringVersion[6/*$ver[0]*/];
+
+    $uriParams = json_encode(array_merge(
+      array($this->labels),
+      $params[6/*$ver[0]*/]));
+
+    $URI = "/1.0.0/index.php/smartesl.blink_special/{$strFWVer}/";
+    $this->core->CallAPI("GET", $URI, $uriParams, true);
+  }
+
+  /**
+   * Turn off led(s)
+   */
+  public function BlinkOff()
+  {
+    $URI = "/1.0.0/index.php/smartesl.blink_special/1.1.0/";
+    $this->core->CallAPI("GET", $URI, "[[\"{$this->labels[0]}\"],3,1,500,1,1]", true);
+//    $URI = "/1.0.0/index.php/smartesl.blink_special/2.0.0/";
+//    $this->core->CallAPI("GET", $URI, "[[\"{$this->labels[0]}\"],0,1,1,500,1,1]", true);
+  }
+
+  /**
+   * Request to label(s) its properties
+   * @return null|object Details
+   */
+  public function GetStatus()
+  {
+    $labels = json_encode(array($this->labels));
+    $URI = "/1.0.0/index.php/smartesl.getstatus/3.1.0/";
+    $ret = $this->core->CallAPI("GET", $URI, $labels);
+    if ($ret['err'] == 0 && $ret['value']['code'] == 0) {
+      return $ret['value']['value'];
     }
+    return null;
+  }
+
+  public function Display(int $templateId, string $barcode)
+  {
+    $URI = "/1.0.0/index.php/smartesl.display/2.3.0/";
+    $params = json_encode(array(
+      $this->labels[0],
+      $barcode,
+      [],
+      $templateId,
+      1, 1));
+
+    return $this->core->CallAPI("POST", $URI, $params);
+
+  }
+
+  public function GetLabelMatch()
+  {
+    $URI = "/1.0.0/index.php/smartesl.getlabelmatch/1.2.0/";
+    return $this->core->CallAPI("GET", $URI, json_encode(array($this->labels)));
+  }
 }

+ 1 - 1
ui/pick2light_savingproducts.tpl

@@ -7,7 +7,7 @@
     <script>
         setTimeout(function() {
             window.location.href = "{{@BASEURL}}/pick2light/5"
-        }, 20000)
+        }, 5000)
     </script>
 
 </div>