001/* Debug event indicating a state change. 002 003 Copyright (c) 2000-2014 The Regents of the University of California. 004 All rights reserved. 005 Permission is hereby granted, without written agreement and without 006 license or royalty fees, to use, copy, modify, and distribute this 007 software and its documentation for any purpose, provided that the above 008 copyright notice and the following two paragraphs appear in all copies 009 of this software. 010 011 IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY 012 FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 013 ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 014 THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF 015 SUCH DAMAGE. 016 017 THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, 018 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 019 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE 020 PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF 021 CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, 022 ENHANCEMENTS, OR MODIFICATIONS. 023 024 PT_COPYRIGHT_VERSION_2 025 COPYRIGHTENDKEY 026 027 */ 028package ptolemy.domains.modal.kernel; 029 030import ptolemy.kernel.util.DebugEvent; 031import ptolemy.kernel.util.NamedObj; 032 033/////////////////////////////////////////////////////////////////// 034//// StateEvent 035 036/** 037 An event indicating a state change. This event can be used for debugging. 038 039 @author Edward A. Lee 040 @version $Id$ 041 @since Ptolemy II 8.0 042 @Pt.ProposedRating Yellow (eal) 043 @Pt.AcceptedRating Red (nobody) 044 */ 045public class StateEvent implements DebugEvent { 046 /** Construct an event with the specified source and destination 047 * state. 048 * @param source The source of this state event. 049 * @param state The state of this event refers to. 050 */ 051 public StateEvent(FSMActor source, State state) { 052 _source = source; 053 _state = state; 054 } 055 056 /////////////////////////////////////////////////////////////////// 057 //// public methods //// 058 059 /** Return the source of the event, which is an instance of FSMActor. 060 * @return The ptolemy object that published this event. 061 */ 062 @Override 063 public NamedObj getSource() { 064 return _source; 065 } 066 067 /** Return the state to which this event refers. 068 * @return The state to which this event refers. 069 */ 070 public State getState() { 071 return _state; 072 } 073 074 /** Return a string representation of this event, which is the 075 * string "New state: <i>name of state</i>". 076 * @return A string describing the event. 077 */ 078 @Override 079 public String toString() { 080 return "New state: " + _state.getFullName(); 081 } 082 083 /////////////////////////////////////////////////////////////////// 084 //// private variables //// 085 // The source. 086 private FSMActor _source; 087 088 // The new state. 089 private State _state; 090}