PetriNetwork
1.0.0
Petrinetwork is a library on ActionScript 3, which simulates the functioning of the Petri network. Designed to create interactive Flash animation in the training environment hypertest
The Petri network is a dual -bottomed multi -type multiprait, consisting of the tops of two types - positions and transitions interconnected by arcs. The peaks of the same type cannot be connected directly. In positions, markers (markers) can move over the network can be placed in positions.
The event is the operation of the transition in which the marks from the input positions of this transition move to the weekend. Events occur instantly, or differently, when the conditions are fulfilled.
import PetriNetManager . State ;
import PetriNetManager . StateTransition ;
import PetriNetManager . ActionResult ;
import PetriNetManager . SceneManager ;
import PetriNetManager . StatesUpdateEventHandler ;
import flash . display . DisplayObject ; var sceneMgr = new SceneManager ( ) ; var sett : Object = {
//Номера позиций
states : [ 1 , 2 , 3 , 4 , 5 ] ,
//Количество маркеров в каждой позиции
markers : [ 1 , 0 , 0 , 0 , 0 ] ,
//Массив объектов переходов
transitions : [ {
//номер перехода
id : 1 ,
//Входные позиции
inputStates : [ 1 ] ,
//Выходные позиции
outputStates : [ 2 ]
} ,
{
id : 2 ,
inputStates : [ 2 ] ,
outputStates : [ 3 ]
} ,
{
id : 3 ,
inputStates : [ 1 ] ,
outputStates : [ 5 ]
}
]
} ; sceneMgr . initFromObject ( sett ) ; helpBtn . addEventListener ( MouseEvent . CLICK , helpBtnInvoke ) ;
function helpBtnInvoke ( e : MouseEvent ) : void {
sceneMgr . makeAction ( 1 ) ;
} function statesChangedHandler ( e : StatesUpdateEventHandler ) {
for each ( var s : State in e . States ) {
trace ( s . Id + " " + s . hasMarkers ( ) ) ;
}
trace ( "-----------------------------" ) ;
//Если срабатывает первый переход
if ( e . States [ 0 ] . hasMarkers ( ) ) {
//переходим на другой фон
bg1 . gotoAndStop ( 1 ) ;
//меняем текст в навигационном окне
curStr = "Зайдите в меню HELP или нажмите CTRL+SHIFT+D" ;
}
if ( e . States [ 1 ] . hasMarkers ( ) ) {
bg1 . gotoAndStop ( 2 ) ;
curStr = "Выберите пункт Default Keymap Reference" ;
}
if ( e . States [ 2 ] . hasMarkers ( ) ) {
bg1 . gotoAndStop ( 3 ) ;
curStr = "Список со всеми горячими клавишами" ;
}
if ( e . States [ 4 ] . hasMarkers ( ) ) {
bg1 . gotoAndStop ( 4 ) ;
curStr = "Форма поиска команды" ;
}
}
sceneMgr . addEventListener ( StatesUpdateEventHandler . STATES_UPDATE_EVENT , statesChangedHandler ) ; sceneMgr . initFromJson ( net1 . json ) ;