LCLS Controls

SLC-Aware IOC Design


 

Cluster Status and Test Service

 

Quick links:

1.   Scope

The following document describes a software design for the SLC-aware IOC (slcIOC) Cluster Status and Test Service.

2.   Introduction

This service consists of the cstrAsync Thread and the cstrHdlr Thread.

The cstrAsync Thread is the Async controller thread for the SLC IOC.  This simple thread finds out when each cycling function is ready to run and sends a message to the corresponding Async  handler thread which runs that function.  The handler threads that receive messages from cstrAsync include cstrHdlr and mgntHdlr.

 

The cstrHdlr Thread has two jobs.

1.      Service TEST JOB messages sent from the VMS Paranoia process by echoing back a response for every message received.

2.      Service  messages sent from the cstrAsync Thread by running the cycling function as indicated by the message.

 

The cycling functions in cstrHdlr periodically update SLC database CSTR health and status secondaries.  This health and status data is read from Global Memory (it was stored there by this and this and other Async handler threads).  IOC health and status data is also read from associated EPICS PVs and written to CSTR.

2.1 Background

This same functionality is implemented in the TESTMAIN job on the SLC Micros.

2.2 References

1.      PRIMARY.DBS: List of SLC Database Primaries and Secondaries

2.      SLC Asynch Database Update Design Spec by T Lahey, N Spencer 1989

3.      Improving Control of Auto-Checking Functions by T Lahey,N Spencer, R Hall 1990

2.3 Requirements

See the SLC-Aware IOC Functional Requirements by Stephanie Alison.

3.0 Cluster Status and Test Service Design

3.1 Service Description and External Interfaces

3.1.1 Service Block Diagram

The Cluster Status and Test Service includes two threads shown in the block diagram below: the cstrAsync thread and the cstrHdlr thread.

The cstrAsync thread initializes the Global area by calling slcAsyncInit. The Global area is described on the asyncUtil Design page.  

The cstrHdlr thread services TEST-function messages from Paranoia on VMS by receiving the messages and sending a reply back. It reads data from the EPICS database using Epics Runtime Database Access calls. It reads and writes to the SLC CSTR database primary using SLC database utilities and Async utilities.


3.1.2 External Interfaces

Described elsewhere in this document.

3.1.3 Data Flow

See Diagram Above.

3.1.4 Data Structures

See slcJobFunc_ts described in Async Utilities Design.

3.2 cstrAsync Thread Detailed Design

The cstrAsync Thread is the Async controller thread for the SLC IOC.  This simple thread finds out when each cycling function is ready to run and sends a message to the corresponding Async  handler thread which runs that function. 

3.2.1 Functional Flow

3.2.1.1 Thread Initialization

·        slcAsyncInit() is called (see Async Utility web page)  to set up the Async Global area and perform other initialization. This initialization includes reading Cycling parameters from the SLC database for all cycling functions.  slcAsyncInit sets slcThreads_as[cstrAsync].active = epicsTrue. This tells the executive that the thread has started.  The asyncExists global flag is set to true also.  If slcAsyncInit() returns bad status, cstrAsync exits.

 

3.2.1.2 Periodic Thread Processing

1.      There will be no handling of Check Functions from Paranoia (or other messages from VMS) in cstrAsync like there is in the SLC micro TEST job. On the SLC IOC, that functionality is provided by the cstrHdlr thread.

2.      In a Loop, perform the following processing:

·        Check the stop flag slcThreads_as[cstrAsync].stop.  If it is set, call cstrAsyncExit.

·        Get current time for use below.

·        Call cstrAsyncSendFuncMsg() to send a message to a handler for the next cycling function to be run.

·        Call epicsThreadSleep(1)  to sleep for one second.

WORK IN PROGRESSThis logic was in slcAsyncSleep before.  Clean this up it’s redundant.  Change it per latest design.

Do logic like was in slcAsyncSleep ** PUT THIS IN cstrAsyncSendFuncMsg() ***********************

Introduction

Wait up to forever for a cycling function of the calling job to be be ready to run. Return when either the cycling function is ready or SLC exec has asked for the task to exit (async task stop flag), polled every second. Return with the function that is most past-due. To determine if a cycling function is ready, the following conditions must be true. Note that current values of supertype 2 CSTR secondaries (MMSK, CMSK, and HSTA) must be retrieved from the database first:

§         The current time exceeds the time of the previous action (ie. exceeds the last time this function was executed: stored in slcJobFunc_ts) by the cycling period (CTIM). The cycling period is either CYCL or SCAN, if the bit for the function is set in MMSK and SCAN is less than CYCL. Get SCAN from the database only if the MMSK bit is set (only if needed). See Steph's PDL below for more details.

§         The function must be enabled as determined by checking the appropriate bit in CMSK.

§         The job must be enabled as determined by checking the appropriate bit in HSTA.

 

Function Description

The first thing slcAsyncsleep() does is to call slcAsyncReady() NO< IT”S STATIC to wait on  for the global area to be ready to be accessed. If it returns an error, return with error from here.

LOOP:

·        Check if the "stop" flag for the async thread associated with the current job is set. This is accomplished by looking at the stop flag in the slcThread_as for the async job associated with the current entry in slcJob_as as indicated by the input jobEnum.  If the "stop" flag is set, immediately exit with the proper status indicating exit requested. The task itself then does cleanup processing and exits.

·        Call slcAsyncUpdSt2() to get the latest values from the database for CSTR: CMSK, HSTA, MMSK, and SCAN (you’re really getting values for all functions across the ioc).   Note: Some common cycling functions (like Magnets) can have CSTR:CMSK changed from the SCP Cluster Status Panel. However, there are other cycling functions that are not supported for toggling CSTR::CMSK on the Cluster Status Panel.
For the purposes of this code, we'll just always support it being changed for all cycling functions as far as code in this function goes.

·        Call slcAsyncGetCycleTime() to get the cycle time for the function.  

·        Go through all the functions in slcJobFunc_as for the input jobEnum and see if there an async function for this job that is ready to be executed based on current time, CSTR: CTIM, CYCL, SCAN, HSTA, CMSK, and MMSK. Return an indication as to which async function it is to the caller in *asyncFunc_as and slcFuncIx output parameters.

·        If there is nothing to do, then sleep for 1 second by calling epicsThreadSleep.

·        In the above two steps, it is necessary for the function which is called to look at all cycling functions for the current thread. That is done by looking in slcJobs_as[jobEnum] for the current thread, and picking up the first cycle function index and number_of_functions. Those two values are used to inspect the slcJobFunc_as and associated arrays of secondary values.

·        Go back to (1) and repeat.

3.2.1.3 Messages Received by cstrAsync

No messages are received by cstrAsync.

3.2.1.4 Termination

Termination is initiated by the slcExec thread setting the slcThreads_as[cstrAsync].stop flag to TRUE.  When that happens, call cstrAsyncExit() to release resources and clean up.  Then, the main thread simply returns.

3.2.2 Global  Data

slcThread_as[cstrAsync_e].active is set.

asyncExists (in slcGlob) is set.

For a description of Flags and Mutexes Used by Async Tasks, see the Async Utilities Document.

 

3.2.3 Resource Management

Writes to the SLC database will be metered in a manner similar to the SLC Micro Test Job by calling the utility function slcAsyncMeterDbsend().

3.2.4 Message Logging

All messages logged are stated explicitly in this document.

3.2.5 Diagnostics

Update the following diagnostics, reset some on-demand.
They will be accessed from the IOC shell via the iocsh commands.

·        Diagnostics list is TBD

3.2.6 Major Routines

The following table shows the names of Functions on the SLC RMX micros and the corresponding cstrAsync Functions on the SLC IOC which accomplish roughly the same functionality.

This code exists in ioc/cstr/cstrAsync.c and cstrAsync.h

SLC Micro Function

SLC IOC Function

TESTMAIN (job)

cstrAsync (thread)

EXEC_CHK1

cstrHdlrChk1

EXEC_CHK2

cstrHdlrChk2

EXEC_CPUM

cstrHdlrCpum

None

