initial checkin of FanContol2
[enigma2-plugins.git] / fancontrol2 / src / FC2webSite.py
1 # -*- coding: utf-8 -*-
2 from twisted.web import resource, http
3 from plugin import *
4 from Sensors import sensors
5 from __init__ import _
6 from Components.config import configfile, config
7
8 import os
9 import datetime
10
11 HeadLine = "Time;Temp;RPM;VLT;PWM;HDD;Status;Temp1;Temp2;Temp3;Temp4;Temp5;Temp6;Temp7;Temp8\r\n"
12
13 ########################################################
14 class FC2web(resource.Resource):
15     
16         title = "FanControl2 Webinterface"
17         isLeaf = False
18    
19         def render(self, req):
20                 req.setHeader('Content-type', 'text/html')
21                 req.setHeader('charset', 'UTF-8')
22
23                 """ rendering server response """
24                 command = req.args.get("cmd",None)
25
26                 html = "<html>"
27                 html += "<head>\n"
28                 html += "<meta http-equiv=\"Content-Language\" content=\"de\">\n"
29                 html += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\">\n"
30                 html += "<meta http-equiv=\"cache-control\" content=\"no-cache\" />\n"
31                 html += "<meta http-equiv=\"pragma\" content=\"no-cache\" />\n"
32                 html += "<meta http-equiv=\"expires\" content=\"0\">\n"
33                 html += "<meta http-equiv=\"refresh\" content=\"20\">\n"
34                 html += "<title>Fan Control 2 - Info</title>\n"
35                 html += "</head>"
36                 html += "<body bgcolor=\"#666666\" text=\"#FFFFFF\">\n"
37                 html += "<form method=\"POST\" action=\"--WEBBOT-SELF--\">\n"
38                 html += "<table border=\"1\" width=\"500\" bordercolorlight=\"#000000\" bordercolordark=\"#000000\" cellspacing=\"1\"><tr><td bgcolor=\"#000000\" width=\"200\">\n"
39                 html += "<p align=\"center\"><img border=\"0\" src=\"/web-data/fc2/FC2dreambox.png\" width=\"181\" height=\"10\">\n"
40                 html += "<font color=\"#FFFFFF\"><BR><b>Fan Control 2 - Info</b></font></p>\n"
41                 html += "</td><td bgcolor=\"#000000\">\n"
42                 html += "<p align=\"right\">"
43                 html += BoxStatus()
44                 if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2data.csv"):
45                         html += "<a href=\"/fancontrol/chart\"><img border=\"0\" src=\"/web-data/fc2/FC2Chart.png\" width=\"100\" height=\"40\"></a>\n"
46                 html += "<a href=\"/fancontrol/log\"><img border=\"0\" src=\"/web-data/fc2/FC2Setup.png\" width=\"100\" height=\"40\"></a></td></tr></table>\n"
47                 html += "<table border=\"1\" width=\"500\" id=\"table1\">\n"
48                 html += "<tr>\n"
49                 html += "<td>%s: <b><font color=\"#FFCC00\">%4.1f C</font></b></td>\n" % (_("Temperature"),FC2werte[0])
50                 html += "<td>%s: <font color=\"#FFCC00\"><b>%4d rpm</b></font></td>\n" % (_("Speed"),FC2werte[1])
51                 html += "<td>%s: <font color=\"#FFCC00\"><b>%03d</b></font></td>\n" % (_("Voltage"),FC2werte[2])
52                 html += "<td>PWM: <font color=\"#FFCC00\"><b>%03d</b></font></td>\n" % FC2werte[3]
53                 html += "</tr>\n"
54                 html += "</table>\n"
55
56                 html += "<table border=\"1\" width=\"500\">\n"
57                 html += "<tr>\n"
58                 html += "<td>%s C</td>\n" % _("Sensors")
59                 templist = sensors.getSensorsList(sensors.TYPE_TEMPERATURE)
60                 tempcount = len(templist)
61                 for count in range(tempcount):
62                         html += "<td><font color=\"#FFCC00\">%d</font></td>" % sensors.getSensorValue(count)
63                 if FC2werte[4] > 0:
64                         html += "<td><font size=\"1\">HDD </font><font color=\"#FFCC00\">%d</font></td>\n" % FC2werte[4]
65                 html += "</tr>\n"
66                 html += "</table>\n"
67
68                 html += "<table border=\"1\" width=\"500\">\n"
69                 html += "<tr>\n"
70                 for count in range(0,12):
71                         tmp = ("<BR>-" if FC2stunde[count] == "-" else FC2stunde[count])
72                         html +="<td><p align=\"center\"><font size=\"1\">%02d:00<br><font color=\"#FFCC00\">%s</font></font></td>\n" % (count,tmp)
73                 html += "</tr><tr>\n"
74                 for count in range(12,24):
75                         tmp = ("<BR>-" if FC2stunde[count] == "-" else FC2stunde[count])
76                         html +="<td><p align=\"center\"><font size=\"1\">%02d:00<br><font color=\"#FFCC00\">%s</font></font></td>\n" % (count,tmp)
77                 html += "</tr></table>\n"
78
79                 html += "<script type=\"text/javascript\">\n"
80                 html += "function doLogWrite() {\n"
81                 html += "var iFrameWin = window.myIFrameName;\n"
82                 html += "iFrameWin.document.write('<html><head><title>FC2 Log Window</title></head><body bgcolor=\"#D3D3D3\">');\n"
83                 html += "iFrameWin.document.write('<font size=\"-1\">');\n"
84                 for L in FC2Log:
85                         html += "iFrameWin.document.write('" + L + "<br>');\n"
86                 html += "iFrameWin.document.write('</font>');\n"
87                 html += "iFrameWin.document.write('</body></html>');\n"
88                 html += "iFrameWin.document.close();\n"
89                 html += "}\n"
90                 html += "</script>\n"
91                 html += "<iframe id=\"myIFrameId\" name=\"myIFrameName\" width=\"500\" height=\"320\" marginwidth=\"5\" vspace=\"2\" marginheight=\"5\" frameborder=\"1\" scrolling=\"auto\"></iframe>\n"
92                 html += "<script>doLogWrite();\n"
93                 html += "myIFrameName.document.body.scrollTop = myIFrameName.document.body.scrollHeight*100;\n" 
94                 html += "</script>\n"
95
96                 html += "</form>\n"
97                 html += "Version: %s\n" % Version
98                 html += "</body>\n"
99                 html += "</html>\n"
100
101                 return html
102
103 ##########################################################
104 class FC2webLog(resource.Resource):
105     
106         title = "FanControl2 Webinterface"
107         isLeaf = True
108
109         def render(self, req):
110                 command = req.args.get("cmd",None)
111                 html = ""
112                 if command is None:
113                         req.setHeader('Content-type', 'text/html')
114                         req.setHeader('charset', 'UTF-8')
115
116                         """ rendering server response """
117
118                         html = "<html>"
119                         html += "<head>"
120                         html += "<meta http-equiv=\"Content-Language\" content=\"de\">"
121                         html += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\">"
122                         html += "<meta http-equiv=\"cache-control\" content=\"no-cache\" />"
123                         html += "<meta http-equiv=\"pragma\" content=\"no-cache\" />"
124                         html += "<meta http-equiv=\"expires\" content=\"0\">"
125                         html += "<meta http-equiv=\"refresh\" content=\"30\">"
126                         html += "<title>Fan Control 2 - Logging</title>"
127                         html += "</head>"
128                         html += "<body bgcolor=\"#666666\" text=\"#FFFFFF\">\n"
129                         html += "<table border=\"1\" width=\"500\" bordercolorlight=\"#000000\" bordercolordark=\"#000000\" cellspacing=\"1\"><tr><td bgcolor=\"#000000\" width=\"200\">\n"
130                         html += "<p align=\"center\"><img border=\"0\" src=\"/web-data/fc2/FC2dreambox.png\" width=\"181\" height=\"10\">\n"
131                         html += "<font color=\"#FFFFFF\"><BR><b>Fan Control 2 - Logging</b></font></p>\n"
132                         html += "</td><td bgcolor=\"#000000\">\n"
133                         html += "<p align=\"right\">"
134                         html += BoxStatus()
135                         if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2data.csv"):
136                                 html += "<a href=\"/fancontrol/chart\"><img border=\"0\" src=\"/web-data/fc2/FC2Chart.png\" width=\"100\" height=\"40\"></a>\n"
137                         html += "<a href=\"/fancontrol\"><img border=\"0\" src=\"/web-data/fc2/FC2Info.png\" width=\"100\" height=\"40\"></a></td></tr></table>\n"
138
139                         html += "<table border=\"1\" width=\"500\">"
140                         html += "<tr><td width=\"50%\" align=\"center\" valign=\"top\">Data Logging "
141                         if config.plugins.FanControl.EnableDataLog.value:
142                                 html += "<font color=\"#00FF00\">%s</font>" % _("active")
143                                 html += "<form method=\"GET\">"
144                                 html += "<input type=\"hidden\" name=\"cmd\" value=\"dataenable\">"
145                                 html += "<input type=\"submit\" value=\"%s\">" % _("turn off")
146                                 html += "</form>"
147                         else:
148                                 html += "<font color=\"#FF0000\">%s</font>" % _("not active")
149                                 html += "<form method=\"GET\">"
150                                 html += "<input type=\"hidden\" name=\"cmd\" value=\"dataenable\">"
151                                 html += "<input type=\"submit\" value=\"%s\">" % _("turn on")
152                                 html += "</form>"
153                         if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2data.csv"):
154                                 s = os.stat(config.plugins.FanControl.LogPath.value + "FC2data.csv")
155                                 if int(s.st_size/1024) == 0:
156                                         html += "<BR>" + _("Filesize : %d %sByte") % (int(s.st_size), "")
157                                 else:
158                                         html += "<BR>" + _("Filesize : %d %sByte") % (int(s.st_size/1024), "k")
159                                 s = os.statvfs(config.plugins.FanControl.LogPath.value)
160                                 html += "<BR>" + _("Disk free : %d MByte") % (int(s.f_bsize * s.f_bavail / 1024 / 1024))
161                                 html += "<form method=\"GET\">"
162                                 html += "<input type=\"hidden\" name=\"cmd\" value=\"data\">"
163                                 html += "<input type=\"submit\" value=\"%s\">" % _("Download")
164                                 html += "</form>"
165                                 html += "<form method=\"GET\">"
166                                 html += "<input type=\"hidden\" name=\"cmd\" value=\"datadel\">"
167                                 html += "<input type=\"submit\" value=\"%s\">" % _("Delete")
168                                 html += "</form>"
169                                 html += "<form method=\"GET\">"
170                                 html += "<input type=\"hidden\" name=\"cmd\" value=\"datadel48h\">"
171                                 html += "<input type=\"submit\" value=\"%s\">" % _("Delete older 48h")
172                                 html += "</form>"
173                         else:
174                                 html += "<BR>" + _("File %s does not exists") % "FC2data.csv"
175
176                         html += "</td><td width=\"50%\" align=\"center\" valign=\"top\">Event Logging "
177                         if config.plugins.FanControl.EnableEventLog.value:
178                                 html += "<font color=\"#00FF00\">%s</font>" % _("active")
179                                 html += "<form method=\"GET\">"
180                                 html += "<input type=\"hidden\" name=\"cmd\" value=\"eventsenable\">"
181                                 html += "<input type=\"submit\" value=\"%s\">" % _("turn off")
182                                 html += "</form>"
183                         else:
184                                 html += "<font color=\"#FF0000\">%s</font>" % _("not active")
185                                 html += "<form method=\"GET\">"
186                                 html += "<input type=\"hidden\" name=\"cmd\" value=\"eventsenable\">"
187                                 html += "<input type=\"submit\" value=\"%s\">" % _("turn on")
188                                 html += "</form>"
189                         if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2events.txt"):
190                                 s = os.stat(config.plugins.FanControl.LogPath.value + "FC2events.txt")
191                                 if int(s.st_size/1024) == 0:
192                                         html += "<BR>" + _("Filesize : %d %sByte") % (int(s.st_size), "")
193                                 else:
194                                         html += "<BR>" + _("Filesize : %d %sByte") % (int(s.st_size/1024), "k")
195                                 s = os.statvfs(config.plugins.FanControl.LogPath.value)
196                                 html += "<BR>" + _("Disk free : %d MByte") % (int(s.f_bsize * s.f_bavail / 1024 / 1024))
197                                 html += "<form method=\"GET\">"
198                                 html += "<input type=\"hidden\" name=\"cmd\" value=\"events\">"
199                                 html += "<input type=\"submit\" value=\"%s\">" % _("Download")
200                                 html += "</form>"
201                                 html += "<form method=\"GET\">"
202                                 html += "<input type=\"hidden\" name=\"cmd\" value=\"eventsdel\">"
203                                 html += "<input type=\"submit\" value=\"%s\">" % _("Delete")
204                                 html += "</form>"
205 #                               html += "<form method=\"GET\">"
206 #                               html += "<input type=\"hidden\" name=\"cmd\" value=\"eventsdel48h\">"
207 #                               html += "<input type=\"submit\" value=\"%s\">" % _("Delete older 48h")
208 #                               html += "</form>"
209
210                         else:
211                                 html += "<BR>" + _("File %s does not exists") % "FC2events.txt"
212                         html += "</td></tr></table>"
213                         html += _("Logging-Path: %s") % config.plugins.FanControl.LogPath.value
214                         html += "</html>"
215
216                 elif command[0] ==  "data":
217                         req.setResponseCode(http.OK)
218 #                       req.setHeader('Content-type', 'application/octet-stream')
219                         req.setHeader('Content-type', 'application/vnd.ms-excel')
220                         req.setHeader('Content-Disposition', 'attachment;filename=FC2data.csv')
221                         req.setHeader('Content-Length', os.stat(config.plugins.FanControl.LogPath.value + "FC2data.csv").st_size)
222 #                       req.setHeader('Content-Disposition', 'inline;filename=FC2data.csv')
223                         req.setHeader('charset', 'UTF-8')
224                         f = open(config.plugins.FanControl.LogPath.value + "FC2data.csv","r")
225                         html = f.read()
226                         f.close()
227                 elif command[0] ==  "datadel":
228                         if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2data.csv"):
229                                 os.remove(config.plugins.FanControl.LogPath.value + "FC2data.csv")
230                         CreateDataHead()
231                         html = LogRefresh()
232                 elif command[0] ==  "datadel48h":
233                         if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2data.csv") and os.stat(config.plugins.FanControl.LogPath.value + "FC2data.csv").st_size > 10000:
234                                 f = open(config.plugins.FanControl.LogPath.value + "FC2data.csv","a")
235                                 s = f.tell()
236                                 f.close()
237                                 f = open(config.plugins.FanControl.LogPath.value + "FC2data.csv","r")
238                                 f.seek(s-100)
239                                 line = f.readline()
240                                 line = f.readline()
241                                 DT = line.split(";")
242                                 DT = DT[0].split(" ")
243                                 DD = DT[0].split(".")
244                                 DD48h = datetime.date(int(DD[0]),int(DD[1]),int(DD[2])) - datetime.timedelta(2)
245                                 Dfind = "%04d.%02d.%02d %s" % (DD48h.year,DD48h.month,DD48h.day,DT[1])
246                                 f.seek(0)
247                                 line = f.readline()
248                                 fw = open(config.plugins.FanControl.LogPath.value + "FC2data.csv.tmp","w")
249                                 fw.write(HeadLine)
250                                 for line in f.readlines():
251                                         DT = line.split(";")
252                                         if DT[0] > Dfind:
253                                                 fw.write(line)
254                                 f.close()
255                                 fw.close()
256                                 if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2data.csv"):
257                                         os.remove(config.plugins.FanControl.LogPath.value + "FC2data.csv")
258                                 if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2data.csv.tmp"):
259                                         os.rename(config.plugins.FanControl.LogPath.value + "FC2data.csv.tmp",config.plugins.FanControl.LogPath.value + "FC2data.csv")
260                         html = LogRefresh()
261                 elif command[0] ==  "dataenable":
262                         config.plugins.FanControl.EnableDataLog.value = not config.plugins.FanControl.EnableDataLog.value
263                         CreateDataHead()
264                         config.plugins.FanControl.EnableDataLog.save()
265                         html = LogRefresh()
266
267                 elif command[0] ==  "events":
268                         req.setResponseCode(http.OK)
269                         req.setHeader('Content-type', 'application/octet-stream')
270                         req.setHeader('Content-Disposition', 'attachment;filename=FC2events.txt')
271                         req.setHeader('Content-Length', os.stat(config.plugins.FanControl.LogPath.value + "FC2events.txt").st_size)
272 #                       req.setHeader('Content-Disposition', 'inline;filename=FC2events.txt')
273                         req.setHeader('charset', 'UTF-8')
274                         f = open(config.plugins.FanControl.LogPath.value + "FC2events.txt","r")
275                         html = f.read()
276                         f.close()
277                 elif command[0] ==  "eventsdel":
278                         if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2events.txt"):
279                                 os.remove(config.plugins.FanControl.LogPath.value + "FC2events.txt")
280                         html = LogRefresh()
281                 elif command[0] ==  "eventsdel48h":
282                         if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2events.txt"):
283                                 f = open(config.plugins.FanControl.LogPath.value + "FC2events.txt","a")
284                                 s = f.tell()
285                                 f.close()
286                                 f = open(config.plugins.FanControl.LogPath.value + "FC2events.txt","r")
287                                 f.seek(s-100)
288                                 line = f.readline()
289                                 line = f.readline()
290                                 DT = line.split(";")
291                                 DT = DT[0].split(" ")
292                                 DD = DT[0].split(".")
293                                 DD48h = datetime.date(int(DD[0]),int(DD[1]),int(DD[2])) - datetime.timedelta(2)
294                                 Dfind = "%04d.%02d.%02d %s" % (DD48h.year,DD48h.month,DD48h.day,DT[1])
295                                 f.seek(0)
296                                 line = f.readline()
297                                 fw = open(config.plugins.FanControl.LogPath.value + "FC2events.txt.tmp","w")
298                                 fw.write(HeadLine)
299                                 for line in f.readlines():
300                                         DT = line.split(";")
301                                         if DT[0] > Dfind:
302                                                 fw.write(line)
303                                 f.close()
304                                 fw.close()
305                                 if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2events.txt"):
306                                         os.remove(config.plugins.FanControl.LogPath.value + "FC2events.txt")
307                                 if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2events.txt.tmp"):
308                                         os.rename(config.plugins.FanControl.LogPath.value + "FC2events.txt.tmp",config.plugins.FanControl.LogPath.value + "FC2events.txt")
309                         html = LogRefresh()
310                 elif command[0] ==  "eventsenable":
311                         config.plugins.FanControl.EnableEventLog.value = not config.plugins.FanControl.EnableEventLog.value
312                         config.plugins.FanControl.EnableEventLog.save()
313                         html = LogRefresh()
314
315                 return html
316
317 def LogRefresh():
318         h = "<html>"
319         h += "<head>"
320         h += "<meta http-equiv=\"refresh\" content=\"1; url=/fancontrol/log\">"
321         h += "<a href=\"/fancontrol/log\">Execution completed... jump back...</a>"
322         h += "</html>"
323         h += "</head>"
324         return h
325
326 def CreateDataHead():
327         if not os.path.exists(config.plugins.FanControl.LogPath.value + "FC2data.csv") and config.plugins.FanControl.EnableDataLog.value and Free(config.plugins.FanControl.LogPath.value):
328                 try:
329                         f = open(config.plugins.FanControl.LogPath.value + "FC2data.csv","w")
330                         try:
331                                 f.write(HeadLine)
332                         except:
333                                 f.close()
334                 except IOError:
335                         pass
336
337 ##########################################################
338 class FC2webChart(resource.Resource):
339     
340         title = "FanControl2 Webinterface"
341         isLeaf = True
342     
343         def render(self, req):
344                 command = req.args.get("cmd",None)
345                 html = ""
346                 if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2data.csv"):
347                         req.setHeader('Content-type', 'text/html')
348                         req.setHeader('charset', 'UTF-8')
349
350                         """ rendering server response """
351
352                         f = open(config.plugins.FanControl.LogPath.value + "FC2data.csv","a")
353                         s = f.tell()
354                         f.close()
355                         if s < 150:
356                                 html = "<html><body><html>Not enough Data!</body></html>"
357                                 return html
358                         f = open(config.plugins.FanControl.LogPath.value + "FC2data.csv","r")
359                         f.seek(s-100)
360                         line = f.readline()
361                         line = f.readline()
362                         DT = line.split(";")
363                         DT = DT[0].split(" ")
364                         DD = DT[0].split(".")
365                         DD48h = datetime.date(int(DD[0]),int(DD[1]),int(DD[2])) - datetime.timedelta(2)
366                         Dfind = "%04d.%02d.%02d %s" % (DD48h.year,DD48h.month,DD48h.day,DT[1])
367                         f.seek(0)
368                         line = f.readline()
369                         Anzahl = 0
370                         for line in f.readlines():
371                                 DT = line.split(";")
372                                 if DT[0] > Dfind:
373                                         Anzahl += 1
374 #                       Anzahl -= 1
375                         html = "<html>"
376                         html += "<head>"
377                         html += "<meta http-equiv=\"Content-Language\" content=\"de\">"
378                         html += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\">"
379                         html += "<meta http-equiv=\"cache-control\" content=\"no-cache\" />"
380                         html += "<meta http-equiv=\"pragma\" content=\"no-cache\" />"
381                         html += "<meta http-equiv=\"expires\" content=\"0\">"
382                         html += "<title>Fan Control 2 - Chart</title>"
383                         html += "</head>"
384                         html += "<body bgcolor=\"#666666\" text=\"#FFFFFF\">\n"
385                         html += "<table border=\"1\" width=\"900\" bordercolorlight=\"#000000\" bordercolordark=\"#000000\"  cellspacing=\"1\"><tr><td bgcolor=\"#000000\" width=\"200\">\n"
386                         html += "<p align=\"center\"><img border=\"0\" src=\"/web-data/fc2/FC2dreambox.png\" width=\"181\" height=\"10\">\n"
387                         html += "<font color=\"#FFFFFF\"><BR><b>Fan Control 2 - Chart</b></font></p>\n"
388                         html += "</td><td bgcolor=\"#000000\">\n"
389                         html += "<p align=\"right\">"
390                         html += BoxStatus()
391                         if os.path.exists(config.plugins.FanControl.LogPath.value + "FC2data.csv"):
392                                 html += "<a href=\"/fancontrol\"><img border=\"0\" src=\"/web-data/fc2/FC2Info.png\" width=\"100\" height=\"40\"></a>\n"
393                         html += "<a href=\"/fancontrol/log\"><img border=\"0\" src=\"/web-data/fc2/FC2Setup.png\" width=\"100\" height=\"40\"></a></td></tr></table>\n"
394
395                         html += "<applet code=\"diagram.class\" codebase=\"/web-data/fc2/\" name=\"DiaTemp\" "
396                         html += "align=\"baseline\" width=\"900\" height=\"250\" mayscript>\n"
397                         html += "<param name=\"title\" value=\"Temp  (48h - %s)\">\n" % DT[0]
398                         html += "<param name=\"bgcolor\" value=\"240; 240; 240\">\n"
399                         html += "<param name=\"ytitle\" value=\"Temp\">\n"
400                         html += "<param name=\"rolling\" value=\"%d\">\n" % Anzahl
401                         html += "<param name=\"show_xscale\" value=\"atText\">\n"
402                         html += "<param name=\"show_ygrid\" value=\"true\">\n"
403                         html += "<param name=\"show_xgrid\" value=\"true\">\n"
404
405                         html += "<param name=\"y0\" value=\"\">\n"
406                         html += "<param name=\"color0\" value=\"240; 0; 0\">\n"
407                         html += "<param name=\"style0\" value=\"LINE\">\n"
408                         html += "<param name=\"ylabel0\" value=\"Temp\">\n"
409
410                         html += "<param name=\"y1\" value=\"\">\n"
411                         html += "<param name=\"color1\" value=\"240; 0; 240\">\n"
412                         html += "<param name=\"style1\" value=\"LINE\">\n"
413                         html += "<param name=\"ylabel1\" value=\"HDD\">\n"
414
415                         html += "<param name=\"y2\" value=\"\">\n"
416                         html += "<param name=\"color2\" value=\"0; 255; 0\">\n"
417                         html += "<param name=\"style2\" value=\"LINE\">\n"
418                         html += "<param name=\"ylabel2\" value=\"BoxOn\">\n"
419
420                         html += "<param name=\"y3\" value=\"\">\n"
421                         html += "<param name=\"color3\" value=\"72; 118; 255\">\n"
422                         html += "<param name=\"style3\" value=\"LINE\">\n"
423                         html += "<param name=\"ylabel3\" value=\"HDDon\">\n"
424
425                         html += "<param name=\"y4\" value=\"\">\n"
426                         html += "<param name=\"color4\" value=\"255; 165; 0\">\n"
427                         html += "<param name=\"style4\" value=\"LINE\">\n"
428                         html += "<param name=\"ylabel4\" value=\"Record\">\n"
429
430                         html += "</applet>\n"
431
432 #                       html += "<div style=\"position: absolute; width: 100px; height: 100px; z-index: 1; left: 910px; top: 146px\" id=\"Ebene1\">\n"
433 #                       html += "<img border=\"0\" src=\"/web-data/fc2/FC2Status.png\" width=\"115\" height=\"168\"></div>\n"
434
435                         html += "<applet code=\"diagram.class\" codebase=\"/web-data/fc2/\" name=\"DiaRPM\" "
436                         html += "align=\"baseline\" width=\"900\" height=\"250\" mayscript>\n"
437                         html += "<param name=\"title\" value=\"RPM  (48h - %s)\">\n" % DT[0]
438                         html += "<param name=\"bgcolor\" value=\"240; 240; 240\">\n"
439                         html += "<param name=\"ytitle\" value=\"RPM\">\n"
440                         html += "<param name=\"rolling\" value=\"%d\">\n" % Anzahl
441                         html += "<param name=\"show_xscale\" value=\"atText\">\n"
442                         html += "<param name=\"show_ygrid\" value=\"true\">\n"
443                         html += "<param name=\"show_xgrid\" value=\"true\">\n"
444
445                         html += "<param name=\"y0\" value=\"\">\n"
446                         html += "<param name=\"color0\" value=\"240; 0; 0\">\n"
447                         html += "<param name=\"style0\" value=\"LINE\">\n"
448                         html += "<param name=\"ylabel0\" value=\"RPM\">\n"
449
450                         html += "</applet>\n"
451
452                         f.seek(0)
453                         line = f.readline()
454                         html += "<script language=javascript>\n"
455                         html += "dT = document.DiaTemp\n"
456                         html += "dR = document.DiaRPM\n"
457                         t = 0
458                         Xtime = int((Anzahl/20))
459                         if Anzahl < 1000:
460                                 Xtime += 1
461                         for line in f.readlines():
462                                 DT = line.split(";")
463                                 if DT[0] > Dfind:
464                                         if Xtime > 0:
465                                                 tmp = ("\"" + DT[0].split(" ")[1] + "\"") if t % Xtime == 0 else "null"
466                                         else:
467                                                 tmp = "null"
468                                         t += 1
469                                         if len(DT[6])>1:
470                                                 DT[6]="0"
471                                         B = 0
472                                         H = 0
473                                         R = 0
474                                         S = int(DT[6])
475                                         if (S & 1)>0 :
476                                                 B = 4
477                                         if (S & 2)>0 :
478                                                 H = 8
479                                         if (S & 4)>0 :
480                                                 R = 12
481                                         html += "dT.AddPoint(\"%s; %s; %d; %d; %d\", %s, null);\n" % (DT[1].replace(",","."),DT[5],B,H,R,tmp)
482                                         html += "dR.AddPoint(\"%s\", %s, null);\n" % (DT[2],tmp)
483                         f.close()
484                         html += "dT.repaint();\ndR.repaint();\n"
485                         html += "</script>"
486                 else:
487                         html = "<html>no Data!"
488                 html += "</body>"
489                 html += "</html>"
490
491                 return html
492
493 def BoxStatus():
494         h = ""
495         S = int(FC2werte[5])
496         if (S & 1)>0 :
497                 h += "<img border=\"0\" src=\"/web-data/fc2/FC2on.png\" width=\"20\" height=\"20\" title=\"Box On\" align=\"left\" hspace=\"2\" vspace=\"5\">\n"
498         if (S & 2)>0 :
499                 h += "<img border=\"0\" src=\"/web-data/fc2/FC2hdd.png\" width=\"20\" height=\"20\" title=\"HDD On\" align=\"left\" hspace=\"2\" vspace=\"5\">\n"
500         if (S & 4)>0 :
501                 h += "<img border=\"0\" src=\"/web-data/fc2/FC2record.png\" width=\"20\" height=\"20\" title=\"Recording\" align=\"left\" hspace=\"2\" vspace=\"5\">\n"
502         return h