001package jmri.jmrit.ussctc; 002 003import jmri.*; 004 005/** 006 * Derive a CTC machine bell via a Turnout output. Will only ring if a particular 007 * Sensor is active. Used to provide a bell cutout. 008 * 009 * @author Bob Jacobsen Copyright (C) 2007, 2017, 2021 010 */ 011public class VetoedBell implements Bell { 012 013 public VetoedBell(String veto, Bell bell) { 014 NamedBeanHandleManager hm = InstanceManager.getDefault(NamedBeanHandleManager.class); 015 SensorManager tm = InstanceManager.getDefault(SensorManager.class); 016 017 hVeto = hm.getNamedBeanHandle(veto, tm.provideSensor(veto)); 018 this.bell = bell; 019 } 020 021 NamedBeanHandle<Sensor> hVeto; 022 Bell bell; 023 024 @Override 025 public void ring() { 026 if (hVeto.getBean().getKnownState() != Sensor.ACTIVE) { 027 bell.ring(); 028 } 029 } 030 031}