rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Data Fields | Static Public Attributes | Private Member Functions | Private Attributes
AcController Class Reference

#include <ac_control.h>

Inheritance diagram for AcController:
Inheritance graph
[legend]
Collaboration diagram for AcController:
Collaboration graph
[legend]

Public Types

using interface_t = AcController
 

Public Member Functions

void onSlowCallback () override
 
virtual bool isAcEnabled () const
 
- Public Member Functions inherited from EngineModule
virtual void initNoConfiguration ()
 
virtual void setDefaultConfiguration ()
 
virtual void onConfigurationChange (engine_configuration_s const *)
 
virtual void onFastCallback ()
 
virtual void onEngineStop ()
 
virtual void onIgnitionStateChanged (bool)
 
virtual bool needsDelayedShutoff ()
 
virtual void onEnginePhase (float, efitick_t, angle_t, angle_t)
 

Data Fields

Timer timeSinceStateChange
 
- Data Fields inherited from ac_control_s
int8_t acButtonState = (int8_t)0
 
uint8_t alignmentFill_at_1 [3] = {}
 
bool m_acEnabled: 1 {}
 
bool engineTooSlow: 1 {}
 
bool engineTooFast: 1 {}
 
bool noClt: 1 {}
 
bool engineTooHot: 1 {}
 
bool tpsTooHigh: 1 {}
 
bool isDisabledByLua: 1 {}
 
bool acCompressorState: 1 {}
 
bool acPressureTooLow: 1 {}
 
bool acPressureTooHigh: 1 {}
 
bool unusedBit_12_10: 1 {}
 
bool unusedBit_12_11: 1 {}
 
bool unusedBit_12_12: 1 {}
 
bool unusedBit_12_13: 1 {}
 
bool unusedBit_12_14: 1 {}
 
bool unusedBit_12_15: 1 {}
 
bool unusedBit_12_16: 1 {}
 
bool unusedBit_12_17: 1 {}
 
bool unusedBit_12_18: 1 {}
 
bool unusedBit_12_19: 1 {}
 
bool unusedBit_12_20: 1 {}
 
bool unusedBit_12_21: 1 {}
 
bool unusedBit_12_22: 1 {}
 
bool unusedBit_12_23: 1 {}
 
bool unusedBit_12_24: 1 {}
 
bool unusedBit_12_25: 1 {}
 
bool unusedBit_12_26: 1 {}
 
bool unusedBit_12_27: 1 {}
 
bool unusedBit_12_28: 1 {}
 
bool unusedBit_12_29: 1 {}
 
bool unusedBit_12_30: 1 {}
 
bool unusedBit_12_31: 1 {}
 

Static Public Attributes

static constexpr int PRESSURE_DEADBAND_WIDTH = 5
 

Private Member Functions

bool getAcState ()
 

Private Attributes

Timer m_timeSinceNoAc
 

Detailed Description

Definition at line 6 of file ac_control.h.

Member Typedef Documentation

◆ interface_t

Definition at line 10 of file ac_control.h.

Member Function Documentation

◆ getAcState()

bool AcController::getAcState ( )
private

Definition at line 16 of file ac_control.cpp.

16 {
18
19 engineTooSlow = rpm < 500;
20
21 if (engineTooSlow) {
22 return false;
23 }
24
25 auto maxRpm = engineConfiguration->maxAcRpm;
26 engineTooFast = maxRpm != 0 && maxRpmDeadband.gt(rpm, maxRpm);
27 if (engineTooFast) {
28 return false;
29 }
30
32
33 noClt = !clt;
34 // No AC with failed CLT
35 if (noClt) {
36 return false;
37 }
38
39 // Engine too hot, disable
40 auto maxClt = engineConfiguration->maxAcClt;
41 engineTooHot = (maxClt != 0) && maxCltDeadband.gt(clt.Value, maxClt);
42 if (engineTooHot) {
43 return false;
44 }
45
46 // TPS too high, disable
47 auto maxTps = engineConfiguration->maxAcTps;
48 tpsTooHigh = maxTps != 0 && maxTpsDeadband.gt(Sensor::getOrZero(SensorType::Tps1), maxTps);
49 if (tpsTooHigh) {
50 return false;
51 }
52
54 if (acPressure.Valid) {
55 const auto minAcPressure = static_cast<float>(engineConfiguration->minAcPressure);
56 acPressureTooLow = minPressureDeadband.lt(acPressure.Value, minAcPressure);
57 if (acPressureTooLow) {
58 return false;
59 }
60
61 const auto maxAcPressure = static_cast<float>(engineConfiguration->maxAcPressure);
62 acPressureTooHigh = acPressureEnableHysteresis.checkIfLimitIsExceeded(
63 acPressure.Value,
64 maxAcPressure,
66 );
68 return false;
69 }
70 }
71
72 if (isDisabledByLua) {
73 return false;
74 }
75
76 // All conditions allow AC, simply pass thru switch
77 return acButtonState;
78}
virtual SensorResult get() const =0
static float getOrZero(SensorType type)
Definition sensor.h:83
static constexpr engine_configuration_s * engineConfiguration
static CCM_OPTIONAL FunctionalSensor clt(SensorType::Clt, MS2NT(10))
acPressure("A/C pressure", SensorCategory.SENSOR_INPUTS, FieldType.INT, 816, 1.0, 0.0, 0.0, "kPa")

Referenced by onSlowCallback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isAcEnabled()

bool AcController::isAcEnabled ( ) const
virtual

Definition at line 101 of file ac_control.cpp.

101 {
102 return m_acEnabled;
103}

◆ onSlowCallback()

void AcController::onSlowCallback ( )
overridevirtual

Reimplemented from EngineModule.

Definition at line 80 of file ac_control.cpp.

80 {
81 bool isEnabled = getAcState();
82
83 m_acEnabled = isEnabled;
84
85 if (!isEnabled) {
86 // reset the timer if AC is off
87 m_timeSinceNoAc.reset();
88 }
89
90 float acDelay = engineConfiguration->acDelay;
91 if (acDelay == 0) {
92 // Without delay configured, enable immediately
93 acCompressorState = isEnabled;
94 } else {
95 acCompressorState = isEnabled && m_timeSinceNoAc.hasElapsedSec(acDelay);
96 }
97
99}
Timer m_timeSinceNoAc
Definition ac_control.h:21
bool getAcState()
RegisteredOutputPin acRelay
Definition efi_gpio.h:90
void setValue(const char *msg, int logicValue, bool isForce=false)
Definition efi_gpio.cpp:604
EnginePins enginePins
Definition efi_gpio.cpp:24
Here is the call graph for this function:

Field Documentation

◆ m_timeSinceNoAc

Timer AcController::m_timeSinceNoAc
private

Definition at line 21 of file ac_control.h.

Referenced by onSlowCallback().

◆ PRESSURE_DEADBAND_WIDTH

constexpr int AcController::PRESSURE_DEADBAND_WIDTH = 5
staticconstexpr

Definition at line 8 of file ac_control.h.

◆ timeSinceStateChange

Timer AcController::timeSinceStateChange

The documentation for this class was generated from the following files: