-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added MrModule and fixed ImageManagementModule
- Loading branch information
Showing
9 changed files
with
547 additions
and
296 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.apw.carcontrol; | ||
|
||
import javax.swing.*; | ||
import java.awt.image.BufferedImage; | ||
import java.util.ArrayList; | ||
import java.util.concurrent.Executors; | ||
import java.util.concurrent.ScheduledExecutorService; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
public class MrModule extends JFrame implements Runnable { | ||
|
||
private ScheduledExecutorService executorService; | ||
private ArrayList<Module> modules; | ||
private TrakSimControl trakSimControl; | ||
private BufferedImage displayImage; | ||
|
||
private final int width = 1920; | ||
private final int height = 1080; | ||
|
||
private MrModule() { | ||
init(); | ||
setupWindow(); | ||
createModules(); | ||
} | ||
|
||
private void init() { | ||
executorService = Executors.newSingleThreadScheduledExecutor(); | ||
displayImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); | ||
|
||
trakSimControl = new TrakSimControl(); | ||
modules = new ArrayList<>(); | ||
} | ||
|
||
private void setupWindow() { | ||
executorService.scheduleAtFixedRate(this, 0, 1000 / 60, TimeUnit.MILLISECONDS); | ||
|
||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
setSize(width, height); | ||
setVisible(true); | ||
} | ||
|
||
private void createModules() { | ||
modules.add(new ImageManagementModule(width, height)); | ||
modules.add(new SpeedControlModule()); | ||
modules.add(new SteeringModule()); | ||
} | ||
|
||
private void update() { | ||
trakSimControl.readCameraImage(); | ||
for (Module module : modules) | ||
module.update(trakSimControl); | ||
} | ||
|
||
private void paint() { | ||
for (Module module : modules) | ||
module.paint(trakSimControl, displayImage); | ||
} | ||
|
||
@Override | ||
public void run() { | ||
update(); | ||
paint(); | ||
} | ||
|
||
public static void main(String[] args) { | ||
new MrModule(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.apw.carcontrol; | ||
|
||
import java.awt.image.BufferedImage; | ||
|
||
public class SpeedControlModule implements Module { | ||
@Override | ||
public void update(CarControl control) { | ||
|
||
} | ||
|
||
@Override | ||
public void paint(CarControl control, BufferedImage image) { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.apw.carcontrol; | ||
|
||
import java.awt.image.BufferedImage; | ||
|
||
public class SteeringModule implements Module { | ||
@Override | ||
public void update(CarControl control) { | ||
|
||
} | ||
|
||
@Override | ||
public void paint(CarControl control, BufferedImage image) { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters