From: <jsa...@us...> - 2008-11-12 16:41:16
|
Revision: 89 http://flexotask.svn.sourceforge.net/flexotask/?rev=89&view=rev Author: jsauerbach Date: 2008-11-12 16:41:11 +0000 (Wed, 12 Nov 2008) Log Message: ----------- API and javadoc cleanup, including some minor interface changes (mostly renamings). Modified Paths: -------------- trunk/flexotask/src/com/ibm/realtime/flexotask/system/FlexotaskValidator.java trunk/flexotask/src/com/ibm/realtime/flexotask/template/AbstractFlexotaskTemplate.java trunk/flexotask/src/com/ibm/realtime/flexotask/template/FlexotaskCommunicatorTemplate.java trunk/flexotask/src/com/ibm/realtime/flexotask/template/FlexotaskConnectionMode.java trunk/flexotask/src/com/ibm/realtime/flexotask/template/FlexotaskConnectionTemplate.java trunk/flexotask/src/com/ibm/realtime/flexotask/template/FlexotaskPortTemplate.java trunk/flexotask/src/com/ibm/realtime/flexotask/template/FlexotaskPredicateTemplate.java trunk/flexotask/src/com/ibm/realtime/flexotask/template/FlexotaskStableMode.java trunk/flexotask/src/com/ibm/realtime/flexotask/template/FlexotaskTaskTemplate.java trunk/flexotask/src/com/ibm/realtime/flexotask/template/FlexotaskTemplate.java trunk/flexotask/src/com/ibm/realtime/flexotask/timing/simple/SimpleTimingAnnotation.java trunk/flexotask/src/com/ibm/realtime/flexotask/tools/FlexotaskXMLParser.java trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/TaskDiagram.java trunk/flexotask-functiontest/src/types/Main.java trunk/flexotask-generic/src/com/ibm/realtime/flexotask/template/FlexotaskTemplate.java Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/system/FlexotaskValidator.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/system/FlexotaskValidator.java 2008-11-12 16:40:46 UTC (rev 88) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/system/FlexotaskValidator.java 2008-11-12 16:41:11 UTC (rev 89) @@ -223,7 +223,7 @@ if (controller instanceof AtomicFlexotaskController) { FlexotaskTaskTemplate task = (FlexotaskTaskTemplate) entry.getKey(); try { - Class guardClass = CodeValidator.resolveClass(task.getGuard(), cl); + Class guardClass = CodeValidator.resolveClass((task.getImplementationClass() + "$Guard"), cl); AtomicFlexotaskGuard guard = (AtomicFlexotaskGuard) guardClass.newInstance(); AtomicFlexotaskBase atomicTask = (AtomicFlexotaskBase) ((FlexotaskControllerImpl) controller).root.getTask(); guard.setDelegate((AtomicFlexotask) atomicTask); Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/template/AbstractFlexotaskTemplate.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/template/AbstractFlexotaskTemplate.java 2008-11-12 16:40:46 UTC (rev 88) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/template/AbstractFlexotaskTemplate.java 2008-11-12 16:41:11 UTC (rev 89) @@ -112,7 +112,7 @@ ans.append("ans.setSynchronizing(").append(String.valueOf(synchronizing)).append(");"); ans.append("ans.setStableMode(com.ibm.realtime.flexotask.template.FlexotaskStableMode.getStableMode(\"") .append(stableMode.toString()).append("\"));"); - if (stableMode != FlexotaskStableMode.AUTO) { + if (stableMode != FlexotaskStableMode.MARKER) { for (Iterator iter = stableClasses.iterator(); iter.hasNext();) { String classname = (String) iter.next(); ans.append("ans.getStableClasses().add(").append(classname).append(");").append(newline); @@ -186,15 +186,25 @@ } /** - * @return the size of the tasks set. + * Get the number of tasks (equivalent to getTasks().size()) + * @return the number of tasks */ - public int getTaskSize() { + public int getNumberOfTasks() { return tasks.size(); } /** - * @return timingData. + * Get the number of connections (equivalent to getConnections().size()) + * @return the number of connections */ + public int getNumberOfConnections() { + return connections.size(); + } + + /** + * Get the FlexotaskGlobalTimingData for this template + * @return the timing data + */ public FlexotaskGlobalTimingData getTimingData() { return timingData; } Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/template/FlexotaskCommunicatorTemplate.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/template/FlexotaskCommunicatorTemplate.java 2008-11-12 16:40:46 UTC (rev 88) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/template/FlexotaskCommunicatorTemplate.java 2008-11-12 16:41:11 UTC (rev 89) @@ -71,58 +71,40 @@ } /** - * Illegal in a communicator, whose ports are always called in0 and out0 + * Illegal in a communicator, whose ports are fixed by design * @throws IllegalArgumentException unconditionally */ - public void setInputPortNames(String[] inputPortNames) - { + public void setInputPorts(FlexotaskPortTemplate[] inputPorts) { throw new IllegalArgumentException(); } /** - * Illegal in a communicator, whose port types are determined by setParameterType + * Illegal in a communicator, whose ports are fixed by design * @throws IllegalArgumentException unconditionally */ - public void setInputPortTypes(String[] inputPortTypes) - { + public void setInputPorts(String[] inputPortTypes, + boolean[] inputPortBuffering, String[] inputPortNames) { throw new IllegalArgumentException(); } /** - * Illegal in a communicator + * Illegal in a communicator, whose ports are fixed by design * @throws IllegalArgumentException unconditionally */ - public void setInputPortBuffering(boolean[] isBuffered) { - throw new IllegalArgumentException(); - } - - /** - * Illegal in a communicator, whose ports are always called in0 and out0 - * @throws IllegalArgumentException unconditionally - */ - public void setOutputPortNames(String[] outputPortNames) - { + public void setOutputPorts(FlexotaskPortTemplate[] outputPorts) { throw new IllegalArgumentException(); } /** - * Illegal in a communicator, whose port types are determined by setParameterType + * Illegal in a communicator, whose ports are fixed by design * @throws IllegalArgumentException unconditionally */ - public void setOutputPortTypes(String[] outputPortTypes) - { + public void setOutputPorts(String[] outputPortTypes, + boolean[] outputPortBuffering, String[] outputPortNames) { throw new IllegalArgumentException(); } /** - * Illegal in a communicator - * @throws IllegalArgumentException unconditionally - */ - public void setOutputPortBuffering(boolean[] isBuffered) { - throw new IllegalArgumentException(); - } - - /** * In a communicator, the parameterType (class) is the type of the communicator's ports and buffer. */ public void setParameterType(String parameterType) @@ -132,8 +114,8 @@ FlexotaskPortTemplate outputPort = new FlexotaskPortTemplate(); inputPort.setPortType(parameterType); outputPort.setPortType(parameterType); - super.setInputPortGroup(new FlexotaskPortTemplate[] {inputPort}); - super.setOutputPortGroup(new FlexotaskPortTemplate[] {outputPort}); + super.setInputPorts(new FlexotaskPortTemplate[] {inputPort}); + super.setOutputPorts(new FlexotaskPortTemplate[] {outputPort}); } /** Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/template/FlexotaskConnectionMode.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/template/FlexotaskConnectionMode.java 2008-11-12 16:40:46 UTC (rev 88) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/template/FlexotaskConnectionMode.java 2008-11-12 16:41:11 UTC (rev 89) @@ -14,13 +14,21 @@ package com.ibm.realtime.flexotask.template; /** - * Represents the possible modes which a connection driver can move objects. - * Possible modes are: + * Represents the possible ways in which object references can be transmitted across connections. + * The semantics depend both on the connection mode and on where the objects reside. + * <p>Objects may reside in a Flexotask private heap + * or on the public heap (the latter objects are reference-immutable and pinned; they are reached either + * from legal static fields or from the parameters passed to weakly isolated Flexotasks). + * + * <p>Possible modes are: * <ul> - * <li>BYREF - indicating that objects are moved by reference. - * <li>DEEPCLONE - indicates that objects are moved by deep-cloning them. - * <li>HYBRID - indicates that objects are moved by reference for the - * pinned, heap-allocated objects, and otherwise by deep-cloning. + * <li>BYREF - indicating that only objects on the public heap may be transmitted; all such + * objects are transmitted by reference. Attempts to transmit other objects cause an + * IllegalArgumentException at the time an object is stored in an output port. + * <li>DEEPCLONE - indicates that all objects are transmitted by deep-cloning them, regardless of where + * they reside; the result is always a new object. + * <li>HYBRID - indicates that objects are transmitted by reference if they reside on the public heap + * and by deep-cloning if they reside in the Flexotask private memory space * </ul> * */ Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/template/FlexotaskConnectionTemplate.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/template/FlexotaskConnectionTemplate.java 2008-11-12 16:40:46 UTC (rev 88) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/template/FlexotaskConnectionTemplate.java 2008-11-12 16:41:11 UTC (rev 89) @@ -41,7 +41,7 @@ private FlexotaskConnectionMode mode = FlexotaskConnectionMode.DEEPCLONE; /** - * Specify a new FlexotaskConnectionSTemplate in one step + * Specify a new FlexotaskConnectionTemplate in one step * @param name a name for this connection (if null, a useful stylized name is generated) * @param timingData information that provides timing semantics for the graph, typically used * by the scheduler Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/template/FlexotaskPortTemplate.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/template/FlexotaskPortTemplate.java 2008-11-12 16:40:46 UTC (rev 88) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/template/FlexotaskPortTemplate.java 2008-11-12 16:41:11 UTC (rev 89) @@ -30,7 +30,7 @@ private FlexotaskTaskTemplate containerTask; /** - * constructor + * Create a new, empty, Port template. At least the type must be specified subsequently. */ public FlexotaskPortTemplate() { portType = ""; @@ -38,23 +38,24 @@ } /** + * Get the task to which the port has been assigned or null if the port has never teen assigned to a task * @return the task containing this port */ - public FlexotaskTaskTemplate getContainerTask() { + public FlexotaskTaskTemplate getContainingTask() { return containerTask; } /** - * Get the input port buffering - * @return the input port buffering + * Query whether or not the port is buffered + * @return true iff the port is buffered */ - public boolean getPortBuffer() { + public boolean isBuffered() { return this.portBuffer; } /** - * Get the input port name - * @return the input port name + * Get the port name + * @return the port name */ public String getPortName() { @@ -62,8 +63,8 @@ } /** - * Get the input port type - * @return the input port type + * Get the port type + * @return the port type (as a String class name) */ public String getPortType() { @@ -71,25 +72,29 @@ } /** - * @return whether this port is an input port of a task + * Determine whether this port is the input port of a task + * @return true if the port is the input port of a task and false if it is not (meaning either that + * it is the output port of a task or has never been assigned to task) */ public boolean isInput() { - return getContainerTask().isInputPort(this); + return containerTask == null ? false : containerTask.isInputPort(this); } /** - * @return whether this port is an output port of a task + * Determine whether this port is the output port of a task + * @return true if the port is the output port of a task and false if it is not (meaning either that + * it is the input port of a task or has never been assigned to task) */ public boolean isOutput() { - return getContainerTask().isOutputPort(this); + return containerTask == null ? false : containerTask.isOutputPort(this); } /** - * Set the input port buffering - * @param portBuffer true if the input port is buffered, false otherwise + * Set the port buffering + * @param buffered true if the port is to be buffered, false otherwise */ - public void setPortBuffer(boolean portBuffer) { - this.portBuffer = portBuffer; + public void setBuffered(boolean buffered) { + this.portBuffer = buffered; } /** Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/template/FlexotaskPredicateTemplate.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/template/FlexotaskPredicateTemplate.java 2008-11-12 16:40:46 UTC (rev 88) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/template/FlexotaskPredicateTemplate.java 2008-11-12 16:41:11 UTC (rev 89) @@ -74,7 +74,7 @@ ans.setName(getName()); /* Don't copy the timing data or graphics */ ans.setImplementationClass(getImplementationClass()); - ans.setInputPortGroup((FlexotaskPortTemplate[]) getInputPortGroup().toArray()); + ans.setInputPorts(getInputPorts()); ans.setParameterType(getParameterType()); ans.setParameterValue(getParameterValue()); ans.setWeaklyIsolated(isWeaklyIsolated()); Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/template/FlexotaskStableMode.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/template/FlexotaskStableMode.java 2008-11-12 16:40:46 UTC (rev 88) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/template/FlexotaskStableMode.java 2008-11-12 16:41:11 UTC (rev 89) @@ -14,34 +14,34 @@ package com.ibm.realtime.flexotask.template; /** - * Indicator class for the stable mode of a flexotask template, ie., how the - * type checker deals with stable classes. There are four different modes: + * Describes the policy for dividing the Flexotask private memory area into a stable + * heap and a transient area. * <ol> - * <li>AUTO -- the type checker considers only classes implementing the <code> - * Stable</code> marker interface, their subclasses and any Flexotask - * subclasses as stable. - * <li>INFER -- the type checker infers all stable classes from a simple set - * of rules; any Flexotask subclasses, their non-primitive and non-primitive - * array fields and their subclasses are considered stable. - * <li>MANUAL -- the type checker only considers classes that are pre-specified - * and provided to the type checker as stable. - * <li>DEFAULT -- the type checker considers all classes as stable. + * <li>DEFAULT -- all classes are stable. + * <li>MARKER -- the classes implementing the <code>Stable</code> marker interface, and their subclasses, + * are considered stable. All others are transient. + * <li>INFER -- the validator infers the smallest set of stable classes such that the rules governing + * stable and transient storage are not violated. All others are transient. + * <li>MANUAL -- stable classes are explicitly listed in the template. All others are transient. * </ol> */ public final class FlexotaskStableMode { - /** Indicates the mode in which the checker will use marker interfaces to infer - * stable classes */ - public static final FlexotaskStableMode AUTO = new FlexotaskStableMode("auto"); - /** Indicates the mode in which the checker will infer stable classes only from - * their uses */ + /** Indicates that the classes implementing the <code>Stable</code> marker interface, and their subclasses, + * are considered stable while all others are transient. + */ + public static final FlexotaskStableMode MARKER = new FlexotaskStableMode("marker"); + /** Indicates that the validator should infer the smallest set of stable classes such that the rules + * governing stable and transient storage are not violated, with all others transient. + */ public static final FlexotaskStableMode INFER = new FlexotaskStableMode("infer"); - /** Indicates the mode in which the user will provide complete and explicit list - * of stable classes*/ + /** Indicates that stable classes are explicitly listed in the template, with all others transient. + */ public static final FlexotaskStableMode MANUAL = new FlexotaskStableMode("manual"); - /** Indicates the mode in which all classes are default to stable */ + /** Indicates that all classes are stable (this is the default if no FlexotaskStableMode is declared for a + * template) */ public static final FlexotaskStableMode DEFAULT = new FlexotaskStableMode("default"); /** The array of all possible modes */ - private static final FlexotaskStableMode[] modes = { AUTO, INFER, MANUAL, DEFAULT }; + private static final FlexotaskStableMode[] modes = { MARKER, INFER, MANUAL, DEFAULT }; /** The current mode category of this instance */ private final String mode; @@ -75,7 +75,7 @@ /** * Returns the <code>FlexotaskStableMode</code> singleton object corresponding - * to the provided mode + * to the provided mode. * @param mode the name of the mode * @return the corresponding FlexotaskStableMode instance * @throws IllegalArgumentException if provided mode is illegal. Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/template/FlexotaskTaskTemplate.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/template/FlexotaskTaskTemplate.java 2008-11-12 16:40:46 UTC (rev 88) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/template/FlexotaskTaskTemplate.java 2008-11-12 16:41:11 UTC (rev 89) @@ -13,11 +13,10 @@ */ package com.ibm.realtime.flexotask.template; -import java.util.LinkedList; /** * Specifies one Flexotask within an FlexotaskTemplate. Used directly - * for user-defined exotasks that are not predicates. To create a predicate or communicator, + * for user-defined Flexotasks that are not predicates. To create a predicate or communicator, * use FlexotaskPredicateTemplate or FlexotaskCommunicatorTemplate, both of which * specialize this class. */ @@ -27,28 +26,28 @@ private String implementationClass; /** The port templates representing input ports, in declaration order */ - private FlexotaskPortTemplate[] inputPortGroup; + private FlexotaskPortTemplate[] inputPorts; /** The port templates representing output ports, in declaration order */ - private FlexotaskPortTemplate[] outputPortGroup; + private FlexotaskPortTemplate[] outputPorts; /** A String that becomes the value of the graphics='...' attribute when converted to XML. - * Used to support the exotask graphical editor. Ignored otherwise. + * Used to support the Flexotask graphical editor. Ignored otherwise. */ private String graphics; - /** Indicates that this is a weakly isolated exotask (its parameter, if any, must be ref-immutable and is not + /** Indicates that this is a weakly isolated Flexotask (its parameter, if any, must be ref-immutable and is not * deep-copied). Its presence in the graph means that all getstatic checks for the graph will require * only ref-immutability and not full immutability. */ private boolean weaklyIsolated; - /** The type of the exotask's default parameter value in this specification. If null, the exotask + /** The type of the Flexotask's default parameter value in this specification. If null, the Flexotask * has no default parameter, though it may still have a runtime parameter. */ private String parameterType; - /** The value expression of the exotask's default parameter (ignored if parameterType is null) */ + /** The value expression of the Flexotask's default parameter (ignored if parameterType is null) */ private String parameterValue; // @see com.ibm.realtime.flexotask.template.FlexotaskTemplateElement#generateSource() @@ -58,18 +57,18 @@ .append("=new FlexotaskTaskTemplate();").append(newline); getCommonSource(ans); getCommonTaskSource(ans); - if (outputPortGroup != null && outputPortGroup.length > 0) { - ans.append(getName()).append(".setOutputPortGroup(new String[]{"); - for (int i = 0; i < outputPortGroup.length; i++) { - ans.append("\"").append(outputPortGroup[i].getPortType()).append("\","); + if (outputPorts != null && outputPorts.length > 0) { + ans.append(getName()).append(".setOutputPorts(new String[]{"); + for (int i = 0; i < outputPorts.length; i++) { + ans.append("\"").append(outputPorts[i].getPortType()).append("\","); } ans.append("},new boolean[]{"); - for (int i = 0; i < outputPortGroup.length; i++) { - ans.append(outputPortGroup[i].getPortBuffer()).append(","); + for (int i = 0; i < outputPorts.length; i++) { + ans.append(outputPorts[i].isBuffered()).append(","); } ans.append("},new String[]{"); - for (int i = 0; i < outputPortGroup.length; i++) { - ans.append("\"").append(outputPortGroup[i].getPortName()).append("\","); + for (int i = 0; i < outputPorts.length; i++) { + ans.append("\"").append(outputPorts[i].getPortName()).append("\","); } ans.append("});").append(newline); } @@ -86,12 +85,12 @@ String[] outputNames = getOutputPortNames(); for (int i = 0; i < inputNames.length; i++) { ans.append(" <Input id='").append(inputNames[i]).append("' type='") - .append(inputPortGroup[i].getPortType()).append("' isBuffered='").append(inputPortGroup[i].getPortBuffer()) + .append(inputPorts[i].getPortType()).append("' isBuffered='").append(inputPorts[i].isBuffered()) .append("'/>").append(newline); } for (int i = 0; i < outputNames.length; i++) { ans.append(" <Output id='").append(outputNames[i]).append("' type='") - .append(outputPortGroup[i].getPortType()).append("' isBuffered='").append(outputPortGroup[i].getPortBuffer()) + .append(outputPorts[i].getPortType()).append("' isBuffered='").append(outputPorts[i].isBuffered()) .append("'/>").append(newline); } getTimingDataXML(ans); @@ -119,65 +118,63 @@ * Get a specific input port template * @param index the index of the desired template, in declaration order * @return the input port in this task associated with the given index + * @throws ArrayIndexOutOfBoundsException */ public FlexotaskPortTemplate getInputPort(int index) { - return inputPortGroup[index]; + return inputPorts[index]; } /** * Get a specific output port template * @param index the index of the desired template, in declaration order * @return the output port in this task associated with the given index + * @throws ArrayIndexOutOfBoundsException */ public FlexotaskPortTemplate getOutputPort(int index) { - return outputPortGroup[index]; + return outputPorts[index]; } /** - * @return the size of the input port group + * Get the number of input ports (equivalent to getInputPorts().length) + * @return the number of input ports */ - public int getInputPortSize() { - if (inputPortGroup == null) + public int getNumberOfInputPorts() { + if (inputPorts == null) return 0; else - return inputPortGroup.length; + return inputPorts.length; } /** - * @return the size of the output port group + * Get the number of output ports (equivalent to getOutputPorts().length) + * @return the number of output ports */ - public int getOutputPortSize() { - if (outputPortGroup == null) + public int getNumberOfOutputPorts() { + if (outputPorts == null) return 0; else - return outputPortGroup.length; + return outputPorts.length; } /** - * @return the whole input port group stored in a LinkedList data structure + * Get the entire array of input ports + * @return the array of FlexotaskPortTemplate objects representing the input ports */ - public LinkedList getInputPortGroup() { - LinkedList inputPortList = new LinkedList(); - for (int i = 0; i < getInputPortSize(); i++) { - inputPortList.add(inputPortGroup[i]); - } - return inputPortList; + public FlexotaskPortTemplate[] getInputPorts() { + return inputPorts; } /** - * @return the whole output port group stored in a LinkedList data structure + * Get the entire array of output ports + * @return the array of FlexotaskPortTemplate objects representing the output ports */ - public LinkedList getOutputPortGroup() { - LinkedList outputPortList = new LinkedList(); - for (int i = 0; i < getOutputPortSize(); i++) { - outputPortList.add(outputPortGroup[i]); - } - return outputPortList; + public FlexotaskPortTemplate[] getOutputPorts() { + return outputPorts; } /** - * Get the the type (class) of the default parameter. The default parameter is passed to the initialize - * method even if no parameter is specified dynamically + * Get the the type (class name) of the default parameter. The default parameter is passed to the initialize + * method if no parameter is specified dynamically * @return the String class name of the default parameter's type or the empty String if unspecified */ public String getParameterType() @@ -187,7 +184,8 @@ /** * Get the value of the default parameter as a string. The default parameter is passed to the initialize - * method even if no parameter is specified dynamically + * method if no parameter is specified dynamically. See {@link #setParameterValue(String)} for the syntax of this + * expression. * @return the parameter, in string format, or the empty String if unspecified */ public String getParameterValue() @@ -195,8 +193,8 @@ return parameterValue != null ? parameterValue : ""; } - /** Test whether this is a weakly isolated exotask. If so, its parameter, if any, must be ref-immutable - * and is not deep-copied. The presence of a weakly isolated exotask in the graph means that all + /** Test whether this is a weakly isolated Flexotask. If so, its parameter, if any, must be ref-immutable + * and is not deep-copied. The presence of a weakly isolated Flexotask in the graph means that all * getstatic checks for the graph will require only ref-immutability and not full immutability. * @return true if weakly isolated, false if strongly isolated */ @@ -208,15 +206,14 @@ /** * Determine if a port of this task is an input port * @param port the port to test as a FlexotaskPortTemplate - * @return true if the given port in this task is indeed an input port in this task - * if this port is not found + * @return true if the given port in this task is indeed an input port in this task, false otherwise */ public boolean isInputPort(FlexotaskPortTemplate port) { boolean foundFlag = false; int i = 0; - if (inputPortGroup != null) { - while (i < inputPortGroup.length && foundFlag == false) { - if (inputPortGroup[i].equals(port)) { + if (inputPorts != null) { + while (i < inputPorts.length && foundFlag == false) { + if (inputPorts[i].equals(port)) { foundFlag = true; } i++; @@ -228,16 +225,14 @@ /** * Determine if a port of this task is an output port * @param port the port to test as a FlexotaskPortTemplate - * @return true if the given port in this task is indeed an output port in this task - * if this port is not found. - * Notice, if this port does not belong in this task at all, the end result would still be false. + * @return true if the given port in this task is indeed an output port in this task, false otherwise */ public boolean isOutputPort(FlexotaskPortTemplate port) { boolean foundFlag = false; - if (outputPortGroup != null) { + if (outputPorts != null) { int i = 0; - while (i < outputPortGroup.length && foundFlag == false) { - if (outputPortGroup[i].equals(port)) { + while (i < outputPorts.length && foundFlag == false) { + if (outputPorts[i].equals(port)) { foundFlag = true; } i++; @@ -267,7 +262,7 @@ /** * Set the the type (class) of the default parameter. The default parameter is passed to the initialize - * method even if no parameter is specified dynamically + * method if no parameter is specified dynamically * @param parameterType the String class name of the default parameter's type */ public void setParameterType(String parameterType) @@ -277,7 +272,7 @@ /** * Set the value expression of the default parameter. The default parameter is passed to the initialize - * method even if no parameter is specified dynamically. In a communicator, the default parameter is used to + * method if no parameter is specified dynamically. In a communicator, the default parameter is used to * initialize the communicator's input and output ports. In any case, the value expression is converted to * an Object as follows * <ol><li>If the parameterType is java.lang.String the parameterValue is used as is @@ -297,8 +292,8 @@ this.parameterValue = parameterValue; } - /** Set whether or not this is a weakly isolated exotask. If set, the exotask's parameter, if any, must be - * ref-immutable and is not deep-copied. The presence of a weakly isolated exotask in the graph means that all + /** Set whether or not this is a weakly isolated Flexotask. If set, the Flexotask's parameter, if any, must be + * ref-immutable and is not deep-copied. The presence of a weakly isolated Flexotask in the graph means that all * getstatic checks for the graph will require only ref-immutability and not full immutability. * @param weaklyIsolated true to set weak isolation, false for strong isolation (the default) */ @@ -326,9 +321,9 @@ { builder.append(getName()).append(".setImplementationClass(\"").append(getImplementationClass()) .append("\");").append(newline); - if (inputPortGroup != null && inputPortGroup.length > 0) { + if (inputPorts != null && inputPorts.length > 0) { String[] inputPortTypes = getInputPortTypes(); - builder.append(getName()).append(".setInputPortGroup(new String[]{"); + builder.append(getName()).append(".setInputPorts(new String[]{"); for (int i = 0; i < inputPortTypes.length; i++) { builder.append("\"").append(inputPortTypes[i]).append("\","); } @@ -386,14 +381,8 @@ ans.setName(getName()); /* Don't copy the timing data or graphics */ ans.setImplementationClass(implementationClass); - ans.setInputPortGroup(inputPortGroup); - ans.setOutputPortGroup(outputPortGroup); -// ans.setInputPortTypes(inputPortTypes); -// ans.setInputPortNames(inputPortNames); -// ans.setInputPortBuffering(inputPortBuffering); -// ans.setOutputPortTypes(outputPortTypes); -// ans.setOutputPortNames(outputPortNames); -// ans.setOutputPortBuffering(outputPortBuffering); + ans.setInputPorts(inputPorts); + ans.setOutputPorts(outputPorts); ans.setWeaklyIsolated(weaklyIsolated); ans.setParameterType(parameterType); ans.setParameterValue(parameterValue); @@ -401,71 +390,74 @@ } /** - * Get the class that should be instantiated as a guard object iff this Flexotask is an AtomicFlexotask. - * This name is deterministic based on the implementation class name. - * @return the name of the guard class + * Set the input ports directly from an array of port templates + * @param inputPorts the input ports as an array of FlexotaskPortTemplate */ - public String getGuard() { - return getImplementationClass() + "$Guard"; + public void setInputPorts(FlexotaskPortTemplate[] inputPorts) { + this.inputPorts = inputPorts; } /** - * set the input port group given a string of port templates - * @param inputPortGroup + * Set the input ports by specifying the types, port buffering property, and names of the ports in separate arrays. + * A useful alternative for tools and generator functions. Arrays must be of the same length, although the buffering and + * names arrays may be null, implying defaults. + * @param inputPortTypes the input port types as class names in the intended index order + * @param inputPortBuffering the input port buffering properties of the ports in the intended index order or null if all ports are + * unbuffered + * @param inputPortNames the input port names in the intended index order or null if all ports have the default generated names + * in0..inN */ - public void setInputPortGroup(FlexotaskPortTemplate[] inputPortGroup) { - this.inputPortGroup = inputPortGroup; - } - - /** - * set the input port group by specifying the three types at the types, buffering, and names in one method. - * Notice they are in a specific order. - */ - public void setInputPortGroup(String[] inputPortTypes, boolean[] inputPortBuffering, String[] inputPortNames) { + public void setInputPorts(String[] inputPortTypes, boolean[] inputPortBuffering, String[] inputPortNames) { if (inputPortBuffering != null && inputPortBuffering.length != inputPortTypes.length) { throw new IllegalArgumentException("Arrays must be of the same length"); } if (inputPortNames != null && inputPortNames.length != inputPortTypes.length) { throw new IllegalArgumentException("Arrays must be of the same length"); } - inputPortGroup = new FlexotaskPortTemplate[inputPortTypes.length]; - for (int i = 0; i < inputPortGroup.length; i++) { + inputPorts = new FlexotaskPortTemplate[inputPortTypes.length]; + for (int i = 0; i < inputPorts.length; i++) { FlexotaskPortTemplate port = new FlexotaskPortTemplate(); port.setPortType(inputPortTypes[i]); port.setPortName(inputPortNames == null ? "in" + i : inputPortNames[i]); - port.setPortBuffer(inputPortBuffering == null ? false : inputPortBuffering[i]); + port.setBuffered(inputPortBuffering == null ? false : inputPortBuffering[i]); port.setContainerTask(this); - inputPortGroup[i] = port; + inputPorts[i] = port; } } /** - * set the output port group given an array of port templates - * @param outputPortGroup the array of port templates to set + * Set the output ports directly from an array of port templates + * @param outputPorts the output ports as an array of FlexotaskPortTemplate */ - public void setOutputPortGroup(FlexotaskPortTemplate[] outputPortGroup) { - this.outputPortGroup = outputPortGroup; + public void setOutputPorts(FlexotaskPortTemplate[] outputPorts) { + this.outputPorts = outputPorts; } /** - * set the output port group by specifying the three types at the types, buffering, and names in one method. - * Notice they are in a specific order. + * Set the output ports by specifying the types, port buffering property, and names of the ports in separate arrays. + * A useful alternative for tools and generator functions. Arrays must be of the same length, although the buffering and + * names arrays may be null, implying defaults. + * @param outputPortTypes the output port types as class names in the intended index order + * @param outputPortBuffering the output port buffering properties of the ports in the intended index order or null if all ports are + * unbuffered + * @param outputPortNames the output port names in the intended index order or null if all ports have the default generated names + * out0..outN */ - public void setOutputPortGroup(String[] outputPortTypes, boolean[] outputPortBuffering, String[] outputPortNames) { + public void setOutputPorts(String[] outputPortTypes, boolean[] outputPortBuffering, String[] outputPortNames) { if (outputPortBuffering != null && outputPortBuffering.length != outputPortTypes.length) { throw new IllegalArgumentException("Arrays must be of the same length"); } if (outputPortNames != null && outputPortNames.length != outputPortTypes.length) { throw new IllegalArgumentException("Arrays must be of the same length"); } - outputPortGroup = new FlexotaskPortTemplate[outputPortTypes.length]; - for (int i = 0; i < outputPortGroup.length; i++) { + outputPorts = new FlexotaskPortTemplate[outputPortTypes.length]; + for (int i = 0; i < outputPorts.length; i++) { FlexotaskPortTemplate port = new FlexotaskPortTemplate(); port.setPortType(outputPortTypes[i]); port.setPortName(outputPortNames == null ? "out" + i : outputPortNames[i]); - port.setPortBuffer(outputPortBuffering == null ? false : outputPortBuffering[i]); + port.setBuffered(outputPortBuffering == null ? false : outputPortBuffering[i]); port.setContainerTask(this); - outputPortGroup[i] = port; + outputPorts[i] = port; } } @@ -475,13 +467,13 @@ */ public String[] getInputPortNames() { - if (inputPortGroup == null) { + if (inputPorts == null) { return new String[0]; } - String[] portNames = new String[inputPortGroup.length]; - for (int i = 0; i < inputPortGroup.length; i++) { - if (inputPortGroup[i].getPortName() != null) - portNames[i] = inputPortGroup[i].getPortName(); + String[] portNames = new String[inputPorts.length]; + for (int i = 0; i < inputPorts.length; i++) { + if (inputPorts[i].getPortName() != null) + portNames[i] = inputPorts[i].getPortName(); else portNames[i] = "in"+i; } @@ -493,22 +485,26 @@ * @return the inputPorts as a (possibly empty) array of strings (never null) */ public String[] getInputPortTypes() { - if (inputPortGroup == null) { + if (inputPorts == null) { return new String[0]; } - String[] portTypes = new String[inputPortGroup.length]; - for (int i = 0; i < inputPortGroup.length; i++) { - portTypes[i] = inputPortGroup[i].getPortType(); + String[] portTypes = new String[inputPorts.length]; + for (int i = 0; i < inputPorts.length; i++) { + portTypes[i] = inputPorts[i].getPortType(); } return portTypes; } - /** return the index of a particular port within this task */ + /** Determine the index of a particular input port within this task + * @param port the port template object whose index is desired + * @return the index of the port if found + * @throws IllegalArgumentException if not found + */ public int getInputPortIndex(FlexotaskPortTemplate port) throws IllegalArgumentException { int i = 0; boolean foundFlag = false; - while (i < inputPortGroup.length && foundFlag == false) { - if (inputPortGroup[i].equals(port)) { + while (i < inputPorts.length && foundFlag == false) { + if (inputPorts[i].equals(port)) { foundFlag = true; } i++; @@ -524,12 +520,12 @@ * @return the array of booleans indicating which of the input ports are buffered */ public boolean[] getInputPortBuffering() { - if (inputPortGroup == null) { + if (inputPorts == null) { return new boolean[0]; } - boolean[] buffering = new boolean[inputPortGroup.length]; - for (int i = 0; i < inputPortGroup.length; i++) { - buffering[i] = inputPortGroup[i].getPortBuffer(); + boolean[] buffering = new boolean[inputPorts.length]; + for (int i = 0; i < inputPorts.length; i++) { + buffering[i] = inputPorts[i].isBuffered(); } return buffering; } @@ -540,13 +536,13 @@ */ public String[] getOutputPortNames() { - if (outputPortGroup == null) { + if (outputPorts == null) { return new String[0]; } - String[] portNames = new String[outputPortGroup.length]; - for (int i = 0; i < outputPortGroup.length; i++) { - if (outputPortGroup[i].getPortName() != null) - portNames[i] = outputPortGroup[i].getPortName(); + String[] portNames = new String[outputPorts.length]; + for (int i = 0; i < outputPorts.length; i++) { + if (outputPorts[i].getPortName() != null) + portNames[i] = outputPorts[i].getPortName(); else portNames[i] = "out"+i; } @@ -558,22 +554,26 @@ * @return the outputPorts as a (possibly empty) array of strings (never null) */ public String[] getOutputPortTypes() { - if (outputPortGroup == null) { + if (outputPorts == null) { return new String[0]; } - String[] portTypes = new String[outputPortGroup.length]; - for (int i = 0; i < outputPortGroup.length; i++) { - portTypes[i] = outputPortGroup[i].getPortType(); + String[] portTypes = new String[outputPorts.length]; + for (int i = 0; i < outputPorts.length; i++) { + portTypes[i] = outputPorts[i].getPortType(); } return portTypes; } - /** return the index of a particular port within this task */ + /** Determine the index of a particular output port within this task + * @param port the port template object whose index is desired + * @return the index of the port if found + * @throws IllegalArgumentException if not found + */ public int getOutputPortIndex(FlexotaskPortTemplate port) throws IllegalArgumentException{ int i = 0; boolean foundFlag = false; - while (i < outputPortGroup.length && foundFlag == false) { - if (outputPortGroup[i].equals(port)) { + while (i < outputPorts.length && foundFlag == false) { + if (outputPorts[i].equals(port)) { foundFlag = true; } i++; @@ -589,12 +589,12 @@ * @return the array of booleans indicating which of the output ports are buffered */ public boolean[] getOutputPortBuffering() { - if (outputPortGroup == null) { + if (outputPorts == null) { return new boolean[0]; } - boolean[] buffering = new boolean[outputPortGroup.length]; - for (int i = 0; i < outputPortGroup.length; i++) { - buffering[i] = outputPortGroup[i].getPortBuffer(); + boolean[] buffering = new boolean[outputPorts.length]; + for (int i = 0; i < outputPorts.length; i++) { + buffering[i] = outputPorts[i].isBuffered(); } return buffering; } Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/template/FlexotaskTemplate.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/template/FlexotaskTemplate.java 2008-11-12 16:40:46 UTC (rev 88) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/template/FlexotaskTemplate.java 2008-11-12 16:41:11 UTC (rev 89) @@ -18,29 +18,70 @@ /** * A specification of an entire graph of Flexotasks, graph inputs, - * graph outputs, and connections. An FlexotaskTemplate is + * graph outputs, and connections. A FlexotaskTemplate is * validated as a whole and instantiated as a whole. The resulting instance is passed * to the scheduler as a whole to obtain the graph's FlexotaskRunner. * This class exists in both a generic and non-generic version depending on the - * level of the Java compiler you are using + * level of the Java compiler you are using. The generic version returns parameterized + * Set and Iterator results instead of raw ones. */ public class FlexotaskTemplate extends AbstractFlexotaskTemplate { + /** Create a new FlexotaskTemplate with no tasks, no connections, no stable classes, no timing data, + * and default values of all properties. + * All templates are built incrementally starting with this constructor. + */ + public FlexotaskTemplate() {} + + /** + * Gets the entire set of connections for this template, as a mutable Set. The result is never null, but + * is empty for a new template and may be added to. + * @return the current set of FlexotaskConnectionTemplate objects describing the connections + */ public Set getConnections() { return getConnectionsImpl(); } + + /** + * Gets the set of connections originating from a particular port, which must be a valid output port of a task in this template + * (else the result will always be empty). The resulting Iterator is not mutable. + * @param task the FlexotaskTaskTemplate describing the originating task + * @param portIndex a zero-origin index into the output ports of the originating task, thereby designating a specific output port + * @return the set of FlexotaskConnectionTemplate objects describing the connections that originate from the given port + */ public Iterator getConnectionsFrom(FlexotaskTaskTemplate task, int portIndex) { return getConnectionsFromImpl(task, portIndex); } + + /** + * Gets the set of connections terminating at a particular port, which must be a valid input port of a task in this template + * (else the result will always be empty). The resulting Iterator is not mutable. + * @param task the FlexotaskTaskTemplate describing the terminating task + * @param portIndex a zero-origin index into the input ports of the originating task, thereby designating a specific input port + * @return the set of FlexotaskConnectionTemplate objects describing the connections that terminate at the given port + */ public Iterator getConnectionsTo(FlexotaskTaskTemplate task, int portIndex) { return getConnectionsToImpl(task, portIndex); } + + /** + * Gets the set of stable classes declared for this template, as a mutable Set. The result is never null, but + * is empty for a new template and may be added to. This set is only significant if the template has had its stable mode + * property set to <b>FlexotaskStableMode.MANUAL</b>. + * @return the current set of stable classes, as fully qualified String class names + */ public Set getStableClasses() { return getStableClassesImpl(); } + + /** + * Gets the set of tasks in this template, as a mutable Set. The result is never null, but + * is empty for a new template and may be added to. + * @return the current set of FlexotaskTaskTemplate objects describing the tasks + */ public Set getTasks() { return getTasksImpl(); Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/timing/simple/SimpleTimingAnnotation.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/timing/simple/SimpleTimingAnnotation.java 2008-11-12 16:40:46 UTC (rev 88) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/timing/simple/SimpleTimingAnnotation.java 2008-11-12 16:41:11 UTC (rev 89) @@ -38,16 +38,29 @@ private Map modeMap; /** - * Construct an empty SimpleTimingAnnotation to be augmented via addMode calls + * Construct an empty SimpleTimingAnnotation to be augmented via addMode calls. This constructor is + * generally only used when there are multiple modes. It allows for incrementally defining the offsets + * that a task has in different modes. */ public SimpleTimingAnnotation() { modeMap = new HashMap(); } + + /** + * Construct a new SimpleTimingAnnotation specifying just an offset. This is the most common + * case when using the single mode variant of the TT timing grammar + * @param offset the offset that this element has within the period (in nanoseconds) + */ + public SimpleTimingAnnotation(long offset) + { + this(new long[]{offset}); + } /** - * Construct a new SimpleTimingAnnotation for the unnamed mode - * @param offsets the offsets that this element has in the overall period + * Construct a new SimpleTimingAnnotation for the unnamed single mode but with multiple offsets. + * This consructor is used when a task or connection is to execute more than one in the period + * @param offsets the offsets that this element has in the overall period (in nanoseconds) */ public SimpleTimingAnnotation(long[] offsets) { Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/tools/FlexotaskXMLParser.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/tools/FlexotaskXMLParser.java 2008-11-12 16:40:46 UTC (rev 88) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/tools/FlexotaskXMLParser.java 2008-11-12 16:41:11 UTC (rev 89) @@ -515,13 +515,13 @@ task = new FlexotaskPredicateTemplate(); } else { task = new FlexotaskTaskTemplate(); - task.setOutputPortGroup(outputClasses, outputPortBuffering, outputNames); + task.setOutputPorts(outputClasses, outputPortBuffering, outputNames); } task.setWeaklyIsolated("weak".equalsIgnoreCase(isolation)); task.setName(id); task.setTimingData(timingData); task.setImplementationClass(implementation); - task.setInputPortGroup(inputClasses, inputPortBuffering, inputNames); + task.setInputPorts(inputClasses, inputPortBuffering, inputNames); if (parameterType.length() > 0) { task.setParameterType(parameterType); } Modified: trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/TaskDiagram.java =================================================================== --- trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/TaskDiagram.java 2008-11-12 16:40:46 UTC (rev 88) +++ trunk/flexotask-editor/src/com/ibm/realtime/flexotask/editor/model/TaskDiagram.java 2008-11-12 16:41:11 UTC (rev 89) @@ -90,7 +90,7 @@ /** The stable classes iff stableMode is MANUAL */ private List<String> stableClasses = new ArrayList<String>(); /** The possible stable modes */ - private FlexotaskStableMode[] stableModes = {FlexotaskStableMode.DEFAULT, FlexotaskStableMode.AUTO, FlexotaskStableMode.MANUAL, FlexotaskStableMode.INFER}; + private FlexotaskStableMode[] stableModes = {FlexotaskStableMode.DEFAULT, FlexotaskStableMode.MARKER, FlexotaskStableMode.MANUAL, FlexotaskStableMode.INFER}; /** The editor-friendly names for the stable modes, in the same order as previous */ private static final String[] stableModeEditorNames = { "all classes stable", "use marker interface", "listed explicitly", "inferred" }; @@ -595,7 +595,7 @@ kind = "flexotask"; /* non-predicate flexotask has output ports, communicating, and admits as well as the usual things */ String[][] outDecls = getPortDecls(task.getOutputPortDeclarations()); - ans.setOutputPortGroup(outDecls[0], getPortBufferingDecls(task.getOutputPortDeclarations()), outDecls[1]); + ans.setOutputPorts(outDecls[0], getPortBufferingDecls(task.getOutputPortDeclarations()), outDecls[1]); } /* all normal flexotasks have name, timing data, input ports, implementation, parameterType, parameterValue, * and isolation */ @@ -603,7 +603,7 @@ ans.setTimingData(getTimingData(task)); ans.setImplementationClass(nonEmpty(task.getImplementation(), "implementation on " + kind)); String[][] inDecls = getPortDecls(task.getInputPortDeclarations()); - ans.setInputPortGroup(inDecls[0], getPortBufferingDecls(task.getInputPortDeclarations()), inDecls[1]); + ans.setInputPorts(inDecls[0], getPortBufferingDecls(task.getInputPortDeclarations()), inDecls[1]); ans.setParameterType(task.getParameterType()); ans.setParameterValue(task.getParameterValue()); ans.setWeaklyIsolated(task.isCommunicating()); Modified: trunk/flexotask-functiontest/src/types/Main.java =================================================================== --- trunk/flexotask-functiontest/src/types/Main.java 2008-11-12 16:40:46 UTC (rev 88) +++ trunk/flexotask-functiontest/src/types/Main.java 2008-11-12 16:41:11 UTC (rev 89) @@ -41,12 +41,12 @@ FlexotaskTaskTemplate source = new FlexotaskTaskTemplate(); source.setName("source"); source.setImplementationClass(DataSource.class.getName()); - source.setOutputPortGroup(new String[] {Object.class.getName()}, null, null); + source.setOutputPorts(new String[] {Object.class.getName()}, null, null); spec.getTasks().add(source); FlexotaskTaskTemplate sink = new FlexotaskTaskTemplate(); sink.setName("sink"); sink.setImplementationClass(DataSink.class.getName()); - sink.setInputPortGroup(new String[] {Object.class.getName()}, null, null); + sink.setInputPorts(new String[] {Object.class.getName()}, null, null); sink.setTimingData(new SimpleTimingAnnotation(new long[]{ 10 * MILLISECOND })); spec.getTasks().add(sink); FlexotaskConnectionTemplate conn = new FlexotaskConnectionTemplate(); Modified: trunk/flexotask-generic/src/com/ibm/realtime/flexotask/template/FlexotaskTemplate.java =================================================================== --- trunk/flexotask-generic/src/com/ibm/realtime/flexotask/template/FlexotaskTemplate.java 2008-11-12 16:40:46 UTC (rev 88) +++ trunk/flexotask-generic/src/com/ibm/realtime/flexotask/template/FlexotaskTemplate.java 2008-11-12 16:41:11 UTC (rev 89) @@ -18,7 +18,7 @@ /** * A specification of an entire graph of Flexotasks, graph inputs, - * graph outputs, and connections. An FlexotaskTemplate is + * graph outputs, and connections. A FlexotaskTemplate is * validated as a whole and instantiated as a whole. The resulting instance is passed * to the scheduler as a whole to obtain the graph's FlexotaskRunner. * This class exists in both a generic and non-generic version depending on the This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |