Code Search for Developers
 
 
  

OscMessage.as from Make Controller at Krugle


Show OscMessage.as syntax highlighted

/*********************************************************************************
 Copyright 2006 MakingThings

 Licensed under the Apache License, 
 Version 2.0 (the "License"); you may not use this file except in compliance 
 with the License. You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0 

 Unless required by applicable law or agreed to in writing, software distributed
 under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
 CONDITIONS OF ANY KIND, either express or implied. See the License for
 the specific language governing permissions and limitations under the License.
 
*********************************************************************************/

/**
	<p>For more information on OSC, check the <a href="http://www.makingthings.com/resources/tutorials/osc">OSC tutorial</a> on makingthings.com.</p>
	
	<p>For information on how to send out OscMessages, see the send(), sendToAddress(), sendMessage() or sendMessageToAddress() functions in the 
	<a href="McFlashConnect.html">McFlashConnect</a> section.</p>
	
	<p>If you're sending multiple OscMessages to the board at once, consider grouping all the messages into an <b>OscBundle</b> and sending them out
	together.  This reduces network traffic and improves performance.</p>
	
	<p>An OscBundle is simply an Array that is full of OscMessages.  Once you've created your OscMessages, stuff them into an Array and send them
	out using the the sendBundle() and sendBundleToAddress() functions in the 
	<a href="McFlashConnect.html">McFlashConnect</a> section.</p>
	
	<h3>Example</h3>
	<pre>
	// create an OscMessage that will set the state of LED 0 on the Application board to "on".
	var msg:OscMessage = new OscMessage( "/appled/0/state", [1] );
	
	// access the address using the . operator:
	var msgAddress:String = msg.address;
	
	// read (or write) data into the <b>args</b> array, also using the . operator:
	var data = msg.args[0]; // this will be 1
	
	// for incoming OscMessages, check to see where they came from:
	var msgFrom:String = msg.from;
	</pre>
	
	<p>See the list of all the OSC messages that the Make Controller knows how to respond to at
	<a href="http://www.makingthings.com/ref/firmware/html/group___o_s_c.html">http://www.makingthings.com/ref/firmware/html/group___o_s_c.html</a>.
*/

class com.makingthings.makecontroller.OscMessage
{
	/** The OSC address of the message. This must start with a <b>/</b> */
	public var address:String;
	/** A list of zero or more arguments being sent to that OSC address. Arguments
	can be of type string, int, or float. If you have no arguments, simply provide an empty array
	by passing in [] */
	public var args:Array;
	/** For incoming OscMessages, this indicates which board it was sent from.  For boards communicating via Ethernet, this will be an IP address.
	For USB boards, it will be some unique identifier - on Windows it will look like "COM9" and on OS X it will be a long, nasty device location string.
	This property is not relevant for outgoing OscMessages. */
	public var from:String;
	public var time:Number;
	
	/**
	Create a new OscMessage.
	
	@param address The OSC address of this message
	@param args An array of arguments.  To specify no arguments, simply use []
	@param from An optional string indicating where the message originated from. This is mostly used
	internally by the Flosc library for incoming messages, and does not need to be set for outgoing messages.	
	*/
	function OscMessage( address:String, args:Array, from:String )
	{
		this.address = address;
		this.from = from;
		this.args = args;
		this.time = 0;
	}
	
	/**
	Return a string representing an OscMessage, with the arguments following the address, each separated by a space.
	<p>This will look like <pre> /address arg1 (arg2) (argN) </pre></p>
	@return The OscMessage as a string, not including the <b>from</b> string.
	*/
	public function toString( ):String
	{
		var msg:String = this.address;
		var numOfArgs:Number = this.args.length;
		for( var i = 0; i < numOfArgs; i++ )
			msg = msg.concat( " " + this.args[i].toString() );

		return msg;
	}
}





See more files for this project here

Make Controller

The Make Controller is an open microcontroller platform for Makers of all kinds, by MakingThings. This project maintains the official firmware for the board and source for the software tools used with the board.

Project homepage: http://sourceforge.net/projects/makingthings
Programming language(s): C,C#,C++
License: other

  AddressHandler.as
  Board.as
  McFlashConnect.as
  OscMessage.as
  index.as