Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
cosyverif
Services
service adt2amas
Commits
1c1af04c
Commit
1c1af04c
authored
Dec 09, 2020
by
Jaime Arias
Browse files
add minimal schedulign response
parent
ebfa0a60
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/cosyverif/service/adt2amas/MinimalScheduling.java
View file @
1c1af04c
package
org.cosyverif.service.adt2amas
;
package
org.cosyverif.service.adt2amas
;
import
java.io.BufferedReader
;
import
java.io.BufferedWriter
;
import
java.io.BufferedWriter
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileReader
;
import
java.io.FileWriter
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.nio.file.Paths
;
import
java.nio.file.Paths
;
...
@@ -39,15 +41,18 @@ public class MinimalScheduling extends BinaryService {
...
@@ -39,15 +41,18 @@ public class MinimalScheduling extends BinaryService {
private
Model
modelParameter
;
private
Model
modelParameter
;
@Parameter
(
name
=
"Scheduling Table"
,
@Parameter
(
name
=
"Scheduling Table"
,
help
=
"String parameter help message."
,
help
=
"String parameter help message."
,
direction
=
Direction
.
OUT
,
direction
=
Direction
.
OUT
,
multiline
=
true
)
multiline
=
true
)
private
String
outputParameter
=
""
;
private
String
outputParameter
=
""
;
@Parameter
(
name
=
"Number of graphs"
,
help
=
"String parameter help message."
,
direction
=
Direction
.
OUT
)
private
int
nGraphs
=
0
;
@Launch
@Launch
public
Task
executeBinary
()
throws
IOException
{
public
Task
executeBinary
()
throws
IOException
{
parser
=
GrmlParser
.
create
(
modelParameter
);
parser
=
GrmlParser
.
create
(
modelParameter
);
File
model
=
parser
.
parse
();
final
File
model
=
parser
.
parse
();
String
binaryPath
=
Paths
.
get
(
baseDirectory
().
getAbsolutePath
(),
"adt2amas"
).
toString
();
String
binaryPath
=
Paths
.
get
(
baseDirectory
().
getAbsolutePath
(),
"adt2amas"
).
toString
();
...
@@ -63,7 +68,7 @@ public class MinimalScheduling extends BinaryService {
...
@@ -63,7 +68,7 @@ public class MinimalScheduling extends BinaryService {
@Override
@Override
public
void
fallback
(
String
line
){
public
void
fallback
(
String
line
){
try
{
try
{
outputParameter
=
formatResult
();
outputParameter
=
formatResult
(
model
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
@@ -75,25 +80,58 @@ public class MinimalScheduling extends BinaryService {
...
@@ -75,25 +80,58 @@ public class MinimalScheduling extends BinaryService {
});
});
}
}
private
String
formatResult
()
throws
IOException
{
private
String
formatResult
(
File
modelFile
)
throws
IOException
{
BufferedWriter
bw
=
null
;
BufferedReader
br
=
null
;
FileReader
fr
=
null
;
StringBuffer
s
=
new
StringBuffer
();
String
line
=
""
;
String
match
;
FileWriter
fw
=
null
;
FileWriter
fw
=
null
;
String
result
=
""
;
try
{
try
{
File
fileOutput
=
new
File
(
baseDirectory
().
getAbsolutePath
()
+
"/minimal_scheduling.log"
);
File
fileOutput
=
new
File
(
baseDirectory
().
getAbsolutePath
()
+
"/"
+
modelFile
.
getName
()
+
".log"
);
fw
=
new
FileWriter
(
fileOutput
);
fr
=
new
FileReader
(
fileOutput
);
bw
=
new
BufferedWriter
(
fw
);
br
=
new
BufferedReader
(
fr
);
fw
=
new
FileWriter
(
modelFile
.
getParent
()
+
"/debug.out"
);
fw
.
write
(
"writing output: \n"
);
line
=
br
.
readLine
();
if
(
line
!=
null
)
{
match
=
line
.
substring
(
line
.
indexOf
(
":"
)
+
1
).
trim
();
this
.
nGraphs
=
Integer
.
parseInt
(
match
);
fw
.
append
(
"n graphs: "
+
match
+
"\n"
);
}
while
(
this
.
nGraphs
>
0
&&
(
line
=
br
.
readLine
())
!=
null
)
{
// find a graph info
if
(
line
.
startsWith
(
"Graph #"
)
||
line
.
startsWith
(
"# Agents:"
)
||
line
.
startsWith
(
"# Slots:"
))
{
if
(
line
.
startsWith
(
"#"
))
{
s
.
append
(
" - "
);
}
s
.
append
(
line
);
}
// new graph
if
(
line
==
""
&&
s
.
length
()
!=
0
)
{
s
.
append
(
"\n"
);
}
}
fw
.
append
(
"data:\n"
+
s
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
fw
.
append
(
"error: "
+
e
.
getMessage
()
+
"\n"
);
e
.
printStackTrace
();
e
.
printStackTrace
();
}
finally
{
}
finally
{
if
(
bw
!=
null
)
if
(
br
!=
null
)
bw
.
close
();
br
.
close
();
if
(
fr
!=
null
)
fr
.
close
();
if
(
fw
!=
null
)
if
(
fw
!=
null
)
fw
.
close
();
fw
.
close
();
}
}
return
result
;
return
s
.
toString
()
;
}
}
@Example
(
name
=
"Example of the minimal scheduling algorithm"
,
@Example
(
name
=
"Example of the minimal scheduling algorithm"
,
...
...
src/main/resources/binaries.properties
View file @
1c1af04c
binary-linux
=
https://ci.appveyor.com/api/buildjobs/
0i8yjco6qkfmik50
/artifacts/linux-x86_64.zip
binary-linux
=
https://ci.appveyor.com/api/buildjobs/
3fh7puk3cpb2qn9i
/artifacts/linux-x86_64.zip
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment