| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- <?php
- /**
- * @author Open Mind
- * @date 28/03/2018
- * @time 09:09
- */
- namespace OpenMind\Labeling;
- 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 #NODISPLAY da sistemare
- $strFWVer = $firmwareStringVersion[4];
- $uriParams = json_encode(array_merge(
- array($this->labels),
- $params[4]));
- $URI = "/1.0.0/index.php/smartesl.blink_special/{$strFWVer}/";
- $this->core->CallAPI($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($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($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($URI, $labels);
- if ($ret['err'] == 0 && $ret['value']['code'] == 0) {
- return $ret['value']['value'];
- }
- return null;
- }
- public function Display(string $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($URI, $params);
- }
- public function GetLabelMatch()
- {
- $URI = "/1.0.0/index.php/smartesl.getlabelmatch/1.2.0/";
- return $this->core->CallAPI($URI, json_encode(array($this->labels)));
- }
- }
|