Commit Graph
59 Commits
Author SHA1 Message Date
fjc40 42ae89d20c Merge remote-tracking branch 'origin/sprint4_master' into fix_time_since_last_marker 2017-05-25 16:22:23 +12:00
fjc40 fdc03275fe Merge remote-tracking branch 'origin/sprint4_master' into fix_time_since_last_marker 2017-05-25 14:42:07 +12:00
fjc40 234748d056 Visualiser:
Fixed the issue where a boat's time since last mark started counting from when the race screen loaded.
It now starts counting when the race actually starts.
2017-05-25 14:41:51 +12:00
fjc40 1bd9fdd931 Merge remote-tracking branch 'origin/sprint4_master' into story36_boundary_fix_attempt_2
# Conflicts:
#	mock/src/main/java/seng302/Model/Race.java
Resolved.

Also reverted the change to the prestart and preparatory time, as they had gotten flipped around (prestart is > 3min to start, preparatory is < 1 min to start).
2017-05-25 14:04:06 +12:00
fjc40 f71e175f80 Mock.Race:
The race start time was current + prestart period + 1 second.
It is now current + prestart + 1 minute.
2017-05-25 13:53:27 +12:00
fjc40 8273cd5167 Merge branch 'sprint4_master' into story36_boundary_fix_attempt_2 2017-05-25 12:49:18 +12:00
fjc40 5d8380be8d Mock.Race:
Boats now tack only every 15 seconds (see tackPeriod variable).
Also doesn't attempt to calculate VMG (expensive operation) if it won't be used.
2017-05-25 12:35:57 +12:00
fjc40 7f3500202f Mock.Polars:
Moved some code into isBearingInsideInterval and isFlippedInterval utility functions.

Mock.Race:
Appear to have fixed the boats going out bounds issue at last, by fixing a few bugs, simplifying the code, and removing the boat turning speeds.
2017-05-24 19:20:30 +12:00
fjc40 824a5ed3a2 Merge branch 'boat_boundarty_fix' into story36
# Conflicts:
#	mock/src/main/java/seng302/Model/Race.java
Resolved.
2017-05-23 18:35:39 +12:00
fjc40 c8157f3476 Merge remote-tracking branch 'origin/sprint4_master' into story31.2_alternateTack
# Conflicts:
#	visualiser/src/main/java/seng302/Mock/StreamedRace.java
#	visualiser/src/main/java/seng302/Model/ResizableRaceCanvas.java
Resolved.
2017-05-22 14:26:45 +12:00
fjc40 de0abf94e0 Mock.Race:
Fixed an issue where boats sometimes sailed towards the wind when attempting to turn from bearing just under 360 degrees to a bearing just over 360 degrees.
This required an update to the boundary detection code.

Visualiser:
Appear to have fixed issue where clock didn't display correctly. Previous commit only fixed certain circumstances.

#story[873]
2017-05-20 00:18:42 +12:00
fjc40 81ed07330b Fixed the bug where the race clock wasn't visible some of the time.
It appears to have been due to a threading/javaFX thread issue with prop1.bind(prop2).
2017-05-19 21:50:14 +12:00
fjc40 c011ccb11b Did some minor refactoring of Mock module...
Added comments/documentation to most classes.
Cleaned up heaps of repeated code, dead code, redundant stuff, etc...

Mock.App:
Now actually exits the program if catastrophic errors occur, rather than silently doing nothing.

Mock.Constants:
Added race prestart and preparatory times.
Removed TEST_VELOCITIES.

Mock.PolarParser:
Now uses Bearing class.

Mock.Angle:
Now implements the Comparable interface.
Also supports .equals.

Mock.Azimuth and Bearing:
Can convert between them easily.

Mock.Boat:
Now uses Bearing, and has some helper functions like setVMG, calculateMetersTravelled(time), moveforwards(distance, time).

Mock.Marker:
Removed. This wasn't really used, and was redundant.

Mock.GPSCoordinate:
Moved a lot of helper GPS related functions into the GPSCoordinate class, instead of being scattered around the codebase.

Mock.Polars:
Polars now uses Bearing.

Mock.VMG:
Now uses Bearing.

Mock.Race:
Added a RaceStatusEnum member.
Added a RaceTypeEnum member.
Now uses Bearing/Azimuth.
Moved the message creation/sending into their own functions.
The RaceStatus updates correctly through out the race (Prestart, Warning, Preparatory, Started, Finished).

Network.RaceStatusEnum:
Added race status enum.

Network.RaceTypeEnum:
Added.
2017-05-19 16:12:47 +12:00
fjc40 a0468f251b Merge remote-tracking branch 'origin/story33-estimateTime' into sp4_s31_cleanups
# Conflicts:
#	mock/src/main/java/seng302/Model/Race.java
Resolved.
2017-05-18 23:41:17 +12:00
fjc40 aa7337dc6c Merge branch 'story31.2_alternateTack' into sp4_s31_cleanups
# Conflicts:
#	mock/src/main/java/seng302/Model/Race.java
Resolved conflict manually.
2017-05-18 17:16:06 +12:00
fjc40 d88c353213 Brought in some fixes from the story31.2_merge branch. 2017-05-18 17:03:52 +12:00
fjc40 cc54c92d5b Added Mock.Angle, Mock.Azimith, Mock.Bearing. These encapsulate the relevant angle type, to allow for better type safety (e.g., to avoid passing a bearing into an azimuth function).
Added more comments to Mock.Boat.
Moved calculateAzimuth to GPSCoordinate, from Boat.
2017-05-18 14:49:56 +12:00
fjc40 60458f0f7a Merge commit '7990ac9d2ee8c71d50606813e21a0674f442464f' into story31.2_alternateTack.
This commit (7990ac9d2e) was the commit from master that story49 was merged into.
Everything appears to be working.

# Conflicts:
#	mock/src/main/java/seng302/App.java
#	mock/src/main/java/seng302/Constants.java
#	mock/src/main/java/seng302/DataInput/RaceXMLReader.java
#	mock/src/main/java/seng302/DataInput/RegattaXMLReader.java
#	mock/src/main/java/seng302/Model/Boat.java
#	mock/src/main/java/seng302/Model/Event.java
#	mock/src/main/java/seng302/Model/Race.java
#	mock/src/test/java/seng302/Data/BoatDataTest.java
#	mock/src/test/java/seng302/Data/RaceDataTest.java
#	mock/src/test/java/seng302/Model/BoatTest.java
#	mock/src/test/java/seng302/Model/RaceXMLTest.java
#	visualiser/src/main/java/seng302/Controllers/StartController.java
#	visualiser/src/main/java/seng302/RaceXMLReader.java
Manually resolved conflicts. :(
2017-05-18 13:44:02 +12:00
fjc40 0c790c1721 Mock.Polars:
Was accidentally using testng in the PolarsTest. Changed it to junit.

#story[873]
2017-05-17 13:48:05 +12:00
fjc40 be9f19eae5 Mock.Polars:
Finished PolarsTest test cases.

Fixed a number of javadoc errors across the codebase.

#story[873]
2017-05-17 13:33:34 +12:00
fjc40 00c9cb2c83 Mock.PolarParser:
Fixed some javadoc issues
2017-05-15 18:49:57 +12:00
fjc40 656212d06d Mock.Race:
Fixed an issue in updatePositions(...) where unconstrained bounds could be passed into the calculateVMG function (e.g., lower = -182391, upper = 188221), but they need to be in the interval [0, 360).

Mock.Polars:
Added more test cases. Still working on getting the assertions correct.
Refactored and bugfixed the calculateVMG(...) function. There were a few bugs (and ugly "fixes") because we didn't bother enforcing a strict interval on the lower and upper bound angles.
Also added a few more comments to explain the function better.

#story[873]
2017-05-15 18:39:38 +12:00
fjc40 572e54b076 Mock.Race:
An alternate tacking implementation during race simulate. Doesn't handle keeping the boats in-bounds, and sometimes has issues with landing directly on a mark.
Also seems to use wrong starting velocities (from the XML file).

#story[873]
2017-05-15 14:13:36 +12:00
fjc40 f4d5df9df2 Mock.Polars:
Fixed a bug where calculateVMG was placing velocity into the VMG object, instead of speed.
Maybe fixed a bug when a bearingLowerBound which is greater than bearingUpperBound is provided.
Added another test case.

Mock.Constants:
Added knots to millimeters per second conversion factor.

Mock.Boat:
Added calculateDIstanceToNextMarker function, which returns the distance, in nautical miles, to the next mark.

Mock.Race:
Added wind direction as a race property.
Added wind speed as a race property.
The race status messages sent by Race now use Race's wind speed and direction.

#story[873]
2017-05-14 22:34:05 +12:00
fjc40 7f37dbbcb5 Mock.Race:
Usages of VMG.bearing now use the getBearing() function, as the member is now private.

#story[873]
2017-05-14 17:54:27 +12:00
fjc40 c2f487b06d Merge branch 'story31.2' of eng-git.canterbury.ac.nz:seng302-2017/team-7 into story31.2 2017-05-14 17:44:46 +12:00
fjc40 6f2c5d6c40 Mock.VMG:
made speed and bearing members private - had accidentally forget the visibility specifier.

Mock.Polars:
Added linear interpolation between speed values (e.g., if the wind speed is 15.9kn, it will interpolate between the 12kn and 16kn data). This allows for wind speeds less than 4kn (the lowest wind speed in the data file). It does not extrapolate anything for wind speeds larger than 30kn (the largest wind speed in the data file).
Also refactored some of the code into some interpolation functions.

#story[873]
2017-05-14 17:43:34 +12:00
fjc40 2dc17a688f Mock.Polars:
Fixed a bug where duplicate estimates could be added to the Polar table (this happened when the angle was 0, so the "negative" angle became 360, which is equivalent).
Now has a list of angle values for each wind speed, rather than checking if Pair<WindSpeed, WindAngle> exists in the map.
calculateVMG now uses linear interpolation between two adjacent angles (e.g., if data file contains angles 0, 30, 45, etc.. it can interpolate and find an optimal VMG angle between those, for example, 17 degrees).
Added a third test for when we provide a wind speed which is lower than any wind speed values in the Polars table. Still need to actually calculate correct VMG values by hand.

#story[873]
2017-05-14 01:12:36 +12:00
fjc40 6f9249e238 Mock.PolarParser. Fixed a bug where it would only parse the first half of each row.
Mock.Polars. addEstimate also builds up a unique list of angles from the data file, instead of dynamically generating that when calculating a VMG.
addEstimate also adds estimates with negative angles (e.g., 45deg+windSpeed+boatSpeed, and -45deg+windSpeed+boatSpeed).
calculateVMG now accepts an upper and lower bounds to the allowed VMG bearing it returns - this way you can get VMGs only within a certain angle interval (e.g., [16, 99] degrees).
Also fixed some bugs in calculateVMG where it wasn't actually using the angles and such correctly.
Improved the test case slightly, but still need to calculate correct values by hand.

#story[873]
2017-05-13 17:10:06 +12:00
fjc40 3b2f99b7d7 Fixed Polars.calculateVMG function - it was using non-existent keys in some circumstances.
#story[873] #pair[fjc40,jam339]
2017-05-11 11:58:02 +12:00
fjc40 238b97c016 Added a VMG class (has a speed and bearing).
Added the Polars.calculateVMG function, which calculates the VMG from a given wind angle, wind speed, and angle to destination. In may not be completely correct at the moment, so it's a work in progress.

#story[873]
2017-05-11 11:30:18 +12:00
fjc40 693da8a82a Removed some unneccessary code and comments from PolarParser.parse(...).
Fixed a bug where the polar parser would attempt to insert (wind speed, windspeed, windangle) instead of (windspeed, windangle, boatspeed).
Removed some unused constructors from RaceXMLReader, and fixed a bug where it wouldn't actually use the polar table correctly.
Boat's constructor now expects a Polars table.
Added some comments to the Polars class, and specified the HashMap's template parameters
Added PolarsTest - which needs to be implemented properly when the VMG calculations have been added.

#story[900]
2017-05-10 17:21:18 +12:00
fjc40 1434892b51 Merge branch 'story31.1' of eng-git.canterbury.ac.nz:seng302-2017/team-7 into story31.1 2017-05-10 15:12:06 +12:00
fjc40 aeee8ca748 Added polar data file.
Added PolarParse class - currently commented out as it depends on polar table class.

#story[900]
2017-05-10 15:11:51 +12:00
fjc40 a32775eab6 Fixed a few javadoc issues. 2017-05-08 10:59:13 +12:00
fjc40 b247244665 Did some large tidy ups, refactoring, and documenting.
Network:
Moved the Network message classes from the Utils package to the Messages package.
Renamed BoatLocationMessage to BoatLocation and BoatStatusMessage to BoatStatus to be consistent with other message classes.
Renamed the BoatStatus enumeration to BoatStatusEnum as it conflicted with BoatStatus (the message).
Moved the BoatStatusEnum and MessageType enumerations from the Utils package to the Messages/Enums package.
Changed the BoatStatusEnum and MessageType enumerations to use map look ups in the enum.fromByte(b) method - this means that there's less copy and pasted values, and the fromByte function doesn't need to be modified if new enumerations are added.
Added a sequenceNumber member to the Heartbeat class.
Added an InvalidMessageException in the package Networking/Exceptions. This is thrown when a message is read, but it is invalid in some way.
Refactored/tidied up the Networking/BinaryMessageEncoder and Decoder classes. The decoder throws InvalidMessageExceptions instead of returning null.

Visualiser:
VisualiserInput now wraps a DataInputStream around the socket. This provides the stream.readFully(buffer) function, which is a blocking read, removing the need for busy wait loops. Replaced the getBytes() function with getNextMessage() and getNextMessageBytes(). These read the next message from the socket, and return it as a message object and a byte array, respectively.
Changed the current heartbeat timeout to 10 seconds. Added some work-in-progress code to attempt to reconnect when connection is lost. It currently doesn't work. I think Fan-Wu was doing a proper implementation, however.
VisualiserInput also has a queue of received events. Currently not really used, but could be useful in the future. Events get added as they are read.
Changed VisualiserInputs main loop to use instanceOf instead of switch+case. Feedback wanted - are there any downsides to using this instanceOf method?

#story[778,782]
2017-05-08 03:29:33 +12:00
fjc40 466e22437b Visualiser. The nullptr issues relating to the XML data files appears to be fixed. Essentially, the StartController.startRaceNoScaling() function was being called as soon possible, before it was even ready - setRaceClock either hadn't been called or hadn't finished executing yet, so the StartController.raceClock member was null, causing crashes.
Also changed the while(visualiserInput.getRaceStatus() == null) loops to an if-then-return early block. They caused the program to freeze if the race data source wasn't sending any race status messages (currently, our mock doesn't send any once the race has finished).

