Skip to content

Commit

Permalink
fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Goldsmith committed Apr 25, 2018
1 parent fa7ba41 commit 1ede3f9
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 3 deletions.
Binary file removed osc-project-6/Exchange/jars/client.jar
Binary file not shown.
Binary file removed osc-project-6/Exchange/jars/fixtrackerframe.jar
Binary file not shown.
Binary file removed osc-project-6/Exchange/jars/server.jar
Binary file not shown.
25 changes: 25 additions & 0 deletions osc-project-6/Exchange/src/osdi/client/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
//import osdi.client.BanzaiApplication
import osdi.clientui.ClientFrame;
import osdi.configEditor.ConfigurationDocumentViewer;
import osdi.test.acceptanceresynch.ResynchTestServer;

/**
* Entry point for the Client application.
Expand All @@ -66,9 +67,18 @@ public class Client {
private boolean initiatorStarted = false;
private Initiator initiator = null;
private JFrame frame = null;

private final Logger logger = LoggerFactory.getLogger(ResynchTestServer.class);
private final SessionSettings settings = new SessionSettings();
// private final CountDownLatch shutdownLatch = new CountDownLatch(1);
private boolean failed;

private boolean unsynchMode = false;
private boolean forceResynch = false;

public Client(String[] args) throws Exception {
InputStream inputStream = null;

if (args.length == 0) {
inputStream = ConfigurationDocumentViewer.class.getResourceAsStream("config/client.cfg");
//Client.class.getResourceAsStream("client.cfg");
Expand Down Expand Up @@ -158,5 +168,20 @@ public static void main(String[] args) throws Exception {
}
shutdownLatch.await();
}
public void setUnsynchMode(boolean unsynchMode) {
this.unsynchMode = unsynchMode;
}

public boolean isUnsynchMode() {
return unsynchMode;
}

public void setForceResynch(boolean forceResynch) {
this.forceResynch = forceResynch;
}

public boolean isForceResynch() {
return forceResynch;
}

}
Binary file removed osc-project-6/Exchange/src/osdi/client/logo.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions osc-project-6/Exchange/src/osdi/clientui/ClientFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,14 @@ public void splashScreenInit() {
JWindow window = new JWindow();

window.getContentPane()
.add(new JLabel(new javax.swing.ImageIcon(Client.class.getResource("logo.png")), SwingConstants.CENTER))
.add(new JLabel(new javax.swing.ImageIcon(Client.class.getResource("testlogo.png")), SwingConstants.CENTER))
.setBackground(Color.WHITE);
// mediumsmall-res.png

window.setSize(1080, 600);

// previously deleted. we'll keep setBounds for now until
// we add one of the other images that are larger.
window.setBounds(500, 150, 300, 200);
window.setBounds(600, 500, 500, 400); //400
window.setLocationRelativeTo(null);

window.setBackground(Color.WHITE);
Expand Down
60 changes: 60 additions & 0 deletions osc-project-6/Exchange/src/osdi/loyola/index/MathUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package osdi.loyola.index;

import java.util.LinkedList;

/**
* Math Utilities.
*/
public class MathUtils
{
/**
* Simple Moving Average
*/
public static class SMA
{
private LinkedList values = new LinkedList();

private int length;

private double sum = 0;

private double average = 0;

/**
*
* @param length the maximum length
*/
public SMA(int length)
{
if (length <= 0)
{
throw new IllegalArgumentException("length must be greater than zero");
}
this.length = length;
}

public double currentAverage()
{
return average;
}

/**
* Compute the moving average.
* Synchronised so that no changes in the underlying data is made during calculation.
* @param value The value
* @return The average
*/
public synchronized double compute(double value)
{
if (values.size() == length && length > 0)
{
sum -= ((Double) values.getFirst()).doubleValue();
values.removeFirst();
}
sum += value;
values.addLast(new Double(value));
average = sum / values.size();
return average;
}
}
}

0 comments on commit 1ede3f9

Please sign in to comment.