Skip to content

Commit 7aac8f2

Browse files
committed
wip dilution for calibration
1 parent f9272a5 commit 7aac8f2

File tree

5 files changed

+100
-4
lines changed

5 files changed

+100
-4
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import type React from "react";
2+
3+
import { Select, SelectItem } from "@heroui/select";
4+
5+
import { siteConfig } from "@/config/site";
6+
7+
interface ConcentrationSelectorProps {
8+
label?: string;
9+
selectedConcentration: number;
10+
onConcentrationChange: (concentration: number) => void;
11+
}
12+
13+
export const ConcentrationSelector: React.FC<ConcentrationSelectorProps> = ({
14+
label,
15+
selectedConcentration,
16+
onConcentrationChange,
17+
}) => {
18+
return (
19+
<Select
20+
aria-label="Concentration Values"
21+
className="max-w-xs"
22+
label={label}
23+
labelPlacement="outside-left"
24+
selectedKeys={new Set([selectedConcentration.toString()])}
25+
selectionMode="single"
26+
variant="flat"
27+
onSelectionChange={(keys) => {
28+
const concentration = parseFloat(keys.currentKey as string);
29+
30+
if (!isNaN(concentration)) {
31+
onConcentrationChange(concentration);
32+
}
33+
}}
34+
>
35+
{siteConfig.calibrationConcentrations.map((item) => (
36+
<SelectItem key={item.concentration}>{item.name}</SelectItem>
37+
))}
38+
</Select>
39+
);
40+
};

src/components/OrificeSelector.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type React from "react";
22

33
import { Select, SelectItem } from "@heroui/select";
4+
45
import { siteConfig } from "@/config/site";
56

67
interface OrificeSelectorProps {

src/components/navbar.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
NavbarItem,
88
NavbarMenuToggle,
99
NavbarMenu,
10-
NavbarMenuItem,
1110
} from "@heroui/navbar";
1211
import { link as linkStyles } from "@heroui/theme";
1312
import clsx from "clsx";
@@ -83,7 +82,7 @@ export const Navbar = () => {
8382

8483
<NavbarMenu>
8584
<div className="mx-4 mt-2 flex flex-col gap-2">
86-
{siteConfig.navItems.map((item) => (
85+
{siteConfig.navItems.map((item) => (
8786
<NavbarItem key={item.href}>
8887
<Link
8988
className={clsx(

src/config/site.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,18 @@ export type SiteConfig = typeof siteConfig;
99
export interface Orifice {
1010
size: number;
1111
name: string;
12-
};
12+
}
13+
14+
/**
15+
* Interface representing a calibration gas concentration
16+
* @interface Concentration
17+
* @property {number} concentration - The concentration value in ppm
18+
* @property {string} name - The display name of the concentration (e.g., "5 ppm")
19+
*/
20+
export interface Concentration {
21+
concentration: number;
22+
name: string;
23+
}
1324

1425
export const siteConfig = {
1526
name: "Flow Dilution",
@@ -81,4 +92,15 @@ export const siteConfig = {
8192
{ size: 0.95, name: "950 Micron" },
8293
{ size: 1.0, name: "1 mm" },
8394
],
95+
calibrationConcentrations: [
96+
{ concentration: 5e-6, name: "5 ppm" },
97+
{ concentration: 10e-6, name: "10 ppm" },
98+
{ concentration: 20e-6, name: "20 ppm" },
99+
{ concentration: 30e-6, name: "30 ppm" },
100+
{ concentration: 50e-6, name: "50 ppm" },
101+
{ concentration: 100e-6, name: "100 ppm" },
102+
{ concentration: 200e-6, name: "200 ppm" },
103+
{ concentration: 500e-6, name: "500 ppm" },
104+
{ concentration: 1e-3, name: "1000 ppm" },
105+
],
84106
};

src/pages/calibrationgas.tsx

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,19 @@ import {
2727
import { title } from "@/components/primitives";
2828
import DefaultLayout from "@/layouts/default";
2929
import { FlowData, GasInlet } from "@/components/GasInlet";
30+
import { ConcentrationSelector } from "@/components/ConcentrationSelector";
31+
import { OrificeSelector } from "@/components/OrificeSelector";
32+
import { PressureSlider } from "@/components/PressureSlider";
3033

3134
export default function CalibrationGasPage() {
3235
const [temperature, setTemperature] = useState<number>(293.15);
3336
const [selectedGasInlet1, setSelectedGasInlet1] = useState<GasMixtureExt>(
34-
availableGasMixtures.find((gas) => gas.name.toLowerCase() === "nitrogen") as GasMixtureExt,
37+
availableGasMixtures.find(
38+
(gas) => gas.name.toLowerCase() === "nitrogen",
39+
) as GasMixtureExt,
3540
);
3641
const [inlet1Pressure, setInlet1Pressure] = useState<number>(400);
42+
const [inlet2Pressure, setInlet2Pressure] = useState<number>(400);
3743
const [selectedOrificeInlet1, setSelectedOrificeInlet1] =
3844
useState<number>(0.02);
3945
const [inlet1FlowData, setInlet1FlowData] = useState<FlowData>({
@@ -60,6 +66,9 @@ export default function CalibrationGasPage() {
6066
concentration of 5 ppm H<sub>2</sub>S. The calculator uses ISO
6167
9300:2022 standards for sonic nozzle flow calculations.
6268
</p>
69+
<p className="text-xs">Note that the mass of the calibration (ppm values) is ignored in the
70+
calculation. 1000 ppm = 0.1% so it is less than the ISO9300:2022
71+
standard tolerance.</p>
6372
<Input
6473
isRequired
6574
className="max-w-xs mt-4"
@@ -82,6 +91,31 @@ export default function CalibrationGasPage() {
8291
onOrificeChange={setSelectedOrificeInlet1}
8392
onPressureChange={setInlet1Pressure}
8493
/>
94+
<div className="mt-4">
95+
<PressureSlider
96+
label={`Calibration gas Pressure`}
97+
value={inlet2Pressure}
98+
onChange={setInlet2Pressure}
99+
/>
100+
</div>
101+
<div className="mt-4">
102+
<OrificeSelector
103+
label="Calibration orifice"
104+
selectedOrifice={0.020}
105+
onOrificeChange={function (orifice: number): void {
106+
throw new Error("Function not implemented.");
107+
}}
108+
/>
109+
</div>
110+
<div className="mt-4">
111+
<ConcentrationSelector
112+
label="Calibration bottle"
113+
selectedConcentration={50e-6}
114+
onConcentrationChange={function (concentration: number): void {
115+
throw new Error("Function not implemented.");
116+
}}
117+
/>
118+
</div>
85119
</div>
86120
</section>
87121
</DefaultLayout>

0 commit comments

Comments
 (0)