Hi Mike,
How are you looking to perform the calculation? Performance Equations, PISDK...or are you open to the solution?
Take PE (Performance Equations) as a start, there is a great help file installed in "..\PIPC\Help\PEReference.chm" that lists all the functions that you can use. There are functions for returning events (PITime) when something first occurs within a time range, avergage values etc.
You could create a PE tag that is scheduled based on events from your digital tag (electric eye status) that checks if the value = "metal present" then get the time when the value was "no metal present"....etc
Let me know if you want an example and when I get a moment I will take a look....
Cheers,
Rhys.
Principal Consultant
Real-Time Data Management @ Wipro Technologies