| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Giancarlo
- * Date: 09/08/2018
- * Time: 14:42
- */
- namespace OpenMind\FindBox;
- class QueueCommand
- {
- static public $Q_BLINK_ON = 1;
- static public $Q_BLINK_OFF = 2;
- static public $Q_SAVEPRODUCT = 3;
- static public $Q_DISPLAY = 4;
- static public $Q_GETJOBS = 5;
- static public $Q_CLEARQUEUE = 6;
- public $id;
- public $operation;
- public $description;
- public $params;
- /**
- * QueueCommand constructor.
- * @param array|null $labels
- */
- public function __construct(array $labels = null)
- {
- $this->id = $labels;
- $this->params = null;
- }
- /**
- * Get custom property
- *
- * @param $name
- * @return mixed
- */
- public function __get($name)
- {
- return $this->{$name};
- }
- /**
- * Add custom property
- *
- * @param $name
- * @param $value
- */
- public function __set($name, $value)
- {
- $this->{$name} = $value;
- }
- public function setLeds(int $pattern, int $repeat, int $iter_time, int $iterations, int $color)
- {
- $this->operation = self::$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 = self::$Q_SAVEPRODUCT;
- $this->description = $description;
- $this->params['dataFields'] = $dataFields;
- }
- public function setToBlinkOff()
- {
- $this->operation = self::$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'])) * $this->params['repeat']);
- }
- /**
- * Set Display ID
- *
- * @param string $templateId
- * @param string $barcode
- */
- public function setDisplay(string $templateId, string $barcode)
- {
- $this->operation = self::$Q_DISPLAY;
- list(
- $this->params['templateId'],
- $this->params['barcode']
- ) = func_get_args();
- }
- public function getJobs()
- {
- $this->operation = self::$Q_GETJOBS;
- }
- public function clearQueue()
- {
- $this->operation = self::$Q_CLEARQUEUE;
- }
- }
|