Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RA, Dec and Rotator parameters to the ATDome component #656

Merged
merged 4 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Version History
===============

v6.3.0
------

* Add RA, Dec and Rotator parameters to the ATDome component `<https://github.com/lsst-ts/LOVE-frontend/pull/656>`_

v6.2.0
------

Expand Down
31 changes: 31 additions & 0 deletions love/src/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1551,6 +1551,37 @@ export function degrees(radians) {
return (radians * 180) / Math.PI;
}

/**
* Function to transform degress to Right Ascension hour format
* e.g. 180.55 -> 12:02:12
* @param {number} degrees degrees to be transformed
* @returns {string} Right Ascension hour format
*/
export function degreesToHMS(degrees) {
const h = Math.floor(degrees / 15);
const m = Math.floor((degrees % 15) * 4);
const s = Math.floor(((degrees % 15) * 4 - m) * 60);
return `${h.toString().padStart(2, '0')}:${m.toString().padStart(2, '0')}:${s.toString().padStart(2, '0')}`;
}

/**
* Function to transform degress to Declination hour format
* e.g. 180.55 -> +180:02:12
* @param {number} degrees degrees to be transformed
* @returns {string} Declination hour format
*/
export function degreesToDMS(degrees) {
const d = Math.floor(degrees);
const m = Math.floor((degrees % 1) * 4);
const s = Math.floor(((degrees % 1) * 4 - m) * 60);
const hourFormat =
`${Math.sign(degrees) >= 0 ? '+' : '-'}` +
`${d.toString().padStart(2, '0')}` +
`:${m.toString().padStart(2, '0')}` +
`:${s.toString().padStart(2, '0')}`;
return hourFormat;
}

/**
* Function to pase a number or string to float with fixed decimal points
* as specified by the points param
Expand Down
30 changes: 23 additions & 7 deletions love/src/components/AuxTel/Dome/Dome.container.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ this program. If not, see <http://www.gnu.org/licenses/>.

import React from 'react';
import { connect } from 'react-redux';
import Dome from './Dome';
import { getDomeState, getATMCSState } from '../../../redux/selectors';
import { addGroup, removeGroup } from '../../../redux/actions/ws';
import SubscriptionTableContainer from '../../GeneralPurpose/SubscriptionTable/SubscriptionTable.container';
import SubscriptionTableContainer from 'components/GeneralPurpose/SubscriptionTable/SubscriptionTable.container';
import { getDomeState, getATMCSState, getAuxiliaryTelescopeState } from 'redux/selectors';
import { addGroup, removeGroup } from 'redux/actions/ws';
import { EUIs } from 'Config';
import Dome from './Dome';

export const schema = {
description: 'Summary view of the ATDome. Contains general information about the dome and mount state',
Expand All @@ -47,6 +47,12 @@ export const schema = {
isPrivate: false,
default: EUIs.ATDOME,
},
raDecHourFormat: {
type: 'boolean',
description: 'Whether to display the RA and DEC in hour format',
isPrivate: false,
default: false,
},
},
};

Expand Down Expand Up @@ -87,6 +93,10 @@ const DomeContainer = ({
controls,
atDomeTracking,
targetName,
telescopeRA,
telescopeDec,
telescopeRotator,
raDecHourFormat,
...props
}) => {
if (props.isRaw) {
Expand Down Expand Up @@ -130,26 +140,32 @@ const DomeContainer = ({
ATMCSSummaryState={ATMCSSummaryState}
atDomeTracking={atDomeTracking}
targetName={targetName}
telescopeRA={telescopeRA}
telescopeDec={telescopeDec}
telescopeRotator={telescopeRotator}
raDecHourFormat={raDecHourFormat}
/>
);
};

const mapStateToProps = (state) => {
const domeState = getDomeState(state);
const mountState = getATMCSState(state);
return { ...domeState, ...mountState };
const telescopeState = getAuxiliaryTelescopeState(state);
return { ...domeState, ...mountState, ...telescopeState };
};

const mapDispatchToProps = (dispatch) => {
const subscriptions = [
'telemetry-ATDome-0-position',
'telemetry-ATMCS-0-mount_AzEl_Encoders',
'telemetry-ATMCS-0-mount_Nasmyth_Encoders',
'telemetry-Scheduler-2-observatoryState',
'event-ATDome-0-azimuthState',
'event-ATDome-0-azimuthCommandedState',
'event-ATDome-0-dropoutDoorState',
'event-ATDome-0-mainDoorState',
'event-ATDome-0-allAxesInPosition',
'telemetry-ATMCS-0-mount_AzEl_Encoders',
'telemetry-ATMCS-0-mount_Nasmyth_Encoders',
'event-ATMCS-0-atMountState',
'event-ATMCS-0-target',
'event-ATMCS-0-allAxesInPosition',
Expand Down
147 changes: 122 additions & 25 deletions love/src/components/AuxTel/Dome/Dome.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,107 @@ this program. If not, see <http://www.gnu.org/licenses/>.
*/

import React, { Component } from 'react';
// import PropTypes from 'prop-types';
import ManagerInterface, { fixedFloat, parseCommanderData } from 'Utils';
// import SkymapGrid from '../Skymap/SkymapGrid';
import PropTypes from 'prop-types';
import ManagerInterface, { fixedFloat, parseCommanderData, degreesToHMS, degreesToDMS } from 'Utils';
import PlotContainer from 'components/GeneralPurpose/Plot/Plot.container';
import TimeSeriesControls from 'components/GeneralPurpose/Plot/TimeSeriesControls/TimeSeriesControls';
import DomeTopView from './DomeTopView';
import Elevation from 'components/GeneralPurpose/Elevation/Elevation';
import Azimuth from 'components/GeneralPurpose/Azimuth/Azimuth';
import WindRose from 'components/icons/WindRose/WindRose';
import DomePointing from './DomePointing';
import DomeShutter from './DomeShutter';
import MountTopView from './MountTopView';
import Elevation from 'components/GeneralPurpose/Elevation/Elevation';
import Azimuth from 'components/GeneralPurpose/Azimuth/Azimuth';

import WindRose from '../../icons/WindRose/WindRose';
import DomeSummaryTable from './DomeSummaryTable/DomeSummaryTable';

import styles from './Dome.module.css';

