nodeinfodb_h

/*******************************************************************************
**  Copyright 1996-2016, Fermi Research Alliance, LLC.  All rights reserved.
*******************************************************************************/
/*
**++
**  FACILITY:  ACNET (Accelerator Controls Network)
**
**	The Accelerator Controls Network is a proprietary network
**	protocol used in the Fermilab Controls System.  Every node
**	in this network is assigned a 6-character name and a 16-bit
**	trunk/node value.
**
**  ABSTRACT:
**
**	nodeinfodb.h defines types and macros that are of use to any
**	module interested in ACNET node information
**
**  AUTHOR:  Glenn C. Johnson
**
**  MODIFICATION HISTORY:
**
**	07 Aug 96  G Johnson	created
**	21 May 98  T Zingelman	added new fields (+ spares)
**	05 Nov 98  G Johnson	several changes
**	15 Sep 99  G Johnson	remove BULB, add TWT
**	01 Mar 00  G Johnson	more fields
**	02 Mar 01  G Johnson	add OPSYS codes
**	06 Mar 01  G Johnson	add devname_reboot
**	29 Oct 03  G Johnson	add bkeeper_name, bkeeper_email,
**				devname_version, is_gets32_sets32
**	23 Jun 06  G Johnson	Add VME(HRM), MADC, and Middle RF
**	27 Sep 16  G Johnson	Switch to new view in 'johnson'
**				table which has di's in addition to names
**--
**/
/******************************************************************************/

#ifndef	_nodeinfodb_h	/* include only once */
#define	_nodeinfodb_h

#include "cnsparam.h"

/*******************************************************************************
** data base entry: this structure has to match the db table:
** appdb.johnson.acnet_node_info table
*/
#define LEN_NODE_DESCRIPTION	30	/* length of node description */
#define LEN_NODE_LOCATION	30	/* length of node location */
#define LEN_NODE_KEEPER_NAME	30	/* length of node keeper name */
#define LEN_NODE_KEEPER_EMAIL	30	/* length of node keeper email */
#define LEN_NODE_ATTR_DESCRIPTOR	30	/* length of node attribute descriptor */

#define	NODE_SOFTWARE_TYPE	1	/* software type */
#define	NODE_ARCHITECTURE_TYPE	1	/* software type */
#define	NODE_SYSTEM_TYPE	2	/* system type */
#define	NODE_HARDWARE_TYPE	3	/* hardware type */
#define	NODE_STATUS_TYPE	4	/* status type */
#define	NODE_AREA_TYPE		5	/* area type */
#define	NODE_OPSYS_TYPE		6	/* operating system type */

/*******************************************************************************
** System ID codes:
*/
#define NODEDB_SYSTEM_CENTRAL	1	/* Central */
#define NODEDB_SYSTEM_CONSOLE	2	/* Console */
#define NODEDB_SYSTEM_FRIG	3	/* Frig */
#define NODEDB_SYSTEM_VACUUM	4	/* Vacuum */
#define NODEDB_SYSTEM_TECAR	5	/* TECAR */
#define NODEDB_SYSTEM_MECAR	6	/* MECAR */
#define NODEDB_SYSTEM_CAMAC	7	/* New Front-end (CAMAC) */
#define NODEDB_SYSTEM_NFE	7	/* New Front-end (CAMAC) */
#define NODEDB_SYSTEM_UTIL	8	/* Utility */
#define NODEDB_SYSTEM_LLRF	9	/* Low-level RF */
#define NODEDB_SYSTEM_HLRF	10	/* High-level RF */
#define NODEDB_SYSTEM_BPM	11	/* Beam Position Monitor */
#define NODEDB_SYSTEM_QPM	12	/* Quench Position Monitor */
#define NODEDB_SYSTEM_GPIB	13	/* GPIB */
#define NODEDB_SYSTEM_SWIC	14	/* SWIC */
#define NODEDB_SYSTEM_QXR	15	/* QXR */
#define NODEDB_SYSTEM_D0	16	/* D0 experiment */
#define NODEDB_SYSTEM_GFSDA	17	/* GFSDA */
#define NODEDB_SYSTEM_INST	18	/* Instrumentation */
#define NODEDB_SYSTEM_DAMPER	19	/* Dampers */
#define NODEDB_SYSTEM_EXPCNTRL	20	/* Experimental control */
#define NODEDB_SYSTEM_LINAC	21	/* Linac */
#define NODEDB_SYSTEM_MOTION	22	/* Motion Controller */
#define NODEDB_SYSTEM_NETUTIL	23	/* Network Utility */
#define NODEDB_SYSTEM_TWT	24	/* Traveling Wave Tube */
#define NODEDB_SYSTEM_TLG	25	/* Time Line Generator */
#define NODEDB_SYSTEM_EPICURE	26	/* New New Front End (Camac) */
#define NODEDB_SYSTEM_NNFE	26	/* New New Front End (Camac) */
#define NODEDB_SYSTEM_JAVA	27	/* Java Control System Prototype */
#define NODEDB_SYSTEM_ECOOL	28	/* Electron Cooling */
#define NODEDB_SYSTEM_ELENS	29	/* Electron Lens */
#define NODEDB_SYSTEM_BLM	30	/* BLM - Beam Loss Monitor */
#define NODEDB_SYSTEM_FBI	31	/* FBI - Fast Bunch Integrator */
#define NODEDB_SYSTEM_CLOCK	32	/* Clock System */
#define NODEDB_SYSTEM_FLYWIRE	33	/* Flying Wire */
#define NODEDB_SYSTEM_SBD	34	/* SBD - Sampled Bunch Display */
#define NODEDB_SYSTEM_MDAT	35	/* MDAT */
#define NODEDB_SYSTEM_PHOTOINJ	36	/* Photo Injector */
#define NODEDB_SYSTEM_MUONCOOL	37	/* Muon Cooling */
#define NODEDB_SYSTEM_COLLIM	38	/* Collimator */
#define NODEDB_SYSTEM_MIDDLERF	39	/* Middle Level RF */
#define NODEDB_SYSTEM_MADC	40	/* MADC */
#define NODEDB_SYSTEM_NOVA	41	/* Nova */
#define NODEDB_SYSTEM_MODULATOR	42	/* Modulator */
#define NODEDB_SYSTEM_ERLANG_FE	43	/* Erlang Front End */
#define NODEDB_SYSTEM_MPS	44	/* Machine Protection System */
#define NODEDB_SYSTEM_MISC	99	/* Miscellaneous */
#define NODEDB_SYSTEM_OTHER	9999	/* Other (new category requested) */

/*******************************************************************************
** Hardware ID codes:
*/
#define NODEDB_HARDWARE_VAX	1	/* VAX */
#define NODEDB_HARDWARE_PDP	2	/* PDP-11 */
#define NODEDB_HARDWARE_MAC	4	/* Macintosh */
#define NODEDB_HARDWARE_MBI	5	/* Multibus I */
#define NODEDB_HARDWARE_MBII	6	/* Multibus II */
#define NODEDB_HARDWARE_VXI	7	/* VXI */
#define NODEDB_HARDWARE_ARM	8	/* ARM */
#define NODEDB_HARDWARE_PC	10	/* PC (Intel) */
#define NODEDB_HARDWARE_SPARC	11	/* SPARC */
#define NODEDB_HARDWARE_PXI	12	/* PXI */
#define NODEDB_HARDWARE_FPGA	13	/* FPGA */
#define NODEDB_HARDWARE_VME	30	/* VME */
#define NODEDB_HARDWARE_VMESRM	31	/* VME (SRM) */
#define NODEDB_HARDWARE_VMEIRM	32	/* VME (IRM) */
#define NODEDB_HARDWARE_VME1553	33	/* VME (1553) */
#define NODEDB_HARDWARE_VME_68K	34	/* VME (68K) */
#define NODEDB_HARDWARE_VME_PPC	35	/* VME (Power PC) */
#define NODEDB_HARDWARE_VMEHRM	36	/* VME (HRM) */
#define NODEDB_HARDWARE_NONSPECIFIC	98	/* Non-specific */
#define NODEDB_HARDWARE_OTHER	9999	/* Other (new category requested) */

/*******************************************************************************
** Software ID codes:
*/
#define NODEDB_SOFTWARE_FRIG	3	/* Frig */
#define	NODEDB_SOFTWARE_ACNET_NG	4	/* next generation ACNET */
#define NODEDB_SOFTWARE_MOOC	7	/* MOOC */
#define NODEDB_SOFTWARE_OOC	8	/* OOC */
#define NODEDB_SOFTWARE_CONSOL	9	/* Consolidator */
#define NODEDB_SOFTWARE_LABVIEW	10	/* Labview */
#define NODEDB_SOFTWARE_LCS	11	/* Local Control System (Linac) */
#define NODEDB_SOFTWARE_IRM	11	/* IRM */
#define NODEDB_SOFTWARE_CAMAC	12	/* New Front End (Camac) */
#define NODEDB_SOFTWARE_NFE	12	/* New Front End (Camac) */
#define NODEDB_SOFTWARE_JAVA	13	/* Java */
#define NODEDB_SOFTWARE_MULTICAST	14	/* Multicast */
#define NODEDB_SOFTWARE_ACSYS_ERLANG	15	/* ACSys Erlang */
#define NODEDB_SOFTWARE_ACSYS_FEF	15	/* ACSys Front End Framework */
#define NODEDB_SOFTWARE_MISC	99	/* Miscellaneous */
#define NODEDB_SOFTWARE_OTHER	9999	/* Other (new category requested) */

