generic_structures_h
/*
** Copyright 1998, Universities Research Association. All rights reserved.
*/
/******************************************************************************/
/* generic_structures.h
**
** This is a header file containing definitions in support
** of generic structures.
**
** V0.0 B S Hendricks / Accelerator Controls 05-May-98
** Created
**
*/
/******************************************************************************/
#ifndef GENERIC_STRUCTURES_DEFINED /* do this only once */
#define GENERIC_STRUCTURES_DEFINED
#include "cns_data_structs.h"
/******************************************************************************/
/*
** defined constants
*/
/******************************************************************************/
#define STRUCT_NAME_LEN 64 /* maximum length of a structure name */
#define STRUCT_DESCRIPTION_LEN 80 /* maximum description length */
#define STRUCT_LONG_DESCRIPTION_LEN 252 /* maximum int description length */
#define STRUCT_STRING_MAX_LEN 252 /* maximum string length */
#define STRUCT_ARRAY_MAX_LEN 252 /* maximum binary array length */
/******************************************************************************/
/*
** structure definitions
*/
/******************************************************************************/
typedef struct STRUCT_CLASS_DATA
{
char class_name[STRUCT_CLASS_NAME_LEN];
char description[STRUCT_DESCRIPTION_LEN];
int description_length;
char modify_user_name[USER_NAME_LEN];
char user_name[USER_NAME_LEN];
int protection;
int class_id;
} __attribute__((packed)) STRUCT_CLASS_DATA;
typedef struct STRUCT_DIR_DATA
{
char structure_name[STRUCT_NAME_LEN];
int class_id;
char description[STRUCT_DESCRIPTION_LEN];
int description_length;
char modify_user_name[USER_NAME_LEN];
char user_name[USER_NAME_LEN];
int protection;
int structure_id;
} __attribute__((packed)) STRUCT_DIR_DATA;
typedef struct STRUCT_DB_FIELD_DATA
{
int field_number;
int data_type; /* data type */
int atomic_length;
int num_elements;
int edit_this_field;
int is_bit_mask;
char description[STRUCT_DESCRIPTION_LEN];
int description_length;
int specific_data_type;
int value_1;
int value_2;
int value_3;
int value_4;
int default_value_id;
int minimum_value_id;
int maximum_value_id;
int data_id;
} __attribute__((packed)) STRUCT_DB_FIELD_DATA;
typedef struct STRUCT_BYTE_VALUE_DATA
{
int byte_id;
int array_index;
char value;
} __attribute__((packed)) STRUCT_BYTE_VALUE_DATA;
typedef struct STRUCT_UBYTE_VALUE_DATA
{
int byte_id;
int array_index;
unsigned char value;
} __attribute__((packed)) STRUCT_UBYTE_VALUE_DATA;
typedef struct STRUCT_SHORT_VALUE_DATA
{
int short_id;
int array_index;
short value;
} __attribute__((packed)) STRUCT_SHORT_VALUE_DATA;
typedef struct STRUCT_USHORT_VALUE_DATA
{
int short_id;
int array_index;
unsigned short value;
} __attribute__((packed)) STRUCT_USHORT_VALUE_DATA;
typedef struct STRUCT_LONG_VALUE_DATA
{
int long_id;
int array_index;
int value;
} __attribute__((packed)) STRUCT_LONG_VALUE_DATA;
typedef struct STRUCT_ULONG_VALUE_DATA
{
int long_id;
int array_index;
unsigned int value;
} __attribute__((packed)) STRUCT_ULONG_VALUE_DATA;
typedef struct STRUCT_FLOAT_VALUE_DATA
{
int float_id;
int array_index;
float value;
} __attribute__((packed)) STRUCT_FLOAT_VALUE_DATA;
typedef struct STRUCT_DOUBLE_VALUE_DATA
{
int double_id;
int array_index;
double value;
} __attribute__((packed)) STRUCT_DOUBLE_VALUE_DATA;
typedef struct STRUCT_STRING_VALUE_DATA
{
int string_id;
int array_index;
char string[STRUCT_STRING_MAX_LEN];
int string_length;
char description[STRUCT_DESCRIPTION_LEN];
int description_length;
} __attribute__((packed)) STRUCT_STRING_VALUE_DATA;
typedef struct STRUCT_DB_XCHAR_STRING_VALUE_DATA
{
int string_id;
int array_index;
char string[STRUCT_STRING_MAX_LEN];
char colors[STRUCT_STRING_MAX_LEN];
int string_length;
char description[STRUCT_DESCRIPTION_LEN];
int description_length;
} __attribute__((packed)) STRUCT_DB_XCHAR_STRING_VALUE_DATA;
typedef struct STRUCT_XCHAR_STRING_VALUE_DATA
{
int string_id;
int array_index;
XCHAR string[STRUCT_STRING_MAX_LEN];
int string_length;
char description[STRUCT_DESCRIPTION_LEN];
int description_length;
} __attribute__((packed)) STRUCT_XCHAR_STRING_VALUE_DATA;
typedef struct STRUCT_BINARY_ARRAY_VALUE_DATA
{
int array_id;
int array_index;
char array[STRUCT_ARRAY_MAX_LEN];
int array_length;
char description[STRUCT_DESCRIPTION_LEN];
int description_length;
} __attribute__((packed)) STRUCT_BINARY_ARRAY_VALUE_DATA;
typedef struct STRUCT_DB_ENUM_DATA
{
int order_number;
int value;
int atomic_length;
char description[STRUCT_DESCRIPTION_LEN];
int description_length;
} __attribute__((packed)) STRUCT_DB_ENUM_DATA;
typedef struct STRUCT_DB_BIT_MASK_DATA
{
int order_number;
unsigned int bit_number;
int default_value;
char description[STRUCT_DESCRIPTION_LEN];
int description_length;
char description_if_0[STRUCT_DESCRIPTION_LEN];
int description_length_if_0;
char description_if_1[STRUCT_DESCRIPTION_LEN];
int description_length_if_1;
} __attribute__((packed)) STRUCT_DB_BIT_MASK_DATA;
typedef struct STRUCT_ARRAY_DEVICE_VALUE_DATA
{
int array_device_id;
int array_index;
ARRAY_DEVICE_DATA value;
} __attribute__((packed)) STRUCT_ARRAY_DEVICE_VALUE_DATA;
typedef struct STRUCT_ARRAY_DEVICE_EXT_VALUE_DATA
{
int array_device_id;
int array_index;
ARRAY_DEVICE_DATA_EXT value;
} __attribute__((packed)) STRUCT_ARRAY_DEVICE_EXT_VALUE_DATA;
typedef struct STRUCT_STATE_VALUE_DATA
{
int state_value_id;
int array_index;
STATE_VALUE value;
} __attribute__((packed)) STRUCT_STATE_VALUE_DATA;
typedef struct STRUCT_DATA_EVENT_VALUE_DATA
{
int data_event_id;
int array_index;
DATA_EVENT_DATA value;
} __attribute__((packed)) STRUCT_DATA_EVENT_VALUE_DATA;
typedef struct STRUCT_SIMPLE_DATA_EVENT_VALUE_DATA
{
int data_event_id;
int array_index;
SIMPLE_DATA_EVENT_DATA value;
} __attribute__((packed)) STRUCT_SIMPLE_DATA_EVENT_VALUE_DATA;
typedef struct STRUCT_SDA_CASE_DATA
{
int sda_case_id;
int array_index;
SDA_CASE_VALUE value;
} __attribute__((packed)) STRUCT_SDA_CASE_DATA;
typedef struct STRUCT_SDA_FILE_DATA
{
int sda_file_id;
int array_index;
SDA_FILE_VALUE value;
} __attribute__((packed)) STRUCT_SDA_FILE_DATA;
typedef struct STRUCT_DATA_SOURCE_VALUE_DATA
{
int data_source_id;
int array_index;
DATA_SOURCE_DATA value;
} __attribute__((packed)) STRUCT_DATA_SOURCE_VALUE_DATA;
/******************************************************************************/
/*
** SQL strings
*/
/******************************************************************************/
/* class information */
#define SQL_READ_CLASS_DATA "select class_name, \
description, description_length, modify_user_name, user_name, protection, \
class_id from appdb.hendricks.generic_structures_classes where \
class_id = %d"
/* structure header */
#define SQL_READ_STRUCTURE "select structure_name, class_id, \
description, description_length, modify_user_name, user_name, protection, \
structure_id from appdb.hendricks.generic_structures_dir where \
structure_name = '%s'"
#define SQL_WRITE_STRUCTURE "%Lexec \
appdb.hendricks.update_generic_structures_dir '%s', '%s', '%.*s', %d, '', 0, \
'%.*s', %d"
/* structure field */
#define SQL_WRITE_FIELD "%Lexec appdb.hendricks.update_generic_structures \
%d, %d, %d, %d, %d, %d, %d, '%.*s', %d, '', 0, %d, %d, %d, 1, \
%d, %d, %d, %d, %d, %d"
/* array device */
#define SQL_ARRAY_DEVICE_VALUE_COUNT "select count(*) from \
appdb.hendricks.generic_struct_array_devices where array_device_id = %d"
#define SQL_READ_ARRAY_DEVICE_VALUE "select array_device_id, array_index, \
device_index, property, index_number from \
appdb.hendricks.generic_struct_array_devices where array_device_id = %d \
order by array_index"
#define SQL_WRITE_ARRAY_DEVICE_VALUE "%Lexec \
appdb.hendricks.update_gen_structs_array_devs %d, %d, %d, %d, %d"
/* binary array */
#define SQL_READ_BINARY_ARRAY_VALUE "select array_id, array_index, \
array, array_length, description, description_length from \
appdb.hendricks.generic_structure_binary_array where array_id = %d"
#define SQL_WRITE_BINARY_ARRAY_VALUE "%Lexec \
appdb.hendricks.update_generic_structs_binarys %d, %d, %*F, %d, '%.*s', %d"
/* bit mask */
#define SQL_GET_BIT_MASK_ID "exec \
appdb.hendricks.get_generic_structs_bitmsk_id"
#define SQL_WRITE_BIT_MASK_ENTRY "%Linsert into \
appdb.hendricks.generic_structure_bit_masks values (%d, %d, %d, 0, 1, '%.*s', \
%d, '', 0, '', 0, '', 0, getdate()) \n"
#define SIZEOF_LONG 10
#define BIT_MASK_ALLOC_SIZE (sizeof(SQL_WRITE_BIT_MASK_ENTRY) + \
SIZEOF_LONG + SIZEOF_LONG + SIZEOF_LONG + \
STRUCT_DESCRIPTION_LEN + SIZEOF_LONG + 4)
/* byte (char) value */
#define SQL_BYTE_VALUE_COUNT "select count(*) from \
appdb.hendricks.generic_structure_bytes where byte_id = %d"
#define SQL_READ_BYTE_VALUE "select byte_id, array_index, value from \
appdb.hendricks.generic_structure_bytes where byte_id = %d \
order by array_index"
#define SQL_WRITE_BYTE_VALUE "%Lexec \
appdb.hendricks.update_generic_structs_bytes %d, %d, %u"
/* unsigned byte (char) */
#define SQL_UBYTE_VALUE_COUNT "select count(*) from \
appdb.hendricks.generic_structure_bytes where byte_id = %d"
#define SQL_READ_UBYTE_VALUE "select byte_id, array_index, value from \
appdb.hendricks.generic_structure_bytes where byte_id = %d \
order by array_index"
#define SQL_WRITE_UBYTE_VALUE "%Lexec \
appdb.hendricks.update_generic_structs_bytes %d, %d, %u"
/* data event */
#define SQL_DATA_EVENT_VALUE_COUNT "select count(*) from \
appdb.hendricks.generic_struct_data_events where data_event_id = %d"
#define SQL_READ_DATA_EVENT_VALUE "select data_event_id, array_index, \
event_type, num_terms, interval_or_type_or_di, imm_or_event_or_state, \
detect_or_condition, delay, operator from \
appdb.hendricks.generic_struct_data_events where data_event_id = %d \
order by array_index"
#define SQL_WRITE_DATA_EVENT_VALUE "%Lexec \
appdb.hendricks.update_gen_structs_data_events %d, %d, %d, %d, %d, %d, %d, \
%d, %d"
/* data source */
#define SQL_DATA_SOURCE_VALUE_COUNT "select count(*) from \
appdb.hendricks.generic_struct_data_sources where data_source_id = %d"
#define SQL_READ_DATA_SOURCE_VALUE "select data_source_id, array_index, \
source_type, file_number_or_node, case_number_or_start_time, \
subcase_number_or_accuracy, usage_number, try_number from \
appdb.hendricks.generic_struct_data_sources where data_source_id = %d \
order by array_index"
#define SQL_WRITE_DATA_SOURCE_VALUE "%Lexec \
appdb.hendricks.update_gen_structs_data_source %d, %d, %d, %d, %d, %d, %d, \
%d"
/* double value */
#define SQL_DOUBLE_VALUE_COUNT "select count(*) from \
appdb.hendricks.generic_structure_doubles where double_id = %d"
#define SQL_READ_DOUBLE_VALUE "select double_id, array_index, value from \
appdb.hendricks.generic_structure_doubles where double_id = %d \
order by array_index"
#define SQL_WRITE_DOUBLE_VALUE "%Lexec \
appdb.hendricks.update_generic_structs_doubles %d, %d, %f"
/* enumerated values */
#define SQL_GET_ENUM_ID "exec appdb.hendricks.get_generic_structs_enum_id"
#define SQL_WRITE_ENUM_ENTRY "%Linsert into \
appdb.hendricks.generic_structure_enums values (%d, %d, %d, 4, '%.*s', \
%d, '', 0, getdate()) \n"
#define SIZEOF_LONG 10
#define ENUM_ALLOC_SIZE (sizeof(SQL_WRITE_ENUM_ENTRY) + SIZEOF_LONG + \
SIZEOF_LONG + SIZEOF_LONG + STRUCT_DESCRIPTION_LEN + \
SIZEOF_LONG + 4)
/* float value */
#define SQL_FLOAT_VALUE_COUNT "select count(*) from \
appdb.hendricks.generic_structure_floats where float_id = %d"
#define SQL_READ_FLOAT_VALUE "select float_id, array_index, value from \
appdb.hendricks.generic_structure_floats where float_id = %d \
order by array_index"
#define SQL_WRITE_FLOAT_VALUE "%Lexec \
appdb.hendricks.update_generic_structs_floats %d, %d, %f"
/* int value */
#define SQL_LONG_VALUE_COUNT "select count(*) from \
appdb.hendricks.generic_structure_longs where long_id = %d"
#define SQL_READ_LONG_VALUE "select long_id, array_index, value from \
appdb.hendricks.generic_structure_longs where long_id = %d \
order by array_index"
#define SQL_WRITE_LONG_VALUE "%Lexec \
appdb.hendricks.update_generic_structs_longs %d, %d, %d"
/* unsigned int value */
#define SQL_ULONG_VALUE_COUNT "select count(*) from \
appdb.hendricks.generic_structure_longs where long_id = %d"
#define SQL_READ_ULONG_VALUE "select long_id, array_index, value from \
appdb.hendricks.generic_structure_longs where long_id = %d \
order by array_index"
#define SQL_WRITE_ULONG_VALUE "%Lexec \
appdb.hendricks.update_generic_structs_longs %d, %d, %d"
/* SDA case value */
#define SQL_SDA_CASE_VALUE_COUNT "select count(*) from \
appdb.hendricks.generic_struct_sda_case_values where sda_case_id = %d"
#define SQL_READ_SDA_CASE_VALUE "select sda_case_id, array_index, \
usage_number, case_number, subcase_number, try_number from \
appdb.hendricks.generic_struct_sda_case_values where sda_case_id = %d \
order by array_index"
#define SQL_WRITE_SDA_CASE_VALUE "%Lexec \
appdb.hendricks.update_gen_structs_sda_cases %d, %d, %d, %d, %d, %d"
/* SDA file value */
#define SQL_SDA_FILE_VALUE_COUNT "select count(*) from \
appdb.hendricks.generic_struct_sda_file_values where sda_file_id = %d"
#define SQL_READ_SDA_FILE_VALUE "select sda_file_id, array_index, \
usage_number, file_number, case_number, subcase_number, try_number from \
appdb.hendricks.generic_struct_sda_file_values where sda_file_id = %d \
order by array_index"
#define SQL_WRITE_SDA_FILE_VALUE "%Lexec \
appdb.hendricks.update_gen_structs_sda_files %d, %d, %d, %d, %d, %d, %d"
/* short value */
#define SQL_SHORT_VALUE_COUNT "select count(*) from \
appdb.hendricks.generic_structure_shorts where short_id = %d"
#define SQL_READ_SHORT_VALUE "select short_id, array_index, value from \
appdb.hendricks.generic_structure_shorts where short_id = %d \
order by array_index"
#define SQL_WRITE_SHORT_VALUE "%Lexec \
appdb.hendricks.update_generic_structs_shorts %d, %d, %d"
/* unsigned short value */
#define SQL_USHORT_VALUE_COUNT "select count(*) from \
appdb.hendricks.generic_structure_shorts where short_id = %d"
#define SQL_READ_USHORT_VALUE "select short_id, array_index, value from \
appdb.hendricks.generic_structure_shorts where short_id = %d \
order by array_index"
#define SQL_WRITE_USHORT_VALUE "%Lexec \
appdb.hendricks.update_generic_structs_shorts %d, %d, %d"
/* state value */
#define SQL_STATE_VALUE_COUNT "select count(*) from \
appdb.hendricks.generic_struct_state_values where state_value_id = %d"
#define SQL_READ_STATE_VALUE "select state_value_id, array_index, \
vm_device_index, state_number from \
appdb.hendricks.generic_struct_state_values where state_value_id = %d \
order by array_index"
#define SQL_WRITE_STATE_VALUE "%Lexec \
appdb.hendricks.update_gen_structs_state_vals %d, %d, %d, %d"
/* string value */
#define SQL_READ_STRING_VALUE "select string_id, array_index, string, \
string_length, description, description_length from \
appdb.hendricks.generic_structure_strings where string_id = %d"
#define SQL_WRITE_STRING_VALUE "%Lexec \
appdb.hendricks.update_generic_structs_strings %d, %d, '%.*s', %d, '%.*s', %d"
/* fixed string value */
#define SQL_READ_FIXED_STRING_VALUE "select string_id, array_index, \
string, string_length, description, description_length from \
appdb.hendricks.generic_structs_fixed_strings where string_id = %d"
#define SQL_WRITE_FIXED_STRING_VALUE "%Lexec \
appdb.hendricks.update_gen_struct_fixed_string %d, %d, '%.*s', %d, '%.*s', %d"
/* XCHAR string */
#define SQL_READ_XCHAR_STRING_VALUE "select string_id, array_index, \
string, colors, string_length, description, description_length from \
appdb.hendricks.generic_structure_xchar_string where string_id = %d"
#define SQL_WRITE_XCHAR_STRING_VALUE "%Lexec \
appdb.hendricks.update_generic_structs_xchars %d, %d, '%.*s', %*F, %d, \
'%.*s', %d"
#endif