def getFrames(videoPath): frames = [] for line in open(videoPath + '.meta'): if line == '[FRAME]\n': f = frame() elif line == '[/FRAME]\n': frames.append(f) f = None else: var = line.strip().split('=')[0] value = line.strip().split('=')[1] if value.isdigit(): value = int(value) setattr(f, var, value) with open(videoPath, 'rb') as f: data = f.read() f.close() frames.sort(key=attrgetter('pkt_pos')) headerframe = frame() setattr(headerframe, 'pkt_pos', 0) setattr(headerframe, 'pkt_size', frames[0].pkt_pos) frames.insert(0, headerframe) tailframe = frame() setattr(tailframe, 'pkt_pos', frames[-1].pkt_pos + frames[-1].pkt_size) setattr(tailframe, 'pkt_size', len(data) - tailframe.pkt_pos) frames.append(tailframe) for f in frames: f.make_segs(data, args.step) return frames
def ACK_Login(self, Frame_receive): # 1 premier ACK destine au client print "----------------------ACK Login-------------------------" ack = 1 # change the value of ack to 1 roomType = 3 # change the value of roomType to 11(binary)/3(decimal) except Chat messages and user lists, all the others should be made 11 fragment = 0 # usually the ACK frame is too short to be cut, so it's always 0 destinationId = 0 # except Movie Room User list, Message broadcasted to a room, Private message, the others must be flag = self.serverProxy.getUserByName(Frame_receive.data) if flag == None: sequenceNumber = Frame_receive.sequenceNumber msgType = Frame_receive.msgType #print "distribution of New userId in condition of LoginIn et creation de l'utiisateur" userId = self.serverProxy.addUser(Frame_receive.data, "MAIN_ROOM", self) # add the new user to the list print ' the new userId is '+ str(userId) self.sequenceNumber=0 # List of userStore self.userStore.createAndAddUser(Frame_receive.data, "MAIN_ROOM",self,None,userId) self.flag_broadcast[0] = True self.flag_broadcast[1] = 0 dataLength = 0 # in case of ACK, it's thought as zero Frame_send = frame.frame(fragment, ack, msgType, roomType, sequenceNumber, userId, destinationId, dataLength) self.transport.write(logic.logic.ObjectToBinary(Frame_send, "TCP")) # 2 l'envoi de Movie List self.timer_counter = 0 self.sendMovieList(userId) elif Frame_receive.sequenceNumber == 0: # First ACK of Login is lost and resend the this ack sequenceNumber = Frame_receive.sequenceNumber msgType = Frame_receive.msgType #print "distribution of New userId in condition of LoginIn et creation de l'utiisateur" userId = flag.userId print ' the new userId is '+ str(userId) self.sequenceNumber=0 # List of userStore #self.userStore.createAndAddUser(Frame_receive.data, "MAIN_ROOM",None,None,userId) #self.flag_broadcast[0] = True #self.flag_broadcast[1] = 0 dataLength = 0 # in case of ACK, it's thought as zero Frame_send = frame.frame(fragment, ack, msgType, roomType, sequenceNumber, userId, destinationId, dataLength) self.transport.write(logic.logic.ObjectToBinary(Frame_send, "TCP")) # 2 l'envoi de Movie List self.timer.cancel() self.timer_counter = 0 self.sendMovieList(userId) else: sequenceNumber = 0 # duplicate the UserName error msgType = 14 # error messageType dataLength = 1 data = 6 # Invalid Message Frame_send = frame.frame(fragment, ack, msgType, roomType, sequenceNumber, Frame_receive.userId+1, destinationId, dataLength, data) self.transport.write(logic.logic.ObjectToBinary(Frame_send, "TCP"))
def ACK_RoomRequest(self, Frame_receive): # 1 premier ACK destine au client print "----------------------ACK RoomRequest-------------------------" ack = 1 # change the value of ack to 1 roomType = 3 # change the value of roomType to 11(binary)/3(decimal) except Chat messages and user lists, all the others should be made 11 fragment = 0 # usually the ACK frame is too short to be cut, so it's always 0 Movie = self.serverProxy.getMovieById(Frame_receive.destinationId) print "destinationId"+str(Frame_receive.destinationId) if Movie == None: sequenceNumber = Frame_receive.sequenceNumber msgType = 14 #error message movieNumber is wrong destinationId = 0 dataLength = 1 data = 6 # Invalid Message Frame_send = frame.frame(fragment, ack, msgType, roomType, sequenceNumber, Frame_receive.userId+1, destinationId, dataLength, data) self.transport.write(logic.logic.ObjectToBinary(Frame_send, "TCP")) else: self.MovieOpen = [True,Frame_receive.destinationId] #Find the source UserName correspond to UserId in sake of using udateChatroom() for user in self.serverProxy.getUserList(): if user.userId == Frame_receive.userId: name_update = user.userName break # modify(serverProxy) Room status of User to Movie_Room self.serverProxy.updateUserChatroom(name_update, Movie.movieTitle) print "userlist mis a jour dans le serveur proxy"+str(self.serverProxy.getUserList()) # modify(userStore) Ro+om status of User to certain Movie_Room Title self.userStore.updateUserChatRoom(name_update, Movie.movieTitle) print "movie Title"+str(Movie.movieTitle) print "userlist mis a jour dans le user store"+str(self.userStore.getChatRoomUsersList(Movie.movieTitle)) self.flag_broadcast[0] = True self.flag_broadcast[1] = Frame_receive.destinationId sequenceNumber = Frame_receive.sequenceNumber msgType = Frame_receive.msgType #print "distribution of New userId in condition of LoginIn et creation de l'utiisateur" userId = Frame_receive.userId print 'movieIpAddress '+ str(Movie.movieIpAddress) destinationId = Frame_receive.destinationId data = [Movie.moviePort, Movie.movieIpAddress] dataLength = 2+len(Movie.movieIpAddress) # in case of ACK_RoomRequest, it has the content Frame_send = frame.frame(fragment, ack, msgType, roomType, sequenceNumber, userId, destinationId, dataLength, data) self.transport.write(logic.logic.ObjectToBinary(Frame_send, "TCP")) # 2 l'envoi de Movie List self.timer_counter = 0 self.sendUserList(userId ,self, destinationId)
def generateChatMessage(cls,message,sequenceNumber,userId,destinationId,roomType): if roomType == 0: Frame = frame.frame(0,0,logic_client.messageTypeDict['message'],roomType,sequenceNumber,userId,0,len(message),message) elif roomType == 1: Frame = frame.frame(0,0,logic_client.messageTypeDict['message'],roomType,sequenceNumber,userId,destinationId,len(message),message) chat_message = logic.logic.ObjectToBinary(Frame) return chat_message
def generatejoinRoomMessage(cls,movieId,roomType,sequenceNumber,userId): if roomType == 0: Frame = frame.frame(0,0,logic_client.messageTypeDict['Room request'],1,sequenceNumber,userId,movieId,0,"") elif roomType == 1: Frame = frame.frame(0,0,logic_client.messageTypeDict['Room request'],0,sequenceNumber,userId,0,0,"") join_room = logic.logic.ObjectToBinary(Frame) return join_room
def Forward_PrivateChat_sign(self, Frame_receive): # msg-type is 1010 """ :param Frame_receive: the payload after processing by binaryToObject in logic.py called by datagramReceived when it receives a msgType 1010 (Private Chat request) and the roomType is 02 (Private Chat) """ if self.timer_counter_List[userId]< self.timer_num_limit: print "----------------------Forward_PrivateChat-------------------------" """ change the value of roomType to 10(binary)/2(decimal) because this is a private chat message """ roomType = 2 fragment = 0 UserInstance = self.serverProxy.getUserById(Frame_receive.destinationId) print "UserInstance"+str(UserInstance) ack = 0 msgType = 10 #1010 0x0a userId = Frame_receive.destinationId sequenceNumber = self.sequenceNumber[userId] destinationId = Frame_receive.userId dataLength = 0 Frame_send = frame.frame(fragment, ack, msgType, roomType, sequenceNumber, userId, destinationId, dataLength) self.transport.write(logic.logic.ObjectToBinary(Frame_send), UserInstance.userAddress) a = reactor.callLater(self.delay, self.Forward_PrivateChat, Frame_receive) self.timer_List[userId] = a self.timer_counter_List[userId] += 1
def process(self): filename = self.filename_field.get() if (filename == ""): FileNotSelected(self) else: try: text0 = cut.videocuting(filename) size = int(text0[0]) text1 = image.frame(size, text0[1]) text = text0[1] text2 = diff.frame_diff(text0[1]) text = text + "\n" + text2[1] text3 = post.posture(text0[1]) text = text + "\n" + text3[1] vect.vector(text0[1]) #vect.destroy() label1.read_file(text0[1]) label1.result(text0[1]) label1.write_frame(text0[1]) label1.plot(text0[1]) sys.exit() #fnl.final(text0[1]) #print(text3) #text = open(filename).read() self.filename.set("") except IOError: FileNotFoundMessage(self, filename)
def ACK_PrivateChat_sign(self, Frame_receive): """ :param Frame_receive: the payload after processing by binaryToObject in logic.py :param host: the IP address of the source. :param port: the source port. called by datagramReceived when it receives a msgType 1010 Private Chat Request """ # 1 premier ACK destine au client print "----------------------ACK_PrivateChat-------------------------" ack = 1 # change the value of ack to 1 """ change the value of roomType to 10(binary)/2(decimal) because this is a private chat message """ roomType = 2 fragment = 0 # usually the ACK frame is too short to be cut, so it's always 0 UserInstance = self.serverProxy.getUserById(Frame_receive.destinationId) print "UserInstance"+str(UserInstance) sequenceNumber = Frame_receive.sequenceNumber msgType = 8 userId = Frame_receive.destinationId destinationId = Frame_receive.userId dataLength = 0 Frame_send = frame.frame(fragment, ack, msgType, roomType, sequenceNumber, userId, destinationId, dataLength) self.transport.write(logic.logic.ObjectToBinary(Frame_send), UserInstance.userAddress)
def OnInit(self): # wx.InitAllImageHandlers() self.connected = False self.settings = settings.settings() # Crée la frame principale self.frame = frame.frame(None, self, App.title) self.frame.Show(True) self.SetTopWindow(self.frame) self.score = frame_score.frame_score(self.frame) self.score.Show(False) self.son = son.son() self.tour_on = False self.t1 = wx.Timer(self) self.reliquat = reliquat.reliquat() self.onExit = False # Appelle la frame de connexion au début d = dlgconn.dlgconnframe(self) d.ShowModal() if not d.nick: return False self.nick = d.nick self.host = d.host self.port = d.port self.lance_net() return True
def pingoftest(): g = GMIIin("gmiiin.3.dat") rf = ramfile("ram.3.dat") # we generate random length frames and randomly select among mac addresses macaddrs = ["C0:FF:EE:C0:FF:EE", "01:AB:12:34:CD:EF", "FF:FF:FF:FF:FF:FF", "AB:CD:EF:12:34:56"] # and finally, perhaps, a ton of random crap: for j in range(5000): dmac = random.randint(0, 3) d = "" div = [] for i in range(random.randint(50, 60)): r = random.randint(0, 255) d += struct.pack("B", r) if random.randint(0, 10) < 2 : div.append((i, i+random.randint(0,2))) f = frame.frame(macaddrs[dmac], "12:00:3F:00:00:04", 0x0101, d) prelen = random.randint(0, 7) spa = random.randint(2, 10) g.addFrame(f.getWire(preamble=prelen), space=spa) fdata = f.getWire(preamble=0, SFD=False) # just the raw data if dmac != 3: rf.addFrame(fdata[:-4], fdata[-4:])
def receiveFromAbove(self, connectionSocket, ipAddr, message): """ Receives message and destination ip from upper layers, put it into a frame, save this frame and convert it to binary-mode. The converted frame is also saved and fowarded to sendToServer method. """ print(str(dt.now()) + ': receiving message (\'' + message + '\') from upper layer') destMACAddr = '' if ipAddr != 'localhost': destMACAddr = genMACAddr(ipAddr) else: destMACAddr = self.MAC_ADDRESS size = len(message) origPDU = frame(destMACAddr, self.MAC_ADDRESS, message, payloadSize=size, frameType='human') print(str(dt.now()) + ': saving human readable frame') origPDU.writePDU(self.MSGS_FOLDER + 'sent/' + self.FRAME) cvtdPDU = origPDU.convertPDU() print(str(dt.now()) + ': saving binary frame') cvtdPDU.writePDU(self.MSGS_FOLDER + 'sent/' + self.BIN_FRAME) self.sendToServer(connectionSocket, origPDU.payloadSize * 8, self.MSGS_FOLDER + 'sent/' + self.BIN_FRAME)
def tx_host(usrp, tx_streamer, timer_elapsed_event): """Benchmark the transmit chain""" print( " TX freq:%.3f GHz, IQ rate %.3f Msps, gain:%.1f, ant: %s, bandwidth:%.3f MHz,spb:%d", usrp.get_tx_freq() / 1e9, usrp.get_tx_rate() / 1e6, usrp.get_tx_gain(), usrp.get_tx_antenna(), usrp.get_tx_bandwidth() / 1e6, tx_streamer.get_max_num_samps()) # Make a transmit buffer # spb = tx_streamer.get_max_num_samps() spb = 200 buf_length = 120 filename = "bits.txt" sdata = None with open(filename, "rb") as f: sdata = np.fromfile(f, dtype="int8", count=buf_length) # f=fr.frame(sdata) # transmit_buffer=f.frame_to_uhd_buffer(spb) f = fr.frame(sdata) transmit_buffer = f.frame_to_uhd_buffer(spb) metadata = uhd.types.TXMetadata() metadata.time_spec = uhd.types.TimeSpec( usrp.get_time_now().get_real_secs() + INIT_DELAY) metadata.has_time_spec = False print('begin transmit') while not timer_elapsed_event.is_set(): tx_streamer.send(transmit_buffer, metadata) # Send a mini EOB packet metadata.end_of_burst = True tx_streamer.send(np.zeros((1, 0), dtype=np.complex64), metadata)
def ACK_LeaveToMainRoom(self, Frame_receive): print "----------------------ACK_LeaveToMainRoom-------------------------" ack = 1 # change the value of ack to 1 roomType = 0 # change the value of roomType to 11(binary)/3(decimal) except Chat messages and user lists, all the others should be made 11 fragment = 0 # usually the ACK frame is too short to be cut, so it's always 0 for user in self.serverProxy.getUserList(): if user.userId == Frame_receive.userId: name_update = user.userName stopStreamingMovie = user.userChatRoom break Movie = self.serverProxy.getMovieByTitle(stopStreamingMovie) self.flag_broadcast[0] = True self.flag_broadcast[1] = Movie.movieId self.serverProxy.stopStreamingMovie(stopStreamingMovie) self.serverProxy.updateUserChatroom(name_update, "MAIN_ROOM") self.userStore.updateUserChatRoom(name_update, "MAIN_ROOM") sequenceNumber = Frame_receive.sequenceNumber msgType = Frame_receive.msgType userId = Frame_receive.userId destinationId = 0 dataLength = 0 Frame_send = frame.frame(fragment, ack, msgType, roomType, sequenceNumber, userId, destinationId, dataLength) self.transport.write(logic.logic.ObjectToBinary(Frame_send, "TCP")) print "the server has sent for leaving room "+str(roomType) self.sendUserList(userId ,self, destinationId) self.ReturnMainRoom = True
def sendMovieList(self, userId): UserInstance = self.serverProxy.getUserById(userId) print "UserInstance"+str(UserInstance) TCP_Instance = UserInstance.userChatInstance if TCP_Instance.timer_counter< self.timer_num_limit: print "------------------sending Movie list data to the client--------------------" MovieList = self.serverProxy.getMovieList() fragment = 0 ack = 0 msgType = 3 roomType = 3 data = [] dataLength = 0 roomId=1 for movie in MovieList: nameLength = len(movie.movieTitle) data.append([nameLength, movie.movieId, movie.movieTitle]) dataLength = dataLength + 2 + nameLength Frame_send = frame.frame(fragment, ack, msgType, roomType, 0, userId, 0, dataLength, data) # sequenceNumber = 0 self.transport.write(logic.logic.ObjectToBinary(Frame_send, "TCP")) a = reactor.callLater(self.delay, self.sendMovieList, userId) TCP_Instance.timer = a TCP_Instance.timer_counter += 1
def generateDisconnectionMessage(cls,roomType,sequenceNumber,userId): Frame = frame.frame(0,0,logic_client.messageTypeDict['leave_room'],roomType,sequenceNumber,userId, 0, 0,"" ) leave_message = logic.logic.ObjectToBinary(Frame) return leave_message
def Send_msg( self , Frame_receive, finishId): # msg-type is 0001 UserInstance = self.serverProxy.getUserById(finishId) print "UserInstance"+str(UserInstance.userName) TCP_Instance = UserInstance.userChatInstance if TCP_Instance.timer_counter< self.timer_num_limit: print "----------------------Send_msg one to one-------------------------" RoomId = Frame_receive.destinationId if RoomId == 0: roomType = 00 else: roomType = 01 fragment = 0 ack = 0 msgType = 1 #0001 0x01 userId = finishId sequenceNumber = TCP_Instance.sequenceNumber destinationId = Frame_receive.userId dataLength = Frame_receive.dataLength data = Frame_receive.data Frame_send = frame.frame(fragment, ack, msgType, roomType, sequenceNumber, userId, destinationId, dataLength, data) TCP_Instance.transport.write(logic.logic.ObjectToBinary(Frame_send, "TCP")) a = reactor.callLater(self.delay, self.Send_msg, Frame_receive, finishId) TCP_Instance.timer = a TCP_Instance.timer_counter += 1
def generateLoginMessage(cls, userName): messageType = 0 data_length = len(userName) Frame = frame.frame(0,0,0,3,0,0,0,data_length,userName) login_message = logic.logic.ObjectToBinary(Frame) return login_message
def Forward_PrivateChat_msg(self, Frame_receive): # msg-type is 1100 UserInstance = self.serverProxy.getUserById(Frame_receive.destinationId) print "UserInstance"+str(UserInstance) TCP_Instance = UserInstance.userChatInstance if TCP_Instance.timer_counter[userId]< self.timer_num_limit: print "----------------------Forward_PrivateChat-------------------------" roomType = 2 fragment = 0 ack = 0 msgType = 12 #1100 0x0c userId = Frame_receive.destinationId sequenceNumber = TCP_Instance.sequenceNumber destinationId = Frame_receive.userId dataLength = Frame_receive.dataLength data = Frame_receive.data Frame_send = frame.frame(fragment, ack, msgType, roomType, sequenceNumber, userId, destinationId, dataLength, data) TCP_Instance.transport.write(logic.logic.ObjectToBinary(Frame_send, "TCP")) a = reactor.callLater(self.delay, self.Forward_PrivateChat, Frame_receive) TCP_Instance.timer= a TCP_Instance.timer_counter += 1
def ACK_RoomChatMessage(self, Frame_receive): """ :param Frame_receive: the payload after processing by binaryToObject in logic.py :param host: the IP address of the source. :param port: the source port. called by datagramReceived when it receives a msgType 0001 Message or the roomType is not 02 """ print "----------------------ACK_RoomChatMessage-------------------------" ack = 1 # change the value of ack to 1 """ set the roomType to whatever the current room is """ roomType = Frame_receive.roomType fragment = 0 # usually the ACK frame is too short to be cut, so it's always 0 msgType = Frame_receive.msgType sequenceNumber = Frame_receive.sequenceNumber userId = Frame_receive.userId destinationId = Frame_receive.destinationId dataLength = 0 Frame_send = frame.frame(fragment, ack, msgType, roomType, sequenceNumber, userId, destinationId, dataLength) self.transport.write(logic.logic.ObjectToBinary(Frame_send, "TCP"))
def Send_msg( self , Frame_receive, finishId): # msg-type is 0001 """ :param userId: the users numerical user id :param RoomId: flag_broadcast[1]. called by BroadCast_Message to update UserList """ if self.timer_counter_List[finishId]< self.timer_num_limit: print "----------------------Send_msg one to one-------------------------" RoomId = Frame_receive.destinationId if RoomId == 0: roomType = 00 else: roomType = 01 fragment = 0 UserInstance = self.serverProxy.getUserById(finishId) print "UserInstance"+str(UserInstance) ack = 0 msgType = 1 #0001 0x01 userId = finishId sequenceNumber = self.sequenceNumber[userId] destinationId = Frame_receive.userId dataLength = Frame_receive.dataLength data = Frame_receive.data Frame_send = frame.frame(fragment, ack, msgType, roomType, sequenceNumber, userId, destinationId, dataLength, data) self.transport.write(logic.logic.ObjectToBinary(Frame_send), UserInstance.userAddress) a = reactor.callLater(self.delay, self.Send_msg, Frame_receive, finishId) self.timer_List[userId] = a self.timer_counter_List[userId] += 1
def __init__(self, size): self.buffer = [] self.clk = clock() self.dm = diskManager() for i in range(size): self.buffer.append( frame()) # creating buffer frames (i.e., allocating memory) self.buffer[i].frameNumber = i
def sendUserList(self , userId, userChatInstance, RoomId): if userChatInstance.timer_counter< self.timer_num_limit: print "------------------sending User list data to the client--------------------" fragment = 0 ack = 0 msgType = 5 if RoomId == 0: #UserList = self.userStore.getChatRoomUsersList("MAIN_ROOM") UserList = self.serverProxy.getUserList() destinationId=0 roomType = 0 # at the moment, roomtype is 00 for main room data = [] dataLength = 0 for user in UserList: print "userAddress" + str(user.userAddress) nameLength = len(user.userName) data.append([nameLength, user.userId , user.userChatRoom, user.userName]) dataLength = dataLength + 3 + nameLength else: Movie= self.serverProxy.getMovieById(RoomId) print "MovieIP: "+ Movie.movieIpAddress UserList_global = self.serverProxy.getUserList() UserList = [] for user in UserList_global: if user.userChatRoom == Movie.movieTitle: UserList.append(user) #UserList = self.userStore.getChatRoomUsersList(Movie.movieTitle) destinationId=RoomId roomType = 1 # at the moment, roomtype is 01 for movie room data = [] dataLength = 0 for user in UserList: print "user" + str(user) nameLength = len(user.userName) data.append([nameLength, user.userId, user.userChatRoom , user.userName]) dataLength = dataLength + 3 + nameLength TCP_Instance = userChatInstance Frame_send = frame.frame(fragment, ack, msgType, roomType, TCP_Instance.sequenceNumber, userId, destinationId, dataLength, data) TCP_Instance.transport.write(logic.logic.ObjectToBinary(Frame_send, "TCP")) a = reactor.callLater(self.delay, self.sendUserList ,userId, userChatInstance,RoomId) userChatInstance.timer = a userChatInstance.timer_counter += 1
def test1(self): print("====== TEST 1 ======") print( "this only tests the clock algorithm, buffer management features (pin and unpin) are not tested." ) status = True print("1) Creating a smaple buffer of five frames\n") buf = [] for i in range(5): buf.append(frame()) buf[0].pinCount = 1 buf[0].referenced = 1 buf[1].pinCount = 0 buf[1].referenced = 1 buf[2].pinCount = 1 buf[2].referenced = 1 buf[3].pinCount = 1 buf[3].referenced = 1 buf[4].pinCount = 0 buf[4].referenced = 1 # Consider the above buffer. # The clock algorithm starts at frame 0 (buf[0]) and tries to find a frame with pinCount =0 # Clock finds buf[1], flips buf[1].referenced to 0 and continue # Clock finds buf[4], flips buf[4].referenced to 0 and continue # Clock finds buf[1] again and choose it print("2) Call the clock algorithm") clk = clock() if clk.pickVictim(buf) != 1: print(".... Error: clock algorithm did not chose frame 1.\n") status = False return status else: print(".... clock algorithm chose frame 1 successfully.") if buf[1].referenced != 0 or buf[4].referenced != 0: print( ".... Error: clock algorithm did not update referenced attribute correctly.\n" ) status = False return status else: print( ".... Clock algorithm updated referenced attribute correctly.\n" ) print("Test 1 completed successfully....\n") return status
def AppSingleton(pid_file, message=None): '''Singleton for Application''' g = frame.frame(-1).f_globals fp = open(pid_file, 'w') g["singleton_fp"] = fp try: fcntl.lockf(fp, fcntl.LOCK_EX | fcntl.LOCK_NB) except IOError: print(message or "Another instance exist, quit now") os._exit(0)
def simpleTest(): g = GMIIin("gmiiin.0.dat") rf = ramfile("ram.0.dat") destaddr = "C0:FF:EE:C0:FF:EE" srcaddr = "12:00:3F:00:00:04" prelen = 7 space = 10 # 1. Nominal frame data = "01234567" f = frame.frame(destaddr, srcaddr, 0x0101, data) g.addFrame(f.getWire(preamble=prelen), space=space) fdata = f.getWire(preamble=0, SFD=False) # just the raw data rf.addFrame(fdata[:-4], fdata[-4:]) # 2. Invalid CRC data = "0123456789AB" f = frame.frame(destaddr, srcaddr, 0x0101, data) outdata = f.getWire(preamble=prelen) outdata= outdata[:-5] + 'Z' + outdata[-4:] g.addFrame(outdata, space=space) # frames of various lengths data = "01234567" for i in range(20, 24): data += chr(i) f = frame.frame(destaddr, srcaddr, 0x0101, data) g.addFrame(f.getWire(preamble=prelen), space=space) fdata = f.getWire(preamble=0, SFD=False) # just the raw data rf.addFrame(fdata[:-4], fdata[-4:])
def binaryToObject(cls, stream): print "--------------------Binary to objet---------------------------" info = struct.unpack_from('!BBBBH', stream) firstByte = info[0] sequenceNumber = info[1] userId = info[2] destinationId = info[3] dataLength = info [4] #objectTotal = struct.unpack_from('BBBBH'+str(dataLength)+'s', stream) #data = objectTotal[5] print "sequenceNumber: "+ str(sequenceNumber) #Treating the first byte to get info print "firstByte:"+str(firstByte) fragment = firstByte >> 7 print "fragmentation:"+str(fragment) workingByte = firstByte - (fragment << 7) ack = workingByte >> 6 print "ack:"+str(ack) workingByte = workingByte - (ack << 6) msgType = workingByte >> 2 print "msgType:"+str(msgType) workingByte = workingByte - (msgType << 2) roomType = workingByte print "roomType:"+str(roomType) #getting the data print "dataLength:"+str(dataLength) if (dataLength > 0) & (ack == 0): data = cls.dataFunDict_get[msgType](stream, dataLength) elif (dataLength > 0) & (ack == 1) & (msgType == 14) : data = cls.dataFunDict_get[msgType](stream, dataLength) elif (dataLength > 0) & (ack == 1) & (msgType == 8) : data = cls.dataFunDict_get[msgType](stream, dataLength) else: data = '' print "UserID: "+ str (userId) print "Data: "+ str(data) # composer un trame en condition que frame est deja importe Frame = frame.frame(fragment, ack, msgType, roomType, sequenceNumber, userId, destinationId, dataLength, data) return Frame
def ACK_Disconnection(self,Frame_receive): print"-------------------------------------acknoledging disconnection----------------------" ack = 1 # change the value of ack to 1 roomType = 3 # change the value of roomType to 11(binary)/3(decimal) except Chat messages and user lists, all the others should be made 11 fragment = 0 # usually the ACK frame is too short to be cut, so it's always 0 for user in self.serverProxy.getUserList(): if user.userId == Frame_receive.userId: name_update = user.userName break self.serverProxy.removeUser(name_update) #self.serverProxy.updateUserChatroom(name_update, "OUT_OF_THE_SYSTEM_ROOM") self.userStore.updateUserChatRoom(name_update, "OUT_OF_THE_SYSTEM_ROOM") #print "Rest of the UserList: ",self.serverProxy.getUserList() sequenceNumber = Frame_receive.sequenceNumber msgType = Frame_receive.msgType userId = Frame_receive.userId destinationId = 0 dataLength = 0 Frame_send = frame.frame(fragment, ack, msgType, roomType, sequenceNumber, userId, destinationId, dataLength) self.transport.write(logic.logic.ObjectToBinary(Frame_send, "TCP")) print "------------------Broadcast User list update--------------------" UserList = self.serverProxy.getUserList() new_userList = [] print "------------------Broadcast User list in main room update--------------------" print "userList: " + str(UserList) for user in UserList: if (user.userChatRoom == 'MAIN_ROOM'): new_userList.append(user) print "len MainRoom_BroadCast" + str(new_userList) for user in new_userList: UserInstance = self.serverProxy.getUserById(user.userId) TCP_Instance = UserInstance.userChatInstance TCP_Instance.timer_counter = 0 self.sendUserList(user.userId ,user.userChatInstance, 0)
def sendToAbove(self, cvtdPDUPath): """Sends given frame (which path is pointed by cvtdPDUPath) to upper layers""" print(str(dt.now()) + ': sending the received message for upper layer') cvtdPDU = frame('', '', '', frameType='bin') cvtdPDU.readPDU(cvtdPDUPath) origPDU = cvtdPDU.deconvertPDU() print(str(dt.now()) + ': saving human-readable frame') origPDU.writePDU(self.MSGS_FOLDER + 'received/' + self.FRAME) print(str(dt.now()) + ': the message received was: \'' + origPDU.payload + '\'') # url = "http://localhost:3000/receive_message" url = "http://localhost:10524/receivemessagephycli/teste" data = {'msg': origPDU.payload} headers = {'Content-type': 'application/json', 'Accept': 'text/plain'} r = requests.post(url=url, data=json.dumps(data), headers=headers) print("sendToAbove")
def ACK_PrivateChat_msg(self, Frame_receive): # 1 premier ACK destine au client print "----------------------ACK_PrivateChat-------------------------" ack = 1 # change the value of ack to 1 roomType = 2 # change the value of roomType to 10(binary)/1(decimal) except Chat messages and user lists, all the others should be made 11 fragment = 0 # usually the ACK frame is too short to be cut, so it's always 0 sequenceNumber = Frame_receive.sequenceNumber msgType = Frame_receive.msgType userId = Frame_receive.userId destinationId = Frame_receive.destinationId dataLength = 0 Frame_send = frame.frame(fragment, ack, msgType, roomType, sequenceNumber, userId, destinationId, dataLength) self.transport.write(logic.logic.ObjectToBinary(Frame_send, "TCP")) self.Forward_PrivateChat_msg(Frame_receive)
def get_next_frame(RENDERED_FRAMES): try: current_frame = RENDERED_FRAMES[get_current_frame_id()] if not (current_frame.tick == len(RENDERED_FRAMES) - 1): # if current is not the latest frame (we are repeating our steps) set_current_frame_id(current_frame.tick + 1) return RENDERED_FRAMES[get_current_frame_id()] else: update_angle_target() new_angle = LATEST_PUB_ANGLE curr_tick = current_frame.tick + 1 new_frame = frame(tick=curr_tick, target_angle=new_angle) RENDERED_FRAMES.append(new_frame) set_current_frame_id(curr_tick) return new_frame except Exception as frame_exception: print frame_exception sys.exit(1)
def OnInit(self) : # wx.InitAllImageHandlers() self.connected = False self.settings = settings.settings() # Crée la frame principale self.frame = frame.frame(None, self, App.title) self.frame.Show(True) self.SetTopWindow(self.frame) self.score = frame_score.frame_score(self.frame) self.score.Show(False) self.son = son.son() self.tour_on = False self.t1 = wx.Timer(self) # Appelle la frame de connexion au début self.d = dlgconn.dlgconnframe(self.frame, self) self.d.Show() self.d.MakeModal(True) self.reliquat = reliquat.reliquat() self.onExit = False return True
def push(self): ''' 为新函数重新分配虚拟寄存器 ''' self.initregTable(self.generateRegTable()) fm = frame(self.regTable) fm.funcionName = self.methodName self.stack.push(fm) self.stack.esp = len(self.stack.stack) - 1 #获取栈顶指针 if self.stack.esp - 1 > -1: #判断栈的深度是否为0,如果为0则说明是主函数执行阶段。 in_reg = len(self.stack.stack[self.stack.esp - 1].out_reg) for rrr in self.stack.stack[self.stack.esp - 1].out_reg: logging.info("[DVM] - out_reg==>%s 污点属性:%s" % (rrr.name, rrr.isTained)) if self.stack.methodCallType == "invoke-virtual": if in_reg == 1: r0 = register("p0", "") #相当于this指针,用于获取上下文信息 r1 = register("p1", "") r1.isTained = self.stack.stack[self.stack.esp - 1].out_reg[0].isTained self.stack.stack[self.stack.esp].localvars.append(r0) self.stack.stack[self.stack.esp].localvars.append(r1) elif in_reg > 1: for i in range(1, in_reg): r = register("p%d" % i, "") r.isTained = self.stack.stack[self.stack.esp - 1].out_reg[i].isTained self.stack.stack[self.stack.esp].localvars.append(r) else: pass else: #针对static和direct引用 for i in range(in_reg): r = register("p%d" % i, "") r.isTained = self.stack.stack[self.stack.esp - 1].out_reg[i].isTained self.stack.stack[self.stack.esp].localvars.append(r) logging.info("[DVM] - esp==>%s" % self.stack.esp) logging.info("[DVM] - 函数==>%s" % self.methodName) for reg in self.stack.stack[self.stack.esp].localvars: logging.info("[DVM] - 寄存器名:%s,污点属性:%s" % (reg.name, reg.isTained))
def ACK_PrivateChat_sign(self, Frame_receive): # 1 premier ACK destine au client print "----------------------ACK_PrivateChat-------------------------" ack = 1 # change the value of ack to 1 roomType = 2 # change the value of roomType to 10(binary)/1(decimal) except Chat messages and user lists, all the others should be made 11 fragment = 0 # usually the ACK frame is too short to be cut, so it's always 0 UserInstance = self.serverProxy.getUserById(Frame_receive.destinationId) print "UserInstance"+str(UserInstance) TCP_Instance = UserInstance.userChatInstance sequenceNumber = Frame_receive.sequenceNumber msgType = 8 userId = Frame_receive.destinationId destinationId = Frame_receive.userId dataLength = 0 Frame_send = frame.frame(fragment, ack, msgType, roomType, sequenceNumber, userId, destinationId, dataLength) TCP_Instance.transport.write(logic.logic.ObjectToBinary(Frame_send, "TCP"))
def writeFrame(self, length, destMAC = "C0:FF:EE:01:02:03", wronglenval = 0 ): # writes a frame with the above-indicated error conditions data = "" for i in range(length): data += struct.pack("B", random.randint(0, 255)) srcMAC = "%02X:%02X:%02X:%02X:%02X:%02X" % \ (random.randint(0,255), random.randint(0,255), random.randint(0,255), random.randint(0,255), random.randint(0,255), random.randint(0,255)) f = frame.frame(destMAC, srcMAC, 0x0101, data) fdataall = f.getWire(preamble=0, SFD=False) fdata = fdataall self.dfid.write(len(fdata), fdata) self.gfid.write(f)
def test(): conf = dbConfig.dbConfig() host = conf.Obj['host'] port = conf.Obj['port'] testDB = dbConfig.test print 'Host: ' + host print 'Port: ' + str(port) test = frame.frame(host,port,testDB) key1 = 'key1' key2 = 'key2' value1 = 'value1' value2 = 'value2' print 'Append to NonExistent Key (F): ' + str(test.append(key1,value1)) print 'Create New Key (T): ' + str(test.store(key1,value1)) print 'Append to Existent Key (T): ' + str(test.append(key1,value2, ',')) print 'Print Appended Key value ("value1,value2"): ' + str(test.check(key1)) print 'Check Key exists (T): ' + str(test.exists(key1)) print 'Delete Key (T): ' + str(test.delete(key1)) print 'Check NonExistent Key (F): ' + str(test.exists(key1))
def genRobot(self): if self.kind == 'SA': jList = ['S', 'L', 'U', 'R', 'B', 'T', 'F'] else: jList = ['S', 'L', 'U', 'R', 'B', 'T', 'F'] Tw = np.diag(np.ones(4, dtype=np.double)) params = {} params['col'] = self.col for j in range(len(self.DHparams)): if self.kind == 'SA': Tcurr = DH.getTCraig2(self.homePose[j], **self.DHparams[jList[j]]) else: Tcurr = DH.getTSaha2(self.homePose[j], **self.DHparams[jList[j]]) Tw = np.matmul(Tw, Tcurr) params['name'] = jList[j] params['TWorld'] = Tw self.linkFrames[jList[j]] = frame.frame(**params) self.nrk.ConstructFrame(self.col, jList[j], Tcurr) self.nrk.SetWorkingFrame(self.col, jList[j]) self.nrk.SetWorkingFrame("A", "World") self.currPose = self.homePose
def writeFrame(self, length, RXErrors=False, CRCvalid=True, preamble=7, readShort=0, nop=0, destMAC = "C0:FF:EE:01:02:03"): # writes a frame with the above-indicated error conditions data = "" for i in range(length): data += struct.pack("B", i% 256) srcMAC = "%02X:%02X:%02X:%02X:%02X:%02X" % \ (random.randint(0,255), random.randint(0,255), random.randint(0,255), random.randint(0,255), random.randint(0,255), random.randint(0,255)) f = frame.frame(destMAC, srcMAC, 0x0101, data) fdata = f.getWire(preamble=preamble) if not CRCvalid: fdata = fdata[:-7] + "\x22" + fdata[-6:] g = GMIIin(); g.setData(fdata) if RXErrors: g.addER((10,11)) self.gfid.write(g) self.gfid.writeempty(int(len(fdata)*0.07)) if (not RXErrors) and CRCvalid : d = f.getWire(preamble=0, SFD=False) # include the crc self.dfid.write(nop, (len(d) + 1)/2 - readShort+1, d)
if __name__ == '__main__': config = ConfigParser.ConfigParser() config.read('/mnt/sdc1/wenhaoli/Learning-to-Group/code/config.ini') a = Dataset.identity_Dataset(config) train_album_list_fn = config.get('REID', 'TRAIN_ALBUM_LIST_FILE') a.loadAlbumList(train_album_list_fn) data = list(list()) data.append([0, 0, 0]) rb_p2p = ReplayBufferSimple(size=1000) rb_p2g = ReplayBufferSimple(size=1000) rb_g2g = ReplayBufferSimple(size=1000) rbs = [rb_p2p, rb_p2g, rb_g2g] f = frame.frame(rbs) if not os.path.exists(config.get('REID', 'REWARD_P2P_MODEL_TRAIN_DATA')): f.preTrainData(1000) f.init_replay_buffer_from_file() model_p2p = SGDClassifier(loss='modified_huber') model_p2g = SGDClassifier(loss='modified_huber') model_g2g = SGDClassifier(loss='modified_huber') models = [model_p2p, model_p2g, model_g2g] print('...train reward model...') start = time.time() for iteration in tqdm(range(1, 201)): # print '=====================================================' # print 'Iter: %d' % iteration if iteration % 10 == 0:
def createCanvas(): newWindow = Toplevel() newWindow.geometry("500x500") newCanvas = canvas(newWindow, values_json["canvas"][0], values_json["canvas"][1]) entry1 = entry(newWindow, values_json["entry1"][0], newCanvas) entry1.render(values_json["entry1"][1]) buttonCanvas = button(newWindow, entry1.getTextVal, values_json["buttonCanvas"][0], values_json["buttonCanvas"][1]) content = frame(root, values_json["content"][0], values_json["content"][1]) tree = treeview(content.getObject()) tree.addFile("a1.h5") tree.addFile("a1.h5") frame = frame(content.getObject(), values_json["frame"][0], values_json["frame"][1]) frame1 = frame.getObject() button1 = button(frame1, frame1.quit, values_json["button"][0], values_json["button"][1]) label = label(content.getObject(), values_json["label"][0], values_json["label"][1]) # entry = entry(content.getObject(), values_json["entry"][0], values_json["entry"][1]) # entry.render() textBig = text(content.getObject(), values_json["textBig"][0], values_json["textBig"][1]) buttonPrintEntry = button(frame1, entry.getTextVal,
pub = rospy.Publisher('error', pid_input, queue_size=1) Builder.load_file("Sim.kv") Config.set('graphics', 'width', '1400') Config.set('graphics', 'height', '720') Config.set('graphics', 'resizable', False) class SAVE_OPTIONS(Enum): NO = 1 FAILURE = 2 SUCCESS_FAILURE = 3 RENDERED_FRAMES = [frame()] CURRENT_FRAME_ID = 0 LATEST_PUB_ANGLE = 0 SAVE_TRIGGER = SAVE_OPTIONS.NO MAP_SELECTION = 1 TARGET_CENTER = [] STATUS_LABEL = "UNDETERMINED" LIDAR_TO_CAR_ANGLE = 45 # degrees LIDAR_RANGE = meters_to_pixels(2.5) CAMERA_RANGE = meters_to_pixels(4) SAVE_FILE = False FRAME_RATE = 60 TRACE_ROUTE = True STARTING_POSITION = [100, 100] SIM_FLAG = False PHOTO_FRAME_COUNT = 0
def test1(self): print("====== TEST 1 ======") print("this only tests the clock algorithm, buffer management features (pin and unpin) are not tested.") status = True print("1) Creating a sample buffer of five frames\n") thisBuffer = bufferManager buf = [] for i in range(5): buf.append(frame()) buf[0].pinCount = 1 buf[0].referenced = 1 buf[0].frameNumber = 0 buf[1].pinCount = 0 buf[1].referenced = 1 buf[1].frameNumber = 1 buf[2].pinCount = 1 buf[2].referenced = 1 buf[2].frameNumber = 2 buf[3].pinCount = 1 buf[3].referenced = 1 buf[3].frameNumber = 3 buf[4].pinCount = 0 buf[4].referenced = 1 buf[4].frameNumber = 4 # Consider the above buffer. # The clock algorithm starts at frame 0 (buf[0]) and tries to find a frame with pinCount =0 # Clock finds buf[1], flips buf[1].referenced to 0 and continue # Clock finds buf[4], flips buf[4].referenced to 0 and continue # Clock finds buf[1] again and choose it """ for i in range(0,5): print("Buf",i, "PinCount: ",buf[i].pinCount,"\n","referenced ", buf[i].referenced,"\n", "frameNumber ",buf[i].frameNumber,"\n") """ print("2) Call the clock algorithm") clk = clock() victim = clk.pickVictim(buf) #print(type(victim)) if victim != 1: print(victim) for i in range(0, 5): print("Buf", i, "PinCount: ", buf[i].pinCount, "\n", "referenced ", buf[i].referenced, "\n", "frameNumber ", buf[i].frameNumber, "\n") print(".... Error: clock algorithm did not chose frame 1.\n") status = False return status else: print(".... clock algorithm chose frame 1 successfully.") if buf[1].referenced != 0 or buf[4].referenced != 0: print(".... Error: clock algorithm did not update referenced attribute correctly.\n") status = False return status else: print(".... Clock algorithm updated referenced attribute correctly.\n") print("Test 1 completed successfully....\n") return status
def ack_message(cls,sequenceNumber, msgType,userId): Frame = frame.frame(0,1,msgType,3,sequenceNumber,userId,0,0,"") ack_message = logic.logic.ObjectToBinary(Frame) return ack_message
if __name__=='__main__': a=Dataset.identity_Dataset() a.loadAlbumList('albumList_train') data=list(list()) data.append([0,0,0]) iteration=1 while iteration<5000: print '=====================================================' print 'Iter: %d'%iteration iteration+=1 dataset=a.SimulateDataset(1000,0.6,0.4) dataset.computeQuality() dataset.computeAffinity() f=frame.frame() f.loadDataset(dataset) model_p2p=svm_load_model('model/model_p2p.model') model_p2G=svm_load_model('model/model_p2G.model') model_G2G=svm_load_model('model/model_G2G.model') index=1 while f.checkState(): package=f.getObservation() if type(package)==int: print 'Done!' break data[0]=package question_type=len(package) if question_type==3: #point-----point action,t1,t2=svm_predict([0],data, model_p2p) tp='P2P'
import numpy as np import math import random import matplotlib.pyplot as plt from Car import Car from frame import frame if __name__ == '__main__': t = 0.0 dt = 0.01 # Instances cadre = frame([0, 0], math.pi / 120, 4, 4) obj1 = frame([-1.5, 0.9], math.pi / 3, 0.5, 0.3) obj2 = frame([0.25, -1.0], math.pi / 15, 0.5, 0.5) obj3 = frame([1.0, 1.1], math.pi / 4, 0.4, 0.4) voiture = Car(lag=0.15, ang=50) #Objet figure Fig = plt.gcf() # Demarrer voiture.speed = 2.0 remain_delay = 0.0 poursuivre = 1 t_final = 10.0 read = 0 while poursuivre == 1:
if flag == None: sequenceNumber = Frame_receive.sequenceNumber msgType = Frame_receive.msgType #print "distribution of New userId in condition of LoginIn et creation de l'utiisateur" userId = self.serverProxy.addUser(Frame_receive.data, "MAIN_ROOM", None ,(host, port)) # add the new user to the list print ' the new userId is '+ str(userId) self.sequenceNumber[userId] = 0 # List of userStore self.userStore.createAndAddUser(Frame_receive.data, "MAIN_ROOM",None,None,userId) self.flag_broadcast[0] = True self.flag_broadcast[1] = 0 dataLength = 0 # in case of ACK, it's thought as zero Frame_send = frame.frame(fragment, ack, msgType, roomType, sequenceNumber, userId, destinationId, dataLength) self.transport.write(logic.logic.ObjectToBinary(Frame_send), (host, port)) # 2 l'envoi de Movie List self.timer_counter_List[userId] = 0 self.sendMovieList(userId, (host, port)) elif Frame_receive.sequenceNumber == 0: # First ACK of Login is lost and resend the this ack sequenceNumber = Frame_receive.sequenceNumber msgType = Frame_receive.msgType #print "distribution of New userId in condition of LoginIn et creation de l'utiisateur" userId = flag.userId print ' the new userId is '+ str(userId) self.sequenceNumber[userId]=0 # List of userStore #self.userStore.createAndAddUser(Frame_receive.data, "MAIN_ROOM",None,None,userId)
from frame import frame import time frame("video1","v1") time.sleep(1) frame("video1","v2")
def BroadCast_Message(self, Frame_receive): """ :param Frame_receive: the payload after processing by binaryToObject in logic.py called by datagramReceived when it receives a msgType 0001 (Message) or the roomType is not equal to 02 (Private Chat) """ print "------------------Broadcast Message update--------------------" UserList = self.serverProxy.getUserList() new_userList = [] RoomId = Frame_receive.destinationId userId = Frame_receive.userId if RoomId == 0: print "userList: " + str(UserList) if len(UserList) > 1: for user in UserList: if (user.userChatRoom == 'MAIN_ROOM') & (user.userId != userId): new_userList.append(user) print "len MainRoom_BroadCast_List" + str(new_userList) for user in new_userList: self.timer_counter_List[user.userId] = 0 self.Send_msg(Frame_receive, user.userId) else: print "No BroadCast" else: # Movie Room update UserList print "userList: " + str(UserList) Movie = self.serverProxy.getMovieById(RoomId) if len(UserList) > 1: for user in UserList: if (user.userChatRoom == Movie.movieTitle) & (user.userId != userId): new_userList.append(user) print "len MovieRoom_BroadCast: " + str(new_userList) print "MovieTitle"+ Movie.movieTitle for user in new_userList: self.timer_counter_List[user.userId] = 0 self.Send_msg(Frame_receive, user.userId) else: print "No BroadCast" def Forward_PrivateChat_sign(self, Frame_receive): # msg-type is 1010 """ :param Frame_receive: the payload after processing by binaryToObject in logic.py called by datagramReceived when it receives a msgType 1010 (Private Chat request) and the roomType is 02 (Private Chat) """ if self.timer_counter_List[userId]< self.timer_num_limit: print "----------------------Forward_PrivateChat-------------------------" """ change the value of roomType to 10(binary)/2(decimal) because this is a private chat message """ roomType = 2 fragment = 0 UserInstance = self.serverProxy.getUserById(Frame_receive.destinationId) print "UserInstance"+str(UserInstance) ack = 0 msgType = 10 #1010 0x0a userId = Frame_receive.destinationId sequenceNumber = self.sequenceNumber[userId] destinationId = Frame_receive.userId dataLength = 0 Frame_send = frame.frame(fragment, ack, msgType, roomType, sequenceNumber, userId, destinationId, dataLength) self.transport.write(logic.logic.ObjectToBinary(Frame_send), UserInstance.userAddress) a = reactor.callLater(self.delay, self.Forward_PrivateChat, Frame_receive) self.timer_List[userId] = a self.timer_counter_List[userId] += 1 def Forward_PrivateChat_msg(self, Frame_receive): # msg-type is 1100 """ :param Frame_receive: the payload after processing by binaryToObject in logic.py called by ACK_PrivateChat_msg when it receives a msgType 1100 (Message Forward) """ if self.timer_counter_List[userId]< self.timer_num_limit: print "----------------------Forward_PrivateChat-------------------------" roomType = 2 fragment = 0 UserInstance = self.serverProxy.getUserById(Frame_receive.destinationId) print "UserInstance"+str(UserInstance) ack = 0 msgType = 12 #1100 0x0c userId = Frame_receive.destinationId sequenceNumber = self.sequenceNumber[userId] destinationId = Frame_receive.userId dataLength = Frame_receive.dataLength data = Frame_receive.data Frame_send = frame.frame(fragment, ack, msgType, roomType, sequenceNumber, userId, destinationId, dataLength, data) self.transport.write(logic.logic.ObjectToBinary(Frame_send), UserInstance.userAddress) a = reactor.callLater(self.delay, self.Forward_PrivateChat, Frame_receive) self.timer_List[userId] = a self.timer_counter_List[userId] += 1
def loadSimulate(self, dataset): f = frame.frame(training=False) f.loadDataset(dataset) self.frame = f self.dataset = dataset
from frame import frame monApp = frame()
show_dir = "./shows/" + show_dir print "Creating show for directory: %s" % show_dir s = show() s.load_path(show_dir) s.start_observer() shows.append(s) # This merely contains show names theframe.shows.append(os.path.basename(show_dir)) print "Numbers of shows is NOW: %s" % len(shows) dmsg("List of shows was rebuilt") factory.dispatch("http://localhost/status",'show-list-rebuilt') # An instance of the frame class, intended to be used as a signleton theframe = frame() shows = [] scan_for_shows() print "Setting up observer for SHOWS DIRECTORY" showchange_event_handler = MyEventHandler() showobserver = Observer() showobserver.schedule(showchange_event_handler, "./shows", recursive=True) showobserver.start() print "assigning show shortcuts" theframe.activeshow = shows[0] theshow = shows[0] print "Current active path after loading: %s" % theframe.activeshow.path
""" Created on Thu Oct 19 20:44:21 2017 @author: itay """ import matplotlib.pyplot as plt from frame import Frame as frame import grid_functions as gf import numpy as np k_b = 1.38064852e-23 # Boltzmann constant T=313 sumcoll =0; gridcoll =0; test_frame = frame(1024) nimber_of_frmes = 1 M=36 for i in range(nimber_of_frmes): test_frame.load_next_frame() lipid_grid = gf.create_lipid_grid_closest2(test_frame.bilayer.upper,M, test_frame.box_size) director_grid = gf.create_director_grid(lipid_grid,M, test_frame.box_size) lipid_grid2 = gf.create_lipid_grid_closest2(test_frame.bilayer.lower,M, test_frame.box_size) director_grid2 = gf.create_director_grid(lipid_grid2,M, test_frame.box_size) director_grid3 = 0.5*(director_grid-director_grid2) gf.normalize_grid(director_grid3,M)
def loadSimulate(self,dataset): f=frame.frame() f.loadDataset(dataset) self.frame=f self.dataset=dataset
#!/usr/bin/python3 import frame import logging, logging.config import cProfile import signal def signal_handler(signal, frame_py): global logging, frame print() # clear the signal written to terminal (eg ^C) logging.debug("sig:" + str(signal)) logging.debug("Will now shutdown") frame.shutdown() logging.config.fileConfig("etc/logging.conf") signal.signal(signal.SIGINT, signal_handler) frame = frame.frame() frame.main_loop()