Skip to content

Commit

Permalink
6.1.101
Browse files Browse the repository at this point in the history
🌟 新增
rtw對目前測站新增XY軸波形顯示
🐞 修正
可能rtw畫波形圖時顯示異常(亂畫)
🔌 最佳化
依賴更新
  • Loading branch information
yayacat committed Apr 10, 2024
1 parent 525ff48 commit ed6100f
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 53 deletions.
2 changes: 2 additions & 0 deletions TREM.Electron/Views/RTSView.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
<div id="wave-4"></div>
<div id="wave-5"></div>
<div id="wave-6"></div>
<div id="wave-7"></div>
<div id="wave-8"></div>
</div>
</div>
<script src="../js/theme.js"></script>
Expand Down
5 changes: 5 additions & 0 deletions TREM.Electron/js/earthquake.js
Original file line number Diff line number Diff line change
Expand Up @@ -2288,6 +2288,11 @@ function handler(Json) {
: (amount > 3) ? "pga2"
: "pga1";

if (setting["Real-time.websocket"] === "yayacat" && Alert) {
intensity = Math.round(current_data.i);
level_class = IntensityToClassString(intensity);
}

if (intensity > MaxIntensity1) MaxIntensity1 = intensity;

if (intensity > MaxIntensity2) MaxIntensity2 = intensity;
Expand Down
153 changes: 113 additions & 40 deletions TREM.Electron/js/rts.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function handleWindowControls() {
}
}

const wave_count = +localStorage.getItem("displayWaveCount") ?? 8;
const wave_count = +localStorage.getItem("displayWaveCount") ?? 12;

console.log(`lb-${route.auto_run()}`);
let ws = new WebSocket(route.randomWSBaseUrl());
Expand Down Expand Up @@ -173,6 +173,8 @@ const Real_time_station_run = () => {
Realtimestation4.split("-")[2],
Realtimestation5.split("-")[2],
Realtimestation.split("-")[2],
Realtimestation.split("-")[2],
Realtimestation.split("-")[2],
]);
};

