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:
Marc Froehlich
2024-02-27 01:53:24 +01:00
committed by praktimarc
parent d13b7785af
commit e7d13401be
9 changed files with 810 additions and 133 deletions

View File

@@ -9,7 +9,7 @@ public class ApplicationConstants {
/** /**
* Name of file to store preferences in. * 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 VERSIONINFOURLFORUPDATES_KST4CONTEST = "https://do5amf.funkerportal.de/kst4ContestVersionInfo.xml";
public static final String VERSIONINFDOWNLOADEDLOCALFILE = "kst4ContestVersionInfo.xml"; public static final String VERSIONINFDOWNLOADEDLOCALFILE = "kst4ContestVersionInfo.xml";

View File

@@ -99,6 +99,54 @@ public class ChatController {
this.disconnected = disconnected; 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 * Handles the disconnect of either the chat (Case DISCONNECTONLY) or the
* complete application life including all threads (case CLOSEALL)<br/><br/> * complete application life including all threads (case CLOSEALL)<br/><br/>
@@ -290,7 +338,7 @@ public class ChatController {
private String chatState; private String chatState;
private String hostname = "109.90.0.130"; 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 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 private int port = 23001; // kst4contest.test 4 23001

View File

@@ -366,7 +366,8 @@ public class MessageBusManagementThread extends Thread {
// newMember.setQTFdirection(LocatorUtils); // newMember.setQTFdirection(LocatorUtils);
newMember.setQrb(new Location().getDistanceKmByTwoLocatorStrings(client.getChatPreferences().getLoginLocator(), newMember.getQra())); newMember.setQrb(new Location().getDistanceKmByTwoLocatorStrings(client.getChatPreferences().getLoginLocator(), newMember.getQra()));
newMember.setQTFdirection(new Location(client.getChatPreferences().getLoginLocator()).getBearing(new Location(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 // this.client.getChatMemberTable().put(splittedMessageLine[2], newMember); //TODO: map -> List
@@ -406,6 +407,7 @@ public class MessageBusManagementThread extends Thread {
newMember.setQra(splittedMessageLine[4]); newMember.setQra(splittedMessageLine[4]);
newMember.setState(Integer.parseInt(splittedMessageLine[5])); newMember.setState(Integer.parseInt(splittedMessageLine[5]));
newMember.setLastActivity(new Utils4KST().time_generateActualTimeInDateFormat()); newMember.setLastActivity(new Utils4KST().time_generateActualTimeInDateFormat());
newMember.setActivityTimeLastInEpoch(new Utils4KST().time_generateCurrentEpochTime());
newMember.setQrb(new Location().getDistanceKmByTwoLocatorStrings(client.getChatPreferences().getLoginLocator(), newMember.getQra())); newMember.setQrb(new Location().getDistanceKmByTwoLocatorStrings(client.getChatPreferences().getLoginLocator(), newMember.getQra()));
newMember.setQTFdirection(new Location(client.getChatPreferences().getLoginLocator()).getBearing(new Location(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); int index = checkListForChatMemberIndexByCallSign(this.client.getLst_chatMemberList(), sender);
//if the user had been found in the active users list
if (index != -1) { if (index != -1) {
//user found in the chatmember list //user found in the chatmember list
try { try {
newMessage.setSender(this.client.getLst_chatMemberList().get(index)); // set sender to member of 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) { } catch (Exception exc) {
ChatMember aSenderDummy = new ChatMember(); ChatMember aSenderDummy = new ChatMember();
aSenderDummy.setCallSign(splittedMessageLine[3] + "[n/a]"); aSenderDummy.setCallSign(splittedMessageLine[3] + "[n/a]");
@@ -502,7 +506,7 @@ public class MessageBusManagementThread extends Thread {
} }
// b4 init list // b4 init list
} else { } 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())) { if (!sender.getCallSign().equals(this.client.getChatPreferences().getLoginCallSign().toUpperCase())) {
sender.setCallSign("[n/a]" + sender.getCallSign()); sender.setCallSign("[n/a]" + sender.getCallSign());
// if someone sent a message without being in the userlist (cause // if someone sent a message without being in the userlist (cause
@@ -922,9 +926,18 @@ public class MessageBusManagementThread extends Thread {
pwErrorMsg.setSender(server); pwErrorMsg.setSender(server);
pwErrorMsg.setMessageText(splittedMessageLine[2]); 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++) { for (int i = 0; i < 10; i++) {
client.getLst_toMeMessageList().add(pwErrorMsg); client.getLst_globalChatMessageList().add(pwErrorMsg);
client.getLst_toAllMessageList().add(pwErrorMsg); // client.getLst_toMeMessageList().add(pwErrorMsg);
// client.getLst_toAllMessageList().add(pwErrorMsg);
} }
// Kst4ContestApplication.alertWindowEvent("Password was wrong. Pse check!"); // Kst4ContestApplication.alertWindowEvent("Password was wrong. Pse check!");

View File

@@ -50,6 +50,21 @@ public class Utils4KST {
} }
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() { public Date time_generateActualTimeInDateFormat() {
Date date = new Date(time_generateCurrentEpochTime() * 1000L); Date date = new Date(time_generateCurrentEpochTime() * 1000L);
return date; return date;

View 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;
}
}

View File

@@ -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
// 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 lastActivity; // time of last activity in epochtimesec
Date lastActualizationTimeOfThisMember; // time of last state change if that member Date lastActualizationTimeOfThisMember; // time of last state change if that member
Double qrb; Double qrb;
@@ -125,8 +125,8 @@ public class ChatMember {
this.workedCategories = workedCategories; this.workedCategories = workedCategories;
} }
public void setActivityCounter(long activityCounter) { public void setActivityTimeLastInEpoch(long activityTimeLastInEpoch) {
this.activityCounter = activityCounter; this.activityTimeLastInEpoch = activityTimeLastInEpoch;
} }
public int getState() { public int getState() {
@@ -210,12 +210,12 @@ public class ChatMember {
this.frequency = frequency; this.frequency = frequency;
} }
public long getActivityCounter() { public long getActivityTimeLastInEpoch() {
return activityCounter; return activityTimeLastInEpoch;
} }
public void setActivityCounter(int activityCounter) { public void setActivityCounter(int activityCounter) {
this.activityCounter = activityCounter; this.activityTimeLastInEpoch = activityCounter;
} }
public boolean isWorked() { public boolean isWorked() {

View File

@@ -138,6 +138,10 @@ public class ChatPreferences {
String loginName = "Marc"; String loginName = "Marc";
String loginLocator = "jn49fk"; String loginLocator = "jn49fk";
double stn_antennaBeamWidthDeg = 50;
double stn_maxQRBDefault = 900;
double stn_qtfDefault = 135;
ChatCategory loginChatCategory = new ChatCategory(2); ChatCategory loginChatCategory = new ChatCategory(2);
IntegerProperty actualQTF = new SimpleIntegerProperty(360); // will be updated by user at runtime! 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() { public boolean isLoginAFKState() {
return loginAFKState; return loginAFKState;
@@ -560,6 +586,18 @@ public class ChatPreferences {
ChatCategory.setTextContent(this.getLoginChatCategory().getCategoryNumber()+""); ChatCategory.setTextContent(this.getLoginChatCategory().getCategoryNumber()+"");
station.appendChild(ChatCategory); 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"); // Element salary = doc.createElement("salary");
// salary.setAttribute("currency", "USD"); // salary.setAttribute("currency", "USD");
// salary.setTextContent("5000"); // salary.setTextContent("5000");
@@ -851,9 +889,18 @@ public class ChatPreferences {
loginChatCategory = new ChatCategory(2); // TODO: Set this default at another place 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() System.out.println("[ChatPreferences, info]: Current Element: " + node.getNodeName()
+ " --> call: " + call + " / " + password + " / " + loginDisplayedName + " / " + qra + " --> call: " + call + " / " + password + " / " + loginDisplayedName + " / " + qra
+ " / " + category); + " / " + category + " / " + antennaBeamWidthDeg + " / " + maxQRBDefault + " / " + qtfDefault);
} }
} }

File diff suppressed because it is too large Load Diff

View File

@@ -6,6 +6,9 @@
<LoginDisplayedName>Paule</LoginDisplayedName> <LoginDisplayedName>Paule</LoginDisplayedName>
<LoginLocator>JO51DI</LoginLocator> <LoginLocator>JO51DI</LoginLocator>
<ChatCategory>2</ChatCategory> <ChatCategory>2</ChatCategory>
<stn_antennaBeamWidthDeg>50</stn_antennaBeamWidthDeg>
<stn_maxQRBDefault>900</stn_maxQRBDefault>
<stn_qtfDefault>135</stn_qtfDefault>
</station> </station>
<logsynch> <logsynch>
<logsynch_fileBasedWkdCallInterpreterFileNameReadOnly>SimpleLogFile.txt</logsynch_fileBasedWkdCallInterpreterFileNameReadOnly> <logsynch_fileBasedWkdCallInterpreterFileNameReadOnly>SimpleLogFile.txt</logsynch_fileBasedWkdCallInterpreterFileNameReadOnly>