cstrHdlrChk3

1.     void cstrAsyncThread(void)

cstrAsyncThread is the main procedure and loop of the cstrAsync thread. It initializes the cstrAsync resources and globals, and then enters a loop where is figures out the next Cycling function to be executed and sends a message to the Handler that processes it. It cleans up resources when terminating.

Functions called only from within cstrAsync

1.     void cstrAsyncExit()

Called to do cleanup processing before thread exit.

1.      Call slcAsyncExit() to release global area resources.

2.      Set slcThreads_as[cstrAsync].active = epicsFalse

3.      Set slcThreads_as[cstrAsync].tid_ps = NO_THREAD

4.      Log a "cstrAsync Stopped and out of service" informational message to CMLOG.

5.      return

3.3 cstrHdlr Thread Detailed Design

The CSTR Handler Thread (cstrHdlr) services all TEST job messages from VMS by sending replies back to VMS. SlcAsyncChk1() (CHK1) cycling function is called after each message received.

It also services  messages sent from the cstrAsync Thread by running the cycling function as indicated by the message.  The cycling functions periodically update SLC database CSTR health and status secondaries.  This health and status data is read from Global Memory (it was stored there by this and this and other Async handler threads).  IOC health and status data is also read from associated EPICS PVs and written to CSTR by one of the cycling functions.  It then queues an update request to the SLC database service.

3.3.1 Functional Flow

3.3.1.1 Initialization

The cstrHdlr thread performs the following as initialization

·        Create the message queue using the messageQCreate utility.  Cleanup and exit if this fails.

·        Call cstrAsyncInitChk1() to initialize dblist() and do dblget() for CTIM, UTIM, and ELPS (one value per function)

·        Call cstrAsyncInitChk2() to initialize dblist() and do dblget() for NRUN, FAIL, PUPD, and PVAX (one value per function)

·        Call cstrAsyncInitST2() to initialize dblist() and do dblget() for SCAN (one value per function), HSTA, CMSK, MMSK, and FMSK (one value per ioc)..  

·        Call private function cstrInitMicrStatus() which initializes micro status data items and calls private function cstrProcMicrSts() to set AMSK and MSTA secondaries into the SLC database per the table below. It also echos CSTR:VTIM in MTIM.  Call local cleanup routine to exit this thread if bad status was returned from cstrInitMicrStatus().

·        CSTR:VTIM will not be checked to see if it is 25 minutes older than current micro time as it is on the SLC micro. On the SLC micro, that test is done to see if no SCP was involved in the boot request (in which case fast feedback loops are not to be restarted).

·        Set slcThreads_as[cstrHdlr].active = epicsTrue

3.3.1.2 Normal Processing Loop

The cstrHdlr thread is similar to the logic of any message-queue driven thread in the slcIOC.
It accepts incoming message commands and acts on them. The basic loop is:

While (slcThreads_as[cstrHdlr].stop !=epicsTrue)

·        Read message from message queue using the msgQMsgRecv utility.
Gets the data word length, function code

·        If the message is from VMS:

1.      Perform the function based on function code in msgheader
If not a valid function code, drop the message

2.      Allocate buffer for reply message using the msgQGetSmallBuffer utility

3.      Create reply data; converting for VMS

4.      Copy the source SCP ID from the request header to the destination SCP ID used by message logging. Reset after reply is queued.

5.      Copy the source and destination from the request header to destination and source, respectively, in the reply header. Copy the VMS timestamp and function code from the request to the reply header. Set the proper data length in the reply header.

6.      Release the incoming message buffer back to the pool

7.      Send message to the msgSend thread using the msgQMsgReply utility.
Sets up the msgheader in native format

8.      Call Async function cstrHdlrChk1() to perform a CHK1 function.

·        Else, if the message is from cstrAsync

1.      Based on the indication in the message of what to do , call one of the cstrAsync check functions:
cstrHdlrChk1(dbUpdateNeedeed)
cstrHdlrChk2(dbUpdateNeeded)
cstrHdlrCpum(dbUpdateNeeded)
cstrHdlrChk3(dbUpdateNeeded)
Those functions call dblput() (not chk3) as needed to write to the SLC database.

