Sunday, 11 September 2011

Blowing Smoke...

up my own bottom!
I once built a 2 dimensional cross sectional Stockpile management system in Visual Basic 3 for a mining client of a software and engineering company I was working for. You can see an example of a circular stockpile/reclaimer next to the road just before Aberdeen on the New England Highway at the mothballed Dartbrook mine.

As usual the management troglodytes had given us insufficient time to effectively develop the application thoroughly and we were beset with performance issues from the get go.

VB3 came with the code for an icon drawing package and I hacked out relevant bits to generate the rendering of the stockpile using the Windows drawing APIs. The idea was the the circular stockpile was metaphorically split open and displayed in 2 dimensions and when you dragged a cursor representing the reclaimer over the stockpile, a calculation of the approximate coal quality was displayed - sulphur and moisture content etc.

One of the main problems was the ODBC driver for SQL Server was abysmally slow to the point of useless.
ODBC is a protocol - not a standard - so you could be served up a pretty sloppy driver if you weren't careful and the driver we were using at the time was pretty sloppy.
Every time you would drag the virtual reclaimer over the stockpile it would take minutes for any numbers to appear. The app was busily querying the SQL Server db with the offsets of the start and end points of the reclamation and extracting data harvested from the Citect SCADA system. But it took freaking forever!

What to do?

I managed to get hold of a book that detailed the ODBC api with enough information to enable me to roll my own ODBC 'driver' making direct calls to the DLL. It reduced the time from a couple of minutes per query down to a couple of seconds.

Looking back it was a masterful solution - I'm forever talking myself down in an industry populated by people that constantly spend most of their time telling everybody how wonderfully clever they are but this was one time where I think I delivered some pretty nifty code. The source has been lost to the sands of time but I look back on this particular project with a bit of fondness because it provided a workable solution with the shortest amount of time and with pretty inflexible specifications.