Expand Down Expand Up @@ -205,6 +207,8 @@ const Real_time_station = () => {
Realtimestation4.split("-")[2],
Realtimestation5.split("-")[2],
Realtimestation.split("-")[2],
Realtimestation.split("-")[2],
Realtimestation.split("-")[2],
]);
} else if (themedark != app.Configuration.data["theme.dark"]) {
themedark = app.Configuration.data["theme.dark"];
Expand All @@ -215,6 +219,8 @@ const Real_time_station = () => {
Realtimestation4.split("-")[2],
Realtimestation5.split("-")[2],
Realtimestation.split("-")[2],
Realtimestation.split("-")[2],
Realtimestation.split("-")[2],
]);
}
} catch (error) {
Expand Down Expand Up @@ -338,6 +344,8 @@ const charts = [
echarts.init(document.getElementById("wave-4"), null, { height: 560 / 6, width: 400 }),
echarts.init(document.getElementById("wave-5"), null, { height: 560 / 6, width: 400 }),
echarts.init(document.getElementById("wave-6"), null, { height: 560 / 6, width: 400 }),
echarts.init(document.getElementById("wave-7"), null, { height: 560 / 6, width: 400 }),
echarts.init(document.getElementById("wave-8"), null, { height: 560 / 6, width: 400 }),
];
const chartdata = [
[],
Expand All @@ -346,6 +354,8 @@ const chartdata = [
[],
[],
[],
[],
[],
];

for (let i = 0; i < wave_count; i++) {
Expand All @@ -359,18 +369,26 @@ for (let i = 0; i < wave_count; i++) {
* @param {string[]} ids
*/
const setCharts = (ids) => {
for (let i = 0; i < 6; i++)
for (let i = 0; i < 8; i++)
if (data.stations?.[ids[i]]?.uuid) {
if (chartuuids[i] != data.stations[ids[i]].uuid) {
chartuuids[i] = data.stations[ids[i]].uuid;
chartdata[i] = [];
}

charts[i].setOption({
title: {
text: `${data.stations[ids[i]].Loc} | ${chartuuids[i]}`,
},
});
if (i >= 5) {

Check failure on line 379 in TREM.Electron/js/rts.js

View workflow job for this annotation

GitHub Actions / macOS_x64

Unnecessary { after 'if' condition

Check failure on line 379 in TREM.Electron/js/rts.js

View workflow job for this annotation

GitHub Actions / Windows_x64

Unnecessary { after 'if' condition

Check failure on line 379 in TREM.Electron/js/rts.js

View workflow job for this annotation

GitHub Actions / Linux_amd64

Unnecessary { after 'if' condition
charts[i].setOption({
title: {
text: `${data.stations[ids[i]].Loc} | ${chartuuids[i]} | ${(i == 5) ? "X" : (i == 6) ? "Y" : (i == 7) ? "Z" : ""}`,
},
});
} else {

Check failure on line 385 in TREM.Electron/js/rts.js

View workflow job for this annotation

GitHub Actions / macOS_x64

Unnecessary { after 'else'

Check failure on line 385 in TREM.Electron/js/rts.js

View workflow job for this annotation

GitHub Actions / Windows_x64

Unnecessary { after 'else'

Check failure on line 385 in TREM.Electron/js/rts.js

View workflow job for this annotation

GitHub Actions / Linux_amd64

Unnecessary { after 'else'
charts[i].setOption({
title: {
text: `${data.stations[ids[i]].Loc} | ${chartuuids[i]}`,
},
});
}
} else {
chartuuids.splice(i, 1);
charts[i].clear();
Expand Down Expand Up @@ -429,49 +447,102 @@ const wave = (wave_data) => {

let id;

for (const i in chartuuids)
for (const i in chartuuids) {
if (parseInt(chartuuids[i].split("-")[2]) === wave_data_id)
id = i;
if (parseInt(Realtimestation.split("-")[2]) === wave_data_id)

Check warning on line 453 in TREM.Electron/js/rts.js

View workflow job for this annotation

GitHub Actions / macOS_x64

Expected blank line before this statement

Check warning on line 453 in TREM.Electron/js/rts.js

View workflow job for this annotation

GitHub Actions / Windows_x64

Expected blank line before this statement

Check warning on line 453 in TREM.Electron/js/rts.js

View workflow job for this annotation

GitHub Actions / Linux_amd64

Expected blank line before this statement
id = 10;
}

if (id == 10) {
for (let i = 0; i < n; i++) {
const calculatedTime = time + (i * timeOffset);
chartdata[5].push({
name : now.getTime(),
value : [new Date(calculatedTime).getTime(), Math.round(+wave_data.X[i] * 1000)],
});
chartdata[6].push({
name : now.getTime(),
value : [new Date(calculatedTime).getTime(), Math.round(+wave_data.Y[i] * 1000)],
});
chartdata[7].push({
name : now.getTime(),
value : [new Date(calculatedTime).getTime(), Math.round(+wave_data.Z[i] * 1000)],
});
}

for (let i = 0; i < n; i++) {
const calculatedTime = time + (i * timeOffset);
chartdata[id].push({
name : now.getTime(),
value : [new Date(calculatedTime).getTime(), Math.round(+wave_data.Z[i] * 1000)],
});
}
for (let j = 5; j < 8; j++) {
while (true)
if (chartdata[j].length > (chartuuids[6].startsWith("H") ? 2975 : 2380)) {
chartdata[j].shift();
} else if (chartdata[j].length == (chartuuids[6].startsWith("H") ? 2975 : 2380)) {
break;
} else if (chartdata[j].length != (chartuuids[6].startsWith("H") ? 2975 : 2380)) {
chartdata[j].shift();
chartdata[j].unshift({
name : new Date(time - 120_000).getTime(),
value : [new Date(time - 120_000).getTime(), null],
});
break;
}

while (true)
if (chartdata[id].length > (chartuuids[id].startsWith("H") ? 2950 : 1180)) {
chartdata[id].shift();
} else if (chartdata[id].length == (chartuuids[id].startsWith("H") ? 2950 : 1180)) {
break;
} else if (chartdata[id].length != (chartuuids[id].startsWith("H") ? 2950 : 1180)) {
chartdata[id].shift();
chartdata[id].unshift({
name : new Date(time - 60_000).getTime(),
value : [new Date(time - 60_000).getTime(), null],
const values = chartdata[j].map(v => v.value[1]);
const maxmin = Math.max(Math.abs(Math.max(...values)), Math.abs(Math.min(...values)));

charts[j].setOption({
animation : false,
yAxis : {
max : maxmin < (chartuuids[6].startsWith("H") ? 1 : 1000) ? (chartuuids[6].startsWith("H") ? 1 : 1000) : maxmin,
min : -(maxmin < (chartuuids[6].startsWith("H") ? 1 : 1000) ? (chartuuids[6].startsWith("H") ? 1 : 1000) : maxmin),
},
series: [
{
type : "line",
data : chartdata[j],
},
],
});
}
} else {
for (let i = 0; i < n; i++) {
const calculatedTime = time + (i * timeOffset);
chartdata[id].push({
name : now.getTime(),
value : [new Date(calculatedTime).getTime(), Math.round(+wave_data.Z[i] * 1000)],
});
break;
}

const values = chartdata[id].map(v => v.value[1]);
const maxmin = Math.max(Math.abs(Math.max(...values)), Math.abs(Math.min(...values)));
while (true)
if (chartdata[id].length > (chartuuids[id].startsWith("H") ? 2975 : 2380)) {
chartdata[id].shift();
} else if (chartdata[id].length == (chartuuids[id].startsWith("H") ? 2975 : 2380)) {
break;
} else if (chartdata[id].length != (chartuuids[id].startsWith("H") ? 2975 : 2380)) {
chartdata[id].shift();
chartdata[id].unshift({
name : new Date(time - 120_000).getTime(),
value : [new Date(time - 120_000).getTime(), null],
});
break;
}

charts[id].setOption({
animation : false,
yAxis : {
max : maxmin < (chartuuids[id].startsWith("H") ? 1 : 1000) ? (chartuuids[id].startsWith("H") ? 1 : 1000) : maxmin,
min : -(maxmin < (chartuuids[id].startsWith("H") ? 1 : 1000) ? (chartuuids[id].startsWith("H") ? 1 : 1000) : maxmin),
},
series: [
{
type : "line",
data : chartdata[id],
const values = chartdata[id].map(v => v.value[1]);
const maxmin = Math.max(Math.abs(Math.max(...values)), Math.abs(Math.min(...values)));

charts[id].setOption({
animation : false,
yAxis : {
max : maxmin < (chartuuids[id].startsWith("H") ? 1 : 1000) ? (chartuuids[id].startsWith("H") ? 1 : 1000) : maxmin,
min : -(maxmin < (chartuuids[id].startsWith("H") ? 1 : 1000) ? (chartuuids[id].startsWith("H") ? 1 : 1000) : maxmin),
},
],
});
series: [
{
type : "line",
data : chartdata[id],
},
],
});
}
};

async function init() {
Expand Down Expand Up @@ -500,6 +571,8 @@ async function init() {
Realtimestation4.split("-")[2],
Realtimestation5.split("-")[2],
Realtimestation.split("-")[2],
Realtimestation.split("-")[2],
Realtimestation.split("-")[2],
]);
for (const chart of charts)
chart.setOption({
Expand Down
4 changes: 2 additions & 2 deletions TREM.Electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ function createRTSWindow() {
if (RTSWindow instanceof BrowserWindow) return RTSWindow.focus();
RTSWindow = TREM.Window.set("rts", new BrowserWindow({
title : TREM.Localization.getString("Setting_Title"),
height : 580,
height : 774,
width : 400,
minHeight : 580,
minHeight : 774,
minWidth : 400,
frame : false,
transparent : true,
Expand Down
16 changes: 8 additions & 8 deletions TREM.Electron/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions TREM.Electron/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tremv",
"version": "6.1.100",
"version": "6.1.101",
"description": "Taiwan Real-time Earthquake Monitoring Variety ( 臺灣即時地震監測變體 )",
"main": "main.js",
"homepage": "https://exptech.com.tw/",
Expand Down Expand Up @@ -99,7 +99,7 @@
"bytenode": "^1.5.6",
"chokidar": "^3.5.3",
"discord.js": "14.14.1",
"echarts": "^5.4.3",
"echarts": "^5.5.0",
"electron-common-ipc": "^16.0.4",
"electron-fcm-push-receiver": "^2.1.7",
"electron-log": "5.1.1",
Expand Down
Loading

0 comments on commit ed6100f

Please sign in to comment.