#story[782]
2017-05-07 18:34:44 +12:00
fjc40 020c0329b0 Merge remote-tracking branch 'origin/TCPDisconnection' into submission 2017-05-07 16:55:07 +12:00
fjc40 83ce9b99d2 Mockoutput's main loop now pops messages off the message queue, rather than iterating over it like an array, and clearing it (this could have threading issues where the iteration starts (with e.g., 5 messages), as it is sending the messages another one is added, and then it ends up clearing the sent messages, and the unsent message.
Made a few quick fixes (to be tidied a bit later) to Mock.Race class. It now has this.startTime, instead of the AnimationTimers having their own starTime value. RaceStatus messages are now sent properly (still need a refactor though), so they actually send the race star time - this means that the visualizer using the mock data source displays the correct time instead of (midnight, jan 1, 1970).

Removed one of the constructors from RaceStatus - it allowed for constructing and sending essentially invalid RaceStatus messages, and simply wasn't needed.

Added a temporary title ("RaceVision - Team 7") to the visualiser - may be worth changing when we decide on a team name.

Fixed a bug with the order of operations in visualiser.StartController.countdownTimer(). Calling begin race before hiding panes caused them to never be hidden.

Mock.Event. Changed the scaleFactor to 5x for the time being - to easier testing of things like pre-race timers, countdowns, etc...

#story[778,782]
2017-05-07 15:52:34 +12:00
fjc40 01224c509a Added some comments to MockOutput. Also removed instance of RaceVisionByteEncoder, as it has no state, and the functions used are all static. 2017-05-07 14:43:11 +12:00
fjc40 3481a882de Fixed Team Oracle's boat name in mock data file.
#story[778]
2017-05-07 14:28:31 +12:00
fjc40 ecebace9f1 Merge branch 'splitIntoTwoModules' of eng-git.canterbury.ac.nz:seng302-2017/team-7 into splitIntoTwoModules 2017-04-28 11:22:05 +12:00
fjc40 873089707d Fixed the RaceStatusDecoder not deserializing BoatStatus (a subobject of RaceStatus) properly.
RaceVisionByteEncoder.heartBeat now uses a long (and grabs the low 4 bytes from it), as the streaming spec requires a 4 byte unsigned int.
#story[778] #story[782]
2017-04-28 01:32:39 +12:00
fjc40 d29c0a9439 Mock now serializes and sends Boat.xml, Race.xml, Regatta.xml, Heartbeat, BoatLocation messages.
#story[778]
2017-04-28 01:30:03 +12:00
fjc40 90f8bec415 Moved several classes from seng302.model to its own module - sharedModel (this is supposed to contain any shared data model code between mock and visualiser). Specifically, Regatta, Boat, BoatInRace, Constants, GPSCoordinate, Leg, Marker.
Updated RaceVisionByteEncoder.raceStatus to accept a Racestatus object rather than a bunch of parameters.
Added getters to RaceStatus class.
Updated some tests.
Removed Network tests from Mock, as they were duplicated.
2017-04-28 01:27:45 +12:00
fjc40 50cb31b85f Moved networking code into the network module. 2017-04-27 20:28:07 +12:00
fjc40 06d786d581 Merge remote-tracking branch 'origin/networkingTest' into splitIntoTwoModules
# Conflicts:
#	mock/src/main/java/seng302/RaceEventMessages/BoatLocationMessage.java
#             Selected copy from splitIntoTwoModules.
2017-04-27 20:02:18 +12:00
fjc40 2876eec1e4 Added some exception classes to encapsulate the internal exceptions that can occur when sending Boat/race/regatta data.
#story[778]
2017-04-25 11:24:33 +12:00
fjc40 bf5ea193af Mock App now passes an OutputStream into the "Event" class. This is where data is written to (i.e., writing data over tcp socket).
Updated Event and Race class to write to this stream, and added some TODO notes which point out where we need to properly serialize messages, when merged with networking code.
2017-04-24 21:53:51 +12:00
fjc40 2ce84e3be4 Added myself to the .mailmap file. 2017-04-24 20:23:29 +12:00
fjc40 091ee4735b Race.simulateRace() function now generates a BoatLocationMessage after updating the position of each boat. Currently we just print the message to stdout.
Added functions to convert knots (as a double) to mm/sec (as an int) to BoatLocationMessage class.
Added toString function to BoatLocationMessage class.
Added a sequence number member to the BoatInRace class.
Added Knots to meters per second conversion factor to Contants class.

#story[788]
2017-04-24 20:19:39 +12:00
fjc40andFan-Wu Yang a1ab8347ca Added Encodings to RaceVisionByteEncoder
- Added boatLocation Encoding
- Added markRounding Encoding
- Added courseWind Encoding
- Added averageWind Encoding
#story[778]
2017-04-21 16:23:48 +12:00
fjc40 149c312080 Merge branch 'isolatingMock' of eng-git.canterbury.ac.nz:seng302-2017/team-7 into isolatingMock 2017-04-21 13:38:01 +12:00
fjc40 9e1b3365bf Added helper functions to BoatLocationMessage which convert between the datatypes used by the message and datatypes used by our model. (Converts boat heading, wind angle, gps coordinate).
#story[778]
2017-04-21 13:19:49 +12:00
fjc40 ef53dee7fe Changed device type constants to bytes.
#fix #story[778]
2017-04-21 12:56:00 +12:00
fjc40 421663c145 Added device type enumerations as static ints for BoatLocationMessage.
#story[778]
2017-04-21 12:54:48 +12:00
fjc40andFan-Wu Yang a7e0ffae42 Added class to encapsulate a BoatLocationMessage.
#story[778]
2017-04-21 12:43:36 +12:00
fjc40 1a085e881d Merge branch 'isolatingMock' of eng-git.canterbury.ac.nz:seng302-2017/team-7 into isolatingMock 2017-04-21 12:26:34 +12:00
fjc40 8da67d1dbc Added class to encapsulate a BoatLocationMessage.
#story[778]
2017-04-21 12:25:57 +12:00