export default class Dome extends Component {
static propTypes = {
// raftsDetailedState: PropTypes.string,
// imageReadinessDetailedState: PropTypes.string,
// calibrationDetailedState: PropTypes.string,
// shutterDetailedState: PropTypes.string,
// imageSequence: PropTypes.object,
/** Width for the diferent SVG components */
width: PropTypes.number,
/** Height for the diferent SVG components */
height: PropTypes.number,
/** Dropout door opening percentage */
dropoutDoorOpeningPercentage: PropTypes.number,
/** Main door opening percentage */
mainDoorOpeningPercentage: PropTypes.number,
/** Azimuth position */
azimuthPosition: PropTypes.number,
/** Azimuth state */
azimuthState: PropTypes.string,
/** Azimuth commanded */
azimuthCommanded: PropTypes.number,
/** Dome in position */
domeInPosition: PropTypes.bool,
/** Dropout door state */
dropoutDoorState: PropTypes.string,
/** Main door state */
mainDoorState: PropTypes.string,
/** AT mount state */
atMountState: PropTypes.string,
/** Mount in position */
mountInPosition: PropTypes.bool,
/** Track ID */
trackID: PropTypes.number,
/** Target azimuth */
targetAzimuth: PropTypes.number,
/** Target elevation */
targetElevation: PropTypes.number,
/** Target nasmyth1 */
targetNasmyth1: PropTypes.number,
/** Target nasmyth2 */
targetNasmyth2: PropTypes.number,
/** M3 state */
m3State: PropTypes.string,
/** Min elevation */
minEl: PropTypes.number,
/** Min azimuth */
minAz: PropTypes.number,
/** Min nasmyth1 */
minNas1: PropTypes.number,
/** Min nasmyth2 */
minNas2: PropTypes.number,
/** Min M3 */
minM3: PropTypes.number,
/** Max elevation */
maxEl: PropTypes.number,
/** Max azimuth */
maxAz: PropTypes.number,
/** Max nasmyth1 */
maxNas1: PropTypes.number,
/** Max nasmyth2 */
maxNas2: PropTypes.number,
/** Max M3 */
maxM3: PropTypes.number,
/** Time azimuth limit */
timeAzLim: PropTypes.number,
/** Time rotation limit */
timeRotLim: PropTypes.number,
/** Time unobservable */
timeUnobservable: PropTypes.number,
/** Time elevation high limit */
timeElHighLimit: PropTypes.number,
/** Current pointing azimuth */
currentPointingAz: PropTypes.number,
/** Current pointing elevation */
currentPointingEl: PropTypes.number,
/** Current pointing nasmyth1 */
currentPointingNasmyth1: PropTypes.number,
/** Current pointing nasmyth2 */
currentPointingNasmyth2: PropTypes.number,
/** AT dome summary state */
atDomeSummaryState: PropTypes.string,
/** ATMCS summary state */
ATMCSSummaryState: PropTypes.string,
/** AT dome tracking */
atDomeTracking: PropTypes.bool,
/** Target name */
targetName: PropTypes.string,
/** Telescope RA */
telescopeRA: PropTypes.number,
/** Telescope Dec */
telescopeDec: PropTypes.number,
/** Rotator position */
telescopeRotator: PropTypes.number,
};

static defaultProps = {
Expand Down Expand Up @@ -196,10 +273,9 @@ export default class Dome extends Component {
};

render() {
const width = this.props.width;
const height = this.props.height;

const {
width,
height,
dropoutDoorOpeningPercentage,
mainDoorOpeningPercentage,
azimuthPosition,
Expand All @@ -216,12 +292,12 @@ export default class Dome extends Component {
targetNasmyth1,
targetNasmyth2,
m3State,
minEl,
// minEl,
minAz,
minNas1,
minNas2,
minM3,
maxEl,
// maxEl,
maxAz,
maxNas1,
maxNas2,
Expand All @@ -238,8 +314,14 @@ export default class Dome extends Component {
ATMCSSummaryState,
atDomeTracking,
targetName,
telescopeRA,
telescopeDec,
telescopeRotator,
raDecHourFormat,
} = this.props;

const { timeWindow, isLive, historicalData } = this.state;

const isProjected = true;
let azDiff = Math.abs(azimuthPosition - currentPointingAz);
if (azDiff > 180) azDiff = azDiff - 360;
Expand All @@ -257,16 +339,18 @@ export default class Dome extends Component {
};

const timeSeriesControlsProps = {
timeWindow: this.state.timeWindow,
isLive: this.state.isLive,
historicalData: this.state.historicalData,
timeWindow: timeWindow,
isLive: isLive,
historicalData: historicalData,
};

const parsedTelescopeRA = raDecHourFormat ? degreesToHMS(telescopeRA) : `${telescopeRA}°`;
const parsedTelescopeDec = raDecHourFormat ? degreesToDMS(telescopeDec) : `${telescopeDec}°`;

return (
<div className={styles.domeContainer}>
<div className={styles.topRow}>
<div className={styles.skymapGridContainer}>
{/* <SkymapGrid width={width} height={height} isProjected={isProjected} /> */}
<div className={styles.windRoseContainer}>
<WindRose />
</div>
Expand All @@ -285,7 +369,6 @@ export default class Dome extends Component {
targetValue={targetElevation}
/>
</div>

<Azimuth
className={styles.svgAzimuth}
width={width}
Expand Down Expand Up @@ -331,7 +414,21 @@ export default class Dome extends Component {
title="Difference between telescope and dome azimuth, multiplied by cos(telescope altitude)"
>
<span>Vignetting distance: </span>
<span className={styles.value}>{vignettingDistance}º</span>
<span className={styles.value}>{vignettingDistance}°</span>
<div
title="The following parameters requires the Scheduler:2 CSC to be active"
className={styles.telescopeParametersContainer}
>
<div>
Telescope RA: <span className={styles.value}>{parsedTelescopeRA}</span>
</div>
<div>
Telescope Dec: <span className={styles.value}>{parsedTelescopeDec}</span>
</div>
<div>
Rotator position: <span className={styles.value}>{telescopeRotator}°</span>
</div>
</div>
</div>
</div>
<DomeSummaryTable
Expand Down
Loading
Loading