Battery.py
Go to the documentation of this file.
00001 __author__ = 'tom1231'
00002 from PyQt4.QtGui import *
00003 from BAL.Interface.DeviceFrame import DeviceFrame, BATTERY
00004 
00005 
00006 class Battery(DeviceFrame):
00007 
00008     def __init__(self, frame, data):
00009         DeviceFrame.__init__(self, BATTERY, frame, data)
00010         self._pubHz = '10'
00011         self._voltDivRation = '6'
00012 
00013     def fromDict(self, data):
00014         self._pubHz = data['pubHz']
00015         self._voltDivRation = data['voltDivRation']
00016 
00017     def toDict(self):
00018         data = dict()
00019         data['type'] = BATTERY
00020         data['pubHz'] = self._pubHz
00021         data['voltDivRation'] = self._voltDivRation
00022 
00023         return data
00024 
00025     def saveToFile(self, file):
00026         file.write('Battery/name: ' + self.getName() + '\n')
00027         file.write('Battery/pubHz: ' + self._pubHz + '\n')
00028         file.write('Battery/voltageDividerRatio: ' + self._voltDivRation + '\n')
00029 
00030     def showDetails(self, items=None):
00031         self.puHzField = QLineEdit(self._pubHz)
00032         self.voltDivRationField = QLineEdit(self._voltDivRation)
00033 
00034         self._frame.layout().addRow(QLabel('Publish Hz: '), self.puHzField)
00035         self._frame.layout().addRow(QLabel('Voltage divider ratio: '), self.voltDivRationField)
00036 
00037     def getName(self):
00038         return 'battery_monitor'
00039 
00040     def add(self):
00041         if not self.nameIsValid():
00042             error = QErrorMessage()
00043             error.setWindowTitle("Same name error")
00044             error.showMessage("Name already taken.")
00045             error.exec_()
00046             self._isValid = False
00047             return
00048         self._isValid = True
00049         self._pubHz = str(self.puHzField.text())
00050         self._voltDivRation = str(self.voltDivRationField.text())
00051 
00052     def printDetails(self):
00053         self._frame.layout().addRow(QLabel('Publish Hz: '), QLabel(self._pubHz))
00054         self._frame.layout().addRow(QLabel('Voltage divider ratio: '), QLabel(self._voltDivRation))


ric_board
Author(s): RoboTiCan
autogenerated on Fri Oct 27 2017 03:02:30