Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | two new twv demos added |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
166df1f2ef8ecb374bd4a5295d9aee15 |
User & Date: | chw 2019-06-19 06:44:50.916 |
Context
2019-06-20
| ||
05:44 | cleanup twv and examples check-in: 71419c4d08 user: chw tags: trunk | |
2019-06-19
| ||
06:44 | two new twv demos added check-in: 166df1f2ef user: chw tags: trunk | |
2019-06-18
| ||
18:27 | fix for ticket [1a46afebae] check-in: 3485b4485c user: chw tags: trunk | |
Changes
Added undroid/tsb/examples/mqtt.tsb.
> > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 1 {h2 "MQTT Demo"} 2 {#HTML <p>Preparation: load Schelte Bronn's mqtt package</p>} 3 {package require mqtt} 4 {#HTML <p>Define a callback function which is invoked on reception of a subscription. The callback stores the received data with a timestamp in an array indexed by the so called topic, i.e. the item(s) the subscription refers to.</p>} 5 {proc callback {topic content retain} { set content [encoding convertfrom utf-8 $content] set now [clock seconds] set date [clock format $now -format "%Y-%m-%d"] set time [clock format $now -format "%H:%M:%S"] # cut "de.wsv/pegel/cm" prefix from topic set topic [join [lrange [split $topic /] 3 end] /] set ::DATA($topic) [list $date $time $content] }} 6 {#HTML <p>Create an MQTT client and connect it to the Mosquitto test server.</p>} 7 {set MQTT_CLIENT [mqtt new] $MQTT_CLIENT connect test-client test.mosquitto.org 1883} 8 {#HTML <p>Subscribe to topic(s), here we choose the river levels published by the GWDS/WSV.</p>} 9 {$MQTT_CLIENT subscribe "de.wsv/pegel/cm/#" callback} 10 {#HTML <p>From now on, periodic updates should be written into the DATA array.</p>} 11 {table {topic data} [array get DATA]} 12 {#HTML <p>Refresh the table above each minute.</p>} 13 {proc refresh {} { after cancel refresh after 60000 refresh tsb::eval 11 } refresh} 14 {tsb::save mqtt.tsb} |
Added undroid/tsb/examples/northwind.tsb.
> > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 8 {#HTML <p>Display the images from table [Categories].</p>} 4 {#HTML <p>Let's retrieve the schema diagram of the Northwind database ...</p>} 10 {tsb::save northwind.tsb} 9 {foreach img [DB eval {select Picture from [Categories]}] { img_from_binary $img image/jpeg 0 }} 5 {img_from_binary [curl_get https://raw.githubusercontent.com/jpwhite3/northwind-SQLite3/master/Northwind_ERD.png] image/png 0} 1 {h2 "Northwind Sample With SQLite3"} 6 {#HTML <p>Now we create an in-memory SQLite3 database, fill it with the NorthWind data from SQL source, and finally list data fromthe [Categories] table.</p>} 2 {#HTML <p>Some helper code to fetch data from an URL ...</p>} 7 {package require sqlite3 sqlite3 DB :memory: DB eval [encoding convertfrom iso8859-15 [curl_get https://raw.githubusercontent.com/jpwhite3/northwind-SQLite3/master/Northwind.Sqlite3.create.sql]] table {CategoryID CategoryName Description} [DB eval {select CategoryID, CategoryName, Description from [Categories]}]} 3 {package require TclCurl proc curl_get {url} { set h [curl::init] $h configure -url $url -bodyvar result catch {$h perform} e if {$e != 0} { return -code error [curl::easystrerror $e] } $h cleanup return $result }} |