[openrtm-commit:01184] r494 - branches/work_ForRTMSafety/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor

openrtm @ openrtm.org openrtm @ openrtm.org
2014年 1月 25日 (土) 11:46:25 JST


Author: win-ei
Date: 2014-01-25 11:46:24 +0900 (Sat, 25 Jan 2014)
New Revision: 494

Modified:
   branches/work_ForRTMSafety/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/AbstractSystemDiagramEditor.java
Log:
Daily work.

Modified: branches/work_ForRTMSafety/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/AbstractSystemDiagramEditor.java
===================================================================
--- branches/work_ForRTMSafety/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/AbstractSystemDiagramEditor.java	2014-01-25 01:01:03 UTC (rev 493)
+++ branches/work_ForRTMSafety/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/editor/AbstractSystemDiagramEditor.java	2014-01-25 02:46:24 UTC (rev 494)
@@ -710,6 +710,14 @@
 					//DataPortConctTbl.c
 					//
 					{
+					Map<String, Object> contextMap = new HashMap<String, Object>();
+					contextMap.put("tablepath", tablepath);
+					contextMap.put("template", TEMPLATE_PATH);
+					contextMap.put("profile", profile);
+					generateDataPortConctTbl(contextMap);
+					}
+					{
+						/*
 					String template = TEMPLATE_PATH + "/" +"DataPortConctTbl.c.vsl";
 					ClassLoader cl = Thread.currentThread().getContextClassLoader();
 					InputStream ins = cl.getResourceAsStream(template);
@@ -736,11 +744,20 @@
 					pw.close();
 
 					//System.out.println(gr.getCode());
+					*/
 					}
 					//
 					//DataPortCreateTbl.c.vsl
 					//
 					{
+					Map<String, Object> contextMap = new HashMap<String, Object>();
+					contextMap.put("tablepath", tablepath);
+					contextMap.put("template", TEMPLATE_PATH);
+					contextMap.put("profile", profile);
+					generateDataPortCreateTbl(contextMap);
+					}
+					{
+						/*
 					String template = TEMPLATE_PATH + "/" +"DataPortCreateTbl.c.vsl";
 					ClassLoader cl = Thread.currentThread().getContextClassLoader();
 					InputStream ins = cl.getResourceAsStream(template);
@@ -765,11 +782,20 @@
 					pw.println(gr.getCode());
 					pw.close();
 					//System.out.println(gr.getCode());
+					*/
 					}
 					//
 					//RtcCreateTbl.c
 					//
 					{
+					Map<String, Object> contextMap = new HashMap<String, Object>();
+					contextMap.put("tablepath", tablepath);
+					contextMap.put("template", TEMPLATE_PATH);
+					contextMap.put("profile", profile);
+					generateRtcCreateTbl(contextMap);
+					}
+					{
+						/*
 					String template = TEMPLATE_PATH + "/" +"RtcCreateTbl.c.vsl";
 					ClassLoader cl = Thread.currentThread().getContextClassLoader();
 					InputStream ins = cl.getResourceAsStream(template);
@@ -793,6 +819,7 @@
 					pw.println(gr.getCode());
 					pw.close();
 					//System.out.println(gr.getCode());
+					*/
 					}
 					//
 					//RtcEcCreateTbl.c
@@ -1370,18 +1397,18 @@
 	/**
 	 * Creates  DataPortConctTbl.c
 	 */
