mirror of
https://github.com/praktimarc/kst4contest.git
synced 2026-03-30 04:31:04 +02:00
implemented all filters to the chatmemberlist, activity-displays in chatmember table and userinfopanel, linked selected messages to the userinfopanel for better UI feeling, begin of AS-Showpath-function (not yet ready)
This commit is contained in:
@@ -9,7 +9,7 @@ public class ApplicationConstants {
|
||||
/**
|
||||
* Name of file to store preferences in.
|
||||
*/
|
||||
public static final double APPLICATION_CURRENTVERSIONNUMBER = 0.9;
|
||||
public static final double APPLICATION_CURRENTVERSIONNUMBER = 1.0;
|
||||
|
||||
public static final String VERSIONINFOURLFORUPDATES_KST4CONTEST = "https://do5amf.funkerportal.de/kst4ContestVersionInfo.xml";
|
||||
public static final String VERSIONINFDOWNLOADEDLOCALFILE = "kst4ContestVersionInfo.xml";
|
||||
|
||||
@@ -99,6 +99,54 @@ public class ChatController {
|
||||
this.disconnected = disconnected;
|
||||
}
|
||||
|
||||
public void airScout_SendAsShowPathPacket(ChatMember remoteChatMember) {
|
||||
|
||||
DatagramSocket dsocket;
|
||||
|
||||
String prefix_asSetpath ="ASSHOWPATH: \"KST\" \"AS\" ";
|
||||
String bandString = "1440000";
|
||||
String myCallAndMyLocString = chatPreferences.getLoginCallSign() + "," + chatPreferences.getLoginLocator();
|
||||
String remoteCallAndLocString = remoteChatMember.getCallSign() +"," + remoteChatMember.getQra();
|
||||
|
||||
String host = "255.255.255.255";
|
||||
// int port = 9872;
|
||||
int port = chatPreferences.getAirScout_asCommunicationPort();
|
||||
// System.out.println("<<<<<<<<<<<<<<<<<<<<ASPERI: " + port);
|
||||
|
||||
// byte[] message = "ASSETPATH: \"KST\" \"AS\" 1440000,DO5AMF,JN49GL,OK1MZM,JN89IW ".getBytes(); Original, ging
|
||||
InetAddress address;
|
||||
|
||||
String queryStringToAirScout = "";
|
||||
|
||||
queryStringToAirScout += prefix_asSetpath + bandString + "," + myCallAndMyLocString + "," + remoteCallAndLocString;
|
||||
|
||||
byte[] queryStringToAirScoutMSG = queryStringToAirScout.getBytes();
|
||||
|
||||
try {
|
||||
address = InetAddress.getByName("255.255.255.255");
|
||||
DatagramPacket packet = new DatagramPacket(queryStringToAirScoutMSG, queryStringToAirScoutMSG.length, address, port);
|
||||
dsocket = new DatagramSocket();
|
||||
dsocket.setBroadcast(true);
|
||||
dsocket.send(packet);
|
||||
dsocket.close();
|
||||
} catch (UnknownHostException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
} catch (NoRouteToHostException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (SocketException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handles the disconnect of either the chat (Case DISCONNECTONLY) or the
|
||||
* complete application life including all threads (case CLOSEALL)<br/><br/>
|
||||
@@ -290,7 +338,7 @@ public class ChatController {
|
||||
private String chatState;
|
||||
|
||||
private String hostname = "109.90.0.130";
|
||||
private String praktiKSTVersion = "praktiKST 0.9b";
|
||||
private String praktiKSTVersion = "praktiKST 1.0";
|
||||
private String praktiKSTVersionInfo = "2022-10 - 2022-12\ndeveloped by DO5AMF, Marc\nContact: praktimarc@gmail.com\nDonations via paypal are welcome";
|
||||
|
||||
private int port = 23001; // kst4contest.test 4 23001
|
||||
|
||||
@@ -366,7 +366,8 @@ public class MessageBusManagementThread extends Thread {
|
||||
// newMember.setQTFdirection(LocatorUtils);
|
||||
newMember.setQrb(new Location().getDistanceKmByTwoLocatorStrings(client.getChatPreferences().getLoginLocator(), newMember.getQra()));
|
||||
newMember.setQTFdirection(new Location(client.getChatPreferences().getLoginLocator()).getBearing(new Location(newMember.getQra())));
|
||||
newMember.setLastActivity(new Utils4KST().time_generateActualTimeInDateFormat());
|
||||
newMember.setLastActivity(new Utils4KST().time_generateActualTimeInDateFormat());//TODO evt obsolete!
|
||||
newMember.setActivityTimeLastInEpoch(new Utils4KST().time_generateCurrentEpochTime());
|
||||
|
||||
// this.client.getChatMemberTable().put(splittedMessageLine[2], newMember); //TODO: map -> List
|
||||
|
||||
@@ -406,6 +407,7 @@ public class MessageBusManagementThread extends Thread {
|
||||
newMember.setQra(splittedMessageLine[4]);
|
||||
newMember.setState(Integer.parseInt(splittedMessageLine[5]));
|
||||
newMember.setLastActivity(new Utils4KST().time_generateActualTimeInDateFormat());
|
||||
newMember.setActivityTimeLastInEpoch(new Utils4KST().time_generateCurrentEpochTime());
|
||||
newMember.setQrb(new Location().getDistanceKmByTwoLocatorStrings(client.getChatPreferences().getLoginLocator(), newMember.getQra()));
|
||||
newMember.setQTFdirection(new Location(client.getChatPreferences().getLoginLocator()).getBearing(new Location(newMember.getQra())));
|
||||
|
||||
@@ -488,10 +490,12 @@ public class MessageBusManagementThread extends Thread {
|
||||
|
||||
int index = checkListForChatMemberIndexByCallSign(this.client.getLst_chatMemberList(), sender);
|
||||
|
||||
//if the user had been found in the active users list
|
||||
if (index != -1) {
|
||||
//user found in the chatmember list
|
||||
try {
|
||||
newMessage.setSender(this.client.getLst_chatMemberList().get(index)); // set sender to member of
|
||||
this.client.getLst_chatMemberList().get(index).setActivityTimeLastInEpoch(new Utils4KST().time_generateCurrentEpochTime());
|
||||
} catch (Exception exc) {
|
||||
ChatMember aSenderDummy = new ChatMember();
|
||||
aSenderDummy.setCallSign(splittedMessageLine[3] + "[n/a]");
|
||||
@@ -502,7 +506,7 @@ public class MessageBusManagementThread extends Thread {
|
||||
}
|
||||
// b4 init list
|
||||
} else {
|
||||
//user not found in chatmember list
|
||||
//user not found in chatmember list, mark it, sender can not be set
|
||||
if (!sender.getCallSign().equals(this.client.getChatPreferences().getLoginCallSign().toUpperCase())) {
|
||||
sender.setCallSign("[n/a]" + sender.getCallSign());
|
||||
// if someone sent a message without being in the userlist (cause
|
||||
@@ -909,7 +913,7 @@ public class MessageBusManagementThread extends Thread {
|
||||
System.out.println("Passwort falsch!");
|
||||
|
||||
if (splittedMessageLine[2].contains("password")) {
|
||||
splittedMessageLine[2] += "pse disc- and reconnect";
|
||||
splittedMessageLine[2] += " pse disc- and reconnect";
|
||||
}
|
||||
|
||||
ChatMember server = new ChatMember();
|
||||
@@ -921,10 +925,19 @@ public class MessageBusManagementThread extends Thread {
|
||||
pwErrorMsg.setMessageGeneratedTime(client.getCurrentEpochTime()+"");
|
||||
pwErrorMsg.setSender(server);
|
||||
pwErrorMsg.setMessageText(splittedMessageLine[2]);
|
||||
|
||||
ChatMember receiverDummy = new ChatMember();
|
||||
receiverDummy.setCallSign(client.getChatPreferences().getLoginCallSign());
|
||||
receiverDummy.setQrb(0.);
|
||||
receiverDummy.setQTFdirection(0.);
|
||||
pwErrorMsg.setReceiver(receiverDummy);
|
||||
|
||||
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
client.getLst_toMeMessageList().add(pwErrorMsg);
|
||||
client.getLst_toAllMessageList().add(pwErrorMsg);
|
||||
client.getLst_globalChatMessageList().add(pwErrorMsg);
|
||||
// client.getLst_toMeMessageList().add(pwErrorMsg);
|
||||
// client.getLst_toAllMessageList().add(pwErrorMsg);
|
||||
}
|
||||
|
||||
// Kst4ContestApplication.alertWindowEvent("Password was wrong. Pse check!");
|
||||
|
||||
@@ -49,6 +49,21 @@ public class Utils4KST {
|
||||
return formatted;
|
||||
|
||||
}
|
||||
|
||||
public static long time_getSecondsBetweenEpochAndNow(String epoch1) {
|
||||
|
||||
long epoch1Long = Long.parseLong(epoch1);
|
||||
long epoch2Long = new Utils4KST().time_generateCurrentEpochTime();
|
||||
// Instant instant = Instant.ofEpochSecond(epoch);
|
||||
|
||||
Date date = new Date(epoch1Long * 1000L);
|
||||
Date date2 = new Date(epoch2Long * 1000L);
|
||||
|
||||
long seconds = Math.abs(date.getTime()-date2.getTime())/1000;
|
||||
|
||||
return seconds;
|
||||
|
||||
}
|
||||
|
||||
public Date time_generateActualTimeInDateFormat() {
|
||||
Date date = new Date(time_generateCurrentEpochTime() * 1000L);
|
||||
|
||||
50
src/main/java/kst4contest/locatorUtils/DirectionUtils.java
Normal file
50
src/main/java/kst4contest/locatorUtils/DirectionUtils.java
Normal file
@@ -0,0 +1,50 @@
|
||||
package kst4contest.locatorUtils;
|
||||
|
||||
public class DirectionUtils {
|
||||
|
||||
/**
|
||||
* Tests, if the angle (from me to) other station is in the range of the
|
||||
* angle (qtf) in degrees where my antenna points to.
|
||||
*
|
||||
* @param toForeignAngle [degrees]
|
||||
* @param mySelectedQTFAngle [degrees]
|
||||
* @param antennaBeamwidth [degrees]
|
||||
* @return
|
||||
*/
|
||||
public static boolean isAngleInRange(double toForeignAngle,
|
||||
double mySelectedQTFAngle, double antennaBeamwidth) {
|
||||
|
||||
double beamwidth = antennaBeamwidth / 2; // half left, half right
|
||||
|
||||
double startAngle = mySelectedQTFAngle - beamwidth;
|
||||
double endAngle = mySelectedQTFAngle + beamwidth;
|
||||
|
||||
// Normalize angles to be between 0 and 360 degrees
|
||||
toForeignAngle = normalizeAngle(toForeignAngle);
|
||||
startAngle = normalizeAngle(startAngle);
|
||||
endAngle = normalizeAngle(endAngle);
|
||||
|
||||
// Check if the range wraps around 360 degrees
|
||||
if (startAngle <= endAngle) {
|
||||
return toForeignAngle >= startAngle && toForeignAngle <= endAngle;
|
||||
} else {
|
||||
// Range wraps around 360 degrees, so check if angle is within the
|
||||
// range or outside the range
|
||||
return toForeignAngle >= startAngle || toForeignAngle <= endAngle;
|
||||
}
|
||||
}
|
||||
|
||||
private static double normalizeAngle(double angle) {
|
||||
if (angle < 0) {
|
||||
angle += 360;
|
||||
}
|
||||
if (angle >= 360) {
|
||||
angle -= 360;
|
||||
}
|
||||
return angle;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -19,7 +19,7 @@ public class ChatMember {
|
||||
ChatCategory chatCategory; // only used by own instance of the chatmember instance to login to the chat
|
||||
// ChatCategory chatCategory;//only used by own instance of the chatmember instance to login to the chat
|
||||
|
||||
long activityCounter; // time of last activity in epochtimesec
|
||||
long activityTimeLastInEpoch; // time of last activity in epochtimesec
|
||||
Date lastActivity; // time of last activity in epochtimesec
|
||||
Date lastActualizationTimeOfThisMember; // time of last state change if that member
|
||||
Double qrb;
|
||||
@@ -125,8 +125,8 @@ public class ChatMember {
|
||||
this.workedCategories = workedCategories;
|
||||
}
|
||||
|
||||
public void setActivityCounter(long activityCounter) {
|
||||
this.activityCounter = activityCounter;
|
||||
public void setActivityTimeLastInEpoch(long activityTimeLastInEpoch) {
|
||||
this.activityTimeLastInEpoch = activityTimeLastInEpoch;
|
||||
}
|
||||
|
||||
public int getState() {
|
||||
@@ -210,12 +210,12 @@ public class ChatMember {
|
||||
this.frequency = frequency;
|
||||
}
|
||||
|
||||
public long getActivityCounter() {
|
||||
return activityCounter;
|
||||
public long getActivityTimeLastInEpoch() {
|
||||
return activityTimeLastInEpoch;
|
||||
}
|
||||
|
||||
public void setActivityCounter(int activityCounter) {
|
||||
this.activityCounter = activityCounter;
|
||||
this.activityTimeLastInEpoch = activityCounter;
|
||||
}
|
||||
|
||||
public boolean isWorked() {
|
||||
|
||||
@@ -138,6 +138,10 @@ public class ChatPreferences {
|
||||
String loginName = "Marc";
|
||||
String loginLocator = "jn49fk";
|
||||
|
||||
double stn_antennaBeamWidthDeg = 50;
|
||||
double stn_maxQRBDefault = 900;
|
||||
double stn_qtfDefault = 135;
|
||||
|
||||
ChatCategory loginChatCategory = new ChatCategory(2);
|
||||
IntegerProperty actualQTF = new SimpleIntegerProperty(360); // will be updated by user at runtime!
|
||||
|
||||
@@ -211,7 +215,29 @@ public class ChatPreferences {
|
||||
// }
|
||||
|
||||
|
||||
public double getStn_antennaBeamWidthDeg() {
|
||||
return stn_antennaBeamWidthDeg;
|
||||
}
|
||||
|
||||
public void setStn_antennaBeamWidthDeg(double stn_antennaBeamWidthDeg) {
|
||||
this.stn_antennaBeamWidthDeg = stn_antennaBeamWidthDeg;
|
||||
}
|
||||
|
||||
public double getStn_maxQRBDefault() {
|
||||
return stn_maxQRBDefault;
|
||||
}
|
||||
|
||||
public void setStn_maxQRBDefault(double stn_maxQRBDefault) {
|
||||
this.stn_maxQRBDefault = stn_maxQRBDefault;
|
||||
}
|
||||
|
||||
public double getStn_qtfDefault() {
|
||||
return stn_qtfDefault;
|
||||
}
|
||||
|
||||
public void setStn_qtfDefault(double stn_qtfDefault) {
|
||||
this.stn_qtfDefault = stn_qtfDefault;
|
||||
}
|
||||
|
||||
public boolean isLoginAFKState() {
|
||||
return loginAFKState;
|
||||
@@ -560,6 +586,18 @@ public class ChatPreferences {
|
||||
ChatCategory.setTextContent(this.getLoginChatCategory().getCategoryNumber()+"");
|
||||
station.appendChild(ChatCategory);
|
||||
|
||||
Element stn_antennaBeamWidthDeg = doc.createElement("stn_antennaBeamWidthDeg");
|
||||
stn_antennaBeamWidthDeg.setTextContent(this.stn_antennaBeamWidthDeg+"");
|
||||
station.appendChild(stn_antennaBeamWidthDeg);
|
||||
|
||||
Element stn_maxQRBDefault = doc.createElement("stn_maxQRBDefault");
|
||||
stn_maxQRBDefault.setTextContent(this.stn_maxQRBDefault+"");
|
||||
station.appendChild(stn_maxQRBDefault);
|
||||
|
||||
Element stn_qtfDefault = doc.createElement("stn_qtfDefault");
|
||||
stn_qtfDefault.setTextContent(this.stn_qtfDefault+"");
|
||||
station.appendChild(stn_qtfDefault);
|
||||
|
||||
// Element salary = doc.createElement("salary");
|
||||
// salary.setAttribute("currency", "USD");
|
||||
// salary.setTextContent("5000");
|
||||
@@ -851,9 +889,18 @@ public class ChatPreferences {
|
||||
loginChatCategory = new ChatCategory(2); // TODO: Set this default at another place
|
||||
}
|
||||
|
||||
double antennaBeamWidthDeg = Double.parseDouble(element.getElementsByTagName("stn_antennaBeamWidthDeg").item(0).getTextContent());
|
||||
stn_antennaBeamWidthDeg = antennaBeamWidthDeg;
|
||||
double maxQRBDefault = Double.parseDouble(element.getElementsByTagName("stn_maxQRBDefault").item(0).getTextContent());
|
||||
stn_maxQRBDefault = maxQRBDefault;
|
||||
double qtfDefault = Double.parseDouble(element.getElementsByTagName("stn_qtfDefault").item(0).getTextContent());
|
||||
stn_qtfDefault = qtfDefault;
|
||||
|
||||
|
||||
|
||||
System.out.println("[ChatPreferences, info]: Current Element: " + node.getNodeName()
|
||||
+ " --> call: " + call + " / " + password + " / " + loginDisplayedName + " / " + qra
|
||||
+ " / " + category);
|
||||
+ " / " + category + " / " + antennaBeamWidthDeg + " / " + maxQRBDefault + " / " + qtfDefault);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -6,6 +6,9 @@
|
||||
<LoginDisplayedName>Paule</LoginDisplayedName>
|
||||
<LoginLocator>JO51DI</LoginLocator>
|
||||
<ChatCategory>2</ChatCategory>
|
||||
<stn_antennaBeamWidthDeg>50</stn_antennaBeamWidthDeg>
|
||||
<stn_maxQRBDefault>900</stn_maxQRBDefault>
|
||||
<stn_qtfDefault>135</stn_qtfDefault>
|
||||
</station>
|
||||
<logsynch>
|
||||
<logsynch_fileBasedWkdCallInterpreterFileNameReadOnly>SimpleLogFile.txt</logsynch_fileBasedWkdCallInterpreterFileNameReadOnly>
|
||||
|
||||
Reference in New Issue
Block a user