Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
titleFindPrimes.cnc
borderStylesolid
// Declarations
// The tag values are the odd numbers in the range [3..n]
<string oddNums>;

// The prime numbers as identified by the compute step
[string->int primes];

// Step execution
// The compute step may produce a prime number (in the form of a tag instance)
(compute) -> [primes];

// Step prescription
// For each oddNums instance, there is 
<oddNums> ::  (python compute);


// Input from the environment: initialize all tags
env -> <oddNums>; 

// Output to the environment is the collection of the prime numbers
[primes] -> env;

...

env is a special keyword representing the environment and in this example we define the environment will put string tags into the oddNums Tag Collection and read the results from the primes Item Collection.

After defining the CnC graph, we need to run this file using the CnC-Python translator using the following command:
cnc_t FindPrimes.cnc

Running the command will generate the following directories: hj-cnc-api, sidl, java-client, py-lib, user-code, and hj-main. In short, these are what the directories represent:

Directory Name

Function

hj-cnc-api

Wrapper classes for the HJ-CnC runtime used by Babel while generating SIDL server/client code

sidl

SIDL files used by the program. This includes the SIDL file for the runtime wrapper classes as well as the Step and Item Collections for the current program

java-client

The java client generated from the SIDL files used by the HJ program to call into the python implementation

py-lib

The generated python files that are invoked from the HJ program

user-code

This is the only directory the user should need to edit. It will contain template files for the python Steps as well as an application class to attach start and end event handlers. The even handlers are used to place values from the environment into Item Collections and read results back from Item Collections.

hj-main

The generated HJ files that manages code to make native invocations into the python implementations using the Babel runtime. The user launches the CnC-Python program using a generated script that invokes the generated HJ main class.