Changeset 875 for branches


Ignore:
Timestamp:
Mar 19, 2018, 10:32:24 PM (7 years ago)
Author:
djay
Message:

Add documentation for the R support.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/prototype-v0/docs/services/howtos.rst

    r794 r875  
    439439  }
    440440
     441
     442R
     443----------
     444
     445ZOO API
     446*********
     447
     448For using the R language from the ZOO-Project, you have first to copy
     449``minimal.r`` in the same directory as the ZOO-Kernel.
     450
     451The ZOO-API is available from a R script and provide access to a
     452global zoo environment which contains both static variables and also
     453the dictionaries for outputs and conf:
     454
     455:int zoo[["SERVICE_SUCCEEDED"]]:
     456   Value to return in case your service end successfully.
     457:int zoo[["SERVICE_FAILED"]]:
     458   Value to retrun in case of failure.
     459
     460The ZOO-API provides the following functions:
     461
     462:string ZOOTranslate(String s):
     463   This function call the internal ZOO-Kernel function responsible for
     464   searching a translation of ``s`` in the zoo-services dictionary.
     465
     466:void ZOOUpdateStatus(ZMaps conf,String pourcent):
     467   This function call the updateStatus ZOO-Kernel function responsible
     468   for updating the status of the running service (only usefull when
     469   the service has been called asynchronously).
     470
     471
     472R ZCFG requirements
     473**********************************
     474
     475.. Note:: For each Service provided by your ZOO R Services Provider,
     476          the ZCFG File must be named the same as the R function name
     477          (it is case-sensitive).
     478
     479The ZCFG file should contain the following :
     480
     481serviceType
     482   R
     483serviceProvider
     484    The name of the R file to use as a ZOO Service Provider. For instance, if your
     485    script, located in the same directory as your ZOO Kernel, was named ``my_module.r`` then
     486    you should use ``my_module.r``.
     487
     488
     489R Data Structure used
     490********************************
     491
     492The three parameters of the function are passed to the R function as
     493R dictionaries.
     494
     495The specificity of the R language make that it was easier to use
     496global variales than passing parameters by reference as we do in
     497other progamming languages. It is the reason why you will have to
     498access outpus by using the global variable as for the main
     499configuration dictionary.
     500
     501Sample ZOO R Services Provider
     502******************************************
     503
     504.. code-block:: javascript
     505
     506    source("minimal.r")
     507               
     508    hellor <- function(a,b,c) {
     509        # Set the result
     510        zoo[["outputs"]][["Result"]][["value"]] <<- ZOOTranslate(paste("Hello",b[["S"]][["value"]],"from the R World!",sep=" "))
     511        # Return SERVICE_SUCCEEDEED
     512        return(zoo[["SERVICE_SUCCEEDEED"]])
     513    }
     514
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png