DeviceArea.tsx 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. import { Flex, Button, Badge } from 'antd';
  2. import {
  3. ToolOutlined,
  4. CameraOutlined,
  5. TabletOutlined,
  6. } from '@ant-design/icons';
  7. import { useSelector } from 'react-redux';
  8. import { RootState } from '@/states/store';
  9. import {
  10. GENERATOR_STATUS,
  11. GeneratorStatus,
  12. } from '@/states/exam/deviceAreaSlice';
  13. import triggerInspection from '../../API/exam/triggerInspection';
  14. const DeviceArea = ({ className }: { className?: string }) => {
  15. const generatorStatus = useSelector(
  16. (state: RootState) => state.deviceArea.generatorStatus
  17. );
  18. const generatorStatus_2 = useSelector(
  19. (state: RootState) => state.deviceArea.generatorStatus_2
  20. );
  21. const exposureStatus = useSelector(
  22. (state: RootState) => state.deviceArea.exposureStatus
  23. );
  24. const tabletStatus = useSelector(
  25. (state: RootState) => state.deviceArea.tabletStatus
  26. );
  27. // 读取 FPD 状态,判断是否为模拟器模式
  28. const fpd = useSelector((state: RootState) => state.product.fpd);
  29. const isSimulator = fpd === 'Simulator';
  30. const btnStyle = { width: '1.5rem', height: '1.5rem' };
  31. const classValue = 'mr-1';
  32. return (
  33. <Flex justify="end" align="center" className={`w-full ${className}`}>
  34. <Button
  35. style={btnStyle}
  36. className={classValue}
  37. icon={
  38. <ToolOutlined
  39. className={
  40. generatorStatus_2 === GENERATOR_STATUS.GENERATOR_STATUS_STANDBY
  41. ? 'text-green-500'
  42. : generatorStatus === GeneratorStatus.GENERATOR_RAD_PREPARE
  43. ? 'text-yellow-500'
  44. : generatorStatus === GeneratorStatus.GENERATOR_RAD_READY
  45. ? 'text-yellow-500'
  46. : ''
  47. }
  48. />
  49. }
  50. title={`手闸状态指示器: ${generatorStatus}`}
  51. />
  52. <Badge count={isSimulator ? 'S' : 'R'} offset={[-15, 10]} color="orange">
  53. <Button
  54. style={btnStyle}
  55. data-testid="device-all-ready"
  56. className={`${classValue} ${
  57. exposureStatus === 'ready'
  58. ? 'text-green-500'
  59. : exposureStatus === 'not_ready'
  60. ? ''
  61. : ''
  62. }`}
  63. icon={
  64. <CameraOutlined
  65. // className={
  66. // exposureStatus === 'ready'
  67. // ? 'text-green-500'
  68. // : exposureStatus === 'not_ready'
  69. // ? ''
  70. // : ''
  71. // }
  72. />
  73. }
  74. onClick={() => {
  75. if (!isSimulator) {
  76. // 真实环境下禁止点击
  77. console.warn('真实环境下,曝光操作需要通过硬件触发');
  78. return;
  79. }
  80. // 模拟环境下允许点击
  81. triggerInspection();
  82. }}
  83. title={`曝光指示器: ${exposureStatus}${isSimulator ? ' (模拟模式)' : ' (真实模式)'}`}
  84. />
  85. </Badge>
  86. <Button
  87. style={btnStyle}
  88. className={`${classValue} ${
  89. tabletStatus === 'exposing'
  90. ? 'text-yellow-500'
  91. : tabletStatus === 'ready'
  92. ? 'text-green-500'
  93. : tabletStatus === 'error'
  94. ? 'text-red-500'
  95. : ''
  96. }`}
  97. icon={
  98. <TabletOutlined
  99. // className={
  100. // tabletStatus === 'exposing'
  101. // ? 'text-yellow-500'
  102. // : tabletStatus === 'ready'
  103. // ? 'text-green-500'
  104. // : tabletStatus === 'error'
  105. // ? 'text-red-500'
  106. // : ''
  107. // }
  108. />
  109. }
  110. title={`平板指示器: ${tabletStatus}`}
  111. />
  112. </Flex>
  113. );
  114. };
  115. export default DeviceArea;