Odd channel behavior
ericmedley
Posts: 4,177
for(nloop=length_array(HCS_Devices);nloop>0;nloop--) { if(HCS_Device_Stat[nloop] and HCS_Device_Count[nloop]<12 ) { HCS_Device_Count[nloop]++ [b]if(HCS_Device_Count[nloop]>11 and ![vdv_My_HCS, HCS_Devices_chan[nloop]])[/b] { on[vdv_My_HCS, HCS_Devices_chan[nloop] ] HCS_Device_Alarm_Sent_flag[nloop]=1 } } // end if(HCS_Device_Stat[nloop])
I'm noticing some odd behavior that I dont understand.
In the example above the idea is that when I get a device offline during a poll, I increment it's count. When that count gets to 12 I turn on a channel on a virtual device. In the IF statement that is bolded, I also have a conditional that says If the channel is already on don't bother trying to turn it on again. (a one-time trap)
The problem is that the conditional is being ignored. The channel is clearly on in diagnostic, the variable tracking it shows it's on but the conditional statement fires anyway and the channel get's turned on again (this creating and error message sent out in another part of the code)
How am I being a bone-head?
0
Comments
Where's the code where you are tracking that channel state? I'd start by making sure that's rock solid.
I've seen peculiarities with the compiler before relating to ![dev,chan] logic. It shouldn't be necessary, but try it this way with some extra parentheses...
if((HCS_Device_Count[nloop]>11) and (![vdv_My_HCS, HCS_Devices_chan[nloop]]))
or try it as a two level if
if(HCS_Device_Count[nloop]>11)
if(![vdv_My_HCS, HCS_Devices_chan[nloop]])