Skip to content

Commit

Permalink
iot2050-conf-webui: Add support for SM1231-RTD modules
Browse files Browse the repository at this point in the history
Signed-off-by: Baocheng Su <[email protected]>
  • Loading branch information
BaochengSu committed Jan 15, 2024
1 parent 40a0144 commit 47049c7
Show file tree
Hide file tree
Showing 8 changed files with 825 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* eslint-disable react/prop-types */
import * as React from 'react';
import Checkbox from '@mui/material/Checkbox';
import FormControlLabel from '@mui/material/FormControlLabel';

const doNothing = (id) => {};

export default function CheckConfig ({ id, data, updateConfig, disabled = false, postChange = doNothing }) {
const setNewValue = (newValue) => {
data.value = newValue;
postChange(id);
updateConfig();
};

const onChange = (event) => {
setNewValue(event.target.checked);
};

/* When disabled, the value should be setting to false */
React.useEffect(() => {
if (disabled) {
setNewValue(false);
}
}, [disabled]);

return (
<FormControlLabel
disabled={disabled}
label={data.label}
control={<Checkbox
checked={data.value}
onChange={onChange}
id={id}
name={id}
/>}
/>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* eslint-disable react/prop-types */
import * as React from 'react';
import FormLabel from '@mui/material/FormLabel';
import Typography from '@mui/material/Typography';

export default function ConfigGroupLabel ({ label }) {
return (
<FormLabel>
<Typography
sx={{ fontWeight: 'bold', lineHeight: 2, textTransform: 'uppercase' }}
variant="h6"
>
{label}
</Typography>
</FormLabel>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* eslint-disable camelcase */
/* eslint-disable react/prop-types */
import * as React from 'react';
import SM1231_RTDConf, { channelConfigDefault } from './SM1231_RTDConf';
import uiString from '@/lib/uiString/SM1231_RTD.json';

export const SM1231_4RTDConfDefault = {
mlfb: '6ES7231-5PD32-0XB0',
power_alarm: {
label: uiString.LABEL_POWER_ALARM,
value: true,
disabled: false
},
integ_time: {
label: uiString.LABEL_INT_TIME,
selection: [
uiString.INT_TIME_0,
uiString.INT_TIME_1,
uiString.INT_TIME_2,
uiString.INT_TIME_3
],
value: uiString.INT_TIME_2
},
channels: [
JSON.parse(JSON.stringify(channelConfigDefault)),
JSON.parse(JSON.stringify(channelConfigDefault)),
JSON.parse(JSON.stringify(channelConfigDefault)),
JSON.parse(JSON.stringify(channelConfigDefault))
]
};

export default function SM1231_4RTDConf ({ slotNum, configData, updateConfig }) {
return (
<SM1231_RTDConf
slotNum={slotNum}
configData={configData}
updateConfig={updateConfig}
chTotal={4}
/>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* eslint-disable camelcase */
/* eslint-disable react/prop-types */
import * as React from 'react';
import SM1231_RTDConf, { channelConfigDefault } from './SM1231_RTDConf';
import uiString from '@/lib/uiString/SM1231_RTD.json';

export const SM1231_8RTDConfDefault = {
mlfb: '6ES7231-5PF32-0XB0',
power_alarm: {
label: uiString.LABEL_POWER_ALARM,
value: true,
disabled: false
},
integ_time: {
label: uiString.LABEL_INT_TIME,
selection: [
uiString.INT_TIME_0,
uiString.INT_TIME_1,
uiString.INT_TIME_2,
uiString.INT_TIME_3
],
value: uiString.INT_TIME_2
},
channels: [
JSON.parse(JSON.stringify(channelConfigDefault)),
JSON.parse(JSON.stringify(channelConfigDefault)),
JSON.parse(JSON.stringify(channelConfigDefault)),
JSON.parse(JSON.stringify(channelConfigDefault)),
JSON.parse(JSON.stringify(channelConfigDefault)),
JSON.parse(JSON.stringify(channelConfigDefault)),
JSON.parse(JSON.stringify(channelConfigDefault)),
JSON.parse(JSON.stringify(channelConfigDefault))
]
};

export default function SM1231_8RTDConf ({ slotNum, configData, updateConfig }) {
return (
<SM1231_RTDConf
slotNum={slotNum}
configData={configData}
updateConfig={updateConfig}
chTotal={8}
/>
);
}
Loading

0 comments on commit 47049c7

Please sign in to comment.