Discussion Locked

How can I generate the Water Consumption bill in c sharp?

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

hi all.. I am working on Automatic Meter Reading system. Using GSM modem to send and receive SMS. I am getting the SMS string as
>>AA5500101#0000440585#000000000.820#0000000.000#0.3.689#TE=Y,RF=N#0000440585#0000000000#0000000000#000#000#212#55AA
Now I am breaking it as
Flowmeter Id :- 001
GSM/GPRS :- 01 (02 for GPRS)
Current Meter Reading :- 820
Battery Voltage :-3.689
TE=Y, RF=N

the pseudo code,,

Get the Message string
Detect Flowmeter_ID
Find Previous Meter reading(PMR) for the same( If it is for the first time then PMR=0 else the Meter reading taken last time
Subtract PMR from Current Meter reading to get Consumed Water
Now Store Current meter reading as Previous Meter reading for the next Time
Similarly if I am getting the Message string as following

AA5500201#0000440585#000000000.620#0000000.000#0.3.689#TE=Y,RF=N#0000440585#0000000000#0000000000#000#000#212#55AA

Flowmeter Id :- 002
GSM/GPRS :- 01 (02 for GPRS)
Current Meter Reading :- 620
Battery Voltage :-3.689
TE=Y, RF=N

In this case device id is different so it will search the PMR for device id 002 and subtract it from the Current meter reading of the same device.

there will be a database column

Device Number
Date Time
Flowmeter_ID(PKey)
GSM/GPRS
Current Meter Reading
Battery voltage
TE, RF
Consumed Water
Charge/Ltr
Amount

then in the reporting I will be create a view in which I will combine customer table with Device table

and finally I will have following in the report

Customer ID
Customer Name
Address
Device Number
Date Time
Flowmeter_ID(PKey)
GSM/GPRS
Current Meter Reading
Battery voltage
TE, RF
Consumed Water
Charge/Ltr
Amount

I am cant able to write the code for shifting PMR and CMR.........
please help me out.

3 replies

by tony hopkinson

all you should be doing is calling a stored procedure and passing it the content of teh SMS message, raw or otherwise.
Then you can simplify your life and openn up all sorts of enhancements simply by recording the reading.

That way consumed water can be calculated on next meter reading, or for the report.
You've fallen into a classic trap here

All you need is meter reading and datemeteread.
The previous is the one before it order of ascending date.
No calculations, no finding, one insert statement.
Current is the last one, job done.
and you've got them all...
in one place....
and no messing about trying to figure out why the previous meter reading doesn't make sense.

Time to apply the KISS principle, trust me you don't want to go with this previous and next crap, it's a tin of worms.

This discussion is closed to new replies.