def example(): """This example show how to create a marked Laurie state machine""" modelfiledir = '../subjects/' # modelfile="ntscd_example.txt" # modelfile="sm3.txt" # modelfile="fairnessEG.txt" # modelfile="kellysample.txt" modelfile = "webchess.txt" # modelfile="EFSM_ATM_noexit.txt" # modelfile="EFSM_ATM_noexit_TEMP.txt" # modelfile = 'efsm_atm_not23.txt' # modelfile = 'efsm_cashier_noexit.txt' # modelfile = 'efsm_cashier_shortpin.txt' # modelfile="EFSM_ATM_noexit_new.txt" # modelfile="EFSM_Cashier.txt" # modelfile="EFSM_Cashier_shortPin.txt" # modelfile="EFSM_Cashier_noexit.txt" # modelfile="EFSM_CruiseControl-new.txt" # modelfile="EFSM_FuelPump.txt" # modelfile="EFSM_FuelPump_noexit.txt" # modelfile="EFSM_INRES.txt" # modelfile="EFSM_INRES_noexit.txt" # modelfile="EFSM_Lift.txt" # modelfile="EFSM_PrinTok.txt" # modelfile="EFSM_SimplifiedPhone.txt" # modelfile="EFSM_SimplifiedPhone_noexit.txt" # modelfile="EFSM_TCP.txt" # modelfile="EFSM_TCSbin.txt" # modelfile="EFSM_TCSbin_EXIT.txt" # modelfile="EFSM_VendingMachine.txt" # modelfile="EFSM_VendingMachine_noexit.txt" ################################################## #initialize the model and dependence of SM inputfile = modelfiledir + modelfile SM = EFSM.efsmFromFile(inputfile) print "%s has %s states and %s transitions" % (SM.name, len( SM.stateList), len(SM.transitionList)) # for item in SM.transitionList: # print item.name # print SM.findPathforGivenTrans(item.name) # print '\transiton\n', SM.transitionList SM.allPathNum() # SM.alltransitions() # <**Path ['T1', 'T2', 'T4', 'T5', 'T8', 'T17', 'T21', 'T20', 'T22', 'T10', 'T7', 'T9', 'T23']**> # path='<**Path ['T1',\'T3\']**>' # print path # SM.pathInputVar(path) # for item in SM.transitionList: # print item.name # print SM.findPathforGivenTrans(item.name) # SM.duAnalysis() SM.testGen()
def targetDeal(inputfile): f = open(inputfile, 'r') targetList = [] targetList = f.readlines() f.close() k = 0 for item in targetList: s.append(item.split(', ')) #需要修改成<name, src,tgt,event,cond,action> src = SM.state(s[k][1]) tgt = SM.state(s[k][2]) targetbranchlist.append( EFSM.Transition(s[k][0], src, tgt, s[k][3], s[k][4], s[k][5])) k += 1
def example(): """This example show how to create a marked Laurie state machine""" modelfiledir = 'D:/cxc/subjects/' # modelfile="ntscd_example.txt" # modelfile="sm3.txt" # modelfile="fairnessEG.txt" # modelfile="kellysample.txt" modelfile = "efsm_atm.txt" # modelfile="EFSM_ATM_noexit.txt" # modelfile="EFSM_ATM_noexit_TEMP.txt" # modelfile="EFSM_ATM_noexit_new.txt" # modelfile="EFSM_Cashier.txt" # modelfile="EFSM_Cashier_shortPin.txt" # modelfile="EFSM_Cashier_noexit.txt" # modelfile="EFSM_CruiseControl-new.txt" # modelfile="EFSM_FuelPump.txt" # modelfile="EFSM_FuelPump_noexit.txt" # modelfile="EFSM_INRES.txt" # modelfile="EFSM_INRES_noexit.txt" # modelfile="EFSM_Lift.txt" # modelfile="EFSM_PrinTok.txt" # modelfile="EFSM_SimplifiedPhone.txt" # modelfile="EFSM_SimplifiedPhone_noexit.txt" # modelfile="EFSM_TCP.txt" # modelfile="EFSM_TCSbin.txt" # modelfile="EFSM_TCSbin_EXIT.txt" # modelfile="EFSM_VendingMachine.txt" # modelfile="EFSM_VendingMachine_noexit.txt" ################################################## #initialize the model and dependence of SM inputfile = modelfiledir + modelfile SM = EFSM.efsmFromFile(inputfile) print "%s has %s states and %s transitions" % (SM.name, len( SM.stateList), len(SM.transitionList)) # print '\transiton\n', SM.transitionList SM.allPathNum() SM.duAnalysis()
def example(): """This example show how to create a marked Laurie state machine""" ################################################## #select a example here # currentdir = os.curdir # imagedir = os.path.join(currentdir, "..\..\subjects") # imagefile = os.path.join(imagedir, "test.txt") # print imagefile modelfiledir = '../../subjects/' # currentdir = os.path.dirname(__file__) #imagedir = os.path.join(currentdir, "images") # modelfile="test.txt" # modelfile="ntscd_example.txt" # modelfile="sm3.txt" # modelfile="fairnessEG.txt" # modelfile="kellysample.txt" modelfile="EFSM_ATM.txt" #by zhao # modelfile="EFSM_ATM_noexit.txt" # modelfile="EFSM_Cashier.txt" # modelfile="EFSM_Cashier_noexit.txt" # modelfile="EFSM_CruiseControl.txt" # modelfile="EFSM_FuelPump.txt" # modelfile="EFSM_FuelPump_noexit.txt" # modelfile="EFSM_INRES.txt" # modelfile="EFSM_INRES_noexit.txt" # modelfile="EFSM_Lift.txt" # modelfile="EFSM_PrinTok.txt" # modelfile="EFSM_SimplifiedPhone.txt" # modelfile="EFSM_SimplifiedPhone_noexit.txt" # modelfile="EFSM_TCP.txt" # modelfile="EFSM_TCSbin.txt" # modelfile="EFSM_TCSbin_EXIT.txt" # modelfile="EFSM_VendingMachine.txt" # modelfile="EFSM_VendingMachine_noexit.txt" ################################################## #initialize the model and dependence of SM inputfile = modelfiledir+modelfile SM=EFSM.efsmFromFile(inputfile) # print "%s has %s states and %s transitions" %(SM.name, len(SM.stateList), len(SM.transitionList)) # print '\transiton\n', SM.transitionList ################################################## #view the model #create Laurie SM, with marked transitions states=[] for s in SM.stateList: if s.name=='START': states.append(LSM.State(s.name, True)) else: states.append(LSM.State(s.name)) transitions=[] for tran in SM.transitionList: srcState=[state for state in states if state.name == tran.src.name].pop() tgtState=[state for state in states if state.name == tran.tgt.name].pop() transitions.append(LSM.Transition(tran.name, srcState, tgtState, True)) EFSMGraph = LSM.State_Machine(states, transitions) EFSMGraph.visualize() ################################################## #initialize the dependence of model EFSM.initEFSM(SM) ################################################## #TEST # print SM.stateTransitiveSuccessor(SM.state('START')) # print SM.ntscdSuccessor(SM.transition('TS12')) # print SM.maxPathDict[SM.transition('TS11').name] # print SM.findSuccSinkPath(SM.transition('TS2')) # for transition in SM.transitionList: # print transition, ":\n" # # print SM.findMaxPath(transition) # print SM.maxPathDict[transition.name] # print "\n" # print SM.findSuccMaxPath(SM.transition('T3')) # print SM.maxPathDict[SM.transition('T2').name] ################################################## # #output variables for each transition # ofile=open(SM.name+"_variables_list.txt", "w") # vSet=set() # for tran in SM.transitionList: # # {eventVdef:vlist, condVuse:vlist, actionVdef:vlist, actionVuse,vlist} # for x in ["eventVdef", "condVuse", "actionVdef", "actionVuse"]: # ofile.write(tran.name+'\t'+x+':\t') # for y in SM.tranVarDict[tran.name][x]: # ofile.write(y+'\t') # vSet.add(y) # ofile.write('\n') # ofile.write("\ntotal variables: "+str(len(vSet))+'\n') # for v in vSet: # ofile.write(v+', ') # ofile.close() ################################################## #generate dependence graph # print 'generate the dependence graph...' # SMDG=SM.makeDependenceGraph('DATA', 'NTSCD') # SMDG=SM.makeDependenceGraph('DATA', 'NTICD') # SMDG=SM.makeDependenceGraph('DATA', 'UNTICD') # SMDG.view() # view the dependence graph for cd in ['NTICD', 'NTSCD', 'UNTICD']: SMDG=SM.makeDependenceGraph('DATA', cd) SMDG.view() # view the dependence graph # ################################################## # #define a slicing criterion here criterion=SM.transition('T7') # ################################################## #generate the dependence graph wrt the criterion subDG=SMDG.subBWGraphwrtNode(criterion) subDG.view(criterion) # view the subdependence graph #create Laurie SM, with marked transitions states=[] for s in SM.stateList: if s.name=='START': states.append(LSM.State(s.name, True)) else: states.append(LSM.State(s.name)) transitions=[] for tran in SM.transitionList: srcState=[state for state in states if state.name == tran.src.name].pop() tgtState=[state for state in states if state.name == tran.tgt.name].pop() if tran in subDG.nodeList: transitions.append(LSM.Transition(tran.name, \ srcState, tgtState, True)) else: transitions.append(LSM.Transition(tran.name, \ srcState, tgtState, False)) SMGraph=LSM.State_Machine(states,transitions) # added by zhao on 21.04.2009 SMGraph.visualize() # added by zhao on 21.04.2009
def example(): """This example show how to create a marked Laurie state machine""" ################################################## #select a example here # currentdir = os.curdir # imagedir = os.path.join(currentdir, "..\..\subjects") # imagefile = os.path.join(imagedir, "test.txt") # print imagefile modelfiledir = '../../subjects/' # currentdir = os.path.dirname(__file__) #imagedir = os.path.join(currentdir, "images") # modelfile="ntscd_example.txt" # modelfile="sm3.txt" # modelfile="fairnessEG.txt" # modelfile="kellysample.txt" # modelfile="EFSM_ATM.txt" # modelfile="EFSM_ATM_noexit.txt" # modelfile="EFSM_Cashier.txt" # modelfile="EFSM_Cashier_noexit.txt" # modelfile="EFSM_CruiseControl.txt" # modelfile="EFSM_FuelPump.txt" # modelfile="EFSM_FuelPump_noexit.txt" # modelfile="EFSM_INRES_noexit.txt" # modelfile="EFSM_Lift.txt" modelfile="EFSM_PrinTok.txt" # modelfile="EFSM_SimplifiedPhone.txt" # modelfile="EFSM_SimplifiedPhone_noexit.txt" # modelfile="EFSM_VendingMachine.txt" # modelfile="EFSM_VendingMachine_noexit.txt" ################################################## #initialize the model and dependence of SM inputfile = modelfiledir+modelfile SM=EFSM.efsmFromFile(inputfile) # #view the model # #create Laurie SM, with marked transitions # states=[] # for s in SM.stateList: # if s.name=='START': # states.append(LSM.State(s.name, True)) # else: # states.append(LSM.State(s.name)) # transitions=[] # for tran in SM.transitionList: # srcState=[state for state in states if state.name == tran.src.name].pop() # tgtState=[state for state in states if state.name == tran.tgt.name].pop() # transitions.append(LSM.Transition(tran.name, srcState, tgtState, True)) # EFSMGraph = LSM.State_Machine(states, transitions) # EFSMGraph.visualize() #initialize the dependence of model EFSM.initEFSM(SM) ################################################## #TEST # print SM.ntscdSuccessor(SM.transition('T12')) # print SM.maxPathDict[SM.transition('T4').name] # print SM.findSuccSinkPath(SM.transition('T2')) # for transition in SM.transitionList: # print transition, ":\n" # # print SM.findMaxPath(transition) # print SM.maxPathDict[transition.name] # print "\n" # ofile=open("test.txt", "w") # for transition in SM.transitionList: # ofile.write(transition.name+'\t'+ str(SM.maxPathDict[transition.name])+'\n') # ofile.close() # sum=0 # for transition in SM.transitionList: # x=len(SM.maxPathDict[transition.name]) # sum += x # print x # print 'sum', sum # #count slibling transition and their successors # tempSet=set() # for transition in SM.transitionList: # if SM.transitionSibling(transition): # tempSet.add(transition) # for transition in tempSet.copy(): # for t in SM.succDict[transition.name]: # tempSet.add(t) # print('lenth of set is ', len(tempSet)) ################################################## #select the control dependence here and generate #the dependence graph print 'generate the dependence graph...'
# encoding:UTF-8 import sys import types import re import EFSM import config import sclexer SM = EFSM.efsmFromFile(config.getGenerateModule()) # 对efsm类实例化 #----------------rinsmq # print ('rinsmq') print('执行 obtain_efsm_info 文件') #----------------rinsmq def obtain_tran_info(): # 得到某efsm的全部迁移信息(name, src, tgt, event, cond, action) # print "%s has %s states and %s transitions" % (SM.name, len(SM.stateList), len(SM.transitionList)) return SM.transitionList def tran_number(): return len(SM.transitionList) def obtain_end_tranlist(): # 得到end transition list SM.findEndTransition() return SM.endTransitionList def obtain_start_tranlist(): SM.findStartTransition()
# encoding:UTF-8 import sys import types import re import EFSM import config SM = EFSM.efsmFromFile(config.getGenerateModule()) # 对efsm类实例化 print(SM) #----------------rinsmq # print ('rinsmq') # print('obtain_efsm_info') # print(type(SM)) #----------------rinsmq def obtain_tran_info(): # 得到某efsm的全部迁移信息(name, src, tgt, event, cond, action) # print "%s has %s states and %s transitions" % (SM.name, len(SM.stateList), len(SM.transitionList)) return SM.transitionList def tran_number(): return len(SM.transitionList) def obtain_end_tranlist(): # 得到end transition list SM.findEndTransition() return SM.endTransitionList def obtain_start_tranlist():
# encoding:UTF-8 import sys import types import re import EFSM import config SM = EFSM.efsmFromFile(config.getGenerateModule()) # 对efsm类实例化 def obtain_tran_info(): # 得到某efsm的全部迁移信息(name, src, tgt, event, cond, action) # print "%s has %s states and %s transitions" % (SM.name, len(SM.stateList), len(SM.transitionList)) return SM.transitionList def tran_number(): return len(SM.transitionList) def obtain_end_tranlist(): # 得到end transition list SM.findEndTransition() return SM.endTransitionList def obtain_start_tranlist(): SM.findStartTransition() return SM.startTransitionList #返回当前迁移的前向迁移(前向迁移的结束节点指向当前迁移的开始节点)