2.      Those functions return an indication if the database needs to be updated.

3.      If any of those functions return bad status, call cstrHdlrExit() to exit the task

4.      If the check function returned an indication that the database update needs to be sent to VMS, call slcAsyncMeterDbSend(asyncFuncIx). That indication is set only if something changed and needs to be updated. If it returns bad status, call cstrAsyncExit() to exit the task.

5.      Call slcAsyncSetFcnStats(asyncFuncIx) to update statistics for the function in the async function (global) table (this is done inside CHK functions on RMX). If it returns bad status, call cstrAsyncExit() to exit the task.

·        Update statistics for the CHK1 function in the async function tables by calling slcAsyncSetFcnStats()

·        Send a request to update the Alpha database by calling slcAsyncDbSend().

3.3.1.3 Messages Received by the cstrHdlr

The cstrHdlr thread performs the functions related to the follow messages from the SLC Control System,

3.3.1.3.1 IOC_STOP

The slcExec sends this message to tell the thread to terminate itself. The messages is an internal slc ioc message, not from VMS. The cstrHdlr thread terminates without a reply.

3.3.1.3.2 TEST_ECHO

Reply with data exactly as sent.

3.3.1.3.3 TEST_ECHO_MWORD

Reply with blocks of repetitions for given word.

3.3.1.3.4 FUNC_TEST

Existence check from PARANOIA. Reply with data exactly as sent.

3.3.1.3.5 TEST_ERR_METER_RESET

Reset cmlog throttling (TBD). Reply with the throttling reset status.

3.3.1.4 Termination

Termination is initiated by the slcExec thread setting the slcThreads_as[cstrHdlr].stop flag to TRUE, or when the cstrHdlr thread receives a IOC_STOP message.

In either case:

·        Set slcThreads_as[cstrHdlr].active = epicsFalse

·        Destroy the message queue using the messageQRelease utility. This releases any message buffer held in the message queue first.

·        Set slcThreads_as[cstrHdlr].tid_ps = NO_THREAD

·        log a "cstrHdlr stopped and out of service" message to CMLOG .

·        Log a MICR_DOWN "Stopped and out of service" informational message to CMLOG.  New msg in ref_slcmsg:micrdef.msg.

·        Return

See the Async utility slcAsyncExit() for a description of resources relased when the slc ioc is stopped.

3.3.2 Global Data

1.      slcThreads_as[cstrHdlr].stop is read.

2.      See the asyncUtil design page for a description of the Job Global Area where the following data is stored.  All access to Global is through Async Utilities.

3.      For a description of Flags and Mutexes Used by Async Tasks, see the Async Utilities Document.

4.      The following CSTR Supertype I (read-only) secondaries are read as part of cstrHdlr processing. Much of the processing is generalized for all ASYNC threads and is therefore handled within utilities listed in the Async Utilities Section below.

CSTR Secn

Description

CNAM

Cycling function name (job + function name). Read at initialization time only

CYCL

Cycle length in seconds for this function.

MTRL, MTRC, MAXT

Database-write metering parameters (length, count, and max_time).

5.      The following CSTR Supertype II (read-only) secondaries are read as part of cstrAsync processing. Much of the processing is generalized for all ASYNC threads and is therefore handled within utilities listed in the Async Utilities Section.

CSTR Secn

Description

               HSTA

Status. Set by Cluster Status Panel. Used to tell if an ASYNC is enabled/disabled.
Read by IS_FCN_ENABLED() on RMX.

               VTIM

Read at initialization time only.  Used in setting MTIM

CMSK

Mask of functions in this IOC which should cycle asynchronously. Set by Cluster Status Panel..
Read by IS_FCN_ENABLED() on RMX.

MMSK

Mask of functions that have CA monitors.
Used in calculating when to do database updates (if set, use minimum of CYCL and SCAN).

FMSK

Mask of functions that have CA monitors.
Used in calculating when to do database updates (if set, force at SCAN interval).

SCAN

Cycle length in seconds for this async function.
Used in conjunction with MMSK, FMSK, and CYCL.

