第一次提交
This commit is contained in:
28
nladmin-system/src/test/java/org/nl/BaseTest.java
Normal file
28
nladmin-system/src/test/java/org/nl/BaseTest.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package org.nl;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.nl.modules.wql.WQLCore;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
@RunWith(SpringRunner.class)
|
||||
public class BaseTest {
|
||||
@Before
|
||||
public void init() {
|
||||
WQLCore.defalutDBName = "eladmin";
|
||||
WQLCore.ROOT = "org.nl";
|
||||
try {
|
||||
WQLCore.init();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
public void after() {
|
||||
System.out.println("测试结束-----------------");
|
||||
}
|
||||
}
|
||||
83
nladmin-system/src/test/java/org/nl/Test2.java
Normal file
83
nladmin-system/src/test/java/org/nl/Test2.java
Normal file
@@ -0,0 +1,83 @@
|
||||
package org.nl;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import edu.wpi.rail.jrosbridge.Ros;
|
||||
import edu.wpi.rail.jrosbridge.Service;
|
||||
import edu.wpi.rail.jrosbridge.Topic;
|
||||
import edu.wpi.rail.jrosbridge.callback.TopicCallback;
|
||||
import edu.wpi.rail.jrosbridge.messages.Message;
|
||||
import edu.wpi.rail.jrosbridge.services.ServiceRequest;
|
||||
import edu.wpi.rail.jrosbridge.services.ServiceResponse;
|
||||
import jline.internal.Log;
|
||||
import org.nl.agv.unit.sendToAgvUtil;
|
||||
|
||||
public class Test2{
|
||||
public static void main231(String[] args) {
|
||||
// Ros ros = new Ros("192.168.200.63", 9290);
|
||||
try {
|
||||
Ros ros = new Ros("192.168.200.63", 9999);
|
||||
ros.connect();
|
||||
Service addTwoInts = new Service(ros, "/Service_HMIString", "lu_ps20l_msgs/Srv_HMIString");
|
||||
JSONObject json = new JSONObject();
|
||||
//IFCONFIG
|
||||
json.put("HMI_String_Input", "HMIStepOrRTPathFollow:0;18;1#");
|
||||
//日志列表
|
||||
//json.put("HMI_String_Input", "GetLogList");
|
||||
//ros请求列表
|
||||
//json.put("HMI_String_Input", "GetROSNodeList");
|
||||
//芯片温度
|
||||
//json.put("HMI_String_Input", "Temperature");
|
||||
//获取站点(刘先源写正则表达式)
|
||||
//json.put("HMI_String_Input", "GetStationFloorIndexTable");
|
||||
//获取坐标(第二个)
|
||||
//json.put("HMI_String_Input", "GetNodePointManagerTable");
|
||||
ServiceRequest request = new ServiceRequest(json.toString());
|
||||
ServiceResponse response = addTwoInts.callServiceAndWait(request);
|
||||
System.out.println(response.toString());
|
||||
ros.disconnect();
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static void main3212(String[] args) {
|
||||
//调试信息
|
||||
Ros ros = new Ros("192.168.200.63", 9999);
|
||||
ros.connect();
|
||||
while(true) {
|
||||
Topic echoBack = new Topic(ros, "/Topic_Display_State", "lu_ps20l_msgs/Msg_DisplayState");
|
||||
echoBack.subscribe(new TopicCallback(){
|
||||
@Override
|
||||
public void handleMessage(Message message) {
|
||||
JSONObject jo = JSONObject.parseObject(message.toString());
|
||||
System.out.println(message.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
ServiceResponse response = sendToAgvUtil.send("GetStationFloorIndexTable");
|
||||
String result_info = response.toString();
|
||||
String a = JSONObject.parseObject(response.toString()).getString("ROS_String_Output");
|
||||
String[] split = a.split("\\n");
|
||||
JSONObject json = new JSONObject();
|
||||
for(int i = 0; i < split.length; i++) {
|
||||
String row = split[i];
|
||||
String[] rowArr = row.split("\\s+");
|
||||
json.put(rowArr[3], rowArr[4].contains("<") ? "" : rowArr[4]);
|
||||
}
|
||||
JSONArray arr = new JSONArray();
|
||||
for(Object key : json.keySet()) {
|
||||
String value = (String) json.get(key);
|
||||
System.out.println("Key = " + key + ", Value = " + value);
|
||||
JSONObject row = new JSONObject();
|
||||
row.put("point_code", key);
|
||||
row.put("point_name", value);
|
||||
arr.add(row);
|
||||
}
|
||||
System.out.println(arr);
|
||||
}
|
||||
}
|
||||
53
nladmin-system/src/test/java/org/nl/Test3.java
Normal file
53
nladmin-system/src/test/java/org/nl/Test3.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package org.nl;
|
||||
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import jline.internal.Log;
|
||||
|
||||
public class Test3{
|
||||
public static void main67(String[] args) {
|
||||
try {
|
||||
String url = "http://192.168.200.63:9999";
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("msg_js_can", "0x101|0x10,0x01,0x04,0x00,0x00,0x00,0x00,0x00");
|
||||
json.put("srv_HMIString", "GetIP");
|
||||
String resultMsg = HttpRequest.post(url).body(String.valueOf(json)).execute().body();
|
||||
JSONObject result = JSONObject.parseObject(resultMsg);
|
||||
System.out.println(result);
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static void main231(String[] args) {
|
||||
String url = "http://192.168.200.63:9999";
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("msg_js_can", "0x101|0x10,0x01,0x04,0x00,0x01,0x00,0x00,0x00");
|
||||
// json.put("srv_HMIString", "GetIP");
|
||||
while(true) {
|
||||
String resultMsg = HttpRequest.post(url).body(String.valueOf(json)).execute().body();
|
||||
// JSONObject result = JSONObject.fromObject(resultMsg);
|
||||
System.out.println(resultMsg);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String url = "http://192.168.200.63:9999";
|
||||
String result1 = HttpUtil.get(url);
|
||||
System.out.println(result1);
|
||||
JSONObject json = JSONObject.parseObject(result1);
|
||||
JSONObject jo = JSONObject.parseObject(json.getString("Msg_DisplayState"));
|
||||
System.out.println(jo.parseObject("AGV_ID"));
|
||||
System.out.println(jo.getJSONObject("header").getJSONObject("stamp").parseObject("sec"));
|
||||
}
|
||||
|
||||
public static void main1233(String[] args) {
|
||||
int a = 258;
|
||||
if((258 >> 8) % 2 == 1) {
|
||||
System.out.println("有异常");
|
||||
}
|
||||
System.out.println("测试完毕");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user