MCS to FHS

The interface from the MCS to the FHS is largely in the form of communication between Tango devices running on either side.

Command Sequence

InitSysParam Sequence

The sequence diagram below shows the main sequence of calls in MCS to initialize the system parameters.

@startuml
'https://plantuml.com/sequence-diagram
skinparam backgroundColor #EEEBDC
skinparam sequence {
ParticipantBorderColor DodgerBlue
ParticipantBackgroundColor DeepSkyBlue
ActorBorderColor DarkGreen
ActorBackgroundColor Green
BoxBorderColor LightBlue
BoxBackgroundColor #F0FFFF
}
skinparam collections {
  BackGroundColor LightBlue
  BorderColor DodgerBlue
}
skinparam responseMessageBelowArrow true

title InitSysParam Command Sequence\n

participant "CSP_Mid\n.LMC" as lmc #Thistle
box "\nMCS\n"
  participant "Mid.CBF\nController" as controller
  collections "Mid.CBF\nSubarray" as subarray
end box
participant "Central Artefact Repository\n(CAR)" as car #YellowGreen

lmc            -> controller        : InitSysParam(<JSON-formatted system parameter string>)
controller     -> controller        : Validate JSON against schema

group #SeaShell If JSON is valid:

  group #SeaShell If URI provided:
    controller -> car               : Retrieve init sys param JSON file
    controller -> controller        : Validate JSON  against schema
  end group

  controller   -> controller        : Update sysParam attribute
  controller   -> subarray          : Set sysParam attribute
  subarray     -> subarray          : Update sysParam attribute
  controller   -> lmc               : ResultCode.OK

end group


@enduml

AssignResources Sequence

The sequence diagram below shows the main sequence of calls in MCS to assign dish resources to a subarray.

@startuml
'https://plantuml.com/sequence-diagram

skinparam backgroundColor #EEEBDC
skinparam sequence {
    ParticipantBorderColor DodgerBlue
    ParticipantBackgroundColor DeepSkyBlue
    ActorBorderColor DarkGreen
    ActorBackgroundColor Green
    BoxBorderColor LightBlue
    BoxBackgroundColor #F0FFFF
}
skinparam collections {
    BackGroundColor LightBlue
    BorderColor DodgerBlue
}

title MCS Correlation Assign Resources\n

participant "TMC\n" as tmc #Gold
participant "CSP_Mid\n.LMC" as lmc #Thistle
box "\nMCS\n"
    participant "Mid.CBF\nSubarray" as subarray
    collections "VCC\n" as vcc
    collections "Talon\nBoard" as talon
end box

note over subarray       : ObsState: EMPTY
lmc         ->  subarray     : AssignResources(list[str])
note over subarray           : ObsState: RESOURCING
group #LightCyan For each receptor in argin:
    subarray    -> subarray  : Validate receptors in argin
end group

group #SeaShell If len(valid receptors) > 0:
    group #LightCyan For each receptor:
        subarray    -> vcc       : Update simulationMode
        subarray    -> vcc       : AdminMode.ONLINE
        note over vcc            : OpState: ON
        subarray    ->  vcc      : Update subarrayMembership
        subarray    ->  talon    : Update subarrayID
    end group

    subarray    ->  subarray     : Update receptors
    note over subarray       : ObsState: IDLE
else Failure in AssignResources, ObsState unchanged
    note over subarray       : ObsState: EMPTY
end group


lmc        <--  subarray     : Success

@enduml

ReleaseResources Sequence

The sequence diagram below shows the main sequence of calls in MCS to release dish resources from a subarray.

Note: the RemoveAllReceptors command has the same code flow, the only difference being that it takes in no argument and instead releases all assigned dish resources.

@startuml
'https://plantuml.com/sequence-diagram

skinparam backgroundColor #EEEBDC
skinparam sequence {
    ParticipantBorderColor DodgerBlue
    ParticipantBackgroundColor DeepSkyBlue
    ActorBorderColor DarkGreen
    ActorBackgroundColor Green
    BoxBorderColor LightBlue
    BoxBackgroundColor #F0FFFF
}
skinparam collections {
    BackGroundColor LightBlue
    BorderColor DodgerBlue
}

title MCS Correlation Release Resources\n

participant "TMC\n" as tmc #Gold
participant "CSP_Mid\n.LMC" as lmc #Thistle
box "\nMCS\n"
    participant "Mid.CBF\nSubarray" as subarray
    collections "VCC\n" as vcc
    collections "Talon\nBoard" as talon
