REBOL [ Title: "Farm Demonstration" Date: 31-Jan-2006 Version: 0.1.0 File: %farmDemo.r Author: "R. v.d. Zee" Purpose: {Rebol Demo Conrtest 2006 The demonstration program hopes to provide an answer to the question: "Yes mate... but what's it good for?" . This script is a kiosk style application, or a demonstration of what REBOL's communication scripts can be used for. } Rights: "R. v.d. Zee Copyright (C) 2006" Comment: {There are two images that are produced by the Australian Bureau Of Meteorology are used in accordance with their copyright guidlines as described on the http://http://www.bom.gov.au/other/copyright.shtml. Images for this script may be downloaded only until March 1, 2006. } History: [ 0.1.0 [31-Jan-2006 "Created"] ] Library: [ level: 'beginner platform: Windows XP type: 'demo domain: none tested-under: Windows XP support: none license: BSD ] ] alreadyDone: false totalDown: 0 home: what-dir forcast: {IDQ1070001 WARNING SUMMARY No warnings. STATE FORECAST for Sunday night and Monday Isolated showers and thunderstorms north of about Normanton to Cardwell. Fine and less humid elsewhere. Light to moderate NE to NW winds across the northern districts. Dry SW/SE winds over central and southern districts. IDQ1070002 EXTENDED OUTLOOK The dry airmass extends into the Gulf Country and has swept over the interior with SW winds clearing all thunderstorms to sea. Showers and thunderstorms to persist north of about Townsville to Normanton and over Cape York Peninsula. On Monday much the same except that the dry SW winds easing over the SE. Minimum temperatures below average over the southern half. } words: {This program is a demonstration of Rebol's powerful yet easy to use communication features. The demonstration illustrates that just a few REBOL scripts could quickly provide a wealth of critical information to for example, farmers or ranchers. Such an application could enable a farmer to: - read & post email & community bulletin boards - check weather charts and forecasts - monitor currency values - monitor commodity prices - download rural news broadcasts - collect & display data from remote sensors - provide security surveillance of the farm Because of REBOL's versatile communication functions, programs that provide information may be written in a concise and timely way. No longer is it necessary for users to sacrifice hours of productive time every week, hunting and pecking through the internet. This program is a kiosk style demonstration. A small audio clip is included. } fxPoints: [ 56x196 70x167 84x179 98x213 112x191 126x172 140x210 154x174 168x210 182x182 196x152 210x202 224x170 238x194 252x189 266x173 280x176 294x195 308x164 322x201 336x148 350x193 364x175 378x170 392x191 406x156 420x172 434x182 448x147 462x163 476x144 490x183 ] legendFont: make face/font [style: size: 10] lowerLineFont: make face/font [style: size: 15] siteFont: make face/font [style: [bold] size: 18] litresFont: make face/font [style: [italic] size: 24] pumpMonitors: layout [ origin 0x0 box 512x368 black effect [ draw [ pen Gold font siteFont text "Pump Monitor" 15x5 pen snow siteFont text "Cow Shed" 30x65 siteFont text "River Paddock" 30x175 siteFont text "2nd Section" 30x285 pen coffee fill-pen leaf line-width 2 circle 220x80 50 fill-pen orange circle 220x190 50 fill-pen red circle 220x300 50 line-width 1 fill-pen olDrab pen olive box 340x30 460x90 pen leaf fill-pen leaf line-width 2 circle 360x40 3 pen orange fill-pen orange circle 360x60 3 pen red fill-pen red circle 360x80 3 pen green line-width 2 font legendFont text "OK" 380x35 pen orange legendFont text "Over Supply" 380x55 pen red legendFont text "Failure" 380x75 pen white font litresFont text "200" 200x65 litresFont text "90,012" 180x175 litresFont text "2" 210x285 ] ] ] bulletinBoard: layout [ size 512x368 across space 0x3 origin 10x10 h3 "Cape York Bulletin Board" box 1x40 return t1: text-list green coal 480x195 left wrap font-size 16 data [ {Hino Tractor For Sale approx. 10,000 Hrs. $8,500 View at Riverside Farms, Tolga - cal@riverside.com.au} "" {Painter Required Interior/Exterior 3 Bedroom House Main Street, Atherton - manager@northernCropDusting} "" {Bananna PIckers Needed Feb 10 - March 14 Tropical Fruits, Innisfail - info@tropicalFruits.com.au} "" {Swim Club Sign On All Welcome Tuesday 8:00pm Gordonvale Swimming Pool} ] return area 482x60 coal (coal + 10) wrap font-color gold - 10 font-size 16 return indent 360 button coal "Post " ] t1/iter/size/2: 60 t1/colors/1: reduce red coul-select: (reduce pewter - 50) t1/iter/feel: make t1/iter/feel [ redraw: func[f a e] bind [ f/color: either find picked f/text [coul-select] [slf/color] ] in t1 'self ] bulletinBoard/offset: 0x0 titleFont: make face/font [style: size: 20] gps: layout [ size 512x368 origin 0x0 gridBox: box 512x368 khaki effect [grid 10x10 0x0 leaf 1x1 ] origin 0x0 mapBox: box 512x368 effect [ draw [ pen red fill-pen red circle 200x150 2 circle 210x150 2 circle 215x160 2 circle 220x170 2 circle 230x175 2 circle 240x180 2 circle 250x180 2 circle 260x180 2 circle 270x180 2 circle 280x180 2 circle 290x180 2 circle 300x180 2 circle 310x180 2 circle 320x175 2 circle 330x170 2 circle 340x165 2 pen coffee fill-pen silver line-width 1 line-join round polygon 10x10 250x10 250X40 10X40 polygon 10x300 500x300 500X340 10X340 pen leaf font siteFont text "GPS Tracking Stock Truck" 20x15 siteFont text "20:00 1-2-2006 E143 20.0 S12 49.0 50 kph 65 klms " 15x310 ] ] ] gps/offset: 0x0 fx: layout [ origin 0x0 currencyBox: box 512x374 black effect [ draw [ pen coffee fill-pen 13.109.169 box 0x0 512x474 text "$1.50" 5x50 text "$1.45" 5x100 text "$1.40" 5x150 text "$1.35" 5x200 text "$1.30" 5x250 text "$1.25" 5x300 text "Dec 1 2005" 55x352 text "Dec 15 1" 265x352 text "Dec 24" 355x352 font titleFont text "The $US In Australian Dollars" 140x10 text "$AU" 2x15 line-width 2 line 45x350 45x10 line 45x350 500x350 line-width 1 pen silver orange line-pattern 5 1 line 45x50 500x50 line 45x100 500x100 line 45x150 500x150 line 45x200 500x200 line 45x250 500x250 line 45x300 500x300 pen white line-width 2 line-pattern none line 56x200 line 56x196 70x167 84x179 98x213 112x191 126x172 140x210 154x174 168x210 182x182 196x152 210x202 224x170 238x194 252x189 266x173 280x176 294x195 308x164 322x201 336x148 350x193 364x175 378x170 392x191 406x156 420x172 434x182 448x147 462x163 476x144 490x183 ] ] ] diesel: layout [ origin 0x0 currencyBox: box 512x374 green effect [ draw [ pen coffee fill-pen 13.109.169 fill-pen linear 0x0 0 400 89.66 1.99 1.99 0.121.186 0.0.156 0.0.181 box pen ivory text "97" 15x50 text "96" 15x70 text "95" 15x90 text "94" 15x110 text "93" 15x130 text "92" 15x150 text "91" 15x170 text "90" 15x190 text "89" 15x210 text "88" 15x230 text "87" 15x250 text "86" 15x270 text "85" 15x290 text "84" 15x310 pen gray text "|" 55x323 text "|" 70x323 text "|" 85x323 text "|" 100x323 text "|" 115x323 text "|" 130x323 text "|" 145x323 text "|" 160x323 text "|" 175x323 text "|" 190x323 text "|" 205x323 text "|" 220x323 text "|" 235x323 text "|" 250x323 text "|" 265x323 text "|" 280x323 text "|" 295x323 text "|" 310x323 text "|" 325x323 text "|" 340x323 text "|" 355x323 text "|" 370x323 text "|" 385x323 text "|" 400x323 text "|" 415x323 text "|" 430x323 text "|" 445x323 text "|" 460x323 text "|" 475x323 pen black line-width 2 line 40x330 40x10 line 40x330 500x330 line-width 1 pen orange silver line-pattern 5 1 line 42x50 500x50 line 42x100 500x100 line 42x150 500x150 line 42x200 500x200 line 42x250 500x250 line 42x300 500x300 pen ivory line-pattern none font titleFont text "DIESEL $AU / BARREL" 170x10 font lowerLineFont text "For The 21 Days Ending January 28, 2006" 145x340 line 70x205 85x178 100x156 115x160 130x168 145x165 160x195 175x193 190x202 205x232 220x214 235x195 250x153 265x168 280x157 295x135 310x135 325x157 340x157 355x154 ] ] ] mainLayout: layout [size 1024x744] mainLayout/offset: 0x0 multiPanes: layout [ size 1024x744 backcolor leaf below space 2x2 origin 2x2 upperLeft: box 509x368 lowerLeft: box 509x368 return upperRight: box 507x368 ;? lowerRight: box 507x368 ] multiPanes/offset: 0x0 emailClient: layout [ size 512x368 across space 0 origin 0x0 eBox: box 512x368 silver coal left top wrap origin 55x340 button teal "Send" button teal "Save" button teal "Check" button teal "Quit ""Mail" origin 30x15 mailWords: area 450x320 coal silver font-size 16 font-color ivory wrap {January 23, 2005 From: Sugar Mountain Research Station Annual Open House Day Tuesday, February 14 10:00 - 4:00. The day begins with a review of the station's research program for the year. After lunch, there is a demonstration of new hoeing machinery and a presentation of the new cane variety QB1445C/2. And, G. Reenback will provide the background information that promoted the recent 10 cent per pound surge in the sugar price. R. Ralph, Cheif Scientist } slider 14x320 pewter coffee ] email: layout [ size 512x368 backcolor 0.71.0 origin 0x0 emailBox: box 512x368 0.71.0 font-color green origin 170x60 emailLogoBox: box 142x30 effect [fit] ] weather: layout [ size 512x368 backcolor 0.71.0 origin 0x0 weatherBox: box 512x368 0.71.0 font-color green origin 170x60 weatherLogoBox: box 142x30 effect [fit] ] dataStream: layout [ size 512x368 backcolor 0.71.0 origin 0x0 dataBox: box 512x368 0.71.0 font-color green origin 170x60 dataStreamLogoBox: box 142x30 effect [fit] ] security: layout [ size 512x368 backcolor orange origin 0x0 yardBox: box 512x368 wrap left top "Cameras" origin 0x0 securityBox: box 512x368 0.71.0 font-color green origin 170x60 securityLogoBox: box 142x30 effect [fit] ] photoUrl: "http://www.users.tpg.com.au/vico72/public/farmDemoFiles/" filesRequired: [ %driveway.png %horses.png %irMap.jpg %irMap.jpg %logo.png %news4.wav %openCane.png %tractorShed.png %weatherChart.gif ] yardImages: [%driveway.png %horses.png %tractorShed.png] if not exists? %farmDemoFiles/ [ make-dir %farmDemoFiles/ ] filesDownloaded: read %farmDemoFiles/. filesToGet: difference filesRequired filesDownloaded setUp: layout [ size 500x180 origin 0x0 box 500x180 effect [gradient 0x1 255.255.255 190.190.190 draw [ pen none fill-pen cubic -93x-76 0 114 21 6 6 72.0.90.133 128.128.0.155 44.80.132.153 139.69.19.162 250.240.230.145 128.128.128.148 160.82.45.130 box 0x0 500x180 ] ] origin 20x30 label 500x44 "Rebol Demo Contest 2006 - Farm Communications" gold font-size 16 underline setUpStatus: h3 500x44 oldrab font-size 16 downloadProgressBar: progress 300x16 olive ] if not empty? filesToGet [ if connected? [ if (now/date - 1-Feb-2006 > 30) [ alert "Subsitution Files Must Be Created - The Required Files Are No Longer Available" break ] setUpStatus/text: "Downloading Files...." show setUpStatus view/new setUp change-dir %farmDemoFiles foreach fileIn filesToGet [ write/binary fileIn (read/binary to-url join photoUrl fileIn) totalDown: totalDown + (size? to-url join photoUrl fileIn) downloadProgressBar/data: divide totalDown 1313334 show downloadProgressBar ] change-dir home ] if not connected? [ setUpStatus/text: "Files Are Needed...There Is No Internet Connection" show setUpStatus view/new setUp hide downloadProgressBar wait 6 setUpStatus/text: "Without The Required Files, This Program Must Terminate." show setUpStatus wait 15 quit ] ] unview/only setUp introduction: layout [ origin 0x0 box 1024x744 effect [ draw [ fill-pen conic 940x744 0 367.04 89.66 0.11 0.11 0.155.0 0.0.0 0.155.0 box ] ] across space 100 origin 100x55 rebolLogo: image %farmDemoFiles/logo.png origin 100x120 introNote: label 850x660 wrap left font-color white font-size 18 origin 0x600 pressGo: box 200x200 effect [ draw [ line-width 2 pen leaf fill-pen goImage circle 100x100 50 ] ] rate 1 feel [engage: func [face action event][ if (now/time - starttime) > 00:00:10 [ pressGo/rate: none pressGo/offset: 841x560 show pressGo if action = 'down [ mainLayout/pane: multiPanes show mainLayout wait 2 weatherBox/text: "Loading Weather Information..." show weatherBox wait 3 originalSize: weatherBox/font/size weatherBox/font/size: 12 weatherBox/text: "(Images & Data © Australian Bureau Of Meteorology)" show weatherBox weatherBox/font/size: originalSize wait 3 hide weatherBox weatherBox/text: "" weatherBox/effect: ['aspect] ;or 'fit weatherBox/image: load %farmDemoFiles/irMap.jpg show weatherBox wait 5 weatherBox/image: load %farmDemoFiles/weatherChart.gif show weatherBox wait 5 weatherBox/image: none weatherBox/color: water weatherBox/font/align: 'left weatherBox/font/valign: 'top weatherBox/para/origin: 5x20 weatherBox/font/color: snow weatherBox/text: forcast show weatherBox weatherBox/para/origin: 2x2 ;otherwise affects button faces weatherBox/line-list: 0 weatherBox/color: 0.71.0 weatherBox/font/color: green weatherBox/font/align: 'center weatherBox/font/valign: 'middle wait 2 dataBox/text: "Gathering Pump Data From Serial Port..." show dataBox wait 4 emailBox/text: "Looking For Email..." show emailBox wait 3 dataBox/text: "Graphing Pump Data..." show dataBox wait 2 dataStream/image: to-image pumpMonitors hide dataBox show dataStream wait 3 emailBox/text: "New Messages ...." show emailBox wait 3 upperLeft/pane: emailClient show upperLeft lowerRightpane: security show lowerRight securityBox/text: "Loading Camera Images..." show securityBox wait 3 captions: ["Driveway" "Horse Paddock" "Tractor Shed"] securityBox/font/align: 'left securityBox/font/valign: 'top securityBox/para/origin: 2x2 securityBox/font/color: ivory wait 3 loop 3 [ securityBox/text: captions/1 securityBox/image: load join %farmDemoFiles/ (first yardImages) show securityBox ;box yardImages: next yardImages captions: next captions wait 5 ] yardImages: head yardImages captions: head captions securityBox/line-list: 0 securityBox/color: 0.71.0 securityBox/font/color: green securityBox/font/align: 'center securityBox/font/valign: 'middle weatherBox/text: "Loading Rural Radio News..." show weatherBox wait 0 ring: load %farmDemoFiles/news4.wav sound-port: open sound:// insert sound-port ring wait sound-port close sound-port wait 3 weatherBox/text: "Transferring Newscast To Pod..." show weatherBox wait 2 dataBox/text: "Getting Today's $US Rate..." show dataBox wait 4 dataBox/text: "Updating Currency Graph..." show dataBox wait 2 dataStream/image: to-image fx dataStream/effect: [fit] show dataStream hide dataBox wait 5 show dataBox dataBox/text: "Updating Diesel Price...." show dataBox wait 4 upperRight/pane: diesel show upperRight wait 5 weatherBox/text: "Logging On To Bullentin Board..." show weatherBox wait 4 lowerLeft/pane: bulletinBoard show lowerLeft wait 5 upperLeft/pane: email show upperLeft emailBox/text: "Reading Relayed Email..." show emailBox wait 4 emailBox/text: "Parsing Email Navigation Data ..." show emailBox wait 4 emailBox/text: "Mapping Vehicle Track...." show emailBox wait 4 upperLeft/pane: gps show upperLeft wait 5 lowerLeft/pane: weather show lowerLeft weatherBox/font/align: 'left weatherBox/text: { - HTTP Download Weather Data & Bulletin Board - Parse & Reformat Text - Download Large MP3 Files - Transfer MP3 File To Pod - Launch Audio Player - FTP Upload To Bulletin Board } weatherLogoBox/image: load %farmDemoFiles/logo.png show weatherLogoBox show weatherBox wait 6 upperLeft/pane: email show upperLeft emailBox/font/align: 'left emailBox/text: { - POP Download Email Messages - SMTP Upload Email - Parse Foreign Currency & GPS Relayed Emails - Draw Tracking Map } show emailBox emailLogoBox/image: load %farmDemoFiles/logo.png show emailLogoBox wait 4 upperRight/pane: datastream show upperRight datastream/image: none dataBox/font/align: 'left dataBox/text: { - Open Serial Port For Data Exchange - Draw Graphs From Remote Data Stream - Draw Graphs From Parsed Emails } show dataStream show dataBox dataStreamLogoBox/image: load %farmDemoFiles/logo.png show dataStreamLogoBox wait 5 securityBox/image: none show securityBox securityBox/font/align: 'left securityBox/text: rejoin [{ - Load Photo Binary Files - Fit Images To Display } "^/" ] ;placeholder clear securityBox/effect show securityBox securityLogoBox/image: load %farmDemoFiles/logo.png show securityLogoBox wait 5 backTime: 40 securityText: copy securityBox/text loop 40 [ securityBox/text: rejoin [{ - FTP Download Photo Binary Files - Fit Images To Display } "^/" " Returning To Introduction In " backTime " Seconds" ] show securityBox backTime: backTime - 1 wait 1 ] mainLayout/pane: introduction show mainLayout clear [dataBox/text emailBox/text securityBox/text weatherBox/text] dataBox/text: emailBox/text: securityBox/text: weatherBox/text: "" weatherBox/text: "" show [dataBox emailBox securityBox weatherBox] weatherBox/line-list: 0 emailBox/font/align: dataBox/font/align: securityBox/font/align: weatherBox/font/align: 'center emailLogoBox/image: dataStreamLogoBox/image: securityLogoBox/image: weatherLogoBox/image: none starttime: now/time pressGo/rate: 1 ] ] ] ] ] introNote/text: form words mainLayout/pane: introduction upperLeft/pane: email lowerLeft/pane: weather upperRight/pane: dataStream lowerRight/pane: security introduction/offset: diesel/offset: emailClient/offset: 0x0 bulletinBoard/offset: dataStream/offset: security/offset: weather/offset: email/offset: 2x1 weatherBox/offset: 2x1 pressGo/offset: 1200x55 goImage: load %farmDemoFiles/openCane.png startTime: now/time mainLayout/offset: 0x25 view mainLayout