Skip to content

Commit

Permalink
FLEXmax detection should no longer throw errors
Browse files Browse the repository at this point in the history
  • Loading branch information
retrodaredevil committed Jan 8, 2023
1 parent f8602a9 commit 336aeea
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
* make sure that the value code you compare with this
* <p>
* Also, it's possible there are undocumented modes such as 27: https://forum.outbackpower.com/viewtopic.php?f=14&t=8268&sid=710ecc3edc75cf26584532c3b93d5aef
* <p>
* For modes such as 27 or 63, it is assumed that an Outback FLEXmax is being used and a Mate with outdated firmware is reporting the aux mode.
* For these situations, you must be careful in parsing the aux mode.
*/
@SuppressWarnings("unused")
public enum AuxMode implements CodeMode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,10 @@ default boolean isNewDay(DailyData previousDailyData){
default int getAuxModeValue() {
return AuxMode.getActualValueCode(getRawAuxModeValue());
}
@GraphQLInclude("auxMode")
@Deprecated
default @NotNull AuxMode getAuxMode(){ return Modes.getActiveMode(AuxMode.class, getAuxModeValue());}
@GraphQLInclude("auxMode")
default @Nullable AuxMode getAuxModeOrNull(){ return Modes.getActiveModeOrNull(AuxMode.class, getAuxModeValue());}
@GraphQLInclude("auxBitActive")
default boolean isAuxBitActive(){ return AuxMode.isAuxModeActive(getRawAuxModeValue()); }

Expand All @@ -162,7 +164,7 @@ default int getAuxModeValue() {

/**
* Should be serialized as "chargerMode"
*
* <p>
* Right now, the range should only be [0..4] as there are no documented charger modes other than those 5
* @return [0..99] representing the MX's {@link ChargerMode}
*/
Expand Down Expand Up @@ -206,9 +208,14 @@ default int getAuxModeValue() {
// endregion

// region Convenience Strings
@Deprecated
default @NotNull String getAuxModeName(){ return getAuxMode().getModeName(); }
@ConvenienceField
@JsonProperty("auxModeName")
default @NotNull String getAuxModeName(){ return getAuxMode().getModeName(); }
default @Nullable String getAuxModeNameOrNull(){
AuxMode auxMode = getAuxModeOrNull();
return auxMode == null ? null : auxMode.getModeName();
}
@ConvenienceField
@JsonProperty("errors")
default @NotNull String getErrorsString(){ return Modes.toString(MXErrorMode.class, getErrorModeValue()); }
Expand All @@ -218,7 +225,6 @@ default int getAuxModeValue() {
// endregion

/**
* Note: It is unknown if this means old MX firmware or old mate firmware
* @return true if the Mate's firmware is pre 4.01, false otherwise
*/
default boolean isOldMateFirmware(){
Expand All @@ -234,12 +240,25 @@ default boolean isOldMateFirmware(){
* @return true if this is a FlexMAX charge controller, false if it's an MX, null if the Mate has old firmware and is unable to tell
*/
default @Nullable Boolean isFlexMax(){
if (isAuxBitActive() || getAuxMode().isFlexMaxOnly() || getAmpChargerCurrent() != 0) {
if (isAuxBitActive() || getAmpChargerCurrent() != 0) {
return true;
}
AuxMode auxMode = getAuxModeOrNull();
boolean oldMateFirmware = isOldMateFirmware();
if (auxMode == null) {
// If we cannot parse the aux mode, then we assume we have an old MATE firmware and it is a FLEXmax.
// If it's a new MATE firmware and we cannot parse the aux mode, we don't know what the heck is going on
return oldMateFirmware ? true : null;
}
if (auxMode.isFlexMaxOnly()) {
return true;
}
if (isOldMateFirmware()) {
// In this case we parsed an auxiliary mode that could be for an MX or for a FLEXmax.
// It is most likely that this is an MX since we were able to parse the aux mode at all, but there's still a chance it is a FLEXmax.
return null;
}
// In this case, we have updated MATE firmware, so it is only an MX device if the daily AH reading is 9999
return getDailyAH() != 9999;
}

Expand Down
63 changes: 62 additions & 1 deletion web/src/generated/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export type Scalars = {
Long: any;
/** Built-in scalar for dynamic values */
ObjectScalar: any;
/** Built-in Short as Int */
Short: any;
/** Use SPQR's SchemaPrinter to remove this from SDL */
UNREPRESENTABLE: any;
};
Expand Down Expand Up @@ -123,6 +125,11 @@ export enum BatteryManagementMode {
VOLTAGE_COMPENSATION = 'VOLTAGE_COMPENSATION'
}

export enum BatteryType {
LEAD_ACID = 'LEAD_ACID',
LITHIUM = 'LITHIUM'
}

export type BatteryVoltage = {
__typename?: 'BatteryVoltage';
/** The battery voltage */
Expand Down Expand Up @@ -161,6 +168,16 @@ export enum ChargingEquipmentError {
PV_INPUT_SHORT = 'PV_INPUT_SHORT'
}

export enum ChargingMethod_E02D {
DIRECT = 'DIRECT',
PWM = 'PWM'
}

export enum ChargingMethod_E021 {
DIRECT = 'DIRECT',
PWM = 'PWM'
}

export enum ChargingState {
ACTIVATED = 'ACTIVATED',
BOOST = 'BOOST',
Expand Down Expand Up @@ -368,6 +385,7 @@ export type ExecutionReason = {
};

export enum ExecutionReasonType {
PACKET_COLLECTION = 'PACKET_COLLECTION',
SOURCE = 'SOURCE'
}

Expand Down Expand Up @@ -672,7 +690,7 @@ export type MXStatusPacket = {
/** @deprecated Field no longer supported */
ampChargerCurrent: Scalars['Float'];
auxBitActive: Scalars['Boolean'];
auxMode: AuxMode;
auxMode?: Maybe<AuxMode>;
auxModeValue: Scalars['Int'];
auxModeValueRaw: Scalars['Int'];
/** The battery voltage */
Expand Down Expand Up @@ -1418,7 +1436,9 @@ export type RoverStatusPacket = {
solarModeName: Scalars['String'];
solarModeType: SolarModeType;
solarModeTypeDisplayName: Scalars['String'];
specialPowerControlE02D?: Maybe<SpecialPowerControl_E02D>;
specialPowerControlE02DRaw?: Maybe<Scalars['Int']>;
specialPowerControlE021?: Maybe<SpecialPowerControl_E021>;
specialPowerControlE021Raw: Scalars['Int'];
streetLightValue: Scalars['Int'];
systemVoltageSetting: Scalars['Int'];
Expand Down Expand Up @@ -1689,6 +1709,42 @@ export type SolarThingStatusQuery = {
tracerStatus: Array<PacketNode_TracerStatusPacket>;
};

export type SpecialPowerControl_E02D = {
__typename?: 'SpecialPowerControl_E02D';
batteryType?: Maybe<BatteryType>;
batteryTypeValueCode: Scalars['Int'];
chargingMethod?: Maybe<ChargingMethod_E02D>;
chargingMethodValueCode: Scalars['Int'];
combined: Scalars['Int'];
combinedShort: Scalars['Short'];
formattedInfo?: Maybe<Scalars['String']>;
is24VSystem: Scalars['Boolean'];
isEachNightOnEnabled: Scalars['Boolean'];
isIntelligentPowerEnabled: Scalars['Boolean'];
isLithiumBattery: Scalars['Boolean'];
isNoChargingBelow0CEnabled: Scalars['Boolean'];
lower: Scalars['Int'];
rawChargingMethodValueCode: Scalars['Int'];
systemVoltage?: Maybe<SystemVoltage>;
systemVoltageValueCode: Scalars['Int'];
upper: Scalars['Int'];
};

export type SpecialPowerControl_E021 = {
__typename?: 'SpecialPowerControl_E021';
chargingMethod?: Maybe<ChargingMethod_E021>;
chargingMethodValueCode: Scalars['Int'];
combined: Scalars['Int'];
combinedShort: Scalars['Short'];
formattedInfo?: Maybe<Scalars['String']>;
isChargingModeControlledByVoltage: Scalars['Boolean'];
isEachNightOnEnabled: Scalars['Boolean'];
isNoChargingBelow0CEnabled: Scalars['Boolean'];
isSpecialPowerControlEnabled: Scalars['Boolean'];
lower: Scalars['Int'];
upper: Scalars['Int'];
};

export type SuccessMateCommandPacket = {
__typename?: 'SuccessMateCommandPacket';
command: MateCommand;
Expand All @@ -1705,6 +1761,11 @@ export enum Support {
UNKNOWN = 'UNKNOWN'
}

export enum SystemVoltage {
V12 = 'V12',
V24 = 'V24'
}

export enum TargetedMetaPacketType {
DATA_INFO = 'DATA_INFO',
DEVICE_INFO = 'DEVICE_INFO',
Expand Down

0 comments on commit 336aeea

Please sign in to comment.