summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorphilippe colliot <philippe.colliot@mpsa.com>2014-08-04 18:10:39 +0200
committerphilippe colliot <philippe.colliot@mpsa.com>2014-08-04 18:10:39 +0200
commitb8f0c5930205c111be428c2f6abf3446b9ffa712 (patch)
tree147d70c85104231456e4d44189847262cba38cd8
parentacf7be3da38e08d2666d163646b0a43c2680d3fd (diff)
downloadnavigation-b8f0c5930205c111be428c2f6abf3446b9ffa712.tar.gz
update log-replayer and extend py script
-rw-r--r--src/log-replayer/log-replayer.c38
-rw-r--r--src/script/navigation-service.mk2
-rwxr-xr-xsrc/script/run19
-rw-r--r--test/script/dashboard.pngbin7524 -> 13998 bytes
-rw-r--r--test/script/dashboard.xcfbin30528 -> 49332 bytes
-rw-r--r--test/script/simulation-dashboard.py62
6 files changed, 96 insertions, 25 deletions
diff --git a/src/log-replayer/log-replayer.c b/src/log-replayer/log-replayer.c
index bdc6e2e..efbae50 100644
--- a/src/log-replayer/log-replayer.c
+++ b/src/log-replayer/log-replayer.c
@@ -37,6 +37,14 @@
DLT_DECLARE_CONTEXT(gContext);
+bool running = true;
+
+void sighandler(int sig)
+{
+ LOG_INFO_MSG(gContext,"Signal received");
+ running = false;
+}
+
bool getStrToSend(FILE* file, char* line, int dim)
{
static long unsigned int lastTimestamp = 0;
@@ -65,10 +73,15 @@ bool getStrToSend(FILE* file, char* line, int dim)
if(strchr(line, '#') != 0)
{
- return true; //skip comment line - no impact on delta times
+ line[0] = '\0';
+ return true; //skip comment line
}
- sscanf(line, "%lu", &timestamp);
+ if (!sscanf(line, "%lu", &timestamp))
+ {
+ line[0] = '\0';
+ return true; //skip lines without timestamp
+ }
if(!lastTimestamp)
{
@@ -83,7 +96,7 @@ bool getStrToSend(FILE* file, char* line, int dim)
LOG_DEBUG(gContext,"Waiting %lu ms", delta);
LOG_DEBUG_MSG(gContext,"------------------------------------------------");
- if(delta >= 0)
+ if(timestamp >= lastTimestamp)
{
usleep(delta*1000); // TODO time drift issues
}
@@ -107,6 +120,9 @@ int main(int argc, char* argv[])
char buf[BUFLEN];
char msgId[MSGIDLEN];
+ signal(SIGTERM, sighandler);
+ signal(SIGINT, sighandler);
+
if(argc < 2)
{
LOG_ERROR_MSG(gContext,"missing input parameter: logfile");
@@ -133,7 +149,7 @@ int main(int argc, char* argv[])
//si_other.sin_port = htons(<port number>);
if(inet_aton(IPADDR, &si_other.sin_addr) == 0)
{
- LOG_ERROR_MSG(gContext,"inet_aton() failded!");
+ LOG_ERROR_MSG(gContext,"inet_aton() failed!");
return EXIT_FAILURE;
}
@@ -147,7 +163,7 @@ int main(int argc, char* argv[])
LOG_INFO(gContext,"Started reading log file %s",filename);
- while(1)
+ while(running)
{
if(!getStrToSend(logfile,buf,BUFLEN))
{
@@ -155,12 +171,18 @@ int main(int argc, char* argv[])
return EXIT_FAILURE;
}
+ if (strlen(buf) < 3)
+ {
+ //skip empty lines (includes comments)
+ continue;
+ }
+
sscanf(buf, "%*[^'$']$%[^',']", msgId);
//GNSS: list of supported message IDs
char* gnssstr = "GVGNSVER,GVGNSP,GVGNSC,GVGNSSAC,GVGNSC3D,GVGNSSSAT,GVGNSSUTCT,"
"GVGNSSUTCD";
- if(strstr(gnssstr, msgId) != NULL && buf[0] != '#')
+ if(strstr(gnssstr, msgId) != NULL)
{
LOG_DEBUG(gContext,"Sending Packet to %s:%d",IPADDR,PORT1);
LOG_DEBUG(gContext,"MsgID:%s", msgId);
@@ -179,7 +201,7 @@ int main(int argc, char* argv[])
char* snsstr = "GVSNSVER,GVSNSACC,GVSNSACCCONF,GVSNSGYRO,GVSNSGYROCONF,GVSNSINCL,"
"GVSNSODO,GVSNSREV,GVSNSSLIP,GVSTEER,GVSNSVEHCONF,GVSNSVEHSP,"
"GVSNSVEHST,GVSNSWHTK,GVSNSWHTKCONF,GVSNSWHA,GVSNSWHS,GVSNSDRVDIR,";
- if(strstr(snsstr, msgId) != NULL && buf[0] != '#')
+ if(strstr(snsstr, msgId) != NULL)
{
LOG_DEBUG(gContext,"Sending Packet to %s:%d",IPADDR,PORT2);
LOG_DEBUG(gContext,"MsgID:%s", msgId);
@@ -198,7 +220,7 @@ int main(int argc, char* argv[])
char* vhlstr = "GVVEHVER,GVVEHENGSPEED,GVVEHFUELLEVEL,GVVEHFUELCONS,"
"GVVEHTOTALODO,GVVEHWHRDCONF,GVVEHFRTKWDCONF,GVVEHRRTKWDCONF,"
"GVVEHFRWHBSCONF,GVVEHRRWHBSCONF";
- if(strstr(vhlstr, msgId) != NULL && buf[0] != '#')
+ if(strstr(vhlstr, msgId) != NULL)
{
LOG_DEBUG(gContext,"Sending Packet to %s:%d",IPADDR,PORT3);
LOG_DEBUG(gContext,"MsgID:%s", msgId);
diff --git a/src/script/navigation-service.mk b/src/script/navigation-service.mk
index 8e878fd..5040486 100644
--- a/src/script/navigation-service.mk
+++ b/src/script/navigation-service.mk
@@ -24,7 +24,7 @@
#
# @licence end@
navigation-service_URL="http://git.projects.genivi.org/lbs/navigation.git"
-navigation-service_VERSION=b5d53aec423b420da3249342803bc68a04be7a45
+navigation-service_VERSION=bc2fe3369a425e48064ec507206c2d6410e0543d
navigation-service_SRC=$(SRC_DIR)/navigation-service_$(navigation-service_VERSION)
navigation-service_API=$(navigation-service_SRC)/api
navigation-service_BIN=$(BIN_DIR)/navigation-service
diff --git a/src/script/run b/src/script/run
index 36cbfb2..d1724d1 100755
--- a/src/script/run
+++ b/src/script/run
@@ -193,30 +193,25 @@ 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 !
+#we don't use the replayer used by the navigation core because we still need a plugin for the application !
if [ "$enhpos" = 1 ]
then
run "Navit Plugins" ./run -r -b $BIN_DIR $plugin_args
+ if [ "$replayer" = 1 ]
+ then
+ cd $BIN_DIR/log-replayer
+ run "Log Replayer" ./log-replayer $SRC_DIR/positioning_*/log-replayer/logs/geneve-cologny.log
+ fi
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 ]
diff --git a/test/script/dashboard.png b/test/script/dashboard.png
index d52b84f..9a8f1ec 100644
--- a/test/script/dashboard.png
+++ b/test/script/dashboard.png
Binary files differ
diff --git a/test/script/dashboard.xcf b/test/script/dashboard.xcf
index 8e650a1..d9dcea7 100644
--- a/test/script/dashboard.xcf
+++ b/test/script/dashboard.xcf
Binary files differ
diff --git a/test/script/simulation-dashboard.py b/test/script/simulation-dashboard.py
index e79dab4..e839b8d 100644
--- a/test/script/simulation-dashboard.py
+++ b/test/script/simulation-dashboard.py
@@ -24,12 +24,14 @@
* @licence end@
**************************************************************************
"""
-import sys,tty,termios,select,pygame,gobject,time,dbus,re
+import sys,tty,termios,select,pygame,gobject,time,dbus,re,argparse
from pygame.locals import *
from threading import Timer
from configTests import *
from enum import Enum
+from dbus.mainloop.glib import DBusGMainLoop
+from traceback import print_exc
class Step(Enum):
START = 0
@@ -67,13 +69,21 @@ FUEL_INSTANT_CONSUMPTION_LOCATION = (150,238)
VEHICLE_SPEED_LOCATION = (150,287)
LATITUDE_LOCATION = (64,340)
LONGITUDE_LOCATION = (185,340)
+GUIDANCE_STATUS_LOCATION = (380,238)
+SIMULATION_STATUS_LOCATION = (380,175)
+FUEL_STOP_ADVISOR_WARNING_LOCATION = (380,238)
def display(string,location,fontColor,fontBackground):
+ global args
text = font.render(string, True, fontColor, fontBackground)
textRect = text.get_rect()
textRect.topleft = location
screen.blit(text, textRect)
+def logVerbose(data,value):
+ if args.ver==True:
+ print data,": ",value
+
def displayStatus(string):
display(string,STATUS_LOCATION,WHITE,BLUE)
@@ -82,6 +92,7 @@ def displayStep(string):
def displayEngineSpeed(string):
display(string,ENGINE_SPEED_LOCATION,YELLOW,BLACK)
+ logVerbose("EngineSpeed",string)
def displayFuelLevel(string):
display(string,FUEL_LEVEL_LOCATION,YELLOW,BLACK)
@@ -98,6 +109,15 @@ def displayLatitude(string):
def displayLongitude(string):
display(string,LONGITUDE_LOCATION,YELLOW,BLACK)
+def displayGuidanceStatus(string):
+ display(string,GUIDANCE_STATUS_LOCATION,YELLOW,BLACK)
+
+def displaySimulationStatus(string):
+ display(string,SIMULATION_STATUS_LOCATION,YELLOW,BLACK)
+
+def displayFuelStopAdvisorWarning(string):
+ display(string,FUEL_STOP_ADVISOR_WARNING_LOCATION,YELLOW,BLACK)
+
def refresh():
pygame.display.update()
@@ -163,7 +183,7 @@ def getDbus():
displayVehicleSpeed(str(int(odometer[0])*SPEED_CONVERSION))
# get the geolocation
- geoLocation = enhancedPositionInterface.GetData(dbus.Array([Genivi.ENHANCEDPOSITIONSERVICE_LATITUDE,Genivi.ENHANCEDPOSITIONSERVICE_LONGITUDE,Genivi.ENHANCEDPOSITIONSERVICE_ALTITUDE]))
+ geoLocation = enhancedPositionInterface.GetData(dbus.Array([Genivi.ENHANCEDPOSITIONSERVICE_LATITUDE,Genivi.ENHANCEDPOSITIONSERVICE_LONGITUDE]))
latitude=float(geoLocation[dbus.UInt16(Genivi.ENHANCEDPOSITIONSERVICE_LATITUDE)])
displayLatitude("{:.3f}".format(latitude))
longitude=float(geoLocation[dbus.UInt16(Genivi.ENHANCEDPOSITIONSERVICE_LONGITUDE)])
@@ -176,6 +196,15 @@ def getDbus():
return True
+def fuelStopAdvisorWarningHandler(arg):
+ displayFuelStopAdvisorWarning("F")
+
+
+# Main program begins here
+parser = argparse.ArgumentParser(description='Simulation dashboard for navigation PoC and FSA.')
+parser.add_argument('-v','--ver',action='store_true', help='Print log messages')
+args = parser.parse_args()
+
# Initialize the game engine
pygame.init()
@@ -189,11 +218,20 @@ screen.blit(background,backgroundRect)
font = pygame.font.SysFont('Calibri', 25, True, False)
initDisplay()
+# Initialize DBus loop as the main loop
+DBusGMainLoop(set_as_default=True)
+
# Connect on the bus
+dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
dbusConnectionBus = dbus.SessionBus()
# Automotive message broker
-ambObject = dbusConnectionBus.get_object("org.automotive.message.broker", "/")
+try:
+ ambObject = dbusConnectionBus.get_object("org.automotive.message.broker", "/")
+except dbus.DBusException:
+ print "connection to Automotive message broker failed"
+ print_exc()
+ sys.exit(1)
ambInterface = dbus.Interface(ambObject, "org.automotive.Manager")
# Get the object path to retrieve Engine Speed
@@ -211,11 +249,26 @@ odometerPath = ambInterface.FindObject("Odometer");
ambOdometer = dbusConnectionBus.get_object("org.automotive.message.broker", odometerPath[0])
ambOdometerInterface = dbus.Interface(ambOdometer, "org.automotive.Odometer")
+# Fuel Stop Advisor
+try:
+ fuelStopAdvisorObject = dbusConnectionBus.get_object("org.genivi.demonstrator.FuelStopAdvisor","/org/genivi/demonstrator/FuelStopAdvisor")
+except dbus.DBusException:
+ print "connection to Fuel Stop Advisor failed"
+ print_exc()
+ sys.exit(1)
+fuelStopAdvisorInterface = dbus.Interface(fuelStopAdvisorObject, "org.genivi.demonstrator.FuelStopAdvisor")
+dbusConnectionBus.add_signal_receiver(fuelStopAdvisorWarningHandler, dbus_interface = "org.genivi.demonstrator.FuelStopAdvisor", signal_name = "FuelStopAdvisorWarning")
# Enhanced position
-enhancedPositionObject = dbusConnectionBus.get_object("org.genivi.positioning.EnhancedPosition", "/org/genivi/positioning/EnhancedPosition")
+try:
+ enhancedPositionObject = dbusConnectionBus.get_object("org.genivi.positioning.EnhancedPosition", "/org/genivi/positioning/EnhancedPosition")
+except dbus.DBusException:
+ print "connection to Enhanced position failed"
+ print_exc()
+ sys.exit(1)
enhancedPositionInterface = dbus.Interface(enhancedPositionObject, "org.genivi.positioning.EnhancedPosition")
+
displayStatus( 'Start simulation' )
refresh()
@@ -224,6 +277,7 @@ refresh()
step = Step.START
gobject.timeout_add(KEYBOARD_PERIODICITY,getKeyboard)
gobject.timeout_add(GET_DBUS_PERIODICITY,getDbus)
+
loop = gobject.MainLoop()
loop.run()