Skip to content

Commit

Permalink
refactor: Use Web Workers to process seismic data
Browse files Browse the repository at this point in the history
  • Loading branch information
bclswl0827 committed Sep 21, 2024
1 parent cd20c16 commit 6e6ccde
Show file tree
Hide file tree
Showing 32 changed files with 568 additions and 672 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@

Starting from v2.2.5, all notable changes to this project will be documented in this file.

# v3.3.2

### Bug Fixes

- Handle auto flag properly for event data sources of China.
- Fixed occasional checksum error in legacy mode.

### Refactor

- Use Web Workers to process seismic data.

### Chore

- chore: Update slgo dependency to v0.0.4.

## v3.3.1

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v3.3.1
v3.3.2
13 changes: 13 additions & 0 deletions frontend/src/craco.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ module.exports = {
const buildPath = resolve(__dirname, "..", "dist");
webpackConfig.output!.path = buildPath;
paths.appBuild = buildPath;

// Add worker-loader for Web Workers
webpackConfig.module!.rules!.unshift({
test: /\.worker\.ts$/,
use: {
loader: "worker-loader",
options: {
// Use directory structure & typical names of chunks produces by "react-scripts"
filename: "static/js/[name].[contenthash:8].js"
}
}
});

return webpackConfig;
}
}
Expand Down
129 changes: 114 additions & 15 deletions frontend/src/package-lock.json

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

5 changes: 4 additions & 1 deletion frontend/src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"@mui/x-date-pickers": "^6.16.0",
"@reduxjs/toolkit": "^1.9.6",
"axios": "^1.5.1",
"bignumber.js": "^9.1.2",
"comlink": "^4.4.1",
"date-fns": "^2.30.0",
"file-saver": "^2.0.5",
"formik": "^2.4.6",
Expand Down Expand Up @@ -68,6 +70,7 @@
"react-scripts": "5.0.1",
"tailwindcss": "^3.3.3",
"tailwindcss-animated": "^1.0.1",
"typescript": "^4.9.5"
"typescript": "^4.9.5",
"worker-loader": "3.0.x"
}
}
14 changes: 5 additions & 9 deletions frontend/src/src/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ import { ReduxStoreProps } from "./config/store";
import { sendUserAlert } from "./helpers/interact/sendUserAlert";
import { sendUserConfirm } from "./helpers/interact/sendUserConfirm";
import { requestRestApi } from "./helpers/request/requestRestApi";
import { onUpdate as UpdateADC } from "./stores/adc";
import { onUpdate as UpdateCredential } from "./stores/credential";
import { onUpdate as UpdateGeophone } from "./stores/geophone";
import { onUpdate as UpdateStation } from "./stores/station";
import { onUpdate as UpdateSensor } from "./stores/sensor";
import { onUpdate as UpdateStation } from "./stores/stream";

interface MainProps {
currentLocale: string;
Expand Down Expand Up @@ -94,13 +93,10 @@ export const Main = ({ currentLocale, locales, onSwitchLocale, onLoginStateChang
endpoint: endpoints.station
});
if (res?.data) {
const initialized = true;
const { sensitivity, frequency } = res.data.sensor;
dispatch(UpdateGeophone({ sensitivity, frequency, initialized }));
const { resolution, fullscale } = res.data.sensor;
dispatch(UpdateADC({ resolution, fullscale, initialized }));
const { resolution, velocity } = res.data.sensor;
dispatch(UpdateSensor({ resolution, velocity, initialized: true }));
const { station, network, location, channel } = res.data.stream;
dispatch(UpdateStation({ station, network, location, initialized, channel }));
dispatch(UpdateStation({ station, network, location, channel, initialized: true }));
}
}, [dispatch]);
useEffect(() => {
Expand Down
26 changes: 4 additions & 22 deletions frontend/src/src/config/global.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
import {
CSISIntensityStandard,
CWAIntensityStandard,
IntensityStandard,
JMAIntensityStandard,
MMIIntensityStandard
} from "../helpers/seismic/intensityStandard";
import { i18nConfig } from "./i18n";

interface GlobalConfig {
Expand All @@ -23,31 +16,20 @@ interface GlobalConfig {
readonly maximum: number;
readonly minimum: number;
};
readonly scales: IntensityStandard[];
readonly footer: Record<keyof typeof i18nConfig.resources, string>;
}

const scales = [
new JMAIntensityStandard(),
new CWAIntensityStandard(),
new MMIIntensityStandard(),
new CSISIntensityStandard()
];

export const globalConfig: GlobalConfig = {
scales,
name: "Observer",
author: "AnyShake",
title: "AnyShake Observer",
homepage: "https://anyshake.org",
repository: "https://github.com/AnyShake",
repository: "https://github.com/anyshake/observer",
duration: { default: 300, maximum: 3600, minimum: 10 },
retention: { default: 120, maximum: 600, minimum: 10 },
footer: {
"en-US": "Constructing Realtime Seismic Network Ambitiously.",
"zh-CN": "雄心勃勃,致力于构建实时地震网络",
"zh-TW": "雄心勃勃,致力於建置即時地震網路"
"en-US": "Listen to the whispering earth.",
"zh-CN": "听见地球。",
"zh-TW": "聽見地球。",
}
};

export const fallbackScale = scales[0];
Loading

0 comments on commit 6e6ccde

Please sign in to comment.