Compared with state diagram, activity diagram can be used to display the concurrent behavior of program in a more natural and intuitive way. Six primitives of initial, fork, join, flow final, activity final and activity were selected as the basis for graphical modeling and automatic code generation. A XML document for- mat was defined to describe the activity diagram, then the XML document was parsed based on DOM, after that original activity diagram was split into separate activity sub-diagrams; and then each activity diagram was parsed into a number of processes and semaphores and codes. The methods and algorithms proposed were test- ed by designing and implementing a software system and good results were achieved, it showed that the meth- ods and algorithms were right and effective.%针对活动图能够比状态图更自然和直观地显示程序的并发行为,为达到图形化描述程序的并发行为并自动生成代码的目标,通过分析活动图的图元语义,以fork、join、activity、initial、activity final、flow final等6个图元作为图形建模和代码生成的基础,提出了一套代码自动生成算法.该算法把活动图拆分成若干独立的活动子图;再把每个活动子图解析成若干进程和信号量;最后对每一个进程和信号量进行代码生成.实验证明,基于本算法开发的原型系统取得了较满意的效果,同时也证明了所提出的方法和算法的正确性、有效性.
展开▼