At a high level, weewx consists of an engine that is responsible for managing a set of services. A service consists of a Python class with a set of member functions. The engine arranges to have appropriate member functions called when specific events happen. For example, when a new LOOP packet arrives, member function processLoopPacket() of all services is called.
To customize, you can
This document describes how to do all three.
The default install of weewx includes the following services:
Service | Function |
weewx.wxengine.StdWunderground | Starts thread to manage WU connection; adds new data to a Queue to be posted to the WU by the thread. |
weewx.wxengine.StdCatchUp | Any data found on the weather station memory but not yet in the archive, is retrieved and put in the archive. |
weewx.wxengine.StdTimeSynch | Arranges to have the clock on the station synchronized at regular intervals. |
weewx.wxengine.StdPrint | Prints out new LOOP and archive packets on the console. |
weewx.wxengine.StdProcess | Launches a new thread to create reports, HTML, and images. |
The service weewx.wxengine.StdPrint prints out new LOOP and archive packets to the console when they arrive. By default, it prints out time, barometer, outside temperature, wind speed, and wind direction. Suppose you want to add
In this section, we look at how to install a custom Engine. In general, this is the least desirable way to proceed, but in some cases it may be the only way to get what you want.
The standard engine is a class called StdEngine. To customize, you must inherit from this class. Here's an example, which prints out the full LOOP packet.
Create a file with your engine in it. Call it file myengine.py. Here's the contents:
from weewx.wxengine import StdEngine
# Create a specialized, custom engine:
class MyEngine(StdEngine):
# Pass on the init parameters to my superclass
def __init__(self, *args, **vargs):
super(MyEngine, self).__init__(*args,
**vargs)
# Override the member function that processes loop packets:
def processLoopPacket(self, physicalPacket):
# First let the superclass process
it:
super(MyEngine, self).processLoopPacket(physicalPacket)
# Then add my specialized processing:
print "Hi! I'm a specialized loop
packet processor"
print physicalPacket
Then go into file weewxd.py and change the line
weewx.wxengine.main()
so that it uses your new engine:
from myengine import MyEngine
# Specify that my specialized engine should be used instead
# of the default:
weewx.wxengine.main(EngineClass = MyEngine)