Registered Member
|
(Newbie alert!!!)
I would like to create a battery charge charting plasmoid that updates the plotter at set intervals. I currently have a plotter working but, from what I can tell, the data engine only calls "dataUpdated" when the charge changes. This makes for a rather linear graph which does not indicate change in charge over time. From what I can tell, this is to be expected since the documentation for dataEngine states the following concerning the pollingInterval: "If the data has not changed, no update will be sent. " So, I'm hoping someone could give me some guidance on how to capture and plot change of charge over time. By the way, I am building on the plasmoid from "getting started with python plasma tutorial". The following is some simple code illustrating how I currently am using the dataengine: def connectToEngine(self): self.engine = self.dataEngine('soliddevice') battery = self.engine.query('IS Battery').values()[0].toString() print "Connecting to battery %s"%battery self.engine.connectSource(battery, self) @pyqtSignature("dataUpdated(const QString &, const Plasma::DataEngine::Data &)") def dataUpdated(self, sourceName, data): charge = data[QString("Charge Percent")].toInt()[0] print "Charge: %s%%"%charge samples = [charge,] self.chart.addSample(samples) Thanks for any help! Ben |
Registered Member
|
Well, it looks like I implemented this easy enough... Just used a "time" dataEngine source to manage the plotter update at set intervals. The battery datasource just updates the charge value to be used when plotting. Out of curiosity now... is there a better way to do it? Thanks again! Ben |
Administrator
|
Other than using the time dataengine, you could have used a QTimer which actvated every x seconds / minutes.
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
Registered users: Bing [Bot], daret, Google [Bot], sandyvee, Sogou [Bot]