Hi Dehong,
It was a really good idea to raise this on tech talk. It looks like you're basically doing channel access within a record. I tried that too; it was awful. I think it will in the long run be a lot more work than writing the equivalent SNL program, because this is the sort of thing SNL was designed to do. SNL includes a lot of features developers have found helpful for jobs like this: such as connection management, separate threads, and array syntax for collections of PV names. Plus, SNL is well documented, and there are lots of examples from which to lift code fragments.
Tim
----- Original Message -----
From: "Dehong Zhang" <[email protected]>
To: "Andrew Johnson" <[email protected]>, [email protected]
Sent: Thursday, August 23, 2012 5:47:22 PM
Subject: RE: Creating INLINK/OUTLINK in record support
Hi Andrew and Tim,
Thanks you very much for the advices.
I am trying to build an IOC/record to watch and protect a large system, where
I need to access 100+ PVs. Since those PVs have very similiar names, I was
hoping to hard-code the common part of the names, then use something
like the dbNameToAddr function to create an array of links to use in for loops.
Now, I am doing it half-automatic: list all those PVs in the dbd file, then put
them into some arrays in init_record, then use for loops to fetch their values.
This way i almost get what i wanted. If we can avoid the need to list all the PVs
in the dbd file, both the dbd and c files will be even shorter.
Best regards,
Dehong
________________________________________
From: Andrew Johnson [[email protected]]
Sent: Thursday, August 23, 2012 3:06 PM
To: [email protected]
Cc: Zhang, Dehong
Subject: Re: Creating INLINK/OUTLINK in record support
Hi Dehong,
On 2012-08-23 Zhang, Dehong wrote:
Is it possible to create these things dynamically inside a record, so that
I can access PVs on another IOC, without listing them all in the dbd file
of my custom record?
In other words, is there something like the
dbNameToAddr
to use for creating and accessing LINKs?
Anything is possible if you're willing to write enough code, but...
The dbNameToAddr() routine is only for local PVs; CA links are implemented
using the code in dbCa, and initializing those links happens at iocInit() or
whenever the INP/OUT link value is changed. However there isn't really a
public API for that kind of thing, and I don't really recommend that you try
to do that.
It sounds to me like you're creating a new record type when maybe you should
be writing a State Notation Language program. Why don't you step back a bit
and reconsider what you're trying to do? Feel free to explain here if you
want more advice, but you will need to explain the bigger picture because I
wouldn't recommend trying what you describe above.
HTH,
- Andrew
--
Never interrupt your enemy when he is making a mistake.
-- Napoleon Bonaparte