Files
2026-10-22 12:58:21 +02:00

59 lines
1.9 KiB
PHP

<?php
declare(strict_types=1);
trait DevoloPLCLocalLib
{
public static $IS_SERVERERROR = IS_EBASE + 10;
public static $IS_HTTPERROR = IS_EBASE + 11;
public static $IS_INVALIDDATA = IS_EBASE + 12;
private function GetFormStatus()
{
$formStatus = $this->GetCommonFormStatus();
$formStatus[] = ['code' => self::$IS_SERVERERROR, 'icon' => 'error', 'caption' => 'Instance is inactive (server error)'];
$formStatus[] = ['code' => self::$IS_HTTPERROR, 'icon' => 'error', 'caption' => 'Instance is inactive (http error)'];
$formStatus[] = ['code' => self::$IS_INVALIDDATA, 'icon' => 'error', 'caption' => 'Instance is inactive (invalid data)'];
return $formStatus;
}
public static $STATUS_INVALID = 0;
public static $STATUS_VALID = 1;
public static $STATUS_RETRYABLE = 2;
private function CheckStatus()
{
switch ($this->GetStatus()) {
case IS_ACTIVE:
$class = self::$STATUS_VALID;
break;
case self::$IS_SERVERERROR:
case self::$IS_HTTPERROR:
case self::$IS_INVALIDDATA:
$class = self::$STATUS_RETRYABLE;
break;
default:
$class = self::$STATUS_INVALID;
break;
}
return $class;
}
private function InstallVarProfiles(bool $reInstall = false)
{
if ($reInstall) {
$this->SendDebug(__FUNCTION__, 'reInstall=' . $this->bool2str($reInstall), 0);
}
$this->CreateVarProfile('Devolo.TransferRate', VARIABLETYPE_INTEGER, ' Mbit/s', 0, 300, 0, 0, '');
$associations = [];
$associations[] = ['Wert' => 0, 'Name' => 'nie', 'Farbe' => -1];
$associations[] = ['Wert' => 1, 'Name' => '%d min', 'Farbe' => -1];
$this->CreateVarProfile('Devolo.Timeout', VARIABLETYPE_INTEGER, '', 0, 0, 0, 0, 'Hourglass', $associations);
}
}