comparison web/log.py @ 227:efb5cad2e98b

Only print interesting legend labels
author Matt Johnston <matt@ucc.asn.au>
date Sat, 28 Feb 2015 00:14:21 +0800
parents 59379b2bd056
children 0a1b642e3086
comparison
equal deleted inserted replaced
226:da769023bf08 227:efb5cad2e98b
113 except ValueError: 113 except ValueError:
114 pass 114 pass
115 width = config.LINE_WIDTH 115 width = config.LINE_WIDTH
116 legend = config.SENSOR_NAMES.get(sensor, sensor) 116 legend = config.SENSOR_NAMES.get(sensor, sensor)
117 colour = config.SENSOR_COLOURS.get(legend, colour_from_string(sensor)) 117 colour = config.SENSOR_COLOURS.get(legend, colour_from_string(sensor))
118 if format_last_value: 118 print_legend = ''
119 print_legend = '%s (%s)' % (legend, format_last_value) 119 if legend in config.LEGEND_NAMES:
120 else: 120 if format_last_value:
121 print_legend = legend 121 print_legend = ':%s (%s)' % (legend, format_last_value)
122 sensor_lines.append( (legend, 'LINE%(width)f:%(vname)s#%(colour)s:%(print_legend)s' % locals()) ) 122 else:
123 print_legend = ":%s" % legend
124 sensor_lines.append( (legend, 'LINE%(width)f:%(vname)s#%(colour)s%(print_legend)s' % locals()) )
123 if legend == 'Wort': 125 if legend == 'Wort':
124 wort_sensor = vname 126 wort_sensor = vname
125 elif legend == 'Fridge': 127 elif legend == 'Fridge':
126 fridge_sensor = vname 128 fridge_sensor = vname
127 129
128 # calculated bits 130 # calculated bits
129 colour = '000000' 131 colour = '000000'
130 print_legend = 'Heat'
131 graph_args.append('CDEF:wortdel=%(wort_sensor)s,PREV(%(wort_sensor)s),-' % locals()) 132 graph_args.append('CDEF:wortdel=%(wort_sensor)s,PREV(%(wort_sensor)s),-' % locals())
132 graph_args.append('CDEF:tempdel=%(wort_sensor)s,%(fridge_sensor)s,-' % locals()) 133 graph_args.append('CDEF:tempdel=%(wort_sensor)s,%(fridge_sensor)s,-' % locals())
133 graph_args.append('CDEF:fermheat=wortdel,80,*,tempdel,0.9,*,+' % locals()) 134 graph_args.append('CDEF:fermheat=wortdel,80,*,tempdel,0.9,*,+' % locals())
134 graph_args.append('CDEF:trendfermheat=fermheat,7200,TRENDNAN' % locals()) 135 graph_args.append('CDEF:trendfermheat=fermheat,7200,TRENDNAN' % locals())
135 graph_args.append('CDEF:limitfermheat=trendfermheat,5,+,11,MIN,2,MAX' % locals()) 136 graph_args.append('CDEF:limitfermheat=trendfermheat,5,+,11,MIN,2,MAX' % locals())
136 graph_args.append('LINE0.5:limitfermheat#%(colour)s:%(print_legend)s' % locals()) 137 graph_args.append('LINE0.5:limitfermheat#%(colour)s' % locals())
137 138
138 # lines are done afterwards so they can be layered 139 # lines are done afterwards so they can be layered
139 sensor_lines.sort(key = lambda (legend, line): "Wort" in legend) 140 sensor_lines.sort(key = lambda (legend, line): "Wort" in legend)
140 graph_args += (line for (legend, line) in sensor_lines) 141 graph_args += (line for (legend, line) in sensor_lines)
141 142