Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NetworkedGraphicsMV3500
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Savage
NetworkedGraphicsMV3500
Commits
f73c7269
Commit
f73c7269
authored
6 years ago
by
John Furr
Browse files
Options
Downloads
Patches
Plain Diff
Edit comments
parent
9bba1164
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
deliverables/src/MV3500Cohort2018JulySeptember/FinalProject/FriscoFurrProject/FDCSendRecieve.java
+3
-57
3 additions, 57 deletions
...tember/FinalProject/FriscoFurrProject/FDCSendRecieve.java
with
3 additions
and
57 deletions
deliverables/src/MV3500Cohort2018JulySeptember/FinalProject/FriscoFurrProject/FDCSendRecieve.java
+
3
−
57
View file @
f73c7269
...
@@ -61,14 +61,7 @@ public class FDCSendRecieve {
...
@@ -61,14 +61,7 @@ public class FDCSendRecieve {
short
currentPduType
=
pdu
.
getPduType
();
short
currentPduType
=
pdu
.
getPduType
();
System
.
out
.
println
(
"in sender, recived PDU type: "
+
currentPduType
);
System
.
out
.
println
(
"in sender, recived PDU type: "
+
currentPduType
);
// String currentPduTypeName = pdu.getClass().getName();
// short currentProtocolFamilyID = pdu.getProtocolFamily();
// String currentPduFamilyName = pdu.getClass().getSuperclass().getSimpleName();
// Loop through all the enumerated PDU types, create a PDU for each type,
// and add that PDU to a list.
//System.out.println(pdu);
//Change the switch statement to the currentPduType from the recieve portion, then when a packet we want comes in, send the CASE file.
switch
(
currentPduType
)
// using enumeration values from edu.nps.moves.disenum.*
switch
(
currentPduType
)
// using enumeration values from edu.nps.moves.disenum.*
{
{
...
@@ -76,25 +69,13 @@ public class FDCSendRecieve {
...
@@ -76,25 +69,13 @@ public class FDCSendRecieve {
aPdu
=
pdu
;
aPdu
=
pdu
;
break
;
break
;
// case COMMENT:
// aPdu = new CommentPdu();
// break;
//
case
2
:
//FIRE
case
2
:
//FIRE
aPdu
=
pdu
;
aPdu
=
pdu
;
break
;
break
;
//
// case DETONATION:
// aPdu = new DetonationPdu();
// break;
//
//
case
15
:
//AcknowledgePdu
case
15
:
//AcknowledgePdu
aPdu
=
pdu
;
aPdu
=
pdu
;
break
;
break
;
//
// case 16: //ACTION_REQUEST:
// aPdu = new ActionRequestPdu();
// break;
case
17
:
case
17
:
aPdu
=
pdu
;
aPdu
=
pdu
;
...
@@ -105,7 +86,6 @@ public class FDCSendRecieve {
...
@@ -105,7 +86,6 @@ public class FDCSendRecieve {
break
;
break
;
default
:
default
:
//add some shit that makes sense here.
System
.
out
.
print
(
"PDU of type "
+
pdu
+
" not supported, created or sent "
);
System
.
out
.
print
(
"PDU of type "
+
pdu
+
" not supported, created or sent "
);
System
.
out
.
println
();
System
.
out
.
println
();
}
}
...
@@ -126,7 +106,6 @@ public class FDCSendRecieve {
...
@@ -126,7 +106,6 @@ public class FDCSendRecieve {
buffer
=
baos
.
toByteArray
();
buffer
=
baos
.
toByteArray
();
DatagramPacket
packet
=
new
DatagramPacket
(
buffer
,
buffer
.
length
,
localMulticastAddress
,
DEFAULT_MULTICAST_PORT
);
DatagramPacket
packet
=
new
DatagramPacket
(
buffer
,
buffer
.
length
,
localMulticastAddress
,
DEFAULT_MULTICAST_PORT
);
socket
.
send
(
packet
);
socket
.
send
(
packet
);
//sentBuffer[sentBuffer.length] = aPdu.getTimestamp();
sentBufferList
.
add
(
aPdu
.
getTimestamp
());
sentBufferList
.
add
(
aPdu
.
getTimestamp
());
System
.
out
.
println
(
"Sent PDU of type "
+
aPdu
.
getClass
().
getName
()+
"\n"
);
System
.
out
.
println
(
"Sent PDU of type "
+
aPdu
.
getClass
().
getName
()+
"\n"
);
}
}
...
@@ -134,24 +113,7 @@ public class FDCSendRecieve {
...
@@ -134,24 +113,7 @@ public class FDCSendRecieve {
public
static
void
main
(
String
[]
args
)
throws
IOException
,
InterruptedException
{
public
static
void
main
(
String
[]
args
)
throws
IOException
,
InterruptedException
{
DisTime
disTime
=
DisTime
.
getInstance
();
DisTime
disTime
=
DisTime
.
getInstance
();
//turns on the sender code - might need to move around down into the recieve with the if statements...
//
// ORIGINAL SENDING CODE MAIN CLASS:
//
//
// if (args.length == 2) {
// FDCSendRecieve sender = new FDCSendRecieve(Integer.parseInt(args[0]), args[1]);
// // sender.run(); //needs to be sender.run(pdu)
// } else {
// System.out.println("Usage: PduSender <port> <multicast group>");
// System.out.println("Default: PduSender " + DEFAULT_MULTICAST_PORT + " " + DEFAULT_MULTICAST_ADDRESS);
// FDCSendRecieve sender = new FDCSendRecieve(DEFAULT_MULTICAST_PORT, DEFAULT_MULTICAST_ADDRESS);
// sender.run();
// }
//
// Inital Hello world from entity:
//
FDCSendRecieve
sender
=
new
FDCSendRecieve
(
DEFAULT_MULTICAST_PORT
,
DEFAULT_MULTICAST_ADDRESS
);
//initalize the sender
FDCSendRecieve
sender
=
new
FDCSendRecieve
(
DEFAULT_MULTICAST_PORT
,
DEFAULT_MULTICAST_ADDRESS
);
//initalize the sender
EntityStatePdu
FDCespdu
=
new
EntityStatePdu
();
EntityStatePdu
FDCespdu
=
new
EntityStatePdu
();
...
@@ -181,7 +143,7 @@ public class FDCSendRecieve {
...
@@ -181,7 +143,7 @@ public class FDCSendRecieve {
FDCespdu
.
setEntityLocation
(
location
);
FDCespdu
.
setEntityLocation
(
location
);
int
timestamp
=
disTime
.
getDisAbsoluteTimestamp
();
int
timestamp
=
disTime
.
getDisAbsoluteTimestamp
();
FDCespdu
.
setTimestamp
(
timestamp
);
FDCespdu
.
setTimestamp
(
timestamp
);
//FDCespdu.setTimestamp(System.currentTimeMillis());
sender
.
run
(
FDCespdu
);
//sends inital here I am and who I am
sender
.
run
(
FDCespdu
);
//sends inital here I am and who I am
//Set up other players to look for:
//Set up other players to look for:
...
@@ -206,7 +168,6 @@ public class FDCSendRecieve {
...
@@ -206,7 +168,6 @@ public class FDCSendRecieve {
short
currentPduType
=
0
;
//will use the curentPduType as the check for sending other packets.
short
currentPduType
=
0
;
//will use the curentPduType as the check for sending other packets.
try
{
try
{
// TODO: Change the line below to make sense for each class
System
.
out
.
println
(
"FDC is alive and ready to recieve fire missions...\n\n"
);
System
.
out
.
println
(
"FDC is alive and ready to recieve fire missions...\n\n"
);
socket
=
new
MulticastSocket
(
MULTICAST_PORT
);
socket
=
new
MulticastSocket
(
MULTICAST_PORT
);
address
=
InetAddress
.
getByName
(
MULTICAST_GROUP
);
address
=
InetAddress
.
getByName
(
MULTICAST_GROUP
);
...
@@ -221,9 +182,6 @@ public class FDCSendRecieve {
...
@@ -221,9 +182,6 @@ public class FDCSendRecieve {
packet
=
new
DatagramPacket
(
buffer
,
buffer
.
length
);
// reset
packet
=
new
DatagramPacket
(
buffer
,
buffer
.
length
);
// reset
socket
.
receive
(
packet
);
socket
.
receive
(
packet
);
//
//TODO: NEED IF STATEMENT IF THE SENDER IS THIS CLASS TO DELETE.
//
String
marking2
=
new
String
();
String
marking2
=
new
String
();
Pdu
pdu
=
factory
.
createPdu
(
packet
.
getData
());
Pdu
pdu
=
factory
.
createPdu
(
packet
.
getData
());
...
@@ -246,7 +204,6 @@ public class FDCSendRecieve {
...
@@ -246,7 +204,6 @@ public class FDCSendRecieve {
EntityStatePdu
pdu2
=
(
EntityStatePdu
)
pdu
;
EntityStatePdu
pdu2
=
(
EntityStatePdu
)
pdu
;
marking2
=
pdu2
.
getMarking
().
getCharactersString
();
marking2
=
pdu2
.
getMarking
().
getCharactersString
();
}
}
//Keep adding any if statements as needed for the class you are building.
StringBuilder
message
=
new
StringBuilder
();
StringBuilder
message
=
new
StringBuilder
();
message
.
append
(
"received DIS PDU: "
);
message
.
append
(
"received DIS PDU: "
);
message
.
append
(
"pduType "
);
message
.
append
(
"pduType "
);
...
@@ -266,9 +223,6 @@ public class FDCSendRecieve {
...
@@ -266,9 +223,6 @@ public class FDCSendRecieve {
EntityStatePdu
entityPDU
=
(
EntityStatePdu
)
pdu
;
EntityStatePdu
entityPDU
=
(
EntityStatePdu
)
pdu
;
EntityType
PduEntityType
=
entityPDU
.
getEntityType
();
EntityType
PduEntityType
=
entityPDU
.
getEntityType
();
if
(
PduEntityType
.
getCountry
()
==
225
)
{
if
(
PduEntityType
.
getCountry
()
==
225
)
{
//do something for the OBS as this is a russian asshat. Most likely send the pdu with sender.run(pdu);
//create Action Request PDU
//sender.run(actionPDU);
Thread
.
sleep
((
long
)
200
);
Thread
.
sleep
((
long
)
200
);
timestamp
=
disTime
.
getDisAbsoluteTimestamp
();
timestamp
=
disTime
.
getDisAbsoluteTimestamp
();
FDCespdu
.
setTimestamp
(
timestamp
);
FDCespdu
.
setTimestamp
(
timestamp
);
...
@@ -284,14 +238,7 @@ public class FDCSendRecieve {
...
@@ -284,14 +238,7 @@ public class FDCSendRecieve {
ack
.
setRequestID
((
long
)
1
);
ack
.
setRequestID
((
long
)
1
);
timestamp
=
disTime
.
getDisAbsoluteTimestamp
();
timestamp
=
disTime
.
getDisAbsoluteTimestamp
();
ack
.
setTimestamp
(
timestamp
);
ack
.
setTimestamp
(
timestamp
);
// ActionResponsePdu response = new ActionResponsePdu();
// response.setExerciseID((short) 1);
// response.setRequestID((long) 1);
// response.setOriginatingEntityID(FDCID);
// response.setReceivingEntityID(OBSEntityID);
// timestamp = disTime.getDisAbsoluteTimestamp();
// response.setTimestamp(timestamp);
//
FirePdu
fire
=
new
FirePdu
();
FirePdu
fire
=
new
FirePdu
();
fire
.
setExerciseID
((
short
)
1
);
fire
.
setExerciseID
((
short
)
1
);
fire
.
setFireMissionIndex
(
1000
);
fire
.
setFireMissionIndex
(
1000
);
...
@@ -301,7 +248,6 @@ public class FDCSendRecieve {
...
@@ -301,7 +248,6 @@ public class FDCSendRecieve {
timestamp
=
disTime
.
getDisAbsoluteTimestamp
();
timestamp
=
disTime
.
getDisAbsoluteTimestamp
();
fire
.
setTimestamp
(
timestamp
);
fire
.
setTimestamp
(
timestamp
);
sender
.
run
(
ack
,
fire
);
sender
.
run
(
ack
,
fire
);
// sender.run(fire,fire);
}
}
if
(
currentPduType
==
22
)
//Comment PDU
if
(
currentPduType
==
22
)
//Comment PDU
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment