EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  <20072008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  <20072008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: error code mapping best practice
From: Maren Purves <[email protected]>
To: "Rodney R. Porter" <[email protected]>
Cc: [email protected]
Date: Tue, 10 Jul 2007 17:04:54 -1000
I have something like this:

void dhsDhsErrHd (int status)
{
char string[DHS_STRING_LENGTH];

printf("DHS error: ... status: %d\n", status);
switch (status)
{
case DHS_S_CMD_BULK_SENT: strcpy (string, "Message sent as bulk data"); break;
case DHS_S_CMD_DELETE : strcpy (string, "Deleting command structure"); break;
case DHS_S_CMD_MSG_SENT : strcpy (string, "Message sent as regular message"); break;
case DHS_S_CMD_NEW : strcpy (string, "Creating command structure"); break;
case DHS_S_COND_TIMEOUT : strcpy (string, "Condition variable timed out"); break;
case DHS_S_CONNECT : strcpy (string, "Client is requesting connection"); break;
case DHS_S_DISCONNECT : strcpy (string, "Client has disconnected"); break;
case DHS_S_EL_EXIT : strcpy (string, "Exit the event loop"); break;
case DHS_S_FN_ENTRY : strcpy (string, "Entering function"); break;
case DHS_S_FN_EXIT : strcpy (string, "Exiting function"); break;


[...]

lying around. This runs on an IOC and is part of the 'device support'
for FITS files - obviously you can extend the number of codes to any
enum value.

If I was to do this again today I'd probably put it into a table
(hopefully pvLoad-able) and use a genSub (I think the code above
predates genSubs, at least it predates genSubs being wide-spread).

Aloha,
Maren

Rodney R. Porter wrote:
I have implemented similar conversions, though with considerably less than
300 states, using either a genSub record or SNL program.  I choose between
them based on what is needed for other support for the device or instrument.
Rodney Porter


On 7/9/07 4:38 PM, "Emmanuel Mayssat" <[email protected]> wrote:

Hello,
I have a device that returns error codes as integers (error code stored
in a ai record).
The error codes needs to be mapped to the corresponding strings.
I have approximately 300 error codes.
What would you say is the most elegant way to implement the translation?
Custom record? seq? etc.

Thank you for your advice,
--
E






References:
Re: error code mapping best practice Rodney R. Porter

Navigate by Date:
Prev: Job Opennings at NSLS II bdalesio1
Next: dbLoadRecord of dbLoadTemplate Emmanuel Mayssat
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  <20072008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: error code mapping best practice Rodney R. Porter
Next: sequencer macro and debug log Emmanuel Mayssat
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  <20072008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 10 Nov 2011 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·