/*******************************************************************************
** Status ID codes:
*/
#define NODEDB_STATUS_OPERATIONAL	1	/* Operational */
#define NODEDB_STATUS_TEST		2	/* Test */
#define NODEDB_STATUS_OUT_OF_SERVICE	3	/* Out of service */
#define NODEDB_STATUS_OUT_OF_SERVICE_TEVATRON	98 /* Out of Service due to decommissioning of Tevatron */
#define NODEDB_STATUS_OBSOLETE		99	/* Obsolete */
#define NODEDB_STATUS_OTHER	9999	/* Other (new category requested) */

/*******************************************************************************
** Area ID codes:
*/
#define NODEDB_AREA_CENTRAL	1	/* Central */
#define NODEDB_AREA_BOOSTER	2	/* Booster */
#define NODEDB_AREA_TEVATRON	3	/* Tevatron */
#define NODEDB_AREA_LINAC	4	/* Linac */
#define NODEDB_AREA_PBAR	5	/* Antiproton */
#define NODEDB_AREA_SWYD	6	/* Switchyard */
#define NODEDB_AREA_CDF		7	/* Colliding Detector Facility */
#define NODEDB_AREA_D0		8	/* D0 Experiment */
#define NODEDB_AREA_MAININJ	9	/* Main Injector */
#define NODEDB_AREA_MRING	10	/* Main Ring */
#define NODEDB_AREA_CHL		11	/* Central Helium Liquifier */
#define NODEDB_AREA_TRN_GAL	12	/* Transfer Gallery */
#define NODEDB_AREA_XGAL	13	/* Cross Gallery */
#define NODEDB_AREA_RECYCLER	14	/* Recycler */
#define NODEDB_AREA_CUB		15	/* CUB */
#define NODEDB_AREA_BET		16	/* East Booster Tower */
#define NODEDB_AREA_BWT		17	/* West Booster Tower */
#define NODEDB_AREA_LINAC_ANNEX	18	/* Linac Annex */
#define NODEDB_AREA_NML		19	/* NML */
#define NODEDB_AREA_BEAM_LINE	20	/* Beam Line */
#define NODEDB_AREA_WILSON	21	/* Wilson Hall */
#define NODEDB_AREA_MW9		22	/* MW9 building */
#define NODEDB_AREA_MINIBOONE	23	/* MiniBooNE */
#define NODEDB_AREA_NUMI	24	/* NuMI */
#define NODEDB_AREA_WIDEBAND	25	/* Wideband */
#define NODEDB_AREA_MTA		26	/* MTA */
#define NODEDB_AREA_PHOTO_INJECTOR	27	/* A0 Photo Injector */
#define NODEDB_AREA_FCC		28	/* Feynman Computing Center */
#define NODEDB_AREA_E4R		29	/* E4 frig test building */
#define NODEDB_AREA_MCR		30	/* MCR */
#define NODEDB_AREA_MAC_ROOM	31	/* MAC room */
#define NODEDB_AREA_SMTF	32	/* SMTF */
#define NODEDB_AREA_HINS	33	/* HINS */
#define NODEDB_AREA_AIAB	34	/* ACNET in a Box */
#define NODEDB_AREA_NOVA_NEAR	35	/* Nova Near Detector */
#define NODEDB_AREA_HTS		36	/* HTS (Horizontal Test Stand) */
#define NODEDB_AREA_CMTF	37	/* CMTF (Cryo Module Test Facility) */
#define NODEDB_AREA_PXIE	38	/* PXIE (Project X Injector Experiment) */
#define NODEDB_AREA_NWA		39	/* NWA */
#define NODEDB_AREA_MUON	40	/* Muon */
#define NODEDB_AREA_EVERYWHERE	98	/* Everywhere */
#define NODEDB_AREA_OOSCOPE	99	/* Out of scope, including off-site */
#define NODEDB_AREA_OTHER	9999	/* Other (new category requested) */

