and saves them via a DataStore object.
"""
- DEFAULT_WINDOWS_LOGFILE = "C:\\owl_server_log.txt"
- DEFAULT_NON_WINDOWS_LOGFILE = "/var/log/owl_server_log.txt"
-
- DEFAULT_SERVER_PORT = 12745
DEVICE_NAME = "OWL+USB (CM160)"
MESSAGE_ID_0 = 0xa9
def openSerialPort(self):
"""Open a serial port with the required settings
- Returns the seialPort object or None if an error occured opening the
- serial port.
- """
+ Returns the serialPort object or None if an error occured opening the serial port. """
#Ifthe serial port is open, close it
if self.__ser != None:
self.__ser.close()
self.__serRXBuffer = self.__serRXBuffer + list(buf)
def getSerialPortPacket(self, timeoutSeconds=60):
- """Get the next 11 byte message an OWL+USB device
+ """Get the next 11 bytes message of an OWL+USB device
Returns a list object holding the message (string elements) or None
if a timeout occured while waiting for a message.
"""
self.__uo.debug("TX: %03d/0x%02x" % (b,b) )
def processSerialPacket(self, packet, realTimeData):
- """Process an 11 byte packet containing sensor data"""
+ """Process an 11 bytes packet containing sensor data"""
if len(packet) != 11:
raise OWLError("Invalid data message length. 11 bytes expected, got %d" % (len(packet)) )
#Convert strings to list of numbers
day = frame[3]
hour = frame[4]
_min = frame[5]
-# costPerKWH = (frame[6]+(frame[7]<<8))/100.0 #Cost in pence per kWh
amps = (frame[8]+(frame[9]<<8))* 0.07 #Conversion factor to Amps
cm160Data = CM160Data(_min, hour, day, month, year, amps)
#Set flag to indicate if this CM160Data was read in realtime or during a data download
self.__ser.close()
self.__uo.info("%s closed" % (self.__serialPortName) )
-# if self.__server != None:
-# self.__server.stop()
-
if self.__queueReader != None:
self.__queueReader.stop()