# Joe's watcher code # if bitand(str2double(tmp),2^15) % klystron deactivated # error_flag(n) = 1; # end # ===================================================== # make "deactivated" mask record(calc, KLYS:ACTIVE:MASK) { field(CALC, "2**15") field(PINI, "YES") } # do the bitwise and and see if non-0 # 1 if DEACTIVATED, 0 if ACTIVE # SWRD comes from VMS and has no SEVR # therefore, invalid indicates that this channel is # unavailable, which will make the final result invalid. record(calc, $(KLYS)1:DEACTCALC) { field(CALC, "A&B>0?1:0") field(INPA, "$(KLYS)1:SWRD NPP MS") field(INPB, "KLYS:ACTIVE:MASK") field(SCAN, "$(RATE) second") field(FLNK, "$(KLYS)1:DEACT") } # put the result into a bi for state names and alarm statuses record(bi, "$(KLYS)1:DEACT") { field(DESC, "$(DESC)") field(INP, "$(KLYS)1:DEACTCALC.VAL NPP MS") field(ZSV, "NO_ALARM") field(OSV, "MAJOR") field(ZNAM, "ACTIVE") field(ONAM, "DEACTIVATED") }