Joule: SoftwareDefined Energy Metering