Changeset 875 for branches/prototype-v0
- Timestamp:
- Mar 19, 2018, 10:32:24 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/prototype-v0/docs/services/howtos.rst
r794 r875 439 439 } 440 440 441 442 R 443 ---------- 444 445 ZOO API 446 ********* 447 448 For 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 451 The ZOO-API is available from a R script and provide access to a 452 global zoo environment which contains both static variables and also 453 the 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 460 The 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 472 R 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 479 The ZCFG file should contain the following : 480 481 serviceType 482 R 483 serviceProvider 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 489 R Data Structure used 490 ******************************** 491 492 The three parameters of the function are passed to the R function as 493 R dictionaries. 494 495 The specificity of the R language make that it was easier to use 496 global variales than passing parameters by reference as we do in 497 other progamming languages. It is the reason why you will have to 498 access outpus by using the global variable as for the main 499 configuration dictionary. 500 501 Sample 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.