mirror of
https://github.com/nasa/trick.git
synced 2024-12-18 20:57:55 +00:00
Fix variable server config in java clients. Ref #474
This commit is contained in:
parent
0a6e1bbc64
commit
9335b9cff8
@ -737,18 +737,19 @@ public class CannonDisplay extends JFrame {
|
||||
// Configure the Variable Server to cyclically send us the following varibales.
|
||||
// Tell the variable server:
|
||||
// 1) We want the values of the following variables:
|
||||
evd.out.writeBytes( "trick.var_add(\"dyn.cannon.impact\")\n" +
|
||||
evd.out.writeBytes( "trick.var_pause() \n" +
|
||||
"trick.var_add(\"dyn.cannon.impact\")\n" +
|
||||
"trick.var_add(\"dyn.cannon.pos[0]\")\n" +
|
||||
"trick.var_add(\"dyn.cannon.pos[1]\")\n" +
|
||||
"trick.var_add(\"dyn.cannon.vel[0]\")\n" +
|
||||
"trick.var_add(\"dyn.cannon.vel[1]\")\n" +
|
||||
"trick.var_add(\"trick_sys.sched.mode\")\n");
|
||||
"trick.var_add(\"trick_sys.sched.mode\")\n" +
|
||||
// 2) We want the responses in ASCII:
|
||||
evd.out.writeBytes("trick.var_ascii() \n");
|
||||
"trick.var_ascii() \n" +
|
||||
// 3) We want values to be updated at the specified rate:
|
||||
evd.out.writeBytes( String.format("trick.var_cycle(%.3f)\n", dt));
|
||||
String.format("trick.var_cycle(%.3f)\n", dt) +
|
||||
// 4) Start sending values as specified.
|
||||
evd.out.writeBytes("trick.var_send() \n" );
|
||||
"trick.var_unpause() \n" );
|
||||
evd.out.flush();
|
||||
|
||||
while (go) {
|
||||
|
@ -46,7 +46,7 @@ class SkyView extends JPanel {
|
||||
scale = mapScale;
|
||||
setScale(mapScale);
|
||||
skyColor = Color.BLACK;
|
||||
planetColor = new Color(100,200,200);
|
||||
planetColor = new Color(128,128,255);
|
||||
satelliteColor = new Color(255,0,0);
|
||||
planetRadius = 6378000;
|
||||
satellitePos = new double[] {0.0, planetRadius + 200000};
|
||||
@ -65,7 +65,13 @@ class SkyView extends JPanel {
|
||||
}
|
||||
}
|
||||
|
||||
public void drawCenteredCircle(Graphics2D g, int x, int y, int r) {
|
||||
public void drawCenteredOval(Graphics2D g, int x, int y, int rh, int rv) {
|
||||
x = x-(rh/2);
|
||||
y = y-(rv/2);
|
||||
g.drawOval(x,y,rh,rv);
|
||||
}
|
||||
|
||||
public void fillCenteredCircle(Graphics2D g, int x, int y, int r) {
|
||||
x = x-(r/2);
|
||||
y = y-(r/2);
|
||||
g.fillOval(x,y,r,r);
|
||||
@ -83,15 +89,34 @@ class SkyView extends JPanel {
|
||||
g2d.setPaint(Color.BLACK);
|
||||
g2d.fillRect(0, 0, width, height);
|
||||
|
||||
int pr0 = (int)(scale * planetRadius);
|
||||
int pr30 = (int)(scale * planetRadius * Math.cos(Math.toRadians(30)));
|
||||
int pr60 = (int)(scale * planetRadius * Math.cos(Math.toRadians(60)));
|
||||
|
||||
// Draw Planet
|
||||
g2d.setPaint(planetColor);
|
||||
drawCenteredCircle(g2d, worldOriginX, worldOriginY, (int)(scale * 2 * planetRadius));
|
||||
fillCenteredCircle(g2d, worldOriginX, worldOriginY, 2 * pr0);
|
||||
|
||||
g2d.setPaint(Color.BLACK);
|
||||
|
||||
// Circles of Latitude
|
||||
g2d.drawLine(worldOriginX - pr60, worldOriginY - pr30 , worldOriginX + pr60, worldOriginY - pr30);
|
||||
g2d.drawLine(worldOriginX - pr30, worldOriginY - pr60 , worldOriginX + pr30, worldOriginY - pr60);
|
||||
g2d.drawLine(worldOriginX - pr0, worldOriginY, worldOriginX + pr0, worldOriginY ); // Equator
|
||||
g2d.drawLine(worldOriginX - pr30, worldOriginY + pr60 , worldOriginX + pr30, worldOriginY + pr60);
|
||||
g2d.drawLine(worldOriginX - pr60, worldOriginY + pr30 , worldOriginX + pr60, worldOriginY + pr30);
|
||||
|
||||
// Meridians
|
||||
g2d.drawLine(worldOriginX, worldOriginY - pr0, worldOriginX, worldOriginY + pr0 );
|
||||
drawCenteredOval(g2d, worldOriginX, worldOriginY, 2 * pr60, 2 * pr0);
|
||||
drawCenteredOval(g2d, worldOriginX, worldOriginY, 2 * pr30, 2 * pr0);
|
||||
drawCenteredOval(g2d, worldOriginX, worldOriginY, 2 * pr0, 2 * pr0);
|
||||
|
||||
// Draw Satellite
|
||||
g2d.setPaint(satelliteColor);
|
||||
int sx = (int)(worldOriginX + scale * satellitePos[0]);
|
||||
int sy = (int)(worldOriginY - scale * satellitePos[1]);
|
||||
drawCenteredCircle(g2d, sx, sy, (int)(10));
|
||||
fillCenteredCircle(g2d, sx, sy, (int)(10));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -171,16 +196,13 @@ public class SatDisplay extends JFrame {
|
||||
System.out.println("Connecting to: " + host + ":" + port);
|
||||
sd.connectToServer(host, port);
|
||||
|
||||
sd.out.writeBytes("trick.var_set_client_tag(\"SatDisplay\") \n");
|
||||
sd.out.flush();
|
||||
|
||||
sd.out.writeBytes("trick.var_add(\"dyn.satellite.pos[0]\") \n" +
|
||||
"trick.var_add(\"dyn.satellite.pos[1]\") \n" );
|
||||
sd.out.flush();
|
||||
|
||||
sd.out.writeBytes("trick.var_ascii() \n" +
|
||||
"trick.var_cycle(0.1) \n" +
|
||||
"trick.var_send() \n" );
|
||||
sd.out.writeBytes("trick.var_set_client_tag(\"SatDisplay\") \n" +
|
||||
"trick.var_pause() \n" +
|
||||
"trick.var_add(\"dyn.satellite.pos[0]\") \n" +
|
||||
"trick.var_add(\"dyn.satellite.pos[1]\") \n" +
|
||||
"trick.var_ascii() \n" +
|
||||
"trick.var_cycle(0.1) \n" +
|
||||
"trick.var_unpause()\n" );
|
||||
sd.out.flush();
|
||||
|
||||
Boolean go = true;
|
||||
|
@ -404,10 +404,9 @@ public class SunDisplay extends JFrame implements ActionListener {
|
||||
System.out.println("Connecting to: " + host + ":" + port);
|
||||
evd.connectToServer(host, port);
|
||||
|
||||
evd.out.writeBytes("trick.var_set_client_tag(\"SunDisplay\") \n");
|
||||
evd.out.flush();
|
||||
|
||||
evd.out.writeBytes("trick.var_add(\"sun_predictor.sun.JD\") \n" +
|
||||
evd.out.writeBytes("trick.var_set_client_tag(\"SunDisplay\") \n" +
|
||||
"trick.var_pause() \n" +
|
||||
"trick.var_add(\"sun_predictor.sun.JD\") \n" +
|
||||
"trick.var_add(\"sun_predictor.sun.observer_latitude\") \n" +
|
||||
"trick.var_add(\"sun_predictor.sun.observer_longitude\") \n" +
|
||||
"trick.var_add(\"sun_predictor.sun.observer_offset_from_UTC\") \n" +
|
||||
@ -430,13 +429,9 @@ public class SunDisplay extends JFrame implements ActionListener {
|
||||
"trick.var_add(\"sun_predictor.sun.utc.hour\") \n" +
|
||||
"trick.var_add(\"sun_predictor.sun.utc.min\") \n" +
|
||||
"trick.var_add(\"sun_predictor.sun.utc.sec\") \n" +
|
||||
""
|
||||
);
|
||||
|
||||
evd.out.flush();
|
||||
evd.out.writeBytes("trick.var_ascii() \n" +
|
||||
"trick.var_ascii() \n" +
|
||||
"trick.var_cycle(0.1) \n" +
|
||||
"trick.var_send() \n" );
|
||||
"trick.var_unpause() \n" );
|
||||
evd.out.flush();
|
||||
|
||||
Boolean go = true;
|
||||
|
@ -229,17 +229,14 @@ public class EVDisplay extends JFrame {
|
||||
System.out.println("Connecting to: " + host + ":" + port);
|
||||
evd.connectToServer(host, port);
|
||||
|
||||
evd.out.writeBytes("trick.var_set_client_tag(\"EVDisplay\") \n");
|
||||
evd.out.flush();
|
||||
|
||||
evd.out.writeBytes("trick.var_add(\"veh.vehicle.position[0]\") \n" +
|
||||
evd.out.writeBytes("trick.var_set_client_tag(\"EVDisplay\") \n" +
|
||||
"trick.var_pause() \n" +
|
||||
"trick.var_add(\"veh.vehicle.position[0]\") \n" +
|
||||
"trick.var_add(\"veh.vehicle.position[1]\") \n" +
|
||||
"trick.var_add(\"veh.vehicle.heading\") \n");
|
||||
evd.out.flush();
|
||||
|
||||
evd.out.writeBytes("trick.var_ascii() \n" +
|
||||
"trick.var_add(\"veh.vehicle.heading\") \n" +
|
||||
"trick.var_ascii() \n" +
|
||||
"trick.var_cycle(0.1) \n" +
|
||||
"trick.var_send() \n" );
|
||||
"trick.var_unpause() \n" );
|
||||
evd.out.flush();
|
||||
|
||||
Boolean go = true;
|
||||
|
Loading…
Reference in New Issue
Block a user