summaryrefslogtreecommitdiff
path: root/src/script/run
blob: 36cbfb22c320d73a29e3c4f485dd8138ffee2ce4 (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
238
239
240
#! /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 # 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:
# 
# <date>, <name>, <description of change>
#
# @licence end@
###########################################################################

function run
{
	local x=$xterm
	local g=$gdb
	local l=$log
	title="$1"
	shift

	if [ "$1" = "-n" ]
	then
		shift
		x=0
		l=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 [ "$l" = 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 2>/dev/null
	if [ "$gdb" = 1 ]
	then
		kill $PIDS 2>/dev/null
	fi
	if [ -n "$wm" ]
	then
		sleep 2
		cd
		nohup $wm >/dev/null 2>/dev/null &
	fi
}

CUR_DIR=$PWD
BIN_DIR=$PWD/../../bin
SRC_DIR=$PWD/..
gdb=0
xterm=0
log=0
enhpos=1
lm=0
prototyping=0
replayer=1
wm=""
app=$SRC_DIR/hmi/qml/application.qml
popup=$SRC_DIR/hmi/qml/pop-up.qml

while getopts a:c:glnoprx opt
do
	case $opt in
	a)
		app=$OPTARG
		;;
	c)
		plugin_args="$plugin_args -$opt $OPTARG"
		;;
	g)
		plugin_args="$plugin_args -$opt"
		gdb=1
		;;
	l)
		lm=1
		;;
	n)
		enhpos=0
		plugin_args="$plugin_args -$opt"
		;;
	o)
		plugin_args="$plugin_args -$opt"
		log=1
		;;
	p)
		prototyping=1
		;;
	r)
		replayer=0
		;;
	x)
		plugin_args="$plugin_args -$opt"
		xterm=1
		;;
	\?)
		echo "Usage:"
		echo "$0 [-a application][-c center][-glnoprx]"
		echo "-a: Set application (default application.qml)"
		echo "-c: Set center (supported values: paris,tokyo,longitude latitude). Default is geneve"
		echo "-g: Run subprocesses within gdb (only with -x)"
		echo "-l: Use layermanager"
		echo "-n: Don't start enhanced positioning service"
		echo "-o: Create log file of subprocess output"
		echo "-p: Prototyping"
		echo "-r: Don't start replayer"
		echo "-x: Run subprocesses in own xterm to get separated log messages (doesn't make sense with -l)"
		exit 1
	esac
done

REPLAYER_LOG_FILE=none
export REPLAYER_LOG_FILE

if [ "$lm" = "1" ]
then
	for i in metacity compiz
	do
		if pidof $i
		then
			killall $i
			while pidof $i
			do
				echo "Waiting for termination of $i"
				sleep 1
			done
			wm="$i"
			break
		fi
	done
	set -e
	export LM_USE_SESSION_BUS=enable
	PATH=$PWD/../bin/layer_management/inst/usr/local/bin:$PWD/../bin/libqtlayerman/lmqmlviewer:$PATH
	export LD_LIBRARY_PATH=$PWD/../bin/layer_management/inst/usr/local/lib:$PWD/../bin/libqtlayerman/src
	export LM_PLUGIN_PATH=$PWD/../bin/layer_management/inst/usr/local/lib/layermanager
	LayerManagerService  &
	lm_pid=$!
	sleep 2
fi
export | egrep " LM_PLUGIN_PATH=|LM_USE_SESSION_BUS=| DBUS_SESSION_BUS_ADDRESS=| LD_LIBRARY_PATH=| PATH=| DISPLAY=" >env.sh
trap "terminate" EXIT INT
set -e

cd $BIN_DIR/automotive-message-broker
run "Automotive Message Broker" ./ambd/ambd --config $SRC_DIR/genivilogreplayer/logreplayerconfig
wait_for_service org.automotive.message.broker /
sleep 2

if [ "$enhpos" = 1 ]
then
	if [ "$replayer" = 1 ]
	then
		cd $BIN_DIR/log-replayer
		run "Log Replayer" ./log-replayer $SRC_DIR/positioning_*/log-replayer/logs/geneve-cologny.log
	fi
fi

cd $BIN_DIR/poi-service
run "POI service" ./poi-server -f empty.db

wait_for_service org.genivi.poiservice.POISearch /org/genivi/poiservice/POISearch

cd $SRC_DIR/navigation-service*/src/navigation/script
#we don't use the replayer used by the navigation core because we need a plugin for the application !
if [ "$enhpos" = 1 ]
then
	run "Navit Plugins" ./run -r -b $BIN_DIR $plugin_args
else
	run "Navit Plugins" ./run -rn -b $BIN_DIR $plugin_args
fi
run "Fuel Stop Advisor" $BIN_DIR/fuel-stop-advisor/fuel-stop-advisor

if [ "$log" = 1 ]
then
	exec >$CUR_DIR/qmlviewer.log
	exec 2>&1
fi

cd $BIN_DIR/hmi/qml
if [ "$lm" = 1 ]
then
	lmqmlviewer $app
else
if [ "$prototyping" = 1 ]
then
	./hmi-launcher $app $popup
else
	./hmi-launcher $app 
fi
fi