Compare commits
3 Commits
phase1-gui
...
master
Author | SHA1 | Date | |
---|---|---|---|
e3e7bf5ccd | |||
b386665e66 | |||
5e1ff6451c |
14
package.sh
Executable file
14
package.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
GIT=$(command -v git)
|
||||
HEAD=$(command -v head)
|
||||
CUT=$(command -v cut)
|
||||
|
||||
JAR_ARTIFACT="out/artifacts/Hajj_simulation_jar/Hajj-simulation.jar"
|
||||
|
||||
if [ -z $"GIT" ] || [ -z $"HEAD" ] || [ -z $"CUT" ]; then
|
||||
echo "Tools missing"
|
||||
exit 1
|
||||
else
|
||||
tar -cvf Hajj-Simulation-$(git log | head -n1 | cut -d' ' -f2).tar.gz $JAR_ARTIFACT run.sh
|
||||
fi
|
9
run.sh
Executable file
9
run.sh
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
jav=$(command -v java)
|
||||
|
||||
if [ -z "$jav" ]; then
|
||||
>&2 echo "Can't find java installation"
|
||||
else
|
||||
java -jar out/artifacts/Hajj_simulation_jar/Hajj-simulation.jar
|
||||
fi
|
@ -32,6 +32,7 @@ public class MakkahCity {
|
||||
private static final Thread t = new Thread(inputListener,"InputThread-Makkah");
|
||||
private static boolean isAllRoutSet;
|
||||
private static final DataManeger dataManeger = new DataManeger();
|
||||
private static volatile boolean done_flag;
|
||||
//GUI
|
||||
private static boolean exit_flag;
|
||||
private static boolean pause_flag;
|
||||
@ -65,6 +66,7 @@ public class MakkahCity {
|
||||
generateCamps(District.ALMANSOOR, (int)getRandom(1600, 1800));
|
||||
generateCamps(District.ALHIJRA, (int)getRandom(1400, 1600));
|
||||
|
||||
Collections.shuffle(listOfCampaigns);
|
||||
|
||||
fillBusesToList();
|
||||
|
||||
@ -211,7 +213,10 @@ public class MakkahCity {
|
||||
btnExit.setFont(new Font("Rockwell", Font.PLAIN, 16));
|
||||
btnExit.setForeground(Color.white);
|
||||
btnExit.setBounds(888, 623, 166, 29);
|
||||
btnExit.addActionListener(actionEvent -> exit_flag = true);
|
||||
btnExit.addActionListener(actionEvent -> {
|
||||
if (pause_flag || done_flag) System.exit(0);
|
||||
else exit_flag = true;
|
||||
});
|
||||
|
||||
btnPause = new JButton("Pause");
|
||||
btnPause.setBackground(new Color(9,9,9));
|
||||
@ -416,11 +421,14 @@ public class MakkahCity {
|
||||
makkahFrame.setVisible(true);
|
||||
|
||||
//Set Routes for Campaigns
|
||||
setRoutesForCampaigns(Mashier.ARAFAT);
|
||||
while(!firstDayTimeMan.isEnded()) {
|
||||
checkInput();
|
||||
|
||||
|
||||
if (!isAllRoutSet) {
|
||||
isAllRoutSet = true;
|
||||
setRoutesForCampaigns(Mashier.ARAFAT);
|
||||
}
|
||||
//Start of Every hour
|
||||
if (firstDayTimeMan.getCurrentCalendar().get(Calendar.MINUTE) == 0){
|
||||
System.out.println("\n\n" + getStreetsReport());
|
||||
updateStreetFrame();
|
||||
@ -436,6 +444,7 @@ public class MakkahCity {
|
||||
Route route = vehicle.getRoute();
|
||||
double currentLocation = vehicle.getCurrentLocation();
|
||||
if (vehicle.getCurrentStreet() == null &&
|
||||
firstDayTimeMan.getCurrentCalendar().get(Calendar.MINUTE) % 2 == 0 &&
|
||||
route.getStreets()[0].capcityPoint(0,1000) < 1) {
|
||||
vehicle.setCurrentStreet(route.getStreets()[0]);
|
||||
}
|
||||
@ -459,10 +468,12 @@ public class MakkahCity {
|
||||
if (isAllArrived() && allArrivedToArafatTime == null) allArrivedToArafatTime = (Date)currenttimeManager.getCurrentTime().clone();
|
||||
firstDayTimeMan.step(Calendar.MINUTE, 1);
|
||||
lblDate.setText(currenttimeManager.getCurrentTime().toString());
|
||||
//lblArrivedToArafatTime.setText(getDistTimeForLbl());
|
||||
}
|
||||
|
||||
currenttimeManager = lastDayTimeMan;
|
||||
System.out.println("\n***************FINSHIED ARAFAT DAY***************");
|
||||
//Collections.shuffle(listOfVehicles);
|
||||
isAllRoutSet = false;
|
||||
for (Vehicle vehicle : listOfVehicles) {
|
||||
vehicle.setCurrentStreet(null);
|
||||
@ -473,10 +484,13 @@ public class MakkahCity {
|
||||
|
||||
System.out.println("***************STARTING LAST DAY***************");
|
||||
setRoutesForCampaigns(Mashier.MINA);
|
||||
setRoutesForCampaigns(Mashier.MINA);
|
||||
while(!lastDayTimeMan.isEnded()) {
|
||||
checkInput();
|
||||
|
||||
if (!isAllRoutSet) {
|
||||
isAllRoutSet = true;
|
||||
setRoutesForCampaigns(Mashier.MINA);
|
||||
}
|
||||
|
||||
//Start of Every hour
|
||||
if (lastDayTimeMan.getCurrentCalendar().get(Calendar.MINUTE) == 0){
|
||||
@ -517,8 +531,10 @@ public class MakkahCity {
|
||||
if (isAllArrived() && allArrivedToHotelsTime == null) allArrivedToHotelsTime = (Date)currenttimeManager.getCurrentTime().clone();
|
||||
lastDayTimeMan.step(Calendar.MINUTE, 1);
|
||||
lblDate.setText(currenttimeManager.getCurrentTime().toString());
|
||||
//lblArrivedToHotelsTime.setText(getDistTimeForLbl());
|
||||
}
|
||||
//When done show menu to analyze. Exit from menu too.
|
||||
done_flag = true;
|
||||
inputListener.pause();
|
||||
startMenu();
|
||||
}
|
||||
@ -724,7 +740,7 @@ public class MakkahCity {
|
||||
for (Campaign camp : listOfCampaigns){
|
||||
if(camp.getVehicles().get(0).getCurrentStreet() == null) {
|
||||
isAllRoutSet = false;
|
||||
camp.setRoute(getShortestRoute(camp, mashier));
|
||||
camp.setRoute(getBestRoute(camp, mashier));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -878,7 +894,8 @@ public class MakkahCity {
|
||||
private static void addCivilVehicleNoise() {
|
||||
|
||||
for (Street street: stdStreet) {
|
||||
|
||||
if (street.getPercentRemainingCapacity() >= 80)
|
||||
continue;
|
||||
|
||||
int numOfSedan = (int)getRandom(10,15);
|
||||
int numOfSUV = (int)getRandom(5,9);
|
||||
@ -948,6 +965,7 @@ public class MakkahCity {
|
||||
*/
|
||||
|
||||
private static Route getBestRoute(Campaign campaign , Mashier mashier) {
|
||||
//ArrayList<Route> routes = (ArrayList<Route>) Arrays.asList(getRoutesToDistrict(campaign.getHotelDistrict()));
|
||||
Route[] routes = getRoutesToDistrict(campaign.getHotelDistrict());
|
||||
routes = sortRoutes(routes);
|
||||
for (Route r : routes) {
|
||||
|
Loading…
Reference in New Issue
Block a user