2025-03-28 09:35:03 +01:00
2024-03-04 11:22:34 +01:00
2024-06-04 08:56:48 +02:00
2024-03-05 14:23:54 +01:00
2024-06-04 08:56:48 +02:00
2024-03-01 15:07:38 +01:00
2024-06-04 09:02:56 +02:00
2024-12-13 16:10:24 +01:00
2024-03-04 11:22:34 +01:00
2025-03-28 09:35:03 +01:00
2024-03-27 12:10:07 +01:00

ecmc_plugin_daq

A shared library with DAQ (data acquisition) functionalities loadable into ecmc:

https://github.com/epics-modules/ecmc (or local ess fork https://github.com/icshwi/ecmc).

Configuration is made through ecmccfg:

https://github.com/paulscherrerinstitute/ecmccfg (ot local ess fork https://github.com/icshwi/ecmccfg)

Introduction

The plugin can package ecmc data into arrays of double (collected in the same realtime loop). Data can be both ethercat data (also supports oversampling) or from other objects in ecmc, like motion. The advantage of this is that all data is sampled at the same time.

The structure of the data can be divided into 3 levels of objects:

  • Array
  • Channel
  • DataItem The Array is the top level object that represents the final array, the plugin supports multiple array objects. Each Array object can contain several Channels and each Channel can contain several DataItems.

The first elements in the Array contains header data describing the contets of the array. dataformat.png

To summarize:

  1. First element of array is always the channel count

  2. Second element is the ethercat time (micro seconds, 32bit)

  3. Each channel then have a 4 element header:

    1. Type code (defined by user)
    2. Data start position in array
    3. Data element count in array
    4. Spare for future use

Loading of DAQ plugin in ecmc:

The plugin should be loaded in ecmc by use of require, the parameter PLUGIN_ID needs to be defined:

require ecmc_plugin_daq sandst_a "PLUGIN_ID=0"

Defining the array:

Create an empty array object with ecmcDAQAddArray.cmd:

${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddArray.cmd,         "NAME=TestArray01"

This will an empty array object named "TestArray01"

This "NAME" parameter is also used to define the asyn port name and the asyn parameter name for for accessing the waveform data.

Adding a channel in the array

Add a channel to the last created array with ecmcDAQAddChannel.cmd. The parameter TYPE needs to be defined in the function call:

  • TYPE : User defined number for identification of the data channelm type. The type can for instance be used by a consumer of data to trigger different analysis for differet types.

Example:

${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddChannel.cmd,      "TYPE=1234"

Adding a data item the a channel

Add a channel to the last created array with ecmcDAQAddDataItem.cmd. The command takes three parameters:

  1. PARAM : Parameter name to specify the data to read from ecmc, ec0.s1.analogInput01, ax1.poserr,...
  2. FORMAT : Optional formatting of data:
       0 = raw (default)             : Take raw value (do not apply special format)
       1 = time_micro_s              : Time: Recalc 64bit nano seconds to 32 bit micro second counter
       2 = time_micro_s_minus_period : Time: Recalc 64bit nano seconds to 32 bit micro second counter minus one ec-period.
                                       Useful for oversampling slaves where normally the nextsync time is available.
                                       The calculated time then would correspond to the first data in the array recived.
       3 = time_ns_minus_period      : Time: Raw value minus one period.
  1. SEND_OLD : Optional to send old data (for scalars from previosu cycle, for arrays just one element shift)

Finalizing a array

When the configurations for an array is finalized then the ecmcDAQFinalizeArray.cmd must be called. The command will read the total array size (header plus data) from the plugin and then load the database with the waveform record (with correct NELM). The command takes the array name as a parameter ("NAME").

The wawform record will be named: "${PREFIX}:DAQ-${NAME}-DataAct"

Example:

${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQFinalizeArray.cmd,     "NAME=TestArray01"

Example:

The below example configures 2 array objects:

  1. Array "Testing1" containg 3 channels with a few data items (also arrays from oversampling slaves)
  2. Array "Testing2" containg 2 channels with a few data items
##############################################################################
## Load daq plugin
#
require ecmc_plugin_daq sandst_a "PLUGIN_ID=0"

epicsEnvSet(NAME,Testing1)
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddArray.cmd,        "NAME=${NAME}"
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddChannel.cmd,      "TYPE=1234"
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd,     "PARAM=ec0.s13.ONE,FORMAT=2"
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd,     "PARAM=ec0.s13.positionActual01"
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd,     "PARAM=ax1.setpos"
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd,     "PARAM=ec0.s13.positionActual01"
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddChannel.cmd,      "TYPE=4321"
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd,     "PARAM=ec0.s13.ONE,FORMAT=2"
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd,     "PARAM=ec0.s13.positionActual01"
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd,     "PARAM=ax1.setpos"
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddChannel.cmd,      "TYPE=3702"
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd,     "PARAM=ec0.s9.mm.analogInputArray01"
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd,     "PARAM=ec0.s9.mm.analogInputArray02"
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQFinalizeArray.cmd    "NAME=${NAME}"

epicsEnvSet(NAME,Testing2)
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddArray.cmd,        "NAME=${NAME}"
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddChannel.cmd,      "TYPE=1234"
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd,     "PARAM=ec0.s13.ONE,FORMAT=2"
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd,     "PARAM=ec0.s13.positionActual01"
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd,     "PARAM=ax1.setpos"
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd,     "PARAM=ec0.s13.positionActual01"
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddChannel.cmd,      "TYPE=4321"
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd,     "PARAM=ec0.s13.ONE,FORMAT=2"
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd,     "PARAM=ec0.s13.positionActual01"
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQAddDataItem.cmd,     "PARAM=ax1.setpos"
${SCRIPTEXEC} ${ecmc_plugin_daq_DIR}ecmcDAQFinalizeArray.cmd    "NAME=${NAME}"

Records:

c6025a> dbgrep *DAQ*
c6025a:DAQ-Testing1-Enable
c6025a:DAQ-Testing2-Enable
c6025a:DAQ-Testing1-DataAct
c6025a:DAQ-Testing2-DataAct

Array data "Testing1":

caget -t c6025a:DAQ-Testing1-DataAct
14:22:04.745986 c6025a:DAQ-Testing1-Data-Act 3 2134284536 1234 14 6 -1 4321 20 5 -1 3702 25 200 -1 4293967 0 0 0 0 0 4293967 0 0 0 0 -5 -8 -7 -5 -5 -5 -7 -5 -7 -5 -7 -7 -5 -7 -7 -3 -5 -5 -9 -4 -5 -5 -9 -5 -8 -8 -7 -7 -7 -8 -5 -4 -8 -8 -7 -5 -7 -4 -5 -9 -8 -8 -11 -7 -4 -5 -8 -8 -8 -9 -5 -7 -4 -4 -5 -9 -7 -4 -10 -7 -7 -8 -8 -5 -5 -7 -8 -8 -5 -5 -8 -7 -7 -7 -8 -8 -7 -4 -7 -8 -8 -7 -8 -7 -5 -9 -8 -7 -8 -9 -9 -5 -7 -7 -8 -5 -9 -8 -9 -5 -5 -3 -5 -4 -6 -4 -6 -5 -5 -5 -6 -6 -4 -5 -4 -6 -6 -6 -5 -6 -4 -4 -5 -6 -7 -7 -6 -4 -7 -4 -6 -6 -8 -6 -5 -4 -4 -5 -4 -6 -6 -6 -6 -5 -4 -6 -3 -4 -7 -9 -6 -4 -3 -4 -6 -6 -5 -5 -7 -5 -5 -4 -6 -5 -3 -6 -6 -6 -5 -4 -4 -5 -3 -4 -5 -5 -6 -5 -5 -6 -6 -5 -4 -7 -3 -6 -6 -5 -6 -6 -5 -5 -3 -4 -6 -6 -5 -7 -6 -5 

In this case the header is "3 2134284536 1234 14 6 -1 4321 20 5 -1 3702 25 200 -1":
0.  Channel count                          : 3
1.  EtherCAT dc time in micro seconds      : 2134284536
2.  Type of first channel                  : 1234
3.  Data starts at element                 : 14
4.  Data element count                     : 6
5.  Spare                                  : -1
6.  Type of second channel                 : 4321
7.  Data starts at element                 : 20
8.  Data element count                     : 5
9.  Spare                                  : -1
10. Type of third channel                  : 3702
11. Data starts at element                 : 25
12. Data element count                     : 200  (two oversampling arrays of size 100)
13. Spare                                  : -1
14. First data element of first ch. "1234" : 4293967
15. Second data element of first ch.       : 0
...
...
25. Data start element for third ch.       : -5
...
...

Array data "Testing2":

caget -t c6025a:DAQ-Testing2-DataAct
14:21:22.652988 c6025a:DAQ-Testing2-Data-Act 2 2092191543 1234 10 6 -1 4321 16 5 -1 4293967 0 0 0 0 0 4293967 0 0 0 0 

Some data

camon -t c6025a:DAQ-ToEdwin-DataAct

16:54:32.812939 c6025a:DAQ-ToEdwin-DataAct 6 4194379137 1 26 1 -1 2 27 1 -1 3 28 1 -1 1100 29 102 -1 4 131 2 -1 1050 133 52 -1 0 0 0 4194377117 4194378117 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4194376067 4194377067 -316 -285 -499 -578 -400 -414 -313 -390 -365 -408 -545 -448 -188 -482 -445 -364 -398 -261 -310 -450 -229 -227 -563 -319 -335 -326 -490 -240 -307 -513 -448 -435 -582 -394 -298 -242 -539 -449 -492 -443 -377 -143 -299 -484 -515 -370 -422 -636 -547 -288 
16:54:32.813945 c6025a:DAQ-ToEdwin-DataAct 6 4194380144 1 26 1 -1 2 27 1 -1 3 28 1 -1 1100 29 102 -1 4 131 2 -1 1050 133 52 -1 0 0 0 4194378117 4194379117 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4194377067 4194378067 -344 -364 -685 -532 -328 -527 -483 -386 -346 -528 -340 -437 -323 -453 -382 -525 -629 -475 -466 -577 -516 -550 -451 -326 -273 -308 -535 -269 -413 -465 -297 -340 -480 -443 -280 -469 -523 -555 -630 -412 -350 -411 -591 -548 -580 -466 -238 -265 -321 -394 
16:54:32.814938 c6025a:DAQ-ToEdwin-DataAct 6 4194381137 1 26 1 -1 2 27 1 -1 3 28 1 -1 1100 29 102 -1 4 131 2 -1 1050 133 52 -1 0 0 0 4194379117 4194380117 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4194378067 4194379067 -417 -219 -286 -338 -338 -270 -214 -409 -481 -423 -488 -565 -359 -544 -423 -190 -236 -487 -633 -488 -468 -336 -556 -505 -232 -257 -463 -464 -382 -480 -215 -420 -548 -467 -335 -330 -406 -337 -278 -361 -511 -509 -588 -376 -315 -399 -448 -512 -602 -778 
16:54:32.815937 c6025a:DAQ-ToEdwin-DataAct 6 4194382136 1 26 1 -1 2 27 1 -1 3 28 1 -1 1100 29 102 -1 4 131 2 -1 1050 133 52 -1 0 0 0 4194380117 4194381117 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4194379067 4194380067 -586 -383 -404 -641 -533 -296 -208 -416 -525 -314 -379 -362 -468 -491 -483 -503 -471 -513 -462 -482 -690 -483 -368 -294 -400 -452 -452 -456 -246 -371 -353 -395 -330 -554 -317 -204 -375 -361 -545 -580 -396 -493 -415 -349 -484 -252 -311 -573 -432 -289 
16:54:32.816939 c6025a:DAQ-ToEdwin-DataAct 6 4194383137 1 26 1 -1 2 27 1 -1 3 28 1 -1 1100 29 102 -1 4 131 2 -1 1050 133 52 -1 0 0 0 4194381117 4194382117 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4194380067 4194381067 -358 -237 -197 -450 -430 -279 -448 -518 -490 -213 -202 -248 -300 -418 -344 -595 -658 -525 -302 -262 -353 -328 -401 -360 -478 -460 -364 -549 -522 -342 -410 -472 -444 -459 -338 -321 -344 -313 -423 -445 -427 -560 -470 -298 -341 -190 -339 -374 -536 -494 
Description
No description provided
Readme 185 KiB
Languages
C++ 73.6%
Batchfile 11.9%
C 10.7%
Makefile 3.8%