/*******************************************************************************
** Operating System ID codes:
*/
#define NODEDB_OPSYS_VMS	1	/* VMS */
#define NODEDB_OPSYS_VXWORKS	2	/* VxWorks */
#define NODEDB_OPSYS_SOLARIS	3	/* Solaris */
#define NODEDB_OPSYS_FREEBSD	4	/* Free BSD */
#define NODEDB_OPSYS_SCO	5	/* SCO UNIX */
#define NODEDB_OPSYS_WNT	6	/* Windows NT */
#define NODEDB_OPSYS_WINNT	6	/* Windows NT */
#define NODEDB_OPSYS_MTOS	7	/* MTOS */
#define NODEDB_OPSYS_PSOS	8	/* PSOS */
#define NODEDB_OPSYS_MAC	9	/* Macintosh */
#define NODEDB_OPSYS_LINUS	10	/* Linux */
#define NODEDB_OPSYS_LINUX	10	/* Linux */
#define NODEDB_OPSYS_WIN2000	11	/* Windows 2000 */
#define NODEDB_OPSYS_OSX	12	/* Macintosh OS X */
#define NODEDB_OPSYS_WINXP	13	/* Windows XP */
#define NODEDB_OPSYS_WIN7	14	/* Windows 7 */
#define NODEDB_OPSYS_NONSPECIFIC	98	/* Non-specific */
#define NODEDB_OPSYS_MISC	99	/* Miscellaneous */
#define NODEDB_OPSYS_OTHER	9999	/* Other (new category requested) */

typedef	struct NODEDB			/* ACNET Node Information DataBase */
  {
  char nodedb_name[6];					/* ACNET node name */
  char nodedb_description[LEN_NODE_DESCRIPTION];	/* node description */
  char nodedb_location[LEN_NODE_LOCATION];		/* node location */
  char nodedb_keeper_name[LEN_NODE_KEEPER_NAME];	/* keeper's name */
  char nodedb_keeper_email[LEN_NODE_KEEPER_EMAIL];	/* keeper's email addr */
  char nodedb_bkeeper_name[LEN_NODE_KEEPER_NAME];	/* backup keeper's name */
  char nodedb_bkeeper_email[LEN_NODE_KEEPER_EMAIL];	/* backup keeper's email addr */
  char nodedb_devname_read[DEVICE_TERSE_NAME_LEN];	/* guaranteed readable device */
  char nodedb_devname_set[DEVICE_TERSE_NAME_LEN];	/* guaranteed settable device */
  char nodedb_devname_tod[DEVICE_TERSE_NAME_LEN];	/* time-of-day device */
  char nodedb_devname_uptime[DEVICE_TERSE_NAME_LEN];	/* uptime device */
  char nodedb_devname_download[DEVICE_TERSE_NAME_LEN];	/* download device */
  char nodedb_devname_reboot[DEVICE_TERSE_NAME_LEN];	/* reboot device */
  char nodedb_devname_version[DEVICE_TERSE_NAME_LEN];	/* version device */
  unsigned int nodedb_di_read;		/* guaranteed readable device */
  unsigned int nodedb_di_set;		/* guaranteed settable device */
  unsigned int nodedb_di_tod;		/* time-of-day device */
  unsigned int nodedb_di_uptime;	/* uptime device */
  unsigned int nodedb_di_download;	/* download device */
  unsigned int nodedb_di_reboot;	/* reboot device */
  unsigned int nodedb_di_version;	/* version device */
  unsigned int nodedb_system_id;	/* system ID */
  unsigned int nodedb_hardware_id;	/* hardware ID */
  unsigned int nodedb_software_id;	/* software ID */
  unsigned int nodedb_status_id;	/* status ID */
  unsigned int nodedb_area_id;		/* area ID */
  unsigned int nodedb_opsys_id;		/* operating system ID */
  unsigned char nodedb_is_front_end;	/* front-end boolean flag */
  unsigned char nodedb_is_open_access;	/* open-access front-end boolean flag */
  unsigned char nodedb_is_console;	/* console boolean flag */
  unsigned char nodedb_is_central;	/* central node boolean flag */
  unsigned char nodedb_is_subordinate;	/* OBSOLETE */
  unsigned char nodedb_is_alternate;	/* alternate boolean flag */
  unsigned char nodedb_is_alarmer;	/* alarms speaker boolean flag */
  unsigned char nodedb_is_ftp_fe;	/* supportx ftp protocol flag */
  unsigned char nodedb_is_tclk_fe;	/* supports tclk flag */
  unsigned char nodedb_is_gets32_sets32;/* gets32-sets32 boolean flag */
  unsigned char nodedb_subsystems;	/* subsystems implemented mask */
  unsigned char nodedb_url[255];	/* URL for documentation */
  unsigned short nodedb_spare;		/* spare for longword alignment */
  } __attribute__((packed)) /* Added by the PACKINATOR(tm) */ nodedb_t;

