Permalink
Browse files

Grafische Aufbereitung einer UI-Konfiguration

  • Loading branch information...
il il
il authored and il committed Dec 9, 2018
1 parent 9087c47 commit 3ec21cce3e05be560555b3fd95ab19e3b915ac85
@@ -0,0 +1,17 @@
# Verwendung per: make

CF_FILE = 72
DOT = ./$(CF_FILE).dot
TARGET = ./$(CF_FILE).png

CF_SRC = /home/il/Dropbox/HCAN/HI_SERVER/conf

cf2png:
awk -f cf2dot.awk $(CF_SRC)/$(CF_FILE).cf > $(DOT)
dot -Tpng $(DOT) -o $(TARGET)
#less $(DOT)

clean:
rm $(DOT)
rm $(TARGET)

@@ -0,0 +1,17 @@
Grafische Aufbereitung einer UI-Konfiguration (Dateiname ist z.B. "72.cf")


Voraussetzung:
--------------
sudo apt-get install graphviz mawk


In Console ausführen:
---------------------
make ODER
"./cf2png.sh /home/il/Dropbox/HCAN/HI_SERVER/conf/72" (ohne .cf!)


Ergebnis:
--------
72.png liegt dann neben 72.cf
@@ -0,0 +1,52 @@
#!/usr/bin/awk -f
# $1=set, $2xxx_id, $3=id-value
BEGIN {print "digraph G{"}
BEGIN {print "graph [rankdir=BT]"} #LR (untenstehendes Beispiel), BT (von unten nach oben)
BEGIN {BlockNr=0; parseBlock = false}
{
#fuer jede Zeile:

if($1 == "create")
{
if ( ($2 == "screensaver_page") || ($2 == "leave_come_page") || ($2 == "dir_page") || ($2 == "rolladen_page") || ($2 == "powerport_page") || ($2 == "gesamt_heiz_page") || ($2 == "heiz_page") || ($2 == "temp_anzeige_page") )
{
parseBlock = true
BlockZeilenOFFSET = NR
BlockNr++
genaralPageName[BlockNr] = $2
#printf "\"parseBlockNr=%s %s\"\n", BlockNr, genaralPageName[BlockNr]
}
}
#printf "\"page_id[%s]=%s\"\n", BlockNr, pageId[BlockNr]

if(parseBlock == true)
{
if(NR == BlockZeilenOFFSET+1) {pageId[BlockNr] = $3}
if(NR == BlockZeilenOFFSET+2) {parentId[BlockNr] = $3}
if(NR == BlockZeilenOFFSET+3) {nextId[BlockNr] = $3}
if(NR == BlockZeilenOFFSET+4) {prevId[BlockNr] = $3}
if($2 == "name") {pageName[BlockNr] = $3}
}

if( ($1 == "exit") && (parseBlock == true) )
{
#one block finished -> save page/state -name (Page-Bezeichnung leicht aenderbar!):
pageBez[ pageId[BlockNr] ] = genaralPageName[BlockNr]"__"pageId[BlockNr]"__"pageName[BlockNr]
parseBlock = false
#printf "exitGefunden,BlockNr=%s:PageBez=%s\n", BlockNr, pageBez[ pageId[BlockNr] ]
}
}
#all lines were read:
END{
for(i=1; i<=BlockNr; i++)
{
#printf "i=%i\n", i
if(parentId[i] != 0) {
printf "%s->%s [label=\"parent_id\",fontcolor=green][color=green];\n", pageBez[ pageId[i] ], pageBez[ parentId[i] ]}
if(nextId[i] != 0) {
printf "%s->%s [label=\"next_id\",fontcolor=blue][color=blue];\n", pageBez[ pageId[i] ], pageBez[ nextId[i] ]}
if(prevId[i] != 0) {
printf "%s->%s [label=\"prev_id\",fontcolor=pink][color=pink];\n", pageBez[ pageId[i] ], pageBez[ prevId[i] ]}
}
}
END{print "}"}
@@ -0,0 +1,6 @@
# UI-conf 2 graph
#################

awk -f cf2dot.awk $1.cf > $1.dot
dot -Tpng $1.dot -o $1.png
# rm $1.dot

0 comments on commit 3ec21cc

Please sign in to comment.