First commit
adding aas protocol
This commit is contained in:
@@ -9,6 +9,8 @@ import java.net.Socket;
|
||||
public class AASMini {
|
||||
private final String targetIP;
|
||||
private final int targetPort;
|
||||
private final int msgId = 15;
|
||||
private final String zones = "Zone_1,Zone_2,Zone_3,Zone_4";
|
||||
private Socket socket;
|
||||
|
||||
/**
|
||||
@@ -16,11 +18,13 @@ public class AASMini {
|
||||
* @param ip IP Address of the AAS Mini
|
||||
* @param port Port of the AAS Mini
|
||||
*/
|
||||
public AASMini(String ip , int port){
|
||||
public AASMini(String ip , int port,){
|
||||
this.targetIP = ip;
|
||||
this.targetPort = port;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the AAS Mini is connected
|
||||
* @return true if connected, false otherwise
|
||||
@@ -67,6 +71,22 @@ public class AASMini {
|
||||
}
|
||||
|
||||
//TODO protocol untuk kirim data ke AAS Mini
|
||||
private void SendPlatNoToAAS(String platNo){
|
||||
|
||||
String protocol = "BROADCAST;"+msgId+";IND;$PLATNOMOR$="+platNo+";"+zones;
|
||||
byte[] data = protocol.getBytes();
|
||||
byte[] rplyData = SendAndReceive(data);
|
||||
String rplyInStr = rplyData.toString();
|
||||
String[] rply = rplyInStr.split(";");
|
||||
if (rply.length ==2){
|
||||
if (rply[0].equals("BROADCAST")){
|
||||
if (rply[1].equals("OK")){
|
||||
System.out.println("Success sending data to AAS!");
|
||||
}else System.out.println("Failed sending data to AAS!");
|
||||
}else System.out.println("Wrong format answer!");
|
||||
}else System.out.println("Wrong size answer");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send data to AAS Mini and receive response
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import AASMini.AASMini;
|
||||
import ProtegeGX.ProtegeGX;
|
||||
|
||||
public class Main {
|
||||
private static AASMini aas;
|
||||
private static ProtegeGX protegeGX;
|
||||
|
||||
private static String aasIP = "192.168.10.10";
|
||||
private static int aasPort = 8080;
|
||||
public static void main(String[] args) {
|
||||
@@ -9,10 +12,14 @@ public class Main {
|
||||
public void run() {
|
||||
System.out.println("Shutting down...");
|
||||
if (aas!=null) aas.Disconnect();
|
||||
if (protegeGX!=null) protegeGX.Disconnect();
|
||||
}
|
||||
});
|
||||
|
||||
System.out.println("Protege to AAS Mini Connector");
|
||||
|
||||
protegeGX = new ProtegeGX();
|
||||
|
||||
aas = new AASMini(aasIP, aasPort);
|
||||
aas.Connect();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
package ProtegeGX;
|
||||
|
||||
public class ProtegeGX {
|
||||
public ProtegeGX(){
|
||||
System.out.println("ProtegeGX Constructor");
|
||||
//TODO belum ada codingan, tunggu apache cxf jar nya
|
||||
}
|
||||
|
||||
public void Disconnect(){
|
||||
//TODO belum ada codingan, tunggu apache cxf jar nya
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user