end box

lmc             ->  subarray    : ReleaseResources(list[str])
note over subarray              : ObsState: RESOURCING
group #LightCyan For each receptor in argin:
    subarray    -> subarray     : Validate receptors in argin
    subarray    -> vcc          : Reset subarrayMembership to 0
    subarray    -> vcc          : AdminMode.OFFLINE
    note over vcc               : OpState: DISABLE
    subarray    ->  talon       : Reset subarrayID
end group

subarray    ->  subarray        : Update receptors

group #SeaShell If len(receptors) == 0:
    note over subarray          : ObsState: EMPTY
else
    note over subarray          : ObsState: IDLE
end group


lmc        <--  subarray     : Success

@enduml

Configure Scan Sequence

MCS currently supports Correlation observing mode. All modes have their own specific schema for the ConfigureScan input JSON-formatted string.

All Observing Modes

The sequence diagram below shows the main sequence of calls in MCS to configure a scan.

@startuml
'https://plantuml.com/sequence-diagram

skinparam backgroundColor #EEEBDC
skinparam sequence {
    ParticipantBorderColor DodgerBlue
    ParticipantBackgroundColor DeepSkyBlue
    ActorBorderColor DarkGreen
    ActorBackgroundColor Green
    BoxBorderColor LightBlue
    BoxBackgroundColor #F0FFFF
}
skinparam collections {
    BackGroundColor LightBlue
    BorderColor DodgerBlue
}

title MCS Configure Scan\n

participant "TMC\n" as tmc #Gold
participant "CSP_Mid\n.LMC" as lmc #Thistle

box "\nMCS\n"
    participant "Mid.CBF\nSubarray" as subarray
    collections "Vcc\nUnit" as vcc
    collections "FSP\n" as fsp
    collections "FSP ObsMode\nSubarray" as fsp_obs
    participant "Network\nSwitch" as network_switch
end box

box "\nFHS\n" #LightYellow
    participant "FHS FPGA\nController" as fhs_cont
    participant "VCC All Bands\nController" as vcc_cont
    participant "FSP Mode Management \nController" as fsp_cont
    participant "FSP ObsMode\nController" as fsp_obs_cont
end box

note over subarray                    : OpState: ON
note over subarray                    : ObsState: IDLE
lmc -> subarray                       : ConfigureScan(<JSON-formatted string>)
subarray -> subarray                  : Save new configuration to lastScanConfiguration
subarray -> subarray                  : Validate JSON against schema,\nLoad configuration

group #LightCyan For each assigned VCC:
    subarray -> subarray              : Build VCC\nconfiguration
    note over vcc_cont                : ObsState: IDLE
    subarray -> vcc_cont              : ConfigureScan(<JSON-formatted string>)
    note over vcc_cont                : ObsState: READY
    vcc_cont -> subarray              : ResultCode.OK
end group

group #LightCyan For each requested FSP:
    subarray -> subarray              : Build FSP\nconfiguration

    group #SeaShell If FSP not already assigned to subarray:

        group #White If len(fsp.subarrayMembership) == 0:
            note over fsp             : ObsMode: IDLE
            subarray -> fsp           : SetObsMode(<ObsMode in configuration>)
            note over fsp_obs         : OpState: DISABLE
            fsp      -> fsp_obs       : AdminMode.ONLINE
            note over fsp_obs         : OpState: ON
            fsp      -> fsp_cont      : SetObsMode(<ObsMode in configuration>)
            note over fsp_obs_cont    : OpState: DISABLE
            fsp_cont -> fsp_obs_cont  : AdminMode.ONLINE
            note over fsp_obs_cont    : OpState: ON
            fsp_cont -> fsp           : ResultCode.OK
            note over fsp             : ObsMode: <ObsMode in configuration>
            fsp      -> subarray      : ResultCode.OK
        end group

        subarray -> fsp               : AddSubarrayMembership(<subarray ID int>)
        fsp      -> subarray          : ResultCode.OK
    end group

    note over fsp_obs                 : ObsState: IDLE
    subarray     -> fsp_obs           : ConfigureScan(<JSON-formatted string>)
    fsp_obs      -> fsp_obs_cont      : ConfigureScan(<JSON-formatted string>)
    fsp_obs_cont -> fsp_obs           : ResultCode.OK
    note over fsp_obs                 : ObsState: READY
    fsp_obs      -> subarray          : ResultCode.OK

