[译]StateWizard VC ++加载项和带有源代码的引擎
By robot-v1.0
本文链接 https://www.kyfws.com/applications/the-statewizard-vc-add-in-and-engine-with-source-c-zh/
版权声明 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
- 17 分钟阅读 - 8350 个词 阅读量 0[译]StateWizard VC ++加载项和带有源代码的引擎
原文地址:https://www.codeproject.com/Articles/14413/The-StateWizard-VC-Add-in-and-Engine-with-Source-C
原文作者:Alex_Intw
译文由本站 robot-v1.0 翻译
前言
A cross-platform state-oriented application framework and a ClassWizard-like round-trip UML dynamic modeling/development tool that runs in popular IDEs. Aims at providing concurrent, distributed, and real-time application development tools for Win32/Linux
跨平台的面向状态的应用程序框架,以及可在流行的IDE中运行的类ClassWizard往返UML动态建模/开发工具.旨在为Win32/Linux提供并发,分布式和实时应用程序开发工具
- 下载状态机引擎源文件-141.13 KB(Download the state machine engine source files - 141.13 KB)
- 下载StateWizard Standard for VS2003外接程序源代码-318.92 KB(Download the StateWizard Standard for VS2003 add-in source code - 318.92 KB)
- 下载StateWizard Standard for VS2005外接程序源代码-325.61 KB(Download the StateWizard Standard for VS2005 add-in source code - 325.61 KB)
- StateWizard标准安装(The StateWizard Standard Installation)
- 在主页上快速下载最新版本(Quick download the latest version at home page)
介绍(Introduction)
在软件系统越来越复杂,并发且面向实时的环境中,建模语言和工具的选择成为许多项目成功的关键.(In an environment where software systems are more and more complex, concurrent, and real-time oriented, the choice of modeling languages and tools becomes the success key for many projects.)
本文介绍了一个用于Win32/Linux的,使用标准C ++/C的跨平台,面向状态的应用程序框架,以及一个类似于ClassWizard的往返UML动态建模/开发工具:StateWizard.(This article introduces a cross-platform state-oriented application framework using standard C++/C for Win32/Linux and a ClassWizard-like round-trip UML dynamic modeling / development tool: StateWizard.)
兴趣点(Points of Interest)
下表列出了为该项目编写的各种技术:(The following table lists a wide range of techniques written for this project:)
- 使用DTE的VS2003或VS2005的Visual Studio外接程序开发(Visual Studio add-in development for VS2003 or VS2005 using DTE)
- COM开发(COM development)
- 异步函数调用(Asynchronous function call)
- 跨平台OS相关的库(Cross-platform OS-related library)
- 产品质量状态机引擎(Product quality state machine engines)
- Win32地图文件分析(Win32 map file analysis)
有什么新功能?(What is New?)
UML:标准(UML: The Standard)
统一建模语言(The Unified Modeling Language)TM值(TM)-UML-是OMG最常用的规范,也是世界建模应用程序,行为和体系结构以及业务流程和数据结构的方式.[1](- UML - is OMG’s most-used specification and the way the world models not only application structure, behavior, and architecture, but also business processes and data structures.[1])
UML动态视图用于表示和建模系统随时间的行为,通过状态机,序列和活动图来表示.(UML dynamic views are used to express and model the behavior of a system over time, presented through state machines, sequences, and activity diagrams.)
状态机图捕获软件系统的行为.状态机可用于对类,子系统或整个应用程序的行为进行建模.它们还提供了一种通过协议或基于事件的系统对与外部实体的通信进行建模的出色方法.(State machine diagrams capture the behavior of a software system. State machines can be used to model the behavior of a class, subsystem, or an entire application. They also provide an excellent way of modeling communications with external entities via a protocol or event-based system.)
顺序图用于显示系统内用户,屏幕,对象和实体之间的交互.它们提供了对象之间随时间传递的消息的顺序映射.(Sequence diagrams are used to display the interaction between users, screens, objects, and entities within the system. They provide a sequential map of messages passing between objects over time.)
为什么选择UML StateWizard?(Why UML StateWizard?)
您可能会问,为什么已经有许多好的UML工具(例如Rational Rose,VisualState等),为什么要使用UML StateWizard.我们的答案是:(You may ask why UML StateWizard, while there are already many good UML tools such as Rational Rose, VisualState, and others. Our answer is:)
- StateWizard是类似于ClassWizard的简单高效的IDE集成工具(StateWizard is a ClassWizard-like, simple and efficient IDE integrated tool)
- StateWizard是功能齐全的UML工具[2](StateWizard is a full featured UML tool [2])
- StateWizard基于完善的概念,实现选择和数据结构(StateWizard is based on sound and optimized notions, implementation choices, and data structures)
- StateWizard具有许多有用的"杂项"功能(StateWizard has many useful “miscellaneous” features)
1.一种类似于ClassWizard的简单高效的IDE集成工具(1. A ClassWizard-like, Simple and Efficient IDE Integrated Tool)
在开发StateWizard时,我们谨记要提供一个直观且易于使用的解决方案:(When developing the StateWizard, we kept in mind to offer an intuitive and easy to use solution:)
-
就像Microsoft Visual C ++ ClassWizard一样,StateWizard在集成开发环境中运行.无需在设计/开发工具之间切换,而许多UML建模工具可作为独立应用程序运行.(Just like Microsoft Visual C++ ClassWizard, StateWizard runs inside the integrated development environment. No need to switch between tools for design/development, while many UML modeling tools run as standalone applications.)
-
没有中间的建模文件,可以直接从源代码中的一组特定宏和标志构建UML图.(No intermediate modeling file, directly build UML diagrams from a set of specific macros and flags in the source code.)
-
StateWizard使用基于状态机的框架快速构建应用程序.它直接在独立于平台的标准C/C ++中高效地对状态图进行编码.(StateWizard rapidly builds applications with state machine based frameworks. It efficiently codes state charts directly in platform-independent standard C/C++.)
-
StateWizard为嵌入式系统开发提供状态跟踪,仿真和调试.(StateWizard provides state tracking, simulation, and debugging for embedded system development.) UML状态向导支持以下IDE:(The UML StateWizard supports the following IDEs:)
-
Visual C ++ 6.0(Visual C++ 6.0)
-
嵌入式Visual C ++ 4.0(eMbedded Visual C++ 4.0)
-
Visual Studio 2003(Visual Studio 2003)
-
Visual Studio 2005(Visual Studio 2005)
2.功能齐全的UML工具(2. A Full-featured UML Tool)
一些CASE工具允许用户根据一组规范生成代码.但是,有时生成的代码可能不是很有用,因为它可能庞大且难以为设计人员所理解. StateWizard提供了以下解决方案:(Some CASE tools allow the user to generate code from a set of specifications. Nevertheless, sometimes the generated code might not be very useful as it may be bulky and hard to understand for the designer. The StateWizard presents this solution:)
- UML图支持:StateWizard支持九个组成UML状态机的图.它支持状态树和状态图绘图.(UML diagram support: The StateWizard supports nine diagrams that make up UML state machines. It supports state tree and state chart drawing.)
- 正向工程:StateWizard UML工具的用途不仅仅限于图示的图形表示.由于该图定义的系统结构已由开发人员转换为实际的源代码,因此StateWizard通过在状态机框架中使用残存的方法生成源代码来桥接此步骤.开发人员可以使用此存根代码并填写实际代码.自动生成源代码的这一特性称为正向工程.(Forward engineering: The StateWizard UML tool does not have its use limited to just a pictorial depiction of diagrams. Because the structure of the system defined by the diagram is translated by a developer into actual source code, the StateWizard bridges this step by generating the source code in a state machine framework with the methods stubbed out. Developers can take up this stub code and fill in with the actual code. This characteristic of automating the generation of source code is called forward engineering.)
- 逆向工程:逆向工程与正向工程完全相反.在逆向工程中,StateWizard加载应用程序/系统的所有文件,识别应用程序之间的状态关系,并从本质上重建整个状态机结构以及所有关系.(Reverse engineering: Reverse engineering is exactly the opposite of forward engineering. In reverse engineering, StateWizard loads all the files of the application/system, identifies state relationships among applications, and essentially reconstructs the entire state machine structure along with all the relationships.)
- 往返工程:除正向工程和反向工程外,另一个有用的功能是往返工程.正向和反向工程本质上是一次性的活动,需要输入并生成所需的输出.往返工程扩展了这些功能.软件设计中的一个重要规则是没有设计可以保持不变.小型系统和大型系统都是如此.在开发过程中,UML模型中定义的设计结构会进行更改,以将实现过程中可能未曾想到的物理差异纳入实现中.保持系统设计与源代码更改同步变得非常困难.往返工程功能使UML工具能够将模型与应用程序代码中的更改同步. StateWizard倾向于根据代码部分中的修改来增强UML工具的实时同步其模型的能力.例如,开发人员可以在状态图上直观地进行拖放操作,随后源代码也将发生变化.相反,开发人员可以直接纠正代码部分,而修改将自动显示在状态图中.它导致StateWizard充当状态图和源代码之间的桥梁.(Round-trip engineering: Another useful feature apart from forward and reverse engineering is round-trip engineering. Forward and reverse engineering are essentially one-off activities that take input and generate the required output. Round-trip engineering extends these features. An important rule in software design is that no design remains unchanged. This is as true for small systems as it is for large systems. During development, the design structure defined in the UML model does undergo changes to incorporate physical differences in the implementation that may not have been envisaged during the design. It becomes very difficult to keep the design of the system synchronized with the changes in the source code. The round-trip engineering feature enables the UML tool to synchronize the model with the changes in the application code. The StateWizard tends to enforce the UML tool’s capability of real-time synchronizing its model according to the modification in the code part. For example, developers can visually do a drag-and-drop operation in the state chart diagram, and subsequently the source code would change as well; to the contrary, developers may directly rectify the code part while modification will be automatically shown in the state chart diagram. It results in the StateWizard serving as a bridge between the state chart diagram and the source code.)
- 文档编制:StateWizard为设计人员提供了某种方式来在图表中记录设计决策.设计者可以将状态图另存为BMP文件,并将状态树另存为文本文件.(Documentation: The StateWizard provides some way for the designer to document the design decisions in the diagrams. The designer may save the state chart as a BMP file and save the state tree as a text file.)
3. StateWizard基于声音,优化的概念和实现选择(3. StateWizard is Based on Sound and Optimized Notions and Implementation Choices)
除了其创新的概念和概念(例如应用程序和端口)外,StateWizard还设计有最佳的数据结构和实现选择,以确保高效的应用程序代码生成和往返工程.在其功能中,我们可以声明:(In addition to its innovative notions and concepts such as application and ports, the StateWizard was designed with optimal data structures and implementation choices guaranteeing efficient application code generation and round trip engineering. Among its features, we can state:)
状态图(The State Chart)
状态图可对嵌入式系统进行建模,而无需使用笨重且昂贵的CASE工具.状态图为您提供了应用程序逻辑结构和流程的"鸟瞰图".它以图形方式构造状态层次结构,并将子状态嵌套在其父模式下.状态图相对于状态树的另一个主要优点是,它以箭头的形式显示从一个状态到另一个状态的每个状态的转换.如果开发人员选择状态或转换,然后右键单击鼠标,则StateWizard将通过菜单提供一个动作列表,具体取决于所选状态或转换.(The State Chart models embedded systems without heavyweight, expensive CASE tools. The State Chart gives you a “bird’s-eye view” of your application’s logical structure and flow. It graphically constructs the state hierarchy, with child states nested within their parent mode. Another of State Chart’s major advantages over the State Tree is that it displays every state’s transitions in the form of arrows from one state to another state. If a developer selects a state or a transition, and then right clicks the mouse, the StateWizard will provide an action list by a menu depending on the selected state or the transition.)
图:状态图(Figure: The State Chart)#### 状态树(The State Tree)
状态树是状态机程序员的助手,位于VC工作区选项卡窗口中.在编码时,它将提供状态机框架.它使开发人员可以轻松地执行某些路由任务,例如创建状态机应用程序,创建状态层次结构,为状态定义入口函数和出口函数以及定义事件处理程序.运行时,它是所有活动应用程序的状态跟踪器.如果开发人员选择状态树项,然后右键单击鼠标,则StateWizard将通过菜单提供操作列表,具体取决于所选项目,应用程序或状态.(The State Tree is a state machine programmer’s assistant, located in the VC workspace tab window. While coding, it will provide a state machine framework. It makes it easy for developers to do certain routing tasks such as creating a state machine application, creating a state hierarchy, defining an entry function and an exit function for a state, and defining event handlers. While running, it is a state tracker for all active applications. If a developer selects a state tree item and then right clicks the mouse, the StateWizard will provide an action list by a menu depending on the selected project, the application, or the state.)
图:状态树(Figure: The State Tree)## StateTree和StateChart如何支持逆向工程(How the StateTree and StateChart Support Reverse Engineering)
除了C/C ++源代码外,没有其他状态机信息. StateTree和StateChart如何支持逆向工程?就像Visual C ++ ClassWizard一样,StateWizard定义了一组宏来构造状态机,定义状态,子状态,声明事件处理程序和状态转换.(There is no additional state machine information besides C/C++ source code. How do the StateTree and StateChart support reverse engineering? Just like the Visual C++ ClassWizard, the StateWizard defines a set of macros to construct state machines, define states, sub-states, declare event handlers and state transitions.)
例如,以下C ++宏定义了一个名为Player的状态机,具有以下状态:(For example, the following C++ macro defines a state machine named Player with the following states:)
-
Player
((()PowerDown
,(,)PowerUp
((()Playing
,(,)Pause
))())) 和状态转换:(and state transitions:) -
((()
EXT_EVENT_ID_POWER, PowerDown
->(->)PowerUp, OnPowerDownEXT_EVENT_ID_POWER
)()) -
((()
EXT_EVENT_ID_POWER, PowerUp
->(->)PowerDown, OnPowerUpEXT_EVENT_ID_POWER
)()) -
((()
EXT_EVENT_ID_PAUSE_RESUME, Playing
->(->)Pause, OnPlayingEXT_EVENT_ID_PAUSE_RESUME
)()) -
((()
EXT_EVENT_ID_PAUSE_RESUME, Pause
->(->)Playing, OnPauseEXT_EVENT_ID_PAUSE_RESUME
)())
SME_HANDLER_CLASS_DEF(Player)
SME_BEGIN_STATE_DEF(Player,Player)
/*{{SME_STATE_DEF(Player,Player)*/
SME_STATE_ENTRY_FUNC(PlayerEntry)
SME_STATE_EXIT_FUNC(PlayerExit)
/*}}SME_STATE_DEF*/
SME_END_STATE_DEF
SME_BEGIN_STATE_DEF(Player,PowerDown)
/*{{SME_STATE_DEF(Player,PowerDown)*/
SME_STATE_ENTRY_FUNC(PowerDownEntry)
SME_STATE_EXIT_FUNC(PowerDownExit)
SME_ON_EVENT(EXT_EVENT_ID_POWER,OnPowerDownEXT_EVENT_ID_POWER,PowerUp)
/*}}SME_STATE_DEF*/
SME_END_STATE_DEF
SME_BEGIN_STATE_DEF(Player,PowerUp)
/*{{SME_STATE_DEF(Player,PowerUp)*/
SME_STATE_ENTRY_FUNC(PowerUpEntry)
SME_STATE_EXIT_FUNC(PowerUpExit)
SME_ON_EVENT(EXT_EVENT_ID_POWER,OnPowerUpEXT_EVENT_ID_POWER,PowerDown)
/*}}SME_STATE_DEF*/
SME_END_STATE_DEF
SME_BEGIN_STATE_DEF(Player,Playing)
/*{{SME_STATE_DEF(Player,Playing)*/
SME_STATE_ENTRY_FUNC(PlayingEntry)
SME_STATE_EXIT_FUNC(PlayingExit)
SME_ON_EVENT(EXT_EVENT_ID_PAUSE_RESUME,OnPlayingEXT_EVENT_ID_PAUSE_RESUME,Pause)
/*}}SME_STATE_DEF*/
SME_END_STATE_DEF
SME_BEGIN_STATE_DEF(Player,Pause)
/*{{SME_STATE_DEF(Player,Pause)*/
SME_STATE_ENTRY_FUNC(PauseEntry)
SME_STATE_EXIT_FUNC(PauseExit)
SME_ON_EVENT(EXT_EVENT_ID_PAUSE_RESUME,OnPauseEXT_EVENT_ID_PAUSE_RESUME,Playing)
/*}}SME_STATE_DEF*/
SME_END_STATE_DEF
/*{{SME_STATE_STATETREE_SEPARATOR}}*/
SME_BEGIN_STATE_TREE_DEF(Player)
/*{{SME_STATE_TREE_DEF(Player)*/
SME_STATE(Player,Player,SME_INVALID_STATE,PowerDown)
SME_STATE(Player,PowerDown,0,-1)
SME_STATE(Player,PowerUp,0,Playing)
SME_STATE(Player,Playing,PowerUp,-1)
SME_STATE(Player,Pause,PowerUp,-1)
/*}}SME_STATE_TREE_DEF*/
SME_END_STATE_TREE_DEF
/*{{SME_DEC_IMP_SEPARATOR}}*/
SME_APPLICATION_DEF(Player, "Player")
状态机运行环境(State Machine Running Environment)
实时或嵌入式应用程序的设计通常涉及将应用程序软件分解为对象,其中一些可以为过程或系统控制实现有限状态机.这些控制对象的示例可能是电话交换系统内的呼叫控制类,或医疗仪器内的治疗控制类.有限状态机是反应性的,事件驱动的控制结构,其行为由接收到的事件及其之前的事件历史决定.其他非反应性类提供计算或数据检索服务,不需要维护机器状态或刺激历史即可完成其功能.(The design of real-time or embedded applications usually involves decomposing the application software into objects, some of which may implement finite state machines for the process or the system control. Examples of these control objects might be the call control classes within a telephone switching system, or the treatment control classes within a medical instrument. Finite state machines are reactive, event-driven control structures whose behavior is determined by a received event and the history of events that preceded it. Other non-reactive classes provide computational or data retrieval services, not requiring maintenance of a machine state or a history of stimuli to complete their functions.)
在StateWizard环境中,这些活动类实现状态机并可以处理输入事件. StateWizard状态机引擎管理这些类并充当事件分发程序.(In the StateWizard environment, these active classes implement state machines and can process input events. The StateWizard State Machine Engine manages these classes and acts as an event dispatcher.)
状态机对象可以在活动状态或非活动状态下工作.状态机引擎仅将事件调度到活动状态机对象.非活动状态机对象不处理事件.(State machine objects can work in an active state or an inactive state. The State Machine Engine dispatches events to active state machine objects only. Inactive state machine objects do not handle events.)
下图描述了StateWizard运行时环境的体系结构,显示了在状态机引擎上方运行的应用程序对象和线程. RTOS虚拟层为通用RTOS服务(如信号量,互斥量和线程控制)提供了通用接口.服务提供者层是较低层模块和硬件接口的接口层.模拟或目标环境层为目标环境或该目标环境的模拟提供接口.当真正的目标硬件尚不可用,或者需要大量的调试工具但目标上不可用时,通常在软件开发过程中使用仿真.(The architecture of the StateWizard runtime environment is depicted in the following diagram, showing the application objects and threads running above the State Machine Engine. The RTOS virtual layer provides a generic interface for the common RTOS services such as semaphores, mutexes, and thread control. The service provider layer is the interface layer to lower level modules and hardware interfaces. A simulation or destination environment layer provides the interface to the target environment or to a simulation of that target environment. Simulation is often employed during software development when the real target hardware is not yet available, or when extensive debugging facilities are needed but are not available on the target.)
图:StateWizard运行时体系结构(Figure: StateWizard Runtime Architecture)### 状态机线程(State Machine Threads)
多个活动状态机对象可以在单个线程上下文下运行.线程上下文标识一个独立的执行线程,并包含一个线程标识符,一组对象,一个内部事件池和几个事件挂钩函数.(Several active state machine objects may run under a single thread context. A thread context identifies an independent execution thread, and contains a thread identifier, a group of objects, an internal event pool, and several event hook functions.)
状态机应用框架(State Machine Application Framework)
StateWizard为状态机对象提供了两个应用程序框架:(The StateWizard provides two application frameworks for state machine objects:)
- 标准嵌入式C(Standard Embedded C)
- 标准C ++(Standard C++) 对于标准C ++应用程序框架,状态机对象由C ++类构造.(For the standard C++ application framework, a state machine object is constructed by a C++ class.)
状态机对象激活(State Machine Object Activation)
为了激活,状态机对象通过调用(To activate, a state machine object identifies itself to the State Machine Engine by calling the) SmeActivateObj ()
功能.以下示例创建一个(function. The following sample creates a) Player
状态机对象名为(state machine object named) Player1
.(.) Player1
在单独的线程下运行,其入口函数为(runs under a separate thread whose entry function is) AppThreadProc
.线程上下文是(. The thread context is) g_AppThreadContext
.(.)
void* AppThreadProc(void *Param)
{
// The second parameter (NULL) is the state machine Player1's parent.
SmeActivateObj(&Player1,NULL);
SmeRun();
}
SME_OBJ_DEF(Player1,Player)
SME_THREAD_CONTEXT_T g_AppThreadContext;
XTHREADHANDLE ThreadHandle = 0;
// Install thread local storage data functions.
XTlsAlloc();
SmeSetTlsProc(XSetThreadContext, XGetThreadContext);
// Initialize the engine
SmeInitEngine(&g_AppThreadContext);
// Install external event handler functions.
// They act as a plug-in of the state machine engine.
SmeSetExtEventOprProc(XGetExtEvent, XDelExtEvent, XPostThreadExtIntEvent,
XPostThreadExtPtrEvent, XInitMsgBuf, XFreeMsgBuf);
int ret = XCreateThread(AppThreadProc, NULL, &AppThreadHandle);
// The second parameter is the parameter for the thread entry function.
播放器控制面板可以将外部事件发布到正在运行的线程的事件队列中.引擎会将它们分派到活动的应用程序(The player control panel may post external events to the event queue of the running thread. The engine will dispatch them to the active application) Player1
.(.)
XPostThreadExtIntEvent(&g_AppThreadContext, EXT_EVENT_ID_POWER, 0, 0,
NULL,0,SME_EVENT_CAT_OTHER);
状态机对象停用(State Machine Object Deactivation)
通过调用以下命令来取消激活状态机对象(De-activating a state machine object is done by calling the) SmeDeactivateObj()
功能.以下语句将停用(function. The following statement de-activates the) Player1
状态机对象.(state machine object.)
SmeDeactivateObj(&Player1);
服务供应商(Service Providers)
卫星机器的应用程序可能与称为服务提供者的较低层(其他模块)或硬件紧密协作.服务由一组可用于服务用户(应用程序)的原语(操作)正式指定.这些原语告诉服务执行某些操作,或报告对等组件/实体所采取的操作.服务原语分为四类:(Sate machine applications may tightly co-work with lower layer (other modules) or hardware, which are called service providers. A service is formally specified by a set of primitives (operations) available to service users (applications). These primitives tell the service to perform some action, or report on an action taken by a peer component/entity. The service primitives are classified into four categories:)
- 请求(Request)
- 适应症(Indication)
- 响应(Response)
- 确认(Confirm) [计算机网络,Andrew S.Tanenbaum].请求和确认原语可以以服务调用的形式实现.指示和响应原语可以以外部事件发布的形式实现.([Computer Networks, Andrew S.Tanenbaum]. The request and confirm primitives can be implemented in the form of service calls. The indication and response primitives can be implemented in the form of external event posting.)
活动状态机对象可以使用以下机制之一与服务提供者进行通信,以交换信息:(Active state machine objects can communicate with service providers using one of the following mechanisms, to exchange information:)
- 同步服务呼叫(Synchronous service calls).这些同步服务调用可能会阻塞,并在操作完成后将控制权返回给应用程序.由于大多数实时系统必须在预定的时间内响应外部事件,因此不使用同步服务调用.(. These synchronous service calls may block, returning control to the application when the operation completes. Since most real-time systems must respond to external events in a predetermined amount of time, synchronous service calls are not used.)
- 异步服务呼叫(Asynchronous service calls).异步功能不会阻塞,而是继续执行并在操作完成之前返回.(. Asynchronous functions do not block, continuing execution and returning before the operation is completed.)
- 主动事件指示(Pro-active event indications).这些事件无需任何请求即可从服务组件发布到客户端组件.一个示例可能是硬件中断服务例程发布的事件.(. These events are posted from a service component to a client component without any request. An example might be an event posted by a hardware interrupt service routine.)
独立于平台的嵌入式系统开发(Platform-independent Embedded System Development)
嵌入式系统市场上有许多不同的实时操作系统(RTOS).每个不同的RTOS提供不同的API来访问一组通用系统服务. StateWizard RTOS虚拟层提供了独立于平台的适配器层,允许状态机在不同操作系统之间进行可移植性.我们可以在不更改应用程序代码的情况下将应用程序从一个RTOS移至另一个. RTOS虚拟层中的外部事件接收器充当状态机引擎的插件.(There are many different Real Time Operation Systems (RTOS) on the embedded system market. Each different RTOS provides a different API to access a set of common system services. The StateWizard RTOS Virtual Layer provides a platform independent adapter layer allowing state machine portability between different operating systems. We can move the application from one RTOS to another without changing the application code. The external event receiver in the RTOS Virtual Layer acts as a plug-in to the state machine engine.)
模拟器(Simulators)
在以下情况下应考虑使用模拟器:(Simulators should be considered when:)
- 硬件不可用或价格昂贵(Hardware is unavailable or expensive)
- 需要广泛的调试功能(Extensive debugging capabilities are needed) 模拟器是测试工具的几个重要类别之一.它们模拟了软件最终将在其中运行的环境,并且通常包含有用的调试功能.它们还使测试人员能够更有效地控制测试环境,并且当工程师之间必须共享稀缺的目标硬件时,可以节省关键的开发资源.(Simulators are one of several important categories of testing tools. They emulate the environment in which the software will eventually perform, and often incorporate useful debugging features. They also enable testers to more effectively control the test environment, and may save critical development resources when scarce target hardware must be shared between engineers.)
仿真允许在硬件原型可用之前开始软件测试.它还可以随着系统的大小和复杂性进行扩展,从而有助于在开发周期较早的情况下(尽管校正仍然不昂贵)识别和解决问题.(Simulation allows commencement of software testing before a hardware prototype is available. It also scales with the size and complexity of the system, helping to identify and solve problems early in the development cycle when correction is still inexpensive.)
在模拟环境中,开发人员可以模拟在桌面平台(例如Windows或Linux)上运行的服务提供商.这些模拟服务具有与目标服务提供者接口相同的接口.当转移到目标环境时,在模拟中对状态机应用程序和真实环境进行集成后,应该花费很少的精力.活动应用程序可以进行由服务提供商提出的服务调用,并且可以通过RTOS功能接收由服务提供商触发的外部事件.(In a simulation environment, developers can simulate service providers running on desktop platforms, for example, Windows or Linux. These simulated services have identical interfaces with the target service provider interfaces. When moving to the destination environment, it should take little effort to integrate state machine applications with the real environment after they have been tested in the simulation. Active applications may make service calls presented by the service providers, and may receive external events triggered by service providers through RTOS functions.)
您可以将StateWizard应用于:(You May Apply StateWizard To:)
- 通过窗口消息挂钩技术开发基于状态机的Win32/WinCE程序(State machines based Win32/WinCE programs development through window message hooking technology)
- 跨平台嵌入式系统建模与仿真(Cross-platform embedded system modeling and simulation)
具有产品质量的StateWizard Pro Engine(The StateWizard Pro Engine with Product Quality)
- 分层状态机(Hierarchical state machines)
- 通过在几个C/C ++文件中分离状态树定义,支持具有数百个状态的大型状态机(Support large state machine with hundreds of states through separating state tree definitions in several C/C++ files)
- 状态历史记录信息和历史记录转换(State history information and history transitions)
- 事件处理的保护过渡(Guarded transitions on event handling)
- 条件伪状态(Conditional pseudo-states)
- 加入伪状态(Join pseudo-states)
- 多线程正交状态(Multi-threaded orthogonal states)
- 内置状态计时器;状态进入时,自动启动内置计时器,状态退出时停止(Built-in state timers; on state entry, starts the built-in timer automatically, stops it on state exit)
- 适用于Linux/Win32的跨平台事件循环和与操作系统相关的API库(Cross-platform event loop and OS-related API library for Linux/Win32) 下载StateWizard Pro(Download the StateWizard Pro) 这里(here) .(.)
发牌(Licensing)
您可以下载更多信息(You may download more information) 从这里(from here) ,这是LGPL许可下的UML StateWizard开源项目的官方网站.(, the official site of the UML StateWizard open source project under LGPL license.)
参考文献(References)
- www.uml.org(www.uml.org)
- UML工具:Mandar Chitnis,Pravin Tiwari和Lakshmi Ananthamurthy撰写(UML Tool: by Mandar Chitnis, Pravin Tiwari, and Lakshmi Ananthamurthy)
许可
本文以及所有相关的源代码和文件均已获得The Code Project Open License (CPOL)的许可。
eVC4.0 C++ eVC VC7.1 WinMobile Mobile Windows Visual-Studio Dev 新闻 翻译