-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
143 lines (131 loc) · 4.3 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
package main
import (
"fmt"
"log"
"os"
"os/exec"
"strings"
_ "embed"
g "github.com/AllenDang/giu"
)
//go:embed bonnmotion_settings.txt
var theoneConfig string
func onRun() {
fmt.Println("Run")
var fout string
if filename == "" {
fout = "move"
} else {
fout = filename
}
convertToOne(fout)
one_cfg := strings.Replace(theoneConfig, "Scenario.endTime = DURATION", fmt.Sprintf("Scenario.endTime = %v", duration), 1)
one_cfg = strings.Replace(one_cfg, "NODES", fmt.Sprintf("%v", num_nodes), 1)
one_cfg = strings.Replace(one_cfg, "WIDTH", fmt.Sprintf("%v", width), 1)
one_cfg = strings.Replace(one_cfg, "HEIGHT", fmt.Sprintf("%v", height), 1)
one_cfg = strings.Replace(one_cfg, "FILENAME", fmt.Sprintf("%v.one", fout), 1)
//fmt.Println(one_cfg)
file, err := os.Create("one_settings.txt")
if err != nil {
log.Fatal(err)
}
file.WriteString(one_cfg)
file.Close()
fmt.Println(file.Name())
cmd := exec.Command("one.sh", file.Name())
err = cmd.Start()
if err != nil {
fmt.Println(err)
}
}
func loop() {
g.SingleWindow().Layout(
g.Label("DarMotion"),
g.InputText(&filename).Label("filename"),
g.Combo("format", formats[selected], formats, &selected),
g.Spacing(),
g.Row(
g.Checkbox("batch", &batch),
g.InputInt(&reps).Size(100).Label("reptitions"),
),
g.Spacing(),
g.Separator(),
g.Spacing(),
g.InputInt(&num_nodes).Size(100).Label("nodes"),
g.InputInt(&duration).Size(100).Label("duration in seconds"),
g.InputInt(&skip).Size(100).Label("seconds to skip"),
g.Row(
g.InputInt(&width).Size(100),
g.Label("x"),
g.InputInt(&height).Size(100).Label("area in m^2"),
),
g.Spacing(),
g.TabBar().TabItems(
g.TabItem("Random Waypoint").Layout(
g.Spacing(),
//g.Label("Random Waypoint Model"),
g.Row(
g.Button("Generate").OnClick(onGenerateRandomWaypoint),
g.Button("Run").OnClick(onRun),
),
g.Spacing(),
g.InputInt(&rwp.min_speed).Size(100).Label("min speed"),
g.InputInt(&rwp.max_speed).Size(100).Label("max speed"),
g.InputInt(&rwp.max_pause).Size(100).Label("max pause"),
//g.InputTextMultiline(&multiline).Size(g.Auto, g.Auto),
),
g.TabItem("SMOOTH").Layout(
g.Spacing(),
//g.Label("SMOOTH Mobility Model"),
g.Row(
g.Button("Generate").OnClick(onGenerateSMOOTH),
g.Button("Run").OnClick(onRun),
),
g.Spacing(),
g.InputInt(&smooth.comm_range).Size(100).Label("range"),
g.InputInt(&smooth.clusters).Size(100).Label("clusters"),
g.InputFloat(&smooth.alpha).Size(100).Label("alpha"),
g.InputInt(&smooth.f_min).Size(100).Label("f_min"),
g.InputInt(&smooth.f_max).Size(100).Label("f_max"),
g.InputFloat(&smooth.beta).Size(100).Label("beta"),
g.InputInt(&smooth.p_min).Size(100).Label("p_min"),
g.InputInt(&smooth.p_max).Size(100).Label("p_max"),
),
g.TabItem("SWIM").Layout(
g.Spacing(),
//g.Label("SWIM Mobility Model"),
g.Row(
g.Button("Generate").OnClick(onGenerateSWIM),
g.Button("Run").OnClick(onRun),
),
g.Spacing(),
g.InputFloat(&swim.radius).Size(100).Label("radius"),
g.InputFloat(&swim.cell_distance).Size(100).Label("cell distance weight"),
g.InputFloat(&swim.node_speed).Size(100).Label("node speed multiplier"),
g.InputFloat(&swim.wait_time_exp).Size(100).Label("waiting time exponent"),
g.InputFloat(&swim.wait_time_upper_bound).Size(100).Label("waitng time upper bound"),
),
g.TabItem("SLAW").Layout(
g.Spacing(),
g.Row(
g.Button("Generate").OnClick(onGenerateSLAW),
g.Button("Run").OnClick(onRun),
),
g.Spacing(),
g.InputInt(&slaw.num_waypoints).Size(100).Label("number of waypoints"),
g.InputInt(&slaw.min_pause).Size(100).Label("minimum pause time"),
g.InputInt(&slaw.max_pause).Size(100).Label("maximum pause time"),
g.InputFloat(&slaw.levy_exp).Size(100).Label("levy exponent for pause time"),
g.InputFloat(&slaw.hurst).Size(100).Label("hurst parameter for self-similarity of waypoints"),
g.InputFloat(&slaw.dist_weight).Size(100).Label("distance weight"),
g.InputInt(&slaw.clustering_range).Size(100).Label("clustering range (meter)"),
g.InputFloat(&slaw.cluster_ratio).Size(100).Label("cluster ratio"),
g.InputFloat(&slaw.waypoint_ratio).Size(100).Label("waypoint ratio"),
),
),
)
}
func main() {
wnd := g.NewMasterWindow("DarMotion", 800, 600, 0)
wnd.Run(loop)
}