end group

group #LemonChiffon TMC Subscription Points
    subarray -> tmc                   : Subscribe delay model
end group

note over subarray                    : ObsState: READY
subarray -> lmc                       : ResultCode.OK

@enduml

Correlation (CORR)

The sequence diagram below shows details of calls to configure a FSP for a CORR scan.

@startuml
'https://plantuml.com/sequence-diagram
!pragma teoz true /'This allows nested participant boxes'/

skinparam backgroundColor #EEEBDC
skinparam sequence {
    ParticipantBorderColor DodgerBlue
    ParticipantBackgroundColor DeepSkyBlue
    ActorBorderColor DarkGreen
    ActorBackgroundColor Green
    BoxBorderColor LightBlue
    BoxBackgroundColor #F0FFFF
}
skinparam collections {
    BackGroundColor LightBlue
    BorderColor DodgerBlue
}

title FHS Configure FSP for Correlation Scan\n

box "\nMCS\n"
    participant "Mid.CBF\nSubarray\n" as subarray
    participant "FSP Corr\nSubarray\n" as fspcorr
end box
box "\nFHS"
    collections "FSP Corr\nController\n" as fhsfspcorr
end box

subarray    ->  fspcorr         : ConfigureScan(json_str)
note over fspcorr               : ObsState CONFIGURING

group #LightCyan For all FHS FSP Corr Controllers:
    fspcorr     -> fhsfspcorr   : UpdateSubarrayAssignments(json_str)
    fhsfspcorr  --> fspcorr     : ResultCode.OK
end group    


group #LightCyan For each FHS FSP Corr Controller in use:
    fspcorr -> fspcorr          : Extract configurations for VCCs with\ninputs for the specific FHS FSP Corr Controller\nfrom the FSP Corr Subarray configuration\ninto the FHS FSP Corr Controller configuration\nparameters
    fspcorr -> fhsfspcorr       : ConfigureScan(json_str)
    fhsfspcorr --> fspcorr      : ResultCode.OK

end group

note over fspcorr               : ObsState READY
fspcorr     --> subarray        : ResultCode.OK

@enduml

Pulsar Search Timing (PST)

The sequence diagram below shows details of calls to configure a FSP for a PST scan.

TODO .. .. uml:: ../../diagrams/configure-scan-pst-fsp-hps.puml

Abort Sequence

The sequence diagram below shows the main sequence of calls in MCS to Abort from a correlation/pst scan. Return calls are not shown.

TODO .. .. uml:: ../../diagrams/abort-command.puml

ObsReset Sequence

The sequence diagram below shows the main sequence of calls in MCS to return to IDLE via the ObsReset command for a correlation/pst scan. Return calls are not shown.

TODO .. .. uml:: ../../diagrams/obsreset-command.puml

Restart Sequence

The sequence diagram below shows the main sequence of calls in MCS to return to EMPTY via the Restart command for a correlation/pst scan. Return calls are not shown.

TODO .. .. uml:: ../../diagrams/restart-command.puml

Synchronizing HBM Corner Turner Initial Write Timestamp

The initial write timestamp values published by all the High Bandwidth Memory (HBM) Corner Turner FHS devices will be captured by the MCS FSP Tango device. In turn, once it has received the first initial write timestamp value, the MCS device will propagate it back down to the FHS FSP devices to synchronize the corner turners across all FPGAs in the FSP Unit, ensuring all outputs by all FSP Unit FPGAs are aligned to generate with the same initial timestamp.

This synchronization procedure must occur every time the FSP Unit transitions from having no input data from any VCCs to having at least one active input signal from one VCC.

The overall behaviour of the Corner Turners (CT) is as follows:

  • Expected operation of the corner turners is that once at least 1 VCC has data flowing, then all FGPAs will have data flowing; normal operation is that as long as at least 1 VCC continues to send data to the FSP, all corner turners will get data (it could be different VCCs from different scans) and no re-initialization is required

  • Data will stop flowing when all VCCs stop sending data. Once data starts flowing again as above, all corner turners need to be re-initialized

