1 | package de.ugoe.cs.eventbench.commands;
|
---|
2 |
|
---|
3 | import java.security.InvalidParameterException;
|
---|
4 | import java.util.List;
|
---|
5 |
|
---|
6 | import de.ugoe.cs.eventbench.CommandHelpers;
|
---|
7 | import de.ugoe.cs.eventbench.data.GlobalDataContainer;
|
---|
8 | import de.ugoe.cs.eventbench.models.IStochasticProcess;
|
---|
9 | import de.ugoe.cs.util.console.Command;
|
---|
10 | import de.ugoe.cs.util.console.Console;
|
---|
11 |
|
---|
12 | /**
|
---|
13 | * <p>
|
---|
14 | * Command that prints the size of a stochastic process to the console.
|
---|
15 | * </p>
|
---|
16 | *
|
---|
17 | * @author Steffen Herbold
|
---|
18 | * @version 1.0
|
---|
19 | */
|
---|
20 | public class CMDmodelSize implements Command {
|
---|
21 |
|
---|
22 | /*
|
---|
23 | * (non-Javadoc)
|
---|
24 | *
|
---|
25 | * @see de.ugoe.cs.util.console.Command#run(java.util.List)
|
---|
26 | */
|
---|
27 | @Override
|
---|
28 | public void run(List<Object> parameters) {
|
---|
29 | String modelname;
|
---|
30 | try {
|
---|
31 | modelname = (String) parameters.get(0);
|
---|
32 | } catch (Exception e) {
|
---|
33 | throw new InvalidParameterException();
|
---|
34 | }
|
---|
35 |
|
---|
36 | Object dataObject = GlobalDataContainer.getInstance()
|
---|
37 | .getData(modelname);
|
---|
38 | if (dataObject == null) {
|
---|
39 | CommandHelpers.objectNotFoundMessage(modelname);
|
---|
40 | return;
|
---|
41 | }
|
---|
42 | if (!(dataObject instanceof IStochasticProcess)) {
|
---|
43 | CommandHelpers.objectNotType(modelname, "IStochasticProcess");
|
---|
44 | return;
|
---|
45 | }
|
---|
46 |
|
---|
47 | IStochasticProcess process = (IStochasticProcess) dataObject;
|
---|
48 | Console.println("#symbols: " + process.getNumSymbols()
|
---|
49 | + " ; #FOMstates " + process.getNumFOMStates()
|
---|
50 | + " ; #transitions: " + process.getNumTransitions());
|
---|
51 | }
|
---|
52 |
|
---|
53 | /*
|
---|
54 | * (non-Javadoc)
|
---|
55 | *
|
---|
56 | * @see de.ugoe.cs.util.console.Command#help()
|
---|
57 | */
|
---|
58 | @Override
|
---|
59 | public void help() {
|
---|
60 | Console.println("Usage: modelSize <modelName>");
|
---|
61 | }
|
---|
62 |
|
---|
63 | }
|
---|