Final Update for calibration charge
This commit is contained in:
parent
c6a21232f1
commit
907bc6f32b
|
@ -3,7 +3,7 @@
|
|||
dotnet_version='net6.0'
|
||||
salimax_ip="$1"
|
||||
username='ie-entwicklung'
|
||||
|
||||
root_password='Salimax4x25'
|
||||
set -e
|
||||
|
||||
echo -e "\n============================ Build ============================\n"
|
||||
|
@ -21,3 +21,6 @@ rsync -v \
|
|||
./bin/Release/$dotnet_version/linux-x64/publish/* \
|
||||
$username@"$salimax_ip":~/salimax
|
||||
|
||||
echo -e "\n============================ Execute ============================\n"
|
||||
|
||||
sshpass -p "$root_password" ssh -o StrictHostKeyChecking=no -t "$username"@"$salimax_ip" "echo '$root_password' | sudo -S sh -c 'cd salimax && ./restart'" 2>/dev/null
|
||||
|
|
|
@ -26,8 +26,7 @@ for ip_address in "${ip_addresses[@]}"; do
|
|||
|
||||
ssh "$username"@"$ip_address" "cd salimax && echo '$root_password' | sudo -S ./restart"
|
||||
|
||||
|
||||
echo "Deployed and ran commands on $ip_address"
|
||||
echo "Deployed and ran commands on $ip_address"
|
||||
done
|
||||
|
||||
|
||||
|
|
|
@ -10,7 +10,8 @@ namespace InnovEnergy.App.SaliMax.Ess;
|
|||
public static class Controller
|
||||
{
|
||||
private static readonly Double BatteryHeatingPower = 200.0; // TODO: move to config
|
||||
private static Boolean _hasCalibrationChargeChecked = false;
|
||||
private static Boolean _hasAdditionalCalibrationChargeChecked = false;
|
||||
private static Boolean _hasRepetitiveCalibrationChargeChecked = false;
|
||||
private static DateTime _nextDayAt10Am = DateTime.Now;
|
||||
|
||||
public static EssMode SelectControlMode(this StatusRecord s)
|
||||
|
@ -188,9 +189,8 @@ public static class Controller
|
|||
private static Boolean MustDoCalibrationCharge(this StatusRecord statusRecord)
|
||||
{
|
||||
var calibrationChargeForced = statusRecord.Config.ForceCalibrationChargeState;
|
||||
var additionalCalibrationRequired = CalibrationDateHasBeenPassed(statusRecord.Config.DayAndTimeForAdditionalCalibration);
|
||||
var repetitiveCalibrationRequired = CalibrationDateHasBeenPassed(statusRecord.Config.DayAndTimeForRepetitiveCalibration);
|
||||
//var batteryCalibrationChargeRequested = statusRecord.Battery is { CalibrationChargeRequested: true };
|
||||
var additionalCalibrationRequired = AdditionalCalibrationDateHasBeenPassed(statusRecord.Config.DayAndTimeForAdditionalCalibration);
|
||||
var repetitiveCalibrationRequired = RepetitiveCalibrationDateHasBeenPassed(statusRecord.Config.DayAndTimeForRepetitiveCalibration);
|
||||
|
||||
var mustDoCalibrationCharge = calibrationChargeForced == CalibrationChargeType.ChargePermanently ||
|
||||
(calibrationChargeForced == CalibrationChargeType.AdditionallyOnce && additionalCalibrationRequired) ||
|
||||
|
@ -201,25 +201,39 @@ public static class Controller
|
|||
if (calibrationChargeForced == CalibrationChargeType.AdditionallyOnce && statusRecord.Battery.Eoc )
|
||||
{
|
||||
statusRecord.Config.ForceCalibrationChargeState = CalibrationChargeType.RepetitivelyEvery;
|
||||
_hasCalibrationChargeChecked = false;
|
||||
_hasAdditionalCalibrationChargeChecked = false;
|
||||
|
||||
}
|
||||
else if (calibrationChargeForced == CalibrationChargeType.RepetitivelyEvery && statusRecord.Battery.Eoc)
|
||||
{
|
||||
statusRecord.Config.DayAndTimeForRepetitiveCalibration = statusRecord.Config.DayAndTimeForRepetitiveCalibration.AddDays(7);
|
||||
_hasCalibrationChargeChecked = false;
|
||||
_hasRepetitiveCalibrationChargeChecked = false;
|
||||
}
|
||||
}
|
||||
return mustDoCalibrationCharge;
|
||||
}
|
||||
|
||||
private static Boolean CalibrationDateHasBeenPassed(DateTime calibrationChargeDate)
|
||||
private static Boolean RepetitiveCalibrationDateHasBeenPassed(DateTime calibrationChargeDate)
|
||||
{
|
||||
if (!_hasCalibrationChargeChecked)
|
||||
if (!_hasRepetitiveCalibrationChargeChecked)
|
||||
{
|
||||
if (DateTime.Now >= calibrationChargeDate )
|
||||
{
|
||||
_hasCalibrationChargeChecked = true;
|
||||
_hasRepetitiveCalibrationChargeChecked = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
private static Boolean AdditionalCalibrationDateHasBeenPassed(DateTime calibrationChargeDate)
|
||||
{
|
||||
if (!_hasAdditionalCalibrationChargeChecked)
|
||||
{
|
||||
if (DateTime.Now >= calibrationChargeDate )
|
||||
{
|
||||
_hasAdditionalCalibrationChargeChecked = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -21,7 +21,11 @@ import Button from '@mui/material/Button';
|
|||
import axiosConfig from '../../../Resources/axiosConfig';
|
||||
import { Close as CloseIcon } from '@mui/icons-material';
|
||||
import MenuItem from '@mui/material/MenuItem';
|
||||
import { DateTimePicker, LocalizationProvider } from '@mui/x-date-pickers';
|
||||
import {
|
||||
DateTimePicker,
|
||||
LocalizationProvider,
|
||||
TimePicker
|
||||
} from '@mui/x-date-pickers';
|
||||
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
|
@ -47,6 +51,16 @@ function Configuration(props: ConfigurationProps) {
|
|||
'ChargePermanently'
|
||||
];
|
||||
|
||||
const daysInWeek = [
|
||||
'Sunday',
|
||||
'Monday',
|
||||
'Tuesday',
|
||||
'Wednesday',
|
||||
'Thursday',
|
||||
'Friday',
|
||||
'Saturday'
|
||||
];
|
||||
|
||||
const [errors, setErrors] = useState({
|
||||
minimumSoC: false,
|
||||
gridSetPoint: false
|
||||
|
@ -64,18 +78,7 @@ function Configuration(props: ConfigurationProps) {
|
|||
const [updated, setUpdated] = useState(false);
|
||||
const [dateSelectionError, setDateSelectionError] = useState('');
|
||||
const [isErrorDateModalOpen, setErrorDateModalOpen] = useState(false);
|
||||
const [openForcedCalibrationCharge, setOpenForcedCalibrationCharge] =
|
||||
useState(false);
|
||||
const [
|
||||
selectedForcedCalibrationChargeOption,
|
||||
setSelectedForcedCalibrationChargeOption
|
||||
] = useState<string>(
|
||||
CalibrationChargeOptions[
|
||||
CalibrationChargeOptionsController.indexOf(
|
||||
props.values.calibrationChargeState[0].value.toString()
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
const [formValues, setFormValues] = useState<ConfigurationValues>({
|
||||
minimumSoC: props.values.minimumSoC[0].value,
|
||||
gridSetPoint: (props.values.gridSetPoint[0].value as number) / 1000,
|
||||
|
@ -105,9 +108,21 @@ function Configuration(props: ConfigurationProps) {
|
|||
setErrorDateModalOpen(true);
|
||||
return;
|
||||
} else {
|
||||
const configurationToSend: ConfigurationValues = {
|
||||
minimumSoC: formValues.minimumSoC,
|
||||
gridSetPoint: formValues.gridSetPoint,
|
||||
CalibrationChargeState: formValues.CalibrationChargeState,
|
||||
calibrationChargeDate: dayjs(formValues.calibrationChargeDate)
|
||||
.add(1, 'hours')
|
||||
.toDate()
|
||||
};
|
||||
|
||||
setLoading(true);
|
||||
const res = await axiosConfig
|
||||
.post(`/EditInstallationConfig?installationId=${props.id}`, formValues)
|
||||
.post(
|
||||
`/EditInstallationConfig?installationId=${props.id}`,
|
||||
configurationToSend
|
||||
)
|
||||
.catch((err) => {
|
||||
if (err.response) {
|
||||
setError(true);
|
||||
|
@ -129,13 +144,26 @@ function Configuration(props: ConfigurationProps) {
|
|||
const handleConfirm = (newDate) => {
|
||||
setFormValues({
|
||||
...formValues,
|
||||
['calibrationChargeDate']: newDate.toDate()
|
||||
['calibrationChargeDate']: dayjs(newDate).toDate()
|
||||
});
|
||||
};
|
||||
|
||||
const handleSelectedCalibrationChargeDay = (event) => {
|
||||
const selectedDay = daysInWeek.indexOf(event.target.value);
|
||||
const currentDate = dayjs();
|
||||
let difference = selectedDay - currentDate.day();
|
||||
if (difference < 0) {
|
||||
difference += 7;
|
||||
}
|
||||
const adjustedDate = currentDate.add(difference, 'day');
|
||||
|
||||
setFormValues({
|
||||
...formValues,
|
||||
['calibrationChargeDate']: adjustedDate.toDate()
|
||||
});
|
||||
};
|
||||
|
||||
const handleSelectedCalibrationChargeChange = (event) => {
|
||||
setSelectedForcedCalibrationChargeOption(event.target.value);
|
||||
|
||||
setFormValues({
|
||||
...formValues,
|
||||
['CalibrationChargeState']: CalibrationChargeOptions.indexOf(
|
||||
|
@ -152,14 +180,6 @@ function Configuration(props: ConfigurationProps) {
|
|||
});
|
||||
};
|
||||
|
||||
const handleOpenForcedCalibrationCharge = () => {
|
||||
setOpenForcedCalibrationCharge(true);
|
||||
};
|
||||
|
||||
const handleCloseForcedCalibrationCharge = () => {
|
||||
setOpenForcedCalibrationCharge(false);
|
||||
};
|
||||
|
||||
const handleChange = (e) => {
|
||||
const { name, value } = e.target;
|
||||
|
||||
|
@ -277,11 +297,8 @@ function Configuration(props: ConfigurationProps) {
|
|||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<FormControl
|
||||
fullWidth
|
||||
sx={{ marginLeft: 1, marginBottom: '10px', width: 390 }}
|
||||
>
|
||||
<div style={{ marginBottom: '5px', marginTop: '10px' }}>
|
||||
<FormControl fullWidth sx={{ marginLeft: 1, width: 390 }}>
|
||||
<InputLabel
|
||||
sx={{
|
||||
fontSize: 14,
|
||||
|
@ -294,11 +311,15 @@ function Configuration(props: ConfigurationProps) {
|
|||
/>
|
||||
</InputLabel>
|
||||
<Select
|
||||
value={selectedForcedCalibrationChargeOption}
|
||||
value={
|
||||
CalibrationChargeOptions[
|
||||
formValues.CalibrationChargeState
|
||||
]
|
||||
}
|
||||
onChange={handleSelectedCalibrationChargeChange}
|
||||
open={openForcedCalibrationCharge}
|
||||
onClose={handleCloseForcedCalibrationCharge}
|
||||
onOpen={handleOpenForcedCalibrationCharge}
|
||||
//open={openForcedCalibrationCharge}
|
||||
//onClose={handleCloseForcedCalibrationCharge}
|
||||
//onOpen={handleOpenForcedCalibrationCharge}
|
||||
>
|
||||
{CalibrationChargeOptions.map((option) => (
|
||||
<MenuItem key={option} value={option}>
|
||||
|
@ -308,7 +329,7 @@ function Configuration(props: ConfigurationProps) {
|
|||
</Select>
|
||||
</FormControl>
|
||||
</div>
|
||||
{formValues.CalibrationChargeState != 2 && (
|
||||
{formValues.CalibrationChargeState == 1 && (
|
||||
<div>
|
||||
<LocalizationProvider dateAdapter={AdapterDayjs}>
|
||||
<DateTimePicker
|
||||
|
@ -323,6 +344,54 @@ function Configuration(props: ConfigurationProps) {
|
|||
</div>
|
||||
)}
|
||||
|
||||
{formValues.CalibrationChargeState == 0 && (
|
||||
<>
|
||||
<div style={{ marginBottom: '5px' }}>
|
||||
<FormControl
|
||||
fullWidth
|
||||
sx={{ marginLeft: 1, width: 390, marginTop: 2 }}
|
||||
>
|
||||
<InputLabel
|
||||
sx={{
|
||||
fontSize: 14,
|
||||
backgroundColor: 'transparent'
|
||||
}}
|
||||
>
|
||||
<FormattedMessage
|
||||
id="calibration_charge_day"
|
||||
defaultMessage="Calibration Charge Day"
|
||||
/>
|
||||
</InputLabel>
|
||||
<Select
|
||||
value={
|
||||
daysInWeek[formValues.calibrationChargeDate.getDay()]
|
||||
}
|
||||
onChange={handleSelectedCalibrationChargeDay}
|
||||
// open={openForcedCalibrationCharge}
|
||||
// onClose={handleCloseForcedCalibrationCharge}
|
||||
// onOpen={handleOpenForcedCalibrationCharge}
|
||||
>
|
||||
{daysInWeek.map((day) => (
|
||||
<MenuItem key={day} value={day}>
|
||||
{day}
|
||||
</MenuItem>
|
||||
))}
|
||||
</Select>
|
||||
</FormControl>
|
||||
</div>
|
||||
|
||||
<div style={{ marginBottom: '5px', marginTop: '10px' }}>
|
||||
<LocalizationProvider dateAdapter={AdapterDayjs}>
|
||||
<TimePicker
|
||||
label="Calibration Charge Hour"
|
||||
value={dayjs(formValues.calibrationChargeDate)}
|
||||
onChange={handleConfirm}
|
||||
/>
|
||||
</LocalizationProvider>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
<div style={{ marginBottom: '5px' }}>
|
||||
<TextField
|
||||
label={
|
||||
|
|
Loading…
Reference in New Issue