[kepler-dev] Fwd: Do you know whats wrong?

Peter Reutemann fracpete at gmail.com
Tue Mar 31 22:36:09 PDT 2009


---------- Forwarded message ----------
From: subhav mital <...>
Date: Wed, Apr 1, 2009 at 18:20
Subject: Do you know whats wrong?
To: Peter Reutemann <...>


hey,
I am just trying to convert this into a yes no decision maker.
Can u please suggest whats wrong?
Thanks!
/**
 *
 */
package org.userinputmod;
import javax.swing.JOptionPane;
import ptolemy.actor.TypedIOPort;
import ptolemy.actor.lib.LimitedFiringSource;
import ptolemy.data.StringToken;
import ptolemy.data.expr.Parameter;
import ptolemy.data.type.BaseType;
import ptolemy.kernel.CompositeEntity;
import ptolemy.kernel.util.IllegalActionException;
import ptolemy.kernel.util.NameDuplicationException;
/**
 * @author Subhav
 *
 */
public class UserInputMod extends LimitedFiringSource {
public Parameter user;
public TypedIOPort opeqtrue;
public TypedIOPort opeqfalse;
/**
* @param containert
* @param name
* @throws NameDuplicationException
* @throws IllegalActionException
*/
public UserInputMod(CompositeEntity container, String name)
throws NameDuplicationException, IllegalActionException {
super(container, name);
output.setTypeEquals(BaseType.STRING);
opeqtrue= new TypedIOPort(this, "opeqtrue", false, true);
opeqfalse= new TypedIOPort(this, "opeqfalse", false, true);
//output.setTypeEquals(BaseType.INT);
user = new Parameter(this,"user");
}
/* (non-Javadoc)
* @see ptolemy.actor.lib.Source#fire()
*/
@Override
public void fire() throws IllegalActionException {
super.fire();
String reply = JOptionPane.showInputDialog("Please enter 'yes' or 'no'");
  if (reply == "yes")
  {
  opeqtrue.broadcast(new StringToken(reply));
}
  else
  {
  opeqfalse.broadcast(new StringToken("no"));
  }
  //output.s
  //output.broadcast(new StringToken(reply));
  //output.b
}
}
Basically, if yes, then I want to do something, if no then I want to
branch somewhere. Can you please suggest something?
Thanks!


-- 
Peter Reutemann, Dept. of Computer Science, University of Waikato, NZ
http://www.cs.waikato.ac.nz/~fracpete/           Ph. +64 (7) 858-5174


More information about the Kepler-dev mailing list