-	/*
-	public generateDataPortConctTbl()
+	public void generateDataPortConctTbl(Map<String, Object> contextMap)
 	{
-		String template = TEMPLATE_PATH + "/" +"DataPortConctTbl.c.vsl";
+		try
+		{
+		String template = contextMap.get("template") + "/" +"DataPortConctTbl.c.vsl";
 		ClassLoader cl = Thread.currentThread().getContextClassLoader();
 		InputStream ins = cl.getResourceAsStream(template);
+		String tablepath = (String)contextMap.get("tablepath");
 		String dataPortContct = tablepath+File.separator+"DataPortConctTbl.c";
-		Map<String, Object> contextMap = new HashMap<String, Object>();
-		contextMap.put("template", TEMPLATE_PATH);
+		RtsProfileExt profile = (RtsProfileExt)contextMap.get("profile");
 		List<DataportConnector> conns = profile.getDataPortConnectors();
-		int ic = 0;
-		Map connsMap = new HashMap();
+		Map<String, Object> connsMap = new HashMap();
 		for(DataportConnector conn : conns)
 		{
 			connsMap.put(conn.getTargetDataPort().getPortName().replace(".", "_"),conn.getSourceDataPort().getPortName().replace(".", "_"));
@@ -1400,9 +1427,94 @@
 		pw.close();
 
 		//System.out.println(gr.getCode());
+		}
+		catch(Exception e)
+		{
+			e.printStackTrace();
+		}
 	}
-	*/
+	/**
+	 * Creates DataPortCreateTbl.c
+	 */
+	public void generateDataPortCreateTbl(Map<String, Object> contextMap)
+	{
+		try
+		{
+		String template = contextMap.get("template") + "/" +"DataPortCreateTbl.c.vsl";
+		ClassLoader cl = Thread.currentThread().getContextClassLoader();
+		InputStream ins = cl.getResourceAsStream(template);
+		String tablepath = (String)contextMap.get("tablepath");
+		String dataPortContct = tablepath+File.separator+"DataPortCreateTbl.c";
+		RtsProfileExt profile = (RtsProfileExt)contextMap.get("profile");
+		List<org.openrtp.namespaces.rts.version02.Component> componetns = profile.getComponents();
+		ArrayList<String> complist = new ArrayList<String>();
+		for(org.openrtp.namespaces.rts.version02.Component comp :componetns)
+		{
+			if(!comp.getDataPorts().isEmpty())
+			{
+				complist.add(comp.getInstanceName()); 
+			}
+		}
+		contextMap.put("ports", complist);
+		GeneratedResult gr = TemplateUtil.createGeneratedResult(ins, contextMap, dataPortContct);
+		if (ins != null) 
+		{
+			ins.close();
+		}			
+		File targetFile = new File(dataPortContct);
+		FileWriter filewriter = new FileWriter(targetFile);
+		BufferedWriter bw = new BufferedWriter(filewriter);
+		PrintWriter pw = new PrintWriter(bw);
+		pw.println(gr.getCode());
+		pw.close();
+		//System.out.println(gr.getCode());
+		}
+		catch(Exception e)
+		{
+			e.printStackTrace();
+		}
+	}
+	/**
+	 * Creates RtcCreateTbl.c
+	 */
+	public void generateRtcCreateTbl(Map<String, Object> contextMap)
+	{
+		try
+		{
+		String template = contextMap.get("template") + "/" +"RtcCreateTbl.c.vsl";
+		ClassLoader cl = Thread.currentThread().getContextClassLoader();
+		InputStream ins = cl.getResourceAsStream(template);
+		String tablepath = (String)contextMap.get("tablepath");
+		String dataPortContct = tablepath+File.separator+"RtcCreateTbl.c";
+		RtsProfileExt profile = (RtsProfileExt)contextMap.get("profile");
+		List<org.openrtp.namespaces.rts.version02.Component> componetns = profile.getComponents();
+		ArrayList<String> complist = new ArrayList<String>();
+		for(org.openrtp.namespaces.rts.version02.Component comp :componetns)
+		{
+			String[] strary = comp.getId().split(":");
+			complist.add(strary[3]); 
+		}
+		contextMap.put("comps", complist);
+		GeneratedResult gr = TemplateUtil.createGeneratedResult(ins, contextMap, dataPortContct);
+		if (ins != null) 
+		{
+			ins.close();
+		}			
+		File targetFile = new File(dataPortContct);
+		FileWriter filewriter = new FileWriter(targetFile);
+		BufferedWriter bw = new BufferedWriter(filewriter);
+		PrintWriter pw = new PrintWriter(bw);
+		pw.println(gr.getCode());
+		pw.close();
+		//System.out.println(gr.getCode());
+		}
+		catch(Exception e)
+		{
+			e.printStackTrace();
+		}
+	}
 
+
 //	private void debugPrint(EditPart part, int size) {
 //		Object model = part.getModel();
 //		if (model instanceof Port) debugPrint((Port)model);



More information about the openrtm-commit mailing list