###### tags: `modern system` # Tripo ## Change Log |ver.|Date|Description|Author| |----|----|----|----| |1.0.0|2020-02-06|The first release|Ruby| ## Category [TOC] --- ## Introduction ![](https://i.imgur.com/A3pc2Zd.png) ## Related Services - [Converto](https://hackmd.io/@Ye0fx7gRQ76VNKwJJyVYdA/SJofhmFM8) - Alerto - Vehicol - Drivo ## Related Collections - [vehicle_statuses](https://dbdiagram.io/d/5e3a227a9e76504e0ef10aa7) - trip_histories - trip_points ## Main Functions ### Maintain vehicle_statuses - vehicle_statuses.tripType - Trip > Receive engine start > Receive during trip (valid L1) and only when tyip type is pakring - Parking > Receive sleep start, keep_alive, tow end - Tow > Receive tow start - Unexpected engine start > Receive unexpected engine start - Long idle end/start > Receive trip restart update as long idle end , then pack vehicle_statuses, update as long idle start with new trip - vehicle_statuses.summary - tripTime > Total duration of this trip is defined as > $\sum_{i=0}^n (reportTime_i - reportTime_{i-1})$ - distance > Total distance of this trip is defined as > $d=(odometer_{i} - odometer_{0})$ - speedinDistance > Total speed distance of this trip is defined as > $\sum_{i=0}^navgVssSpeed_i{\Delta}t$ - gpsDistance > Total gps distance of this trip is defined as > $\sum_{i=0}^n > 2r \cdot arcsin( > \sqrt{ > sin^2(\frac{\alpha_i - \alpha_{i-1}}{2}) + > cos(\alpha_{i-1})cos(\alpha_i) > sin^2(\frac{\beta_i - \beta_{i-1}}{2}) > } > ) \ ,$ > $where \ (i) \ r =radius \ of \ the \ sphere$ > $(ii) \ \alpha = latitude \ of \ point \ in \ radians$ > $(iii) \ \beta = longitude \ of \ point \ in \ radians$ - tripStartTime > Timestamp when start a trip, e.g., engine_on, receive during_trip (valid L1) when current trip type is "Parking", tow_start, trip_restart - tripEndTime > Timestamp when end a trip, e.g., engine_off, tow_end, trip_restart - odoMeterStart > The first valid odometer - odoMeterEnd > Current valid odometer - startLatitude > - startLongitude > - startAddress > - ### Trip Points Creating Tripo creates the [trip points](https://docs.google.com/spreadsheets/d/1Zr9yzV_JxYHf3Yo3zJzW6VpScZVlthe1zxncnZK6IpI/edit?usp=sharing) while one of the following events happends: 1. Receive "engine_start" event 2. Receive "engine_off" event 3. Receive "tow_start" event 4. Receive "tow_end" event 5. Receive "trip_restart" event (end point for current trip, start point for new trip) 6. No new trip point created for more than 1 km 7. No new trip point created for more than 10 mins 8. Heading changes more than 45 degree 9. Event point (manual event created by Alerto) ### Trip History Packaging #### Step-by-step process 1. Check the trip type, where the trip types include: - Trip - Receive engine start - Receive during trip (valid L1) and only when tyip type is pakring - Parking - Receive sleep start, keep_alive, tow end - Tow - Receive tow start - Unexpected engine start - Receive unexpected engine start - Long idle end - Receive trip restart - Long idle start - Receive trip restart 2. Pack the `vehicle_statuses` into `trip_histories`, if the trip type changes. 3. Create a document in `trip_histories` with the value in `vehicle_statuses`, where the [schama](https://docs.google.com/spreadsheets/d/1Zr9yzV_JxYHf3Yo3zJzW6VpScZVlthe1zxncnZK6IpI/edit?usp=sharing) of `vehicle_statuses` and `trip_histories` are totally the same. ### Message Forwarding #### [trip_end event](https://hackmd.io/lAoHZ1KmQm6YHg_x6Os_PA) ###### Step-by-step process 1. Receives the ["sleep_start" event](https://hackmd.io/b3XKz_hYQou7S3Depah19Q) sent from *Converto*. 2. Pack `vehicle_statuses` into `trip_histories` 3. Sends the "trip_end" event to *Vehicol*, and *Drivo* via SQS queue, `{AWS_URL}/tripo_vehicol.fifo` and `{AWS_URL}/tripo_drivo.fifo`. #### [sleep_end event](https://hackmd.io/lAoHZ1KmQm6YHg_x6Os_PA) ###### Step-by-step process 1. Receives the ["engine_start" event](https://hackmd.io/b3XKz_hYQou7S3Depah19Q) sent from *Converto*. 2. Sends the "sleep_end" event to *Devicio* via SQS queue, `{AWS_URL}/tripo_devicio.fifo`.