Compare commits

..

No commits in common. "7a5c5845bf050ce162676c50bf9b111840630838" and "78ae53f7633efb55ce0a606f7187af32b0865609" have entirely different histories.

4 changed files with 49 additions and 67 deletions

View File

@ -195,8 +195,6 @@ public static class Controller
var mustDoCalibrationCharge = calibrationChargeForced == CalibrationChargeType.ChargePermanently ||
(calibrationChargeForced == CalibrationChargeType.AdditionallyOnce && additionalCalibrationRequired) ||
(calibrationChargeForced == CalibrationChargeType.RepetitivelyEvery && repetitiveCalibrationRequired);
Console.WriteLine("Next Repetitive calibration charge date is "+statusRecord.Config.DayAndTimeForRepetitiveCalibration);
Console.WriteLine("Next Additional calibration charge date is "+statusRecord.Config.DayAndTimeForAdditionalCalibration);
if (statusRecord.Battery is not null)
{
@ -206,7 +204,7 @@ public static class Controller
_hasAdditionalCalibrationChargeChecked = false;
}
else if (calibrationChargeForced == CalibrationChargeType.RepetitivelyEvery && statusRecord.Battery.Eoc )
else if (calibrationChargeForced == CalibrationChargeType.RepetitivelyEvery && statusRecord.Battery.Eoc)
{
statusRecord.Config.DayAndTimeForRepetitiveCalibration = statusRecord.Config.DayAndTimeForRepetitiveCalibration.AddDays(7);
_hasRepetitiveCalibrationChargeChecked = false;

View File

@ -18,6 +18,7 @@ import {
import React, { useState } from 'react';
import { FormattedMessage } from 'react-intl';
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 {
@ -27,8 +28,6 @@ import {
} from '@mui/x-date-pickers';
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
import dayjs from 'dayjs';
import axiosConfig from '../../../Resources/axiosConfig';
import utc from 'dayjs/plugin/utc';
interface ConfigurationProps {
values: TopologyValues;
@ -62,9 +61,6 @@ function Configuration(props: ConfigurationProps) {
'Saturday'
];
dayjs.extend(utc);
const localOffset = dayjs().utcOffset();
const [errors, setErrors] = useState({
minimumSoC: false,
gridSetPoint: false
@ -93,43 +89,35 @@ function Configuration(props: ConfigurationProps) {
CalibrationChargeOptionsController.indexOf(
props.values.calibrationChargeState[0].value.toString()
) == 0
? dayjs
.utc(props.values.repetitiveCalibrationChargeDate[0].value)
.add(localOffset, 'minute')
.toDate()
: dayjs
.utc(props.values.additionalCalibrationChargeDate[0].value)
.add(localOffset, 'minute')
.toDate()
? dayjs(props.values.repetitiveCalibrationChargeDate[0].value).toDate()
: dayjs(props.values.additionalCalibrationChargeDate[0].value).toDate()
});
const handleSubmit = async (e) => {
if (
CalibrationChargeOptionsController.indexOf(
props.values.calibrationChargeState[0].value.toString()
) != 2 &&
props.values.mode[0].value === 'CalibrationCharge'
props.values.mode[0].value === 'CalibrationCharge' &&
formValues.CalibrationChargeState == 0
) {
setDateSelectionError(
'You cannot change the date while the installation is in Calibration Charge Mode'
);
setErrorDateModalOpen(true);
return;
} else if (
formValues.CalibrationChargeState != 2 &&
dayjs(formValues.calibrationChargeDate).isBefore(dayjs())
) {
//console.log('asked for', dayjs(formValues.calibrationChargeDate));
} else if (dayjs(formValues.calibrationChargeDate).isBefore(dayjs())) {
console.log(dayjs());
console.log('asked for', dayjs(formValues.calibrationChargeDate));
setDateSelectionError('You must specify a future date');
setErrorDateModalOpen(true);
return;
} else {
//console.log('asked for', dayjs(formValues.calibrationChargeDate));
console.log('asked for', dayjs(formValues.calibrationChargeDate));
const configurationToSend: ConfigurationValues = {
minimumSoC: formValues.minimumSoC,
gridSetPoint: formValues.gridSetPoint,
CalibrationChargeState: formValues.CalibrationChargeState,
calibrationChargeDate: dayjs(formValues.calibrationChargeDate).toDate()
calibrationChargeDate: dayjs(formValues.calibrationChargeDate)
.add(2, 'hours')
.toDate()
};
setLoading(true);
@ -159,7 +147,7 @@ function Configuration(props: ConfigurationProps) {
const handleConfirm = (newDate) => {
setFormValues({
...formValues,
['calibrationChargeDate']: dayjs.utc(newDate).toDate()
['calibrationChargeDate']: dayjs(newDate).toDate()
});
};
@ -171,6 +159,7 @@ function Configuration(props: ConfigurationProps) {
difference += 7;
}
const adjustedDate = currentDate.add(difference, 'day');
setFormValues({
...formValues,
['calibrationChargeDate']: adjustedDate.toDate()
@ -185,14 +174,12 @@ function Configuration(props: ConfigurationProps) {
),
['calibrationChargeDate']:
CalibrationChargeOptions.indexOf(event.target.value) == 0
? dayjs
.utc(props.values.repetitiveCalibrationChargeDate[0].value)
.add(localOffset, 'minute')
.toDate()
: dayjs
.utc(props.values.additionalCalibrationChargeDate[0].value)
.add(localOffset, 'minute')
.toDate()
? dayjs(
props.values.repetitiveCalibrationChargeDate[0].value
).toDate()
: dayjs(
props.values.additionalCalibrationChargeDate[0].value
).toDate()
});
};
@ -333,6 +320,9 @@ function Configuration(props: ConfigurationProps) {
]
}
onChange={handleSelectedCalibrationChargeChange}
//open={openForcedCalibrationCharge}
//onClose={handleCloseForcedCalibrationCharge}
//onOpen={handleOpenForcedCalibrationCharge}
>
{CalibrationChargeOptions.map((option) => (
<MenuItem key={option} value={option}>
@ -346,10 +336,8 @@ function Configuration(props: ConfigurationProps) {
<div>
<LocalizationProvider dateAdapter={AdapterDayjs}>
<DateTimePicker
format="DD/MM/YYYY HH:mm"
ampm={false}
label="Select Next Calibration Charge Date"
value={dayjs.utc(formValues.calibrationChargeDate)}
value={dayjs(formValues.calibrationChargeDate)}
onChange={handleConfirm}
sx={{
marginTop: 2
@ -382,6 +370,9 @@ function Configuration(props: ConfigurationProps) {
daysInWeek[formValues.calibrationChargeDate.getDay()]
}
onChange={handleSelectedCalibrationChargeDay}
// open={openForcedCalibrationCharge}
// onClose={handleCloseForcedCalibrationCharge}
// onOpen={handleOpenForcedCalibrationCharge}
>
{daysInWeek.map((day) => (
<MenuItem key={day} value={day}>
@ -395,9 +386,8 @@ function Configuration(props: ConfigurationProps) {
<div style={{ marginBottom: '5px', marginTop: '10px' }}>
<LocalizationProvider dateAdapter={AdapterDayjs}>
<TimePicker
ampm={false}
label="Calibration Charge Hour"
value={dayjs.utc(formValues.calibrationChargeDate)}
value={dayjs(formValues.calibrationChargeDate)}
onChange={handleConfirm}
/>
</LocalizationProvider>

View File

@ -282,25 +282,25 @@ function Information(props: InformationProps) {
/>
</div>
{/*<div>*/}
{/* <TextField*/}
{/* label="S3 Write Key"*/}
{/* name="s3writekey"*/}
{/* value={formValues.s3WriteKey}*/}
{/* variant="outlined"*/}
{/* fullWidth*/}
{/* />*/}
{/*</div>*/}
<div>
<TextField
label="S3 Write Key"
name="s3writekey"
value={formValues.s3WriteKey}
variant="outlined"
fullWidth
/>
</div>
{/*<div>*/}
{/* <TextField*/}
{/* label="S3 Write Secret Key"*/}
{/* name="s3writesecretkey"*/}
{/* value={formValues.s3WriteSecret}*/}
{/* variant="outlined"*/}
{/* fullWidth*/}
{/* />*/}
{/*</div>*/}
<div>
<TextField
label="S3 Write Secret Key"
name="s3writesecretkey"
value={formValues.s3WriteSecret}
variant="outlined"
fullWidth
/>
</div>
<div>
<TextField

View File

@ -143,9 +143,7 @@ export const transformInputToBatteryViewData = async (
startUnixTime = UnixTime.fromTicks(startUnixTime.ticks + 1);
}
const adjustedTimestamp = new Date(startUnixTime.ticks * 1000);
adjustedTimestamp.setHours(
adjustedTimestamp.getHours() - adjustedTimestamp.getTimezoneOffset() / 60
);
adjustedTimestamp.setHours(adjustedTimestamp.getHours() + 1);
adjustedTimestampArray.push(adjustedTimestamp);
}
@ -328,11 +326,7 @@ export const transformInputToDailyData = async (
startUnixTime = UnixTime.fromTicks(startUnixTime.ticks + 1);
}
const adjustedTimestamp = new Date(startUnixTime.ticks * 1000);
//Timezone offset is negative, so we convert the timestamp to the current zone by subtracting the corresponding offset
adjustedTimestamp.setHours(
adjustedTimestamp.getHours() - adjustedTimestamp.getTimezoneOffset() / 60
);
adjustedTimestamp.setHours(adjustedTimestamp.getHours() + 1);
adjustedTimestampArray.push(adjustedTimestamp);
}