Esempio n. 1
0
def sumoGUISimulate(cfgFile):
	'''
Function that simulates the configuration file with the gui support.
	'''
	if os.path.exists(cfgFile):
		sumoPath=globalasp.getPPath('SUMOGUI')
		rollOut=sumoPath+' -c '+cfgFile
		print'''
[sumoGUISimulate says]: Using SUMO GUI:Working ... Please wait.
		'''
		subprocess.check_output(rollOut)
	else:
		print'''
[sumoGUISimulate says]: Error locating the configuration file %s! Check if the configuration file %s exists.
		'''%(cfgFile,cfgFile)
Esempio n. 2
0
def viewRawDump(cfgFile,netFile,settingFile,routeFile,opdumpFile):
    '''
Function to output the raw dump data using a configuration file 'cfgFile',settings file 'settingFile' and route file 'routeFile'.
    '''
    
    if os.path.exists(cfgFile) and os.path.exists(netFile) and os.path.exists(settingFile) and os.path.exists(routeFile):
        relPath=globalasp.getPPath('SUMO')#Gets the relative path of SUMO binary
        rollOut=relPath+' -c '+cfgFile+' -n '+netFile+' --netstate-dump '+opdumpFile
        subprocess.check_output(rollOut)
        print '''
[viewRawDump says]:Working ... Please wait.The output file %s has been written to %s. 
        '''%(opdumpFile,os.getcwd())
    else:
        print'''
[viewRawDump says]:Error!Check if the file(s) %s,%s,%s and %s exists in the working directory %s.If the file exists,check if you have enough permissions to execute the
file.
        '''%(cfgFile,netFile,settingFile,routeFile,os.getcwd())
Esempio n. 3
0
def viewFullOutput(cfgFile,opFile):
    '''
Function that examines the cfg file cfgFile of a simulation and then writes the full output details in a file opFile.
    '''
    if os.path.exists(cfgFile):
        relPath=globalasp.getPPath('SUMO')#Gets the relative path of SUMO binary
        foFlag='--full-output'
        #Putting everything together ---- (V)
        rollOut=relPath+' '+'-c '+cfgFile+' '+foFlag+' '+opFile
        #Executing the command (V)
        subprocess.check_output(rollOut)
        print '''
[viewFullOutput says]:Working ... Please wait.The output file %s has been written to %s. 
        '''%(opFile,os.getcwd())
    else:
        print'''
[viewFullOutput says]:Error!Check if the file %s exists in the working directory %s.If the file exists,check if you have enough permissions to execute the
file.
        '''%(cfgFile,os.getcwd())
Esempio n. 4
0
def generateNetwork (nodFile,edgFile,out_netFile):
    '''
Function to generate the *.net.xml(out_netFile) file with *.nod.xml(nodFile) and *.edg.xml(edgFile) files as input.
    '''
##  Syntax for executing the edg and nod file to produce net file
##  netconvert --node-files=hello.nod.xml --edge-files=hello.edg.xml --output-file=hello.net.xml
    
    try:
        netconvertpath = globalasp.getPPath ('NETCONV')
        #This exists in 'D:\\Quest\\Aspire\\IDP\\sumo-winbin-0.16.0\\sumo-0.16.0\\bin\\netconvert.exe'
        genPath = netconvertpath+' '+'--node-files='+nodFile+' '+'--edge-files='+edgFile+' '+'--output-file='+out_netFile
        subprocess.check_output (genPath)
        print '''
[generateNetwork says]: The file %s has been written to location %s @ %s. 
                '''%(out_netFile,os.getcwd(),time.strftime("%d-%m-%Y %H:%M:%S"))
    except WindowsError,IOError:
        print
        ''' [generateNetwork says]: Error. Required program netconvert may not be installed or may not be located in <HOME-DIRECTORY>\SUMO\bin or the files %s and %s may not exist at all.
        ''' %(nodFile,edgFile)
Esempio n. 5
0
def viewVtk(cfgFile,opvtkFile):
    '''
Function that examines the cfg file cfgFile of a simulation and then writes the details in a VTK file opvtkFile.
    '''
    prevWD=os.getcwd()
    relPath=globalasp.getPPath('SUMO') #Gets the relative path of SUMO binary
    cfgFilePath=prevWD+'\\'+cfgFile
    dirString=time.strftime('%H_%M_%S_%d_%m_%y')
    createDir=os.makedirs(dirString)
    print'''
[viewVtk says]:Creating directory %s at location %s.
    '''%(dirString,prevWD)
    newPath=os.getcwd()+'\\'+dirString
    print'''
[viewVtk says]:Changing into directory %s.
    '''%(newPath)
    os.chdir(newPath)
    if os.path.exists(cfgFilePath):
        vtkFlag=' --vtk-output'
        #Putting everything together ---- (V)
        rollOut=relPath+' '+'-c '+cfgFilePath+' '+vtkFlag+' '+opvtkFile
        #Executing the command (V)
        subprocess.check_output(rollOut)
        print '''
[viewVtk says]:Working ... Please wait.The output file %s has been written to %s. 
        '''%(opvtkFile,newPath)
        print'''
[viewVtk says]:Done!Changing the working directory to %s.Syncing....wait a moment.
        '''%(prevWD)
        os.chdir(prevWD)
        sncfheaders.waitForSync(3)
    else:
        print'''
[viewVtk says]:Error!Check if the file %s exists in the working directory %s.If the file exists,check if you have enough permissions to execute the
file.
        '''%(opvtkFile,newPath)