Frank,
One way to detect whether the relay switched would be to check the minimum and maximum values of the output array Y. If they are about 0 and 3.5 V, the it switched. If both are close to zero or both are close to 3.5, it did not switch. Or look at the threshold. If it is between 1.5 and 2, switching occurred. If it is close to zero or 3.5, then it did not switch.
You can use the Split 1D Array or Array Subset functions to get the parts of the array before the first rising edge and after the last one. Taking the averages of those subsets will give you the DC values. I did not check what you get from an empty array. Probably NaN because the length is zero.
Lynn