Exemple #1
0
def main():
    #define busses, . means black, + means green, - means red
    #busList = [
    #            {'name': 'bus1','description': '6kV','status': '.'},
    #            {'name': 'bus2','description': '12kV','status': '.'},
    #            {'name': 'bus3','description': '18kV','status': '.'},
    #            {'name': 'bus4','description': '22kV','status': '.'},
    #            {'name': 'bus5','description': '54kV','status': '.'},
    #        ]
    ## define the connections. '.' means black, + means green, - means read
    #connectionList = [
    #                {1 : 'bus1', 2 : 'bus2', 'status': '.'},
    #                {1 : 'bus2', 2 : 'bus3', 'status': '.'},
    #                {1 : 'bus1', 2 : 'bus3', 'status': '+'},
    #                {1 : 'bus4', 2 : 'bus1', 'status': '+'},
    #                {1 : 'bus5', 2 : 'bus1', 'status': '+'},
    #                ]
    # mkae graphviz string

    #get json data and deserialize it

    fp = open('jsonFile.txt')
    for line in fp:
        print (line)

    fp.close()
    fp = open('jsonFile.txt')
    dataDict = json.loads(fp.read())
    fp.close()
    
    # load data
    nodeList = dataDict['busList']
    connectionList = dataDict['connectionList']
    config['destPath'] = dataDict['filepath']

    # add transformer name to node list
    for node in nodeList:
        if node['type'] == 'transformer':
            #node['name'] = node['busFrom'] + '' + node['id'] + '' + node['busTo']
            node['name'] = str(int(node['busFrom']) + int(node['busTo']))
    # add transformer connections
    for node in nodeList:
        if node['type'] == 'transformer':
            makeTransformerConnection(node, connectionList)
    
    gString = make_graphviz_string(nodeList, connectionList)

    # make node info list
    nodeTypeDict = {}
    for item in nodeList:
        nodeTypeDict[item['name']] = item['type']

    
    # write gString to file for later use
    text_file = open("temp.dot", "w")
    text_file.write(gString)
    text_file.close()

    # write gString to file for later use
    text_file = open(config['pollDir'] + "out.txt", "w")
    text_file.write(gString)
    text_file.close()

    # write dest to file for later use
    text_file = open(config['pollDir'] + "dest.txt", "w")
    text_file.write(config['destPath'])
    text_file.close()

    # write node information
    text_file = open(config['pollDir'] + "nodeInfo.txt", "w")
    json.dump(nodeTypeDict,text_file)
    text_file.close()
    
    # write node list
    text_file = open(config['pollDir'] + "nodeList.txt", "w")
    json.dump(nodeList,text_file)
    text_file.close()
    
    command = '"' + config['graphvizPath'] + '" ' + config['dotCommand'] \
              + "temp.dot > " + config['formatlessVisioFilename']
              #+ "temp.dot > " + config['destPath'] + ".png" 
    print (gString)
    print (command)
    returnCode = os.system(command)
    os.remove("temp.dot")
    print (returnCode)
    
    # start formatter
    formatter = Formatter(config['formatlessVisioFilename'])
    #input(config['destPath'] + config['outputExtension'])
    formatter.start(config['destPath'] + config['outputExtension'])
    time.sleep(1)
Exemple #2
0
from formatter import Formatter

f = Formatter('/media/sf_test-output/temp.vdx')
f.start()