6.      The following CSTR Supertype III secondaries are handled by the crate verifier on the SLC micros.
On the SLC IOC, they are set to zero at SLC IOC startup time by cstrAsync and then not set periodically.

CSTR Secn

Description

CRTS

Camac Crate Status Mask

CRTT

Camac Crate Temperatures (degF?)

CRV1 to CRV7

Camac Crate Voltages (V?)

CAM

Available CAMAC memory pool (bytes)

NTIM

Last time was TSTA updated by micro

TSTA

Timing job interrupt status

7.      The following CSTR Supertype III secondaries are set to the values indicated in the table below at SLC IOC startup time by slcAsyncInit().
There is no periodic processing for these secondaries.

CSTR Secn

Description

Init. Value

MTIM

Last Successful IPL from micro

VTIM

8.      The following CSTR Supertype III secondaries are periodically processed.
dblistalloc()/dblist() are called at processes startup time. Then, dblput is called to write values to the database as part of periodic cycling.

CSTR Secn

Description

UTIM

Last database update timestamp per job

CTIM

Last async cycling function update timestamp per job

ELPS

Elapsed time for last cycling function update per job (seconds)

NRUN

Number of executions in last calculation interval per job

FAIL

Number of times dbupdate failed in last calculation interval per job

PUPD

Percent of executions triggering database update in last calculation interval per job.

PVAX

Percent of executions triggered by VMS message in last calculation interval per job.

 

CPU

CPU idle time (percent)

 

RMX

Available memory (bytes)

 

AMSK/MSTA/JMSK

Masks of Active Jobs/Micro Job Status/Jobs Included (JMSK is SuperType I)
At startup and periodically, CSTR AMSK (job active mask) and MSTA(micro job status) are set.

All these bit masks are zero referenced (32 jobs are represented by bits 0 – 31).
AMSK is set by looking the slc job array (slcJobs_as) and setting a bit for each index where the non-zero threads (async and/or hdlr) have the active flag set. Each bit in AMSK corresponding to a particular job is set if ALL the tasks associated with the job are active AND the correspoinding JMSK bit is set.. Then MSTA is set to 1 if AMSK == JMSK and 0 otherwise. This logic is consistent with logic in ref_rmx_test:procmicrsts.f86.

 

9.      The following CSTR Supertype III secondaries are handled by the Magnet Handler (not by cstrAsync).

CSTR Secn

Description

MAGF

Current Magnet Job Function Code

BTIM

Timestamp when magnet job was initialized

 

 

3.3.3 Resouce Manement

3.3.3.1 Message Queue

The cstrHdlr thread creates a message queue for incoming messages. The message queue is destroyed before the thread exists. The cstrHdlr thread uses the messageQRelease utility to destroy the queue, which first reads out each message in the queue and releases the message buffer it points to, then destroys the queue.

3.3.3.2 Memory Pool

Once it is done acting upon the incoming message the cstrHdlr thread releases the message buffer in which it was stored. The cstrHdlr thread allocates the memory block required to store the reply data for the current reply message.

3.3.4 Message Logging

Many of the error messages logged by the cstrHdlr thread are generated and logged by utility functions. But, for messages logged here, the cstrHdlr thread will log all status and error messages using the slcCmlogLogMsg utility (described in the slcCmlog Utilities section of the General Purpose Utilities document).

The cstrHdlr logs messages for the following conditions:

·        Service availabilty change

·        Invalid function code

·        Unable to queue a reply

·        Queue full

3.3.5 Diagnostics

See the requirements document for a list of diagnostics that are updated and reset upon demand.

3.3.6 Major Routines

This code exists in ioc/cstr/cstrHdlr.c and cstrHdlr.h

1.     void cstrHdlrThread(void)

cstrHdlrThread is the main procedure and loop of the cstrHdlr thread. It initialized the cstrHdlr resources and globals, and waits for message at the message queue. It cleans up resources when terminating.

2.      int cstrAsyncChk1(void)

This is a static function (called only by another function within this .c file).

Call dblistalloc(), dblist() are called to set up lists for later access to CTIM, UTIM, and ELPS (one value per function).  Pointers to lists are in file scope for use by other utilities.  Dblget() is called to get initial values which may be overwritten later.  If any calls fail, return -1 (failed), otherwise 0.

 

3.      int cstrAsyncInitChk2(void)

This is a static function (called only by another function within this .c file).

Call dblistalloc(), dblist() are called to set up lists for later access to NRUN, FAIL, PUPD, and PVAX (one value per function).  Pointers to lists are in file scope for use by other utilities.  Dblget() is called to get initial values which may be overwritten later.   If any calls fail, return -1 (failed), otherwise 0.

 

4.      int cstrAsycInitST2(void)

This is a static function (called only by another function within this .c file).

Call dblistalloc(), dblist() are called to set up lists for later access to HSTA, CMSK, MMSK, and FMSK (one value per ioc).  Pointers to lists are in file scope for use by other utilities.  Dblget() is called to get initial values which may be overwritten later. If any calls fail, return -1 (failed), otherwise 0.

 

Call dblistalloc(), dblist() are called to set a list for SCAN (one per function).  A pointer to the list is stored in file scope for use by other utilities.  Dblget() is called to get initial values which will be overwritten later. If any calls fail, return -1 (failed), otherwise 0.

 

 

cstrHdlr Check functions

5.     int cstrHdlrChk1(Boolean dbUpdateNeeded)

dbUpdateNeeded is an output parameter.

Call cstrProcMicrSts() to process and update CSTR secondaries AMSK and MSTA.
Call slcAsyncProcChk1() to update dblget data and do dblput() for UTIM, CTIM, and ELPS.
Unlike RMX, don't call slcAsyncSetFcnStats(Function_enum) to set statistics in the Global Area for this async function. It's called in the main routine.

Set dbUpdateNeeded = true (we always do dbupdate for this check function)

Any failures in the logic above cause -1 (failed) to be returned.  Otherwise 0 (success) is returned.

 

6.      int cstrHdlrChk2(Boolean dbUpdateNeeded)

dbUpdateNeeded is an output parameter

 

Call slcAsyncProcChk2(dbUpdateNeeded) to dblget the data as needed and do dblput() for , FAIL, PVAX, and PUPD.

Do dblput() on all lists where the data  has changed only.
Unlike RMX, don't call slcAsyncSetFcnStats(Function_enum) to set statistics in the Global Area for this async function. It's called in the main routine.

      Any failures in the logic above cause -1 (failed) to be returned.  Otherwise 0 (success) is returned.

 

7.     int cstrHdlrCpum(Boolean dbUpdateNeeded)

dbUpdateNeeded is an output parameter

Call epics dbget (Epics runtime database access call) to get CPU idle time from PV IOC::1:CPU and put it into the CPU dblist
Call epics dbget (Epics runtime database access call) to get Available Memory from PV IOC::1:MEM and put it into the RMX dblist
Note: The parameters for these Epics dbGet calls were set up at initialization time.
Call dblput() to put the CPU and RMX lists into local database and set dbUpdate=True since this data will change often.
Unlike RMX, don't call slcAsyncSetFcnStats(Function_enum) to set statistics in the Global Area for this async function. It's done in the main routine.

 

8.      cstrHdlrChk3(Boolean dbUpdateNeeded)
This is a future CHK function. The current values of TBD are fetched from TBD and copied to TBD EPICS PVs. NO SLC database update is done so we returndbUpdateNeeded = False.

 

9.     int cstrProcMicrSts()
This function processes AMSK and MSTA per the table above.

This function is only called by other cstrAsync routines.  So, it is static file scoped.

Clear local AMSK bit array.

Go through slcThread_as and set a bit in AMSK for each active job.  An active job has the active flag set in slcThread_as for all the threads that it has.     (a given job may have zero or one hdlr/async threads).  If they are not all set, then the bit is not set in AMSK for that job.

Call dblput() to put local AMSK into CSTR:AMSK.
If AMSK != JMSK, set MSTA to BAD(0)
ELSE set MSTA to ALIVE(1).
Call dblput() to put local MSTA into CSTR:MSTA
When it is noticed that a thread has exited (ie AMSK is different than JMSK)
:

o       It is desired to have users notice the problem and attempt a restart manually (and if the thread that's dead is not critical, then they could time the restart to be less invasive). So, no automatic restart will be attempted.  BTW, this is the way EPICS works - when a task suspends or exits, it doesn't crash the IOC. Instead people start noticing (sometimes subtle) problems and notify controls. Doesn't happen very often.

o       A message will be logged indicating the thread that has died. This message is logged every time through as a reminder that repair and restart are needed.

o       An automatic SLC restart should not be attempted since the fatal error would probably just happen again.

10. int cstrInitMicrStatus().

Initialize data items in global and dblists associated with micro (ioc) status after startup.

This function is only called by another cstrHdlr routine.  So, it is static file scoped.

Call dballoc() and dblist() to set up lists for CSTR,[this_micro],1:AMSK, MSTA.
Likewise, do the same for CPU, and RMX (one per SLC IOC) for use by CPUM check function.
(Those CSTR secondaries are one per SLC IOC)
The lists are in file scope for future use cstrProcMicrSts().

CSTR,[this_micro],1,[CTRS, CRTT, CRVn, CAM, NTIM, and TSTA, ] are set in the database once using dblistalloc(),dblput(), slcAsyncMeterDbSend(forceUpdate),dblistfree(). They are never set again.

Do a dballoc(), dblist, dblget(), and dbfree() for JMSK.  Store JMSK in file scope for use by another function.

Epics PV's (IOC::1:CPU and IOC::1:MEM) will be accessed for use in calculating SLC database CPU and RMX CSTR secondaries and the initial values will be written to the SLC database using dblput().
Perform Initialization for access to these Epics PV's as follows:

o       call EPICS dbNameToAddr() to get the pointer for each PV and EPICS dbGet() for the the initial value. dbGet requires a dbrType argument. That argument will be hard coded based on what's in primary.dbs for the particular secondary (alternately, it would be possible to determine the proper value using a yet unwritten but handy utilitiy in database utility dbget.c called dbgetDbrType that converts from dbgetFormat and dbgetWidth to an EPICS dbrType).

o       A bad status return from any db routine is cause for exit and proper cleanup (dblistfree's, reset "active" flag, etc).

o       The PV name format will be:
CSTR:(4 char ioc name):1:(secondary name of interest).
The 4 char ioc name is determined using executive routine slcGetIOCName().

A bad status return from any of these db calls is cause for exit and cleanup.

Call cstrProcMicrSts()

The value of CSTR:VTIM is echoed to VMS in CSTR:MTIM as an indication that the micro's database has been downloaded.  This is accomplished by calling an local cstrAsync function which will do a dblistalloc()/dblist() for each secondary, dblget() for CSTR:VTIM, dblput() putting the VTIM value to the database using the MTIM list.  Dbupdate() is done below by MeterDbSend().

Call slcAsyncMeterDbSend(forceUpdate=yes) to do a non-metered dbupdate() to the VMS  database for all the data we set into the lists above.

Call Dblistfree() to free the pointer and data lists for MTIM and VTIM.

 

11. void cstrHdlrExit(void)

This routine is called just before the thread terminates. It sets the active flag to false and destroys the cstrHdlr message queue.

12. void doStop(void)

This routine is called when the TEST_STOP message is received. It sets the slcThreads_as[cstrHdlr].active flag to false, causing the thread to terminate.

13. void doEcho(TBD)

This routine is called when the TEST_ECHO message is received.

14. void doEchoMWord(TBD)

This routine is called when the TEST_ECHO_MWORD is message received.

15. void doExistance(TDB)

This routine is called when the TEST_EXISTANCE message is received.

16. void doErrMeterReset(TBD)

This routine is called when the TEST_ERR_METER_RESET message is received.


SLC-Aware IOC Home Page | LCLS Controls | EPICS at SLAC | SLAC Computing | SLAC Networking | SLAC Home

Contact: Ron MacKenzie
Last Modified: Feb, 2005. by RONM.