In many homes there are still electricity meters with a mechanical counter that do not provide a direct interface for reading the consumption of electrical energy. In this blog, I am trying to capture the consumption of electrical energy with a mobile device (Android) as a scanner to read the information from the mechanical counter and record it in the database like SAP HCP. In this case, we are going to build a SAPUI5 Cordova electricity meter reading with the SDK from Anyline.io.
scanElectricMeter: function() {
cordova.exec(this.onResult, this.onError, "AnylineSDK", "scanElectricMeter", this.energyConfig);
}
onResult: function(result) {
var meterType = []; var reading=[];
meterType.push(result.meterType);
reading.push(result.reading);
var data = [];
for(var i = 0; i < meterType.length; i++) {
data.push({"meterType": meterType[i], "reading": reading[i]});
}
var oModel1 = new sap.ui.model.json.JSONModel({ "zgwmat": data });
sap.ui.getCore().setModel(oModel1, "zgwmatmodel");
var bus = sap.ui.getCore().getEventBus();
bus.publish("nav", "to", {
id : "scanresult",
});
},
That's it!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
12 | |
12 | |
7 | |
5 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |