From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

VeriStand

cancel
Showing results for 
Search instead for 
Did you mean: 

IWorkspace2 Interface: Undefined timing behaviour.

Hello,

 

I set various channels using the SetSingleChannelValue function of the IWorkspace2 Interface.

When I read a channel using the GetSingleChannelValue function afterwards, I don't get the expected result. It seems that it takes some undefined (?) time for the set-value operation to complete after the function returned.

 

For example after executing the following code, channel_val will be 0 (when 0 is the previous value of the channel):

 

WorkSpace = Factory().GetIWorkspace2()
WorkSpace.SetSingleChannelValue('some_channel', 10)

WorkSpace.GetSingleChannelValue('some_channel', channel_val)

 

However, when waiting some time after the call to SetSingleChannelValue, channel_val will have the correct value (10):

 

WorkSpace = Factory().GetIWorkspace2()
WorkSpace.SetSingleChannelValue('some_channel', 10)

time.sleep(0.2) #Wait 200ms

WorkSpace.GetSingleChannelValue('some_channel', channel_val)

 

Can anybody explain this behaviour? In my oppinion this is a bug, because when I call a function to do some operation, I expect the operation (set-value in this case) to be completed when the function returns. I'm using VeriStand 2012.

 

Thanks

 

 

0 Kudos
Message 1 of 5
(5,149 Views)

Hello Krid,

 

setting the value is asynchronous. So the gateway sends the command to real time side asap. 

Reading of the value is based on gateway refresh rate, that is 15 Hz. So in the worst case you have to wait up to 60ms to get value refreshed on host side.

 

Jiri

CLA, CTA, CLED

0 Kudos
Message 2 of 5
(5,146 Views)

Hello Jiri,

 

thank you for your answer. Is the gateway refresh rate of 15Hz a fixed value or is it possible to access/change this value using the API (I haven't found anything in the docs so far)?

 

I'm thinking of using the IChannelMonitor interface to be notified when a channel value really changed to the value I set it to (seems to be a quite cumbersome solution though).

 

Krid

0 Kudos
Message 3 of 5
(5,142 Views)

Hi Krid,

 

it is not possible to change that 15 Hz through API.

If you need more rapid action, you will have to use Real-Time sequence a manage the logic on the RT side.

Or you can subscribe for a UDP stream of specific channel through API. Than you will get undecimated data, but with slight transport delay...

 

Jiri

CLA, CTA, CLED

0 Kudos
Message 4 of 5
(5,140 Views)

Hi Jiri

 

I may have an answer at the end of this thread : http://forums.ni.com/t5/NI-VeriStand/Gateway-channel-caching/m-p/2603559#M3258

 

Regards

0 Kudos
Message 5 of 5
(5,135 Views)