-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into webpack-update
- Loading branch information
Showing
34 changed files
with
516 additions
and
349 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/app/Marine2/components/boxes/EnergyConnectedGenset/EnergyConnectedGenset.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import GeneratorIcon from "../../../images/icons/generator.svg" | ||
import { ConnectedGensetType, useAppStore, useConnectedGenset } from "@victronenergy/mfd-modules" | ||
import { translate } from "react-i18nify" | ||
import ValueBox from "../../ui/ValueBox" | ||
import ValueOverview from "../../ui/ValueOverview" | ||
import { ComponentMode } from "@m2Types/generic/component-mode" | ||
import { responsiveBoxIcon } from "../../../utils/helpers/classes/responsive-box-icon" | ||
import { ISize } from "@m2Types/generic/size" | ||
import { valueFor } from "app/Marine2/utils/formatters/phase/phase-value-for" | ||
import { unitFor } from "app/Marine2/utils/formatters/phase/phase-unit-for" | ||
import { observer } from "mobx-react" | ||
|
||
interface Props { | ||
gensetType: ConnectedGensetType | ||
gensetInstance: number | ||
showInstance: boolean | ||
componentMode?: ComponentMode | ||
compactBoxSize?: ISize | ||
} | ||
|
||
const EnergyConnectedGenset = ({ | ||
componentMode = "compact", | ||
gensetType, | ||
gensetInstance, | ||
showInstance, | ||
compactBoxSize, | ||
}: Props) => { | ||
const { electricalPowerIndicator } = useAppStore() | ||
const gensetValues = useConnectedGenset(gensetType, gensetInstance) | ||
const instance = showInstance ? ` [${gensetInstance}]` : "" | ||
|
||
if (gensetValues.gensetType === ConnectedGensetType.ACGENSET) { | ||
// TODO: We do not support displaying connected AC Genset | ||
// TODO: on the EnergyOverview page | ||
return null | ||
} | ||
|
||
if (gensetValues.gensetType === ConnectedGensetType.DCGENSET) { | ||
const { customName, productName, current, voltage } = gensetValues | ||
const power = voltage * current | ||
|
||
if (componentMode === "compact" && compactBoxSize) { | ||
return ( | ||
<ValueOverview | ||
Icon={GeneratorIcon} | ||
title={customName || productName || translate("boxes.generator")} | ||
value={valueFor(current, power, electricalPowerIndicator)} | ||
unit={unitFor(electricalPowerIndicator)} | ||
boxSize={compactBoxSize} | ||
/> | ||
) | ||
} | ||
|
||
return ( | ||
<ValueBox | ||
title={customName || productName || translate("boxes.generator") + instance} | ||
icon={<GeneratorIcon className={responsiveBoxIcon} />} | ||
value={valueFor(current, power, electricalPowerIndicator)} | ||
unit={unitFor(electricalPowerIndicator)} | ||
bottomValues={[ | ||
[ | ||
{ value: voltage, unit: "V", hideDecimal: true }, | ||
{ value: current, unit: "A", hideDecimal: true }, | ||
{ value: power, unit: "W", hideDecimal: true }, | ||
], | ||
]} | ||
/> | ||
) | ||
} | ||
} | ||
|
||
export default observer(EnergyConnectedGenset) |
2 changes: 2 additions & 0 deletions
2
src/app/Marine2/components/boxes/EnergyConnectedGenset/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { default } from "./EnergyConnectedGenset" | ||
export * from "./EnergyConnectedGenset" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.