= FofbTool Module

This python module provides functions to deal with the Fofb MTCA platform.
It connects to the OPCUAProxy tango devices.

The module is packaged in sections
* FofbTool.Configuration: For application configuration
* FofbTool.Operation: Function to perform operation (start, stop...)
* FofbTool.DeviceAttributeConfiguration: contains functions to apply tango attribute configuration
* FofbTool.Utils: Usefull function that relies on ConfigParser files and call the operation/configuration. Used by the command line tool.

There is also a Command Line Interface bin/FofbTool written in python.



= Command Line Interface: Basic usages

== Classic: stop, config, start

This stops the communication on all the nodes.
Also stops Bpm to CellNode communication blocks.

Then apply the default configuration on FPGA blocks:

* ComCellNode (Expected packets, correct MAC size...)
* ComBPM (BPM ID filter Filter for each CellNode...)
* ComCorr (Default PSCID on output...)

IMPORTANT: This do not configure Orbit Reference or Inv Response Matrix.
This do not start the FOFB, only the communication.

WARNING: PSC will receive frames upon start. Better stop the FOFB beforehand. The CLI won't let you do that.

[source,console]
----
$ FofbTool --stop --conf --start
----

== Synchronize BPMs

[source,console]
----
$ FofbTool --sync
----

== Align Electron and LBP FA stream

[source,console]
----
$ FofbTool --align-fa cellnode-c09
----

== Configure OPCUAProxy DS


Upon restart of OPCUAProxy Tango DS, to reapply attribute configuration (units, alarm level, descriptions...)

[source,console]
----
$ FofbTool --DS-conf

----

== Deploy to pyroot

Checkout the project, make the source distributable.

[source,console]
----
$ python setup.py sdist
----

A .tar.gz file is created in the directory dist/

With sufficient access rights to pyroot, run

[source,console]
----
$ pip install dist/FofbTool-X.Y.tar.gz
----



== More help

[source,console]
----
usage: FofbTool [-h] [--log LOG] [--force] [--fileconfig FILECONFIG]
                [--DS-init-opcua] [--DS-init-watcher] [--DS-conf] [--stop]
                [--stop-combpm] [--stop-ccn] [--stop-comlbp]
                [--dump-configuration DUMP_CONFIGURATION]
                [--configure [{combpm,ccn,comcorr,corr,all}]]
                [--align-fa cellnode-cXX] [--nolbp] [--start] [--start-combpm]
                [--start-comlbp] [--start-ccn] [--sync]

version x.x

optional arguments:
  -h, --help            show this help message and exit
  --log LOG             Log level (error, warning, info, debug)
  --force               Force operation even if FOFB is running.
  --fileconfig FILECONFIG
                        Path to config file to apply.
  --DS-init-opcua       Run init on opcua devices.
  --DS-init-watcher     Run init on the Fofb-Watcher device, and then the
                        Fofb-Command.
  --DS-conf             Applying attribute configuration on Tango Device
                        Servers. This is required after restart of devices.
  --stop                Stop command for the CCN and ComBPM applications
                        blocks.
  --stop-combpm         Stop command for the ComBPM applications blocks.
  --stop-ccn            Stop command for the ComBPM applications blocks.
  --stop-comlbp         Stop command for the ComLBP applications blocks.
  --dump-configuration DUMP_CONFIGURATION
                        Dump the current configuration in a file at the giver
                        path.
  --configure [{combpm,ccn,comcorr,corr,all}]
                        Configuration commands for the Fofb applications
                        blocs. 'all' is for all com and corrector. Default is
                        'all'
  --align-fa cellnode-cXX
                        Start alignement process for electron and brillance
                        plus FA sequence. The designation of the cellnode must
                        be set as argument.
  --nolbp               Do not start comlbp module when doing start.
  --start               Start command for the CCN and ComBPM applications
                        blocks.
  --start-combpm        Start command for the ComBPM applications blocks.
  --start-comlbp        Start command for the ComLBP applications blocks.
  --start-ccn           Start command for the ComBPM applications blocks.
  --sync                Start synchronization sequence for Libera Electron and
                        Libera Brillance Plus.

----