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(AnnotationEngin e.java:426) [java] at org.ecoinformatics.seek.sms.AnnotationEngine.buildTreeModel(AnnotationEngin e.java:442) [java] at org.ecoinformatics.seek.sms.AnnotationEngine.buildTreeModel(AnnotationEngin e.java:442) [java] at org.ecoinformatics.seek.sms.AnnotationEngine.buildDefaultActorLibrary(Annot ationEngine.java:377) [java] at org.kepler.gui.TabbedLibraryPane.<init>(TabbedLibraryPane.java:108) [java] at org.kepler.gui.TabbedLibraryPane$Factory.createLibraryPane(TabbedLibraryPan e.java:268) [java] at org.kepler.gui.LibraryPaneFactory.createLibraryPane(LibraryPaneFactory.java :121) [java] at ptolemy.vergil.basic.BasicGraphFrame.<init>(BasicGraphFrame.java:351) [java] at ptolemy.vergil.basic.ExtendedGraphFrame.<init>(ExtendedGraphFrame.java:98) [java] at ptolemy.vergil.actor.ActorGraphFrame.<init>(ActorGraphFrame.java:122) [java] at ptolemy.vergil.actor.ActorGraphTableau.<init>(ActorGraphTableau.java:103) [java] at ptolemy.vergil.actor.ActorGraphTableau$Factory.createTableau(ActorGraphTabl eau.java:159) [java] at ptolemy.actor.gui.PtolemyTableauFactory.createTableau(PtolemyTableauFactory .java:101) [java] at ptolemy.actor.gui.TableauFactory.createTableau(TableauFactory.java:123) [java] at ptolemy.actor.gui.Configuration.createPrimaryTableau(Configuration.java:202 ) [java] at ptolemy.actor.gui.TableauFrame$1.actionPerformed(TableauFrame.java:369) [java] at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786) [java] at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButt on.java:1839) [java] at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java: 420) [java] at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258) [java] at javax.swing.AbstractButton.doClick(AbstractButton.java:289) [java] at javax.swing.AbstractButton.doClick(AbstractButton.java:269) [java] at javax.swing.plaf.basic.BasicMenuUI$MenuKeyHandler.menuKeyPressed(BasicMenuU I.java:589) [java] at javax.swing.JMenuItem.fireMenuKeyPressed(JMenuItem.java:608) [java] at javax.swing.JMenuItem.processMenuKeyEvent(JMenuItem.java:499) [java] at javax.swing.JMenuItem.processKeyEvent(JMenuItem.java:458) [java] at javax.swing.MenuSelectionManager.processKeyEvent(MenuSelectionManager.java: 417) [java] at javax.swing.plaf.basic.BasicPopupMenuUI$MenuKeyboardHelper.keyPressed(Basic PopupMenuUI.java:1057) [java] at java.awt.Component.processKeyEvent(Component.java:5058) [java] at javax.swing.JComponent.processKeyEvent(JComponent.java:2388) [java] at java.awt.Component.processEvent(Component.java:4909) [java] at java.awt.Container.processEvent(Container.java:1569) [java] at java.awt.Component.dispatchEventImpl(Component.java:3615) [java] at java.awt.Container.dispatchEventImpl(Container.java:1627) [java] at java.awt.Component.dispatchEvent(Component.java:3477) [java] at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:171 3) [java] at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusM anager.java:627) [java] at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFoc usManager.java:831) [java] at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFoc usManager.java:741) [java] at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusMana ger.java:592) [java] at java.awt.Component.dispatchEventImpl(Component.java:3506) [java] at java.awt.Container.dispatchEventImpl(Container.java:1627) [java] at java.awt.Window.dispatchEventImpl(Window.java:1606) [java] at java.awt.Component.dispatchEvent(Component.java:3477) [java] at java.awt.EventQueue.dispatchEvent(EventQueue.java:456) [java] at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.j ava:201) [java] at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.jav a:151) [java] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145) [java] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137) [java] at java.awt.EventDispatchThread.run(EventDispatchThread.java:100) [java] Caused by: ptolemy.kernel.util.IllegalActionException: Could not find a port named 'outputLog' or 'outputLogPort'. This can occur when the name of the variable does not match the name passed to the constructor of the actor. [java] Right: [java] outputLog = new TypedIOPort(this, "outputLog", true, false); [java] Right: [java] outputLog = new TypedIOPort(this, "outputLogPort", true, false); [java] Wrong: [java] outputLog = new TypedIOPort(this, "foo", true, false); [java] in .configuration.actor library.Wmsd Actor [java] at ptolemy.kernel.Entity.clone(Entity.java:199) [java] ... 52 more --------------------------------------------------------------------------- - Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: [EMAIL PROTECTED] -------- ---------------------------------------------------------------------------- Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: [EMAIL PROTECTED]