问题描述
对于具有原生语言(因此没有FSM生成工具)的语言的建议支持状态机开发和执行和传递消息/信号。这是为了电信,例如执行这种复杂程度的FSM。
我已经考虑过Erlang,但是会喜欢一些反馈,建议,指向教程,替代方案基于Java的框架。也许斯卡拉?
仅开源。我不是在寻找UML或正则表达式相关的解决方案。
由于这是为了实现电信协议,FSM可能是不平凡的。许多状态,许多过渡,基于信号,输入约束/守卫。动态实例化将是一个加分。切换语句是不成问题的,它很快嵌套到不可用。如果/ else,那么几乎不会更好。
我更喜欢不是依赖于图形设计;格式FSM描述应该是人类可读/可编辑/可管理的。
-
我已经决定重点对于C ++的基于Actor的解决方案
例如,Theron框架提供了一个起点,并避免在基于FSM的事件处理程序中的switch语句这个C ++ FSM模板框架看起来很有用
我同意switch语句应该是不成问题的...他们最终导致维护噩梦。你不能使用来实现您的FSM?根据实际的实际情况,您可以使用演员(如果您有多个FSM协作 - 可能的话)。演员的好处是传递消息的框架已经存在了。
使用State的一个例子是:
pre>
trait状态{
def changeState(message:Any):State
}
trait FSM extends Actor {
var state:State
def processMessage(message:Any){
state = state.changeState(message)
}
override def act ){
loop {
反应{
case m:Any => processMessage(m)
}
}
}
}
这是非常基本的代码,但是由于我不知道更多的要求,这是我能想到的最多的。国家的优势在于,每个国家都是一个班级自成一体的。
Recommendations for languages with native (so no FSM generation tools) support for state machine development and execution and passing of messages/signals. This is for telecoms, e.g implementation of FSMs of this level of complexity.
I have considered Erlang, but would love some feedback, suggestions, pointer to tutorials, alternatives, particularly Java based frameworks. Maybe Scala?
Open source only. I'm not looking for UML or regular expression related solutions.
As this is for the implementation of telecoms protocols the FSMs may be non-trivial. Many states, many transitions, signal based, input constraints/guards. Dynamic instantiation would be a plus. Switch statements are out of the question, it quickly nests to unusable. It's barely better that if/else.
I would prefer to not depend on graphical design; the format FSM description should be human readable/editable/manageable.
--
I have decided to focus on an Actor based solution for C++
For example, the Theron framework provides a starting point http://theron.ashtonmason.net/ and to avoid switch statements in the FSM based event handler this C++ FSM Template Framework looks useful http://satsky.spb.ru/articles/fsm/fsmEng.php
I agree that switch statements should be out of the question... they eventually lead to maintenance nightmares. Can't you use the State Pattern to implement your FSM? Depending on your actual implementation, you could use actors (if you have multiple FSM collaborating - hm... is that possible?). The nice thing about actors is that the framework for passing messages is already there.
An example of using State would be:
trait State {
def changeState(message: Any): State
}
trait FSM extends Actor {
var state: State
def processMessage(message: Any) {
state = state.changeState(message)
}
override def act() {
loop {
react {
case m: Any => processMessage(m)
}
}
}
}
This is very basic code, but as I don't know more of the requirements, that's the most I can think of. The advantage of State is that every state is self-contained in one class.
这篇关于有限状态机和FSM信令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!