Dashcode (Beta) Officially Released

Discussion in 'Mac Programming' started by mduser63, Dec 21, 2006.

  1. macrumors 68040

    mduser63

    Joined:
    Nov 9, 2004
    Location:
    Salt Lake City, UT
    #1
    It was leaked a long time ago and its existence was leaked even before that, but Dashcode is now officially available in beta from Apple. You have to have an ADC account (free membership is fine) to get it. It's on the ADC site under downloads. I just downloaded it. I've been wanting to create a widget to go with the app I'm developing. That'll give me a project to work on in order to learn how to use Dashcode.
     
  2. macrumors 6502a

    steelphantom

    Joined:
    Oct 15, 2005
    #2
    Nice! Downloading it right now. I just hope I can make something that doesn't suck. :D
     
  3. macrumors regular

    Joined:
    Nov 23, 2006
  4. macrumors 65816

    monke

    Joined:
    May 30, 2005
    #4
    Thanks for the heads up mduser63! Downloading now. :)
     
  5. macrumors G4

    Chundles

    Joined:
    Jul 4, 2005
    #5
    Downloading now.

    Let's see how well this works shall we? I wonder if it's the same version that shipped in the early MacBooks?
     
  6. macrumors G4

    Chundles

    Joined:
    Jul 4, 2005
    #6
    Anybody know how to add an "Uptime" indicator to the gauge widget?
     
  7. thread starter macrumors 68040

    mduser63

    Joined:
    Nov 9, 2004
    Location:
    Salt Lake City, UT
    #7
    The way they're doing things in the default gauge is by running command line tools then processing the output to get the data they need. "uptime" is the command-line tool to find uptime. I don't know javascript really at all, so I'd have a hard time rewriting their code, but it's basically just a matter of modifying one of their handler functions to run uptime and process its output.

    In the gauge prototype, check out CommandMonitor.js. For example, this is used to do the disk activity gauge:

    Code:
    function IOStatMonitor (frequency) {
    	this.commandLine = "/usr/sbin/iostat -d -C -w " + frequency;
    }
    
    IOStatMonitor.prototype = new CommandMonitor();
    
    IOStatMonitor.prototype.processLine = function (line)
    {
    	//  KB/t tps  MB/s   KB/t tps  MB/s   KB/t tps  MB/s  us sy id
    	// 20.06   5  0.09   9.70   0  0.00  10.67   0  0.00   4  3 92
    
    	// Take off leading and trailing spaces
    	line = line.replace(/^\s+/, "");
    	line = line.replace(/\s+$/, "");
    
    	// Look for a line of numbers	
    	var match;
    	if ((match = line.match(/^(\s*[\d\.]+)+$/)) != null) {
    		var n = match[0].split(/\s+/);
    
    		if (n.length > 0 && n.length % 3 == 0) {
    			// Add up all the MB/s numbers
    			var mbps = 0.0;
    			for (var i = 2; i < n.length - 3; i += 3) {
    				mbps += parseFloat(n[i]);
    			}
    
    			// Grab the inverse of the CPU idle time and call it load
    			var load = 100 - parseInt(n[n.length - 1]);
    			
    			// alert("disk io: " + mbps + ", load: " + load);
    			if (this.ioCallback != null) {
    				this.ioCallback(mbps);
    			}
    			if (this.loadCallback != null) {
    				this.loadCallback(load);
    			}
    		}
    		else {
    			alert("iostat format violation: expecting groups of three:");
    			alert(line);
    		}
    	}
    }

    Dashcode looks good. Easy to use and powerful. However, I think it's going to require a fairly good knowledge of JavaScript. Oh well, that gives me something new to learn!
     
  8. macrumors 6502a

    Joined:
    Apr 22, 2005
    #8
    Free ADC membership account? It is the first time I hear of it. Where do you sign up for it? I can't find it.


    EDIT: Nevermind, I found it. Thanks for sharing. :D
     

Share This Page