添加触发器以过渡 [英] Add Trigger to Transition

查看:190
本文介绍了添加触发器以过渡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

怎样才能触发添加到Enterprise Architect的状态机转变的属性约束的触发器区域?引号是你如何到达那里EA内手动。



我已经试过



下面,这实际上导致触发被添加到状态机,但我需要将它链接到一个特定的过渡。可变的的statemachine 的类型是EA.Element的。

  EA.Element触发=(EA.Element) stateMachine.Elements.AddNew(触发,触发); 

国家的类型是EA.Element的。的连接的类型是EA.Connector(我试图添加触发器具体Stateflow的转变)的。所有这些似乎什么都不做。事实上,限制的似乎是一个空集,即使我添加新的项目。

  state.Constraints.AddNew(触发,触发); 
connector.Constraints.AddNew(触发,触发);
state.StateTransitions.AddNew(触发,触发);



我通过EA的帮助,没有运气挖为好。搜索功能也不是那么好了,所以这是可能的,我错过了一些东西。



有趣的信息(可能将要发生什么)



MiscData 的的的连接的类型似乎有国家流动引发的信息。据非常可靠的书(感谢你基利安先生)的 PDATA1 的的的 MiscData 的似乎是国家流动触发器的名字。但我怎么添加一个新的触发?的 MiscData 的是只读的。


解决方案

可能是不支持这种特殊的关系(从过渡到触发)由API本身。
在这种情况下,你将不得不使用一种解决方法。



首先,您需要弄清楚哪儿EA存储该信息。算出这个最简单的是从空模型开始,只创建你需要的元素(状态机,两个状态,过渡和触发),并使用EA的图形用户界面的链接。



然后检查数据库。既然你只有在有这几个因素应该很容易找到的地方EA已经存储的关系。



如果我猜我会说,这将可能被存储在t_xref表,或在一个样式或styleEx柱(或PDATA列你表示自己)别处。
然后,你需要直接使用SQL更新添加此信息到数据库或插入查询和无证Repository.Execute操作。
你可以的 github上



<预类=郎-CS prettyprint-覆盖> ///<总结> ;
///复制工作集TOT给定用户
///< /总结>
///< PARAM NAME =用户>将用户复制工作集到< /参数>
///< PARAM NAME =覆盖>如果为true,则使用相同的名称
///给定用户找到的第一个工作集将被覆盖< /参数>
公共无效copyToUser(用户用户,布尔覆盖)
{
如果(覆盖)
{
//检查是否具有相同名称的工作集已经存在
工作集workingSetToOverwrite = this.model.workingSets.Find(W =>
w.user = NULL
和!&安培; w.user.login == user.login
和;&安培; w.name == this.name);
如果(workingSetToOverwrite!= NULL)
{
workingSetToOverwrite.delete();
}
}
串insertQuery = @插入t_document(的DocID,可采用DocName,记事本,样式,ElementID,的ElementType,StrContent,BinContent,的DocType,作者,DocDate)
选择'+ Guid.NewGuid()。的ToString(b)+ @',d.DocName,d.Notes,d.Style,
d.ElementID,d.ElementType,d.StrContent,D。 BinContent,d.DocType,'+ user.fullName + @',d.DocDate从t_document D
,其中d.DocID像'+ this.ID +';
this.model.executeSQL(insertQuery);

}


How does one add a trigger to the "Properties-Constraints-Triggers" area of a state machine transition in Enterprise Architect? The quotes are how you get there manually within EA.

What I've Tried

Below, this actually results in the trigger being added to the state machine, but I need to link it to a specific transition. Variable stateMachine is of type EA.Element.

EA.Element trigger = (EA.Element)stateMachine.Elements.AddNew("trigger", "Trigger");

State is of type EA.Element. connector is of type EA.Connector (the specific StateFlow transition that I'm trying to add the trigger to). All of these appear to do absolutely nothing. In fact, Constraints seems to be an empty collection, even after I add the new items.

state.Constraints.AddNew("trigger", "Trigger");
connector.Constraints.AddNew("trigger", "Trigger");
state.StateTransitions.AddNew("trigger", "Trigger");

I've dug through the EA help with no luck as well. The search functionality isn't so good though, so it's possible I've missed something.

Interesting Information (May be on to something)

The MiscData for the Connector type seems to have the State Flow trigger information. According to a very reliable book (thank you Mr. Kilian), PDATA1 of MiscData seems to be the State Flow trigger's name. But how do I add a new trigger? MiscData is Read Only.

解决方案

This particular relation (from Transition to Trigger) is probably not supported by the API as such. In that case you'll have to use a workaround.

First you'll need to figure out where exactly EA stores this information. The easiest to figure this out is to start from an empty model, create only the elements you need (state machine, two states, a transition and a trigger) and create the link using the EA GUI.

Then inspect the database. Since you only have these few elements in there it should be quite easy to find where EA has stored the relationship.

If I had to guess I would say that it will probably be stored in the t_xref table, or else somewhere in a style or styleEx column (or the Pdata column as you indicated yourself). Then you'll need to add this info directly into the database using an SQL update or insert query and the undocumented Repository.Execute operation. You can find an example of such a thing on github:

        /// <summary>
        /// copy the workingset tot the given user
        /// </summary>
        /// <param name="user">the user to copy the working set to</param>
        /// <param name="overwrite">if true then the first workingset found with the same name
        /// for the given user will be overwritten</param>
        public void copyToUser(User user, bool overwrite)
        {
            if (overwrite)
            {
                //check if a workingset with the same name already exists
                WorkingSet workingSetToOverwrite = this.model.workingSets.Find(w => 
                                                                    w.user != null
                                                                    && w.user.login == user.login 
                                                                    && w.name == this.name);
                if (workingSetToOverwrite != null)
                {
                    workingSetToOverwrite.delete();
                }
            }
            string insertQuery = @"insert into t_document (DocID,DocName, Notes, Style,ElementID, ElementType,StrContent,BinContent,DocType,Author,DocDate )
                                select '"+Guid.NewGuid().ToString("B")+@"',d.DocName, d.Notes, d.Style,
                                d.ElementID, d.ElementType,d.StrContent,d.BinContent,d.DocType,'" + user.fullName + @"',d.DocDate from t_document d
                                where d.DocID like '"+this.ID+"'";
            this.model.executeSQL(insertQuery);

        }

这篇关于添加触发器以过渡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