Skip to content

Commit

Permalink
Merge pull request #214 from xspanger3770/0.10.1-real-one
Browse files Browse the repository at this point in the history
Version 0.10.1
  • Loading branch information
xspanger3770 committed Jan 26, 2024
2 parents 7bf0716 + f5092ca commit 0e67a73
Show file tree
Hide file tree
Showing 86 changed files with 1,631 additions and 564 deletions.
2 changes: 1 addition & 1 deletion GlobalQuakeAPI/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>xspanger.GlobalQuake</groupId>
<artifactId>GlobalQuake</artifactId>
<version>0.10.0</version>
<version>0.10.1</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
4 changes: 2 additions & 2 deletions GlobalQuakeClient/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>xspanger.GlobalQuake</groupId>
<artifactId>GlobalQuake</artifactId>
<version>0.10.0</version>
<version>0.10.1</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -61,7 +61,7 @@
<dependency>
<groupId>xspanger.GlobalQuake</groupId>
<artifactId>GlobalQuakeCore</artifactId>
<version>0.10.0</version>
<version>0.10.1</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ public void onQuakeUpdate(QuakeUpdateEvent event) {
}

public synchronized void tick() {
GlobalQuake.instance.getEarthquakeAnalysis().getEarthquakes().forEach(earthquake -> warnings.putIfAbsent(earthquake, new Warning()));
GlobalQuake.instance.getEarthquakeAnalysis().getEarthquakes().forEach(earthquake -> warnings.putIfAbsent(earthquake, new Warning(GlobalQuake.instance.currentTimeMillis())));

for (Iterator<Map.Entry<Warnable, Warning>> iterator = warnings.entrySet().iterator(); iterator.hasNext(); ) {
var kv = iterator.next();
Warnable warnable = kv.getKey();
Warning warning = kv.getValue();

long age = System.currentTimeMillis() - warning.createdAt;
long age = GlobalQuake.instance.currentTimeMillis() - warning.createdAt;
if(age > 1000 * 60 * STORE_TIME_MINUTES){
iterator.remove();
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

public class Warning {

public Warning() {
createdAt = System.currentTimeMillis();
public Warning(long time) {
createdAt = time;
metConditions = false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public ClusterAnalysisClient() {
private void checkClusters() {
List<Cluster> toRemove = new ArrayList<>();
for(Cluster cluster : clusters){
if(System.currentTimeMillis() - cluster.getLastUpdate() > 30 * 60 * 1000){
if(GlobalQuake.instance.currentTimeMillis() - cluster.getLastUpdate() > 30 * 60 * 1000){
toRemove.add(cluster);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private void processDataRecordPacket(DataRecordPacket dataRecordPacket) {
try {
DataRecord dataRecord = (DataRecord) DataRecord.read(dataRecordPacket.data());
station.getAnalysis().analyse(dataRecord);
station.getAnalysis().second(System.currentTimeMillis());
station.getAnalysis().second(GlobalQuakeLocal.instance.currentTimeMillis());
} catch (IOException | SeedFormatException e) {
Logger.error(e);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package globalquake.client.data;

import globalquake.core.GlobalQuake;
import gqserver.api.packets.station.InputType;
import globalquake.core.station.GlobalStation;

Expand Down Expand Up @@ -27,7 +28,7 @@ public boolean isInEventMode() {

@Override
public long getDelayMS() {
return System.currentTimeMillis() - lastDataTime;
return GlobalQuake.instance.currentTimeMillis() - lastDataTime;
}

@Override
Expand Down
12 changes: 9 additions & 3 deletions GlobalQuakeClient/src/main/java/globalquake/main/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ public static void main(String[] args) {
initErrorHandler();
initMainDirectory();
GlobalQuake.prepare(MAIN_FOLDER, getErrorHandler());

Options options = new Options();

Option maxGpuMemOption = new Option("g", "gpu-max-mem", true, "maximum GPU memory limit in GB");
maxGpuMemOption.setRequired(false);
options.addOption(maxGpuMemOption);

CommandLineParser parser = new org.apache.commons.cli.BasicParser();
HelpFormatter formatter = new HelpFormatter();
CommandLine cmd = null;

try {
cmd = parser.parse(options, args);
} catch (ParseException e) {
Expand Down Expand Up @@ -69,6 +69,12 @@ private static void initMainDirectory() {
getErrorHandler().handleException(new FatalIOException("Unable to create main directory!", null));
}
}
File VOLUME_FOLDER = new File(MAIN_FOLDER, "volume/");
if (!VOLUME_FOLDER.exists()) {
if (!VOLUME_FOLDER.mkdirs()) {
getErrorHandler().handleException(new FatalIOException("Unable to create volume directory!", null));
}
}
}

public static ApplicationErrorHandler getErrorHandler() {
Expand Down
159 changes: 0 additions & 159 deletions GlobalQuakeClient/src/main/java/globalquake/sounds/Sounds.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

public class SoundsInfo {

public boolean firstSound;
public int maxLevel;
public int maxLevel = -1;
public double maxPGA;
public double maxPGAHome;
public boolean warningPlayed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import globalquake.core.events.specific.QuakeUpdateEvent;
import globalquake.core.geo.taup.TauPTravelTimeCalculator;
import globalquake.core.intensity.IntensityScales;
import globalquake.core.intensity.MMIIntensityScale;
import globalquake.utils.GeoUtils;
import org.tinylog.Logger;

Expand All @@ -32,16 +31,21 @@ public SoundsService(){
GlobalQuake.instance.getEventHandler().registerEventListener(new GlobalQuakeEventListener(){
@Override
public void onQuakeCreate(QuakeCreateEvent event) {
Sounds.playSound(Sounds.found);
if(SoundsService.this.canPing(event.earthquake())) {
Sounds.playSound(Sounds.found);
}
}

@Override
public void onQuakeUpdate(QuakeUpdateEvent event) {
Sounds.playSound(Sounds.update);
if(SoundsService.this.canPing(event.earthquake())) {
Sounds.playSound(Sounds.update);
}
}
});
}


private void checkSounds() {
try {
if(GlobalQuake.instance.getClusterAnalysis() == null ||GlobalQuake.instance.getEarthquakeAnalysis() == null){
Expand Down Expand Up @@ -69,13 +73,11 @@ public void determineSounds(Cluster cluster) {
clusterSoundsInfo.put(cluster, info = new SoundsInfo());
}

if (!info.firstSound) {
Sounds.playSound(Sounds.level_0);
info.firstSound = true;
}

int level = cluster.getLevel();
if (level > info.maxLevel) {
if (level > info.maxLevel && canPing(cluster)) {
if(info.maxLevel < 0){
Sounds.playSound(Sounds.level_0);
}
if (level >= 1 && info.maxLevel < 1) {
Sounds.playSound(Sounds.level_1);
}
Expand All @@ -102,7 +104,8 @@ public void determineSounds(Cluster cluster) {
double pga = GeoUtils.pgaFunction(quake.getMag(), quake.getDepth(), quake.getDepth());
if (info.maxPGA < pga) {
info.maxPGA = pga;
if (info.maxPGA >= MMIIntensityScale.VI.getPga() && !info.warningPlayed && level >= 2) {
double threshold_eew = IntensityScales.INTENSITY_SCALES[Settings.eewScale].getLevels().get(Settings.eewLevelIndex).getPga();
if (info.maxPGA >= threshold_eew && !info.warningPlayed && level >= Settings.eewClusterLevel) {
Sounds.playSound(Sounds.eew_warning);
info.warningPlayed = true;
}
Expand Down Expand Up @@ -131,7 +134,7 @@ public void determineSounds(Cluster cluster) {
if (shakingExpected) {
double sTravel = (long) (TauPTravelTimeCalculator.getSWaveTravelTime(quake.getDepth(),
TauPTravelTimeCalculator.toAngle(distGCD)));
double age = (System.currentTimeMillis() - quake.getOrigin()) / 1000.0;
double age = (GlobalQuake.instance.currentTimeMillis() - quake.getOrigin()) / 1000.0;
int secondsS = (int) Math.max(0, Math.ceil(sTravel - age));

if (secondsS < info.lastCountdown && secondsS <= 10) {
Expand All @@ -143,6 +146,24 @@ public void determineSounds(Cluster cluster) {
}
}


private boolean canPing(Earthquake earthquake) {
if(!Settings.enableEarthquakeSounds){
return false;
}

double distGCD = GeoUtils.greatCircleDistance(earthquake.getLat(), earthquake.getLon(), Settings.homeLat, Settings.homeLon);
return !(earthquake.getMag() < Settings.earthquakeSoundsMinMagnitude) || !(distGCD > Settings.earthquakeSoundsMaxDist);
}

private boolean canPing(Cluster cluster) {
if(!Settings.alertPossibleShaking){
return false;
}
double distGCD = GeoUtils.greatCircleDistance(cluster.getRootLat(), cluster.getRootLon(), Settings.homeLat, Settings.homeLon);
return !(distGCD > Settings.alertPossibleShakingDistance);
}

public void destroy(){
GlobalQuake.instance.stopService(soundCheckService);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ public void updateImage() {
}

private long getTime() {
return System.currentTimeMillis();
return GlobalQuake.instance != null ? GlobalQuake.instance.currentTimeMillis() : System.currentTimeMillis();
}

private double getX(long time) {
Expand Down
Loading

0 comments on commit 0e67a73

Please sign in to comment.