1 | package com.framsticks.running; |
---|
2 | |
---|
3 | |
---|
4 | |
---|
5 | import com.framsticks.params.ParamFlags; |
---|
6 | import com.framsticks.params.annotations.FramsClassAnnotation; |
---|
7 | import com.framsticks.params.annotations.ParamAnnotation; |
---|
8 | import com.framsticks.util.lang.Strings; |
---|
9 | |
---|
10 | @FramsClassAnnotation |
---|
11 | public class FramsServer extends ExternalProcess { |
---|
12 | |
---|
13 | protected Integer port; |
---|
14 | protected String path; |
---|
15 | protected String expdef; |
---|
16 | |
---|
17 | /** |
---|
18 | * |
---|
19 | */ |
---|
20 | public FramsServer() { |
---|
21 | super(); |
---|
22 | setCommand("frams.linux"); |
---|
23 | setPath("opt/framsticks"); |
---|
24 | setName("frams"); |
---|
25 | } |
---|
26 | |
---|
27 | |
---|
28 | /** |
---|
29 | * @return the port |
---|
30 | */ |
---|
31 | @ParamAnnotation(flags = ParamFlags.USERREADONLY) |
---|
32 | public Integer getPort() { |
---|
33 | return port; |
---|
34 | } |
---|
35 | |
---|
36 | /** |
---|
37 | * @param port the port to set |
---|
38 | */ |
---|
39 | @ParamAnnotation |
---|
40 | public void setPort(Integer port) { |
---|
41 | this.port = port; |
---|
42 | } |
---|
43 | |
---|
44 | /** |
---|
45 | * @return the path |
---|
46 | */ |
---|
47 | @ParamAnnotation(flags = ParamFlags.USERREADONLY) |
---|
48 | public String getPath() { |
---|
49 | return path; |
---|
50 | } |
---|
51 | |
---|
52 | /** |
---|
53 | * @param path the path to set |
---|
54 | */ |
---|
55 | @ParamAnnotation |
---|
56 | public void setPath(String path) { |
---|
57 | this.path = path; |
---|
58 | setDirectory(path); |
---|
59 | } |
---|
60 | |
---|
61 | /** |
---|
62 | * @return the expdef |
---|
63 | */ |
---|
64 | @ParamAnnotation(flags = ParamFlags.USERREADONLY) |
---|
65 | public String getExpdef() { |
---|
66 | return expdef; |
---|
67 | } |
---|
68 | |
---|
69 | /** |
---|
70 | * @param expdef the expdef to set |
---|
71 | */ |
---|
72 | @ParamAnnotation |
---|
73 | public void setExpdef(String expdef) { |
---|
74 | this.expdef = expdef; |
---|
75 | } |
---|
76 | |
---|
77 | @Override |
---|
78 | protected void joinableStart() { |
---|
79 | if (port != null) { |
---|
80 | arguments.add("-n"); |
---|
81 | arguments.add("-p" + port); |
---|
82 | } |
---|
83 | if (Strings.notEmpty(expdef)) { |
---|
84 | arguments.add("Simulator.expdef=\"" + expdef + "\";"); |
---|
85 | } |
---|
86 | // log.debug("running {} with arguments {}", getCommand(), arguments); |
---|
87 | super.joinableStart(); |
---|
88 | } |
---|
89 | |
---|
90 | } |
---|