001package jmri.jmrix.can.cbus; 002 003import javax.annotation.CheckForNull; 004import jmri.jmrix.can.CanMessage; 005 006/** 007 * Interface for CBUS Sensors, Turnouts and Lights to report CBUS Events. 008 * @author Steve Young (c) 2020 009 */ 010public interface CbusEventInterface { 011 012 /** 013 * Get event for primary Bean On Action. 014 * e.g. without inversion, Light On. 015 * @return Event for the Action, may be null 016 */ 017 @CheckForNull 018 CanMessage getBeanOnMessage(); 019 020 /** 021 * Get event for primary Bean Off Action. 022 * e.g. without Inversion Light Off. 023 * @return Event for the Action, may be null 024 */ 025 @CheckForNull 026 CanMessage getBeanOffMessage(); 027 028 /** 029 * Check if CanMessage is an event. 030 * @param m CAN Frame to test. 031 * @return Passed CanMessage if event, else null. 032 */ 033 @CheckForNull 034 default CanMessage checkEvent(CanMessage m) { 035 if ( CbusMessage.isEvent(m) ){ 036 return m; 037 } 038 return null; 039 } 040 041}