core = $coreL; $this->labels = array_map('strtoupper', $LabelID); // TODO utilizzare la $Cache di F3 per velocizzare le operazioni $this->labelProperties = $this->GetStatus(); } /** * 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) { // Update current properties $this->labelProperties = $ret['value']['value']; return $this->labelProperties; } return null; } /** * 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 with parameters. BlinkSpecial make use of getData() and check how many leds has to auto select the firmware version. * * @param int $pattern * @param int $repeat * @param int $iter_time * @param int $iterations * @param int|null $ledColor * @return array */ public function BlinkSpecial(int $pattern, int $repeat, int $iter_time, int $iterations, int $ledColor = null) { $numLeds = $this->getData()['led']; switch ($numLeds) { case 2: $version = 4; break; case 4: $version = 6; break; default: $version = 3; break; } $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[$version]; $uriParams = json_encode(array_merge( array($this->labels), $params[$version])); $URI = "/1.0.0/index.php/smartesl.blink_special/{$strFWVer}/"; return $this->core->CallAPI($URI, $uriParams); } public function getData() { return $this->labelProperties[$this->labels[0]]['data']; } /** * Turn off led(s) */ public function BlinkOff() { $URI = "/1.0.0/index.php/smartesl.blink_special/2.0.0/"; return $this->core->CallAPI($URI, "[[\"{$this->labels[0]}\"],0,0,0,0,0,1]"); } 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))); } }