|
@@ -1,5 +1,6 @@
|
|
|
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
|
|
|
import emitter from '../../utils/eventEmitter';
|
|
|
+import store from '../store';
|
|
|
|
|
|
enum GeneratorStatus {
|
|
|
GENERATOR_SYNC_ERR = -1, // 错误状态
|
|
@@ -51,62 +52,35 @@ const deviceAreaSlice = createSlice({
|
|
|
});
|
|
|
|
|
|
emitter.on('DETECTOR_ACQUISITION_STARTED', () => {
|
|
|
- deviceAreaSlice.caseReducers.setTabletStatus(
|
|
|
- deviceAreaSlice.getInitialState(),
|
|
|
- { type: 'setTabletStatus', payload: 'ready' }
|
|
|
- );
|
|
|
+ store.dispatch(setTabletStatus('ready'));
|
|
|
});
|
|
|
|
|
|
-emitter.on('GENERATOR_RAD_OFF', () => {
|
|
|
- deviceAreaSlice.caseReducers.setGeneratorStatus(
|
|
|
- deviceAreaSlice.getInitialState(),
|
|
|
- { type: 'setGeneratorStatus', payload: GeneratorStatus.GENERATOR_RAD_OFF }
|
|
|
- );
|
|
|
+emitter.on('DETECTOR_ACQUISITION_INPROGRESS', () => {
|
|
|
+ store.dispatch(setTabletStatus('exposing'));
|
|
|
});
|
|
|
|
|
|
-emitter.on('GENERATOR_RAD_PREPARE', () => {
|
|
|
- deviceAreaSlice.caseReducers.setGeneratorStatus(
|
|
|
- deviceAreaSlice.getInitialState(),
|
|
|
- {
|
|
|
- type: 'setGeneratorStatus',
|
|
|
- payload: GeneratorStatus.GENERATOR_RAD_PREPARE,
|
|
|
- }
|
|
|
- );
|
|
|
+emitter.on('DETECTOR_ACQUISITION_ERROR', () => {
|
|
|
+ store.dispatch(setTabletStatus('error'));
|
|
|
});
|
|
|
|
|
|
-emitter.on('GENERATOR_RAD_READY', () => {
|
|
|
- deviceAreaSlice.caseReducers.setGeneratorStatus(
|
|
|
- deviceAreaSlice.getInitialState(),
|
|
|
- { type: 'setGeneratorStatus', payload: GeneratorStatus.GENERATOR_RAD_READY }
|
|
|
- );
|
|
|
+emitter.on('GENERATOR_RAD_OFF', () => {
|
|
|
+ store.dispatch(setGeneratorStatus(GeneratorStatus.GENERATOR_RAD_OFF));
|
|
|
});
|
|
|
|
|
|
-emitter.on('DETECTOR_ACQUISITION_INPROGRESS', () => {
|
|
|
- deviceAreaSlice.caseReducers.setTabletStatus(
|
|
|
- deviceAreaSlice.getInitialState(),
|
|
|
- { type: 'setTabletStatus', payload: 'exposing' }
|
|
|
- );
|
|
|
+emitter.on('GENERATOR_RAD_PREPARE', () => {
|
|
|
+ store.dispatch(setGeneratorStatus(GeneratorStatus.GENERATOR_RAD_PREPARE));
|
|
|
});
|
|
|
|
|
|
-emitter.on('DETECTOR_ACQUISITION_ERROR', () => {
|
|
|
- deviceAreaSlice.caseReducers.setTabletStatus(
|
|
|
- deviceAreaSlice.getInitialState(),
|
|
|
- { type: 'setTabletStatus', payload: 'error' }
|
|
|
- );
|
|
|
+emitter.on('GENERATOR_RAD_READY', () => {
|
|
|
+ store.dispatch(setGeneratorStatus(GeneratorStatus.GENERATOR_RAD_READY));
|
|
|
});
|
|
|
|
|
|
emitter.on('AllReady_TRUE', () => {
|
|
|
- deviceAreaSlice.caseReducers.setExposureStatus(
|
|
|
- deviceAreaSlice.getInitialState(),
|
|
|
- { type: 'setExposureStatus', payload: 'ready' }
|
|
|
- );
|
|
|
+ store.dispatch(setExposureStatus('ready'));
|
|
|
});
|
|
|
|
|
|
emitter.on('AllReady_FALSE', () => {
|
|
|
- deviceAreaSlice.caseReducers.setExposureStatus(
|
|
|
- deviceAreaSlice.getInitialState(),
|
|
|
- { type: 'setExposureStatus', payload: 'not_ready' }
|
|
|
- );
|
|
|
+ store.dispatch(setExposureStatus('not_ready'));
|
|
|
});
|
|
|
|
|
|
export const { setGeneratorStatus, setExposureStatus, setTabletStatus } =
|