config.ts 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. import type { ElementGroup } from './types';
  2. import { buildOperandSet } from './parser';
  3. /** 模板选项 — 预设表达式 */
  4. export const DEFAULT_TEMPLATE_OPTIONS: { label: string; value: string }[] = [
  5. { label: '压差预警1', value: '20<=sourcePressureChange && sourcePressureChange<=40' },
  6. { label: '压差预警2', value: '40<sourcePressureChange && sourcePressureChange<=60' },
  7. { label: '压差预警3', value: '60<sourcePressureChange && sourcePressureChange<=80' },
  8. { label: '压差预警4', value: '80<sourcePressureChange' },
  9. { label: '火灾预警1', value: '((coRzl<=20||coZf<=0.5*coAvg)&&coVal<=10)||o2Val<=5&&temperatureDifference<2&&co2Val<0.5' },
  10. {
  11. label: '火灾预警2',
  12. value:
  13. '((coRzl>20&&coRzl<=50)||(0.5*coAvg<coZf&&coZf<=coAvg)||(coVal>10&&coVal<=50)||(temperatureDifference>=2&&temperatureDifference<=4))&&co2Val<0.5',
  14. },
  15. {
  16. label: '火灾预警3',
  17. value:
  18. '((coRzl>50&&coRzl<=100)||(coAvg<coZf&&coZf<=2*coAvg)||(coVal>=50&&coVal<=100)||(temperatureDifference>4&&temperatureDifference<=10))&&co2Val<0.5',
  19. },
  20. { label: '火灾预警4', value: 'coRzl>100||2*coAvg<coZf||coVal>100||temperatureDifference>10||(co2Val>=0.5&&co2Trend)' },
  21. { label: '闭外火灾预警1', value: 'temperatureDifference<2||ch4Val<0.5||coVal<5||o2Val<20' },
  22. { label: '闭外火灾预警2', value: 'temperatureDifference>=2&&temperatureDifference<=4||ch4Val>=0.5&&ch4Val<=1||coVal>=5&&coVal<10' },
  23. {
  24. label: '闭外火灾预警3',
  25. value: 'temperatureDifference>4&&temperatureDifference<=10&&temperature>=26||ch4Val>=1&&ch4Val<1.5||coVal>=10&&coVal<24||c2h4Val>0&&c2h2Val==0',
  26. },
  27. { label: '闭外火灾预警4', value: 'temperatureDifference>10&&temperature>=30||ch4Val>=1.5&&ch4Val<2||coVal>=24||c2h2Val>0' },
  28. {
  29. label: 'OPEN',
  30. value:
  31. '(temperature<30||-3<temperature-fireAirTemperature&&temperature-fireAirTemperature<3)&&o2Val<5&&c2h4Val<0.001&&c2h2Val<0.001&&coVal<0.001&&(temperature<25||-3<temperature-fireWaterTemperature&&temperature-fireWaterTemperature<3)&&stableDays>30',
  32. },
  33. ];
  34. /** 元素库分组 — 定义表达式中可用的变量、运算符、逻辑符、括号和数值 */
  35. export const DEFAULT_ELEMENT_GROUPS: ElementGroup[] = [
  36. {
  37. key: 'gas',
  38. header: '监测变量',
  39. type: 'operand',
  40. items: [
  41. { type: 'operand', value: 'sourcePressureChange', label: '压差变化' },
  42. { type: 'operand', value: 'coRzl', label: 'CO日增率' },
  43. { type: 'operand', value: 'coZf', label: 'CO增幅' },
  44. { type: 'operand', value: 'coAvg', label: 'CO平均值' },
  45. { type: 'operand', value: 'coVal', label: 'CO值' },
  46. { type: 'operand', value: 'co2Val', label: 'CO2值' },
  47. { type: 'operand', value: 'co2Trend', label: 'CO2存在上升趋势' },
  48. { type: 'operand', value: 'o2Val', label: 'O2值' },
  49. { type: 'operand', value: 'ch4Val', label: 'CH4值' },
  50. { type: 'operand', value: 'c2h4Val', label: 'C2H4值' },
  51. { type: 'operand', value: 'c2h2Val', label: 'C2H2值' },
  52. { type: 'operand', value: 'temperature', label: '温度' },
  53. { type: 'operand', value: 'fireAirTemperature', label: '气温' },
  54. { type: 'operand', value: 'fireWaterTemperature', label: '水温' },
  55. { type: 'operand', value: 'temperatureDifference', label: '温差' },
  56. { type: 'operand', value: 'stableDays', label: '稳定天数' },
  57. ],
  58. extra: [],
  59. },
  60. {
  61. key: 'operator',
  62. header: '计算符',
  63. type: 'operator',
  64. items: [
  65. { type: 'operator', value: '>', label: '>' },
  66. { type: 'operator', value: '>=', label: '≥' },
  67. { type: 'operator', value: '<', label: '<' },
  68. { type: 'operator', value: '<=', label: '≤' },
  69. { type: 'operator', value: '==', label: '=' },
  70. { type: 'operator', value: '+', label: '+' },
  71. { type: 'operator', value: '-', label: '-' },
  72. { type: 'operator', value: '*', label: '*' },
  73. { type: 'operator', value: '/', label: '/' },
  74. ],
  75. extra: [],
  76. },
  77. {
  78. key: 'logic',
  79. header: '逻辑符',
  80. type: 'logic',
  81. items: [
  82. { type: 'logic', value: '&&', label: '且' },
  83. { type: 'logic', value: '||', label: '或' },
  84. ],
  85. extra: [],
  86. },
  87. {
  88. key: 'paren',
  89. header: '括号',
  90. type: 'paren',
  91. items: [
  92. { type: 'leftParen', value: '(', label: '(' },
  93. { type: 'rightParen', value: ')', label: ')' },
  94. ],
  95. extra: [],
  96. },
  97. {
  98. key: 'number',
  99. header: '数值',
  100. type: 'number',
  101. items: [
  102. { type: 'number', value: '0', label: '0' },
  103. { type: 'number', value: '10', label: '10' },
  104. { type: 'number', value: '20', label: '20' },
  105. { type: 'number', value: '30', label: '30' },
  106. { type: 'number', value: '40', label: '40' },
  107. { type: 'number', value: '50', label: '50' },
  108. { type: 'number', value: '60', label: '60' },
  109. { type: 'number', value: '70', label: '70' },
  110. { type: 'number', value: '80', label: '80' },
  111. { type: 'number', value: '90', label: '90' },
  112. { type: 'number', value: '100', label: '100' },
  113. ],
  114. extra: [{ type: 'number', value: '0', label: '追加自定义值' }],
  115. },
  116. ];
  117. /** 显示名称映射 — 变量名/运算符 → 中文标签 */
  118. export const DEFAULT_DISPLAY_MAP: Record<string, string> = {
  119. '&&': '且',
  120. '||': '或',
  121. '>=': '≥',
  122. '<=': '≤',
  123. '==': '=',
  124. sourcePressureChange: '压差变化',
  125. coRzl: 'CO日增率',
  126. coZf: 'CO增幅',
  127. coAvg: 'CO平均值',
  128. coVal: 'CO值',
  129. co2Val: 'CO2值',
  130. co2Trend: 'CO2存在上升趋势',
  131. o2Val: 'O2值',
  132. ch4Val: 'CH4值',
  133. c2h4Val: 'C2H4值',
  134. c2h2Val: 'C2H2值',
  135. temperature: '温度',
  136. fireAirTemperature: '气温',
  137. fireWaterTemperature: '水温',
  138. temperatureDifference: '温差',
  139. stableDays: '稳定天数',
  140. };
  141. /** 基于 DEFAULT_ELEMENT_GROUPS 预计算的操作数集合 */
  142. export const DEFAULT_OPERAND_SET: Set<string> = buildOperandSet(DEFAULT_ELEMENT_GROUPS);