You can think of each tab as a screen. Whenever a screen is disabled the objects in the screen are disabled. When new channel data is received all
enabled objects are notified. Meaning that the checkbox within the disabled tab is not notified of the change in that channels value. There are a couple of ways to handle this.
1. You could change the
NIComV2 object to notify all objects of new channel data regardless of wether they are disabled or not. The problem with this is that performance could be drastically hurt, so I wouldn't take this approach.
2. Basically you need to make sure that if an object is required to recieve data at any time (disabled or not), then it needs to be enabled at all times. The only way to do this is to put the object in globals.
2a. One approach that I think would require little work is to make a copy of your
NICheckBoxV2 object, move the copy into globals, and move it off to the side so that its non-visible. This way if your Tab is disabled you'll still have an object in globals that will recieved the channel data.
2b. Another alternative solution is use an
NIVirtualVariableV2 in globals, and a normal
CheckBoxV2 in the tab instead of an
NICheckBoxV2. When the NIVirtualVariable receives an update on that channels its
NewChannelData() will be called. You can put code in the NewChannelData event to update the CheckBoxV2 and take any other needed actions. The code might look something like this:
Code:
func NewChannelData()
checkbox_1.ischecked = boolvalue
endfunc
Unfortunately I recently fixed a bug in the
NIVirtualVariableV2 object that you'll need to fix also. I wouldn't normally reccomend editing a library directly, but in this case its okay. You can either make this change via a template or editing the library directly. Find the
channeldata function in the
NIVirtualVariableV2 object source and replace it with this code.
Code:
private func channeldata(channelnumber as integer) returns boolean
handles NI_CHANNEL_DATA_RECEIVED
dim data[] as byte
dim i as integer
dim b as byte
dim bool as boolean
dim u as unibyte
dim f as float
dontsend := true
check error
if channelnumber == channel then
data = NICOM_OBJ.getlastdatareceived()
if len(data) > 0 then
if data[0] == datatype then
if datatype == _NI_STRING then
stringvalue = mid(data,1, -1)
elseif datatype == _NI_FLOAT32 then
frombytes(f,mid(data,1, -1), true)
floatvalue = f
elseif datatype == _NI_INT32 then
frombytes(i,mid(data,1, -1), true)
intvalue = i
elseif datatype == _NI_UINT16 then
frombytes(u,mid(data,1, -1), true)
intvalue = u
elseif datatype == _NI_UINT8 then
frombytes(b,mid(data,1, -1), true)
intvalue = b
elseif datatype == _NI_BOOL then
frombytes(bool,mid(data,1, -1), true)
boolvalue = bool
endif
NewChannelData()
endif
endif
endif
on error
_clearException()
enderr
dontsend := false
return false
endfunc