Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3db09734d2 | |||
| c0e3a9c61a | |||
| bcf7b51dc6 | |||
| ba660ac952 | |||
| d171d8b572 | |||
| 1e57bde1df | |||
| 0946b01a41 |
@@ -8,7 +8,7 @@
|
||||
|
||||
<script>
|
||||
import { mapFields } from 'vuex-map-fields'
|
||||
import paramTable from '@/data/param-table/index.js'
|
||||
import paramTable from '@/data/config-table/index.js'
|
||||
|
||||
export default {
|
||||
name: 'show-parameter',
|
||||
|
||||
@@ -22,7 +22,7 @@ import { mapFields } from 'vuex-map-fields'
|
||||
import newDownload from '@/factories/file/downloadFactory'
|
||||
import newChannel from '@/factories/file/channelFactory'
|
||||
import { taskInfo } from '@/data/task/TaskInfo'
|
||||
import paramTable from '@/data/param-table/index'
|
||||
import configTable from '@/data/config-table/index'
|
||||
|
||||
export default {
|
||||
name: 'Download',
|
||||
@@ -108,7 +108,7 @@ export default {
|
||||
}
|
||||
if (meta !== undefined) {
|
||||
this.metaInfo = meta
|
||||
const channelParamObj = paramTable[meta.device.library_name].MODE[meta.parameter_set.MODE].channels
|
||||
const channelParamObj = configTable[meta.device.library_name].MODE[meta.parameter_set.MODE].channels
|
||||
const channelArray = allChannel === 'all' ? JSON.parse(this.metaInfo.channels) : Object.keys(channelParamObj).filter(ele => ele !== 'time')
|
||||
const channelList = []
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import newDownload from '@/factories/file/downloadFactory'
|
||||
import newChannel from '@/factories/file/channelFactory'
|
||||
import progressModal from '@/components/common/progressBarByValueModal/progressModal.vue'
|
||||
import { taskInfo } from '@/data/task/TaskInfo'
|
||||
import paramTable from '@/data/param-table/index'
|
||||
import configTable from '@/data/config-table/index'
|
||||
|
||||
export default {
|
||||
name: 'DownloadOffline',
|
||||
@@ -113,7 +113,7 @@ export default {
|
||||
}
|
||||
if (meta !== undefined) {
|
||||
this.metaInfo = meta
|
||||
const channelParamObj = paramTable[meta.device.library_name].MODE[meta.parameter_set.MODE].channels
|
||||
const channelParamObj = configTable[meta.device.library_name].MODE[meta.parameter_set.MODE].channels
|
||||
const channelArray = allChannel === 'all' ? JSON.parse(this.metaInfo.channels) : Object.keys(channelParamObj).filter(ele => ele !== 'time')
|
||||
const channelList = []
|
||||
|
||||
|
||||
@@ -108,6 +108,7 @@ import { mapFields } from 'vuex-map-fields'
|
||||
import { mapActions } from 'vuex'
|
||||
import taskTypes from '@/store/modules/task/content/types'
|
||||
import TaskFormula from './formula/TaskFormula'
|
||||
import { v4 as uuid } from 'uuid'
|
||||
|
||||
// TODO change chart data tag format
|
||||
|
||||
@@ -261,12 +262,22 @@ export default {
|
||||
this.showShutdownModal = true
|
||||
break
|
||||
case 'start':
|
||||
// register default chart again
|
||||
await this.taskContentChartDefaultChartGenerator({
|
||||
_deviceList: this.deviceListNew,
|
||||
_itemID: parseInt(mes[1]),
|
||||
_chartID: null,
|
||||
_type: 'device',
|
||||
})
|
||||
|
||||
// remove mapping ID chart series data
|
||||
for (const chart in this.chartData) {
|
||||
this.taskContentChartResetSeriesData({
|
||||
chartID: chart,
|
||||
mappingID: mes[1],
|
||||
})
|
||||
}
|
||||
|
||||
device = this.deviceListNew.find((ele) => ele.memory_board === parseInt(mes[1]))
|
||||
device.status = 1
|
||||
break
|
||||
@@ -347,12 +358,20 @@ export default {
|
||||
)
|
||||
},
|
||||
refreshData: function () {
|
||||
// TODO don't need to refresh chart with stop status
|
||||
for (const chart in this.chartData) {
|
||||
this.taskContentChartRefreshData({
|
||||
chartID: parseInt(chart),
|
||||
deviceList: this.deviceListNew,
|
||||
})
|
||||
// find each chart mappingID with device memory_board
|
||||
const device = this.deviceListNew.find(ele => String(ele.memory_board) === String(this.chartData[chart].mappingID))
|
||||
// device not found continue
|
||||
if (device === undefined) {
|
||||
continue
|
||||
}
|
||||
// device is running refresh chart
|
||||
if (device.status === 1) {
|
||||
this.taskContentChartRefreshData({
|
||||
chartID: chart,
|
||||
deviceList: this.deviceListNew,
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
refreshDevicesWindow: function () {
|
||||
@@ -362,25 +381,35 @@ export default {
|
||||
}
|
||||
},
|
||||
addChart: async function (isDefault) {
|
||||
this.taskContentChartAdd({
|
||||
chartID: this.taskContentChartNumber,
|
||||
maxDots: 4000,
|
||||
// create chartID with uuid instead of length of chart list
|
||||
const newChart = await this.taskContentChartAdd({
|
||||
chartID: uuid(),
|
||||
maxDots: 5000,
|
||||
gridLength: 1,
|
||||
})
|
||||
|
||||
// createby default
|
||||
if (isDefault === true) {
|
||||
newChart.createdBy = 'default'
|
||||
}
|
||||
// createby manaul
|
||||
if (isDefault === false) {
|
||||
newChart.createdBy = 'manual'
|
||||
}
|
||||
|
||||
if (this.$refs.chart_ref != null) {
|
||||
this.$refs.chart_ref.forEach(ref => {
|
||||
ref.refreshMappingSelect()
|
||||
})
|
||||
}
|
||||
this.taskContentChartRefreshPanel()
|
||||
this.taskContentChartNumber++
|
||||
|
||||
// save chart config to web storage
|
||||
if (!isDefault) {
|
||||
await this.taskContentChartSaveToCache()
|
||||
}
|
||||
this.pageToast('The chart has been added.')
|
||||
|
||||
return this.taskContentChartNumber - 1
|
||||
return newChart.chartID
|
||||
},
|
||||
refreshChartSetting: async function () {
|
||||
if (this.$refs.chart_ref != null) {
|
||||
@@ -462,9 +491,11 @@ export default {
|
||||
return chart
|
||||
},
|
||||
addDevice: async function (deviceID, memoryBoardID) {
|
||||
// subscribe datastream when add device
|
||||
this.mqttSub(`${taskInfo.getTaskInfo().controllerID}/data_server/device_data_stream/${deviceID}/+`)
|
||||
// add mapping chart
|
||||
await this.addMappingChart(deviceID)
|
||||
|
||||
// register default chart
|
||||
await this.taskContentChartDefaultChartGenerator({
|
||||
_deviceList: this.deviceListNew,
|
||||
_itemID: deviceID,
|
||||
@@ -567,6 +598,7 @@ export default {
|
||||
taskTypes.chart.add,
|
||||
taskTypes.chart.defaultChartGenerator,
|
||||
taskTypes.chart.reset,
|
||||
taskTypes.chart.resetSeriesData,
|
||||
taskTypes.chart.refreshData,
|
||||
taskTypes.chart.refreshChart,
|
||||
taskTypes.chart.refreshPanel,
|
||||
|
||||
@@ -121,7 +121,7 @@ export default {
|
||||
},
|
||||
props: {
|
||||
chartID: {
|
||||
type: Number,
|
||||
type: [Number, String],
|
||||
required: true,
|
||||
},
|
||||
cardclass: {
|
||||
@@ -275,7 +275,7 @@ export default {
|
||||
},
|
||||
refreshMappingSelect: async function () {
|
||||
this.setMappingSelect(this.chartData[this.chartID].mappingID)
|
||||
if (this.chartData[this.chartID].mappingID !== -1 && this.chartData[this.chartID].mappingID != null) {
|
||||
if (this.chartData[this.chartID].mappingID !== '-1' && this.chartData[this.chartID].mappingID != null) {
|
||||
taskInfo.getMappingList().forEach(item => {
|
||||
if (item.id === this.chartData[this.chartID].mappingID) {
|
||||
this.setChartName(item.name)
|
||||
|
||||
@@ -65,7 +65,7 @@ export default {
|
||||
name: 'canvas-chart-filter',
|
||||
props: {
|
||||
chartID: {
|
||||
type: Number,
|
||||
type: [Number, String],
|
||||
required: true,
|
||||
},
|
||||
filterIndex: {
|
||||
|
||||
@@ -29,7 +29,7 @@ export default {
|
||||
},
|
||||
props: {
|
||||
chartID: {
|
||||
type: Number,
|
||||
type: [Number, String],
|
||||
required: true,
|
||||
},
|
||||
chartRef: {
|
||||
|
||||
@@ -66,7 +66,7 @@ export default {
|
||||
name: 'canvas-chart-filter-individual-filter',
|
||||
props: {
|
||||
chartID: {
|
||||
type: Number,
|
||||
type: [Number, String],
|
||||
required: true,
|
||||
},
|
||||
seriesIndex: {
|
||||
|
||||
@@ -30,7 +30,7 @@ export default {
|
||||
name: 'canvas-chart-setting',
|
||||
props: {
|
||||
chartID: {
|
||||
type: Number,
|
||||
type: [Number, String],
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -95,7 +95,7 @@ export default {
|
||||
name: 'canvas-chart-source',
|
||||
props: {
|
||||
chartID: {
|
||||
type: Number,
|
||||
type: [Number, String],
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -44,8 +44,8 @@
|
||||
<div>
|
||||
<file-control-window :ref="'fcwindow_ref'" :device="device" class="pl-0 pr-0" />
|
||||
</div>
|
||||
<div v-if="device.library_name.includes('Elite')">
|
||||
<elite-parameter-window :ref="'epwindow_ref'" :device="device" class="pl-0 pr-0" />
|
||||
<div>
|
||||
<device-parameter-window :ref="'epwindow_ref'" :device="device" class="pl-0 pr-0" />
|
||||
</div>
|
||||
</div>
|
||||
</va-collapse>
|
||||
@@ -54,7 +54,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import EliteParameterWindow from '../parameter/EliteParameterWindow'
|
||||
import DeviceParameterWindow from '../parameter/DeviceParameterWindow'
|
||||
// import EliteParameterWindow from '../parameter/EliteParameterWindow'
|
||||
// import NeuliveParameterWindow from '../parameter/NeuliveParameterWindow'
|
||||
import FileControlWindow from '../meta/FileControlWindow'
|
||||
import { mapActions } from 'vuex'
|
||||
@@ -65,7 +66,8 @@ import api from '@/data/api'
|
||||
export default {
|
||||
name: 'TaskDeviceList',
|
||||
components: {
|
||||
EliteParameterWindow,
|
||||
DeviceParameterWindow,
|
||||
// EliteParameterWindow,
|
||||
// NeuliveParameterWindow,
|
||||
FileControlWindow,
|
||||
},
|
||||
|
||||
@@ -126,7 +126,7 @@ import DevMode from '../parameter/itemNew/DevMode'
|
||||
import EliteParameterRecordingElitePulseSensing from '../parameter/itemNew/PulseSensingNew/EliteParameterRecordingElitePulseSensing'
|
||||
import { VueFinalModal } from 'vue-final-modal'
|
||||
import { mapFields } from 'vuex-map-fields'
|
||||
import parameterTable from '@/data/param-table/index.js'
|
||||
import configTable from '@/data/config-table/index'
|
||||
|
||||
export default {
|
||||
name: 'EliteParameterRecordingElitezm15',
|
||||
@@ -148,7 +148,9 @@ export default {
|
||||
},
|
||||
library: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
serialNumber: {
|
||||
type: String,
|
||||
},
|
||||
device: {
|
||||
type: Object,
|
||||
@@ -156,6 +158,21 @@ export default {
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
parameterTable () {
|
||||
if (this.library !== undefined) {
|
||||
const config = configTable.getConfig(this.library)
|
||||
if (config !== undefined) {
|
||||
return config
|
||||
}
|
||||
}
|
||||
if (this.serialNumber !== undefined) {
|
||||
const config = configTable.getConfig(this.serialNumber)
|
||||
if (config !== undefined) {
|
||||
return config
|
||||
}
|
||||
}
|
||||
return null
|
||||
},
|
||||
parameterArrayInMode () {
|
||||
return this.workingModeSelect && this.parameterTable.MODE[this.workingModeSelect.id].parameter
|
||||
},
|
||||
@@ -184,7 +201,6 @@ export default {
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
parameterTable: parameterTable[this.library],
|
||||
showModal: false,
|
||||
workingModeSelect: null,
|
||||
workingModeOptions: [],
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
<template>
|
||||
<div v-if="device">
|
||||
<device-parameter-recording
|
||||
:parameter="device.configuration"
|
||||
:library="device.library_name"
|
||||
:serialNumber="device.serial_number"
|
||||
:device="device"
|
||||
@sendInstruction="sendInstruction"
|
||||
@getParameter="getParameter"
|
||||
@setParameter="setParameter"
|
||||
@setParameterWithDebounce="setParameterWithDebounce"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import DeviceParameterRecording from './DeviceParameterRecording'
|
||||
import { taskInfo } from '../../../../data/task/TaskInfo'
|
||||
import _ from 'lodash'
|
||||
|
||||
export default {
|
||||
name: 'EliteParameterWindow',
|
||||
components: {
|
||||
DeviceParameterRecording,
|
||||
},
|
||||
props: {
|
||||
device: {
|
||||
type: Object,
|
||||
},
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
}
|
||||
},
|
||||
mqtt: {
|
||||
},
|
||||
methods: {
|
||||
mqttPublish: function (topic, mes) {
|
||||
this.$mqtt.publish(topic, mes)
|
||||
},
|
||||
sendInstruction: function (instruction) {
|
||||
this.mqttPublish(taskInfo.getTaskInfo().controllerID + '_user', JSON.stringify({
|
||||
header: 'device_instruction/0',
|
||||
device: this.device.mac_address,
|
||||
instruction: instruction,
|
||||
}))
|
||||
},
|
||||
getParameter: function (parameterName) {
|
||||
this.mqttPublish(taskInfo.getTaskInfo().controllerID + '_user', JSON.stringify({
|
||||
header: 'device_parameter_value/0',
|
||||
device: this.device.mac_address,
|
||||
parameter: parameterName,
|
||||
}))
|
||||
},
|
||||
setParameter: function (parameterName, parameterValue) {
|
||||
this.mqttPublish(taskInfo.getTaskInfo().controllerID + '_user', JSON.stringify({
|
||||
header: 'device_parameter/0',
|
||||
device: this.device.mac_address,
|
||||
parameter: parameterName,
|
||||
content: parameterValue,
|
||||
}))
|
||||
},
|
||||
setParameterWithDebounce: _.debounce(function (parameterName, parameterValue) {
|
||||
this.mqttPublish(taskInfo.getTaskInfo().controllerID + '_user', JSON.stringify({
|
||||
header: 'device_parameter/0',
|
||||
device: this.device.mac_address,
|
||||
parameter: parameterName,
|
||||
content: parameterValue,
|
||||
}))
|
||||
}, 100),
|
||||
},
|
||||
mounted () {
|
||||
},
|
||||
watch: {
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -120,7 +120,7 @@ import DevMode from '../parameter/itemNew/DevMode'
|
||||
import EliteParameterRecordingElitePulseSensing from '../parameter/itemNew/PulseSensingNew/EliteParameterRecordingElitePulseSensing'
|
||||
import { VueFinalModal } from 'vue-final-modal'
|
||||
import { mapFields } from 'vuex-map-fields'
|
||||
import parameterTable from '@/data/param-table/index.js'
|
||||
import parameterTable from '@/data/config-table/index.js'
|
||||
|
||||
export default {
|
||||
name: 'EliteParameterRecordingElitezm15',
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
import EliteEDC from './EliteEDC/index'
|
||||
import EliteEIS from './EliteEIS/index'
|
||||
|
||||
// object saving library name mapping table
|
||||
const libraryNameMappingTable = {
|
||||
EliteZM15: EliteEDC,
|
||||
'EliteEDC1.4': null,
|
||||
'EliteEDC1.5': EliteEDC,
|
||||
'EliteEDC1.5re': EliteEDC,
|
||||
'EliteEDC1.5r2': EliteEDC,
|
||||
'BAT1.0': null,
|
||||
'EIS1.0': EliteEIS,
|
||||
'EIS1.1': EliteEIS,
|
||||
'TRIG0.1': null,
|
||||
'MEGAFLY0.1': null,
|
||||
}
|
||||
|
||||
// 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
|
||||
},
|
||||
},
|
||||
3: {
|
||||
1: {
|
||||
0: null, // BAT1.0
|
||||
},
|
||||
},
|
||||
4: {
|
||||
0: EliteEIS, // EIS1.0
|
||||
1: EliteEIS, // EIS1.1
|
||||
},
|
||||
5: {
|
||||
1: {
|
||||
0: null, // TRIG0.1
|
||||
},
|
||||
},
|
||||
6: {
|
||||
1: {
|
||||
0: null, // MEAGFLY0.1
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* return config table by libray or serial number (type)
|
||||
* @param {String | Object} type
|
||||
* @returns {Object} : config
|
||||
*/
|
||||
function getConfig (type) {
|
||||
// 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
|
||||
@@ -1,9 +0,0 @@
|
||||
import EliteZM15 from './EliteZM15/index'
|
||||
import EliteEIS from './EliteEIS/index'
|
||||
|
||||
const paramTable = {
|
||||
EliteZM15,
|
||||
EliteEIS,
|
||||
}
|
||||
|
||||
export default paramTable
|
||||
@@ -1,6 +1,6 @@
|
||||
function newChart (chartID) {
|
||||
function newChart (chartID, numOfCharts) {
|
||||
return {
|
||||
chartID: parseInt(chartID),
|
||||
chartID: chartID,
|
||||
chartType: 'detail',
|
||||
chartDevice: 'elite', // elite or neulive
|
||||
chartMode: 0,
|
||||
@@ -8,10 +8,11 @@ function newChart (chartID) {
|
||||
chartYUnit: '',
|
||||
chartXMode: 'value', // value or time
|
||||
chartYMode: 'value', // value or time
|
||||
cardName: 'chart' + String(chartID),
|
||||
cardName: 'chart' + String(numOfCharts),
|
||||
cardHeight: '500px',
|
||||
cardWidth: 'auto',
|
||||
mappingID: -1,
|
||||
mappingID: '-1',
|
||||
createdBy: '', // manual ror default
|
||||
run: false,
|
||||
timer: 0,
|
||||
legend: {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import types from '@/store/modules/download/types'
|
||||
import golbalMethods from '@/data/global/global'
|
||||
import paramTable from '@/data/param-table/index'
|
||||
import configTable from '@/data/config-table/index'
|
||||
import api from '@/data/api'
|
||||
|
||||
const typePath = types.export
|
||||
@@ -49,7 +49,7 @@ const exportActs = {
|
||||
metaPath[metaPath.length - 1].split('.')[0],
|
||||
]
|
||||
|
||||
const paramObj = paramTable[libraryName]
|
||||
const paramObj = configTable[libraryName]
|
||||
const modeObj = paramObj.MODE[meta.parameter_set.MODE]
|
||||
|
||||
const param = modeObj.headerParameter(meta.parameter_set)
|
||||
@@ -120,7 +120,7 @@ const exportActs = {
|
||||
[typePath.getTitle]: function ({ state, getters, commit, dispatch }, payload) {
|
||||
const meta = state.metaInfo
|
||||
const { library_name: libraryName } = meta.device
|
||||
const modeObj = paramTable[libraryName].MODE[meta.parameter_set.MODE]
|
||||
const modeObj = configTable[libraryName].MODE[meta.parameter_set.MODE]
|
||||
const downloadInfo = state.downloadInfo
|
||||
const titleArray = []
|
||||
const channelString = ''
|
||||
|
||||
@@ -20,27 +20,25 @@ const chartActs = {
|
||||
[typePath.initCustomizedFromCache]: async ({ state, getters, commit, dispatch }, payload) => {
|
||||
const cacheData = await localforage.getItem('chart_data')
|
||||
if (cacheData !== null) {
|
||||
// use ID to create new chart by cache
|
||||
for (const _chart of Object.values(cacheData)) {
|
||||
if (_chart.mappingID === -1) { // not default chart
|
||||
const newChartID = state.taskContentChartNumber
|
||||
dispatch(typePath.add, {
|
||||
chartID: newChartID,
|
||||
maxDots: _chart.maxDots,
|
||||
gridLength: _chart.grid.length,
|
||||
})
|
||||
for (let gridIndex = 0; gridIndex < _chart.grid.length; gridIndex++) {
|
||||
if (gridIndex in _chart.gridSource) {
|
||||
dispatch(typePath.registerFromCache, {
|
||||
chartID: newChartID,
|
||||
gridIndex: gridIndex,
|
||||
gridSource: _chart.gridSource[gridIndex],
|
||||
})
|
||||
}
|
||||
dispatch(typePath.add, {
|
||||
chartID: _chart.chartID,
|
||||
maxDots: _chart.maxDots,
|
||||
gridLength: _chart.grid.length,
|
||||
})
|
||||
for (let gridIndex = 0; gridIndex < _chart.grid.length; gridIndex++) {
|
||||
if (gridIndex in _chart.gridSource) {
|
||||
dispatch(typePath.registerFromCache, {
|
||||
chartID: _chart.chartID,
|
||||
gridIndex: gridIndex,
|
||||
gridSource: _chart.gridSource[gridIndex],
|
||||
})
|
||||
}
|
||||
state.taskContentChartNumber++
|
||||
dispatch(typePath.refreshPanel)
|
||||
}
|
||||
state.chartData[_chart.chartID].createdBy = 'manual'
|
||||
}
|
||||
dispatch(typePath.refreshPanel)
|
||||
}
|
||||
},
|
||||
/**
|
||||
@@ -50,12 +48,10 @@ const chartActs = {
|
||||
[typePath.saveToCache]: async ({ state, getters, commit, dispatch }, payload) => {
|
||||
const _chartData = {}
|
||||
for (const [_id, _chart] of Object.entries(state.chartData)) {
|
||||
if (_chart.mappingID === -1) { // not default chart
|
||||
// manual chart clear series data
|
||||
if (_chart.createdBy === 'manual') {
|
||||
_chartData[_id] = JSON.parse(JSON.stringify(_chart))
|
||||
if (_chartData[_id].series.data != null) {
|
||||
_chartData[_id].series.data.length = 0
|
||||
}
|
||||
_chartData[_id].series.length = 0
|
||||
_chartData[_id].series.map((ele) => { ele.data.length = 0 })
|
||||
}
|
||||
}
|
||||
await localforage.setItem('chart_data', _chartData)
|
||||
@@ -70,8 +66,8 @@ const chartActs = {
|
||||
*/
|
||||
[typePath.add]: ({ state, getters, commit, dispatch }, payload) => {
|
||||
const { chartID, maxDots, gridLength } = payload
|
||||
if (state.chartData[parseInt(chartID)] == null) {
|
||||
state.chartData[parseInt(chartID)] = newChart(chartID)
|
||||
if (state.chartData[chartID] == null) {
|
||||
state.chartData[chartID] = newChart(chartID, Object.keys(state.chartData).length)
|
||||
state.chartData[chartID].maxDots = maxDots
|
||||
state.chartData[chartID].tooltip = newTooltip()
|
||||
dispatch(typePath.updateGridList, { chartID: chartID, length: gridLength })
|
||||
@@ -80,6 +76,7 @@ const chartActs = {
|
||||
return state.chartData[chartID]
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* register source channel setting from cache
|
||||
*
|
||||
@@ -362,7 +359,6 @@ const chartActs = {
|
||||
return parseFloat(val / 1000).toFixed(2) + 'uA'
|
||||
}
|
||||
state.chartData[chartID].chartYUnit = 'uA' // nA * 1000
|
||||
console.log(state.chartData[chartID])
|
||||
break
|
||||
case 2:
|
||||
state.chartData[chartID].yAxis[_yAxisIndex].axisLabel.formatter = function (val) {
|
||||
@@ -515,7 +511,14 @@ const chartActs = {
|
||||
if (!state.chartData[chartID].gridSource[gridIndex].some(el => el.name === _gridSeries.name)) {
|
||||
state.chartData[chartID].gridSource[gridIndex].push(_gridSeries)
|
||||
}
|
||||
// console.log(state.chartData[chartID])
|
||||
|
||||
// assign mappingID with device ID
|
||||
if (deviceIDX >= 0) {
|
||||
state.chartData[chartID].mappingID = deviceIDX
|
||||
}
|
||||
if (deviceIDY >= 0) {
|
||||
state.chartData[chartID].mappingID = deviceIDY
|
||||
}
|
||||
return state.chartData[chartID]
|
||||
},
|
||||
/**
|
||||
@@ -537,7 +540,7 @@ const chartActs = {
|
||||
* @param {String} chartID
|
||||
*/
|
||||
[typePath.refreshData]: ({ state, getters, commit, dispatch }, payload) => {
|
||||
const { chartID, deviceList } = payload
|
||||
const { chartID } = payload
|
||||
if (state.chartData[chartID] == null) {
|
||||
return false
|
||||
}
|
||||
@@ -710,24 +713,12 @@ const chartActs = {
|
||||
// series data list shift by time
|
||||
if (series.data.length > 0) {
|
||||
if (series.xAxisSource[0] === -1) {
|
||||
if (deviceList.find(ele => ele.memory_board === series.yAxisSource[0]).library_name.includes('Elite')) {
|
||||
if (series.data.length > state.chartData[chartID].maxDots) {
|
||||
series.data.splice(0, series.data.length - state.chartData[chartID].maxDots)
|
||||
}
|
||||
} else {
|
||||
if (series.data[series.data.length - 1][0] - series.data[0][0] > 3000000) {
|
||||
series.data.splice(0, popData.length)
|
||||
}
|
||||
if (series.data.length > state.chartData[chartID].maxDots) {
|
||||
series.data.splice(0, series.data.length - state.chartData[chartID].maxDots)
|
||||
}
|
||||
} else if (series.yAxisSource[0] === -1) {
|
||||
if (deviceList.find(ele => ele.memory_board === series.xAxisSource[0]).library_name.includes('Elite')) {
|
||||
if (series.data.length > state.chartData[chartID].maxDots) {
|
||||
series.data.splice(0, series.data.length - state.chartData[chartID].maxDots)
|
||||
}
|
||||
} else {
|
||||
if (series.data[series.data.length - 1][1] - series.data[0][1] > 3000000) {
|
||||
series.data.splice(0, popData.length)
|
||||
}
|
||||
if (series.data.length > state.chartData[chartID].maxDots) {
|
||||
series.data.splice(0, series.data.length - state.chartData[chartID].maxDots)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1002,7 +993,7 @@ const chartActs = {
|
||||
mappingID: state.chartData[_chartID].mappingID,
|
||||
cardName: state.chartData[_chartID].cardName,
|
||||
})
|
||||
state.chartData[_chartID].mappingID = parseInt(item.id)
|
||||
state.chartData[_chartID].mappingID = item.id
|
||||
switch (_type) {
|
||||
case 'device':
|
||||
_chartRegisterDevice(_chartID, item)
|
||||
@@ -1016,21 +1007,23 @@ const chartActs = {
|
||||
let isSetting = false
|
||||
|
||||
for (const chartID in state.chartData) {
|
||||
if (parseInt(state.chartData[chartID].mappingID) === parseInt(item.id)) {
|
||||
isSetting = true
|
||||
dispatch(typePath.reset, {
|
||||
chartID: chartID,
|
||||
mappingID: state.chartData[chartID].mappingID,
|
||||
cardName: state.chartData[chartID].cardName,
|
||||
})
|
||||
state.chartData[chartID].mappingID = parseInt(item.id)
|
||||
switch (_type) {
|
||||
case 'device':
|
||||
_chartRegisterDevice(chartID, item)
|
||||
break
|
||||
case 'formula':
|
||||
_chartRegisterFormula(chartID, item)
|
||||
break
|
||||
if (state.chartData[chartID].mappingID === item.id) {
|
||||
if (state.chartData[chartID].createdBy === 'default') {
|
||||
isSetting = true
|
||||
dispatch(typePath.reset, {
|
||||
chartID: chartID,
|
||||
mappingID: state.chartData[chartID].mappingID,
|
||||
cardName: state.chartData[chartID].cardName,
|
||||
})
|
||||
state.chartData[chartID].mappingID = item.id
|
||||
switch (_type) {
|
||||
case 'device':
|
||||
_chartRegisterDevice(chartID, item)
|
||||
break
|
||||
case 'formula':
|
||||
_chartRegisterFormula(chartID, item)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1053,12 +1046,13 @@ const chartActs = {
|
||||
state.chartData[chartID].legend.data.length = 0
|
||||
state.chartData[chartID].xAxis.length = 0
|
||||
state.chartData[chartID].yAxis.length = 0
|
||||
state.chartData[chartID].gridSource.length = 0
|
||||
if (state.chartData[chartID].series.data != null) {
|
||||
state.chartData[chartID].series.data.length = 0
|
||||
}
|
||||
state.chartData[chartID].series.length = 0
|
||||
if (mappingID == null) {
|
||||
state.chartData[chartID].mappingID = -1
|
||||
state.chartData[chartID].mappingID = '-1'
|
||||
}
|
||||
if (cardName == null) {
|
||||
state.chartData[chartID].cardName = 'chart' + String(chartID)
|
||||
@@ -1066,6 +1060,22 @@ const chartActs = {
|
||||
state.chartData[chartID].dataZoom = null
|
||||
dispatch(typePath.updateGridList, { chartID: chartID, length: 1 })
|
||||
},
|
||||
|
||||
/**
|
||||
* reset chart option
|
||||
*
|
||||
* @param {String} chartID
|
||||
* @param {String} mappingID
|
||||
* @param {String} cardName
|
||||
*/
|
||||
[typePath.resetSeriesData]: ({ state, getters, commit, dispatch }, payload) => {
|
||||
const { chartID, mappingID } = payload
|
||||
if (String(mappingID) === state.chartData[chartID].mappingID) {
|
||||
for (const i in state.chartData[chartID].series) {
|
||||
state.chartData[chartID].series[i].data.length = 0
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
* refresh (key++) EChart
|
||||
*
|
||||
|
||||
@@ -9,6 +9,7 @@ const types = {
|
||||
updateGridList: 'taskContentChartUpdateGridList',
|
||||
defaultChartGenerator: 'taskContentChartDefaultChartGenerator',
|
||||
reset: 'taskContentChartReset',
|
||||
resetSeriesData: 'taskContentChartResetSeriesData',
|
||||
refreshData: 'taskContentChartRefreshData',
|
||||
refreshChart: 'taskContentChartRefreshChart',
|
||||
refreshPanel: 'taskContentChartRefreshPanel',
|
||||
|
||||
Reference in New Issue
Block a user