WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 01-27-2014, 07:49 PM
mikeb mikeb is offline
Member
 
Join Date: Jan 2014
Posts: 2
Saving a variable through network

Hello,

I'm relatively new to Vizard and was seeking advise on a project I'm working on.

I have a control program written in MatLab which I was hoping to communicate with a Vizard program. Ideally I would like to save a variable that can be used in Vizard which is sent from MatLab. I have become familiar with the basic networking commands and am able to send and retrieve data back and fourth.
For example using the below code I was able to retrieve data from MatLab.

myNetwork = viz.addNetwork('IP here')
myNetwork.port(4950)
def onNetwork(e):
if isinstance(e,viz.RawNetworkEvent):
print e.raw_data
viz.callback(viz.NETWORK_EVENT,onNetwork)

Is there an easy way to save this data as a variable to be used in a Vizard Script?

Thank you for your time, I hope I explained things as clearly as possible and I apologize if this is an extremely basic question.
Reply With Quote
  #2  
Old 01-31-2014, 11:48 PM
Frank Verberne Frank Verberne is offline
Member
 
Join Date: Mar 2008
Location: Netherlands
Posts: 148
Hi mikeb,

When starting with Vizard, it's good to ask basic questions, so not worries. What you could try is instead of printing the raw data, you can assign that raw data to a variable in Vizard. I don't now the nature of your raw data, so maybe you need to assign one specific part of the raw data to a variable, but the principle is the same:
Code:
myNetwork = viz.addNetwork('IP here')
myNetwork.port(4950)
def onNetwork(e):
	if isinstance(e,viz.RawNetworkEvent):
		 your_variable = e.raw_data
viz.callback(viz.NETWORK_EVENT,onNetwork)
For next time, it's better to use the CODE tags around your code to make it more readable. You can get those tags by clicking the hashtag (#) sign in the editing options for your message.

Good luck,
Frank
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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
Display a variable in main graphics window laker Vizard 2 09-17-2013 12:56 PM
Children not accessible after saving to/loading OSGb torbeng Vizard 3 09-12-2013 03:36 AM
pool network tutorial.py did not work Kazutaka Mitobe Vizard 0 05-29-2012 07:24 AM
Labjack U12 and network server license activation sindi Vizard 1 02-26-2010 12:35 PM
Using 5DT plug-in with the data coming through network... mcicek Vizard 1 05-18-2009 05:17 PM


All times are GMT -7. The time now is 07:33 AM.


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