Wiki

Clone wiki

occam-web / Beginners-Guide / 4.Defining-the-Object-Output

PREVIOUS: Defining the Object Input

Defining the Object Output

We have defined the object configuration options and inputs. Now we will define the output the object produces.

Define the output schema

For easy visualisation and processing, we want our object to output a JSON file that follows a format that OCCAM can understand. For that purpose, we create a schema for the output.

To begin with, create the output schema file output_schema.json:

$ touch ~/occam_workspace/simulator-ExampleSim/output_schema.json

Then, edit the file with your favourite editor and add the following information:

{
    "configurations":[
        {
            "int_config":{
                "units": "Bytes",
                "type": "int"
            },
            "string_config":{
                "type": "string"
            },
            "list_config":{
                "type": "string"
            },
            "bool_config":{
                "type": "boolean"
            }
        }
    ]
}

Compare this schema with the output of our dummy program:

{
    "configurations" :
    [
        {
            "bool_config" : true,
            "int_config" : 2,
            "list_config" : "list",
            "string_config" : "def"
        }
    ]
}

Add the output information to the object description file

Finally, edit the object description file (object.json) and add the following lines:

"outputs": [
    {
        "createIn": "new_output",
        "file": "statistics.json",
        "schema": "output_schema.json",
        "type": "application/json"
    }
]

This tells OCCAM that the object will create a application/json object that contains a file named statistics.json, conforming to the output_schema.json schema, inside a directory named new_output.

Your file should look like this:

{
    "type": "simulator",
    "id": "95fdb476-8984-11e6-8e21-1c1b0d0a9044",
    "name": "ExampleSim",
    "configurations": [
        {
            "schema": "config_schema.json",
            "file": "input.json",
            "name": "Configuration Options"
        }
    ],
    "inputs": [
        {
            "type": "volume"
        }
    ],
    "outputs": [
        {
            "createIn": "new_output",
            "file": "statistics.json",
            "schema": "output_schema.json",
            "type": "application/json"
        }
    ]
}

Commit the new revision

Now we can commit the new revision of the object.

$ git add object.json
$ git add output_schema.json
$ git commit -am "Object now has an output"
$ occam commit

NEXT: Building the Dummy Program

Updated