Is there a way to use events in C#? I am able to create an event delegate, but can't figure out how to subscribe to the event. Currently trying to know when limit test status is valid.
Which API are you using?
I am currently working with Rev A.10.49.
Are you using SCPI? DCOM? an IVI-COM driver?
I am using DCOM.
getting events to work over DCOM is not for the faint of heart !!!
- both the client PC and the analyzer have to be on the same domain
- you have to login to the analyzer with the same domain credentials as you are using on the client PC, or if I am not mistaken, the user account on the analyzer has to have admin status on the domain.
if you get past the security issues, then you can use DCOM events in C#, but the amount of hoops you have to jump through is not worth it, unless you have a real good reason to need events. If you explain more about the measurement you are trying to make, we might be able to suggest an easier alternative.
I'm really just trying to know when I can get a valid reading of whether the limit test has passed or failed.
you don't need events to do that. Limit tests are setup on specific measurements, so if you have a handle to the measurement object, then you can use the property IMeasurement.LimitTestFailed (false = passed, true = failed). Once you have triggered that measurement and the sweep has completed, just check the property to see if your measurement has passed or failed its limit tests
Alternatively, you can setup the Global PASS/FAIL, which is tied to the material handler object. if Global PASS/FAIL is turned on, then you can query the HWMaterialHandlerIO.PassFailStatus after you have completed the sweep of all the channels to see if any of your limit tests had failed.
I'll look into the HWMaterialHandlerIO bit. I wasn't sure yet if I could use this.
Otherwise, how do I determine the sweep status?
depends on how you start your sweeps. But most commonly people who use the COM interface, use the command Channel.Single(), where Channel is a handle to the IChannel object for the specific channel you want to sweep. if you send the command Channel.Single(true), then the command blocks until the sweep is complete, so that is how you know when the execution is done. You can sweep the channel asynchronously by sending Channel.Single(false), but that is when you will need to implement events to know when the sweep is done.
As a general rule or "best practice" in automating VNA measurements, it is best to setup your channels while keeping them in hold mode and then when everything is setup and ready to go, you can loop through all the channels that you have (using the IChannels collection) and do a synchronous single on each one.
Okay, thanks daras. It looks like I could also use Channel.Single(false) with manual triggering setup and then do an app.ManualTrigger with sync true and a timeout.
Retrieving data ...