From 878a98ee1a8f8d3c42a8d855bb5fb962c31c04f5 Mon Sep 17 00:00:00 2001 From: hvxl Date: Mon, 2 Apr 2018 16:53:49 +0200 Subject: [PATCH] - Expand CH2 support --- otmonitor.vfs/dbus.tcl | 9 +- otmonitor.vfs/docroot/graph.svg.tmpl | 24 +++- otmonitor.vfs/docroot/status.html.tmpl | 11 +- otmonitor.vfs/gui.tcl | 148 +++++++++++++++++++------ otmonitor.vfs/otmonitor.tcl | 93 ++++++++++++---- otmonitor.vfs/track.tcl | 4 +- otmonitor.vfs/web.tcl | 8 +- 7 files changed, 232 insertions(+), 65 deletions(-) diff --git a/otmonitor.vfs/dbus.tcl b/otmonitor.vfs/dbus.tcl index a52520c..9ea1717 100644 --- a/otmonitor.vfs/dbus.tcl +++ b/otmonitor.vfs/dbus.tcl @@ -68,21 +68,28 @@ dbif method / Report {} list:a{sv} { set rc {} foreach {name var sig} { BoilerWaterTemperature boilertemp d + BoilerWaterTemperature2 boilertemp2 d CHEnable chenable b + CH2Enable ch2enable b CHSetpoint chsetpoint d CentralHeating chmode b + CentralHeating2 ch2mode b ControlSetpoint controlsp d + ControlSetpoint2 controlsp2 d DHWEnable dhwenable b DHWSetpoint dhwsetpoint d DHWTemperature dhwtemp d + DHWTemperature2 dhwtemp2 d Fault fault b Flame flame b HotWater dhwmode b Modulation modulation d OutsideTemperature outside d ReturnWaterTemperature returntemp d - RoomTemperature temperature d + RoomTemperature roomtemp d + RoomTemperature2 roomtemp2 d Setpoint setpoint d + Setpoint2 setpoint2 d } { if {[info exists gui($var)] && $gui($var) ne "???"} { dict set rc $name [list $sig $gui($var)] diff --git a/otmonitor.vfs/docroot/graph.svg.tmpl b/otmonitor.vfs/docroot/graph.svg.tmpl index c14e5cf..70e750a 100644 --- a/otmonitor.vfs/docroot/graph.svg.tmpl +++ b/otmonitor.vfs/docroot/graph.svg.tmpl @@ -1,6 +1,13 @@ -% global track start graph theme timestamp +% global track start gui graph graphdef theme timestamp % set now $timestamp % set maxx [expr {min(1440, ($now - $start) / 5.) + 25}] +% if {[info exists graph]} { +% } elseif {[info exists gui(ch2)] && $gui(ch2)} { +% set graph $graphdef +% } else { +% # Remove the CH2 related parts +% set graph [dict remove $graphdef chmode2 temperature2] +% } % # Calculate the height of the graph % set height 18 % dict for {name dict} $graph { @@ -83,13 +90,22 @@ % set h [expr {[dict size $line] * 14 - 3}] -% dict for {name data} $line { -% set title [dict get $data name] -% set color [dict get $data color] +% if {[dict exists $dict name]} { +% set title [dict get $dict name] +% set color [dict get $dict color] % incr v 4 $title % incr v 10 +% } else { +% dict for {name data} $line { +% set title [dict get $data name] +% set color [dict get $data color] + +% incr v 4 +$title +% incr v 10 +% } % } % } diff --git a/otmonitor.vfs/docroot/status.html.tmpl b/otmonitor.vfs/docroot/status.html.tmpl index ed2fdea..f504945 100644 --- a/otmonitor.vfs/docroot/status.html.tmpl +++ b/otmonitor.vfs/docroot/status.html.tmpl @@ -31,7 +31,7 @@ var query = {"var" : \["gui", "error"\]}; % overtemp "Water over-temperature" % } % set table2 { -% temperature °C "Room temperature" +% roomtemp °C "Room temperature" % outside °C "Outside temperature" % setpoint °C "Room setpoint" % boilertemp °C "Boiler water temperature" @@ -46,6 +46,15 @@ var query = {"var" : \["gui", "error"\]}; % maxmod % "Max. relative modulation level" % faultcode "" "OEM fault code" % } +% if {[info exists gui(ch2)] && $gui(ch2)} { +% lappend table2 {*}{ +% roomtemp2 °C "Room temperature 2" +% boilertemp2 °C "Boiler water temperature 2" +% setpoint2 °C "Room setpoint 2" +% dhwtemp2 °C "Domestic hot water temperature 2" +% controlsp2 °C "Control setpoint 2" +% } +% } % set col 0 % foreach {n s} $table1 { diff --git a/otmonitor.vfs/gui.tcl b/otmonitor.vfs/gui.tcl index 5790552..f88ea3f 100644 --- a/otmonitor.vfs/gui.tcl +++ b/otmonitor.vfs/gui.tcl @@ -55,7 +55,7 @@ proc gui::imglist {fn} { } proc gui::start {} { - global cfg + global cfg gui upvar #0 cfg(connection,type) devtype themeinit @@ -114,7 +114,7 @@ proc gui::start {} { ttk::label .l10 -text "Relative modulation level" ttk::label .v10 -textvariable gui(modulation) -anchor e -width 6 ttk::label .l11 -text "Room temperature" - ttk::label .v11 -textvariable gui(temperature) -anchor e -width 6 + ttk::label .v11 -textvariable gui(roomtemp) -anchor e -width 6 ttk::label .l12 -text "Room setpoint" ttk::label .v12 -textvariable gui(setpoint) -anchor e -width 6 ttk::label .l13 -text "Return water temperature" @@ -156,6 +156,43 @@ proc gui::start {} { grid .l8 .v8 -in .f3 -sticky we -padx 2 -pady 1 grid .l21 .v21 -in .f3 -sticky we -padx 2 -pady 1 + ttk::separator .sep-ch2 + ttk::label .title-ch2 -text "CH circuit 2" -padding {4 0} + + ttk::frame .f1-ch2 + grid columnconfigure .f1-ch2 0 -weight 1 + ttk::frame .f2-ch2 + grid columnconfigure .f2-ch2 0 -weight 1 + ttk::frame .f3-ch2 + grid columnconfigure .f3-ch2 0 -weight 1 + ttk::separator .sep1-ch2 -orient vertical + ttk::separator .sep2-ch2 -orient vertical + + ttk::checkbutton .f1-ch2.v15 -class TLabel -style Indicator.TCheckbutton \ + -variable gui(ch2mode) -text "Central heating mode " + ttk::checkbutton .f1-ch2.v19 -class TLabel -style Indicator.TCheckbutton \ + -variable gui(ch2enable) -text "Central heating enable " + ttk::label .f2-ch2.l11 -text "Room temperature" + ttk::label .f2-ch2.v11 -textvariable gui(roomtemp2) -anchor e -width 6 + ttk::label .f2-ch2.l12 -text "Room setpoint" + ttk::label .f2-ch2.v12 -textvariable gui(setpoint2) -anchor e -width 6 + ttk::label .f3-ch2.l6 -text "Boiler water temperature" + ttk::label .f3-ch2.v6 -textvariable gui(boilertemp2) -anchor e -width 6 + ttk::label .f3-ch2.l7 -text "Control setpoint" + ttk::label .f3-ch2.v7 -textvariable gui(controlsp2) -anchor e -width 6 + ttk::label .f3-ch2.l18 -text "DHW temperature" + ttk::label .f3-ch2.v18 -textvariable gui(dhwtemp2) -anchor e -width 6 + + grid .f1-ch2.v15 -sticky we -padx 2 -pady 1 + grid .f1-ch2.v19 -sticky we -padx 2 -pady 1 + + grid .f2-ch2.l11 .f2-ch2.v11 -sticky we -padx 2 -pady 1 + grid .f2-ch2.l12 .f2-ch2.v12 -sticky we -padx 2 -pady 1 + + grid .f3-ch2.l6 .f3-ch2.v6 -sticky we -padx 2 -pady 1 + grid .f3-ch2.l7 .f3-ch2.v7 -sticky we -padx 2 -pady 1 + grid .f3-ch2.l18 .f3-ch2.v18 -in .f3-ch2 -sticky we -padx 2 -pady 1 + ttk::separator .sep3 ttk::notebook .nb @@ -190,11 +227,19 @@ proc gui::start {} { grid .sep -padx 2 -sticky ew -columnspan 5 grid .f1 .sep1 .f2 .sep2 .f3 -sticky ns -pady 2 -padx 4 + grid .sep-ch2 .title-ch2 -column 0 -columnspan 5 + grid .sep-ch2 -sticky ew -padx 2 + grid .f1-ch2 .sep1-ch2 .f2-ch2 .sep2-ch2 .f3-ch2 -sticky nsew -pady 2 -padx 4 grid .sep3 -padx 2 -sticky ew -columnspan 5 grid .nb -columnspan 5 -sticky news -padx 8 -pady 8 grid .sep4 -padx 2 -sticky ew -columnspan 5 grid .bar -sticky ew -columnspan 5 + # Do not show the CH2 information until its presence has been reported + grid remove {*}[lsearch -all -inline [winfo children .] *-ch2] + # Add a trace on the gui array to detect if a CH2 circuit is present + trace add variable gui write [namespace code ch2trace] + update idletasks if {[info exists tab($cfg(view,tab))]} { .nb select $tab($cfg(view,tab)) @@ -266,8 +311,6 @@ proc gui::start {} { bind all [namespace code [list configdlg misc]] } - makegrid - tk appname otmonitor wm protocol . WM_DELETE_WINDOW [namespace code finish] @@ -278,6 +321,31 @@ proc gui::finish {} { exit } +proc gui::ch2trace {var arg op} { + global gui + if {$arg in {ch2 roomtemp2 controlsp2 setpoint2 boilertemp2 dhwtemp2}} { + # Received some CH2 related info, so the trace is no longer needed + trace remove variable gui write [namespace code ch2trace] + if {$arg eq "ch2" && !$gui(ch2)} return + # Show the CH2 related information + chcircuit2 + } +} + +proc gui::chcircuit2 {{on 1}} { + global graph graphdef + if {$on} { + # Show the CH circuit 2 values + grid {*}[lsearch -all -inline [winfo children .] *-ch2] + set graph $graphdef + } else { + # Hide the CH circuit 2 values + grid remove {*}[lsearch -all -inline [winfo children .] *-ch2] + set graph [dict remove $graphdef chmode2 temperature2] + } + graphinit .nb.f2.c +} + proc gui::logframe {w} { ttk::frame $w.f1 -style TEntry -borderwidth 2 -takefocus 0 set x 0 @@ -301,7 +369,8 @@ proc gui::logframe {w} { } proc gui::graphframe {w} { - global graph + global graph graphdef + set graph [dict remove $graphdef chmode2 temperature2] ttk::frame $w.f2 -style TEntry -borderwidth 2 -takefocus 0 canvas $w.f2.c -background white -borderwidth 0 -highlightthickness 0 \ -yscrollcommand [list $w.f2.vs set] -xscrollcommand [list $w.f2.hs set] @@ -313,24 +382,54 @@ proc gui::graphframe {w} { grid $w.f2.hs x -sticky news grid columnconfigure $w.f2 $w.f2.c -weight 1 grid rowconfigure $w.f2 $w.f2.c -weight 1 + graphinit $w.f2.c + bind $w.f2.c <1> [namespace code [list information $w.f2.c %x %y]] + bind $w.f2.c <4> [list $w.f2.c yview scroll -1 unit] + bind $w.f2.c <5> [list $w.f2.c yview scroll 1 unit] + bind $w.f2.c \ + [format {%s yview scroll [expr {%%D/-abs(%%D)}] unit} $w.f2.c] + return $w.f2 +} + +proc gui::graphinit {c} { + global graph height span period + + $c delete graph dict for {name data} $graph { dict for {name dict} [dict get $data line] { set tags [list $name graph] set color [dict get $dict color] if {[dict get $data type] eq "polygon"} { - $w.f2.c create polygon 0 -1 1 -1 -tags $tags \ + $c create polygon 0 -1 1 -1 -tags $tags \ -fill $color -outline $color } else { - $w.f2.c create line 0 -1 0 -1 -tags $tags -fill $color + $c create line 0 -1 0 -1 -tags $tags -fill $color } } } - bind $w.f2.c <1> [namespace code [list information $w.f2.c %x %y]] - bind $w.f2.c <4> [list $w.f2.c yview scroll -1 unit] - bind $w.f2.c <5> [list $w.f2.c yview scroll 1 unit] - bind $w.f2.c \ - [format {%s yview scroll [expr {%%D/-abs(%%D)}] unit} $w.f2.c] - return $w.f2 + + # Make the grid + global graph height span period + $c delete grid + set y 0 + set x [expr {$span / $period}] + foreach n [dict keys $graph] { + incr y 8 + dict with graph $n { + set origin [expr {$y + $max * $zoom}] + for {set v $min} {$v <= $max} {incr v $scale} { + set i [expr {$origin - $v * $zoom}] + $c create line 0 $i $x $i -fill #eee -tags grid + $c create text -4 $i -text $v -anchor e -tags grid \ + -font Small -fill #000 + } + } + incr y [expr {round(($max - $min) * $zoom)}] + } + set height [incr y 16] + $c lower grid + + scroll } proc gui::statsframe {w} { @@ -478,29 +577,6 @@ proc gui::tvtrace {type msgid} { if {$resort} {tvsort $tv $cfg(view,sort)} } -proc gui::makegrid {} { - global graph height span period - .nb.f2.c delete grid - set y 0 - set x [expr {$span / $period}] - dict for {name data} $graph { - incr y 8 - dict with data { - set origin [expr {$y + $max * $zoom}] - for {set v $min} {$v <= $max} {incr v $scale} { - set i [expr {$origin - $v * $zoom}] - .nb.f2.c create line 0 $i $x $i -fill #eee -tags grid - .nb.f2.c create text -4 $i -text $v -anchor e -tags grid \ - -font Small -fill #000 - } - } - incr y [expr {round(($max - $min) * $zoom)}] - dict set graph $name origin $origin - } - set height [incr y 16] - .nb.f2.c lower grid -} - proc gui::scroll {} { global graph track period gui start height now zero span devtype timestamp set now $timestamp diff --git a/otmonitor.vfs/otmonitor.tcl b/otmonitor.vfs/otmonitor.tcl index f0780cc..a04bdfe 100644 --- a/otmonitor.vfs/otmonitor.tcl +++ b/otmonitor.vfs/otmonitor.tcl @@ -90,6 +90,7 @@ array set learn { set xlate { airpresfault "Air pressure fault" boilertemp "Boiler water temperature" + boilertemp2 "Boiler water temperature 2" ch2enable "Central heating 2 enable" ch2mode "Central heating 2 mode" chenable "Central heating enable" @@ -97,6 +98,7 @@ set xlate { chwsetpoint "Central heating setpoint" pressure "CH water pressure" controlsp "Control setpoint" + controlsp2 "Control setpoint 2" coolingenable "Cooling enable" coolingstatus "Cooling status" diag "Diagnostic indication" @@ -104,6 +106,7 @@ set xlate { dhwmode "Domestic hot water mode" dhwsetpoint "Domestic hot water setpoint" dhwtemp "Domestic hot water temp" + dhwtemp2 "Domestic hot water temp 2" fault "Fault indication" flame "Flame" flamefault "Gas/flame fault" @@ -117,25 +120,39 @@ set xlate { override "Rem override room setpoint" returntemp "Return water temperature" setpoint "Room setpoint" - temperature "Room temperature" + setpoint2 "Room setpoint 2" + roomtemp "Room temperature" + roomtemp2 "Room temperature 2" service "Service request" timestamp "Time stamp" overtemp "Water over-temperature" } # Graph definitions used by both gui and web -set graph { +set graphdef { dhwmode { origin 0 type polygon min 0 max 1 scale 2 zoom 12 format {%s} line { + dhwenable {color #ccf name "Domestic hot water enable"} dhwmode {color #00f name "Domestic hot water mode"} } + color #00f name "Domestic hot water" } chmode { origin 0 type polygon min 0 max 1 scale 2 zoom 12 format {%s} line { + chenable {color #cfc name "Central heating enable"} chmode {color #0c0 name "Central heating mode"} } + color #0c0 name "Central heating" + } + chmode2 { + origin 0 type polygon min 0 max 1 scale 2 zoom 12 format {%s} + line { + ch2enable {color #cf4 name "Central heating 2 enable"} + ch2mode {color #8c0 name "Central heating 2 mode"} + } + color #8c0 name "Central heating 2" } flame { origin 0 type polygon min 0 max 1 scale 2 zoom 12 format {%s} @@ -159,7 +176,19 @@ set graph { dhwtemp {color #f80 name "DHW temperature"} setpoint {color #0cc name "Room setpoint"} outside {color #0c0 name "Outside temperature"} - temperature {color #c0c name "Room temperature"} + roomtemp {color #c0c name "Room temperature"} + } + } + temperature2 { + origin 0 type line min -20 max 92 scale 5 zoom 4 format "%.2f\u00b0C" + line { + controlsp2 {color #ccc name "Control setpoint"} + returntemp2 {color #00f name "Return water temperature"} + boilertemp2 {color #f00 name "Boiler water temperature"} + dhwtemp2 {color #f80 name "DHW temperature"} + setpoint2 {color #0cc name "Room setpoint"} + outside2 {color #0c0 name "Outside temperature"} + roomtemp2 {color #c0c name "Room temperature"} } } } @@ -191,17 +220,26 @@ set signals { HotWater {on boolean} CentralHeating {on boolean} Fault {on boolean} + Diagnostic {on boolean} + Cooling {on boolean} + CentralHeating2 {on boolean} + Electricity {on boolean} RoomTemperature {temp float} + RoomTemperature2 {temp float} OutsideTemperature {temp float} Setpoint {temp float} + Setpoint2 {temp float} ControlSetpoint {temp float} + ControlSetpoint2 {temp float} DHWEnable {on boolean} DHWSetpoint {temp float} DHWTemperature {temp float} + DHWTemperature2 {temp float} CHEnable {on boolean} CHSetpoint {temp float} Modulation {level float} BoilerWaterTemperature {temp float} + BoilerWaterTemperature2 {temp float} ReturnWaterTemperature {temp float} CHWaterPresure {bar float} RemoteOverrideRoomSetpoint {temp float} @@ -763,9 +801,10 @@ proc slavestatus {list} { guiflag chmode [expr {([lindex $list 1] & 2) != 0}] centralheating guiflag dhwmode [expr {([lindex $list 1] & 4) != 0}] hotwater guiflag flame [expr {([lindex $list 1] & 8) != 0}] flame - guiflag coolingstatus [expr {([lindex $list 1] & 16) != 0}] - guiflag ch2mode [expr {([lindex $list 1] & 32) != 0}] - guiflag diag [expr {([lindex $list 1] & 64) != 0}] + guiflag coolingstatus [expr {([lindex $list 1] & 16) != 0}] cooling + guiflag ch2mode [expr {([lindex $list 1] & 32) != 0}] centralheating2 + guiflag diag [expr {([lindex $list 1] & 64) != 0}] diagnostic + guiflag electricity [expr {([lindex $list 1] & 128) != 0}] electricity return 0 } @@ -777,6 +816,25 @@ proc masterconfig {list} { return 0 } +proc slaveconfig {list} { + reportflags { + "DHW" {"not present" present} + "Control type" {modulating on/off} + "Cooling" {"not supported" supported} + "DHW" {instantaneous "storage tank"} + "Master pump control" {allowed "not allowed"} + "CH2" {"not present" present} + "Remote water filling" {available/unknown "not available"} + "Heat/cool mode control" {heat cool} + } { + } $list + lassign $list flags vendor + guiflag ch2 [expr {($flags & 32) != 0}] + ### For testing !!! + # guiflag ch2 [expr {($flags & 64) != 0}] + return 0 +} + proc mastersolar {list} { reportenum "Solar mode" { "Off" @@ -1654,7 +1712,7 @@ array set cfg { tspeak,interval 120 tspeak,sync false tspeak,key "" - tspeak,field1 temperature + tspeak,field1 roomtemp tspeak,field2 setpoint tspeak,field3 boilertemp tspeak,field4 returntemp @@ -1671,7 +1729,7 @@ set cfg(datalog,itemlist) { diag fault outside - temperature + roomtemp setpoint modulation boilertemp @@ -1779,17 +1837,7 @@ special 0 0 masterstatus special 4 0 slavestatus special 1 2 masterconfig special 5 2 masterconfig -special 4 3 reportflags { - "DHW" {"not present" present} - "Control type" {modulating on/off} - "Cooling" {"not supported" supported} - "DHW" {instantaneous "storage tank"} - "Master pump control" {allowed "not allowed"} - "CH2" {"not present" present} - "Remote water filling" {available/unknown "not available"} - "Heat/cool mode control" {heat cool} -} { -} +special 4 3 slaveconfig special 4 5 asfflags special 4 6 reportflags { "DHW setpoint transfer" {disabled enabled} @@ -1844,6 +1892,7 @@ special 4 103 reportflags { } special 1 1 guifloat controlsp controlsetpoint +special 1 8 guifloat controlsp2 controlsetpoint2 special 4 9 guifloat override remoteoverrideroomsetpoint special 1 56 guifloat dhwsetpoint dhwsetpoint special 4 56 guifloat dhwsetpoint dhwsetpoint @@ -1851,8 +1900,10 @@ special 1 57 guifloat chwsetpoint chsetpoint special 4 57 guifloat chwsetpoint chsetpoint special 4 17 guifloat modulation modulation special 1 14 guifloat maxmod -special 1 24 guifloat temperature roomtemperature +special 1 24 guifloat roomtemp roomtemperature +special 1 37 guifloat roomtemp2 roomtemperature2 special 1 16 guifloat setpoint setpoint +special 1 23 guifloat setpoint2 setpoint2 special 4 28 guifloat returntemp returnwatertemperature special 1 27 readwrite 1 guifloat outside outsidetemperature special 4 27 readwrite 4 guifloat outside outsidetemperature @@ -1860,7 +1911,9 @@ special 5 27 readwrite 5 guifloat outside outsidetemperature special 7 27 readwrite 7 guifloat outside outsidetemperature special 4 18 guifloat pressure chwaterpresure special 4 25 guifloat boilertemp boilerwatertemperature +special 4 31 guifloat boilertemp2 boilerwatertemperature2 special 4 26 guifloat dhwtemp dhwtemperature +special 4 32 guifloat dhwtemp2 dhwtemperature2 special 7 17 unknownid modulation special 7 28 unknownid returntemp special 7 18 unknownid pressure diff --git a/otmonitor.vfs/track.tcl b/otmonitor.vfs/track.tcl index fa80b7c..4567565 100644 --- a/otmonitor.vfs/track.tcl +++ b/otmonitor.vfs/track.tcl @@ -3,8 +3,8 @@ namespace eval track { } proc track::init {} { - global graph track - dict for {name data} $graph { + global graphdef track + dict for {name data} $graphdef { foreach n [dict keys [dict get $data line]] { set track($n) {} } diff --git a/otmonitor.vfs/web.tcl b/otmonitor.vfs/web.tcl index 6cd8994..6e2d140 100644 --- a/otmonitor.vfs/web.tcl +++ b/otmonitor.vfs/web.tcl @@ -441,19 +441,25 @@ namespace eval json { flame "Flame status" dhwmode "Domestic hot water mode" chmode "Central heating mode" + ch2mode "Central heating mode 2" dhwenable "Domestic hot water enable" diag "Diagnostic indication" fault "Fault indication" outside "Outside temperature" - temperature "Room temperature" + roomtemp "Room temperature" + roomtemp2 "Room temperature 2" setpoint "Room setpoint" + setpoint2 "Room setpoint 2" modulation "Relative modulation level" boilertemp "Boiler water temperature" + boilertemp2 "Boiler water temperature 2" returntemp "Return water temperature" controlsp "Control setpoint" + controlsp2 "Control setpoint 2" dhwsetpoint "DHW setpoint" chwsetpoint "Max CH water setpoint" dhwtemp "DHW temperature" + dhwtemp2 "DHW temperature 2" maxmod "Max relative modulation level" pressure "CH water pressure" }