You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Doc_BoxAlgorithm_ExternalProcessing.rst 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. .. _Doc_BoxAlgorithm_ExternalProcessing:
  2. External Processing
  3. ===================
  4. .. container:: attribution
  5. :Author:
  6. Alexis Placet
  7. :Company:
  8. Mensia Technologies SA
  9. .. image:: images/Doc_BoxAlgorithm_ExternalProcessing.png
  10. Launches an external program which can then process data. This box and the program communicate using TCP connection and a defined protocol.
  11. This box allows to externalize data processing into an external program. It sends EBML data in chunks
  12. according to a specified protocol, the external application must respond with an EBML response following
  13. this same protocol.
  14. A SDK for C++ and Python 3 (Python NeuroRT Box) are provided in order to simplify the development of
  15. external boxes.
  16. This box can work in two modes, either it launches the external program itself, or it will wait for client
  17. connections during the initialize step.
  18. .. _Doc_BoxAlgorithm_ExternalProcessing_Settings:
  19. Settings
  20. --------
  21. .. csv-table::
  22. :header: "Setting Name", "Type", "Default Value"
  23. "Launch third party program", "Boolean", "true"
  24. "Executable path", "Filename", ""
  25. "Arguments", "String", ""
  26. "Port", "Integer", "0"
  27. "Automatic connection identifier", "Boolean", "true"
  28. "Custom connection identifier", "String", ""
  29. "Incoming connection timeout", "Integer", "10"
  30. "Generator", "Boolean", "false"
  31. The External Processing box has several settings. The first eight parameters are reserved for the
  32. box. Any additional parameters will be passed to the external program.
  33. Launch third party program
  34. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  35. If true, the box will attempt to start the external program automatically.
  36. We advise to use this mode in production.
  37. If this setting is false, then the box will stop
  38. during the initialize step and wait for the external program to connect during the time speficied by the Connection Timeout setting.
  39. This mode is useful during development, since it allows to run the program manually and check the console.
  40. Executable path
  41. ~~~~~~~~~~~~~~~
  42. Path to the executable to run. This parameter is only used if the first parameter is activated.
  43. Example: OpenViBE SDK comes with two example programs, one can be found in ``${Path_Bin}/sdk-examples-communication-client-filter``
  44. Example: In the case you want to run a Python script on Windows, the program you are running is python, e.g: ``C:/Python35/python.exe``
  45. Arguments
  46. ~~~~~~~~~
  47. Arguments passed to the third party program, if any are necessary. This parameter is only used if the first parameter is activated.
  48. This parameter will be given to the third party program as is, thus it is necessary to quote any arguments that contain spaces.
  49. Example: In the case you want to run a Python script on Windows, the parameter is the absolute path to the script that you want to run, e.g.: ``C:/MyProject/myprogram.py`` or ``-m mylibrary.mymodule.mybox``.
  50. Port
  51. ~~~~
  52. The TCP port that the box is listening. It must be in the range 49152-65535 or it can be 0, in which case the port will be chosen
  53. automatically.
  54. The box acts as a Socket server and the external program as a client. If you have several External Processing boxes in the same scenario
  55. each has to work on a different port.
  56. We advise to use port ``0`` in production.
  57. An argument, with the value of the port, will be given to the third party program (after the Arguments parameter ) as: ``--port PORT``
  58. This means that your external program must accept the ``--port`` parameter and use it to connect to this box.
  59. Automatic connection identifier
  60. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  61. Whether or not to generate of a connection identifier for the connection. See the next setting for explanation.
  62. Custom connection identifier
  63. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  64. This argument will be passed to the external program as a command line parameter: ``--connection-id CONNECTIONID`` and will be communicated to your
  65. program through the protocol as well. You should check that the two are matching in order to avoid a clash if two boxes would be using the same
  66. port.
  67. We advise you to use an automatic identifier generation in production. Choose your custom connection identifier is however necessary when running
  68. the external program explicitly.
  69. Incoming connection timeout
  70. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  71. A timeout, in seconds, for the incoming connection acceptance.
  72. Generator
  73. ~~~~~~~~~
  74. This setting changes how often the box will process data. Each data processing requires that the box will
  75. wait until it has received a response from the external program. Too many of these synchronisations can
  76. induce a severe performance penalty.
  77. If the box is a generator, then it will wait for the external program on each step. If the scenario is
  78. played in real-time, then the box will poll the external program at 16Hz. If the scenario is in fast-forward
  79. the refresh frequency of this box is 1Hz.
  80. If this setting is set to false, the box will send all data it receives into the external program and wait
  81. until it processes it and sends it back.
  82. .. _Doc_BoxAlgorithm_ExternalProcessing_Miscellaneous:
  83. Miscellaneous
  84. -------------
  85. Performances
  86. ~~~~~~~~~~~~
  87. This box requires synchronization with the external program in order to process data correctly and in order.
  88. As the synchronization is a relatively slow process with regards to the duration of one update cycle (62ms) it
  89. is better to try to limit the number of chunks that are send between the box and the client application.
  90. If you find that your scenario is too slow, try using time based epoching in front of it to make chunks of data
  91. larger.
  92. Development mode
  93. ~~~~~~~~~~~~~~~~
  94. While developing your program, you may want to run it in Debug mode in your environment.
  95. In order to run your program manually you should change the settings of the box:
  96. * uncheck option ``Launch Third Party Program``,
  97. * uncheck option ``Automatic connection identifier``,
  98. * change the default port, for example to ``59595``, (make sure this is the default port used by your program)
  99. * make sure the setting ``Incoming connection timeout`` will leave you enough time to run your program manually (default setting should be enough)
  100. Then, you can first run your scenario through NeuroRT Studio, and then run your program manually.