Intel CPU Web API

Intel CPU Web API

Hi,I am trying to use the CPU Web API and though I have installed theIntel Web API Connector I don't see the script detecting my CPU. I am using the same example script given below:=====================================================================

This HTML & JavaScript shows you how to embed the Intel CPU Web API into your app.

  
  
  
  

    // this outer closure just to keep the sample code from cluttering up
    // the namespace with the function names etc being used
    (function() {
      
      //kick off IntelWebAPIs.init() and IntelWebAPIs.require() when
      //the page is loaded
      add_onload_handler( function() {

        IntelWebAPIs.init(init_result_func);
        
        //called by IntelWebAPIs.init()
        function init_result_func(result) {
          if(result.success) {
            // now bring in Intel Web APIs required by your app...
            output_status("IntelWebAPIs Connector init success");
            IntelWebAPIs.require(["cpu"], require_completion_func, require_progress_func);
          }
          else {
            output_status("IntelWebAPIs Connector init error: " + result.error.msg);
            //handle error condition
            //result.error.msg contains an error message
            //result.connectorInstUrl contains the url to the Intel Web API connector installer
            output_status("you may need to download the Intel Web API connector from here: " + 
              result.connectorInstUrl);
          }
        }
    
        //called by IntelWebAPIs.require()
        function require_completion_func(result) {
          if(result.success){
            //you can now use IntelWebAPIs.cpu properties and functions
            output_status("IntelWebAPIs." + result.installInfo.plugins[0].name + " ready for use!");
            output_status("Your CPU Name is: " + IntelWebAPIs.cpu.name);
            setInterval(function(){
              // send a status message to our div every second
              var cpuLoad = Math.round((IntelWebAPIs.cpu.load * 100) * 100)/100;
              output_status("CPU Load =" + cpuLoad + " %");
            },1000);
          }
          else {
            //check other result properties and handle error condition
            output_status("IntelWebAPIs error: " + result.installInfo.msg);
          }
        }
        
        //called by IntelWebAPIs.require()
        function require_progress_func(statusMsg){
          //statusMsg is a string - send this wherever
          output_status("IntelWebAPIs connector status: " + statusMsg);
        }
      
      });
      
      /* Its recommended that you wait until the document is loaded 
         before calling IntelWebAPIs.init() and IntelWebAPIs.require() 
         This utility helps with that...*/
      function add_onload_handler(addfunc, altwindow) {
        var targwindow = window;
        if(typeof(altwindow) != 'undefined'){
          targwindow = altwindow;
        }
        
        /* chain the onload functions together */
        var prevf = targwindow.onload;
        var newf  = addfunc;
        targwindow.onload = function(){
            newf();
            if(typeof(prevf) == 'function'){
              prevf();
            }
          };
      }
      
      /* utility that outputs status messages to a div*/
      function output_status(str) {
        var divout = document.getElementById("IntelWebAPIs_sample_code_status_div");
        divout.innerHTML += str + "
"; divout.scrollTop = divout.scrollHeight; } })(); // end of outer closure

======================================================================I am getting the following errors:CPU Web API status:
IntelWebAPIs,init success,connector version,0.6.p-versionfile
IntelWebAPIs install progress: Downloading Installer's registry signature: http://software.intel.com/sites/whatif/webapis/intelwebapis_reg.json.dsig
IntelWebAPIs install progress: Downloading Installer's registry: http://software.intel.com/sites/whatif/webapis/intelwebapis_reg.json
IntelWebAPIs install progress: Verifying Installer's registry
IntelWebAPIs install progress: Parsing Installer's registry
IntelWebAPIs install progress: Plugin connector already installed.
IntelWebAPIs install progress: Plugin cpu already installed.
IntelWebAPIs CPU API install failure,An unexpected error resulted in failure to instantiate {name: cpu,=====================================================================

3 post / 0 nuovi
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione

Hey there. let me get on the same page with you:

Can you provide me with the browser type and browser version you are using.
Note: for the current version of the CPU (and other) web apis you need a recent version of Firefox, Chrome or Safari. This will change soon - as our next release will support MS Internet Explorer too.

Thanks
Andy

Greetings!

I work with Andy and helped develop some of this code (and I probably created the failure you are experiencing :)). Based on your output, the CPU plugin is installed, but the javascript code failed to embed it into the current web page. Looking at the javascript code inside of the require() call, there are two reasons for such a failure:

1. The browser does not detect the plugin. To see if this is the case, type about:plugins in the location bar of your browser (this works on Firefox and Chrome, in Safari look under Help -> Installed Plugins). If the browser detected the CPU plugin, the "plugins" page will contain a description as follows:

Intel CPU WebAPI - experimental (followed by some details about the .dll and mimetype)

If you don't see this entry, let me know and I'll suggest some workarounds or fixes.

2. The version inside of the CPU plugin does not match the requested version. In your code, you didn't ask for a version, so any version should suffice, so the only reason this version check could fail is if the CPU plugin failed to return its version. If step 1 above shows the plugin, then I'll walk you through a way to check the version of the CPU plugin (basically we'll write a small bit of javascript to print out the CPU plugin and its version, like:

alert(IntelWebAPIs.cpu);
alert(IntelWebAPIs.cpu.version);

and see if either of those fails - the first alert should be an Object of some sort (possibly an NPObject) and the second should be a string of the from "x.y.somestring"

Accedere per lasciare un commento.