MCS Sequence for Initializing the Corner Turners:

  • When FSP receives the command SetObsMode

    • If the obs mode is changing from IDLE to CORR, the FSP subscribes to the first_write_timestamp on every FHS FSP CORR Controller (x8)

    • If the obs mode is changing from CORR to IDLE the FSP unsubscribes to the first_write_timestamp on every FHS FSP CORR Controller (x8)

  • MCS receives change events for first_write_timestamp and uses the first such event to start the initialization process (MCS does not wait for an event from each FPGA).

  • Once MCS detects that the CTs need to be initialized, a configure corner turner command is sent containing

    • first_read_timestamp

      • MCS will set first_read_timestamp to be first_write_timestamp; any adjustments to the first_write_timestamp (such as adding the read_threshold to reduce the amount of flagged data going to SDP) will be done in the FHS FSP top level controller

If MCS encounters DevFailed error while trying to Configure a specific FHS FSP Corr’s Corner Turner, MCS will attempt to retry configuring the Corner Turner 2 more times using the same initial timestamp given in the initial configuration attempt.

Synchronizing FSP Output Time Sequence

Every FSP producing output for a Subarray must have the same time to start producing products. The FHS FSP software will use the first output time to drop data received before this time.

The Mid.CBF Subarray will coordinate the first output time across all FSPs that the Subarray is using for a scan. This first output time will be based on the time the data started flowing for the scan, as determined and provided by the FHS FSP Corr top level controller.

For correlation, each Mid.CBF Subarray communicates with a single FSPCorrSubarray Tango device for each FSP that it is using for the scan. Each FSPCorrSubarray Tango device communicates with up to 8 FHS FSP top level controllers. In this design, this communication hierarchy is maintained.

The sequence diagram below shows the sequence of calls in MCS to synchronize the FSP Output Time for Subarray 1.

subarray1ScanStartTime is one of 16 subarray<1-16>ScanStartTime attributes found in FHS FSP Corr that corresponds to one of the 16 Subarray that can be assigned to FHS FSP Corr. MCS FSPCorrSubarray subscribes the FHS FSP Corr subarray<1-16>ScanStartTime that corresponds to the FSPCorrSubarray’s assigned Subarray.

@startuml sync-fsp-output
!include mid-cbf-puml-definitions.txt

title Synchronizing FSP Output\n

' ======================================
participant "CSP_Mid\n.LMC" as lmc #Thistle
box "\nMCS\n"
    participant "Mid.CBF\nSubarray1" as subarray
    collections "Mid.CBF\nFspCorrSubarray" as corr_subarray

end box

box "\nFHS FSP"
    collections "FHS FSP Corr" as fhs_fsp
end box

' ======================================


' Request resource status report
lmc  ->>  subarray ++  : Scan()

' Controller loops through all FSPs in use by Subarray

loop #LightCyan each FspCorrSubarray in use
subarray ->>  corr_subarray ++ : subscribe scanStartTimeRounded
subarray -> subarray : set _scan_started = False
subarray ->>  corr_subarray : Scan()
end loop

loop #LightCyan each FHS FSP in use
corr_subarray ->> fhs_fsp ++ : subscribe subarray1ScanStartTimeRounded
corr_subarray -> corr_subarray : clear scanStartTimeRounded
corr_subarray ->> fhs_fsp : Scan()
corr_subarray <<-- fhs_fsp : subarray1ScanStartTimeRounded
alt#Gold #LightCyan scanStartTimeRounded is None and\nsubarray1ScanStartTimeRounded is not None
    corr_subarray -> corr_subarray : write scanStartTimeRounded
else #LightGreen scanStartTimeRounded is not None
    corr_subarray -> corr_subarray : do nothing
end
end loop

loop #LightCyan each FspCorrSubarray in use
subarray <<-- corr_subarray : scanStartTimeRounded
end loop

alt#Gold  #LightCyan _scanStarted = False
    subarray -> subarray : set _scan_started = True
    loop #LightCyan each FspCorrSubarray in use
    subarray ->> corr_subarray : SetFirstOutputTime()
    end loop
    loop #LightCyan each FHS FSP in use
    corr_subarray ->> fhs_fsp : SetFirstOutputTime()
    end loop
else #LightGreen _scanStarted = True
    subarray -> subarray : do nothing
end

lmc ->> subarray : EndScan()
loop #LightCyan each FspCorrSubarray
subarray ->> corr_subarray : EndScan()
end loop

loop #LightCyan each FHS FSP in use
corr_subarray ->> fhs_fsp : EndScan()
end loop

@enduml