V1_0.java [src/java/m/example/externalexe] Revision: Date:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package m.example.externalexe;
import csip.ModelDataService;
import csip.api.server.Executable;
import csip.annotations.*;
import static csip.annotations.ResourceType.*;
import javax.ws.rs.Path;
/**
* External model service. Invoking the mod.exe model with arguments.
* The stdout.txt file will contain the result.
*
* @author od
*/
@Name("externalexe")
@Description("Example of an external model")
@Path("m/externalexe/1.0")
@Polling(first = 2000, next = 2000)
@Resources({
// resource definition for the mod.exe executable
@Resource(file = "/bin/lin-amd64/mod.exe", id = "mod", type = EXECUTABLE), // arguments in code.
// list all the files (wildcards alowed) that should be captured as output)
@Resource(file = "*stdout.txt *stderr.txt", type = OUTPUT)
})
public class V1_0 extends ModelDataService {
@Override
protected void doProcess() throws Exception {
// get the resource by its 'id'
Executable e = resources().getExe("mod");
// provide arguments
e.setArguments("1", "2", "3");
// execute it
int ret = e.exec();
System.out.println("ret " + ret);
// return thye status. The output
}
}