WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 12-16-2010, 08:08 PM
psykoko psykoko is offline
Member
 
Join Date: Dec 2010
Posts: 9
attach my code
Code:
import viz
import vizmat
import vizinfo
import socket
import struct
viz.go()
viz.mouse.setVisible(viz.OFF)



#The maximum amount of data to receive at a time
MAX_DATA_SIZE = 1024

#The port to send/receive data on
PORT = 8000

#Get the name of this computer
COMPUTER_NAME = socket.gethostname()

#Get the IP address of this computer
COMPUTER_IP_ADDRESS = socket.gethostbyname('localhost')

#Create a socket to send data over
OutSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
OutSocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

#Create a socket to receive data from
InSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
InSocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
InSocket.bind(('', PORT))
InSocket.setblocking(0)
viz.directormode(viz.DIRECTOR_FAST)

def SendData(data):
	OutSocket.sendto(data,(COMPUTER_IP_ADDRESS,PORT))
	
def ReceiveData():
	try:
		return InSocket.recvfrom(MAX_DATA_SIZE)
	except:
		pass

def onkeydown(key):
	if key == ' ':
		#Send data over the socket
		SendData('hello there')

viz.callback(viz.KEYDOWN_EVENT,onkeydown)


def ontimer(num):
	#Try to receive data from socket
	data = ReceiveData()
	if data:
		udp = struct.unpack(">d", data[0][:8])[0]
		right = open('c:\\new\\new.txt', 'a+')
		right.write(str(udp)+'\n')
		print 'Received Message:',udp

viz.callback(viz.TIMER_EVENT,ontimer)
viz.starttimer(0,0,viz.FOREVER)
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Use saved text file data as replay sources problem mizutani_jun Vizard 4 10-14-2010 04:49 PM
Using 5DT plug-in with the data coming through network... mcicek Vizard 1 05-18-2009 05:17 PM
Flagging the Data Elittdogg Vizard 5 04-11-2008 11:40 AM
Data Files betancourtb82 Vizard 6 05-04-2006 02:43 PM
tracking using quaternarion data jfreeman Vizard 2 06-01-2005 08:48 AM


All times are GMT -7. The time now is 10:38 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC