-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/enrich'
- Loading branch information
Showing
15 changed files
with
531 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/renderer/components/CountdownStatus/CountdownStatus.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { styled } from '@/renderer/globalStyles/styled'; | ||
import { IoMdStopwatch } from 'react-icons/io'; | ||
import { Countdown } from '@/renderer/components/common/Countdown'; | ||
import React, { FC } from 'react'; | ||
|
||
export const CountdownStatus: FC = () => { | ||
return ( | ||
<Countdown | ||
icon={<StyledIoMdStopwatch />} | ||
labelPopup={'scenario'} | ||
durationDefault={35} | ||
/> | ||
); | ||
}; | ||
|
||
const StyledIoMdStopwatch = styled(IoMdStopwatch)` | ||
height: 1.25em; | ||
width: 1.25em; | ||
`; |
35 changes: 35 additions & 0 deletions
35
src/renderer/components/ExplorationStatus/ExplorationCancelNavigation.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { rosClient } from '@/renderer/utils/ros/rosClient'; | ||
import React, { FC } from 'react'; | ||
import { TopicOptions } from '@/renderer/utils/ros/roslib-ts-client/@types'; | ||
import { styled } from '@/renderer/globalStyles/styled'; | ||
import { FaStop } from 'react-icons/fa'; | ||
import { toast } from 'react-toastify'; | ||
|
||
const stopNavigationTopic: TopicOptions = { | ||
name: '/move_base/cancel', | ||
messageType: 'actionlib_msgs/GoalID', | ||
}; | ||
|
||
interface CancelNavigation { | ||
isCancelNavigationProps: () => void; | ||
} | ||
|
||
export const ExplorationCancelNavigation: FC<CancelNavigation> = ({ | ||
isCancelNavigationProps, | ||
}) => { | ||
const onClick = () => { | ||
rosClient.publish(stopNavigationTopic, {}); | ||
isCancelNavigationProps(); | ||
toast.info('Navigation stop'); | ||
}; | ||
|
||
return <StyledFaStop onClick={onClick} />; | ||
}; | ||
|
||
export const StyledFaStop = styled(FaStop)` | ||
margin-top: 0.25em; | ||
color: red; | ||
&:hover { | ||
cursor: pointer; | ||
} | ||
`; |
62 changes: 62 additions & 0 deletions
62
src/renderer/components/ExplorationStatus/ExplorationStatus.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { styled } from '@/renderer/globalStyles/styled'; | ||
import { ExplorationCancelNavigation } from './ExplorationCancelNavigation'; | ||
import { GoTelescope } from 'react-icons/go'; | ||
import { Countdown } from '@/renderer/components/common/Countdown'; | ||
import { rosClient } from '@/renderer/utils/ros/rosClient'; | ||
import React, { FC, useState } from 'react'; | ||
import { log } from '@/renderer/logger'; | ||
|
||
export const ExplorationStatus: FC = () => { | ||
const [isNowStopCountdownTimer, setIsNowStopCountdownTimer] = useState(false); | ||
|
||
const startTimer = (duration: number) => { | ||
setIsNowStopCountdownTimer(false); | ||
startRosExplorationTimer(duration); | ||
}; | ||
|
||
const stopTimer = () => { | ||
setIsNowStopCountdownTimer(true); | ||
stopRosExplorationTimer(); | ||
}; | ||
|
||
const startRosExplorationTimer = (duration: number) => { | ||
rosClient | ||
.callService( | ||
{ | ||
name: `/start_exploration`, | ||
}, | ||
{ timeout: duration * 60 } | ||
) | ||
.catch(log.error); | ||
}; | ||
|
||
const stopRosExplorationTimer = () => { | ||
rosClient | ||
.callService( | ||
{ | ||
name: `/stop_exploration`, | ||
}, | ||
{} | ||
) | ||
.catch(log.error); | ||
}; | ||
|
||
return ( | ||
<Countdown | ||
icon={<StyledGoTelescope />} | ||
labelPopup={'exploration'} | ||
durationDefault={2} | ||
onStartClick={startTimer} | ||
onStopClick={stopTimer} | ||
sideElement={ | ||
<ExplorationCancelNavigation isCancelNavigationProps={stopTimer} /> | ||
} | ||
isNowStopCountdownTimer={isNowStopCountdownTimer} | ||
/> | ||
); | ||
}; | ||
|
||
const StyledGoTelescope = styled(GoTelescope)` | ||
height: 1.25em; | ||
width: 1.25em; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import React, { memo } from 'react'; | ||
import { StyledPopup } from '@/renderer/components/styles'; | ||
import { useSelector } from 'react-redux'; | ||
import { selectAllGpioPins } from '@/renderer/store/modules/gpioPins'; | ||
import { GpioPin } from './GpioPin'; | ||
import { styled } from '@/renderer/globalStyles/styled'; | ||
import { BsLightbulb } from 'react-icons/bs'; | ||
import { BsLightbulbOff } from 'react-icons/bs'; | ||
|
||
const GpioPinsStatus = () => { | ||
const gpioPins = useSelector(selectAllGpioPins); | ||
const isAGpioPinOn = gpioPins.find((gpioPin) => gpioPin.isOn)?.isOn; | ||
return ( | ||
<StyledPopup | ||
trigger={ | ||
<Container> | ||
{isAGpioPinOn ? <StyledBsLightbulb /> : <StyledBsLightbulbOff />} | ||
</Container> | ||
} | ||
on="click" | ||
position="bottom center" | ||
arrow={false} | ||
repositionOnResize={true} | ||
> | ||
<StyledDiv> | ||
{gpioPins.map((gpioPin) => ( | ||
<GpioPin key={gpioPin.id} gpioPin={gpioPin} /> | ||
))} | ||
</StyledDiv> | ||
</StyledPopup> | ||
); | ||
}; | ||
|
||
const Container = styled.div` | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: center; | ||
align-items: center; | ||
&:hover { | ||
cursor: pointer; | ||
} | ||
`; | ||
|
||
const StyledDiv = styled.div` | ||
display: flex; | ||
flex-direction: row; | ||
align-items: flex-start; | ||
background-color: ${({ theme }) => theme.colors.darkerBackground}; | ||
box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.5); | ||
border-radius: 4px; | ||
min-width: 150px; | ||
`; | ||
|
||
const StyledBsLightbulb = styled(BsLightbulb)` | ||
height: 1.25em; | ||
width: 1.25em; | ||
`; | ||
|
||
const StyledBsLightbulbOff = styled(BsLightbulbOff)` | ||
height: 1.25em; | ||
width: 1.25em; | ||
`; | ||
|
||
export default memo(GpioPinsStatus); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.