Skip to content

Commit

Permalink
Add RA, dec and rotator angle data to MTDomeSummaryTable component.
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-aranda committed Nov 14, 2024
1 parent 555f870 commit 3de4ecb
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 12 deletions.
23 changes: 23 additions & 0 deletions love/src/components/MainTel/MTDome/MTDome.container.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
getDomeAzimuth,
getLightWindScreen,
getPointingStatus,
getMainTelescopeState,
} from '../../../redux/selectors';
import { addGroup, removeGroup } from '../../../redux/actions/ws';
import SubscriptionTableContainer from '../../GeneralPurpose/SubscriptionTable/SubscriptionTable.container';
Expand All @@ -47,6 +48,12 @@ export const schema = {
default: true,
isPrivate: false,
},
raDecHourFormat: {
type: 'boolean',
description: 'Whether to display the RA and DEC in hour format',
isPrivate: false,
default: false,
},
},
};

Expand All @@ -72,6 +79,11 @@ const MTDomeContainer = ({
targetPointingAz,
currentPointingEl,
targetPointingEl,
telescopeRAHour,
telescopeRADeg,
telescopeDecDeg,
telescopeRotatorRad,
raDecHourFormat,
...props
}) => {
if (props.isRaw) {
Expand Down Expand Up @@ -100,6 +112,11 @@ const MTDomeContainer = ({
targetPointingAz={targetPointingAz}
currentPointingEl={currentPointingEl}
targetPointingEl={targetPointingEl}
telescopeRAHour={telescopeRAHour}
telescopeRADeg={telescopeRADeg}
telescopeDecDeg={telescopeDecDeg}
telescopeRotatorRad={telescopeRotatorRad}
raDecHourFormat={raDecHourFormat}
/>
);
};
Expand All @@ -111,13 +128,15 @@ const mapStateToProps = (state) => {
const lightWindScreenState = getLightWindScreen(state);
const domeAzimuthState = getDomeAzimuth(state);
const pointingState = getPointingStatus(state);
const telescopeState = getMainTelescopeState(state);
return {
...domeState,
...louversState,
...apertureShutterState,
...lightWindScreenState,
...domeAzimuthState,
...pointingState,
...telescopeState,
};
};

Expand All @@ -129,13 +148,17 @@ const mapDispatchToProps = (dispatch) => {
'telemetry-MTDome-0-louvers',
'telemetry-MTMount-0-azimuth',
'telemetry-MTMount-0-elevation',
'telemetry-MTPtg-0-mountStatus',
'telemetry-MTPtg-0-mountPosition',
'event-MTDome-0-azEnabled',
'event-MTDome-0-azMotion',
'event-MTDome-0-azTarget',
'event-MTDome-0-operationalMode',
'event-MTMount-0-target',
'event-MTDome-0-summaryState',
'event-MTMount-0-summaryState',
'event-MTPtg-0-currentTarget',

];
return {
subscriptions,
Expand Down
23 changes: 21 additions & 2 deletions love/src/components/MainTel/MTDome/MTDome.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ import Azimuth from 'components/GeneralPurpose/Azimuth/Azimuth';
import Elevation from 'components/GeneralPurpose/Elevation/Elevation';
import WindRose from '../../icons/WindRose/WindRose';
import MTDomeSummaryTable from './MTDomeSummaryTable/MTDomeSummaryTable';
import styles from './MTDome.module.css';

import { MTDomeLouversMapAF, MTDomeLouversMapGN } from 'Config';
import styles from './MTDome.module.css';

const defaultValuesAF = {
A1: '0',
Expand Down Expand Up @@ -218,6 +217,16 @@ export default class MTDome extends Component {
targetPointingEl: PropTypes.number,
/** High level state machine state identifier of the MTMount. */
mtMountSummaryState: PropTypes.number,
/** Telescope current RA in hours */
telescopeRAHour: PropTypes.number,
/** Telescope current RA in degrees */
telescopeRADeg: PropTypes.number,
/** Telescope current Dec in degrees */
telescopeDecDeg: PropTypes.number,
/** Telescope rotator position in rad */
telescopeRotatorRad: PropTypes.number,
/** Whether to display the RA and DEC in hour format */
raDecHourFormat: PropTypes.bool,
};

static defaultProps = {
Expand Down Expand Up @@ -559,6 +568,11 @@ export default class MTDome extends Component {
currentPointingEl,
targetPointingAz,
targetPointingEl,
telescopeRAHour,
telescopeRADeg,
telescopeDecDeg,
telescopeRotatorRad,
raDecHourFormat,
} = this.props;

const currentPointing = {
Expand Down Expand Up @@ -642,6 +656,11 @@ export default class MTDome extends Component {
positionCommandedShutter={positionCommandedShutter}
currentPointing={currentPointing}
targetPointing={targetPointing}
telescopeRAHour={telescopeRAHour}
telescopeRADeg={telescopeRADeg}
telescopeDecDeg={telescopeDecDeg}
telescopeRotatorRad={telescopeRotatorRad}
raDecHourFormat={raDecHourFormat}
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@ this program. If not, see <http://www.gnu.org/licenses/>.
*/

import React, { Component } from 'react';
import styles from './MTDomeSummaryTable.module.css';
import StatusText from '../../../GeneralPurpose/StatusText/StatusText';
import CurrentTargetValue from '../../../GeneralPurpose/CurrentTargetValue/CurrentTargetValue';
import PropTypes from 'prop-types';
import Limits from '../../../GeneralPurpose/Limits/Limits';
import SummaryPanel from '../../../GeneralPurpose/SummaryPanel/SummaryPanel';
import Row from '../../../GeneralPurpose/SummaryPanel/Row';
import Label from '../../../GeneralPurpose/SummaryPanel/Label';
import Value from '../../../GeneralPurpose/SummaryPanel/Value';
import Title from '../../../GeneralPurpose/SummaryPanel/Title';
import ProgressBar from '../../../GeneralPurpose/ProgressBar/ProgressBar';
import StatusText from 'components/GeneralPurpose/StatusText/StatusText';
import CurrentTargetValue from 'components/GeneralPurpose/CurrentTargetValue/CurrentTargetValue';
import Limits from 'components/GeneralPurpose/Limits/Limits';
import SummaryPanel from 'components/GeneralPurpose/SummaryPanel/SummaryPanel';
import Row from 'components/GeneralPurpose/SummaryPanel/Row';
import Label from 'components/GeneralPurpose/SummaryPanel/Label';
import Value from 'components/GeneralPurpose/SummaryPanel/Value';
import Title from 'components/GeneralPurpose/SummaryPanel/Title';
import ProgressBar from 'components/GeneralPurpose/ProgressBar/ProgressBar';
import {
summaryStateMap,
summaryStateToStyle,
Expand All @@ -40,6 +39,8 @@ import {
mtdomeMotionStatetoStyle,
MTMountLimits,
} from 'Config';
import { formatHoursToDigital, degreesToDMS, degrees, defaultNumberFormatter } from 'Utils';
import styles from './MTDomeSummaryTable.module.css';

export default class MTDomeSummaryTable extends Component {
static propTypes = {
Expand Down Expand Up @@ -67,6 +68,16 @@ export default class MTDomeSummaryTable extends Component {
positionActualShutter: PropTypes.array,
/** Commanded shutter position */
positionCommandedShutter: PropTypes.array,
/** Telescope current RA in hours */
telescopeRAHour: PropTypes.number,
/** Telescope current RA in degrees */
telescopeRADeg: PropTypes.number,
/** Telescope current Dec in degrees */
telescopeDecDeg: PropTypes.number,
/** Telescope rotator position in rad */
telescopeRotatorRad: PropTypes.number,
/** Whether to display the RA and DEC in hour format */
raDecHourFormat: PropTypes.bool,
};

static defaultProps = {
Expand Down Expand Up @@ -98,6 +109,11 @@ export default class MTDomeSummaryTable extends Component {
targetPointing,
positionActualShutter,
positionCommandedShutter,
telescopeRAHour,
telescopeRADeg,
telescopeDecDeg,
telescopeRotatorRad,
raDecHourFormat,
} = this.props;

const mtDomeStatusText = summaryStateMap[mtDomeSummaryState];
Expand All @@ -113,12 +129,26 @@ export default class MTDomeSummaryTable extends Component {
const shutterPositionCommanded1 = Math.round(positionCommandedShutter[0] ?? 0);
const shutterPositionActual2 = Math.round(positionActualShutter[1] ?? 0);
const shutterPositionCommanded2 = Math.round(positionCommandedShutter[1] ?? 0);

const parsedTelescopeRAHour = formatHoursToDigital(telescopeRAHour);
const parsedTelescopeDecHour = degreesToDMS(telescopeDecDeg);
const parsedTelescopeRADeg = defaultNumberFormatter(telescopeRADeg, 2) + '°';
const parsedTelescopeDecDeg = defaultNumberFormatter(telescopeDecDeg, 2) + '°';
const parsedTelescopeRotatorDeg = defaultNumberFormatter(degrees(telescopeRotatorRad), 2) + '°';
const telescopeRAText = raDecHourFormat ? parsedTelescopeRAHour : parsedTelescopeRADeg;
const telescopeDecText = raDecHourFormat ? parsedTelescopeDecHour : parsedTelescopeDecDeg;

return (
<div className={styles.divSummary}>
<SummaryPanel className={styles.summaryTable}>
<Title>Track ID</Title>
<Value>{trackId?.toString()}</Value>
<Label>Telescope RA</Label>
<Value>{telescopeRAText}</Value>
<Label>Telescope Dec</Label>
<Value>{telescopeDecText}</Value>
<Label>Rotator</Label>
<Value>{parsedTelescopeRotatorDeg}</Value>
<Title>MTDome CSC</Title>
<Value>
<StatusText status={summaryStateToStyle[mtDomeStatusText]}>{mtDomeStatusText}</StatusText>
Expand Down
14 changes: 14 additions & 0 deletions love/src/redux/selectors/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,20 @@ export const getDomeStatus = (state) => {
};
};

export const getMainTelescopeState = (state) => {
const subscriptions = [
'telemetry-MTPtg-0-mountStatus',
'telemetry-MTPtg-0-mountPosition'
];
const data = getStreamsData(state, subscriptions);
return {
telescopeRAHour: data[`telemetry-MTPtg-0-mountStatus`]?.mountRA?.value ?? 0,
telescopeRADeg: data[`telemetry-MTPtg-0-mountPosition`]?.ra?.value ?? 0,
telescopeDecDeg: data[`telemetry-MTPtg-0-mountStatus`]?.mountDec?.value ?? 0,
telescopeRotatorRad: data[`telemetry-MTPtg-0-mountStatus`]?.mountRot?.value ?? 0,
};
};

// MTDome Power Draw
export const getMtDomePowerDraw = (state) => {
const subscriptions = [
Expand Down

0 comments on commit 3de4ecb

Please sign in to comment.