Commit 751446dc authored by Jaime Arias's avatar Jaime Arias
Browse files

add first draft of the EAMAS translator service

parent 707331a9
package org.cosyverif.service.adt2amas;
import org.cosyverif.alligator.service.AnnotatedService.Task;
import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
import org.apache.commons.exec.CommandLine;
import org.cosyverif.alligator.service.BinaryService;
import org.cosyverif.alligator.service.Parameter.Direction;
import org.cosyverif.alligator.service.annotation.Example;
import org.cosyverif.alligator.service.annotation.Launch;
import org.cosyverif.alligator.service.annotation.Parameter;
import org.cosyverif.alligator.service.annotation.Service;
import org.cosyverif.alligator.service.output.ParameterOutputHandler;
import org.cosyverif.model.Model;
@Service(name = "EAMAS Translator",
help = "Translates an ADTree model into its EAMAS model",
version = "1.0.0",
tool = "adt2amas",
authors = {
"Jaime Arias",
"Laure Petrucci",
"Wojciech Penczek",
"Teofil Sidoruk"
},
keywords = {})
public class EAMASTranslation extends BinaryService{
GrmlParser parser;
@Parameter(name = "Model parameter",
help = "Attack-Defence Tree model",
direction = Direction.IN,
formalism = "http://formalisms.cosyverif.org/adtree.fml")
private Model modelParameter;
@Parameter(name = "LaTeX file",
help = "LaTeX file of the EAMAS model",
direction = Direction.OUT,
contenttype = "plain/text")
private File latexFile = null;
@Parameter(name = "IMITATOR file",
help = "IMITATOR file of the EAMAS model",
direction = Direction.OUT,
contenttype = "plain/text")
private File imitatorFile = null;
@Launch
public Task executeBinary() throws IOException {
parser = GrmlParser.create(modelParameter);
final File model = parser.parse();
String binaryPath = Paths.get(baseDirectory().getAbsolutePath(), "adt2amas").toString();
final File runnable = new File(binaryPath);
runnable.setExecutable(true);
final CommandLine command = new CommandLine("./adt2amas");
command.addArguments("transform --model " + model.getName());
return task(command)
.workingDirectory(baseDirectory())
.out(new ParameterOutputHandler(this){
@Override
public void fallback(String line){
try{
getOutputFiles(model);
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void fallback(String key, String value) {
}
});
}
private void getOutputFiles(File modelFile) throws IOException {
}
@Example(name = "Example of the minimal scheduling algorithm",
help = "Example of the minimal scheduling algorithm")
public EAMASTranslation example() {
EAMASTranslation result = new EAMASTranslation();
result.modelParameter = loadModelResource("treasure-hunters.grml");
return result;
}
}
......@@ -3,7 +3,6 @@ package org.cosyverif.service.adt2amas;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
......@@ -11,12 +10,9 @@ import java.io.FilenameFilter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import org.apache.commons.compress.archivers.zip.Zip64ExtendedInformationExtraField;
import org.apache.commons.exec.CommandLine;
import org.cosyverif.alligator.service.AnnotatedService.Task;
......@@ -30,13 +26,15 @@ import org.cosyverif.alligator.service.output.ParameterOutputHandler;
import org.cosyverif.model.Model;
@Service(name = "Minimal Schedule with Minimal Number of Agents in Attack-Defence Trees",
@Service(name = "Minimal Scheduling",
help = "Computes the minimal attack time using minimal number of agents for a given attack-defence tree",
version = "0.1",
version = "1.0.0",
tool = "adt2amas",
authors = {
"Jaime Arias",
"Laure Petrucci",
"Wojciech Penczek",
"Teofil Sidoruk"
},
keywords = {})
public class MinimalScheduling extends BinaryService {
......@@ -48,7 +46,8 @@ public class MinimalScheduling extends BinaryService {
formalism = "http://formalisms.cosyverif.org/adtree.fml")
private Model modelParameter;
@Parameter(name = "Scheduling Information", help = "Scheduling information for each generated graph.",
@Parameter(name = "Scheduling Information",
help = "Scheduling information for each generated graph.",
direction = Direction.OUT,
multiline = true)
private String outputParameter = "";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment