Files
controller-wisetopvue/src/data/config-table/index.js
T
2025-08-29 17:36:48 +08:00

173 lines
3.9 KiB
JavaScript

import EliteEDC from './EliteEDC/index'
import EliteEIS from './EliteEIS/index'
import EliteTrigger from './EliteTrigger/index'
import CPG from './CPG/index'
import PEL20 from './PEL_2_0/index'
import PEL30 from './PEL_3_0/index'
import store from '@/store/index'
// object saving library name mapping table
const libraryNameMappingTable = {
EDC: EliteEDC,
EliteZM15: EliteEDC,
'Elite_EDC_1.4': null,
'Elite_EDC_1.5': EliteEDC,
'Elite_EDC_1.5re': EliteEDC,
'Elite_EDC_1.5r2': EliteEDC,
'Elite_EDC_2.0': EliteEDC,
'Elite_BAT_1.0': EliteEDC,
EIS: EliteEIS,
'Elite_EIS_1.0': EliteEIS,
'Elite_EIS_1.1': EliteEIS,
'Elite_EIS_MINI_1.0': EliteEIS,
'Elite_TRIG_0.1': EliteTrigger,
'Elite_MEGAFLY_0.1': null,
CPG: CPG,
'PEL_2.0': PEL20,
'PEL_3.0': PEL30,
}
// object saving serial number mapping table
const serialNumberMappingTable = {
0: {
2: {
1: {
5: null, // EDC1.4
6: EliteEDC, // EDC1.5
7: EliteEDC, // EDC1.5re
8: EliteEDC, // EDC1.5r2
9: EliteEDC, // EDC2.0
},
},
3: {
1: {
0: EliteEDC, // BAT0.1
1: EliteEDC, // BAT1.0
},
},
4: {
1: {
0: EliteEIS, // EIS1.0
1: EliteEIS, // EIS1.1
2: EliteEIS, // EIS mini1.0
},
},
5: {
1: {
0: EliteTrigger, // TRIG0.1
},
},
6: {
1: {
0: null, // MEAGFLY0.1
},
},
7: {
0: {
0: PEL20,
1: PEL20,
2: PEL30,
},
},
8: {
0: {
0: CPG,
1: CPG,
},
},
},
}
/**
* return config table by library or serial number (type)
* @param {String | Object} type
* @returns {Object} : config
*/
function getConfig (type) {
if (type === undefined || type === null) return
if (typeof type === 'number') {
const deviceList = store.getters.getField('taskContent').deviceListNew
if (deviceList === undefined) return
const device = deviceList.find(ele => ele.memory_board === type)
if (device === undefined) return
return libraryNameMappingTable[device.library_name]
}
// library name
if (typeof type === 'string') {
return libraryNameMappingTable[type]
}
// serial number
if (typeof type === 'object') {
return serialNumberMappingTable[type[0]][type[1]][type[2]][type[3]]
}
}
/**
* return mode config table by type and mode
* @param {String | Object} type
* @param {Number} mode
* @returns {Object} : mode-config
*/
function getModeConfig (type, mode) {
return getConfig(type).MODE[mode]
}
/**
* return parameter config table by type and parameter name
* @param {String | Object} type
* @param {String} parameterName
* @returns {Object} : parameter-config
*/
function getParameterConfig (deviceType, parameterName) {
return getConfig(deviceType)[parameterName]
}
/**
* return channel config table by type and mode
* @param {String | Object} type
* @param {String} mode
* @param {String | Number} channel
* @returns {Object} : channel-config
*/
function getChannelConfig (type, mode, channel) {
if (channel === undefined) {
return getModeConfig(type, mode).channels
}
return getModeConfig(type, mode).channels[channel]
}
/**
* return chart config table by type and mode and chartType
* @param {String | Object} type
* @param {String} mode
* @param {String} chartType
* @returns {Object} : chart-config
*/
function getChartConfig (type, mode, chartType = 'default') {
return getModeConfig(type, mode).charts[chartType]
}
/**
* return mode's parameter list
* @param {String | Object} type
* @param {String} mode
* @returns {Object} : parameter list
*/
function getModeParameter (type, mode) {
return getModeConfig(type, mode).parameter
}
const configTable = {
getConfig,
getModeConfig,
getChannelConfig,
getParameterConfig,
getChartConfig,
getModeParameter,
EliteEDC,
EliteEIS,
}
export default configTable