import {
  DevParamChillerUnit,
  DevParamCoolingPump,
  DevParamCoolingTower,
  DevParamCtrlCabinet,
} from '@/constants/device-params';

import ChillerUnit from './ChillerUnit.vue';
import CoolingPump from './CoolingPump.vue';
import CoolingTower from './CoolingTower.vue';
import CtrlCabinet from './CtrlCabinet.vue';

import type { Component } from 'vue';

type DeviceCardData = Partial<
  Record<
    DeviceType,
    {
      component: Component;
      paramCodes: string[];
    }
  >
>;

export const enum DeviceType {
  空 = 0,
  控制柜 = 1,
  冷水主机 = 2,
  露点仪 = 3,
  流量计 = 4,
  电表 = 5,
  其他传感器 = 6,
  阀门 = 7,
  循环水泵 = 8,
  冷却塔 = 9,
  风冷模块机组 = 10,
  冷却泵 = 11,
  冷冻泵 = 12,
  热水泵 = 13,
  二次冷冻泵 = 14,
  空调风柜 = 15,
  EC风机 = 16,
  其他设备 = 17,
}

export const enum ValveType {
  冷冻侧阀 = 101,
  冷却侧阀 = 102,
  进口阀 = 103,
  出口阀 = 104,
  旁通阀 = 105,
}

/**
 * 设备卡片数据对象
 * - 以设备类型的中文名称作为 key
 * - 以设备组件和参数编码列表作为 value
 */
export const deviceCardData: DeviceCardData = {
  [DeviceType.控制柜]: {
    component: CtrlCabinet,
    paramCodes: [
      DevParamCtrlCabinet.冷冻总管出水温度,
      DevParamCtrlCabinet.冷冻总管回水温度,
      DevParamCtrlCabinet.冷冻总管出水压力,
      DevParamCtrlCabinet.冷冻总管回水压力,
      DevParamCtrlCabinet.冷却总管出水温度,
      DevParamCtrlCabinet.冷却总管回水温度,
      DevParamCtrlCabinet.系统控制模式设定,
    ],
  },
  [DeviceType.冷却塔]: {
    component: CoolingTower,
    paramCodes: [
      DevParamCoolingTower.本地远程状态,
      DevParamCoolingTower.有功功率,
      DevParamCoolingTower.频率反馈,
      DevParamCoolingTower.运行时间,
    ],
  },
  [DeviceType.冷却泵]: {
    component: CoolingPump,
    paramCodes: [
      DevParamCoolingPump.本地远程状态,
      DevParamCoolingPump.有功功率,
      DevParamCoolingPump.频率反馈,
      DevParamCoolingPump.运行时间,
    ],
  },
  [DeviceType.冷冻泵]: {
    component: CoolingPump,
    paramCodes: [
      DevParamCoolingPump.本地远程状态,
      DevParamCoolingPump.有功功率,
      DevParamCoolingPump.频率反馈,
      DevParamCoolingPump.运行时间,
    ],
  },
  [DeviceType.冷水主机]: {
    component: ChillerUnit,
    paramCodes: [
      DevParamChillerUnit.COP,
      DevParamChillerUnit.制冷量,
      DevParamChillerUnit.有功功率,
      DevParamChillerUnit.负载率,
      DevParamChillerUnit.冷冻水出水温度设定值反馈,
      DevParamChillerUnit.今日耗电量,
      DevParamChillerUnit.本月耗电量,
      DevParamChillerUnit.冷冻水回水温度,
      DevParamChillerUnit.冷冻水出水温度,
      DevParamChillerUnit.蒸发压力,
      DevParamChillerUnit.蒸发温度,
      DevParamChillerUnit.冷却水回水温度,
      DevParamChillerUnit.冷却水出水温度,
      DevParamChillerUnit.冷凝压力,
      DevParamChillerUnit.冷凝温度,
      DevParamChillerUnit.排气温度,
      DevParamChillerUnit.吸气温度,
    ],
  },
};
