| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- import type { ElementGroup } from './types';
- import { buildOperandSet } from './parser';
- /** 模板选项 — 预设表达式 */
- export const DEFAULT_TEMPLATE_OPTIONS: { label: string; value: string }[] = [
- { label: '压差预警1', value: '20<=sourcePressureChange && sourcePressureChange<=40' },
- { label: '压差预警2', value: '40<sourcePressureChange && sourcePressureChange<=60' },
- { label: '压差预警3', value: '60<sourcePressureChange && sourcePressureChange<=80' },
- { label: '压差预警4', value: '80<sourcePressureChange' },
- { label: '火灾预警1', value: '((coRzl<=20||coZf<=0.5*coAvg)&&coVal<=10)||o2Val<=5&&temperatureDifference<2&&co2Val<0.5' },
- {
- label: '火灾预警2',
- value:
- '((coRzl>20&&coRzl<=50)||(0.5*coAvg<coZf&&coZf<=coAvg)||(coVal>10&&coVal<=50)||(temperatureDifference>=2&&temperatureDifference<=4))&&co2Val<0.5',
- },
- {
- label: '火灾预警3',
- value:
- '((coRzl>50&&coRzl<=100)||(coAvg<coZf&&coZf<=2*coAvg)||(coVal>=50&&coVal<=100)||(temperatureDifference>4&&temperatureDifference<=10))&&co2Val<0.5',
- },
- { label: '火灾预警4', value: 'coRzl>100||2*coAvg<coZf||coVal>100||temperatureDifference>10||(co2Val>=0.5&&co2Trend)' },
- { label: '闭外火灾预警1', value: 'temperatureDifference<2||ch4Val<0.5||coVal<5||o2Val<20' },
- { label: '闭外火灾预警2', value: 'temperatureDifference>=2&&temperatureDifference<=4||ch4Val>=0.5&&ch4Val<=1||coVal>=5&&coVal<10' },
- {
- label: '闭外火灾预警3',
- value: 'temperatureDifference>4&&temperatureDifference<=10&&temperature>=26||ch4Val>=1&&ch4Val<1.5||coVal>=10&&coVal<24||c2h4Val>0&&c2h2Val==0',
- },
- { label: '闭外火灾预警4', value: 'temperatureDifference>10&&temperature>=30||ch4Val>=1.5&&ch4Val<2||coVal>=24||c2h2Val>0' },
- {
- label: 'OPEN',
- value:
- '(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',
- },
- ];
- /** 元素库分组 — 定义表达式中可用的变量、运算符、逻辑符、括号和数值 */
- export const DEFAULT_ELEMENT_GROUPS: ElementGroup[] = [
- {
- key: 'gas',
- header: '监测变量',
- type: 'operand',
- items: [
- { type: 'operand', value: 'sourcePressureChange', label: '压差变化' },
- { type: 'operand', value: 'coRzl', label: 'CO日增率' },
- { type: 'operand', value: 'coZf', label: 'CO增幅' },
- { type: 'operand', value: 'coAvg', label: 'CO平均值' },
- { type: 'operand', value: 'coVal', label: 'CO值' },
- { type: 'operand', value: 'co2Val', label: 'CO2值' },
- { type: 'operand', value: 'co2Trend', label: 'CO2存在上升趋势' },
- { type: 'operand', value: 'o2Val', label: 'O2值' },
- { type: 'operand', value: 'ch4Val', label: 'CH4值' },
- { type: 'operand', value: 'c2h4Val', label: 'C2H4值' },
- { type: 'operand', value: 'c2h2Val', label: 'C2H2值' },
- { type: 'operand', value: 'temperature', label: '温度' },
- { type: 'operand', value: 'fireAirTemperature', label: '气温' },
- { type: 'operand', value: 'fireWaterTemperature', label: '水温' },
- { type: 'operand', value: 'temperatureDifference', label: '温差' },
- { type: 'operand', value: 'stableDays', label: '稳定天数' },
- ],
- extra: [],
- },
- {
- key: 'operator',
- header: '计算符',
- type: 'operator',
- items: [
- { type: 'operator', value: '>', label: '>' },
- { type: 'operator', value: '>=', label: '≥' },
- { type: 'operator', value: '<', label: '<' },
- { type: 'operator', value: '<=', label: '≤' },
- { type: 'operator', value: '==', label: '=' },
- { type: 'operator', value: '+', label: '+' },
- { type: 'operator', value: '-', label: '-' },
- { type: 'operator', value: '*', label: '*' },
- { type: 'operator', value: '/', label: '/' },
- ],
- extra: [],
- },
- {
- key: 'logic',
- header: '逻辑符',
- type: 'logic',
- items: [
- { type: 'logic', value: '&&', label: '且' },
- { type: 'logic', value: '||', label: '或' },
- ],
- extra: [],
- },
- {
- key: 'paren',
- header: '括号',
- type: 'paren',
- items: [
- { type: 'leftParen', value: '(', label: '(' },
- { type: 'rightParen', value: ')', label: ')' },
- ],
- extra: [],
- },
- {
- key: 'number',
- header: '数值',
- type: 'number',
- items: [
- { type: 'number', value: '0', label: '0' },
- { type: 'number', value: '10', label: '10' },
- { type: 'number', value: '20', label: '20' },
- { type: 'number', value: '30', label: '30' },
- { type: 'number', value: '40', label: '40' },
- { type: 'number', value: '50', label: '50' },
- { type: 'number', value: '60', label: '60' },
- { type: 'number', value: '70', label: '70' },
- { type: 'number', value: '80', label: '80' },
- { type: 'number', value: '90', label: '90' },
- { type: 'number', value: '100', label: '100' },
- ],
- extra: [{ type: 'number', value: '0', label: '追加自定义值' }],
- },
- ];
- /** 显示名称映射 — 变量名/运算符 → 中文标签 */
- export const DEFAULT_DISPLAY_MAP: Record<string, string> = {
- '&&': '且',
- '||': '或',
- '>=': '≥',
- '<=': '≤',
- '==': '=',
- sourcePressureChange: '压差变化',
- coRzl: 'CO日增率',
- coZf: 'CO增幅',
- coAvg: 'CO平均值',
- coVal: 'CO值',
- co2Val: 'CO2值',
- co2Trend: 'CO2存在上升趋势',
- o2Val: 'O2值',
- ch4Val: 'CH4值',
- c2h4Val: 'C2H4值',
- c2h2Val: 'C2H2值',
- temperature: '温度',
- fireAirTemperature: '气温',
- fireWaterTemperature: '水温',
- temperatureDifference: '温差',
- stableDays: '稳定天数',
- };
- /** 基于 DEFAULT_ELEMENT_GROUPS 预计算的操作数集合 */
- export const DEFAULT_OPERAND_SET: Set<string> = buildOperandSet(DEFAULT_ELEMENT_GROUPS);
|