in lambdas/simulation/pushVehiclePosition/index.py [0:0]
def handler(event, context):
#print(event)
route = route_calculation(event['geoStart'],event['geoEnd'])
if 'Legs' in route:
for step in route['Legs'][0]['Steps']:
if step['DurationSeconds'] >= 200:
div=10
elif step['DurationSeconds'] < 200 and step['DurationSeconds'] >= 100:
div=6
else:
div=4
logger.info("Sleeping: " + str(round(step['DurationSeconds']/div)) + " sec")
sleep(round(step['DurationSeconds']/div))
publish_location(event['id'], event['deliveryAgent']['device']['id'], step['StartPosition'])
logger.info("Sleeping: " + str(round(step['DurationSeconds']/div)) + " sec")
sleep(round(step['DurationSeconds']/div))
publish_location(event['id'], event['deliveryAgent']['device']['id'], step['EndPosition'])
response = {
'statusCode': 200,
'body': 'successfully read items!'
}
return response