Jump to content

When there is no value in a cell


Recommended Posts

I have an energy monitoring system that I am building.  This EMS gathers data once per minute and drops that data into a mssql db.  I have php set up to interpret the values and allow the customer to query the mssql for data for a peak value within a 15 minute interval.  


The user enters the 15 minute interval into the web app, along with the timeperiod (15 minute interval in question)  example   (2014-10-16 at 07:30:00 - 07:44:59 ).  Sometimes there is no data in that interval because there was nothing reported (due to power outages or internet connection issue).  When there is no data to report, there is not even an entry row set in mssql, therefore the time and date it is querying is not present.  


I am trying to find a way that if php queries mssql and the row that is queried does not exist,  have php look forward than backwards simultaneously until it finds any value (it can even be a zero as long as its a value) to report.  I would think I could cover any situation including a major power outage by looking forward three (3) days and back three (3) days.  I'm not sure where to even start with something like this.  Does anyone have a suggestion on how to start?

Link to comment
Share on other sites

I see why you would think that, however, if there is no data, the metering sends an empty packet with zero values.  So there will be a row in mssql that has all zeros.  Occasionally there is no row of data sent by the EMS, so if it doesnt exist, it doesnt mean that they were using zero energy, it just means that the data never reached the server ( in the timestamped period), so we look at the next timestamps.  In that event I need a backup plan to look forward then backward until it finds data (that data can even be zero).  


This system never stops sending data, so if it doesnt make it to the server, there is some reason (something blocking the 900 MHz, internet down or electric down).

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.