有什么方法可以state table
从 IBM RhapsodyStatechart
图表中获取?
打开生成的.rpy
文件并尝试手动生成一个不是一个好主意......
有什么方法可以state table
从 IBM RhapsodyStatechart
图表中获取?
打开生成的.rpy
文件并尝试手动生成一个不是一个好主意......
是的,可以以表格格式查看状态图。您需要将状态图属性更改
StatechartDiagram::StateDiagram::DefaultView
为Tabular view
.
此功能从Rhapsody V7.5开始可用。
详情:这里
您可以利用 Rhapsody java api 并编写代码片段来获取任何给定状态图的元素的详细信息。提供了为状态图元素创建表格矩阵的示例代码。
import com.telelogic.rhapsody.core.IRPApplication;
import com.telelogic.rhapsody.core.IRPModelElement;
import com.telelogic.rhapsody.core.IRPProject;
import com.telelogic.rhapsody.core.IRPStateVertex;
import com.telelogic.rhapsody.core.IRPStatechart;
import com.telelogic.rhapsody.core.IRPTransition;
import com.telelogic.rhapsody.core.RhapsodyAppServer;
public class Statechart_Info
{
public static void main(String[] args)
{
IRPApplication app = RhapsodyAppServer.getActiveRhapsodyApplication();
IRPProject prj = app.activeProject();
IRPModelElement moEle = app.getSelectedElement();
IRPStatechart mySC = (IRPStatechart) moEle;
String defTran=null;
for (Object obj : mySC.getNestedElementsRecursive().toList())
{
if(obj instanceof IRPTransition)
{
IRPTransition myTran = (IRPTransition) obj;
if(myTran.isDefaultTransition()==1)
defTran = myTran.getName();
}
}
for (Object obj : mySC.getNestedElementsRecursive().toList())
{
if(obj instanceof IRPStateVertex)
{
IRPStateVertex mySV = (IRPStateVertex) obj;
System.out.println("State: " + mySV.getName());
System.out.println("\nIncoming Transition(s) to " + mySV.getName());
for(Object obj1 : mySV.getInTransitions().toList())
{
IRPTransition myTran = (IRPTransition) obj1;
System.out.println("Transition: " + myTran.getName());
}
System.out.println("\nOutgoing Transition(s) from " + mySV.getName());
for(Object obj1 : mySV.getOutTransitions().toList())
{
IRPTransition myTran = (IRPTransition) obj1;
System.out.println("Transition: " + myTran.getName());
}
if(mySV.getName().equals("ROOT"))
System.out.println("Transition: " + defTran);
System.out.println("\n");
}
}
}
}