Skip to content
This repository has been archived by the owner on Jan 23, 2025. It is now read-only.

Commit

Permalink
fix station limit was not assigned when recalibration is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
xspanger3770 committed Apr 18, 2024
1 parent 9016fb4 commit 5a8585d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 38 deletions.
16 changes: 0 additions & 16 deletions GlobalQuake.iml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,7 @@
<module version="4">
<component name="AdditionalModuleElements">
<content url="file://$MODULE_DIR$" dumb="true">
<excludeFolder url="file://$MODULE_DIR$/GQHypocenterSearch/.vscode" />
<excludeFolder url="file://$MODULE_DIR$/GQHypocenterSearch/SeisTest" />
<excludeFolder url="file://$MODULE_DIR$/GQHypocenterSearch/build" />
<excludeFolder url="file://$MODULE_DIR$/idk" />
<excludeFolder url="file://$MODULE_DIR$/latest" />
<excludeFolder url="file://$MODULE_DIR$/out" />
<excludeFolder url="file://$MODULE_DIR$/tutorials" />
<excludeFolder url="file://$MODULE_DIR$/Container" />
<excludeFolder url="file://$MODULE_DIR$/TrainingData" />
<excludeFolder url="file://$MODULE_DIR$/training/events" />
<excludeFolder url="file://$MODULE_DIR$/training" />
<excludeFolder url="file://$MODULE_DIR$/.GlobalQuakeData" />
<excludeFolder url="file://$MODULE_DIR$/.GlobalQuakeServerData" />
<excludeFolder url="file://$MODULE_DIR$/.construction_tools" />
<excludeFolder url="file://$MODULE_DIR$/.github" />
<excludeFolder url="file://$MODULE_DIR$/.idea" />
<excludeFolder url="file://$MODULE_DIR$/graphs" />
</content>
</component>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ private static void finishInit() {
if(GQHypocs.isCudaLoaded()){
EarthquakeAnalysisTraining.calibrateResolution(MainFrame::updateProgressBar, null, false);
}
} else if (GQHypocs.isCudaLoaded()) {
GQHypocs.calculateStationLimit();
}

updateProgressBar("Updating Station Sources...", (int) ((phase++ / (PHASES + 4)) * 100.0));
Expand Down
57 changes: 35 additions & 22 deletions GlobalQuakeServer/src/main/java/gqserver/main/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,29 +83,29 @@ public static void main(String[] args) {

headless = cmd.hasOption(headlessOption.getOpt());

if(cmd.hasOption(maxClientsOption.getOpt())) {
if (cmd.hasOption(maxClientsOption.getOpt())) {
try {
int maxCli = Integer.parseInt(cmd.getOptionValue(maxClientsOption.getOpt()));
if(maxCli < 1){
int maxCli = Integer.parseInt(cmd.getOptionValue(maxClientsOption.getOpt()));
if (maxCli < 1) {
throw new IllegalArgumentException("Maximum client count must be at least 1!");
}
Settings.maxClients = maxCli;
Logger.info("Maximum client count set to %d".formatted(Settings.maxClients));
} catch(IllegalArgumentException e){
} catch (IllegalArgumentException e) {
Logger.error(e);
System.exit(1);
}
}

if(cmd.hasOption(maxGpuMemOption.getOpt())) {
if (cmd.hasOption(maxGpuMemOption.getOpt())) {
try {
double maxMem = Double.parseDouble(cmd.getOptionValue(maxGpuMemOption.getOpt()));
if(maxMem <= 0){
double maxMem = Double.parseDouble(cmd.getOptionValue(maxGpuMemOption.getOpt()));
if (maxMem <= 0) {
throw new IllegalArgumentException("Invalid maximum GPU memory amount");
}
GQHypocs.MAX_GPU_MEM = maxMem;
Logger.info("Maximum GPU memory allocation will be limited to around %.2f GB".formatted(maxMem));
} catch(IllegalArgumentException e){
} catch (IllegalArgumentException e) {
Logger.error(e);
System.exit(1);
}
Expand All @@ -129,9 +129,9 @@ public static void main(String[] args) {
}

public static void updateProgressBar(String status, int value) {
if(headless){
if (headless) {
Logger.info("Initialising... %d%%: %s".formatted(value, status));
}else{
} else {
databaseMonitorFrame.getMainProgressBar().setString(status);
databaseMonitorFrame.getMainProgressBar().setValue(value);
}
Expand All @@ -140,7 +140,7 @@ public static void updateProgressBar(String status, int value) {
private static final double PHASES = 10.0;
private static int phase = 0;

public static void initAll() throws Exception{
public static void initAll() throws Exception {
updateProgressBar("Loading regions...", (int) ((phase++ / PHASES) * 100.0));
Regions.init();

Expand All @@ -154,33 +154,46 @@ public static void initAll() throws Exception{
GQHypocs.load();

updateProgressBar("Calibrating...", (int) ((phase++ / PHASES) * 100.0));
if(Settings.recalibrateOnLaunch) {
if (Settings.recalibrateOnLaunch) {
EarthquakeAnalysisTraining.calibrateResolution(Main::updateProgressBar, null, true);
if(GQHypocs.isCudaLoaded()) {
if (GQHypocs.isCudaLoaded()) {
EarthquakeAnalysisTraining.calibrateResolution(Main::updateProgressBar, null, false);
}
} else if (GQHypocs.isCudaLoaded()) {
GQHypocs.calculateStationLimit();
}


//start up the FDSNWS_Event Server, if enabled
updateProgressBar("Starting FDSNWS_Event Server...", (int) ((phase++ / PHASES) * 100.0));
if(Settings.autoStartFDSNWSEventServer){
if (Settings.autoStartFDSNWSEventServer) {
try {
FdsnwsEventsHTTPServer.getInstance().startServer();
}catch (Exception e){
} catch (Exception e) {
getErrorHandler().handleWarning(new RuntimeException("Unable to start FDSNWS EVENT server! Check logs for more info.", e));
}
}

updateProgressBar("Starting Discord Bot...", (int) ((phase++ / PHASES) * 100.0));
if(Settings.discordBotEnabled){
if (Settings.discordBotEnabled) {
DiscordBot.init();
}

updateProgressBar("Updating Station Sources...", (int) ((phase++ / PHASES) * 100.0));
databaseManager.runUpdate(
databaseManager.getStationDatabase().getStationSources().stream()
.filter(StationSource::isOutdated).collect(Collectors.toList()),
() -> {
databaseManager.getStationDatabase().

getStationSources().

stream()
.

filter(StationSource::isOutdated).

collect(Collectors.toList()),
() ->

{
updateProgressBar("Checking Seedlink Networks...", (int) ((phase++ / PHASES) * 100.0));
databaseManager.runAvailabilityCheck(databaseManager.getStationDatabase().getSeedlinkNetworks(), () -> {
updateProgressBar("Saving...", (int) ((phase++ / PHASES) * 100.0));
Expand All @@ -191,13 +204,13 @@ public static void initAll() throws Exception{
getErrorHandler().handleException(new RuntimeException(e));
}

if(!headless) {
if (!headless) {
databaseMonitorFrame.initDone();
}

updateProgressBar("Done", (int) ((phase++ / PHASES) * 100.0));

if(headless){
if (headless) {
autoStartServer();
}
});
Expand All @@ -211,7 +224,7 @@ private static void autoStartServer() {
}

public static ApplicationErrorHandler getErrorHandler() {
if(errorHandler == null) {
if (errorHandler == null) {
errorHandler = new ApplicationErrorHandler(null, headless);
}
return errorHandler;
Expand Down

0 comments on commit 5a8585d

Please sign in to comment.