Improve names
[khatus.git] / bin / khatus_loop
index 3bd112d..4952483 100755 (executable)
@@ -2,7 +2,7 @@
 
 MSG_TAG_SEP=': '
 
-fetch_weather() {
+produce_weather() {
     metar -d "$WEATHER_STATION_ID" 2>&1 \
     | awk '
         /METAR pattern not found in NOAA data/ {
@@ -23,35 +23,33 @@ fetch_weather() {
         }'
 }
 
-fetch_datetime() {
+produce_datetime() {
     date +'%a %b %d %H:%M:%S'
 }
 
-read_and_react() {
+consume() {
     pipe="$1"
     tail -f "$pipe" \
     | stdbuf -o L awk \
         '
             /^in:WEATHER:/\
             {
-                chop_off_msg_tag()
-                db["weather_temperature"] = $0
+                db["weather_temperature"] = read_msg()
             }
 
             /^in:DATE_TIME:/\
             {
-                chop_off_msg_tag()
-                db["datetime"] = $0
+                db["datetime"] = read_msg()
             }
 
             /^out:BAR:/\
             {
-                chop_off_msg_tag()
                 print make_bar()
             }
 
-            function chop_off_msg_tag() {
+            function read_msg() {
                 sub("^" $1 " +", "")
+                return $0
             }
 
             function make_bar(    position, bar, i) {
@@ -68,7 +66,7 @@ read_and_react() {
         '
 }
 
-trigger_bar() {
+produce_bar_req() {
     echo ''
 }
 
@@ -93,10 +91,10 @@ main() {
     rm -f "$pipe"
     mkfifo "$pipe"
 
-    spawn fetch_datetime "$pipe" 'in:DATE_TIME' 1
-    spawn fetch_weather  "$pipe" 'in:WEATHER'   $(( 30 * 60 ))
-    spawn trigger_bar    "$pipe" 'out:BAR'      1
-    read_and_react       "$pipe"
+    spawn produce_datetime  "$pipe" 'in:DATE_TIME' 1
+    spawn produce_weather   "$pipe" 'in:WEATHER'   $(( 30 * 60 ))
+    spawn produce_bar_req   "$pipe" 'out:BAR'      1
+    consume "$pipe"
 }
 
 main $@
This page took 0.029383 seconds and 4 git commands to generate.