#define NODE_INFO_GET_SQL "select node_name,description,location,keeper_name,\
keeper_email,bkeeper_name,bkeeper_email,devname_read,devname_set,\
devname_tod,devname_uptime,devname_download,devname_reboot,\
devname_version,di_read,di_set,di_tod,di_uptime,di_download,\
di_reboot,di_version,system_id,hardware_id,software_id,status_id,\
area_id,opsys_id,is_front_end,is_open_access,is_console,is_central,\
0x00,is_alternate,is_alarmer,is_ftp_fe,is_tclk_fe,is_gets32_sets32,\
subsystems,url,0x0000 from appdb.johnson.acnet_view_node_info"

#define NODE_INFO_NUM_SQL "select count(*) from appdb.johnson.acnet_view_node_info"

typedef struct NODEDB_EXT
    {
    char	nodedb_name[NODE_NAME_LEN];
    short	nodedb_trunk;
    short	nodedb_node_number;
    char	nodedb_description[LEN_NODE_DESCRIPTION];
    char	nodedb_location[LEN_NODE_LOCATION];
    char	nodedb_keeper_name[LEN_NODE_KEEPER_NAME];
    char	nodedb_keeper_email[LEN_NODE_KEEPER_EMAIL];
    char	nodedb_bkeeper_name[LEN_NODE_KEEPER_NAME];
    char	nodedb_bkeeper_email[LEN_NODE_KEEPER_EMAIL];
    char	nodedb_devname_read[DEVICE_TERSE_NAME_LEN];
    char	nodedb_devname_set[DEVICE_TERSE_NAME_LEN];
    char	nodedb_devname_tod[DEVICE_TERSE_NAME_LEN];
    char	nodedb_devname_uptime[DEVICE_TERSE_NAME_LEN];
    char	nodedb_devname_download[DEVICE_TERSE_NAME_LEN];
    char	nodedb_devname_reboot[DEVICE_TERSE_NAME_LEN];
    char	nodedb_devname_version[DEVICE_TERSE_NAME_LEN];
    unsigned int nodedb_di_read;
    unsigned int nodedb_di_set;
    unsigned int nodedb_di_tod;
    unsigned int nodedb_di_uptime;
    unsigned int nodedb_di_download;
    unsigned int nodedb_di_reboot;
    unsigned int nodedb_di_version;
    char	nodedb_system_desc[LEN_NODE_ATTR_DESCRIPTOR];
    char	nodedb_hardware_desc[LEN_NODE_ATTR_DESCRIPTOR];
    char	nodedb_software_desc[LEN_NODE_ATTR_DESCRIPTOR];
    char	nodedb_status_desc[LEN_NODE_ATTR_DESCRIPTOR];
    char	nodedb_area_desc[LEN_NODE_ATTR_DESCRIPTOR];
    char	nodedb_opsys_desc[LEN_NODE_ATTR_DESCRIPTOR];
    char	nodedb_is_front_end;
    char	nodedb_is_open_access;
    char	nodedb_is_console;
    char	nodedb_is_central;
    char	nodedb_is_subordinate;
    char	nodedb_is_alternate;
    char	nodedb_is_alarmer;
    char	nodedb_is_ftp_fe;
    char	nodedb_is_tclk_fe;
    char	nodedb_is_gets32_sets32;
    char	nodedb_subsystems;
    char	nodedb_url[255];
    char	nodedb_ip_name[IP_NAME_LEN];
    short	nodedb_node_type;
    unsigned short	nodedb_node_characteristics;
    unsigned short	nodedb_node_spare;  /* for alignment */
    } __attribute__((packed)) nodedb_ext_t;

#ifdef __cplusplus
extern "C" {
#endif

int acnet_node_info_c(int node, nodedb_t *node_info);
int acnet_node_ext_info_c(int node, nodedb_ext_t *node_info);
int acnet_node_ext_info_list_c(int num_nodes, int *nodes,
			       nodedb_ext_t *node_info, short *errors);
int delete_acnet_node_info_cache_c(int node=0, int free_memory=FALSE);
int node_guaranteed_readable_device_c(int node, int *device_index);
int node_info_db(int *num_nodes, nodedb_t **info_list);
int node_reboot_device_c(int node, int *device_index);

#ifdef __cplusplus
}
#endif

#endif		/* include only once */