Hi Christopher,I think I'm doing some weird mistake, but I don't understand why the other actors I wrote work. Anyway, here's the (stripped down) actor that doesn't work and the model.
Cheers, Vincenzo On 21/06/2011 17:32, Christopher Brooks wrote:
Hi Vincenzo, Do you have a small test actor and sample model? _Christopher On 6/21/11 8:05 AM, Vincenzo Forchi wrote:Hi Edward, On 21/06/2011 16:53, Edward A. Lee wrote:Something's fishy here. Such a model should work fine in PN. Note that hasToken() _alaways_ returns true in PN.That's good to know, I completely missed thatThe get() method blocks when there is no input.Apparently in this case it doesn't, but why is the fire even triggered in the first place?Looks like something is terminating the threads using a TerminateProcessException. How is your model supposed to be stopped?When all the tokens have been consumed, which works for most of my actors with the PN and for all of them with the DDF. Cheers, Vincenzo
-- Vincenzo Forchi European Southern Observatory Karl-Schwarzschild-Strasse 2, D-85748 Garching bei Muenchen, Germany. Email: [email protected] Tel: +49 89 32006136 Fax: +49 89 3202362
/* This file is part of Reflex * Copyright (C) 2010 European Southern Observatory * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.eso; import java.util.List; import ptolemy.actor.IOPort; import ptolemy.actor.TypedAtomicActor; import ptolemy.actor.TypedIOPort; import ptolemy.data.BooleanToken; import ptolemy.data.IntToken; 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; import ptolemy.kernel.util.Settable; /** * The FitsRouter routes the files present on the input port to the output ports * based on file category. There are two modes: * * Simple mode: create an output port named against a file type (e.g. FLAT), all files * of that type will be routed there * * Advanced mode: create an output port named as you like (e.g. MyPort) and a StringParameter * named MyPort_config which contains a comma separated list of regular expressions. All files * matching at least one of the regexps will be routed to that port. * * You can limit the number of files broadcasted from a port defining the attributes ' * MyPort_min_number and MyPort_max_number. * * Note: a file can be routed to many ports * * @author Vincenzo Forchi` - [email protected] */ public class FitsRouter extends TypedAtomicActor { private static final long serialVersionUID = -880546985796686687L; /* INPUT */ /* the input port containing the data sets to be processed */ private TypedIOPort d_loso = new TypedIOPort(this, "loso", true, false); private Parameter d_loso_tokenConsumptionRate; /* OUTPUT */ /* the output port containing the rejected data sets */ private TypedIOPort d_rejected = new TypedIOPort(this, "rejected", false, true); /* the output ports where the file should be routed */ List<IOPort> ports; public FitsRouter(CompositeEntity container, String name) throws IllegalActionException, NameDuplicationException { super(container, name); //d_loso.setMultiport(true); d_loso.setTypeEquals(BaseType.STRING); d_rejected.setMultiport(true); d_rejected.setTypeEquals(BaseType.STRING); d_rejected.setDefaultWidth(1); /* show port names */ new Parameter(d_loso, "_showName", new BooleanToken(true)); new Parameter(d_rejected, "_showName", new BooleanToken(true)); /* port parameter */ d_loso_tokenConsumptionRate = new Parameter(d_loso, "tokenConsumptionRate"); d_loso_tokenConsumptionRate.setVisibility(Settable.NOT_EDITABLE); d_loso_tokenConsumptionRate.setTypeEquals(BaseType.INT); d_loso_tokenConsumptionRate.setToken(new IntToken(1)); } @Override public void fire() throws IllegalActionException { /* get input data set */ try { /* get the token and convert it to a string */ if (d_loso.hasToken(0)) { String xml = ((StringToken) d_loso.get(0)).stringValue(); d_rejected.broadcast(new StringToken(xml)); } else { return; } } catch (Exception e) { e.printStackTrace(); throw new IllegalActionException(e.getMessage()); } } }
pn.kar
Description: Binary data
_______________________________________________ Kepler-users mailing list [email protected] http://lists.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users

