def format_all_branch_data(data): tmp=copy.deepcopy(feature_collection) for i in get_all_data(): all_data[i['No']-1]=i for item in branch_data: tmp3=format_Branch_data(item[0],item[1],item[2],all_data[item[1]-1],all_data[item[2]-1]) BRANCH[item[0]-1]=tmp3["properties"] if item[0]==1: tmp3["properties"]['status']=0 tmp3["properties"]['powerLevel']=random.randrange(1,4) tmp['features'].append(tmp3) return tmp
def format_all_branch_data(data): tmp = copy.deepcopy(feature_collection) for i in get_all_data(): all_data[i['No'] - 1] = i for item in branch_data: tmp3 = format_Branch_data(item[0], item[1], item[2], all_data[item[1] - 1], all_data[item[2] - 1]) BRANCH[item[0] - 1] = tmp3["properties"] if item[0] == 1: tmp3["properties"]['status'] = 0 tmp3["properties"]['powerLevel'] = random.randrange(1, 4) tmp['features'].append(tmp3) return tmp
def get_all_branch(request): tmp=format_all_branch_data(get_all_data()) return HttpResponse(json.dumps(tmp))
s.connect((ip,6399+_id)) x=struct.pack('3i',_id,type,0) s.send(x) s.close() if(type==2): op='shutdown bus' else: op='start bus' ty=1 elif type==3 or type==4: print _id,type,branch_data[_id] bus1=socket.socket() bus1.connect((ip,6399+branch_data[_id][1])) x=struct.pack('3i',branch_data[_id][1],type,_id,) bus1.send(x) bus1.close() if(type==3): op='shutdown branch' else: op='start branch' ty=2 return HttpResponse("success") def get_load_history(): return [[float('%.4f'%(120+random.random()*30)) for i in range(7)] for k in range(4)] def get_gen_history(): return [[float('%.4f'%(120+random.random()*30)) for i in range(7)] for k in range(4)] def get_branch_history(): return [[float('%.4f'%(120+random.random()*30)) for i in range(7)] for k in range(4)] import cPickle format_all_bus_data(get_all_data())
def get_all_bus(request): tmp=format_all_bus_data(get_all_data()) #print tmp return HttpResponse(json.dumps(tmp))
def get_all_bus(request): tmp = format_all_bus_data(get_all_data()) #print tmp return HttpResponse(json.dumps(tmp))