Kepler Hands-On Exercises

Exercise-0: Using Vergil (15 minutes)

--- End of exercise-0 ---

Preparation for programming exercises: (5 minutes)

Exercise-1: Creating your own "HelloWorld" actor (30 minutes)

--- End of exercise-1 ---

Exercise-2: Creating a Scale Actor(30 minutes)

  • Copy Scale.java under your directory and open it with your java editor.
  • Add this file to your package:
    
        package edu.tutorial.%YOUR_DIRECTORY%;
        
    
  • Set the type constraint for the polymorphic output port. Add the following line to the constructor:
    
        // set the type constraints.
        output.setTypeAtLeast(new PortParameterFunction(input, factor));
        
    
  • In the "fire" method, receive the input token from the "input" port.
    
        Token in = input.get(0);
    
    
  • Add the following implementation for the scale function into the scale function.
    
        if (input instanceof ArrayToken) {
          Token[] argArray = ( (ArrayToken) input).arrayValue();
          Token[] result = new Token[argArray.length];
          for (int i = 0; i < argArray.length; i++) {
            result[i] = _scale(argArray[i], factor);
          }
    
          return new ArrayToken(result);
        }
        else {
          return factor.multiply(input);
        }
    
    
  • Call the scale function in the fire method. Add to the fire:
    
          result = _scale(in, factorToken);
          
    
  • Add your actor as an entity under the kepler/tutorial library.
  • Open the "XEqualsFactorY.xml" (2nd workflow from Exercise#0.)
  • Replace the Scale actor with the actor you have just built and run the new model. --- End of exercise-2 ---

    Exercise-3: Creating a Stop Actor using the "manager"(20 minutes)

    --- End of exercise-3 ---

    Exercise-4: Inserting an existing application into Kepler(15 minutes)

    --- End of exercise-4 ---