From: "Pierrick Hanlet" <[email protected]>
To: "Tech Talk" <[email protected]>
Sent: Saturday, April 13, 2013 1:38:29 PM
Subject: sequencer and c-code
Hi all,
I'm developing a state machine for a string of superconducting
magnets. I'm reading from an
external configuration database (cdb) to pick up fields (alarm,
adel, scan, etc) for each of my
PVs as well as the state transition parameters. At present, on each
entry block of each state, I
call my c-function to read from the cdb and fill a global struct
with the field values for each PV.
Since the list may change in each state, I have arrays for each
field. For example:
PV.name[ndx] and PV.hihi[ndx] which I fill for each state and these
are global in a header file.
I also have, in another header file, all of my assignments:
e.g. SS2cx01[4] is assigned to MICE-SS2-CX-01:RDGK.HIHI in a header
file.
What I want to do is to have another c-function, SetPVFields(),
which invokes seq_pvPut(). Since I
call SetPVFields(ssId,State,ndx) in a loop over ndx in my .st file,
I want to be able to relate PV.name[ndx]
with pvIndex() inside of my SetPVFields() function. Is there a way
to do this? One thought that I had is
to create the relationship array between pvIndex and the PV name in
the global entry block and use
it inside of SetPVFields(), but I'm not sure of the details and this
does not strike me as very elegant.
Thanks,
Pierrick
Hey Pierrick,
Sorry I didn't get back to you Friday. After looking over your code the only thing I think you're missing for seq_pvPut() is the Id for the PV. So I think you're right in that if you create an additional array to hold the values from pvIndex, your c should work.
However, I tend to agree with Ben's comments. Doing this in python as a CA client may be an easier way to go. Especially as it may evolve over time.
I can take a look at it again if you've updated the code. Just write me offline.
Wesley