Commit 75a1d0b1 authored by ymwang's avatar ymwang

合并成功版本

parent ee424024
...@@ -49,9 +49,9 @@ public class BisheTestMain implements ApplicationRunner { ...@@ -49,9 +49,9 @@ public class BisheTestMain implements ApplicationRunner {
//子任务依赖关系 边 //子任务依赖关系 边
int[][] link = {{0, 0, 1, 2, 3, 4, 5}, {1, 2, 3, 4, 5, 5, 6}}; int[][] link = {{0, 0, 1, 2, 3, 4, 5}, {1, 2, 3, 4, 5, 5, 6}};
//task编号 //task编号
int[] func = {2, 3, 1, 1, 3, 4, 5}; int[] func = {2, 3, 3, 1, 1, 4, 5};
//task列表 //task列表
String[] tasks = {" ","binaryProcess", "cutProcess", "greyProcess", "mergePorcess", "tailorProcess"}; String[] tasks = {" ","binaryProcess", "cutProcess", "greyProcess", "mergeProcess", "tailorProcess"};
// //功能分支表 // //功能分支表
// int[][] branch = {{1, 1},{1, 2},{1, 1},{2, 1},{1, 1}}; // int[][] branch = {{1, 1},{1, 2},{1, 1},{2, 1},{1, 1}};
...@@ -88,18 +88,32 @@ public class BisheTestMain implements ApplicationRunner { ...@@ -88,18 +88,32 @@ public class BisheTestMain implements ApplicationRunner {
String[][] route = new String[lastHop.length][lastHop[0].length]; String[][] route = new String[lastHop.length][lastHop[0].length];
for(int i =0;i<lastHop.length;i++){ for(int i =0;i<lastHop.length;i++){
for (int j=0;j<lastHop[0].length;j++){ for (int j=0;j<lastHop[0].length;j++){
route[i][j] = "sate"+lastHop[i][j]; route[i][j] = "sate"+(lastHop[i][j]+1);
if (route[i][j].equals("sate0")){ if (route[i][j].equals("sate1")){
route[i][j]="sate"+(i+1); route[i][j]="sate"+(j+1);
} }
} }
} }
boolean flad = false;
for(int i =0;i<lastHop.length;i++){
for (int j=0;j<lastHop[0].length;j++){
if (route[i][j].equals("sate"+(i+1)) && i!=j){
flad = true;
}
}
}
if (flad==false){
System.out.println("correct");
}
dataPackage.setRoute(route); dataPackage.setRoute(route);
System.out.println("exec start timestamp: " + System.currentTimeMillis()); System.out.println("exec start timestamp: " + System.currentTimeMillis());
System.out.println("========================================"); System.out.println("========================================");
System.out.println(); System.out.println();
String file_path = "passport.jpg"; String file_path = "passport.jpg";
// G:\code\cnf\
Picture picture = loadPicture(file_path); Picture picture = loadPicture(file_path);
dataPackage.setPicture(picture); dataPackage.setPicture(picture);
dataPackage.setCurrentSataHop("sate1"); dataPackage.setCurrentSataHop("sate1");
......
...@@ -18,7 +18,7 @@ public class CycleTopo { ...@@ -18,7 +18,7 @@ public class CycleTopo {
SimData sd = new SimData(); SimData sd = new SimData();
//tp.delHistory(); //tp.delHistory();
File file = new File("topusim_1.txt"); File file = new File("topusim_1.txt");
//D:\LabratoryJavaPro\codingDownload\latestCoding\ //G:\code\cnf\
List<WeiXingData> wxData = null; List<WeiXingData> wxData = null;
try { try {
wxData = wx.iniTopo(file,sd.getZhouqi()); wxData = wx.iniTopo(file,sd.getZhouqi());
......
...@@ -35,6 +35,7 @@ public class Application implements ApplicationRunner { ...@@ -35,6 +35,7 @@ public class Application implements ApplicationRunner {
} }
Picture[] pictures = new Picture[2]; Picture[] pictures = new Picture[2];
int flag = 0;
@Override @Override
public void run(ApplicationArguments args) { public void run(ApplicationArguments args) {
ServerSocket serverSocket = null; ServerSocket serverSocket = null;
...@@ -55,7 +56,8 @@ public class Application implements ApplicationRunner { ...@@ -55,7 +56,8 @@ public class Application implements ApplicationRunner {
DataPackage newDataPackage = dataPackage; DataPackage newDataPackage = dataPackage;
//得到本机路由表 //得到本机路由表
String[] route = findService.findRoute(dataPackage.getCurrentSataHop(), dataPackage.getRoute()); String[] route = findService.findRoute(dataPackage.getCurrentSataHop(), dataPackage.getRoute());
int flag = 0; System.out.println(Arrays.toString(route));
System.out.println("========================");
//判断是否为该边的终点,如果是,进行函数计算并创建一个新的数据包,转发 //判断是否为该边的终点,如果是,进行函数计算并创建一个新的数据包,转发
if (dataPackage.getCurrentSataHop().equals(dataPackage.getDestinSataHop())) { if (dataPackage.getCurrentSataHop().equals(dataPackage.getDestinSataHop())) {
LinkedList<Picture> picPara = new LinkedList<>(); LinkedList<Picture> picPara = new LinkedList<>();
...@@ -71,16 +73,20 @@ public class Application implements ApplicationRunner { ...@@ -71,16 +73,20 @@ public class Application implements ApplicationRunner {
case "greyProcess": case "greyProcess":
picPara = new greyProcess().picProcess(dataPackage.getPicture()); picPara = new greyProcess().picProcess(dataPackage.getPicture());
break; break;
case "mergePorcess": case "mergeProcess":
if (flag==0){ if (flag==0){
pictures[flag] = dataPackage.getPicture(); pictures[flag] = dataPackage.getPicture();
System.out.println("pictures1:"+pictures.length);
flag =1; flag =1;
continue; continue;
}else { }else {
pictures[flag] = dataPackage.getPicture(); pictures[flag] = dataPackage.getPicture();
System.out.println("pictures2:"+pictures.length);
flag =0; flag =0;
} }
picPara = new mergePorcess().picProcess(pictures); System.out.println("merge Operate");
System.out.println(pictures.length);
picPara = new mergeProcess().picProcess(pictures);
break; break;
case "tailorProcess": case "tailorProcess":
picPara = new tailorProcess().picProcess(dataPackage.getPicture()); picPara = new tailorProcess().picProcess(dataPackage.getPicture());
...@@ -94,9 +100,11 @@ public class Application implements ApplicationRunner { ...@@ -94,9 +100,11 @@ public class Application implements ApplicationRunner {
//找到目的地卫星数组 //找到目的地卫星数组
ArrayList<String> destinSataHops = findService.findDestinSataHops(dataPackage.getPathTable(), dataPackage.getCurrentSataHop()); ArrayList<String> destinSataHops = findService.findDestinSataHops(dataPackage.getPathTable(), dataPackage.getCurrentSataHop());
//最终卫星节点,不做任务处理,仅接受数据
if(destinSataHops.get(0).equals("nolast")){ if(destinSataHops.get(0).equals("nolast")){
System.out.println("运行完毕"); System.out.println("pathcomputing end");
break; //todo:输出到服务器指定文件夹
continue;
} }
for (String destinSataHop : destinSataHops) { for (String destinSataHop : destinSataHops) {
//设置目的地址 //设置目的地址
......
package com.pitong.business.service.picPro.picImpl;
import com.pitong.business.item.Picture;
import com.pitong.business.service.picPro.IPicProcess;
import java.io.IOException;
import java.util.LinkedList;
import static com.pitong.business.service.saveFile.Save.loadPicture;
import static com.pitong.business.service.saveFile.Save.saveToFile;
public class mergePorcess implements IPicProcess {
public static LinkedList<Picture> picPara = new LinkedList<>();
@Override
public LinkedList<Picture> picProcess(Picture... pictures) {
saveToFile(pictures[0],in_file1);
saveToFile(pictures[1],in_file2);
try {
String command = "python merge-pro.py " + in_file1 + " " + in_file2 + " " + out_file;
Process process = Runtime.getRuntime().exec(command);
process.waitFor();
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
picPara.add(loadPicture(out_file));
return picPara;
}
}
...@@ -73,7 +73,6 @@ public class WxTests { ...@@ -73,7 +73,6 @@ public class WxTests {
clusterConfig.setTopology(topo); clusterConfig.setTopology(topo);
separatedClusterConfig.setClusterConfig(clusterConfig); separatedClusterConfig.setClusterConfig(clusterConfig);
clusterConfigs.add(separatedClusterConfig); clusterConfigs.add(separatedClusterConfig);
clusterService.sendClusterConfigToEdgeNode(clusterConfigs); clusterService.sendClusterConfigToEdgeNode(clusterConfigs);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment