Hi Chad, Ptolemy hackers has a limit of 40k for messages, and your last message was over that limit (sorry). I truncated your message in my response below.
Chad writes: > Hey Christopher, > > I forgot to address the problem of the actors with ports that actually > do follow the naming convention. I've attached a class that is an > example of this. Here's the port definition: > > startTrigger = new TypedIOPort(this, "startTrigger", true, false); > > and here's the stack trace: > > [java] java.lang.CloneNotSupportedException: Problem cloning > 'startTrigger' [java] at > ptolemy.kernel.Entity.clone(Entity.java:224) > [java] at > ptolemy.kernel.ComponentEntity.clone(ComponentEntity.java:125) > [java] at ptolemy.actor.AtomicActor.clone(AtomicActor.java:121) > [java] at The problem is in the constructor, where you create startTrigger: startTrigger = new TypedIOPort(this, "startTrigger", true, false); new Attribute(startTrigger, "_showName"); startTrigger.setContainer(null); If I remove the setContainer(null) line, then startTrigger is properly cloned. I think setting setContainer(null) on a port basically removes it from the hierarchy, which causes no end of problems for clone, since then startTrigger is not found. The error message is wrong though. I created a test for this in kernel/Entity.tcl. I'll see if I can come up with a better error message. We have group lunch today, we'll talk over the clone issue and get back to you. > The only test I have for showing this error is to start up kepler and > open a new graph editor and watch the errors scroll by :) ptolemy/configs/test/allConfigs.tcl has tests that clone all the actors. > chad > _Christopher > Christopher Brooks wrote: > > Hi Chad, > > The naming convention for ports is that the name of the port > > is the name of the java field. > > > > There are a couple of reasons for this: > > 1) It means that many actors do not need their own clone(Workspace) method. > > We found that most developers had a hard time properly implementing > > the clone(Workspace) method so we modified Entity.clone(Workspace) > > so that it uses reflection to properly clone the ports. > > > > Entity has had this sort of cloning since at least 2001. > > > > What did change was that in October, 2004, I modified > > Entity.clone(Workspace) so that it handles misnamed ports in a > > cleaner fashion. That should have triggered new Exceptions > > being thrown though. > > > > BTW - $PTII/ptolemy/configs/test/allConfigs.tcl includes tests that > > check port names and check cloning to ensure that the proper type > > constraints are cloned when necessary. These tests run > > on the configuration. > > > > > > 2) I believe that the copernicus code generator might require > > that the names of ports and parameters should match the names > > of the variables. See section 7.2 of Volume 2 of the Ptolemy Design > > doc: > > > > In order for existing actor code to be leveraged by the code > > generator, it assumes that the code is written according to the > > Ptolemy style for writing actors. This style assumes naming > > conventions for the public fields of an actor class that refer to > > parameters and ports of the actor. The code generator also assumes > > that the ports and parameters of an actor are created in the class > > constructor and not modified later. Some actors do not fit these > > constraints and cannot be used directly in the code generator. Such > > actor classes cannot be used directly by the code generator, > > although in some cases we have been able to have the code generator > > deal specially with such actors. In other cases, the actor class > > fits the constraints but cannot be effectively specialized using > > generic techniques. Such actors can also be dealt with specially by > > the code generator to more effectively generate code. > > > > 3) I prefer strong naming conventions because I'm constantly looking > > at other people's code and I don't like stumbling for the mapping > > between the "a nice descriptive port name" and the name of the > > variable. > > > > > > It sounds like there is a bug if the name of the Port that is set in > > the constructor is the same as the name of the field and the exception > > is being thrown. > > > > Do you have a test case I can take a look at? Perhaps the port > > is not public? > > > > One issue is that you probably have lots of actors with "a nice > > descriptive port name" as names. Are these ports of these actors > > properly being cloned? Maybe you should run the tests in > > ptolemy/configs/tests/allConfigs.tcl on you configuration and see what > > comes up. > > > > It would be nice to provide some sort of compatibility functionality > > that would support your "a nice descriptive port name" ports and avoid > > the exception. We could check for a property or something here. > > > > Let me know what you think. > > > > _Christopher > > > > > > -------- > > > > Hi, > > > > Lately, we've been compiling kepler with the CVS version of PTII > > instead > > of release 4.0.1. We've started seeing errors (see bottom of email) > > with a lot of our actors saying that a port cannot be cloned because > > the > > variable name does not match the port name passed to the constructor. > > I'm wondering why this suddenly started happening and why this should > > be > > illegal behavior to begin with. It seems reasonable to me to have a > > declaration like > > > > TypedIOPort inputPort = new TypedIOPort(this, "a nice descriptive port > > name", true, false); > > > > The error message seems to strictly forbid this. On top of this, > > sometimes the variable name *does* match the constructor name and it > > still throws this exception. > > > > My questions are: Does anyone know why this suddenly started happening > > and why is this a problem in the first place? Is there anyway to fix > > this, short of changing the variable names in all of our actors? > > > > thanks, > > chad > > > > java.lang.CloneNotSupportedException: Problem cloning 'outputLog' > > [java] at ptolemy.kernel.Entity.clone(Entity.java:224) > > [java] at > > ptolemy.kernel.ComponentEntity.clone(ComponentEntity.java:125) > > [java] at > > ptolemy.actor.AtomicActor.clone(AtomicActor.java:121) > > [java] at > > > > org.ecoinformatics.seek.sms.AnnotationEngine.buildTreeModel(AnnotationEng > public class WebService > extends TypedAtomicActor { > > /** Construct a WebService actor with the given container and name. > * @param container The container. > * @param name The name of this actor. > * @exception IllegalActionException If the actor cannot be contained > * by the proposed container. > * @exception NameDuplicationException If the container already has an > * actor with this name. > */ > public WebService(CompositeEntity container, String name) throws > NameDuplicationException, IllegalActionException { > > super(container, name); > > wsdlUrl = new StringParameter(this, "wsdlUrl"); > // wsdlUrl.setExpression("http://xml.nig.ac.jp/wsdl/DDBJ.wsdl"); > methodName = new StringParameter(this, "methodName"); > userName = new StringParameter(this, "userName"); > password = new StringParameter(this, "password"); > > startTrigger = new TypedIOPort(this, "startTrigger", true, false); > new Attribute(startTrigger, "_showName"); > startTrigger.setContainer(null); > // Set the trigger Flag. > hasTrigger = new Parameter(this, "hasTrigger", new BooleanToken(false)); > hasTrigger.setTypeEquals(BaseType.BOOLEAN); > > clientExecErrors = new TypedIOPort(this, "clientExecErrors", false, true); > clientExecErrors.setTypeEquals(BaseType.STRING); > > _attachText("_iconDescription", > "<svg>\n" > + "<rect x=\"0\" y=\"0\" " > + "width=\"60\" height=\"30\" " > + "style=\"fill:white\"/>\n" > + "</svg>\n"); > } > > /////////////////////////////////////////////////////////////////// > //// ports and parameters //// > > /** > * @entity.description The parameter for the URL of the web service WSDL. > */ > public StringParameter wsdlUrl; > /** > * @entity.description The parameter for the method name. > */ > public StringParameter methodName; > /** > * @entity.description The userName to invoke the web service if necessary. > */ > public StringParameter userName; > /** > * @entity.description The password to invoke the web service if necessary. > */ > public StringParameter password; > /** > * @entity.description This is an parameter to activate the optional > * startTrigger port. <I>Please activate it <i>ONLY</I> when the actor > * has no input and it is required for scheduling of the actor. > */ > public Parameter hasTrigger; > /** > * @entity.description This is an optional input port that can be used to > * help the scheduling of the actor. > * > * <P>This port is activated by the hasTrigger parameter. Double-click on > * the actor to enable. <I>Please enable it <i>ONLY</I> when the actor has > * no input and it is required for scheduling of the actor. > */ > public TypedIOPort startTrigger; > /** > * @entity.description It outputs the errors if any occured when actor is > * executing. It outputs "NO ERRORS." if there are no exceptional cases. > * > */ > public TypedIOPort clientExecErrors; Christopher Brooks (cxh at eecs berkeley edu) University of California Programmer/Analyst Chess/Ptolemy/Trust US Mail: 558 Cory Hall #1770 ph: 510.643.9841 fax:510.642.2739 Berkeley, CA 94720-1770 home: (F-Tu) 707.665.0131 (W-F) 510.655.5480 (office: 400A Cory) ---------------------------------------------------------------------------- Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: [EMAIL PROTECTED]