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
ce88bb38
Commit
ce88bb38
authored
6 years ago
by
John Furr
Browse files
Options
Downloads
Patches
Plain Diff
Draft files edited.
parent
e5372327
No related branches found
Branches containing commit
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
+20
-15
20 additions, 15 deletions
...tember/FinalProject/FriscoFurrProject/FDCSendRecieve.java
with
20 additions
and
15 deletions
deliverables/src/MV3500Cohort2018JulySeptember/FinalProject/FriscoFurrProject/FDCSendRecieve.java
+
20
−
15
View file @
ce88bb38
...
@@ -5,8 +5,8 @@ import java.io.*;
...
@@ -5,8 +5,8 @@ import java.io.*;
import
java.util.*
;
import
java.util.*
;
import
edu.nps.moves.dis.*
;
import
edu.nps.moves.dis.*
;
import
java.io.IOException
;
import
java.io.IOException
;
import
edu.nps.moves.disenum.*
;
import
edu.nps.moves.disutil.PduFactory
;
import
edu.nps.moves.disutil.PduFactory
;
import
java.sql.Timestamp
;
public
class
FDCSendRecieve
{
public
class
FDCSendRecieve
{
...
@@ -26,7 +26,8 @@ public class FDCSendRecieve {
...
@@ -26,7 +26,8 @@ public class FDCSendRecieve {
public
static
final
int
MULTICAST_PORT
=
3000
;
public
static
final
int
MULTICAST_PORT
=
3000
;
public
static
final
String
MULTICAST_GROUP
=
"239.1.2.3"
;
public
static
final
String
MULTICAST_GROUP
=
"239.1.2.3"
;
public
static
final
boolean
USE_FAST_ESPDU
=
false
;
public
static
final
boolean
USE_FAST_ESPDU
=
false
;
public
long
[]
sentBuffer
=
new
long
[
100
];
// public List<long> sentBufferList;
public
FDCSendRecieve
(
int
port
,
String
multicast
)
{
public
FDCSendRecieve
(
int
port
,
String
multicast
)
{
...
@@ -42,18 +43,20 @@ public class FDCSendRecieve {
...
@@ -42,18 +43,20 @@ public class FDCSendRecieve {
}
}
public
void
run
(
Pdu
pdu
)
{
public
void
run
(
Pdu
pdu
)
{
System
.
out
.
println
(
"DisExamples.PduSender started..."
);
if
(
sentBuffer
.)
System
.
out
.
println
(
"FDC Sender started..."
);
short
currentPduType
=
pdu
.
getPduType
();
short
currentPduType
=
pdu
.
getPduType
();
String
currentPduTypeName
=
pdu
.
getClass
().
getName
();
System
.
out
.
println
(
"in sender, recived PDU type: "
+
currentPduType
);
short
currentProtocolFamilyID
=
pdu
.
getProtocolFamily
();
// String currentPduTypeName = pdu.getClass().getName();
String
currentPduFamilyName
=
pdu
.
getClass
().
getSuperclass
().
getSimpleName
();
// short currentProtocolFamilyID = pdu.getProtocolFamily();
// String currentPduFamilyName = pdu.getClass().getSuperclass().getSimpleName();
try
{
try
{
List
<
Pdu
>
generatedPdus
=
new
ArrayList
<>();
List
<
Pdu
>
generatedPdus
=
new
ArrayList
<>();
// Loop through all the enumerated PDU types, create a PDU for each type,
// Loop through all the enumerated PDU types, create a PDU for each type,
// and add that PDU to a list.
// and add that PDU to a list.
for
(
PduType
pdu2
:
PduType
.
values
())
{
Pdu
aPdu
=
null
;
Pdu
aPdu
=
null
;
System
.
out
.
println
(
pdu
);
System
.
out
.
println
(
pdu
);
...
@@ -73,6 +76,7 @@ public class FDCSendRecieve {
...
@@ -73,6 +76,7 @@ public class FDCSendRecieve {
espduLocation
.
setX
(
1.0
);
espduLocation
.
setX
(
1.0
);
espduLocation
.
setY
(
2.0
);
espduLocation
.
setY
(
2.0
);
espduLocation
.
setZ
(
3.0
);
espduLocation
.
setZ
(
3.0
);
espdu
.
setTimestamp
(
System
.
currentTimeMillis
());
break
;
break
;
// case COMMENT:
// case COMMENT:
...
@@ -104,7 +108,7 @@ public class FDCSendRecieve {
...
@@ -104,7 +108,7 @@ public class FDCSendRecieve {
generatedPdus
.
add
(
aPdu
);
generatedPdus
.
add
(
aPdu
);
System
.
out
.
println
(
"APDU container count "
+
generatedPdus
.
size
());
System
.
out
.
println
(
"APDU container count "
+
generatedPdus
.
size
());
}
}
}
// Send the PDUs we created
// Send the PDUs we created
InetAddress
localMulticastAddress
=
InetAddress
.
getByName
(
DEFAULT_MULTICAST_ADDRESS
);
InetAddress
localMulticastAddress
=
InetAddress
.
getByName
(
DEFAULT_MULTICAST_ADDRESS
);
...
@@ -116,12 +120,13 @@ public class FDCSendRecieve {
...
@@ -116,12 +120,13 @@ public class FDCSendRecieve {
DataOutputStream
dos
=
new
DataOutputStream
(
baos
);
DataOutputStream
dos
=
new
DataOutputStream
(
baos
);
byte
[]
buffer
;
byte
[]
buffer
;
Pdu
aPdu
=
generatedPdus
.
get
(
idx
);
aPdu
=
generatedPdus
.
get
(
idx
);
aPdu
.
marshal
(
dos
);
aPdu
.
marshal
(
dos
);
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
();
System
.
out
.
println
(
"Sent PDU of type "
+
aPdu
.
getClass
().
getName
());
System
.
out
.
println
(
"Sent PDU of type "
+
aPdu
.
getClass
().
getName
());
}
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
...
@@ -173,8 +178,8 @@ public class FDCSendRecieve {
...
@@ -173,8 +178,8 @@ public class FDCSendRecieve {
location
.
setY
(
0.0
);
//TGT = 150 OBS = 75
location
.
setY
(
0.0
);
//TGT = 150 OBS = 75
location
.
setZ
(
10.0
);
//TGT = 20 OBS = 50
location
.
setZ
(
10.0
);
//TGT = 20 OBS = 50
FDCespdu
.
setEntityLocation
(
location
);
FDCespdu
.
setEntityLocation
(
location
);
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
/* BELOW IS THE RECIEVE CODE //
/* BELOW IS THE RECIEVE CODE //
// //
// //
...
@@ -209,9 +214,7 @@ public class FDCSendRecieve {
...
@@ -209,9 +214,7 @@ public class FDCSendRecieve {
Pdu
pdu
=
factory
.
createPdu
(
packet
.
getData
());
Pdu
pdu
=
factory
.
createPdu
(
packet
.
getData
());
if
(
pdu
!=
null
)
{
if
(
pdu
!=
null
)
{
currentPduType
=
pdu
.
getPduType
();
currentPduType
=
pdu
.
getPduType
();
String
currentPduTypeName
=
pdu
.
getClass
().
getName
();
String
currentPduTypeName
=
pdu
.
getClass
().
getName
();
short
currentProtocolFamilyID
=
pdu
.
getProtocolFamily
();
short
currentProtocolFamilyID
=
pdu
.
getProtocolFamily
();
String
currentPduFamilyName
=
pdu
.
getClass
().
getSuperclass
().
getSimpleName
();
String
currentPduFamilyName
=
pdu
.
getClass
().
getSuperclass
().
getSimpleName
();
...
@@ -222,7 +225,9 @@ public class FDCSendRecieve {
...
@@ -222,7 +225,9 @@ public class FDCSendRecieve {
if
(
currentPduType
==
1
)
//EntityState
if
(
currentPduType
==
1
)
//EntityState
{
{
EntityStatePdu
entityPDU
=
(
EntityStatePdu
)
pdu
;
EntityStatePdu
entityPDU
=
(
EntityStatePdu
)
pdu
;
if
(
entityPDU
.
getForceId
()==
222
){
EntityType
PduEntityType
=
entityPDU
.
getEntityType
();
PduEntityType
.
setCountry
(
225
);
if
(
PduEntityType
.
getCountry
()==
222
){
//do something for the OBS as this is a russian asshat. Most likely send the pdu with sender.run(pdu);
//do something for the OBS as this is a russian asshat. Most likely send the pdu with sender.run(pdu);
System
.
out
.
println
(
"got a russian SOB!"
);
System
.
out
.
println
(
"got a russian SOB!"
);
}
}
...
...
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