| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Giancarlo
- * Date: 09/08/2018
- * Time: 14:42
- */
- namespace OpenMind\FindBox;
- define('Q_BLINK_ON', 1);
- define('Q_BLINK_OFF', 2);
- define('Q_SAVEPRODUCT', 3);
- define('Q_DISPLAY', 4);
- class QueueCommand
- {
- public $id;
- public $operation;
- public $description;
- public $params;
- public $tsFirstBlink;
- public $tsLastLongBlink;
- public function __construct(string $labelID)
- {
- $this->id = $labelID;
- $this->params = null;
- $this->tsLastLongBlink = time() - 3600;
- $this->tsFirstBlink = time();
- }
- public function setLeds(int $pattern, int $repeat, int $iter_time, int $iterations, int $color)
- {
- $this->operation = Q_BLINK_ON;
- list(
- $this->params['pattern'],
- $this->params['repeat'],
- $this->params['iter_time'],
- $this->params['iterations'],
- $this->params['color']
- ) = func_get_args();
- }
- public function saveProducts(string $description, array $dataFields)
- {
- $this->operation = Q_SAVEPRODUCT;
- $this->description = $description;
- $this->params['dataFields'] = $dataFields;
- }
- public function setToBlinkOff()
- {
- $this->operation = Q_BLINK_OFF;
- }
- /**
- * Calculate blink duration in seconds for patterns_type=2
- *
- * @return int
- */
- public function getBlinkDuration(): int
- {
- return (($this->params['iter_time'] / 1000) * ($this->params['iterations'] - 1)) * $this->params['repeat'];
- }
- /**
- * Set Display ID
- *
- * @param string $templateId
- * @param string $barcode
- */
- public function setDisplay(string $templateId, string $barcode)
- {
- $this->operation = Q_DISPLAY;
- list(
- $this->params['templateId'],
- $this->params['barcode']
- ) = func_get_args();
- }
- }
|