GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: bsgcontrol.c Lines: 14 14 100.0 %
Date: 2023-10-04 02:52:31 Branches: 10 10 100.0 %

Line Branch Exec Source
1
#include "bsgcontrol.h"
2
#include "calibration.h"
3
4
6
StateBSG selectBSGMode(const Vehicle vehicle, const Engine engine, const BSG bsg,
5
                       const Battery battery) {
6
7
6
   StateBSG stateBSG = BSG_IDLE;
8
9
   // BSG_STARTER - Car Starter
10
6
   if (getBatteryState(battery) != BATTERY_DEAD){
11
5
      if (getEngineState(engine) == ENGINE_OFF){
12
2
         if(vehicle.requestCarStart){
13
1
            stateBSG = BSG_STARTER;
14
         }
15
         else{
16
1
            stateBSG = BSG_IDLE;
17
         }
18
      }
19
      else{
20
         // BSG_GENERATOR - Regenerative Breaking
21
3
         if(getDriverIntention(vehicle) == DRIVE_INTENTION_REDUCE_SPEED){
22
1
            stateBSG = BSG_GENERATOR;
23
         }
24
         //BSG_MOTOR - Torque Assistance
25
2
         else if(getDriverIntention(vehicle) == DRIVE_INTENTION_INCREASE_SPEED){
26
1
            stateBSG = BSG_MOTOR;
27
         }
28
         else{
29
            //BSG_IDLE - Energy Saving
30
1
            stateBSG = BSG_IDLE;
31
         }
32
      }
33
   }
34
   else{
35
1
      stateBSG = BSG_IDLE;
36
   }
37
6
   return stateBSG;
38
}