diff --git a/src/components/BX/rmsWorker.js b/src/components/BX/rmsWorker.js index 7c7f58d..e919c1d 100644 --- a/src/components/BX/rmsWorker.js +++ b/src/components/BX/rmsWorker.js @@ -1,311 +1,152 @@ -// 辅助函数 -const getMax = (temp, tempA, tempB, tempC) => { - temp = temp > tempA ? temp : tempA; - temp = temp > tempB ? temp : tempB; - if (tempC !== undefined) { - temp = temp > tempC ? temp : tempC; +import { + buildRmsMinPoint, + buildWaveTitle, + emptyRmsPrimarySeries, + emptyRmsSecondarySeries, + getMax, + getMaxTwo, + getMin, + getMinOpen, + getSampleStep, + getXRange, + isPrimaryValue, + normalizeStats, + parsePhaseTitles, + shouldSamplePoint, +} from "./waveWorkerUtils.js"; + +const emptyStats = () => ({ max: -Infinity, min: Infinity }); + +const pushRmsSeries = (series, time, vals, iphasic, usePrimary) => { + if (usePrimary) { + series.rmsFA.push([time, vals[0]]); + if (iphasic >= 2) series.rmsFB.push([time, vals[1]]); + if (iphasic >= 3) series.rmsFC.push([time, vals[2]]); + } else { + series.rmsSA.push([time, vals[0]]); + if (iphasic >= 2) series.rmsSB.push([time, vals[1]]); + if (iphasic >= 3) series.rmsSC.push([time, vals[2]]); } - return temp; }; -const getMaxTwo = (temp, tempA, tempB) => { - temp = temp > tempA ? temp : tempA; - temp = temp > tempB ? temp : tempB; - return temp; -}; - -const getMin = (temp, tempA, tempB, tempC) => { - temp = temp < tempA ? temp : tempA; - temp = temp < tempB ? temp : tempB; - if (tempC !== undefined) { - temp = temp < tempC ? temp : tempC; - } - return temp; -}; - -const getMinOpen = (temp, tempA, tempB) => { - temp = temp < tempA ? temp : tempA; - temp = temp < tempB ? temp : tempB; - return temp; -}; - -// 数据处理函数 -const fliteWaveData = (wp, step, iphasicValue, isOpen) => { +const fliteWaveData = (wp, step, iphasicValue, isOpen, value) => { const rmsData = wp.listRmsData; const pt = Number(wp.pt) / 1000; const ct = Number(wp.ct); - const titleList = wp.waveTitle; - let xishu = pt; - let aTitle = "", - bTitle = "", - cTitle = "", - unit = "电压"; - let rmsvFirstX = 0, - rmsvFirstY = 0, - rmsvSecondX = 0, - rmsvSecondY = 0, - firstZhou = "a", - secondeZhou = "a"; - let ifmax = 0, - ifmin = 0, - ismax = 0, - ismin = 0, - rfmax = 0, - rfmin = 0, - rsmax = 0, - rsmin = 0; + const { aTitle, bTitle, cTitle, unit } = parsePhaseTitles(wp.waveTitle, iphasicValue, step); + const xishu = unit === "电流" ? ct : pt; + const usePrimary = isPrimaryValue(value); - const shunshiFA = []; - const shunshiFB = []; - const shunshiFC = []; - const shunshiSA = []; - const shunshiSB = []; - const shunshiSC = []; - const rmsFA = []; - const rmsFB = []; - const rmsFC = []; - const rmsSA = []; - const rmsSB = []; - const rmsSC = []; + let rmsvFirstX = 0, rmsvFirstY = Infinity, rmsvSecondX = 0, rmsvSecondY = Infinity; + let firstZhou = "a", secondeZhou = "a"; + const RMSF = emptyStats(); + const RMSS = emptyStats(); + const RMSFWave = emptyRmsPrimarySeries(); + const RMSSWave = emptyRmsSecondarySeries(); + const activeSeries = usePrimary ? RMSFWave : RMSSWave; + const activeStats = usePrimary ? RMSF : RMSS; - - - if (titleList[iphasicValue * step + 1]?.substring(0, 1) !== "U") { - xishu = ct; - unit = "电流"; + if (!rmsData?.[0] || rmsData[0][iphasicValue * step + 1] === undefined) { + return { + RMSF: normalizeStats(RMSF), + RMSS: normalizeStats(RMSS), + RMSFMinDetail: { rmsvFirstX, rmsvFirstY, firstZhou }, + RMSSMinDetail: { rmsvSecondX, rmsvSecondY, secondeZhou }, + RMSFWave, + RMSSWave, + title: { aTitle, bTitle, cTitle, unit }, + unit, + }; } - for (let i = 1; i <= iphasicValue; i++) { - switch (i) { - case 1: - aTitle = titleList[iphasicValue * step + i]?.substring(1) || ""; - break; - case 2: - bTitle = titleList[iphasicValue * step + i]?.substring(1) || ""; - break; - case 3: - cTitle = titleList[iphasicValue * step + i]?.substring(1) || ""; - break; - } - } + const sampleStep = getSampleStep(rmsData.length); + const base = iphasicValue * step; - if (rmsData[0] && rmsData[0][iphasicValue * step + 1] !== undefined) { - rfmax = rmsData[0][iphasicValue * step + 1] * xishu; - rfmin = rmsData[0][iphasicValue * step + 1] * xishu; - rmsvFirstY = rmsData[0][iphasicValue * step + 1] * xishu; - rmsvFirstX = rmsData[0][0]; - rsmax = rmsData[0][iphasicValue * step + 1]; - rsmin = rmsData[0][iphasicValue * step + 1]; - rmsvSecondY = rmsData[0][iphasicValue * step + 1]; - rmsvSecondX = rmsData[0][0]; - } - - for (let rms = 0; rms < rmsData.length; rms++) { - if (!rmsData[rms] || rmsData[rms][iphasicValue * step + 1] === undefined) { - break; - } + for (let i = 0; i < rmsData.length; i++) { + const row = rmsData[i]; + if (!row || row[base + 1] === undefined) break; + const time = row[0]; + const scaled = [row[base + 1] * xishu, row[base + 2] * xishu, row[base + 3] * xishu]; + const raw = [row[base + 1], row[base + 2], row[base + 3]]; + const vals = usePrimary ? scaled : raw; switch (iphasicValue) { case 1: - const rmsFirstA = rmsData[rms][iphasicValue * step + 1] * xishu; - rmsFA.push([rmsData[rms][0], rmsFirstA]); - rfmax = rfmax > rmsFirstA ? rfmax : rmsFirstA; - rfmin = rfmin < rmsFirstA ? rfmin : rmsFirstA; - if (rfmin < rmsvFirstY) { - rmsvFirstY = rfmin; - firstZhou = "a"; - rmsvFirstX = rmsData[rms][0]; - } - - const rmsSecondA = rmsData[rms][iphasicValue * step + 1]; - rmsSA.push([rmsData[rms][0], rmsSecondA]); - rsmax = rsmax > rmsSecondA ? rsmax : rmsSecondA; - rsmin = rsmin < rmsSecondA ? rsmin : rmsSecondA; - if (rsmin < rmsvSecondY) { - rmsvSecondY = rsmin; - secondeZhou = "a"; - rmsvSecondX = rmsData[rms][0]; + activeStats.max = Math.max(activeStats.max, vals[0]); + activeStats.min = Math.min(activeStats.min, vals[0]); + if (usePrimary && activeStats.min < rmsvFirstY) { + rmsvFirstY = activeStats.min; firstZhou = "a"; rmsvFirstX = time; + } else if (!usePrimary && activeStats.min < rmsvSecondY) { + rmsvSecondY = activeStats.min; secondeZhou = "a"; rmsvSecondX = time; } break; case 2: - const rmsFirstA2 = rmsData[rms][iphasicValue * step + 1] * xishu; - const rmsFirstB2 = rmsData[rms][iphasicValue * step + 2] * xishu; - rmsFA.push([rmsData[rms][0], rmsFirstA2]); - rmsFB.push([rmsData[rms][0], rmsFirstB2]); - rfmax = getMaxTwo(rfmax, rmsFirstA2, rmsFirstB2); - rfmin = getMinOpen(rfmin, rmsFirstA2, rmsFirstB2); - if (rfmin < rmsvFirstY) { - rmsvFirstY = rfmin; - if (rfmin === rmsFirstA2) { - firstZhou = "a"; - } else if (rfmin === rmsFirstB2) { - firstZhou = "b"; - } - rmsvFirstX = rmsData[rms][0]; - } - - const rmsSecondA2 = rmsData[rms][iphasicValue * step + 1]; - const rmsSecondB2 = rmsData[rms][iphasicValue * step + 2]; - rmsSA.push([rmsData[rms][0], rmsSecondA2]); - rmsSB.push([rmsData[rms][0], rmsSecondB2]); - rsmax = getMaxTwo(rsmax, rmsSecondA2, rmsSecondB2); - rsmin = getMinOpen(rsmin, rmsSecondA2, rmsSecondB2); - if (rsmin < rmsvSecondY) { - rmsvSecondY = rsmin; - if (rsmin === rmsSecondA2) { - secondeZhou = "a"; - } else if (rsmin === rmsSecondB2) { - secondeZhou = "b"; - } - rmsvSecondX = rmsData[rms][0]; + activeStats.max = getMaxTwo(activeStats.max, vals[0], vals[1]); + activeStats.min = getMinOpen(activeStats.min, vals[0], vals[1]); + if (usePrimary && activeStats.min < rmsvFirstY) { + rmsvFirstY = activeStats.min; + firstZhou = activeStats.min === vals[0] ? "a" : "b"; + rmsvFirstX = time; + } else if (!usePrimary && activeStats.min < rmsvSecondY) { + rmsvSecondY = activeStats.min; + secondeZhou = activeStats.min === vals[0] ? "a" : "b"; + rmsvSecondX = time; } break; case 3: - const rmsFirstA3 = rmsData[rms][iphasicValue * step + 1] * xishu; - const rmsFirstB3 = rmsData[rms][iphasicValue * step + 2] * xishu; - const rmsFirstC3 = rmsData[rms][iphasicValue * step + 3] * xishu; - rmsFA.push([rmsData[rms][0], rmsFirstA3]); - rmsFB.push([rmsData[rms][0], rmsFirstB3]); - rmsFC.push([rmsData[rms][0], rmsFirstC3]); - rfmax = getMax(rfmax, rmsFirstA3, rmsFirstB3, rmsFirstC3); - rfmin = isOpen - ? getMinOpen(rfmin, rmsFirstA3, rmsFirstC3) - : getMin(rfmin, rmsFirstA3, rmsFirstB3, rmsFirstC3); - if (rfmin < rmsvFirstY) { - rmsvFirstY = rfmin; - if (rfmin === rmsFirstA3) { - firstZhou = "a"; - } else if (rfmin === rmsFirstB3) { - firstZhou = "b"; - } else { - firstZhou = "c"; - } - rmsvFirstX = rmsData[rms][0]; - } - - const rmsSecondA3 = rmsData[rms][iphasicValue * step + 1]; - const rmsSecondB3 = rmsData[rms][iphasicValue * step + 2]; - const rmsSecondC3 = rmsData[rms][iphasicValue * step + 3]; - rmsSA.push([rmsData[rms][0], rmsSecondA3]); - rmsSB.push([rmsData[rms][0], rmsSecondB3]); - rmsSC.push([rmsData[rms][0], rmsSecondC3]); - rsmax = getMax(rsmax, rmsSecondA3, rmsSecondB3, rmsSecondC3); - rsmin = isOpen - ? getMinOpen(rsmin, rmsSecondA3, rmsSecondC3) - : getMin(rsmin, rmsSecondA3, rmsSecondB3, rmsSecondC3); - if (rsmin < rmsvSecondY) { - rmsvSecondY = rsmin; - if (rsmin === rmsSecondA3) { - secondeZhou = "a"; - } else if (rsmin === rmsSecondB3) { - secondeZhou = "b"; - } else { - secondeZhou = "c"; - } - rmsvSecondX = rmsData[rms][0]; + activeStats.max = getMax(activeStats.max, vals[0], vals[1], vals[2]); + activeStats.min = getMin(activeStats.min, vals[0], vals[1], vals[2]); + if (usePrimary && activeStats.min < rmsvFirstY) { + rmsvFirstY = activeStats.min; + firstZhou = activeStats.min === vals[0] ? "a" : activeStats.min === vals[1] ? "b" : "c"; + rmsvFirstX = time; + } else if (!usePrimary && activeStats.min < rmsvSecondY) { + rmsvSecondY = activeStats.min; + secondeZhou = activeStats.min === vals[0] ? "a" : activeStats.min === vals[1] ? "b" : "c"; + rmsvSecondX = time; } break; } + if (shouldSamplePoint(i, rmsData.length, sampleStep)) { + pushRmsSeries(activeSeries, time, vals, iphasicValue, usePrimary); + } } - const instantF = { max: ifmax, min: ifmin }; - const instantS = { max: ismax, min: ismin }; - const RMSF = { max: rfmax, min: rfmin }; - const RMSS = { max: rsmax, min: rsmin }; - const RMSFMinDetail = { rmsvFirstX, rmsvFirstY, firstZhou }; - const RMSSMinDetail = { rmsvSecondX, rmsvSecondY, secondeZhou }; - const shunshiF = { shunshiFA, shunshiFB, shunshiFC }; - const shunshiS = { shunshiSA, shunshiSB, shunshiSC }; - const RMSFWave = { rmsFA, rmsFB, rmsFC }; - const RMSSWave = { rmsSA, rmsSB, rmsSC }; - const title = { aTitle, bTitle, cTitle, unit }; - - return { - - instantF, - instantS, - RMSF, - RMSS, - RMSFMinDetail, - RMSSMinDetail, - shunshiF, - shunshiS, + RMSF: normalizeStats(RMSF), + RMSS: normalizeStats(RMSS), + RMSFMinDetail: { rmsvFirstX, rmsvFirstY, firstZhou }, + RMSSMinDetail: { rmsvSecondX, rmsvSecondY, secondeZhou }, RMSFWave, RMSSWave, - title, + title: { aTitle, bTitle, cTitle, unit }, unit, }; }; -// 监听消息 -self.onmessage = function (e) { - const { wp, isOpen, value, boxoList } = JSON.parse(e.data); - +self.addEventListener("message", (e) => { try { + const { wp, isOpen, boxoList, taskId, value = 2 } = e.data; + const valueType = Number(value) || 2; const iphasicValue = wp.iphasic || 1; - const picCounts = (wp.waveTitle.length - 1) / iphasicValue; const waveDatas = []; - for (let i = 0; i < picCounts; i++) { - const data = fliteWaveData(wp, i, iphasicValue, isOpen,boxoList); - waveDatas.push(data); + waveDatas.push(fliteWaveData(wp, i, iphasicValue, isOpen, valueType)); } -// 处理标题 - let titles = ""; - if (boxoList.systemType == "pms") { - titles = - "变电站名称:" + - boxoList.powerStationName + - " 监测点名称:" + - boxoList.measurementPointName + - " 发生时刻:" + - boxoList.startTime + - " 残余电压:" + - (boxoList.featureAmplitude * 100).toFixed(2) + - "% 持续时间:" + - boxoList.duration + - "s"; - } else if (boxoList.systemType == "ZL") { - titles = - " 监测点名称:" + - boxoList.equipmentName + - " 发生时刻:" + - boxoList.startTime + - " 残余电压:" + - boxoList.evtParamVVaDepth + - " 持续时间:" + - boxoList.evtParamTm + - "s"; - } else { - titles = - "变电站名称:" + - boxoList.subName + - " 监测点名称:" + - boxoList.lineName + - " 发生时刻:" + - boxoList.startTime + - " 残余电压:" + - (boxoList.featureAmplitude * 100).toFixed(2) + - "% 持续时间:" + - boxoList.duration + - "s"; - } - // 发送处理结果回主线程 self.postMessage({ - titles: titles, success: true, + taskId, + titles: buildWaveTitle(boxoList), waveDatas, + xRange: getXRange(wp.listRmsData), + rmsMinPoint: buildRmsMinPoint(wp, valueType), time: wp.time, type: wp.waveType, severity: wp.yzd, iphasic: iphasicValue, }); } catch (error) { - self.postMessage({ - success: false, - error: error.message, - }); + self.postMessage({ success: false, taskId: e.data?.taskId, error: error.message }); } -}; +}); diff --git a/src/components/BX/rmsboxi.vue b/src/components/BX/rmsboxi.vue index 0d0c12a..28a6b96 100644 --- a/src/components/BX/rmsboxi.vue +++ b/src/components/BX/rmsboxi.vue @@ -12,13 +12,25 @@ \ No newline at end of file diff --git a/src/components/BX/shuWorker.js b/src/components/BX/shuWorker.js index 11d7758..2a729ac 100644 --- a/src/components/BX/shuWorker.js +++ b/src/components/BX/shuWorker.js @@ -1,179 +1,124 @@ -// waveData.worker.js -self.addEventListener('message', function(e) { - const { wp, value, iphasic, isOpen, boxoList } = JSON.parse(e.data); - - // 处理波形数据的函数 - const fliteWaveData = (wp, step) => { - // 将原有的fliteWaveData函数实现复制到这里 - const shunData = wp.listWaveData; - const pt = Number(wp.pt) / 1000; - const ct = Number(wp.ct); - const titleList = wp.waveTitle; - let xishu = pt; - let aTitle = '', bTitle = '', cTitle = '', unit = '电压'; - let ifmax = 0, ifmin = 0, ismax = 0, ismin = 0; +import { + buildWaveTitle, + emptyInstantPrimarySeries, + emptyInstantSecondarySeries, + getSampleStep, + getXRange, + isPrimaryValue, + normalizeStats, + parsePhaseTitles, + shouldSamplePoint, +} from "./waveWorkerUtils.js"; - const shunshiFA = []; - const shunshiFB = []; - const shunshiFC = []; - const shunshiSA = []; - const shunshiSB = []; - const shunshiSC = []; +const emptyStats = () => ({ max: -Infinity, min: Infinity }); - if (shunData.length > 0) { - if (titleList[iphasic * step + 1]?.substring(0, 1) !== 'U') { - xishu = ct; - unit = '电流'; - } +const updateStats = (stats, vals, iphasic) => { + const [a, b, c] = vals; + if (iphasic === 1) { + stats.max = Math.max(stats.max, a); + stats.min = Math.min(stats.min, a); + return; + } + if (iphasic === 2) { + stats.max = Math.max(stats.max, a, b); + stats.min = Math.min(stats.min, a, b); + return; + } + stats.max = Math.max(stats.max, a, b, c); + stats.min = Math.min(stats.min, a, b, c); +}; - for (let i = 1; i <= iphasic; i++) { - switch (i) { - case 1: - aTitle = titleList[iphasic * step + i]?.substring(1) || ''; - break; - case 2: - bTitle = titleList[iphasic * step + i]?.substring(1) || ''; - break; - case 3: - cTitle = titleList[iphasic * step + i]?.substring(1) || ''; - break; - } - } - - if (shunData[0][iphasic * step + 1] !== undefined) { - ifmax = shunData[0][iphasic * step + 1] * xishu; - ifmin = shunData[0][iphasic * step + 1] * xishu; - ismax = shunData[0][iphasic * step + 1]; - ismin = shunData[0][iphasic * step + 1]; - } - - for (let shun = 0; shun < shunData.length; shun++) { - if (shunData[shun][iphasic * step + 1] === undefined) { - break; - } - - switch (iphasic) { - case 1: - const shunFirstA = shunData[shun][iphasic * step + 1] * xishu; - shunshiFA.push([shunData[shun][0], shunFirstA]); - ifmax = Math.max(ifmax, shunFirstA); - ifmin = Math.min(ifmin, shunFirstA); - - const shunSecondA = shunData[shun][iphasic * step + 1]; - shunshiSA.push([shunData[shun][0], shunSecondA]); - ismax = Math.max(ismax, shunSecondA); - ismin = Math.min(ismin, shunSecondA); - break; - case 2: - const shunFirstA2 = shunData[shun][iphasic * step + 1] * xishu; - const shunFirstB2 = shunData[shun][iphasic * step + 2] * xishu; - shunshiFA.push([shunData[shun][0], shunFirstA2]); - shunshiFB.push([shunData[shun][0], shunFirstB2]); - ifmax = Math.max(ifmax, shunFirstA2, shunFirstB2); - ifmin = Math.min(ifmin, shunFirstA2, shunFirstB2); - - const shunSecondA2 = shunData[shun][iphasic * step + 1]; - const shunSecondB2 = shunData[shun][iphasic * step + 2]; - shunshiSA.push([shunData[shun][0], shunSecondA2]); - shunshiSB.push([shunData[shun][0], shunSecondB2]); - ismax = Math.max(ismax, shunSecondA2, shunSecondB2); - ismin = Math.min(ismin, shunSecondA2, shunSecondB2); - break; - case 3: - const shunFirstA3 = shunData[shun][iphasic * step + 1] * xishu; - const shunFirstB3 = shunData[shun][iphasic * step + 2] * xishu; - const shunFirstC3 = shunData[shun][iphasic * step + 3] * xishu; - shunshiFA.push([shunData[shun][0], shunFirstA3]); - shunshiFB.push([shunData[shun][0], shunFirstB3]); - shunshiFC.push([shunData[shun][0], shunFirstC3]); - ifmax = Math.max(ifmax, shunFirstA3, shunFirstB3, shunFirstC3); - ifmin = isOpen ? Math.min(ifmin, shunFirstA3, shunFirstC3) : Math.min(ifmin, shunFirstA3, shunFirstB3, shunFirstC3); - - const shunSecondA3 = shunData[shun][iphasic * step + 1]; - const shunSecondB3 = shunData[shun][iphasic * step + 2]; - const shunSecondC3 = shunData[shun][iphasic * step + 3]; - shunshiSA.push([shunData[shun][0], shunSecondA3]); - shunshiSB.push([shunData[shun][0], shunSecondB3]); - shunshiSC.push([shunData[shun][0], shunSecondC3]); - ismax = Math.max(ismax, shunSecondA3, shunSecondB3, shunSecondC3); - ismin = isOpen ? Math.min(ismin, shunSecondA3, shunSecondC3) : Math.min(ismin, shunSecondA3, shunSecondB3, shunSecondC3); - break; - } - } - } - - const instantF = { max: ifmax, min: ifmin }; - const instantS = { max: ismax, min: ismin }; - const shunshiF = { shunshiFA, shunshiFB, shunshiFC }; - const shunshiS = { shunshiSA, shunshiSB, shunshiSC }; - const title = { aTitle, bTitle, cTitle, unit }; - - return { instantF, instantS, shunshiF, shunshiS, title, unit }; - }; - - // 处理标题 - let titles = ''; - if (boxoList.systemType == 'pms') { - titles = '变电站名称:' + - boxoList.powerStationName + - ' 监测点名称:' + - boxoList.measurementPointName + - ' 发生时刻:' + - boxoList.startTime + - ' 残余电压:' + - (boxoList.featureAmplitude * 100).toFixed(2) + - '% 持续时间:' + - boxoList.duration + - 's'; - } else if (boxoList.systemType == 'ZL') { - titles = ' 监测点名称:' + - boxoList.equipmentName + - ' 发生时刻:' + - boxoList.startTime + - ' 残余电压:' + - boxoList.evtParamVVaDepth + - ' 持续时间:' + - boxoList.evtParamTm + - 's'; +const pushSeries = (series, time, vals, iphasic, usePrimary) => { + if (usePrimary) { + series.shunshiFA.push([time, vals[0]]); + if (iphasic >= 2) series.shunshiFB.push([time, vals[1]]); + if (iphasic >= 3) series.shunshiFC.push([time, vals[2]]); } else { - titles = '变电站名称:' + - boxoList.subName + - ' 监测点名称:' + - boxoList.lineName + - ' 发生时刻:' + - boxoList.startTime + - ' 残余电压:' + - (boxoList.featureAmplitude * 100).toFixed(2) + - '% 持续时间:' + - boxoList.duration + - 's'; + series.shunshiSA.push([time, vals[0]]); + if (iphasic >= 2) series.shunshiSB.push([time, vals[1]]); + if (iphasic >= 3) series.shunshiSC.push([time, vals[2]]); + } +}; + +const fliteWaveData = (wp, step, iphasic, isOpen, value) => { + const shunData = wp.listWaveData; + const pt = Number(wp.pt) / 1000; + const ct = Number(wp.ct); + const { aTitle, bTitle, cTitle, unit } = parsePhaseTitles(wp.waveTitle, iphasic, step); + const xishu = unit === "电流" ? ct : pt; + const usePrimary = isPrimaryValue(value); + + const shunshiF = emptyInstantPrimarySeries(); + const shunshiS = emptyInstantSecondarySeries(); + const instantF = emptyStats(); + const instantS = emptyStats(); + const activeSeries = usePrimary ? shunshiF : shunshiS; + const activeStats = usePrimary ? instantF : instantS; + + if (!shunData?.length || shunData[0][iphasic * step + 1] === undefined) { + return { + instantF: normalizeStats(instantF), + instantS: normalizeStats(instantS), + shunshiF, + shunshiS, + title: { aTitle, bTitle, cTitle, unit }, + unit, + }; } - const iphasicValue = wp.iphasic || 1; - const picCounts = (wp.waveTitle.length - 1) / iphasicValue; - const waveDatas = []; + const sampleStep = getSampleStep(shunData.length); + const base = iphasic * step; - for (let i = 0; i < picCounts; i++) { - const data = fliteWaveData(wp, i); - waveDatas.push(data); + for (let i = 0; i < shunData.length; i++) { + const row = shunData[i]; + if (row[base + 1] === undefined) break; + const scaledVals = [row[base + 1] * xishu, row[base + 2] * xishu, row[base + 3] * xishu]; + const rawVals = [row[base + 1], row[base + 2], row[base + 3]]; + const vals = usePrimary ? scaledVals : rawVals; + updateStats(activeStats, vals, iphasic); + if (shouldSamplePoint(i, shunData.length, sampleStep)) { + pushSeries(activeSeries, row[0], vals, iphasic, usePrimary); + } } - const time = wp.time; - const type = wp.waveType; - let severity = wp.yzd; + return { + instantF: normalizeStats(instantF), + instantS: normalizeStats(instantS), + shunshiF, + shunshiS, + title: { aTitle, bTitle, cTitle, unit }, + unit, + }; +}; - if (severity < 0) { - severity = '/'; - type = '/'; +self.addEventListener("message", (e) => { + try { + const { wp, isOpen, boxoList, taskId, value = 2 } = e.data; + const valueType = Number(value) || 2; + const iphasicValue = wp.iphasic || 1; + const picCounts = (wp.waveTitle.length - 1) / iphasicValue; + const waveDatas = []; + for (let i = 0; i < picCounts; i++) { + waveDatas.push(fliteWaveData(wp, i, iphasicValue, isOpen, valueType)); + } + let severity = wp.yzd; + let type = wp.waveType; + if (severity < 0) { + severity = "/"; + type = "/"; + } + self.postMessage({ + success: true, + taskId, + waveDatas, + xRange: getXRange(wp.listWaveData), + time: wp.time, + type, + severity, + titles: buildWaveTitle(boxoList), + iphasic: iphasicValue, + }); + } catch (error) { + self.postMessage({ success: false, taskId: e.data?.taskId, error: error.message }); } - - // 将处理结果发送回主线程 - self.postMessage({ - waveDatas, - time, - type, - severity, - titles, - iphasic: iphasicValue - }); -}); \ No newline at end of file +}); diff --git a/src/components/BX/shushiboxi.vue b/src/components/BX/shushiboxi.vue index 6828bb4..f5e3f32 100644 --- a/src/components/BX/shushiboxi.vue +++ b/src/components/BX/shushiboxi.vue @@ -1,863 +1,945 @@ \ No newline at end of file +defineExpose({ backbxlb, query }); + diff --git a/src/components/BX/waveForm.vue b/src/components/BX/waveForm.vue index b65bb65..a61ad7b 100644 --- a/src/components/BX/waveForm.vue +++ b/src/components/BX/waveForm.vue @@ -1,11 +1,10 @@