summaryrefslogtreecommitdiff
path: root/src/navigation/run
blob: cc736860f3365b8c473e9dfcba775948d940df78 (plain)
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
#!/bin/bash

###########################################################################
# @licence app begin@
# SPDX-License-Identifier: MPL-2.0
#
# \copyright Copyright (C) 2013-2014, PCA Peugeot Citroen
#
# \file run
#
# \brief This file is part of the Build System.
#
# \author Martin Schaller <martin.schaller@it-schaller.de>
#
# \version 1.0
#
# This Source Code Form is subject to the terms of the
# Mozilla Public License (MPL), v. 2.0.
# If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
#
# For further information see http://www.genivi.org/.
#
# List of changes:
# 
# 26-6-2014, Marco Residori, Added support of new EnhancedPositionService
# 4-8-2014, Philippe Colliot, Add some wait for dbus service
#
# @licence end@
###########################################################################
function run
{
	local x=$xterm
	local g=$gdb
	local l=$log
	local title="$1"
	shift
	if [ "$1" = "-n" ]
	then
		shift
		x=0
		log=0
	fi
	if [ "$1" = -"g" ]
	then
		shift
		g=0
	fi
	if [ "$x" = 1 ]
	then
		if [ "$g" = 1 ]
		then
			set -- gdb -ex run --args "$@"
		fi
		xterm -T "$title" -sb -sl 5000 -e "$@" &
	elif [ "$log" = 1 ]
	then
		"$@" >"$CUR_DIR/$title.log" 2>&1 &
	else
		"$@" &
	fi
	PIDS="$PIDS $!"
}

function wait_for_service
{
	for i in $(seq 1 50)
	do
		if dbus-send --dest=$1 $2 org.freedesktop.DBus.Introspectable.Introspect
		then
			return
		fi
		echo "Waiting for $1"
		sleep 0.1
	done
}

function terminate
{
	set +e
	trap "" EXIT INT
	kill $PIDS
}

gdb=0
xterm=0
log=0
enhpos=1 #enhanced position server enabled
replayer=0 #replayer disabled
repl=""
verbose=0 #no debug or log messages displayed
center="4612 N 0608 E"
poi=0
speech=0

CUR_DIR=$PWD
BIN_DIR=$CUR_DIR/bin
SRC_DIR=$PWD
LOGREPLAYER_LOGS_DIR=$SRC_DIR/positioning/log-replayer/logs
NAVIT_BIN_DIR=$CUR_DIR/build/navit/navit/

POI_SERVER=poi-server
POI_SERVER_SRC_DIR=$CUR_DIR/../../src/poi-service/$POI_SERVER
POI_SERVER_BIN_DIR=$CUR_DIR/../../src/poi-service/bin
POI_SERVER_RESOURCE_DIR=$CUR_DIR/../../src/poi-service/resource

poidatabase=$POI_SERVER_RESOURCE_DIR/empty.db # empty poi database by default

SPEECH_SERVER=speech-server
SPEECH_OUTPUT_BIN_DIR=$CUR_DIR/../../src/speech-service/bin/

while getopts c:ghnopr:svx opt
do
	case $opt in
	c)
		case "$OPTARG" in
		paris)
			center="2.34 48.86"
			;;
		tokyo)
			center="139.74 35.70"
			;;
		seoul)
			center="126.99 37.54"
			;;
		[0-9-]*)
			center=$OPTARG
			;;
		*)
			echo "Unsupported center $OPTARG" >&2
			exit 1
			;;
		esac
		;;
	g)
		gdb=1
		;;
	n)
		enhpos=0
		;;
	o)
		log=1
		;;
	p)
		poi=1
		;;
	r) #enable the log replayer and set the file
		replayer=1
		repl=$(readlink -f $OPTARG) 
		;;
	s)
		speech=1
		;;
	v) #enable log messages
		verbose=1
		;;
	x)
		xterm=1
		;;
	h)
		echo "Usage:"
		echo "$0 [-c center][-r replayerfile][-gnopsvxh]"
		echo "-c: Set center (supported values: paris,tokyo,seoul,longitude,latitude). Default is geneve"
		echo "-g: Run subprocesses within gdb (only with -x)"
		echo "-h: This help"
		echo "-n: Don't start enhanced-position-service"
		echo "-r: Start replayer"
		echo "-o: Create log file of subprocess output"
		echo "-p: Launch the poi server"
		echo "-s: Launch the speech server"
		echo "-v: Enable the output debug messages"
		echo "-x: Run subprocesses in own xterm to get separated log messages"
		exit 1
	esac
done
trap "terminate" EXIT INT
set -e

echo "the graphic for navit is based on sdl"
export NAVIT_GRAPHICS='sdl'

cd $BIN_DIR

if [ "$enhpos" = 1 ]
then
    run EnhancedPositionService ./enhanced-position-service 
	wait_for_service org.genivi.positioning.EnhancedPosition /org/genivi/positioning/EnhancedPosition

	if [ "$replayer" = 1 ]
	then
		run "Log Replayer" $LOG_REPLAYER_BIN_DIR/$LOG_REPLAYER  $repl
	fi
fi

if [ "$poi" = 1 ]
then
	# start the poi server 
	run "POI service" $POI_SERVER_BIN_DIR/$POI_SERVER -f $poidatabase
fi

if [ "$speech" = 1 ]
then
	# start the speech server 
	run "Speech service" $SPEECH_OUTPUT_BIN_DIR/$SPEECH_SERVER 
fi

cd $NAVIT_BIN_DIR

>bookmark.txt
echo "$center" >center.txt

if [ "$verbose" = "1" ]
then
	run MapViewer ./navit -d 3 -c navit_genivi_mapviewer.xml
else
	run MapViewer ./navit -d 0 -c navit_genivi_mapviewer.xml
fi

wait_for_service org.genivi.mapviewer.Configuration /org/genivi/mapviewer
wait_for_service org.genivi.mapviewer.MapViewerControl /org/genivi/mapviewer
wait_for_service org.genivi.mapviewer.Session /org/genivi/mapviewer

if [ "$verbose" = "1" ]
then
	run NavigationCore ./navit -d 3 -c navit_genivi_navigationcore.xml
else
	run NavigationCore ./navit -d 0 -c navit_genivi_navigationcore.xml
fi

wait_for_service org.genivi.navigationcore.Configuration /org/genivi/navigationcore
wait_for_service org.genivi.navigationcore.Guidance /org/genivi/navigationcore
wait_for_service org.genivi.navigationcore.LocationInput /org/genivi/navigationcore
wait_for_service org.genivi.navigationcore.MapMatchedPosition /org/genivi/navigationcore
wait_for_service org.genivi.navigationcore.Routing /org/genivi/navigationcore
wait_for_service org.genivi.navigationcore.Session /org/genivi/navigationcore

wait