Package ptolemy.actor

Examples of ptolemy.actor.TypedAtomicActor


     *  place of the given actor.  Use the given options when
     *  necessary.  The given entity is assumed to be an expression actor.
     */
    public SootClass createAtomicActor(Entity actor, String newClassName,
            ConstVariableModelAnalysis constAnalysis, Map options) {
        TypedAtomicActor entity = (TypedAtomicActor) actor;

        String className = entity.getClass().getName();

        SootClass entityClass = Scene.v().loadClassAndSupport(className);
        entityClass.setLibraryClass();

        // Create a class for the entity instance.
        EntitySootClass entityInstanceClass = new EntitySootClass(entityClass,
                newClassName, Modifier.PUBLIC);
        Scene.v().addClass(entityInstanceClass);
        entityInstanceClass.setApplicationClass();

        // Record everything that the class creates.
        HashMap tempCreatedMap = new HashMap();

        // Populate the method to initialize this instance.
        // We need to put something here before folding so that
        // the folder can deal with it.
        SootMethod initMethod = entityInstanceClass.getInitMethod();

        {
            JimpleBody body = Jimple.v().newBody(initMethod);
            initMethod.setActiveBody(body);

            // return void
            body.getUnits().add(Jimple.v().newReturnVoidStmt());
        }

        SootClass theClass = entityInstanceClass;
        SootClass superClass = theClass.getSuperclass();

        while ((superClass != PtolemyUtilities.objectClass)
                && (superClass != PtolemyUtilities.actorClass)
                && (superClass != PtolemyUtilities.compositeActorClass)) {
            superClass.setLibraryClass();
            try {
                SootUtilities.foldClass(theClass);
            } catch (RuntimeException exception) {
                throw new RuntimeException("Failed to fold \"" + theClass
                        + "\"", exception);
            }
            superClass = theClass.getSuperclass();
        }

        // Go through all the initialization code and remove any old
        // parameter initialization code.  This has to happen after
        // class folding so that all of the parameter initialization
        // is available, but before we add the correct initialization.
        // FIXME: This needs to look at all code that is reachable
        // from a constructor.
        _removeAttributeInitialization(theClass);

        Entity classEntity = null;

        try {
            classEntity = (Entity) ModelTransformer._findDeferredInstance(
                    entity).clone(null);

            // The cloning process results an object that defers change
            // requests.  By default, we do not want to defer change
            // requests, but more importantly, we need to execute
            // any change requests that may have been queued
            // during cloning. The following call does that.
            classEntity.setDeferringChangeRequests(false);
        } catch (Exception ex) {
            ex.printStackTrace();
        }

        ModelTransformer.updateCreatedSet(entity.getFullName(), classEntity,
                classEntity, tempCreatedMap);

        // Create methods that will compute and set the values of the
        // parameters of this actor.
        ModelTransformer.createAttributeComputationFunctions(entity, entity,
View Full Code Here


        List entityList = allAtomicEntityList();
        Iterator entities = entityList.iterator();
        while (entities.hasNext()) {
            Object entity = entities.next();
            if (entity instanceof TypedAtomicActor) {
                TypedAtomicActor actor = (TypedAtomicActor) entity;
                String fullName = actor.getName(this);
                TypedAtomicActor clone = (TypedAtomicActor) cloneConfiguration
                        .getEntity(fullName);
                if (clone == null) {
                    results.append("Actor " + fullName + " was not cloned!");
                } else {

                    List constraints = actor.typeConstraintList();
                    List cloneConstraints = clone.typeConstraintList();

                    // Make sure the clone has the same number of constraints.
                    if (constraints.size() != cloneConstraints.size()) {
                        results.append(actor.getFullName() + " has "
                                + constraints.size() + " constraints that "
                                + "differ from " + cloneConstraints.size()
                                + " constraints its clone has.\n");
                    }

                    // Make sure the constraints are the same.
                    StringBuffer constraintsDescription = new StringBuffer();
                    try {
                        Iterator constraintIterator = constraints.iterator();
                        while (constraintIterator.hasNext()) {
                            Inequality constraint = (Inequality) constraintIterator
                                    .next();
                            constraintsDescription
                                    .append(constraint.toString());
                        }
                    } catch (Throwable throwable) {
                        throw new IllegalActionException(actor, throwable,
                                "Failed to iterate through constraints.");
                    }
                    StringBuffer cloneConstraintsDescription = new StringBuffer();
                    Iterator cloneConstraintIterator = cloneConstraints
                            .iterator();
                    while (cloneConstraintIterator.hasNext()) {
                        Inequality constraint = (Inequality) cloneConstraintIterator
                                .next();
                        cloneConstraintsDescription.append(constraint
                                .toString());
                    }

                    if (!constraintsDescription.toString().equals(
                            cloneConstraintsDescription.toString())) {
                        results
                                .append(actor.getFullName()
                                        + " and its clone do "
                                        + "not have the same constraints:\n"
                                        + constraintsDescription.toString()
                                        + "\nClone:\n"
                                        + cloneConstraintsDescription
                                                .toString() + "\n");
                    }

                    // Check that the type constraint is between ports
                    // and Parameters of the same object.

                    cloneConstraintIterator = cloneConstraints.iterator();
                    while (cloneConstraintIterator.hasNext()) {
                        Inequality constraint = (Inequality) cloneConstraintIterator
                                .next();
                        InequalityTerm greaterTerm = constraint
                                .getGreaterTerm();
                        InequalityTerm lesserTerm = constraint.getLesserTerm();

                        Object greaterAssociatedObject = greaterTerm
                                .getAssociatedObject();
                        Object lesserAssociatedObject = lesserTerm
                                .getAssociatedObject();
                        if (greaterAssociatedObject instanceof NamedObj
                                && lesserAssociatedObject instanceof NamedObj) {
                            // FIXME: what about non-NamedObjs?
                            NamedObj greaterNamedObj = (NamedObj) greaterAssociatedObject;
                            NamedObj lesserNamedObj = (NamedObj) lesserAssociatedObject;
                            if (greaterNamedObj != null
                                    && lesserNamedObj != null
                                    && (greaterNamedObj.getContainer() != lesserNamedObj
                                            .getContainer())) {
                                results
                                        .append(clone.getFullName()
                                                + " has type constraints with "
                                                + "associated objects that don't have "
                                                + "the same container:\n"
                                                + greaterNamedObj.getFullName()
                                                + " has a container:\n"
View Full Code Here

        suboutR.setOutput(true);

        // ---------------------------------
        // Create the actors.
        // ---------------------------------
        TypedAtomicActor lin = null;
        ThresholdMonitor mon1 = null;
        ThresholdMonitor mon2 = null;

        switch (code) {
        case 0: // hover state
            sub.setName("HoverCTSub");
            lin = new HoverLinearizer(sub, "Hover");
            break;

        case 1: // acc state
            sub.setName("AccelCTSub");
            lin = new AccelerLinearizer(sub, "Accel");
            mon1 = new ThresholdMonitor(sub, "Mon1");
            break;

        case 2: // first cruise state
            sub.setName("Cruise1CTSub");
            lin = new CruiseLinearizer(sub, "Cruise1");
            mon1 = new ThresholdMonitor(sub, "Mon1");
            mon2 = new ThresholdMonitor(sub, "Mon2");
            break;

        case 3: // climb state
            sub.setName("ClimbCTSub");
            lin = new ClimbLinearizer(sub, "Climb");
            mon1 = new ThresholdMonitor(sub, "Mon1");
            mon2 = new ThresholdMonitor(sub, "Mon2");
            break;

        case 4: // second cruise state
            sub.setName("Cruise2CTSub");
            lin = new CruiseLinearizer(sub, "Cruise2");

            Parameter param = (Parameter) lin.getAttribute("CPz");
            param.setToken(new DoubleToken(-10.0));
            param = (Parameter) lin.getAttribute("CVx");
            param.setToken(new DoubleToken(5.0));
            break;

        default:
            break;
        }

        /*
         ZeroOrderHold hPx = new ZeroOrderHold(sub, "HPx");
         ZeroOrderHold hDPx = new ZeroOrderHold(sub, "HDPx");
         ZeroOrderHold hDDPx = new ZeroOrderHold(sub, "HDDPx");
         ZeroOrderHold hD3Px = new ZeroOrderHold(sub, "HD3Px");
         ZeroOrderHold hD4Px = new ZeroOrderHold(sub, "HD4Px");
         ZeroOrderHold hPz = new ZeroOrderHold(sub, "HPz");
         ZeroOrderHold hDPz = new ZeroOrderHold(sub, "HDPz");
         ZeroOrderHold hDDPz = new ZeroOrderHold(sub, "HDDPz");
         ZeroOrderHold hD3Pz = new ZeroOrderHold(sub, "HD3Pz");
         ZeroOrderHold hD4Pz = new ZeroOrderHold(sub, "HD4Pz");

         sub.connect(hPx.input, subinPx);
         sub.connect(hDPx.input, subinDPx);
         sub.connect(hDDPx.input, subinDDPx);
         sub.connect(hD3Px.input, subinD3Px);
         sub.connect(hD4Px.input, subinD4Px);

         Relation rInPz = sub.connect(hPz.input, subinPz);
         sub.connect(hDPz.input, subinDPz);
         sub.connect(hDDPz.input, subinDDPz);
         sub.connect(hD3Pz.input, subinD3Pz);
         sub.connect(hD4Pz.input, subinD4Pz);

         sub.connect(hPx.output, (ComponentPort)lin.getPort("inputPx"));
         sub.connect(hDPx.output, (ComponentPort)lin.getPort("inputDPx"));
         sub.connect(hDDPx.output, (ComponentPort)lin.getPort("inputDDPx"));
         sub.connect(hD3Px.output, (ComponentPort)lin.getPort("inputD3Px"));
         sub.connect(hD4Px.output, (ComponentPort)lin.getPort("inputD4Px"));

         sub.connect(hPz.output, (ComponentPort)lin.getPort("inputPz"));
         sub.connect(hDPz.output, (ComponentPort)lin.getPort("inputDPz"));
         sub.connect(hDDPz.output, (ComponentPort)lin.getPort("inputDDPz"));
         sub.connect(hD3Pz.output, (ComponentPort)lin.getPort("inputD3Pz"));
         sub.connect(hD4Pz.output, (ComponentPort)lin.getPort("inputD4Pz"));
         */
        sub.connect(subinPx, (ComponentPort) lin.getPort("inputPx"));
        sub.connect(subinDPx, (ComponentPort) lin.getPort("inputDPx"));
        sub.connect(subinDDPx, (ComponentPort) lin.getPort("inputDDPx"));
        sub.connect(subinD3Px, (ComponentPort) lin.getPort("inputD3Px"));
        sub.connect(subinD4Px, (ComponentPort) lin.getPort("inputD4Px"));

        Relation rInPz = sub.connect(subinPz, (ComponentPort) lin
                .getPort("inputPz"));

        //sub.connect(hPz.output, (ComponentPort)lin.getPort("inputPz"));
        sub.connect(subinDPz, (ComponentPort) lin.getPort("inputDPz"));
        sub.connect(subinDDPz, (ComponentPort) lin.getPort("inputDDPz"));
        sub.connect(subinD3Pz, (ComponentPort) lin.getPort("inputD3Pz"));
        sub.connect(subinD4Pz, (ComponentPort) lin.getPort("inputD4Pz"));

        sub.connect(suboutVx, (ComponentPort) lin.getPort("outputVx"));
        sub.connect(suboutVz, (ComponentPort) lin.getPort("outputVz"));

        Relation rV = sub.connect(suboutV, (ComponentPort) lin
                .getPort("outputV"));
        Relation rR = sub.connect(suboutR, (ComponentPort) lin
                .getPort("outputR"));

        // connect and set the monitors
        Parameter p = null;

View Full Code Here

                        // trick to store the "plain" model name as well,
                        // which can be used for model prefs mgmt etc
                        result.setDisplayName(stepName);
                        result.setDirector(getBatchDirectorClone());

                        final TypedAtomicActor actorInstance = RepositoryManager
                                .getActorRepository().getActorForName(step.getName());

                        final TypedAtomicActor clone = (TypedAtomicActor) actorInstance
                                .clone(result.workspace());
                        clone.setContainer(result);
                        if (clone instanceof TransformerV3) {
                            final TransformerV3 transClone = (TransformerV3) clone;
                            final TransformerV3 transInstance = (TransformerV3) actorInstance;
                            // Field is PUBLIC !!
                            if (transClone.input == null) {
View Full Code Here

                            stepkey = random.nextInt();
                            step.setId(stepkey);
                        }
                        result = new Flow(step.getName() + "_" + stepkey, null);
   
                        TypedAtomicActor actorInstance = RepositoryManager.getActorRepository().getActorForName(
                                step.getName());
   
                        TypedAtomicActor clone = (TypedAtomicActor) actorInstance.clone(result.workspace());
                        clone.setContainer(result);
                        if (clone instanceof TransformerV3) {
                            TransformerV3 transClone = (TransformerV3) clone;
                            TransformerV3 transInstance = (TransformerV3) actorInstance;
                            // Field is PUBLIC !!
                            if (transClone.input == null) {
View Full Code Here

            // trick to store the "plain" model name as well,
            // which can be used for model prefs mgmt etc
            result.setDisplayName(stepName);
            result.setDirector(getBatchDirectorClone());

            final TypedAtomicActor actorInstance = RepositoryManager.getActorRepository().getActorForName(step.getName());

            final TypedAtomicActor clone = (TypedAtomicActor) actorInstance.clone(result.workspace());
            clone.setContainer(result);
            if (clone instanceof TransformerV3) {
              final TransformerV3 transClone = (TransformerV3) clone;
              final TransformerV3 transInstance = (TransformerV3) actorInstance;
              // Field is PUBLIC !!
              if (transClone.input == null) {
View Full Code Here

            // trick to store the "plain" model name as well,
            // which can be used for model prefs mgmt etc
            result.setDisplayName(stepName);
            result.setDirector(getBatchDirectorClone());

            TypedAtomicActor actorInstance = RepositoryManager.getActorRepository().getActorForName(step.getName());

            TypedAtomicActor clone = (TypedAtomicActor) actorInstance.clone(result.workspace());
            clone.setContainer(result);
            if (clone instanceof TransformerV3) {
              TransformerV3 transClone = (TransformerV3) clone;
              TransformerV3 transInstance = (TransformerV3) actorInstance;
              // Field is PUBLIC !!
              if (transClone.input == null) {
View Full Code Here

            // trick to store the "plain" model name as well,
            // which can be used for model prefs mgmt etc
            result.setDisplayName(stepName);
            result.setDirector(getBatchDirectorClone());

            final TypedAtomicActor actorInstance = RepositoryManager.getActorRepository().getActorForName(step.getName());

            final TypedAtomicActor clone = (TypedAtomicActor) actorInstance.clone(result.workspace());
            clone.setContainer(result);
            if (clone instanceof TransformerV3) {
              final TransformerV3 transClone = (TransformerV3) clone;
              final TransformerV3 transInstance = (TransformerV3) actorInstance;
              // Field is PUBLIC !!
              if (transClone.input == null) {
View Full Code Here

                        stepkey = random.nextInt();
                        step.setId(stepkey);
                    }
                    result = new Flow(step.getName() + "_" + stepkey, null);

                    TypedAtomicActor actorInstance = RepositoryManager.getActorRepository().getActorForName(
                            step.getName());

                    TypedAtomicActor clone = (TypedAtomicActor) actorInstance.clone(result.workspace());
                    clone.setContainer(result);
                    if (clone instanceof TransformerV3) {
                        TransformerV3 transClone = (TransformerV3) clone;
                        TransformerV3 transInstance = (TransformerV3) actorInstance;
                        // Field is PUBLIC !!
                        if (transClone.input == null) {
View Full Code Here

              result = new Flow(step.getName() + "_" + stepkey,
                  null);
            }
            // END change Erwin

            TypedAtomicActor actorInstance = RepositoryManager
                .getActorRepository().getActorForName(
                    step.getName());

            TypedAtomicActor clone = (TypedAtomicActor) actorInstance
                .clone(result.workspace());
            clone.setContainer(result);
            if (clone instanceof TransformerV3) {
              TransformerV3 transClone = (TransformerV3) clone;
              TransformerV3 transInstance = (TransformerV3) actorInstance;
              // Field is PUBLIC !!
              if (transClone.input == null) {
View Full Code Here

TOP

Related Classes of ptolemy.actor.TypedAtomicActor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.