SPS-Datenattribute
Deklarieren Sie Variablen innerhalb eines FBs mit dem SPS-Datenattribut "TcHmi.ProcessLibrary", damit sie automatisch mit den Eigenschaften des Controls verknüpft werden. Die vollständige Vorlage lautet:
{attribute 'TcHmi.ProcessLibrary' := '[Attribute Name]'}![]() | Positionierung der Datenattribute Verwenden Sie Datenattribute im VAR_-Bereich unmittelbar vor der Deklaration der Variablen, die mit einem Element des Controls verknüpft werden soll. |
Beispiele für die Verwendung von SPS-Datenattributen
Verknüpfung einer sName Variablen mit der LabelText Eigenschaft:
{attribute 'TcHmi.ProcessLibrary' := 'LabelText'}
sName: STRING := 'CustomPLC';Verknüpfung einer nStateMode Variablen mit der LabelStateMode Eigenschaft:
{attribute 'TcHmi.ProcessLibrary' := 'LabelStateMode'}
nStateMode: INT := 1;Verwendung von SPS-Konfigurationsattributen für Funktionen mit SPS-Datenattributen
Über die Deklaration in einem SPS-Code können Formatierungsfunktionen auf die Eigenschaften angewendet werden. Das Attribut-Pragma "TcHmi.ProcessLibrary.Format" sollte verwendet werden:
{attribute 'TcHmi.ProcessLibrary.Format' := '[FormattingFunctionName]'}FormattingFunctionName ist der Name einer Formatierungsfunktion, die im Kapitel Funktionen (Kategorie: Formatierung) aufgeführt ist. Das Attribut mit der Funktion sollte dem SPS-Datenattribut folgen.
Im Folgenden finden Sie einige Beispiele dafür, wie Variablen mit den Attribut-Pragmas deklariert werden können:
{attribute 'TcHmi.ProcessLibrary' := 'LabelValue'}
{attribute 'TcHmi.ProcessLibrary.Format' := 'TcHmi.Functions.Beckhoff.PI.ProcessLibrary.AnalogCompressionValueFormatter,4'}
fValue: REAL;
{attribute 'TcHmi.ProcessLibrary' := 'LabelValueUnit'}
{attribute 'TcHmi.ProcessLibrary.Format' := 'TcHmi.Functions.Beckhoff.PI.ProcessLibrary.MTPUnitValueFormatter'}
nUnit: INT := 1001;
{attribute 'TcHmi.ProcessLibrary' := 'LabelValue'}
{attribute 'TcHmi.ProcessLibrary.Format' := 'TcHmi.Functions.Beckhoff.PI.ProcessLibrary.BinaryValueFormatter,EMERG,NORM'}
_V: BOOL;Verwendung von SPS-Attributen, wenn ein Control mehrere Werte anzeigen muss
Manchmal müssen mehrere Werte für ein Control-Element angezeigt werden, z.B. bei der PID-Regelung. Um dies zu implementieren, können die Attribute LabelValueAdd1 und LabelValueAdd2 zusammen mit LabelValueUnitAdd1 und LabelValueUnitAdd2 verwendet werden, um Units anzuzeigen. Hier finden Sie Beispiele für die Verwendung der Attribute:
{attribute 'TcHmi.ProcessLibrary' := 'LabelValue'}
{attribute 'TcHmi.ProcessLibrary.Format' := 'TcHmi.Functions.Beckhoff.PI.ProcessLibrary.AnalogCompressionValueFormatter,4'}
_SP: REAL;
{attribute 'TcHmi.ProcessLibrary' := 'LabelValueAdd1'}
{attribute 'TcHmi.ProcessLibrary.Format' := 'TcHmi.Functions.Beckhoff.PI.ProcessLibrary.AnalogCompressionValueFormatter,4'}
_PV: REAL;
{attribute 'TcHmi.ProcessLibrary' := 'LabelValueAdd2'}
{attribute 'TcHmi.ProcessLibrary.Format' := 'TcHmi.Functions.Beckhoff.PI.ProcessLibrary.AnalogCompressionValueFormatter,4'}
_MV: REAL;
{attribute 'TcHmi.ProcessLibrary' := 'LabelValueUnit'}
{attribute 'TcHmi.ProcessLibrary.Format' := 'TcHmi.Functions.Beckhoff.PI.ProcessLibrary.MTPUnitValueFormatter'}
nSPUnit: INT;
{attribute 'TcHmi.ProcessLibrary' := 'LabelValueUnitAdd1'}
{attribute 'TcHmi.ProcessLibrary.Format' := 'TcHmi.Functions.Beckhoff.PI.ProcessLibrary.MTPUnitValueFormatter'}
nPVUnit: INT := 1010;
{attribute 'TcHmi.ProcessLibrary' := 'LabelValueUnitAdd2'}
{attribute 'TcHmi.ProcessLibrary.Format' := 'TcHmi.Functions.Beckhoff.PI.ProcessLibrary.MTPUnitValueFormatter'}
nMVUnit: INT := 1342; 