-
Notifications
You must be signed in to change notification settings - Fork 1
/
MotorController.java
58 lines (53 loc) · 1.87 KB
/
MotorController.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
public class MotorController {
double mFirstCurrent;
double mSecondCurrent;
Contactor mContactor;
int mMotorVoltage;
Battery mBattery;
DCDC_Converter mDCDC_Converter;
CircuitBreaker mCircuitBreaker;
Motor mMotor;
public MotorController(Motor pMotor, Contactor pContactor, Battery pBattery, DCDC_Converter pDCDC_Converter, CircuitBreaker pCircuitBreaker){
mMotor = pMotor;
mMotorVoltage = mMotor.mVoltage;
mContactor = pContactor;
mBattery = pBattery;
mDCDC_Converter = pDCDC_Converter;
mCircuitBreaker = pCircuitBreaker;
}
void firstCurrentInput(double pEnergy) {
if (mContactor.mOpen && mCircuitBreaker.mBreaker == false ) {
if (mMotorVoltage >= mBattery.mMinVoltage && mMotorVoltage <= mBattery.mMaxVoltage) {
mFirstCurrent = pEnergy;
} else {
System.out.println("The battery and motor voltages do not match");
}
} else {
System.out.println("Tried to receive energy from batteries with the contactor closed");
}
}
//Amps = mVoltage / ohms (resistance)
double secondCurrentInput(double pResistance) {
mSecondCurrent = mMotorVoltage / pResistance;
return mSecondCurrent;
}
double outputToMotor() {
double total = mFirstCurrent + mSecondCurrent;
if(total > 220){
mCircuitBreaker.pullBreaker();
total = total - mFirstCurrent;
mCircuitBreaker.resetBreaker();
}
if (mContactor.mOpen == false) {
mFirstCurrent = 0;
}
mSecondCurrent = 0;
mMotor.receiveEnergy(total);
return total;
}
void outputTo12Volt() {
if (mFirstCurrent >= 25) {
mDCDC_Converter.convert(25);
}
}
}