[svn r16] added swf panel, generated flags to check trunk svn.16

Mon, 15 Feb 2010 11:24:36 +0100

author
mbayer
date
Mon, 15 Feb 2010 11:24:36 +0100
branch
trunk
changeset 14
bd1361d7e7fe
parent 13
51e97053dca5
child 15
307011f15e5c

[svn r16] added swf panel, generated flags to check

README file | annotate | diff | comparison | revisions
http/img/panel.swf file | annotate | diff | comparison | revisions
http/status.tmpl file | annotate | diff | comparison | revisions
sources/panel/netpro_status.psd file | annotate | diff | comparison | revisions
sources/panel/panel.fla file | annotate | diff | comparison | revisions
structures.py file | annotate | diff | comparison | revisions
tools.py file | annotate | diff | comparison | revisions
victrond.py file | annotate | diff | comparison | revisions
--- a/README	Fri Feb 12 16:21:48 2010 +0100
+++ b/README	Mon Feb 15 11:24:36 2010 +0100
@@ -5,7 +5,7 @@
 TODO:
     create a full xmlrpc interface (should i do???)
     
-    add a graphical UPS Status panel
+    add a graphical UPS Status panel (swf)
     bugfix admin authentication!
     modify selftest to be checked in main loop (do not wait for completion after init test)
     
Binary file http/img/panel.swf has changed
--- a/http/status.tmpl	Fri Feb 12 16:21:48 2010 +0100
+++ b/http/status.tmpl	Mon Feb 15 11:24:36 2010 +0100
@@ -1,16 +1,12 @@
+
 	<div class="infobox fl">
 		<table>
 		    <tr>
 			<th  width="50%">General Device Information</th>
 		    </tr>
 		    <tr>
-			<td>Hardware</td>	<td>[manufacturer] [model] / v[version]</td>
-		    </tr>
-		    <tr>
-			<td>Serial</td>		<td>[serial]</td>
-		    </tr>
-		    <tr>
-			<td>Release</td>	<td>[release]</td>
+			<td>[manufacturer] [model] / v[version] <br /> [serial] <br /> [release]</td>
+			<td> [UPS_Paneldisplay] </td>
 		    </tr>
 		    <tr>
 			<td>Maximum Power</td>	<td>ca. [max_power] W</td>
@@ -55,9 +51,6 @@
 		    <tr>
 			<td>Bypass enabled</td>		<td>[SByPass_en]</td>
 		    </tr>
-		    <tr>
-			<td>Input Transfer Voltage</td>		<td>[SIVLow] - [SIVHigh] V</td>
-		    </tr>
 		</table>
 
 		<table>
@@ -115,6 +108,9 @@
 			<th  width="50%">Line Input Information</th>
 		    </tr>
 		    <tr>
+			<td>Input Transfer Voltage</td>		<td>[TIVLow]-[TIVHigh] V</td>
+		    </tr>
+		    <tr>
 			<td>Input good range</td>	<td>[IVmin]-[IVmax] V</td>
 		    </tr>
 		    <tr>
Binary file sources/panel/netpro_status.psd has changed
Binary file sources/panel/panel.fla has changed
--- a/structures.py	Fri Feb 12 16:21:48 2010 +0100
+++ b/structures.py	Mon Feb 15 11:24:36 2010 +0100
@@ -1,3 +1,5 @@
+from tools import testBit
+
 # feature fields: bc=battery count, pwr=maximum watts
 features = {
 "default":{"bc":2,"pwr":360},
@@ -44,12 +46,6 @@
  6: "No test initiated"
 }
 
-# vTd? -> test_result + 3 (?)
-
-def testBit(int_type, offset):
-    mask = 1 << offset
-    return(int_type & mask)
-
 def getEventText(Event):
     # convert the given events bitmask to a readable string
     if Event < 0:
--- a/tools.py	Fri Feb 12 16:21:48 2010 +0100
+++ b/tools.py	Mon Feb 15 11:24:36 2010 +0100
@@ -55,6 +55,9 @@
 # this defines a function to convert any number to a binary string
 bstr_pos = lambda n: n>0 and bstr_pos(n>>1)+str(n&1) or ''
 
+def testBit(int_type, offset):
+    mask = 1 << offset
+    return(int_type & mask)
 
 def getDuration(val):
     # get the duration as string
--- a/victrond.py	Fri Feb 12 16:21:48 2010 +0100
+++ b/victrond.py	Mon Feb 15 11:24:36 2010 +0100
@@ -9,7 +9,7 @@
 from tools import *
 from config import *
 
-VERSION = "0.7.0"
+VERSION = "0.7.2"
 
 class AuthException(Exception):
     def __init__(self, value):
@@ -42,6 +42,8 @@
 	"battery_voltage":features[model]["bc"]*BATTERYVOLTAGE,
 	"battery_count":features[model]["bc"],
 	"max_power":features[model]["pwr"],
+	"TIVLow":self.query("vFi"),
+	"TIVHigh":self.query("vFj"),
 	"IVmin":self.query("vI0l"),
 	"IVmax":self.query("vI0h")
 	}
@@ -125,8 +127,6 @@
 	"SNoLoad_en":((vZ2C & 4)==4),
 	"SByPass_en":((vZ2C & 2)==2),
 	"SModemNumber":self.query("vZ0d"),
-	"SIVLow":self.query("vFi"),
-	"SIVHigh":self.query("vFj"),
 	"SBuzzer":buzzer,
 	"SBuzzerTxt":BuzzerTexts.get(buzzer,"Unknown: "+str(buzzer)),
 	"SOVolt":int(self.query("vFc")), # 220, 230, 240
@@ -412,11 +412,50 @@
 	
 
     def _getEventStatus(self):
+	#print "------------------------------------ GETTING STATUS"
 	Event = self.query("vAa")
 	try:
 	    self.Event = int(Event)
 	except:
 	    self.Event = "-1"
+	
+	if self.Event >= 0:
+	    #print "Setting status flags..."
+	    # set several status flags
+	    Event = self.Event
+	    self.state = {
+		"RB": False,
+		"BI": False,
+		"LB": False,
+		"BB": False,
+		"OL": False,
+		"OB": False,
+		"SA": False,
+		"OFF": False,
+		"SB": False,
+		"ST": False
+	    }
+
+	    if testBit(Event, 0):
+		self.state["RB"] = True # replace batt
+	    if testBit(Event, 1):
+		self.state["BI"] = True # bad input
+	    if testBit(Event, 2):
+		self.state["LB"] = True # low batt
+	    if testBit(Event, 5):
+		self.state["BB"] = True # bad bypass
+	    if testBit(Event, 7):
+		self.state["OL"] = True # overload
+	    if testBit(Event, 9):
+		self.state["OB"] = True # onbatt
+	    if testBit(Event, 11):
+		self.state["SA"] = True # shutdown timer
+	    if testBit(Event, 13):
+		self.state["OFF"] = True # powered off
+	    if testBit(Event, 14):
+		self.state["SB"] = True # stand-by
+	    if testBit(Event, 23):
+		self.state["ST"] = True # selftest
 
     def getValues(self):
 	self._wait_comm_free()
@@ -443,7 +482,7 @@
 	    syspwr = ipwrtmp-opwr
 
 	if self.attention == False:
-	    self._getEventStatus
+	    self._getEventStatus()
 
 	tstatus = int(self.query("vTr"))
 
@@ -480,6 +519,24 @@
 	"TestStatusTxt":TStatusTexts.get(tstatus,"Unknown: "+str(tstatus)),
 	"TestResult":self.query("vTd")
 	}
+	
+	swfparm = "upsload="+str(self.values["OLoad"])
+	try:
+	    #print "STATE: "+repr(self.state)+"\n"
+	    if self.state["OFF"] == False:
+		swfparm = swfparm + "&led1=1"
+	    if (self.state["OL"] == True) | (self.state["BB"] == True) | (self.state["RB"] == True) | (self.state["LB"] == True):
+		swfparm = swfparm + "&led2=1"
+	    if self.state["SA"] == True:
+		swfparm = swfparm + "&led4=1"
+	    if self.state["RB"] == True:
+		swfparm = swfparm + "&led5=1"
+	    if self.state["OB"] == True:
+		swfparm = swfparm + "&led6=1"
+	except:
+	    print "ERROR: No STATE defined?"
+	self.values["UPS_Paneldisplay"] = "<object width=\"195\" height=\"172\" id=\"panel\"><param name=\"movie\" value=\"img/panel.swf?"+swfparm+"\" /><param name=\"quality\" value=\"high\" /><embed src=\"img/panel.swf?"+swfparm+"\" quality=\"high\" width=\"195\" height=\"172\" name=\"panel\" type=\"application/x-shockwave-flash\" /></object>"
+	#
 	self.comm_free = True
 	if LOG_DEBUG == True:
 	    print "Values: "+repr(self.values)+"\n"
@@ -569,6 +626,7 @@
 	global ups
 	if self.path == "/":
 	    self.path = "/index.tmpl"
+	self.path = self.path.partition("?")[0] # remove passed parameters!
 	dirname = curdir + sep + "http"
 	filename = dirname + self.path
 	(dirName, fileName) = path.split(self.path)

mercurial