Herunterladen Inhalt Inhalt Diese Seite drucken

IFTOOLS MSB-RS485-PLUS Handbuch Seite 133

Inhaltsverzeichnis

Werbung

16
l o c a l f c = t e x t c o l o r s [ t g : d i r ( ) ]
17
l o c a l bc = b a c k c o l o r s [ t g : d i r ( ) ]
18
19
d i s p l a y t i m e
20
box . t e x t { c a p t i o n =" Time " , t e x t = t g : t i m e ( ) , f g = f c , bg=bc }
21
22
d i s p l a y a l l data as hex
23
box . t e x t { c a p t i o n =" Data ( hex ) " , t e x t = t g . dump { } , f g = f c , bg=bc }
24
end
Zur Vollständigkeit haben wir die split Funktion ebenfalls mit aufgelistet.
Zeile 9 ist eine typische Lua Tabelle (oder Array) mit zwei Einträgen für die
Textfarbe (je nach Richtung). Zeile 10 definiert entsprechend zwei Farben für
den Hintergrund.
In Zeile 13 holen wir das zuständige Telegramm und weisen es der Variable tg
zu. Die Funktion tg:dir() liefert die Quelle oder Richtung des Telegramms
als Wert 1 (Port A/Ch1) oder 2 (Port B/CH2). Das Resultat wird in den Zeilen
16 und 17 genutzt um für das aktuelle Telegramm Text- und Hintergrundfarbe
auszuwählen. Zu guter Letzt übergeben wir diese Farben als zusätzliche Para-
meter fg und bg an die beiden Box Aufrufe (Zeile 20 und 23).
Drücken Sie jetzt die Taste F5 - voila - die bislang schwarz/weiße Telegramm-
Anzeige wechselt in eine bunte Darstellung.
Time
Data (hex)
2.339189
03a 030 032 030 032 043 034 00d 00a
Time
Data (hex)
2.351468
03a 030 032 030 032 030 046 031 035 036 041 034 032 037 044 00d 00a
Übrigens: Jede Änderung an dem Template wird automatisch bei Ausführung
mittels F5 gespeichert.
Als nächstes wollen wir die beiden Telegramm Begrenzer ':' (3Ah) und die End-
Of-Frame Sequenz CRLF gesondert hervorheben um etwaige Abweichungen
im Telegramm durch Übertragungsfehler besser erkennen zu können.
function s p l i t ( data , i n t v a l , a l t e r , s t r )
1
i f data == 58 then r e t u r n STARTED end
2
i f s t r : f i n d ( " \ r \ n " ) then r e t u r n COMPLETED end
3
r e t u r n MODIFIED
4
end
5
6
7
function o u t ( )
8
t e l e g r a m c o l o r s
9
l o c a l t e x t c o l o r s = { 0 xFF0000 , 0 x0000FF }
10
l o c a l b a c k c o l o r s = { 0xFFEEDD, 0xDDEEFF}
11
12
access t h e c u r r e n t t e l e g r a m
13
l o c a l t g = t e l e g r a m s . t h i s ( )
14
15
s e l e c t t h e t e x t and background c o l o r depending on t h e data
source
16
l o c a l f c = t e x t c o l o r s [ t g : d i r ( ) ]
17
l o c a l bc = b a c k c o l o r s [ t g : d i r ( ) ]
18
19
d i s p l a y t i m e
20
box . t e x t { c a p t i o n =" Time " , t e x t = t g : t i m e ( ) , f g = f c , bg=bc }
21
22
s t a r t c o l o n
23
box . t e x t { c a p t i o n ="SOF" , t e x t = s t r i n g . char ( t g : data ( 1 ) ) , bg= f c , f g =bc }
13.3. TEMPLATE SPRACHSYNTAX
121

Werbung

Inhaltsverzeichnis
loading

Inhaltsverzeichnis