From Optflux
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 92: | Line 92: | ||
##:[[Image:release8.png]] | ##:[[Image:release8.png]] | ||
# To understand the structure and contents of the plugin.xml file, please refer to the [[The_Plugin.xml_File]] section. | # To understand the structure and contents of the plugin.xml file, please refer to the [[The_Plugin.xml_File]] section. | ||
− | #: [[Image:release9.png]] | + | ##: [[Image:release9.png]] |
# Filling the sub-directory structure with rational packages is the next step. Since AIBench/OptFlux development is based on 3 main artifacts we usually sub-divide our java classes by those 3 artifacts. | # Filling the sub-directory structure with rational packages is the next step. Since AIBench/OptFlux development is based on 3 main artifacts we usually sub-divide our java classes by those 3 artifacts. | ||
## This means that '''we should create 3 sub-packages''', one for the OPERATIONS, one for the VIEWS and one for our DATATYPES. | ## This means that '''we should create 3 sub-packages''', one for the OPERATIONS, one for the VIEWS and one for our DATATYPES. | ||
Line 143: | Line 143: | ||
} | } | ||
− | '''@Port(direction=Direction.OUTPUT,order=3)''' ''// use the port annotation with Direction = OUTPUT to note that this is an output of the operation'' | + | '''@Port(direction=Direction.OUTPUT,order=3)''' "''// use the port annotation with Direction = OUTPUT to note that this is an output of the operation''" |
public int result(){ | public int result(){ | ||
return this.x + this.y; | return this.x + this.y; | ||
Line 299: | Line 299: | ||
* The ''@Datatype'' annotation contains several properties that can be specified. Please refer [[Developers#AIBench_Datatypes | here]] for that. | * The ''@Datatype'' annotation contains several properties that can be specified. Please refer [[Developers#AIBench_Datatypes | here]] for that. | ||
− | * You don't need to declare the Datatypes in the '''plugin.xml''' file. | + | * You don't need to declare the Datatypes in the '''plugin.xml''' file. This will be capture automatically by AIBench/OptFlux when used in Operations or placed in the Clipboard. |
== Creating your first View == | == Creating your first View == | ||
Line 366: | Line 366: | ||
Now we will create a more complex operation to interact with the recently created Datatypes and View: | Now we will create a more complex operation to interact with the recently created Datatypes and View: | ||
− | |||
− | |||
The code for the operation goes as follows: | The code for the operation goes as follows: | ||
Line 377: | Line 375: | ||
int[] elements; | int[] elements; | ||
− | @Port(name="Operation",direction=Direction.INPUT,order=1) | + | @Port(name="Operation",direction=Direction.INPUT,order=1) // deciding on the operator to use - INPUT |
public void setOperator(OperationEnumeration operation){ | public void setOperator(OperationEnumeration operation){ | ||
this.operation = operation; | this.operation = operation; | ||
} | } | ||
− | @Port(name="Elements",direction=Direction.INPUT,order=2) | + | @Port(name="Elements",direction=Direction.INPUT,order=2) // defining the list of elements on which to apply the operator - INPUT |
public void setList(int[] elements){ | public void setList(int[] elements){ | ||
this.elements = elements; | this.elements = elements; | ||
} | } | ||
− | @Port(direction=Direction.OUTPUT,order=3) | + | @Port(direction=Direction.OUTPUT,order=3) // the output port (explained bellow) |
public MyComplexDatatype getResult(){ | public MyComplexDatatype getResult(){ | ||
int res = elements[0]; | int res = elements[0]; | ||
Line 403: | Line 401: | ||
List<MySimpleDatatype> listOfSimples = new ArrayList<MySimpleDatatype>(); | List<MySimpleDatatype> listOfSimples = new ArrayList<MySimpleDatatype>(); | ||
for(int elem: elements) | for(int elem: elements) | ||
− | listOfSimples.add(new MySimpleDatatype(elem)); | + | listOfSimples.add(new MySimpleDatatype(elem)); // create a list of MySimpleDatatype, one for each integer |
− | MyListDatatype list = new MyListDatatype(listOfSimples); | + | MyListDatatype list = new MyListDatatype(listOfSimples); // create an instance of MyListDatatype. A wrapper for the list created above |
− | MySimpleDatatype result = new MySimpleDatatype(res); | + | MySimpleDatatype result = new MySimpleDatatype(res); // create an instance of MySimpleDatatype to store the result |
− | MyComplexDatatype toReturn = new MyComplexDatatype(list, operation, result); | + | MyComplexDatatype toReturn = new MyComplexDatatype(list, operation, result); // create an instance of MyComplexDatatype to hold all the the information above |
return toReturn; ''// return the instance of MyComplexDatatype to the Clipboard'' | return toReturn; ''// return the instance of MyComplexDatatype to the Clipboard'' | ||
Line 415: | Line 413: | ||
} | } | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |