저는 학교 프로젝트를 진행하고 있습니다. 우리는 당신이 선박을 적재하거나 하역 할 수있는 항구를 만들고 있습니다. 컨트롤 부분은 Netbeans
이고 시뮬레이션은 JME
입니다. Netbeans에서 소켓을 통해 JME
으로 데이터를 전송합니다. JME는 Netbeans
에서 입력에 접속하는 서버 소켓을 실행 중입니다.jmonkey와 netbeans 간의 연결
예를 들어 Netbeans
은 컨테이너의 ID를 보내고 JME
에있는 크레인은 그 컨테이너를 가져 와서 해안에 올려 놓습니다.
SimpleUpdate
에서 메소드를 호출 할 수 있도록 주 (Main.count = 2
)의 수를 변경합니다. 문제는 때로는 물건을 건너 뛰는 것입니다. 또한 나는 컨테이너를 가져 오는 차량과 같은 더 많은 정보를 보낼 때 상황이 점점 악화되고 있다고 생각합니다. 이 문제를 어떻게 해결할 수 있습니까? 좋은 연결 고리를 얻을 수있는 다른 방법이 있습니까?
코드 :
넷빈즈
클라이언트 보내기
public static void run() throws Exception
{
Socket socket = new Socket("Localhost", 4321);
out = new ObjectOutputStream(socket.getOutputStream());
}
//Sent arraystring to Simulation
public void sent(String sentString){
try {
out.writeObject(sentString);
} catch (IOException ex) {
Logger.getLogger(CommunicationWithSimulatoin.class.getName()).log(Level.SEVERE, null, ex);
}
}
주요 몇 가지 물건의 예를 보낼
for(int i = Calculator.getContainersFromMaritime(); i > 1; i--)
{
Thread.sleep(50);
sim.sent("craneCon;" + i + ";");
System.out.println(i);
}
JME
리스너
public static void Listener() throws Exception {
boolean isRunning = true;
//Creates the server socket
ServerSocket sSocket = new ServerSocket(4321);
//Acception a connection from the client
Socket socket = sSocket.accept();
ObjectInputStream in = new ObjectInputStream(socket.getInputStream());
//Get the input from the client
while (isRunning) {
//Reads and prints the input
test = (String) in.readObject();
System.out.println(test);
String[] parts = receivedString.split(";");
if(parts[0].equals("ContainerPositionsMaritime"))
{
Maritime.ContainersOnBoard = receivedString.split(";");
Main.count = 0;
}
if(parts[0].equals("craneCon"))
{
int containerId = Integer.parseInt(parts[1]);
SeagoingCranes.idContainer = containerId;
Main.count = 2;
}
}
}
홈페이지 simpleupdate
public void simpleUpdate(float tpf) {
if(count == 0)
{
InitContainers();
//martime.setLocalTranslation(0, 500.0f, 0);
count = 999;
}
if(count == 2)
{
InitCrane(SeagoingCranes.idContainer);
count = 999;
}
if(martime != null)
{
martime.move(0,0,0.25f*tpf);
}
}
컨트롤이 netbeans에 있다는 것은 무엇을 의미합니까? netbeans에서 간단한 응용 프로그램을 실행하고 있다는 것을 의미합니까? –
컨트롤을 사용하면 JME 부품이 컨테이너를 가져 오거나 그 차량을 그 장소로 보내고 그 컨테이너를 픽업하는 것과 같은 조치를 취해야한다는 것을 의미합니다. –
이 질문에 답할 수는 없지만 netbeans는 IDE 일 뿐이며 프로그램의 일부는 아닙니다. 그것은 당신이 –