001/* 002 * Copyright (c) 1998-2010 The Regents of the University of California. 003 * All rights reserved. 004 * 005 * '$Author: jianwu $' 006 * '$Date: 2013-01-23 22:31:43 +0000 (Wed, 23 Jan 2013) $' 007 * '$Revision: 31365 $' 008 * 009 * Permission is hereby granted, without written agreement and without 010 * license or royalty fees, to use, copy, modify, and distribute this 011 * software and its documentation for any purpose, provided that the above 012 * copyright notice and the following two paragraphs appear in all copies 013 * of this software. 014 * 015 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY 016 * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 017 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 018 * THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF 019 * SUCH DAMAGE. 020 * 021 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, 022 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 023 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE 024 * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF 025 * CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, 026 * ENHANCEMENTS, OR MODIFICATIONS. 027 * 028 */ 029 030package org.geon; 031 032import ptolemy.actor.lib.Const; 033import ptolemy.kernel.CompositeEntity; 034import ptolemy.kernel.util.IllegalActionException; 035import ptolemy.kernel.util.NameDuplicationException; 036import ptolemy.kernel.util.Settable; 037import ptolemy.vergil.icon.BoxedValueIcon; 038 039////////////////////////////////////////////////////////////////////////// 040//// ConstOnce 041/** 042 * Produce a constant output once. The value of the output is that of the token 043 * contained by the value parameter, which by default is an IntToken with value 044 * 1. The type of the output is that of value parameter. The actor emits the 045 * parameter value on the ouput port during a single fire event. 046 * 047 * @UserLevelDocumentation This actor produces a constant value once. The value 048 * is set by the user as a parameter of the actor, or 049 * defaults to an integer value of 1 if unset. The actor 050 * emits the parameter value on the ouput port once. A 051 * typical usage of this actor is used to parameterize 052 * other models that take constant values as inputs. 053 * @author Efrat Jaeger 054 * @version $Id: ConstOnce.java 31365 2013-01-23 22:31:43Z jianwu $ 055 * @since Ptolemy II 3.0.2 056 * @deprecated Use ptolemy.actor.lib.Const instead. 057 */ 058 059@Deprecated 060public class ConstOnce extends Const { 061 062 /** 063 * Construct an actor with the given container and name. 064 * 065 * @param container 066 * The container. 067 * @param name 068 * The name of this actor. 069 * @exception IllegalActionException 070 * If the actor cannot be contained by the proposed 071 * container. 072 * @exception NameDuplicationException 073 * If the container already has an actor with this name. 074 */ 075 public ConstOnce(CompositeEntity container, String name) 076 throws NameDuplicationException, IllegalActionException { 077 super(container, name); 078 079 BoxedValueIcon icon = new BoxedValueIcon(this, "_icon"); 080 icon.displayWidth.setExpression("25"); 081 icon.attributeName.setExpression("value"); 082 //disable this parameter since it is not used in this actor. 083 firingCountLimit.setVisibility(Settable.NONE); 084 } 085 086 // ///////////////////////////////////////////////////////////////// 087 // // public methods //// 088 089 /** 090 * Set postfire to false. 091 * 092 * @exception IllegalActionException 093 * If thrown by the super class. 094 */ 095 public boolean postfire() throws IllegalActionException { 096 return false; 097 } 098}