new in EPICS base
This commit is contained in:
Executable
+11
@@ -0,0 +1,11 @@
|
||||
# $Id$
|
||||
# $Log$
|
||||
#
|
||||
# *Revision 1.2 1996/06/24 03:15:25 jbk
|
||||
# *name changes and fixes for aitString and fixed string functions
|
||||
# *Revision 1.1 1996/05/31 13:15:12 jbk
|
||||
# *add new stuff
|
||||
#
|
||||
|
||||
tar zcvf /tmp/gdd.tar.gz *.c *.cc *.h *.MRI Makefile* MAKE* README
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#
|
||||
# Author: Jim Kowalkowski
|
||||
# Date: 2/96
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
# $Log$
|
||||
#
|
||||
# *Revision 1.2 1996/06/25 18:58:55 jbk
|
||||
# *more fixes for the aitString management functions and mapping menus
|
||||
# *Revision 1.1 1996/05/31 13:15:13 jbk
|
||||
# *add new stuff
|
||||
#
|
||||
#
|
||||
|
||||
EPICS=../../..
|
||||
# EPICS=/usr/local/epics/R3.12.2
|
||||
|
||||
include $(EPICS)/config/CONFIG_EXTENSIONS
|
||||
|
||||
include $(EPICS)/config/RULES_ARCHS
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
#
|
||||
# Author: Jim Kowalkowski
|
||||
# Date: 2/96
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
# $Log$
|
||||
#
|
||||
# *Revision 1.4 1996/06/25 18:58:56 jbk
|
||||
# *more fixes for the aitString management functions and mapping menus
|
||||
# *Revision 1.3 1996/06/24 03:15:26 jbk
|
||||
# *name changes and fixes for aitString and fixed string functions
|
||||
# *Revision 1.2 1996/06/11 01:55:18 jbk
|
||||
# *completed ful build
|
||||
# *Revision 1.1 1996/05/31 13:15:14 jbk
|
||||
# *add new stuff
|
||||
|
||||
VPATH=.:..
|
||||
|
||||
EPICS = ../../../..
|
||||
# EPICS = /usr/local/epics/R3.12.2
|
||||
|
||||
include Target.include
|
||||
include $(EPICS)/config/CONFIG_EXTENSIONS
|
||||
|
||||
OPTIM_YES=-g
|
||||
ifeq ($(HOST_ARCH),sun4)
|
||||
CCC=purify CC
|
||||
CC=purify acc
|
||||
endif
|
||||
|
||||
DEPENDS_RULE.cc = -$(COMPILE.cc) -xM $(SRCS.cc) >> .DEPENDS
|
||||
|
||||
USR_LDFLAGS = -L$(EPICS_EXTENSIONS_LIB) -L.
|
||||
USR_CFLAGS = -L$(EPICS_EXTENSIONS_LIB) -L.
|
||||
|
||||
SRCS.cc = ../aitGen.c ../aitTypes.c ../aitHelpers.cc \
|
||||
../gdd.cc ../gddAppDefs.cc ../gddAppTable.cc ../gddNewDel.cc \
|
||||
../gddTest.cc ../genApps.cc
|
||||
# ../dbMapper.cc
|
||||
|
||||
LIBOBJS = gdd.o gddTest.o gddAppTable.o gddNewDel.o gddAppDefs.o \
|
||||
aitTypes.o aitConvert.o aitHelpers.o
|
||||
# dbMapper.o
|
||||
|
||||
LIBNAME = libgdd.a
|
||||
|
||||
TARGETS = dbMapper.o
|
||||
|
||||
# cannot generate dependencies for aitConvert automatically
|
||||
|
||||
aitConvert.o: aitConvert.cc aitConvert.h aitConvertGenerated.cc aitTypes.h
|
||||
|
||||
aitConvertGenerated.cc: aitGen aitTypes.h
|
||||
aitGen
|
||||
|
||||
aitGen: aitGen.o aitTypes.o
|
||||
$(LINK.c) -o $@ $^ $(LDLIBS)
|
||||
|
||||
# cannot generate dependencies for dbMapper.o automatically
|
||||
|
||||
dbMapper.o: ../dbMapper.cc gdd.h gddAppTable.h dbMapper.h gddApps.h aitTypes.h
|
||||
$(COMPILE.cc) $<
|
||||
$(AR) r $(LIBNAME) $@
|
||||
|
||||
gddApps.h: genApps
|
||||
genApps $@
|
||||
|
||||
genApps: genApps.o $(LIBOBJS)
|
||||
$(LINK.cc) -o $@ $^ $(LDLIBS)
|
||||
|
||||
clean::
|
||||
/bin/rm -f aitConvertGenerated.cc aitGen genApps
|
||||
|
||||
include $(EPICS)/config/RULES.Unix
|
||||
|
||||
@@ -0,0 +1,251 @@
|
||||
#
|
||||
# Author: Jim Kowalkowski
|
||||
# Date: 2/96
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
# $Log$
|
||||
#
|
||||
|
||||
# Simple build system for all the platforms I've tested on
|
||||
|
||||
VPATH=.:..
|
||||
|
||||
# ifdef IN_OBJ_DIR
|
||||
# ifeq ($(VX_BUILD),vw)
|
||||
# CCTYPE = $(VX_BUILD)
|
||||
# else
|
||||
# CCTYPE = $(HOST_ARCH)
|
||||
# endif
|
||||
#
|
||||
# else
|
||||
ifdef HOST_ARCH
|
||||
CCTYPE = $(HOST_ARCH)
|
||||
else
|
||||
# CCTYPE = solaris
|
||||
# CCTYPE = sun4
|
||||
# CCTYPE = linux
|
||||
# CCTYPE = hp700
|
||||
# CCTYPE = vw
|
||||
# VX_BUILD = vw
|
||||
endif
|
||||
# endif
|
||||
|
||||
ifeq ($(CCTYPE),vw)
|
||||
|
||||
GNU_DIR = /home/phoebus/HIDEOS/gnu_install
|
||||
# GNU_DIR = /home/hideos/gnu_install
|
||||
GNU_BIN = $(GNU_DIR)/bin
|
||||
VERBOSE = -Wall -Winline
|
||||
OPTIM = -O # -DNO_DUMP_TEST -g
|
||||
VX_DIR = /usr/local/vw/vxV52/vw
|
||||
VX_INCLUDE = $(VX_DIR)/h
|
||||
|
||||
ifeq ($(CCTYPE),sun4)
|
||||
CC_NORMAL = acc
|
||||
else
|
||||
CC_NORMAL = cc
|
||||
endif
|
||||
|
||||
CC = $(GNU_BIN)/sun3-gcc
|
||||
CCC = $(GNU_BIN)/sun3-g++
|
||||
LD = $(GNU_BIN)/sun3-ld
|
||||
AR = $(GNU_BIN)/sun3-ar
|
||||
RANLIB = $(GNU_BIN)/sun3-ranlib
|
||||
|
||||
LIB_FLAGS =
|
||||
LDFLAGS = -L. -r -N -T../vxldscript.MRI
|
||||
CCFLAGS = -B$(GNU_DIR)/lib/gcc-lib/ $(OPTIM) -W \
|
||||
$(VERBOSE) -nostdinc --no-builtin -m68040 -Wa,"-m68040" \
|
||||
-DCPU_FAMILY=MC680X0 -DCPU=MC68040 -DvxWorks -DV5_vxWorks \
|
||||
-I. -I.. -I$(VX_INCLUDE)
|
||||
|
||||
else
|
||||
|
||||
ifeq ($(CCTYPE),solaris)
|
||||
VERBOSE = +w -D__EXTENSIONS__
|
||||
CC = cc
|
||||
CCC = CC
|
||||
CC_NORMAL = $(CC)
|
||||
LIB_FLAGS = # -lposix4
|
||||
POSIX_LEVEL = 2 # 4
|
||||
EPICS = /home/phoebus/JBK/test3.12/include
|
||||
RANLIB = echo
|
||||
endif
|
||||
|
||||
ifeq ($(CCTYPE),sun4)
|
||||
VERBOSE =
|
||||
CC=purify acc
|
||||
CCC=purify CC
|
||||
# CCC = CC
|
||||
# CC = acc
|
||||
CC_NORMAL = acc
|
||||
LIB_FLAGS =
|
||||
POSIX_LEVEL = 2
|
||||
EPICS = /home/phoebus/JBK/test3.12/include
|
||||
RANLIB = ranlib
|
||||
endif
|
||||
|
||||
ifeq ($(CCTYPE),linux)
|
||||
VERBOSE = -Wall -Winline
|
||||
CC = gcc
|
||||
CCC = g++
|
||||
CC_NORMAL = $(CC)
|
||||
LIB_FLAGS =
|
||||
POSIX_LEVEL = 2
|
||||
EPICS = /home/jbk/include
|
||||
RANLIB = ranlib
|
||||
endif
|
||||
|
||||
ifeq ($(CCTYPE),hp700)
|
||||
VERBOSE =
|
||||
CC = c89 -Aa
|
||||
CCC = CC +a1
|
||||
CC_NORMAL = $(CC)
|
||||
LIB_FLAGS =
|
||||
POSIX_LEVEL = 2
|
||||
RANLIB = ranlib
|
||||
endif
|
||||
|
||||
LD = ld
|
||||
AR = ar
|
||||
|
||||
# -p is for profiling
|
||||
OPTIM = -g # -O -p
|
||||
COMP_FLAGS = -D_POSIX_C_SOURCE=$(POSIX_LEVEL) -D$(CCTYPE)
|
||||
BOTH_FLAGS = -I. -I.. $(VERBOSE) $(OPTIM) -I$(EPICS) $(COMP_FLAGS)
|
||||
LDFLAGS = $(BOTH_FLAGS) -L.
|
||||
CCFLAGS = $(BOTH_FLAGS)
|
||||
|
||||
endif
|
||||
|
||||
CXXFLAGS = $(CCFLAGS)
|
||||
CFLAGS = $(CXXFLAGS)
|
||||
CXX = $(CCC)
|
||||
|
||||
DEPLIB = libgdd_t.a
|
||||
DEST_DEPLIB = libgdd.a
|
||||
LIBFLAGS = -lgdd $(LIB_FLAGS)
|
||||
LIBFLAGS_T = -lgdd_t $(LIB_FLAGS)
|
||||
|
||||
# modules that go into the library
|
||||
SRCS = gdd.cc gddTest.cc aitConvert.cc gddAppTable.cc gddNewDel.cc \
|
||||
gddAppDefs.cc aitTypes.c
|
||||
OBJS = gdd.o gddTest.o aitConvert.o gddAppTable.o gddNewDel.o \
|
||||
gddAppDefs.o aitTypes.o
|
||||
INCS = gdd.h aitConvert.h aitTypes.h gddNewDel.h gddUtils.h
|
||||
|
||||
# -----------------------------
|
||||
ifndef HOST_ARCH
|
||||
problem:
|
||||
@echo "you must set the HOST_ARCH environment variable"
|
||||
@echo "set VX_BUILD=vw to build for vxWorks"
|
||||
endif
|
||||
|
||||
# -----------------------------
|
||||
ifndef IN_OBJ_DIR
|
||||
ifdef VX_BUILD
|
||||
first_rule: $(HOST_ARCH)/Makefile $(VX_BUILD)/Makefile
|
||||
else
|
||||
first_rule: $(HOST_ARCH)/Makefile
|
||||
endif
|
||||
(cd $(HOST_ARCH); gnumake all)
|
||||
ifdef VX_BUILD
|
||||
(HOST_ARCH=$(VX_BUILD); cd $(VX_BUILD); gnumake HOST_ARCH=$(VX_BUILD))
|
||||
# (HOST_ARCH=$(VX_BUILD); gnumake HOST_ARCH=$(VX_BUILD))
|
||||
endif
|
||||
|
||||
$(HOST_ARCH)/Makefile: Makefile
|
||||
if [ ! -d "$(HOST_ARCH)" ]; \
|
||||
then \
|
||||
mkdir $(HOST_ARCH); \
|
||||
fi
|
||||
echo "IN_OBJ_DIR=1" > $@
|
||||
cat $< >> $@
|
||||
|
||||
ifdef VX_BUILD
|
||||
$(VX_BUILD)/Makefile: Makefile
|
||||
if [ ! -d "$(VX_BUILD)" ]; \
|
||||
then \
|
||||
mkdir $(VX_BUILD); \
|
||||
fi
|
||||
echo "IN_OBJ_DIR=1" > $@
|
||||
cat $< >> $@
|
||||
endif
|
||||
endif
|
||||
|
||||
# -----------------------------
|
||||
all: aitGen gddApps.h $(DEPLIB) dbMapper.o $(DEST_DEPLIB)
|
||||
|
||||
check_arch:
|
||||
@echo "architecture=$(CCTYPE)"
|
||||
|
||||
$(DEST_DEPLIB): $(DEPLIB)
|
||||
cp $^ $@
|
||||
|
||||
# -----------------------------
|
||||
$(DEPLIB): $(OBJS)
|
||||
/bin/rm -f $@
|
||||
$(AR) r $@ $^
|
||||
cp $@ $(DEST_DEPLIB)
|
||||
ifeq ($(CCTYPE),sun4)
|
||||
$(RANLIB) $@
|
||||
$(RANLIB) $(DEST_DEPLIB)
|
||||
endif
|
||||
ifeq ($(CCTYPE),vw)
|
||||
$(RANLIB) $@
|
||||
$(RANLIB) $(DEST_DEPLIB)
|
||||
endif
|
||||
|
||||
# -----------------------------
|
||||
ifneq ($(CCTYPE),vw)
|
||||
genApps: genApps.o $(OBJS) $(DEPLIB)
|
||||
$(CCC) $(LDFLAGS) -o $@ $< $(LIBFLAGS_T)
|
||||
|
||||
gddApps.h: genApps
|
||||
$< gddApps.h
|
||||
cp gddApps.h ..
|
||||
|
||||
genApps.o: genApps.cc gddAppTable.h aitTypes.h $(INCS)
|
||||
|
||||
else
|
||||
genApps:
|
||||
@echo "Not going to build $@ for vw"
|
||||
endif
|
||||
|
||||
aitGen: aitGen.o aitTypes.o
|
||||
$(CC_NORMAL) -O -o $@ $^
|
||||
|
||||
aitGen.o: aitGen.c aitTypes.h
|
||||
$(CC_NORMAL) -D$(CCTYPE) -O -c -I. $<
|
||||
|
||||
aitConvertGenerated.cc: aitGen aitTypes.h aitConvert.h aitConvert.cc aitTypes.c
|
||||
aitGen
|
||||
|
||||
# -----------------------------
|
||||
gdd.o: gdd.cc $(INCS)
|
||||
gddTest.o: gddTest.cc $(INCS)
|
||||
gddNewDel.o: gddNewDel.cc gddNewDel.h gddUtils.h
|
||||
gddAppTable.o: gddAppTable.cc gddAppTable.h $(INCS)
|
||||
gddAppDefs.o: gddAppDefs.cc gddAppTable.h $(INCS)
|
||||
aitTypes.o: aitTypes.c aitTypes.h
|
||||
aitConvert.o: aitConvert.cc aitConvertGenerated.cc aitConvert.h aitTypes.h
|
||||
|
||||
dbMapper.o: dbMapper.cc dbMapper.h gddApps.h
|
||||
$(CCC) $(CCFLAGS) -c $<
|
||||
ifeq ($(CCTYPE),solaris)
|
||||
# $(CCC) -xar -o $(DEST_DEPLIB) $(CCFLAGS) $<
|
||||
# $(CCC) -xar -o $(DEST_DEPLIB) $(CCFLAGS) $@
|
||||
endif
|
||||
$(AR) r $(DEST_DEPLIB) $@
|
||||
$(RANLIB) $(DEST_DEPLIB)
|
||||
|
||||
ifdef IN_OBJ_DIR
|
||||
clean:
|
||||
/bin/rm -f *.o *.a aitGen genApps
|
||||
/bin/rm -f *pure* p.out mon.out
|
||||
/bin/rm -rf Templates.DB ptrepository
|
||||
else
|
||||
clean:
|
||||
/bin/rm -rf $(HOST_ARCH) $(VX_BUILD) gddApps.h
|
||||
endif
|
||||
+123
@@ -0,0 +1,123 @@
|
||||
#
|
||||
# Author: Jim Kowalkowski
|
||||
# Date: 2/96
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
# $Log$
|
||||
# Revision 1.4 1996/06/25 18:58:57 jbk
|
||||
# more fixes for the aitString management functions and mapping menus
|
||||
#
|
||||
# Revision 1.3 1996/06/24 03:15:27 jbk
|
||||
# name changes and fixes for aitString and fixed string functions
|
||||
#
|
||||
# Revision 1.2 1996/06/13 21:31:51 jbk
|
||||
# Various fixes and correction - including ref_cnt change to unsigned short
|
||||
#
|
||||
# Revision 1.1 1996/05/31 13:15:16 jbk
|
||||
# add new stuff
|
||||
#
|
||||
#
|
||||
|
||||
Some Notes:
|
||||
|
||||
******
|
||||
The following function described in gddAppTable.h and defined in gddAppDefs.cc:
|
||||
|
||||
gddApplicationTypeTable* gddGenerateApplicationTypeTable(void);
|
||||
|
||||
is designed to be called in an application to create the type table
|
||||
with a default set of attributes already registered. The current mechanism
|
||||
for generating the default registered attributes is the C++ code in
|
||||
gddAppDefs.cc. See this file for a list of registered attributes.
|
||||
|
||||
Creating am application type table using new will perform the same function.
|
||||
|
||||
******
|
||||
The gddCleanUp object will automatically clean up the free list storage
|
||||
when it is destructed. There should only be one of these in an application.
|
||||
It is not required.
|
||||
|
||||
******
|
||||
To build for vxWorks, define an environment variable "VX_BUILD=vw" and type
|
||||
make. It will build for the HOST_ARCH architecture and then vxWorks.
|
||||
|
||||
You must have gcc/g++ 2.5.8 or later available to cross compile to 68k object
|
||||
code and vxWorks. You can get the gcc 2.5.8 package from the HiDEOS home
|
||||
page along with instructions on building it.
|
||||
|
||||
The vxldscript.MRI file instructs the gnu loader on how to propare
|
||||
object files to load under vxWorks.
|
||||
|
||||
You must use the ldpp program under vxWorks shell to load g++ generated
|
||||
object modules. The ldpp program is available in the EPICS base package.
|
||||
Contact me if you want a copy of it.
|
||||
|
||||
It is really not difficult to get g++ object files to load under vxWorks
|
||||
or to get the g++ compiled installed and running. The makefile is set up
|
||||
to handle builds for vxWorks.
|
||||
|
||||
******
|
||||
aitTypes.h: Definitions of the architecture independant types.
|
||||
aitTypes.c: definitions of several lookup tables
|
||||
aitConvert.h: conversion table description,byte ordering routines
|
||||
aitConvert.c: conversion information not generated
|
||||
aitGen.c: creates the general conversion functions
|
||||
aitConvertGenerated.c: file of generated conversion functions
|
||||
|
||||
dbMapper.cc: mappings from DBR types to ait types and GDDs
|
||||
dbMapper.h: mappings from DBR types to ait types and GDDs
|
||||
|
||||
gddApps.h:
|
||||
This file contains "#define" statements for quick indexing into
|
||||
managed containers. Generated by program genApps.cc.
|
||||
|
||||
*******
|
||||
Still needed:
|
||||
|
||||
1) AppTable method to map application type to offset (index) into a
|
||||
managed container.
|
||||
* mostly complete
|
||||
|
||||
2) Function to map DBRxxxx types to Application types and back.
|
||||
* still working on mapping method
|
||||
|
||||
3) Methods for managing network byte order conversions in gdd class.
|
||||
|
||||
4) Method to extract data (and bounds information) from a gdd into a
|
||||
user's buffer.
|
||||
|
||||
6) #defines to remove extra checks and make the programs run faster.
|
||||
|
||||
************ 6/13/96 *************
|
||||
|
||||
ref_cnt should be an unsigned short instead of char
|
||||
|
||||
menus need to be fixed - use aitFixedString or aitString
|
||||
|
||||
get/operator=() should be smarter, do conversion if types do not match
|
||||
|
||||
************ 6/20/96 **************
|
||||
|
||||
fix the flatten functions so they work properly with aitString and fixed
|
||||
string
|
||||
|
||||
fix the aitString class, add the install string method and change others
|
||||
|
||||
*********** 6/21/96 ************
|
||||
|
||||
fixe the aitString::compact function, and all other stuff that works with
|
||||
string info so that if the string that the aitString is holding is NULL,
|
||||
then the system will act correctly. The flatten functions have trouble
|
||||
with this when the described string is NULL.
|
||||
|
||||
*********** 6/24/96 *************
|
||||
|
||||
still need to fix the transfer of aitString data into a pre-made gdd.
|
||||
If only array of 5 aitString is placed into a pre-made array of 16,
|
||||
then the last 11 should be initialized to NULLs or something, same for
|
||||
fixed string - especially the fixed string
|
||||
|
||||
Jim
|
||||
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
|
||||
// Author: Jim Kowalkowski
|
||||
// Date: 2/96
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// $Log$
|
||||
//
|
||||
// *Revision 0.4 1996/06/25 18:58:58 jbk
|
||||
// *more fixes for the aitString management functions and mapping menus
|
||||
// *Revision 0.3 1996/06/24 03:15:28 jbk
|
||||
// *name changes and fixes for aitString and fixed string functions
|
||||
// *Revision 0.2 1996/06/17 15:24:04 jbk
|
||||
// *many mods, string class corrections.
|
||||
// *gdd operator= protection.
|
||||
// *dbmapper uses aitString array for menus now
|
||||
// *Revision 0.1 1996/05/31 13:15:17 jbk
|
||||
// *add new stuff
|
||||
|
||||
#define AIT_CONVERT_SOURCE 1
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "aitConvert.h"
|
||||
|
||||
extern "C" {
|
||||
void aitNoConvert(void* /*dest*/,const void* /*src*/,aitIndex /*count*/) { }
|
||||
}
|
||||
|
||||
#ifdef AIT_CONVERT
|
||||
#undef AIT_CONVERT
|
||||
#endif
|
||||
#ifdef AIT_TO_NET_CONVERT
|
||||
#undef AIT_TO_NET_CONVERT
|
||||
#endif
|
||||
#ifdef AIT_FROM_NET_CONVERT
|
||||
#undef AIT_FROM_NET_CONVERT
|
||||
#endif
|
||||
|
||||
/* put the fixed conversion functions here (ones not generated) */
|
||||
|
||||
/* ------- extra string conversion functions --------- */
|
||||
static void aitConvertStringString(void* d,const void* s,aitIndex c)
|
||||
{
|
||||
// does not work - need to be fixed
|
||||
int i;
|
||||
aitString *in=(aitString*)s, *out=(aitString*)d;
|
||||
|
||||
for(i=0;i<c;i++) out[i]=in[i];
|
||||
}
|
||||
static void aitConvertToNetStringString(void* d,const void* s,aitIndex c)
|
||||
{ aitConvertStringString(d,s,c); }
|
||||
static void aitConvertFromNetStringString(void* d,const void* s,aitIndex c)
|
||||
{ aitConvertStringString(d,s,c); }
|
||||
|
||||
/* ------ all the fixed string conversion functions ------ */
|
||||
static void aitConvertFixedStringFixedString(void* d,const void* s,aitIndex c)
|
||||
{
|
||||
aitUint32 len = c*AIT_FIXED_STRING_SIZE;
|
||||
memcpy(d,s,len);
|
||||
}
|
||||
static void aitConvertToNetFixedStringFixedString(void* d,const void* s,aitIndex c)
|
||||
{ aitConvertFixedStringFixedString(d,s,c); }
|
||||
static void aitConvertFromNetFixedStringFixedString(void* d,const void* s,aitIndex c)
|
||||
{ aitConvertFixedStringFixedString(d,s,c); }
|
||||
|
||||
static void aitConvertStringFixedString(void* d,const void* s,aitIndex c)
|
||||
{
|
||||
int i;
|
||||
aitString* out = (aitString*)d;
|
||||
aitFixedString* in = (aitFixedString*)s;
|
||||
|
||||
for(i=0;i<c;i++) out[i].installString(in[i].fixed_string);
|
||||
}
|
||||
|
||||
static void aitConvertFixedStringString(void* d,const void* s,aitIndex c)
|
||||
{
|
||||
int i;
|
||||
aitString* in = (aitString*)s;
|
||||
aitFixedString* out = (aitFixedString*)d;
|
||||
|
||||
for(i=0;i<c;i++) strcpy(out[i].fixed_string,in[i].string());
|
||||
}
|
||||
|
||||
static void aitConvertToNetStringFixedString(void* d,const void* s,aitIndex c)
|
||||
{ aitConvertStringFixedString(d,s,c); }
|
||||
static void aitConvertFromNetFixedStringString(void* d,const void* s,aitIndex c)
|
||||
{ aitConvertFixedStringString(d,s,c); }
|
||||
static void aitConvertToNetFixedStringString(void* d,const void* s,aitIndex c)
|
||||
{ aitConvertStringFixedString(d,s,c); }
|
||||
static void aitConvertFromNetStringFixedString(void* d,const void* s,aitIndex c)
|
||||
{ aitConvertFixedStringString(d,s,c); }
|
||||
|
||||
#define AIT_CONVERT 1
|
||||
#include "aitConvertGenerated.cc"
|
||||
#undef AIT_CONVERT
|
||||
|
||||
/* include the network byte order functions if needed */
|
||||
#ifdef AIT_NEED_BYTE_SWAP
|
||||
|
||||
#define AIT_TO_NET_CONVERT 1
|
||||
#include "aitConvertGenerated.cc"
|
||||
#undef AIT_TO_NET_CONVERT
|
||||
|
||||
#define AIT_FROM_NET_CONVERT 1
|
||||
#include "aitConvertGenerated.cc"
|
||||
#undef AIT_FROM_NET_CONVERT
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
#ifndef AIT_CONVERT_H__
|
||||
#define AIT_CONVERT_H__
|
||||
|
||||
/*
|
||||
* Author: Jim Kowalkowski
|
||||
* Date: 2/96
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* $Log$
|
||||
*
|
||||
* *Revision 1.1 1996/05/31 13:15:18 jbk
|
||||
* *add new stuff
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
#include "aitTypes.h"
|
||||
|
||||
#if defined(__i386) || defined(i386)
|
||||
#define AIT_NEED_BYTE_SWAP 1
|
||||
#endif
|
||||
|
||||
/* all conversion functions have this prototype */
|
||||
typedef void (*aitFunc)(void* dest,const void* src,aitIndex count);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* main conversion table */
|
||||
extern aitFunc aitConvertTable[aitTotal][aitTotal];
|
||||
/* do not make conversion table if not needed */
|
||||
#ifdef AIT_NEED_BYTE_SWAP
|
||||
extern aitFunc aitConvertToNetTable[aitTotal][aitTotal];
|
||||
extern aitFunc aitConvertFromNetTable[aitTotal][aitTotal];
|
||||
#else
|
||||
#define aitConvertToNetTable aitConvertTable
|
||||
#define aitConvertFromNetTable aitConvertTable
|
||||
#endif /* AIT_NEED_BYTE_SWAP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ---------- convenience routines for performing conversions ---------- */
|
||||
|
||||
#if defined(__cplusplus) && !defined(__GNUC__)
|
||||
|
||||
inline void aitConvert(aitEnum desttype, void* dest,
|
||||
aitEnum srctype, const void* src, aitIndex count)
|
||||
{ aitConvertTable[desttype][srctype](dest,src,count); }
|
||||
|
||||
inline void aitConvertToNet(aitEnum desttype, void* dest,
|
||||
aitEnum srctype, const void* src, aitIndex count)
|
||||
{ aitConvertToNetTable[desttype][srctype](dest,src,count); }
|
||||
|
||||
inline void aitConvertFromNet(aitEnum desttype, void* dest,
|
||||
aitEnum srctype, const void* src, aitIndex count)
|
||||
{ aitConvertFromNetTable[desttype][srctype](dest,src,count); }
|
||||
|
||||
#else
|
||||
|
||||
#define aitConvert(DESTTYPE,DEST,SRCTYPE,SRC,COUNT) \
|
||||
aitConvertTable[DESTTYPE][SRCTYPE](DEST,SRC,COUNT)
|
||||
|
||||
#define aitConvertToNet(DESTTYPE,DEST,SRCTYPE,SRC,COUNT) \
|
||||
aitConvertToNetTable[DESTTYPE][SRCTYPE](DEST,SRC,COUNT)
|
||||
|
||||
#define aitConvertFromNet(DESTTYPE,DEST,SRCTYPE,SRC,COUNT) \
|
||||
aitConvertFromNetTable[DESTTYPE][SRCTYPE](DEST,SRC,COUNT)
|
||||
|
||||
#endif
|
||||
|
||||
/* ----------- byte order conversion definitions ------------ */
|
||||
|
||||
#define aitUint64 aitUint32
|
||||
|
||||
#if defined(__cplusplus) && !defined(__GNUC__)
|
||||
|
||||
inline void aitToNetOrder16(aitUint16* dest,aitUint16* src)
|
||||
{ *dest=htons(*src); }
|
||||
inline void aitToNetOrder32(aitUint32* dest,aitUint32* src)
|
||||
{ *dest=htonl(*src); }
|
||||
inline void aitFromNetOrder16(aitUint16* dest,aitUint16* src)
|
||||
{ *dest=ntohs(*src); }
|
||||
inline void aitFromNetOrder32(aitUint32* dest,aitUint32* src)
|
||||
{ *dest=ntohl(*src); }
|
||||
inline void aitToNetOrder64(aitUint64* dest, aitUint64* src)
|
||||
{
|
||||
aitUint32 ait_temp_var_;
|
||||
ait_temp_var_=(aitUint32)htonl(src[1]);
|
||||
dest[1]=(aitUint32)htonl(src[0]);
|
||||
dest[0]=ait_temp_var_;
|
||||
}
|
||||
inline void aitFromNetOrder64(aitUint64* dest, aitUint64* src)
|
||||
{
|
||||
aitUint32 ait_temp_var_;
|
||||
ait_temp_var_=(aitUint32)ntohl(src[1]);
|
||||
dest[1]=(aitUint32)ntohl(src[0]);
|
||||
dest[0]=ait_temp_var_;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/* !The following generate code! */
|
||||
#define aitToNetOrder16(dest,src) (*(dest)=htons(*(src)))
|
||||
#define aitToNetOrder32(dest,src) (*(dest)=htonl(*(src)))
|
||||
#define aitFromNetOrder16(dest,src) (*(dest)=ntohs(*(src)))
|
||||
#define aitFromNetOrder32(dest,src) (*(dest)=ntohl(*(src)))
|
||||
|
||||
/* be careful using these because of brackets, these should be functions */
|
||||
#define aitToNetOrder64(dest,src) \
|
||||
{ \
|
||||
aitUint32 ait_temp_var_; \
|
||||
ait_temp_var_=(aitUint32)htonl((src)[1]); \
|
||||
(dest)[1]=(aitUint32)htonl((src)[0]); \
|
||||
(dest)[0]=ait_temp_var_; \
|
||||
}
|
||||
#define aitFromNetOrder64(dest,src) \
|
||||
{ \
|
||||
aitUint32 ait_temp_var_; \
|
||||
ait_temp_var_=(aitUint32)ntohl((src)[1]); \
|
||||
(dest)[1]=(aitUint32)ntohl((src)[0]); \
|
||||
(dest)[0]=ait_temp_var_; \
|
||||
}
|
||||
|
||||
#endif /* __cpluspluc && !__GNUC__ */
|
||||
|
||||
#define aitToNetFloat64 aitToNetOrder64
|
||||
#define aitToNetFloat32 aitToNetOrder32
|
||||
#define aitFromNetFloat64 aitFromNetOrder64
|
||||
#define aitFromNetFloat32 aitFromNetOrder32
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,439 @@
|
||||
/*
|
||||
* Author: Jim Kowalkowski
|
||||
* Date: 2/96
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* $Log$
|
||||
* Revision 1.3 1996/06/17 15:24:05 jbk
|
||||
* many mods, string class corrections.
|
||||
* gdd operator= protection.
|
||||
* dbmapper uses aitString array for menus now
|
||||
*
|
||||
* Revision 1.2 1996/06/13 21:31:52 jbk
|
||||
* Various fixes and correction - including ref_cnt change to unsigned short
|
||||
*
|
||||
* Revision 1.1 1996/05/31 13:15:19 jbk
|
||||
* add new stuff
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "aitTypes.h"
|
||||
|
||||
/*
|
||||
Still need to generate to "FromNet" matrix and rename the "Net" conversions
|
||||
to "ToNet".
|
||||
*/
|
||||
|
||||
void MakeNormalFunc(int i,int j,int k);
|
||||
void MakeToFunc(int i,int j,int k);
|
||||
void MakeFromFunc(int i,int j,int k);
|
||||
void GenName(int i,int j,int k);
|
||||
void GenVars(int i,int j);
|
||||
void MakeStringFuncFrom(int i,int j,int k);
|
||||
void MakeStringFuncTo(int i,int j,int k);
|
||||
void MakeFStringFuncFrom(int i,int j,int k);
|
||||
void MakeFStringFuncTo(int i,int j,int k);
|
||||
|
||||
#define FILE_NAME "aitConvertGenerated.cc"
|
||||
#define pr fprintf
|
||||
|
||||
#define AIT_TO_NET 0
|
||||
#define AIT_FROM_NET 1
|
||||
#define AIT_NORMAL 2
|
||||
|
||||
#define AIT_SWAP_NONE 0
|
||||
#define AIT_SWAP_16 1
|
||||
#define AIT_SWAP_32 2
|
||||
#define AIT_SWAP_64 3
|
||||
|
||||
static const char* table_type[] = {
|
||||
"aitConvertToNet",
|
||||
"aitConvertFromNet",
|
||||
"aitConvert" };
|
||||
static const char* table_def[] = {
|
||||
"#if defined(AIT_TO_NET_CONVERT)",
|
||||
"#elif defined(AIT_FROM_NET_CONVERT)",
|
||||
"#else /* AIT_CONVERT */" };
|
||||
|
||||
static FILE *dfd;
|
||||
|
||||
int main(int argc,char* argv[])
|
||||
{
|
||||
int i,j,k;
|
||||
|
||||
if((dfd=fopen(FILE_NAME,"w"))==NULL)
|
||||
{
|
||||
pr(stderr,"file %s failed to open\n",FILE_NAME);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------*/
|
||||
/* generate basic conversion functions */
|
||||
|
||||
pr(dfd,"\n");
|
||||
|
||||
/* generate each group - to/from/normal */
|
||||
for(k=0;k<3;k++)
|
||||
{
|
||||
pr(dfd,"%s\n",table_def[k]);
|
||||
for(i=aitConvertAutoFirst;i<=aitConvertAutoLast;i++)
|
||||
for(j=aitConvertAutoFirst;j<=aitConvertAutoLast;j++)
|
||||
{
|
||||
switch(k)
|
||||
{
|
||||
case AIT_TO_NET: MakeToFunc(i,j,k); break;
|
||||
case AIT_FROM_NET: MakeFromFunc(i,j,k); break;
|
||||
case AIT_NORMAL: MakeNormalFunc(i,j,k); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
pr(dfd,"#endif\n\n");
|
||||
|
||||
for(k=0;k<3;k++)
|
||||
{
|
||||
pr(dfd,"%s\n",table_def[k]);
|
||||
for(i=aitConvertAutoFirst;i<=aitConvertAutoLast;i++)
|
||||
{
|
||||
MakeStringFuncTo(i,aitEnumString,k);
|
||||
MakeStringFuncFrom(aitEnumString,i,k);
|
||||
MakeFStringFuncTo(i,aitEnumFixedString,k);
|
||||
MakeFStringFuncFrom(aitEnumFixedString,i,k);
|
||||
}
|
||||
}
|
||||
pr(dfd,"#endif\n\n");
|
||||
|
||||
/* generate the three conversion table matrices */
|
||||
for(k=0;k<3;k++)
|
||||
{
|
||||
pr(dfd,"%s\n",table_def[k]);
|
||||
pr(dfd,"aitFunc %sTable[aitTotal][aitTotal]={\n",table_type[k]);
|
||||
|
||||
/* generate network conversion matrix */
|
||||
for(i=aitFirst;i<=aitLast;i++)
|
||||
{
|
||||
pr(dfd," {\n");
|
||||
for(j=aitFirst;j<=aitLast;j++)
|
||||
{
|
||||
if(i<aitConvertFirst || i>aitConvertLast ||
|
||||
j<aitConvertFirst || j>aitConvertLast)
|
||||
pr(dfd,"aitNoConvert");
|
||||
else
|
||||
pr(dfd,"%s%s%s",table_type[k],
|
||||
&(aitName[i])[3],&(aitName[j])[3]);
|
||||
|
||||
if(j<aitLast)
|
||||
{
|
||||
fputc(',',dfd);
|
||||
if((j+1)%2==0) pr(dfd,"\n");
|
||||
}
|
||||
else
|
||||
fputc('\n',dfd);
|
||||
}
|
||||
pr(dfd," }");
|
||||
if(i<aitLast) pr(dfd,",\n"); else fputc('\n',dfd);
|
||||
}
|
||||
pr(dfd,"};\n\n");
|
||||
}
|
||||
pr(dfd,"#endif\n");
|
||||
|
||||
fclose(dfd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MakeStringFuncFrom(int i,int j,int k)
|
||||
{
|
||||
/* assumes that void* d in an array of char pointers of length c */
|
||||
/* takes numeric data from source j and convert it to string in dest i */
|
||||
|
||||
pr(dfd,"static void %s%s%s(void* d,const void* s,aitIndex c)\n",
|
||||
table_type[k],&(aitName[i])[3],&(aitName[j])[3]);
|
||||
pr(dfd,"{\n");
|
||||
pr(dfd,"\taitIndex i;\n");
|
||||
pr(dfd,"\tchar temp[AIT_FIXED_STRING_SIZE];\n");
|
||||
|
||||
if(j==aitEnumInt8)
|
||||
pr(dfd,"\taitInt32 itmp;\n");
|
||||
else if(j==aitEnumUint8)
|
||||
pr(dfd,"\taitUint32 itmp;\n");
|
||||
|
||||
pr(dfd,"\taitString* out=(aitString*)d;\n");
|
||||
pr(dfd,"\t%s* in=(%s*)s;\n",aitName[j],aitName[j]);
|
||||
pr(dfd,"\tfor(i=0;i<c;i++) {\n");
|
||||
|
||||
if(j==aitEnumInt8)
|
||||
pr(dfd,"\t\titmp=(aitInt32)in[i];\n");
|
||||
else if(j==aitEnumUint8)
|
||||
pr(dfd,"\t\titmp=(aitUint32)in[i];\n");
|
||||
|
||||
if(j==aitEnumInt8)
|
||||
pr(dfd,"\t\tsprintf(temp,aitStringType[aitEnumInt32],itmp);\n");
|
||||
else if(j==aitEnumUint8)
|
||||
pr(dfd,"\t\tsprintf(temp,aitStringType[aitEnumUint32],itmp);\n");
|
||||
else
|
||||
pr(dfd,"\t\tsprintf(temp,aitStringType[%d],in[i]);\n",j);
|
||||
|
||||
pr(dfd,"\t\tout[i].copy(temp);\n");
|
||||
pr(dfd,"\t}\n");
|
||||
pr(dfd,"}\n");
|
||||
}
|
||||
|
||||
void MakeStringFuncTo(int i,int j,int k)
|
||||
{
|
||||
/* assumes that void* d in an array of char pointers of length c */
|
||||
/* takes string data from source j and convert it to numeric in dest i */
|
||||
|
||||
pr(dfd,"static void %s%s%s(void* d,const void* s,aitIndex c)\n",
|
||||
table_type[k],&(aitName[i])[3],&(aitName[j])[3]);
|
||||
pr(dfd,"{\n");
|
||||
pr(dfd,"\taitIndex i;\n");
|
||||
pr(dfd,"\taitString* in=(aitString*)s;\n");
|
||||
|
||||
/* I special cased the Int8 and Uint8 - yuck */
|
||||
|
||||
if(i==aitEnumInt8)
|
||||
pr(dfd,"\taitInt32 itmp;\n");
|
||||
else if(i==aitEnumUint8)
|
||||
pr(dfd,"\taitUint32 itmp;\n");
|
||||
|
||||
pr(dfd,"\t%s* out=(%s*)d;\n",aitName[i],aitName[i]);
|
||||
pr(dfd,"\tfor(i=0;i<c;i++) {\n");
|
||||
pr(dfd,"\t\tif(in[i].string()) {\n");
|
||||
|
||||
if(i==aitEnumInt8)
|
||||
{
|
||||
pr(dfd,"\t\t\tsscanf(in[i],aitStringType[aitEnumInt32],&itmp);\n");
|
||||
pr(dfd,"\t\t\tout[i]=(aitInt8)itmp;\n");
|
||||
}
|
||||
else if(i==aitEnumUint8)
|
||||
{
|
||||
pr(dfd,"\t\t\tsscanf(in[i],aitStringType[aitEnumUint32],&itmp);\n");
|
||||
pr(dfd,"\t\t\tout[i]=(aitUint8)itmp;\n");
|
||||
}
|
||||
else
|
||||
pr(dfd,"\t\t\tsscanf(in[i].string(),aitStringType[%d],&out[i]);\n",i);
|
||||
|
||||
pr(dfd,"\t\t} else\n");
|
||||
pr(dfd,"\t\t\tout[i]=0;\n");
|
||||
pr(dfd,"\t}\n}\n");
|
||||
}
|
||||
|
||||
void MakeFStringFuncFrom(int i,int j,int k)
|
||||
{
|
||||
/* assumes that void* d in an array of char pointers of length c */
|
||||
/* takes numeric data from source j and convert it to string in dest i */
|
||||
|
||||
pr(dfd,"static void %s%s%s(void* d,const void* s,aitIndex c)\n",
|
||||
table_type[k],&(aitName[i])[3],&(aitName[j])[3]);
|
||||
pr(dfd,"{\n");
|
||||
pr(dfd,"\taitIndex i;\n");
|
||||
|
||||
if(j==aitEnumInt8)
|
||||
pr(dfd,"\taitInt32 itmp;\n");
|
||||
else if(j==aitEnumUint8)
|
||||
pr(dfd,"\taitUint32 itmp;\n");
|
||||
|
||||
pr(dfd,"\taitFixedString* out=(aitFixedString*)d;\n");
|
||||
pr(dfd,"\t%s* in=(%s*)s;\n",aitName[j],aitName[j]);
|
||||
pr(dfd,"\tfor(i=0;i<c;i++) {\n");
|
||||
|
||||
if(j==aitEnumInt8)
|
||||
pr(dfd,"\t\titmp=(aitInt32)in[i];\n");
|
||||
else if(j==aitEnumUint8)
|
||||
pr(dfd,"\t\titmp=(aitUint32)in[i];\n");
|
||||
|
||||
if(j==aitEnumInt8)
|
||||
pr(dfd,"\t\tsprintf(out[i].fixed_string,aitStringType[aitEnumInt32],itmp);\n");
|
||||
else if(j==aitEnumUint8)
|
||||
pr(dfd,"\t\tsprintf(out[i].fixed_string,aitStringType[aitEnumUint32],itmp);\n");
|
||||
else
|
||||
pr(dfd,"\t\tsprintf(out[i].fixed_string,aitStringType[%d],in[i]);\n",j);
|
||||
|
||||
pr(dfd,"\t}\n}\n");
|
||||
}
|
||||
|
||||
void MakeFStringFuncTo(int i,int j,int k)
|
||||
{
|
||||
/* assumes that void* d in an array of char pointers of length c */
|
||||
/* takes string data from source j and convert it to numeric in dest i */
|
||||
|
||||
pr(dfd,"static void %s%s%s(void* d,const void* s,aitIndex c)\n",
|
||||
table_type[k],&(aitName[i])[3],&(aitName[j])[3]);
|
||||
pr(dfd,"{\n");
|
||||
pr(dfd,"\taitIndex i;\n");
|
||||
pr(dfd,"\taitFixedString* in=(aitFixedString*)s;\n");
|
||||
|
||||
/* I special cased the Int8 and Uint8 - yuck */
|
||||
|
||||
if(i==aitEnumInt8)
|
||||
pr(dfd,"\taitInt32 itmp;\n");
|
||||
else if(i==aitEnumUint8)
|
||||
pr(dfd,"\taitUint32 itmp;\n");
|
||||
|
||||
pr(dfd,"\t%s* out=(%s*)d;\n",aitName[i],aitName[i]);
|
||||
pr(dfd,"\tfor(i=0;i<c;i++) {\n");
|
||||
|
||||
if(i==aitEnumInt8)
|
||||
{
|
||||
pr(dfd,"\t\tsscanf(in[i].fixed_string,aitStringType[aitEnumInt32],&itmp);\n");
|
||||
pr(dfd,"\t\tout[i]=(aitInt8)itmp;\n");
|
||||
}
|
||||
else if(i==aitEnumUint8)
|
||||
{
|
||||
pr(dfd,"\t\tsscanf(in[i].fixed_string,aitStringType[aitEnumUint32],&itmp);\n");
|
||||
pr(dfd,"\t\tout[i]=(aitUint8)itmp;\n");
|
||||
}
|
||||
else
|
||||
pr(dfd,"\t\tsscanf(in[i].fixed_string,aitStringType[%d],&out[i]);\n",i);
|
||||
|
||||
pr(dfd,"\t}\n}\n");
|
||||
}
|
||||
|
||||
void GenName(int i,int j,int k)
|
||||
{
|
||||
const char* i_name = &((aitName[i])[3]);
|
||||
const char* j_name = &((aitName[j])[3]);
|
||||
|
||||
pr(dfd,"static void %s%s%s(void* d,const void* s,aitIndex c)\n",
|
||||
table_type[k],i_name,j_name);
|
||||
}
|
||||
|
||||
void GenVars(int i,int j)
|
||||
{
|
||||
pr(dfd,"\taitIndex i;\n");
|
||||
pr(dfd,"\t%s* d_val=(%s*)d;\n",aitName[i],aitName[i]);
|
||||
pr(dfd,"\t%s* s_val=(%s*)s;\n\n",aitName[j],aitName[j]);
|
||||
}
|
||||
|
||||
void MakeFromFunc(int i,int j,int k)
|
||||
{
|
||||
int conv_type;
|
||||
char *len_msg,*conv_msg;
|
||||
|
||||
/* destination = i, source = j, type = k */
|
||||
GenName(i,j,k);
|
||||
pr(dfd,"{\n");
|
||||
|
||||
/* check if we need network byte swaps */
|
||||
if (strstr(aitName[j],"16"))
|
||||
{ len_msg="16"; conv_type=AIT_SWAP_16; }
|
||||
else if(strstr(aitName[j],"32"))
|
||||
{ len_msg="32"; conv_type=AIT_SWAP_32; }
|
||||
else if(strstr(aitName[j],"64"))
|
||||
{ len_msg="64"; conv_type=AIT_SWAP_64; }
|
||||
else
|
||||
{ len_msg=""; conv_type=AIT_SWAP_NONE; }
|
||||
|
||||
if (strstr(aitName[j],"Float"))
|
||||
conv_msg="Float";
|
||||
else
|
||||
conv_msg="Order";
|
||||
|
||||
GenVars(i,j);
|
||||
|
||||
if(i==j || conv_type==AIT_SWAP_NONE)
|
||||
{
|
||||
if(conv_type!=AIT_SWAP_NONE)
|
||||
{
|
||||
pr(dfd,"\tfor(i=0;i<c;i++)\n");
|
||||
pr(dfd,"\t\taitFromNet%s%s",conv_msg,len_msg);
|
||||
pr(dfd,"((aitUint%s*)&d_val[i],",len_msg);
|
||||
pr(dfd,"(aitUint%s*)&s_val[i]);\n",len_msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
pr(dfd,"\tfor(i=0;i<c;i++)\n");
|
||||
pr(dfd,"\t\td_val[i]=(%s)(s_val[i]);\n",aitName[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* first swap, then cast to correct type */
|
||||
pr(dfd,"\t%s temp;\n\n",aitName[j]);
|
||||
pr(dfd,"\tfor(i=0;i<c;i++) {\n");
|
||||
pr(dfd,"\t\taitFromNet%s%s",conv_msg,len_msg);
|
||||
pr(dfd,"((aitUint%s*)&temp,",len_msg);
|
||||
pr(dfd,"(aitUint%s*)&s_val[i]);\n",len_msg);
|
||||
pr(dfd,"\t\td_val[i]=(%s)temp;\n",aitName[i]);
|
||||
pr(dfd,"\t}\n");
|
||||
}
|
||||
pr(dfd,"}\n");
|
||||
}
|
||||
|
||||
void MakeToFunc(int i,int j,int k)
|
||||
{
|
||||
int conv_type;
|
||||
char *len_msg,*conv_msg;
|
||||
|
||||
/* destination = i, source = j, type = k */
|
||||
GenName(i,j,k);
|
||||
pr(dfd,"{\n");
|
||||
|
||||
/* check if we need network byte swaps */
|
||||
if (strstr(aitName[i],"16"))
|
||||
{ len_msg="16"; conv_type=AIT_SWAP_16; }
|
||||
else if(strstr(aitName[i],"32"))
|
||||
{ len_msg="32"; conv_type=AIT_SWAP_32; }
|
||||
else if(strstr(aitName[i],"64"))
|
||||
{ len_msg="64"; conv_type=AIT_SWAP_64; }
|
||||
else
|
||||
{ len_msg=""; conv_type=AIT_SWAP_NONE; }
|
||||
|
||||
if (strstr(aitName[i],"Float"))
|
||||
conv_msg="Float";
|
||||
else
|
||||
conv_msg="Order";
|
||||
|
||||
GenVars(i,j);
|
||||
|
||||
if(i==j || conv_type==AIT_SWAP_NONE)
|
||||
{
|
||||
if(conv_type!=AIT_SWAP_NONE)
|
||||
{
|
||||
pr(dfd,"\tfor(i=0;i<c;i++)\n");
|
||||
pr(dfd,"\t\taitToNet%s%s",conv_msg,len_msg);
|
||||
pr(dfd,"((aitUint%s*)&d_val[i],",len_msg);
|
||||
pr(dfd,"(aitUint%s*)&s_val[i]);\n",len_msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
pr(dfd,"\tfor(i=0;i<c;i++)\n");
|
||||
pr(dfd,"\t\td_val[i]=(%s)(s_val[i]);\n",aitName[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* cast first to correct type, then swap */
|
||||
pr(dfd,"\t%s temp;\n\n",aitName[i]);
|
||||
pr(dfd,"\tfor(i=0;i<c;i++) {\n");
|
||||
pr(dfd,"\t\ttemp=(%s)s_val[i];\n",aitName[i]);
|
||||
pr(dfd,"\t\taitToNet%s%s",conv_msg,len_msg);
|
||||
pr(dfd,"((aitUint%s*)&d_val[i],",len_msg);
|
||||
pr(dfd,"(aitUint%s*)&temp);\n",len_msg);
|
||||
pr(dfd,"\t}\n");
|
||||
}
|
||||
|
||||
pr(dfd,"}\n");
|
||||
}
|
||||
|
||||
void MakeNormalFunc(int i,int j,int k)
|
||||
{
|
||||
GenName(i,j,k);
|
||||
pr(dfd,"{\n");
|
||||
|
||||
if(i==j)
|
||||
pr(dfd,"\tmemcpy(d,s,c*sizeof(%s));\n",aitName[i]);
|
||||
else
|
||||
{
|
||||
GenVars(i,j);
|
||||
pr(dfd,"\tfor(i=0;i<c;i++)\n");
|
||||
pr(dfd,"\t\td_val[i]=(%s)(s_val[i]);\n",aitName[i]);
|
||||
}
|
||||
pr(dfd,"}\n");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
|
||||
// Author: Jim Kowalkowski
|
||||
// Date: 6/20/96
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// $Log$
|
||||
//
|
||||
|
||||
#include "aitTypes.h"
|
||||
#include "aitHelpers.h"
|
||||
|
||||
aitIndex aitString::compact(aitString* array, aitIndex arraySize,
|
||||
void* buf, aitIndex bufSize)
|
||||
{
|
||||
aitIndex i,j;
|
||||
aitUint32 pos;
|
||||
char* ptr=(char*)buf;
|
||||
aitString* str=(aitString*)buf;
|
||||
|
||||
// copy the array first
|
||||
pos=sizeof(aitString)*arraySize;
|
||||
if(bufSize<pos) return 0;
|
||||
memcpy(ptr,(char*)array,pos);
|
||||
|
||||
for(i=0;i<arraySize;i++)
|
||||
{
|
||||
if(str[i].string())
|
||||
{
|
||||
memcpy(&ptr[pos],str[i].string(),str[i].length()+1); // include NULL
|
||||
str[i]=&ptr[pos];
|
||||
pos+=str[i].length()+1;
|
||||
}
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
aitUint32 aitString::totalLength(aitString* array, aitIndex arraySize)
|
||||
{
|
||||
aitIndex i;
|
||||
aitUint32 tot;
|
||||
|
||||
tot=sizeof(aitString)*arraySize;
|
||||
for(i=0;i<arraySize;i++)
|
||||
tot+=array[i].length()+1; // include the NULL
|
||||
|
||||
return tot;
|
||||
}
|
||||
|
||||
aitUint32 aitString::stringsLength(aitString* array, aitIndex arraySize)
|
||||
{
|
||||
aitIndex i;
|
||||
aitUint32 tot;
|
||||
|
||||
for(tot=0,i=0;i<arraySize;i++)
|
||||
tot+=array[i].length()+1; // include the NULL
|
||||
|
||||
return tot;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,217 @@
|
||||
#ifndef aitHelpersInclude
|
||||
#define aitHelpersInclude
|
||||
|
||||
/*
|
||||
* Authors: Jeff Hill and Jim Kowalkowski
|
||||
* Date: 6/20/96
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* $Log$
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
#ifndef assert // allows use of epicsAssert.h
|
||||
#include <assert.h>
|
||||
#endif
|
||||
|
||||
const unsigned NSecPerSec = 1000000000u;
|
||||
const unsigned NSecPerUSec = 1000u;
|
||||
const unsigned SecPerMin = 60u;
|
||||
|
||||
class aitTimeStamp {
|
||||
friend aitTimeStamp operator+ (const aitTimeStamp &lhs, const aitTimeStamp &rhs);
|
||||
friend aitTimeStamp operator- (const aitTimeStamp &lhs, const aitTimeStamp &rhs);
|
||||
friend int operator>= (const aitTimeStamp &lhs, const aitTimeStamp &rhs);
|
||||
public:
|
||||
aitTimeStamp () : tv_sec(0u), tv_nsec(0u) {}
|
||||
aitTimeStamp (const aitTimeStamp &t) : tv_sec(t.tv_sec), tv_nsec(t.tv_nsec) {}
|
||||
aitTimeStamp (const unsigned long tv_secIn, const unsigned long tv_nsecIn) :
|
||||
tv_sec(tv_secIn), tv_nsec(tv_nsecIn)
|
||||
{
|
||||
if (tv_nsecIn>=NSecPerSec) {
|
||||
this->tv_sec += this->tv_nsec/NSecPerSec;
|
||||
this->tv_nsec = this->tv_nsec%NSecPerSec;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// fetched as fields so this file is not required
|
||||
// to include os dependent struct timeval
|
||||
//
|
||||
void getTV(long &tv_secOut, long &uSecOut) {
|
||||
assert (this->tv_sec<=LONG_MAX);
|
||||
tv_secOut = (long) this->tv_sec;
|
||||
assert (this->tv_nsec<=LONG_MAX);
|
||||
uSecOut = (long) this->tv_nsec/NSecPerUSec;
|
||||
}
|
||||
//
|
||||
// for use when loading struct timeval
|
||||
//
|
||||
void get(unsigned long &tv_secOut, unsigned long &tv_nsecOut) {
|
||||
tv_secOut = this->tv_sec;
|
||||
tv_nsecOut = this->tv_nsec;
|
||||
}
|
||||
|
||||
operator double()
|
||||
{
|
||||
return ((double)this->tv_nsec)/NSecPerSec+this->tv_sec;
|
||||
}
|
||||
|
||||
operator float()
|
||||
{
|
||||
return ((float)this->tv_nsec)/NSecPerSec+this->tv_sec;
|
||||
}
|
||||
|
||||
static aitTimeStamp getCurrent();
|
||||
// private:
|
||||
unsigned long tv_sec;
|
||||
unsigned long tv_nsec;
|
||||
};
|
||||
|
||||
inline aitTimeStamp operator+ (const aitTimeStamp &lhs, const aitTimeStamp &rhs)
|
||||
{
|
||||
return aitTimeStamp(lhs.tv_sec + rhs.tv_sec, lhs.tv_nsec + rhs.tv_nsec);
|
||||
}
|
||||
|
||||
//
|
||||
// like data type unsigned this assumes that the lhs > rhs
|
||||
// (otherwise we assume tv_sec wrap around)
|
||||
//
|
||||
inline aitTimeStamp operator- (const aitTimeStamp &lhs, const aitTimeStamp &rhs)
|
||||
{
|
||||
unsigned long tv_nsec, tv_sec;
|
||||
|
||||
if (lhs.tv_sec<rhs.tv_sec) {
|
||||
//
|
||||
// wrap around
|
||||
//
|
||||
tv_sec = lhs.tv_sec + (ULONG_MAX - rhs.tv_sec);
|
||||
}
|
||||
else {
|
||||
tv_sec = lhs.tv_sec - rhs.tv_sec;
|
||||
}
|
||||
|
||||
if (lhs.tv_nsec<rhs.tv_nsec) {
|
||||
//
|
||||
// Borrow
|
||||
//
|
||||
tv_nsec = lhs.tv_nsec + NSecPerSec - rhs.tv_nsec;
|
||||
tv_sec--;
|
||||
}
|
||||
else {
|
||||
tv_nsec = lhs.tv_nsec - rhs.tv_nsec;
|
||||
}
|
||||
return aitTimeStamp(tv_sec, tv_nsec);
|
||||
}
|
||||
|
||||
inline int operator>= (const aitTimeStamp &lhs, const aitTimeStamp &rhs)
|
||||
{
|
||||
if (lhs.tv_sec>rhs.tv_sec) {
|
||||
return 1;
|
||||
}
|
||||
else if (lhs.tv_sec==rhs.tv_sec) {
|
||||
if (lhs.tv_nsec>=rhs.tv_nsec) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// very simple class for string storage (for now)
|
||||
//
|
||||
//
|
||||
class aitString
|
||||
{
|
||||
private:
|
||||
enum aitStrType {aitStrMalloc, aitStrConst};
|
||||
|
||||
int set(const char* p)
|
||||
{
|
||||
if(p)
|
||||
{
|
||||
len=strlen(p);
|
||||
str=(const char*)new char[len+1];
|
||||
if(str)
|
||||
{
|
||||
strcpy((char*)str, p);
|
||||
type=aitStrMalloc;
|
||||
}
|
||||
else
|
||||
{
|
||||
// If malloc fails set it to
|
||||
// an empty constant str
|
||||
str = "";
|
||||
len = 0u;
|
||||
type = aitStrConst;
|
||||
printf("aitString: no pool => continuing with nill str\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
str=NULL;
|
||||
len=0u;
|
||||
type=aitStrConst;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cset(const char* p)
|
||||
{
|
||||
str=p;
|
||||
type=aitStrConst;
|
||||
if(str)
|
||||
len=strlen(str);
|
||||
else
|
||||
len = 0u;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
aitString(void) { cset((char*)NULL); }
|
||||
aitString(const char* x) { cset(x); }
|
||||
aitString(char* x) { cset(x); }
|
||||
|
||||
operator aitUint16(void) { return len; }
|
||||
operator const char*(void) { return str; }
|
||||
aitUint32 length(void) { return len; }
|
||||
const char* string(void) const { return str; }
|
||||
void force(char* x) { str=x; }
|
||||
void force(unsigned char* x) { str=(char*)x; }
|
||||
void force(unsigned long x) { str=(char*)x; }
|
||||
|
||||
void clear(void)
|
||||
{
|
||||
if (str && type==aitStrMalloc)
|
||||
{
|
||||
char *pStr=(char*)str;
|
||||
delete [] pStr;
|
||||
}
|
||||
}
|
||||
|
||||
int installString(const char* p) { clear(); return set(p); }
|
||||
int installString(char* p) { clear(); return set(p); }
|
||||
void copy(const char* p) { clear(); cset(p); }
|
||||
void copy(char* p) { clear(); cset(p); }
|
||||
aitString& operator=(const char* p) { this->copy(p); return *this; }
|
||||
aitString& operator=(char* p) { this->copy(p); return *this; }
|
||||
|
||||
// take the aitString array, and put it and all the string into buf,
|
||||
// return the total length the data copied
|
||||
static aitUint32 totalLength(aitString* array,aitIndex arraySize);
|
||||
static aitUint32 stringsLength(aitString* array,aitIndex arraySize);
|
||||
static aitIndex compact(aitString* array, aitIndex arraySize,
|
||||
void* buf, aitIndex bufSize);
|
||||
|
||||
private:
|
||||
const char * str;
|
||||
aitUint16 len;
|
||||
aitUint16 type; // aitStrType goes here
|
||||
};
|
||||
|
||||
#endif // aitHelpersInclude
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Author: Jim Kowalkowski
|
||||
* Date: 2/96
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* $Log$
|
||||
* Revision 1.1 1996/05/31 13:15:21 jbk
|
||||
* add new stuff
|
||||
*
|
||||
*/
|
||||
|
||||
#define AIT_TYPES_SOURCE 1
|
||||
#include <sys/types.h>
|
||||
#include "aitTypes.h"
|
||||
|
||||
const size_t aitSize[aitTotal] = {
|
||||
0,
|
||||
sizeof(aitInt8),
|
||||
sizeof(aitUint8),
|
||||
sizeof(aitInt16),
|
||||
sizeof(aitUint16),
|
||||
sizeof(aitEnum16),
|
||||
sizeof(aitInt32),
|
||||
sizeof(aitUint32),
|
||||
sizeof(aitFloat32),
|
||||
sizeof(aitFloat64),
|
||||
sizeof(aitFixedString),
|
||||
sizeof(aitString),
|
||||
0
|
||||
};
|
||||
|
||||
const char* aitName[aitTotal] = {
|
||||
"aitInvalid",
|
||||
"aitInt8",
|
||||
"aitUint8",
|
||||
"aitInt16",
|
||||
"aitUint16",
|
||||
"aitEnum16",
|
||||
"aitInt32",
|
||||
"aitUint32",
|
||||
"aitFloat32",
|
||||
"aitFloat64",
|
||||
"aitFixedString",
|
||||
"aitString",
|
||||
"aitContainer"
|
||||
};
|
||||
|
||||
const char* aitStringType[aitTotal] = {
|
||||
"%8.8x",
|
||||
"%2.2x",
|
||||
"%2.2x",
|
||||
"%hd",
|
||||
"%hu",
|
||||
"%hu",
|
||||
"%d",
|
||||
"%u",
|
||||
"%f",
|
||||
"%lf",
|
||||
"%s",
|
||||
"%s",
|
||||
"%8.8x"
|
||||
};
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
#ifndef AIT_TYPES_H
|
||||
#define AIT_TYPES_H 1
|
||||
|
||||
/*
|
||||
* Author: Jim Kowalkowski
|
||||
* Date: 2/96
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* $Log$
|
||||
*
|
||||
* *Revision 1.2 1996/06/17 15:24:07 jbk
|
||||
* *many mods, string class corrections.
|
||||
* *gdd operator= protection.
|
||||
* *dbmapper uses aitString array for menus now
|
||||
* *Revision 1.1 1996/05/31 13:15:22 jbk
|
||||
* *add new stuff
|
||||
*
|
||||
*/
|
||||
|
||||
/* This is the file the user sets up for a given architecture */
|
||||
|
||||
#define AIT_FIXED_STRING_SIZE 40
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef char aitInt8;
|
||||
typedef unsigned char aitUint8;
|
||||
typedef short aitInt16;
|
||||
typedef unsigned short aitUint16;
|
||||
typedef aitUint16 aitEnum16;
|
||||
typedef int aitInt32;
|
||||
typedef unsigned int aitUint32;
|
||||
typedef float aitFloat32;
|
||||
typedef double aitFloat64;
|
||||
typedef aitUint32 aitIndex;
|
||||
typedef void* aitPointer;
|
||||
typedef aitUint32 aitStatus;
|
||||
|
||||
/* should the bool be added as a conversion type? it currently is not */
|
||||
typedef enum {
|
||||
aitFalse=0,
|
||||
aitTrue
|
||||
} aitBool;
|
||||
|
||||
typedef struct {
|
||||
char fixed_string[AIT_FIXED_STRING_SIZE];
|
||||
} aitFixedString;
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "aitHelpers.h"
|
||||
#else
|
||||
/* need time stamp structure different from posix unfortunetly */
|
||||
typedef struct {
|
||||
aitUint32 tv_sec;
|
||||
aitUint32 tv_nsec;
|
||||
} aitTimeStamp;
|
||||
|
||||
/* strings are a struct so they are different then aitInt8 */
|
||||
typedef struct {
|
||||
char* string;
|
||||
aitUint32 len;
|
||||
} aitString;
|
||||
#endif
|
||||
|
||||
/* all normal types */
|
||||
#define aitTotal 13
|
||||
#define aitFirst aitEnumInvalid
|
||||
#define aitLast aitEnumContainer
|
||||
#define aitValid(x) ((x)<=aitLast)
|
||||
|
||||
/* all conversion types */
|
||||
#define aitConvertTotal 11
|
||||
#define aitConvertFirst aitEnumInt8
|
||||
#define aitConvertLast aitEnumString
|
||||
#define aitConvertAutoFirst aitEnumInt8
|
||||
#define aitConvertAutoLast aitEnumFloat64
|
||||
#define aitConvertValid(x) ((x)>=aitConvertFirst && (x)<=aitConvertLast)
|
||||
|
||||
/* currently no 64-bit integer support */
|
||||
typedef enum {
|
||||
aitEnumInvalid=0,
|
||||
aitEnumInt8,
|
||||
aitEnumUint8,
|
||||
aitEnumInt16,
|
||||
aitEnumUint16,
|
||||
aitEnumEnum16,
|
||||
aitEnumInt32,
|
||||
aitEnumUint32,
|
||||
aitEnumFloat32,
|
||||
aitEnumFloat64,
|
||||
aitEnumFixedString,
|
||||
aitEnumString,
|
||||
aitEnumContainer
|
||||
} aitEnum;
|
||||
|
||||
typedef union {
|
||||
aitInt8 Int8;
|
||||
aitUint8 Uint8;
|
||||
aitInt16 Int16;
|
||||
aitUint16 Uint16;
|
||||
aitEnum16 Enum16;
|
||||
aitInt32 Int32;
|
||||
aitUint32 Uint32;
|
||||
aitFloat32 Float32;
|
||||
aitFloat64 Float64;
|
||||
aitIndex Index;
|
||||
aitPointer Pointer;
|
||||
aitFixedString* FString;
|
||||
aitUint8 Dumb1[sizeof(aitString)]; /* aitString String; */
|
||||
aitUint8 Dumb3[sizeof(aitTimeStamp)]; /* aitTimeStamp Stamp; */
|
||||
} aitType;
|
||||
|
||||
/*
|
||||
classes are not allowed in union that required construction/destruction
|
||||
so I am insuring that the size of aitType is large enough to hold
|
||||
strings and timestamps in an obsure, horrible way with the Dumb variables
|
||||
*/
|
||||
|
||||
#ifndef AIT_TYPES_SOURCE
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
extern const size_t aitSize[aitTotal];
|
||||
extern const char* aitName[aitTotal];
|
||||
extern const char* aitStringType[aitTotal];
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+1294
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,59 @@
|
||||
#ifndef DB_MAPPER_H
|
||||
#define DB_MAPPER_H
|
||||
|
||||
/*
|
||||
* Author: Jim Kowalkowski
|
||||
* Date: 2/96
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* $Log$
|
||||
*
|
||||
* *Revision 1.1 1996/05/31 13:15:24 jbk
|
||||
* *add new stuff
|
||||
*
|
||||
*/
|
||||
|
||||
#include "aitTypes.h"
|
||||
#include "gdd.h"
|
||||
|
||||
extern "C" {
|
||||
#include "db_access.h"
|
||||
#include "cadef.h"
|
||||
}
|
||||
|
||||
class gddApplicationTypeTable;
|
||||
|
||||
// Function proto to convert from a db_struct to a gdd. The gdd will
|
||||
// reference the data in the db_struct if the db_struct points to an
|
||||
// array. The second argument is the number of elements if db_struct
|
||||
// represents an array, or zero if the db_struct is a scaler.
|
||||
typedef gdd* (*to_gdd)(void* db_struct, aitIndex element_count);
|
||||
|
||||
// Function proto to convert from a gdd to a dbr structure, returns the
|
||||
// number of elements that the value field of db_struct points to if the
|
||||
// gdd points to an array. The db_struct will reference the data
|
||||
// contained within the gdd (which is probably also referenced from the user).
|
||||
typedef int (*to_dbr)(void* db_struct, gdd*);
|
||||
|
||||
struct gddDbrMapFuncTable {
|
||||
to_gdd conv_gdd;
|
||||
to_dbr conv_dbr;
|
||||
};
|
||||
typedef struct gddDbrMapFuncTable gddDbrMapFuncTable;
|
||||
|
||||
struct gddDbrToAitTable {
|
||||
aitEnum type;
|
||||
aitUint16 app;
|
||||
char* app_name;
|
||||
};
|
||||
typedef struct gddDbrToAitTable gddDbrToAitTable;
|
||||
|
||||
extern gddDbrToAitTable gddDbrToAit[];
|
||||
extern const chtype gddAitToDbr[];
|
||||
extern gddDbrMapFuncTable gddMapDbr[];
|
||||
void gddMakeMapDBR(gddApplicationTypeTable& tt);
|
||||
void gddMakeMapDBR(gddApplicationTypeTable* tt);
|
||||
|
||||
#endif
|
||||
|
||||
+1225
File diff suppressed because it is too large
Load Diff
+1145
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,253 @@
|
||||
// Author: Jim Kowalkowski
|
||||
// Date: 2/96
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// $Log$
|
||||
//
|
||||
|
||||
// *Revision 1.3 1996/06/24 03:15:34 jbk
|
||||
// *name changes and fixes for aitString and fixed string functions
|
||||
// *Revision 1.2 1996/06/17 15:24:11 jbk
|
||||
// *many mods, string class corrections.
|
||||
// *gdd operator= protection.
|
||||
// *dbmapper uses aitString array for menus now
|
||||
// *Revision 1.1 1996/05/31 13:15:26 jbk
|
||||
// *add new stuff
|
||||
|
||||
#include "gddAppTable.h"
|
||||
|
||||
static char* thing = "12345678";
|
||||
|
||||
// useless utility function
|
||||
gddApplicationTypeTable* gddGenerateApplicationTypeTable(long x/*=(1<<13)*/)
|
||||
{
|
||||
gddApplicationTypeTable* tt = new gddApplicationTypeTable((unsigned int)x);
|
||||
return tt;
|
||||
}
|
||||
|
||||
void gddApplicationTypeTable::GenerateTypes(void)
|
||||
{
|
||||
gddScaler* add_units = new gddScaler(0);
|
||||
gddAtomic* add_enum = new gddAtomic(0,aitEnumString,1,16);
|
||||
|
||||
aitString add_enum_buf[16];
|
||||
aitString add_units_buf = thing;
|
||||
|
||||
add_units->put(add_units_buf);
|
||||
add_enum->putRef(add_enum_buf);
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// register simple types
|
||||
|
||||
// should I allow a dd retrieved through the tag table to be adjusted
|
||||
// even though it is flattened? What if an array needs to change size
|
||||
|
||||
// or type in a flattened dd?
|
||||
|
||||
// value - filled by user no dd to register
|
||||
// units - variable length of array of chars
|
||||
|
||||
// not really required attributes - they are contained in DDs
|
||||
registerApplicationType(GDD_NAME_STATUS);
|
||||
registerApplicationType(GDD_NAME_SEVERITY);
|
||||
registerApplicationType(GDD_NAME_SECONDS);
|
||||
registerApplicationType(GDD_NAME_NANOSECONDS);
|
||||
|
||||
// required attributes
|
||||
int type_prec=registerApplicationType(GDD_NAME_PRECISION);
|
||||
int type_ghigh=registerApplicationType(GDD_NAME_GRAPH_HIGH);
|
||||
int type_glow=registerApplicationType(GDD_NAME_GRAPH_LOW);
|
||||
int type_chigh=registerApplicationType(GDD_NAME_CONTROL_HIGH);
|
||||
int type_clow=registerApplicationType(GDD_NAME_CONTROL_LOW);
|
||||
int type_ahigh=registerApplicationType(GDD_NAME_ALARM_HIGH);
|
||||
int type_alow=registerApplicationType(GDD_NAME_ALARM_LOW);
|
||||
int type_awhigh=registerApplicationType(GDD_NAME_ALARM_WARN_HIGH);
|
||||
int type_awlow=registerApplicationType(GDD_NAME_ALARM_WARN_LOW);
|
||||
int type_maxele=registerApplicationType(GDD_NAME_MAX_ELEMENTS);
|
||||
int type_value=registerApplicationType(GDD_NAME_VALUE);
|
||||
int type_units=registerApplicationTypeWithProto(GDD_NAME_UNITS,add_units);
|
||||
int type_menu=registerApplicationTypeWithProto(GDD_NAME_ENUM,add_enum);
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// register container types - not as easy
|
||||
|
||||
// container of all PV attributes
|
||||
gddContainer* cdd_attr=new gddContainer(1);
|
||||
cdd_attr->insert(getDD(type_prec));
|
||||
cdd_attr->insert(getDD(type_ghigh));
|
||||
cdd_attr->insert(getDD(type_glow));
|
||||
cdd_attr->insert(getDD(type_chigh));
|
||||
cdd_attr->insert(getDD(type_clow));
|
||||
cdd_attr->insert(getDD(type_ahigh));
|
||||
cdd_attr->insert(getDD(type_alow));
|
||||
cdd_attr->insert(getDD(type_awhigh));
|
||||
cdd_attr->insert(getDD(type_awlow));
|
||||
cdd_attr->insert(getDD(type_units));
|
||||
cdd_attr->insert(getDD(type_maxele));
|
||||
registerApplicationTypeWithProto(GDD_NAME_ATTRIBUTES,cdd_attr);
|
||||
|
||||
// container of everything about a PV
|
||||
gddContainer* cdd_all=new gddContainer(1);
|
||||
cdd_all->insert(getDD(type_prec));
|
||||
cdd_all->insert(getDD(type_ghigh));
|
||||
cdd_all->insert(getDD(type_glow));
|
||||
cdd_all->insert(getDD(type_chigh));
|
||||
cdd_all->insert(getDD(type_clow));
|
||||
cdd_all->insert(getDD(type_ahigh));
|
||||
cdd_all->insert(getDD(type_alow));
|
||||
cdd_all->insert(getDD(type_awhigh));
|
||||
cdd_all->insert(getDD(type_awlow));
|
||||
cdd_all->insert(getDD(type_units));
|
||||
cdd_all->insert(getDD(type_value));
|
||||
registerApplicationTypeWithProto(GDD_NAME_ALL,cdd_all);
|
||||
|
||||
// ------------- generate required dbr containers -----------------
|
||||
|
||||
// DBR_GR_SHORT
|
||||
gddContainer* cdd_gr_short=new gddContainer(0);
|
||||
cdd_gr_short->insert(new gddScaler(type_value,aitEnumInt16));
|
||||
cdd_gr_short->insert(new gddScaler(type_ghigh,aitEnumInt16));
|
||||
cdd_gr_short->insert(new gddScaler(type_glow,aitEnumInt16));
|
||||
cdd_gr_short->insert(new gddScaler(type_ahigh,aitEnumInt16));
|
||||
cdd_gr_short->insert(new gddScaler(type_alow,aitEnumInt16));
|
||||
cdd_gr_short->insert(new gddScaler(type_awhigh,aitEnumInt16));
|
||||
cdd_gr_short->insert(new gddScaler(type_awlow,aitEnumInt16));
|
||||
cdd_gr_short->insert(getDD(type_units));
|
||||
registerApplicationTypeWithProto("dbr_gr_short",cdd_gr_short);
|
||||
|
||||
// DBR_GR_FLOAT
|
||||
gddContainer* cdd_gr_float=new gddContainer(0);
|
||||
cdd_gr_float->insert(new gddScaler(type_value,aitEnumFloat32));
|
||||
cdd_gr_float->insert(new gddScaler(type_prec,aitEnumInt16));
|
||||
cdd_gr_float->insert(new gddScaler(type_ghigh,aitEnumFloat32));
|
||||
cdd_gr_float->insert(new gddScaler(type_glow,aitEnumFloat32));
|
||||
cdd_gr_float->insert(new gddScaler(type_ahigh,aitEnumFloat32));
|
||||
cdd_gr_float->insert(new gddScaler(type_alow,aitEnumFloat32));
|
||||
cdd_gr_float->insert(new gddScaler(type_awhigh,aitEnumFloat32));
|
||||
cdd_gr_float->insert(new gddScaler(type_awlow,aitEnumFloat32));
|
||||
cdd_gr_float->insert(getDD(type_units));
|
||||
registerApplicationTypeWithProto("dbr_gr_float",cdd_gr_float);
|
||||
|
||||
// DBR_GR_ENUM
|
||||
gddContainer* cdd_gr_enum=new gddContainer(0);
|
||||
cdd_gr_enum->insert(getDD(type_menu));
|
||||
cdd_gr_enum->insert(new gddScaler(type_value,aitEnumEnum16));
|
||||
registerApplicationTypeWithProto("dbr_gr_enum",cdd_gr_enum);
|
||||
|
||||
// DBR_GR_CHAR
|
||||
gddContainer* cdd_gr_char=new gddContainer(0);
|
||||
cdd_gr_char->insert(new gddScaler(type_value,aitEnumInt8));
|
||||
cdd_gr_char->insert(new gddScaler(type_ghigh,aitEnumInt8));
|
||||
cdd_gr_char->insert(new gddScaler(type_glow,aitEnumInt8));
|
||||
cdd_gr_char->insert(new gddScaler(type_ahigh,aitEnumInt8));
|
||||
cdd_gr_char->insert(new gddScaler(type_alow,aitEnumInt8));
|
||||
cdd_gr_char->insert(new gddScaler(type_awhigh,aitEnumInt8));
|
||||
cdd_gr_char->insert(new gddScaler(type_awlow,aitEnumInt8));
|
||||
cdd_gr_char->insert(getDD(type_units));
|
||||
registerApplicationTypeWithProto("dbr_gr_char",cdd_gr_char);
|
||||
|
||||
// DBR_GR_LONG
|
||||
gddContainer* cdd_gr_long=new gddContainer(0);
|
||||
cdd_gr_long->insert(new gddScaler(type_value,aitEnumInt32));
|
||||
cdd_gr_long->insert(new gddScaler(type_ghigh,aitEnumInt32));
|
||||
cdd_gr_long->insert(new gddScaler(type_glow,aitEnumInt32));
|
||||
cdd_gr_long->insert(new gddScaler(type_ahigh,aitEnumInt32));
|
||||
cdd_gr_long->insert(new gddScaler(type_alow,aitEnumInt32));
|
||||
cdd_gr_long->insert(new gddScaler(type_awhigh,aitEnumInt32));
|
||||
cdd_gr_long->insert(new gddScaler(type_awlow,aitEnumInt32));
|
||||
cdd_gr_long->insert(getDD(type_units));
|
||||
registerApplicationTypeWithProto("dbr_gr_long",cdd_gr_long);
|
||||
|
||||
// DBR_GR_DOUBLE
|
||||
gddContainer* cdd_gr_double=new gddContainer(0);
|
||||
cdd_gr_double->insert(new gddScaler(type_value,aitEnumFloat64));
|
||||
cdd_gr_double->insert(new gddScaler(type_prec,aitEnumInt16));
|
||||
cdd_gr_double->insert(new gddScaler(type_ghigh,aitEnumFloat64));
|
||||
cdd_gr_double->insert(new gddScaler(type_glow,aitEnumFloat64));
|
||||
cdd_gr_double->insert(new gddScaler(type_ahigh,aitEnumFloat64));
|
||||
cdd_gr_double->insert(new gddScaler(type_alow,aitEnumFloat64));
|
||||
cdd_gr_double->insert(new gddScaler(type_awhigh,aitEnumFloat64));
|
||||
cdd_gr_double->insert(new gddScaler(type_awlow,aitEnumFloat64));
|
||||
cdd_gr_double->insert(getDD(type_units));
|
||||
registerApplicationTypeWithProto("dbr_gr_double",cdd_gr_double);
|
||||
|
||||
// DBR_CTRL_SHORT
|
||||
gddContainer* cdd_ctrl_short=new gddContainer(0);
|
||||
cdd_ctrl_short->insert(new gddScaler(type_value,aitEnumInt16));
|
||||
cdd_ctrl_short->insert(new gddScaler(type_ghigh,aitEnumInt16));
|
||||
cdd_ctrl_short->insert(new gddScaler(type_glow,aitEnumInt16));
|
||||
cdd_ctrl_short->insert(new gddScaler(type_chigh,aitEnumInt16));
|
||||
cdd_ctrl_short->insert(new gddScaler(type_clow,aitEnumInt16));
|
||||
cdd_ctrl_short->insert(new gddScaler(type_ahigh,aitEnumInt16));
|
||||
cdd_ctrl_short->insert(new gddScaler(type_alow,aitEnumInt16));
|
||||
cdd_ctrl_short->insert(new gddScaler(type_awhigh,aitEnumInt16));
|
||||
cdd_ctrl_short->insert(new gddScaler(type_awlow,aitEnumInt16));
|
||||
cdd_ctrl_short->insert(getDD(type_units));
|
||||
registerApplicationTypeWithProto("dbr_ctrl_short",cdd_ctrl_short);
|
||||
|
||||
// DBR_CTRL_FLOAT
|
||||
gddContainer* cdd_ctrl_float=new gddContainer(0);
|
||||
cdd_ctrl_float->insert(new gddScaler(type_value,aitEnumFloat32));
|
||||
cdd_ctrl_float->insert(new gddScaler(type_prec,aitEnumInt16));
|
||||
cdd_ctrl_float->insert(new gddScaler(type_ghigh,aitEnumFloat32));
|
||||
cdd_ctrl_float->insert(new gddScaler(type_glow,aitEnumFloat32));
|
||||
cdd_ctrl_float->insert(new gddScaler(type_chigh,aitEnumFloat32));
|
||||
cdd_ctrl_float->insert(new gddScaler(type_clow,aitEnumFloat32));
|
||||
cdd_ctrl_float->insert(new gddScaler(type_ahigh,aitEnumFloat32));
|
||||
cdd_ctrl_float->insert(new gddScaler(type_alow,aitEnumFloat32));
|
||||
cdd_ctrl_float->insert(new gddScaler(type_awhigh,aitEnumFloat32));
|
||||
cdd_ctrl_float->insert(new gddScaler(type_awlow,aitEnumFloat32));
|
||||
cdd_ctrl_float->insert(getDD(type_units));
|
||||
registerApplicationTypeWithProto("dbr_ctrl_float",cdd_ctrl_float);
|
||||
|
||||
// DBR_CTRL_ENUM
|
||||
gddContainer* cdd_ctrl_enum=new gddContainer(0);
|
||||
cdd_ctrl_enum->insert(getDD(type_menu));
|
||||
cdd_ctrl_enum->insert(new gddScaler(type_value,aitEnumEnum16));
|
||||
registerApplicationTypeWithProto("dbr_ctrl_enum",cdd_ctrl_enum);
|
||||
|
||||
// DBR_CTRL_CHAR
|
||||
gddContainer* cdd_ctrl_char=new gddContainer(0);
|
||||
cdd_ctrl_char->insert(new gddScaler(type_value,aitEnumInt8));
|
||||
cdd_ctrl_char->insert(new gddScaler(type_ghigh,aitEnumInt8));
|
||||
cdd_ctrl_char->insert(new gddScaler(type_glow,aitEnumInt8));
|
||||
cdd_ctrl_char->insert(new gddScaler(type_chigh,aitEnumInt8));
|
||||
cdd_ctrl_char->insert(new gddScaler(type_clow,aitEnumInt8));
|
||||
cdd_ctrl_char->insert(new gddScaler(type_ahigh,aitEnumInt8));
|
||||
cdd_ctrl_char->insert(new gddScaler(type_alow,aitEnumInt8));
|
||||
cdd_ctrl_char->insert(new gddScaler(type_awhigh,aitEnumInt8));
|
||||
cdd_ctrl_char->insert(new gddScaler(type_awlow,aitEnumInt8));
|
||||
cdd_ctrl_char->insert(getDD(type_units));
|
||||
registerApplicationTypeWithProto("dbr_ctrl_char",cdd_ctrl_char);
|
||||
|
||||
// DBR_CTRL_LONG
|
||||
gddContainer* cdd_ctrl_long=new gddContainer(0);
|
||||
cdd_ctrl_long->insert(new gddScaler(type_value,aitEnumInt32));
|
||||
cdd_ctrl_long->insert(new gddScaler(type_ghigh,aitEnumInt32));
|
||||
cdd_ctrl_long->insert(new gddScaler(type_glow,aitEnumInt32));
|
||||
cdd_ctrl_long->insert(new gddScaler(type_chigh,aitEnumInt32));
|
||||
cdd_ctrl_long->insert(new gddScaler(type_clow,aitEnumInt32));
|
||||
cdd_ctrl_long->insert(new gddScaler(type_ahigh,aitEnumInt32));
|
||||
cdd_ctrl_long->insert(new gddScaler(type_alow,aitEnumInt32));
|
||||
cdd_ctrl_long->insert(new gddScaler(type_awhigh,aitEnumInt32));
|
||||
cdd_ctrl_long->insert(new gddScaler(type_awlow,aitEnumInt32));
|
||||
cdd_ctrl_long->insert(getDD(type_units));
|
||||
registerApplicationTypeWithProto("dbr_ctrl_long",cdd_ctrl_long);
|
||||
|
||||
// DBR_CTRL_DOUBLE
|
||||
gddContainer* cdd_ctrl_double=new gddContainer(0);
|
||||
cdd_ctrl_double->insert(new gddScaler(type_value,aitEnumFloat64));
|
||||
cdd_ctrl_double->insert(new gddScaler(type_prec,aitEnumInt16));
|
||||
cdd_ctrl_double->insert(new gddScaler(type_ghigh,aitEnumFloat64));
|
||||
cdd_ctrl_double->insert(new gddScaler(type_glow,aitEnumFloat64));
|
||||
cdd_ctrl_double->insert(new gddScaler(type_chigh,aitEnumFloat64));
|
||||
cdd_ctrl_double->insert(new gddScaler(type_clow,aitEnumFloat64));
|
||||
cdd_ctrl_double->insert(new gddScaler(type_ahigh,aitEnumFloat64));
|
||||
cdd_ctrl_double->insert(new gddScaler(type_alow,aitEnumFloat64));
|
||||
cdd_ctrl_double->insert(new gddScaler(type_awhigh,aitEnumFloat64));
|
||||
cdd_ctrl_double->insert(new gddScaler(type_awlow,aitEnumFloat64));
|
||||
cdd_ctrl_double->insert(getDD(type_units));
|
||||
registerApplicationTypeWithProto("dbr_ctrl_double",cdd_ctrl_double);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,528 @@
|
||||
// Author: Jim Kowalkowski
|
||||
// Date: 2/96
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// $Log$
|
||||
|
||||
// *Revision 1.3 1996/06/24 03:15:35 jbk
|
||||
// *name changes and fixes for aitString and fixed string functions
|
||||
// *Revision 1.2 1996/06/13 21:31:57 jbk
|
||||
// *Various fixes and correction - including ref_cnt change to unsigned short
|
||||
// *Revision 1.1 1996/05/31 13:15:27 jbk
|
||||
// *add new stuff
|
||||
|
||||
#include "gddAppTable.h"
|
||||
|
||||
// -----------------general destructor for managed gdds--------------------
|
||||
|
||||
void gddApplicationTypeDestructor::run(void* v)
|
||||
{
|
||||
gdd* ec = (gdd*)v;
|
||||
// fprintf(stderr," destructing %8.8x\n",v);
|
||||
gddApplicationTypeTable* db = (gddApplicationTypeTable*)arg;
|
||||
db->freeDD(ec);
|
||||
}
|
||||
|
||||
gddApplicationTypeElement::gddApplicationTypeElement(void) { }
|
||||
gddApplicationTypeElement::~gddApplicationTypeElement(void) { }
|
||||
|
||||
// --------------------------app table stuff-----------------------------
|
||||
|
||||
gddApplicationTypeTable gddApplicationTypeTable::app_table;
|
||||
|
||||
gddApplicationTypeTable& gddApplicationTypeTable::AppTable(void)
|
||||
{
|
||||
return gddApplicationTypeTable::app_table;
|
||||
}
|
||||
|
||||
gddApplicationTypeTable::gddApplicationTypeTable(aitUint32 tot)
|
||||
{
|
||||
aitUint32 i,total;
|
||||
|
||||
// round tot up to nearest power of 2
|
||||
for(i=1<<31;i && !(tot&i);i>>=1);
|
||||
if(i==0)
|
||||
total=1;
|
||||
else if(i==tot)
|
||||
total=tot;
|
||||
else
|
||||
total=i<<1;
|
||||
|
||||
max_groups=total/APPLTABLE_GROUP_SIZE;
|
||||
if((max_groups*APPLTABLE_GROUP_SIZE) != total) ++max_groups;
|
||||
max_allowed=total;
|
||||
total_registered=1;
|
||||
attr_table=new gddApplicationTypeElement*[max_groups];
|
||||
|
||||
for(i=0;i<max_groups;i++) attr_table[i]=NULL;
|
||||
GenerateTypes();
|
||||
}
|
||||
|
||||
#if 0
|
||||
void* operator new(size_t x)
|
||||
{
|
||||
void* v = (void*)malloc(x);
|
||||
fprintf(stderr,"%8.8x In operator new %d\n",v,(int)x);
|
||||
return v;
|
||||
}
|
||||
|
||||
void operator delete(void* x)
|
||||
{
|
||||
fprintf(stderr,"%8.8x In operator delete\n",x);
|
||||
free((char*)x);
|
||||
}
|
||||
#endif
|
||||
|
||||
gddApplicationTypeTable::~gddApplicationTypeTable(void)
|
||||
{
|
||||
int i,j;
|
||||
gdd* dd;
|
||||
aitUint8* blk;
|
||||
|
||||
// fprintf(stderr,"in gddApplicationTypeTable dest\n");
|
||||
|
||||
if(this!=&app_table) return;
|
||||
|
||||
for(i=0;i<max_groups;i++)
|
||||
{
|
||||
if(attr_table[i])
|
||||
{
|
||||
// fprintf(stderr,"Delete TypeTable: group %d exists\n",i);
|
||||
for(j=0;j<APPLTABLE_GROUP_SIZE;j++)
|
||||
{
|
||||
switch(attr_table[i][j].type)
|
||||
{
|
||||
case gddApplicationTypeNormal:
|
||||
// fprintf(stderr,"Delete TypeTable: app %d normal\n",j);
|
||||
if(attr_table[i][j].app_name)
|
||||
delete [] attr_table[i][j].app_name;
|
||||
break;
|
||||
case gddApplicationTypeProto:
|
||||
// fprintf(stderr,"Delete TypeTable: app %d has proto\n",j);
|
||||
if(attr_table[i][j].app_name)
|
||||
delete [] attr_table[i][j].app_name;
|
||||
|
||||
if(attr_table[i][j].proto)
|
||||
{
|
||||
// if(attr_table[i][j].free_list)
|
||||
// fprintf(stderr," app %d has free_list\n",j);
|
||||
|
||||
// The proto is stored as flattened gdd
|
||||
blk=(aitUint8*)attr_table[i][j].proto;
|
||||
delete [] blk;
|
||||
|
||||
for(dd=attr_table[i][j].free_list; dd;)
|
||||
{
|
||||
blk=(aitUint8*)dd;
|
||||
// fprintf(stderr," delete dd %8.8x\n",blk);
|
||||
dd=(gdd*)dd->next();
|
||||
delete [] blk;
|
||||
}
|
||||
}
|
||||
|
||||
if(attr_table[i][j].map)
|
||||
delete [] attr_table[i][j].map;
|
||||
break;
|
||||
case gddApplicationTypeUndefined: break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
delete [] attr_table[i];
|
||||
}
|
||||
}
|
||||
delete [] attr_table;
|
||||
}
|
||||
|
||||
int gddApplicationTypeTable::describeDD(gddContainer* dd, FILE* fd,
|
||||
int level, char* tn)
|
||||
{
|
||||
gddCursor cur = dd->getCursor();
|
||||
gdd* pdd;
|
||||
char tmp[8];
|
||||
char* cp;
|
||||
char* str;
|
||||
|
||||
strcpy(tmp,"unknown");
|
||||
|
||||
for(pdd=cur.first();pdd;pdd=pdd->next())
|
||||
{
|
||||
if((cp=getName(pdd->applicationType()))==NULL) cp=tmp;
|
||||
fprintf(fd,"#define gddAppTypeIndex_%s_%s %d\n",tn,cp,level++);
|
||||
}
|
||||
|
||||
for(pdd=cur.first();pdd;pdd=pdd->next())
|
||||
{
|
||||
if((cp=getName(pdd->applicationType()))==NULL) cp=tmp;
|
||||
if(pdd->isContainer())
|
||||
{
|
||||
str = new char[strlen(cp)+strlen(tn)+3];
|
||||
strcpy(str,tn);
|
||||
strcat(str,"_");
|
||||
strcat(str,cp);
|
||||
level=describeDD((gddContainer*)pdd,fd,level,str);
|
||||
delete [] str;
|
||||
}
|
||||
}
|
||||
return level;
|
||||
}
|
||||
|
||||
void gddApplicationTypeTable::describe(FILE* fd)
|
||||
{
|
||||
int i,j;
|
||||
gdd* dd;
|
||||
char* tn;
|
||||
|
||||
fprintf(fd,"\n");
|
||||
for(i=0;i<max_groups;i++)
|
||||
{
|
||||
if(attr_table[i])
|
||||
{
|
||||
for(j=0;j<APPLTABLE_GROUP_SIZE;j++)
|
||||
{
|
||||
switch(attr_table[i][j].type)
|
||||
{
|
||||
case gddApplicationTypeNormal:
|
||||
case gddApplicationTypeProto:
|
||||
tn=attr_table[i][j].app_name;
|
||||
fprintf(fd,"#define gddAppType_%s\t%d\n",
|
||||
tn,i*APPLTABLE_GROUP_SIZE+j);
|
||||
|
||||
if(dd=attr_table[i][j].proto)
|
||||
{
|
||||
fprintf(fd,"#define gddAppTypeIndex_%s 0\n",tn);
|
||||
if(dd->isContainer())
|
||||
describeDD((gddContainer*)dd,fd,1,tn);
|
||||
// fprintf(fd,"\n");
|
||||
}
|
||||
break;
|
||||
case gddApplicationTypeUndefined: break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fprintf(fd,"\n");
|
||||
}
|
||||
|
||||
gddStatus gddApplicationTypeTable::registerApplicationType(
|
||||
const char* const name,aitUint32& new_app)
|
||||
{
|
||||
aitUint32 i,group,app,rapp;
|
||||
gddStatus rc;
|
||||
|
||||
if(new_app=getApplicationType(name))
|
||||
return gddErrorAlreadyDefined;
|
||||
if(total_registered>max_allowed)
|
||||
return gddErrorAtLimit;
|
||||
|
||||
sem.take();
|
||||
rapp=total_registered++;
|
||||
sem.give();
|
||||
|
||||
if((rc=splitApplicationType(rapp,group,app))<0) return rc;
|
||||
|
||||
if(attr_table[group])
|
||||
{
|
||||
// group already allocated - check is app already refined
|
||||
if(attr_table[group][app].type!=gddApplicationTypeUndefined)
|
||||
return gddErrorAlreadyDefined;
|
||||
}
|
||||
else
|
||||
{
|
||||
// group must be allocated
|
||||
attr_table[group]=new gddApplicationTypeElement[APPLTABLE_GROUP_SIZE];
|
||||
|
||||
// initialize each element of the group as undefined
|
||||
for(i=0;i<APPLTABLE_GROUP_SIZE;i++)
|
||||
{
|
||||
attr_table[group][i].type=gddApplicationTypeUndefined;
|
||||
attr_table[group][i].map=NULL;
|
||||
}
|
||||
}
|
||||
|
||||
attr_table[group][app].app_name=strdup(name);
|
||||
attr_table[group][app].type=gddApplicationTypeNormal;
|
||||
attr_table[group][app].proto=NULL;
|
||||
attr_table[group][app].free_list=NULL;
|
||||
|
||||
new_app=rapp;
|
||||
// fprintf(stderr,"registered <%s> %d\n",name,(int)new_app);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// registering a prototype of an empty container causes problems.
|
||||
// The current implementation does not monitor this so the container
|
||||
// is not cleared when free. A user may, however, include an empty
|
||||
// container within a prototype container, and everything will work
|
||||
// correctly.
|
||||
|
||||
gddStatus gddApplicationTypeTable::registerApplicationTypeWithProto(
|
||||
const char* const name, gdd* protoDD, aitUint32& new_app)
|
||||
{
|
||||
aitUint32 group,app,rapp;
|
||||
aitUint8* blk;
|
||||
size_t sz;
|
||||
aitIndex tot;
|
||||
int i;
|
||||
gddStatus rc;
|
||||
|
||||
if(rc=registerApplicationType(name,new_app)) return rc;
|
||||
|
||||
rapp=new_app;
|
||||
protoDD->setApplType(rapp);
|
||||
splitApplicationType(rapp,group,app);
|
||||
|
||||
// user gives me the protoDD, so I should not need to reference it.
|
||||
// Warning, it the user does unreference() on it unknowningly, it will
|
||||
// go away and cause big problems
|
||||
|
||||
// make sure that the currently registered destructor gets called
|
||||
// before setting the new one, this should occur in protoDD.
|
||||
|
||||
// be sure to copy data from DD and create buffer that can be copied
|
||||
// easily when user asks for a DD with proto
|
||||
|
||||
// important!! put destructor into each managed DD - what if atomic?
|
||||
// protoDD->registerDestructor(new gddApplicationTypeDestructor(protoDD));
|
||||
|
||||
sz=protoDD->getTotalSizeBytes();
|
||||
blk=new aitUint8[sz];
|
||||
protoDD->flattenWithAddress(blk,sz,&tot);
|
||||
attr_table[group][app].proto_size=sz;
|
||||
attr_table[group][app].total_dds=tot;
|
||||
protoDD->unreference();
|
||||
|
||||
attr_table[group][app].type=gddApplicationTypeProto;
|
||||
attr_table[group][app].proto=(gdd*)blk;
|
||||
attr_table[group][app].free_list=NULL;
|
||||
|
||||
// create the stupid mapping table - bad implementation for now
|
||||
attr_table[group][app].map=new aitUint16[total_registered];
|
||||
attr_table[group][app].map_size=total_registered;
|
||||
for(i=0;i<total_registered;i++) attr_table[group][app].map[i]=0;
|
||||
for(i=0;i<tot;i++)
|
||||
attr_table[group][app].map[attr_table[group][app].proto[i].applicationType()]=i;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
aitUint32 gddApplicationTypeTable::getApplicationType(const char* const name) const
|
||||
{
|
||||
int i,j,rc;
|
||||
|
||||
for(i=0,rc=0;i<max_groups && attr_table[i] && rc==0;i++)
|
||||
{
|
||||
for(j=0; j<APPLTABLE_GROUP_SIZE && rc==0; j++)
|
||||
{
|
||||
if(attr_table[i][j].type!=gddApplicationTypeUndefined &&
|
||||
strcmp(name,attr_table[i][j].app_name)==0)
|
||||
rc=APPLTABLE_GROUP_SIZE*i+j;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
char* gddApplicationTypeTable::getName(aitUint32 rapp) const
|
||||
{
|
||||
aitUint32 group,app;
|
||||
|
||||
if(splitApplicationType(rapp,group,app)<0) return NULL;
|
||||
if(!attr_table[group]) return NULL;
|
||||
if(attr_table[group][app].type==gddApplicationTypeUndefined) return NULL;
|
||||
|
||||
return attr_table[group][app].app_name;
|
||||
}
|
||||
|
||||
gddStatus gddApplicationTypeTable::mapAppToIndex(
|
||||
aitUint32 c_app, aitUint32 m_app, aitUint32& x)
|
||||
{
|
||||
aitUint32 group,app;
|
||||
gddStatus rc;
|
||||
|
||||
if((rc=splitApplicationType(c_app,group,app))<0) return rc;
|
||||
|
||||
if(attr_table[group][app].map && m_app<attr_table[group][app].map_size)
|
||||
{
|
||||
x=attr_table[group][app].map[m_app];
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return gddErrorOutOfBounds;
|
||||
}
|
||||
|
||||
gdd* gddApplicationTypeTable::getDD(aitUint32 rapp)
|
||||
{
|
||||
gdd* dd=NULL;
|
||||
aitUint32 group,app;
|
||||
aitUint8* blk;
|
||||
|
||||
if(splitApplicationType(rapp,group,app)<0) return NULL;
|
||||
|
||||
switch(attr_table[group][app].type)
|
||||
{
|
||||
case gddApplicationTypeProto:
|
||||
attr_table[group][app].sem.take();
|
||||
if(dd=attr_table[group][app].free_list)
|
||||
{
|
||||
//fprintf(stderr,"Popping a proto DD from list! %d %8.8x\n",app,dd);
|
||||
attr_table[group][app].free_list=dd->next();
|
||||
attr_table[group][app].sem.give();
|
||||
}
|
||||
else
|
||||
{
|
||||
attr_table[group][app].sem.give();
|
||||
// copy the prototype
|
||||
blk=new aitUint8[attr_table[group][app].proto_size];
|
||||
// fprintf(stderr,"Creating a new proto DD! %d %8.8x\n",app,blk);
|
||||
attr_table[group][app].proto->flattenWithAddress(blk,
|
||||
attr_table[group][app].proto_size);
|
||||
dd=(gdd*)blk;
|
||||
}
|
||||
dd->registerDestructor(new gddApplicationTypeDestructor(this));
|
||||
dd->markManaged(); // must be sure to mark the thing as managed!
|
||||
break;
|
||||
case gddApplicationTypeNormal:
|
||||
dd=new gdd(app);
|
||||
// fprintf(stderr,"Creating a new normal DD! %d\n",app);
|
||||
break;
|
||||
case gddApplicationTypeUndefined: dd=NULL; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
return dd;
|
||||
}
|
||||
|
||||
gddStatus gddApplicationTypeTable::freeDD(gdd* dd)
|
||||
{
|
||||
aitUint32 group,app,i;
|
||||
gddStatus rc;
|
||||
|
||||
if((rc=splitApplicationType(dd->applicationType(),group,app))<0) return rc;
|
||||
|
||||
if(attr_table[group][app].type==gddApplicationTypeProto)
|
||||
{
|
||||
// this can be time consuming, clear out all user data from the DD
|
||||
// this is done because we are allowed to register atomic protos
|
||||
// that user can attach data to - which causes problems because
|
||||
// the actual structure of the DD is unknown
|
||||
for(i=1;i<attr_table[group][app].total_dds;i++)
|
||||
dd[i].destroyData();
|
||||
|
||||
// fprintf(stderr,"Adding DD to free_list %d\n",app);
|
||||
dd->setNext(attr_table[group][app].free_list);
|
||||
attr_table[group][app].free_list=dd;
|
||||
}
|
||||
else
|
||||
{
|
||||
// fprintf(stderr,"freeDD a normal DD\n");
|
||||
dd->unreference();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
gddStatus gddApplicationTypeTable::storeValue(aitUint32 ap, aitUint32 uv)
|
||||
{
|
||||
aitUint32 group,app;
|
||||
gddStatus rc;
|
||||
|
||||
if((rc=splitApplicationType(ap,group,app))<0) return rc;
|
||||
if(attr_table[group]==NULL ||
|
||||
attr_table[group][app].type==gddApplicationTypeUndefined)
|
||||
return gddErrorNotDefined;
|
||||
|
||||
attr_table[group][app].user_value=uv;
|
||||
return 0;
|
||||
}
|
||||
|
||||
aitUint32 gddApplicationTypeTable::getValue(aitUint32 ap)
|
||||
{
|
||||
aitUint32 group,app;
|
||||
if(splitApplicationType(ap,group,app)<0) return 0;
|
||||
if(attr_table[group]==NULL ||
|
||||
attr_table[group][app].type==gddApplicationTypeUndefined)
|
||||
return 0;
|
||||
|
||||
return attr_table[group][app].user_value;
|
||||
}
|
||||
|
||||
// the source in the container we must walk through is this called
|
||||
gddStatus gddApplicationTypeTable::copyDD_src(gdd* dest, gdd* src)
|
||||
{
|
||||
gddStatus rc=0;
|
||||
gddStatus s;
|
||||
gddContainer* cdd;
|
||||
gddCursor cur;
|
||||
gdd* dd;
|
||||
aitIndex index;
|
||||
|
||||
// this could be done better (faster) if we did not always recurse for
|
||||
// each GDD. I could have checked for type container before recursing.
|
||||
|
||||
if(src->isContainer())
|
||||
{
|
||||
// go through src gdd and map app types to index into dest
|
||||
cdd=(gddContainer*)src;
|
||||
cur=cdd->getCursor();
|
||||
|
||||
for(dd=cur.first();dd;dd=dd->next()) copyDD_src(dest,dd);
|
||||
}
|
||||
else
|
||||
{
|
||||
// find src gdd in dest container and just do put()
|
||||
s=mapAppToIndex(dest->applicationType(),
|
||||
src->applicationType(),index);
|
||||
|
||||
if(s==0)
|
||||
rc=dest[index].put(src);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
// the destination in the container we must walk through is this called
|
||||
gddStatus gddApplicationTypeTable::copyDD_dest(gdd* dest, gdd* src)
|
||||
{
|
||||
gddStatus rc=0;
|
||||
gddStatus s;
|
||||
gddContainer* cdd;
|
||||
gddCursor cur;
|
||||
gdd* dd;
|
||||
aitIndex index;
|
||||
|
||||
if(dest->isContainer())
|
||||
{
|
||||
// go through dest gdd and map app types to index into src
|
||||
cdd=(gddContainer*)dest;
|
||||
cur=cdd->getCursor();
|
||||
|
||||
for(dd=cur.first();dd;dd=dd->next()) copyDD_dest(dd,src);
|
||||
}
|
||||
else
|
||||
{
|
||||
// find dest gdd in src container and just do put()
|
||||
s=mapAppToIndex(src->applicationType(),
|
||||
dest->applicationType(),index);
|
||||
|
||||
if(s==0)
|
||||
rc=dest->put(&src[index]);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
gddStatus gddApplicationTypeTable::smartCopy(gdd* dest, gdd* src)
|
||||
{
|
||||
gddStatus rc=0;
|
||||
|
||||
if(dest->isContainer() && dest->isManaged())
|
||||
rc=copyDD_src(dest,src);
|
||||
else if(src->isContainer() && src->isManaged())
|
||||
rc=copyDD_dest(dest,src);
|
||||
else if(!src->isContainer() && !dest->isContainer())
|
||||
rc=dest->put(src); // both are not containers, let gdd handle it
|
||||
else
|
||||
rc=gddErrorNotAllowed;
|
||||
|
||||
return rc;
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
#ifndef GDD_APPLTYPE_TABLE_H
|
||||
#define GDD_APPLTYPE_TABLE_H
|
||||
|
||||
/*
|
||||
* Author: Jim Kowalkowski
|
||||
* Date: 2/96
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* $Log$
|
||||
*
|
||||
* *Revision 1.3 1996/06/24 03:15:36 jbk
|
||||
* *name changes and fixes for aitString and fixed string functions
|
||||
* *Revision 1.2 1996/06/13 21:31:58 jbk
|
||||
* *Various fixes and correction - including ref_cnt change to unsigned short
|
||||
* *Revision 1.1 1996/05/31 13:15:29 jbk
|
||||
* *add new stuff
|
||||
*
|
||||
*/
|
||||
|
||||
#include "gdd.h"
|
||||
#include "gddUtils.h"
|
||||
#include <stdio.h>
|
||||
|
||||
// must be power of 2 for group size
|
||||
#define APPLTABLE_GROUP_SIZE 64
|
||||
#define APPLTABLE_GROUP_SIZE_POW 6
|
||||
|
||||
// default set of application type names
|
||||
#define GDD_UNITS_SIZE 8
|
||||
#define GDD_NAME_UNITS "units"
|
||||
#define GDD_NAME_MAX_ELEMENTS "maxElements"
|
||||
#define GDD_NAME_PRECISION "precision"
|
||||
#define GDD_NAME_GRAPH_HIGH "graphicHigh"
|
||||
#define GDD_NAME_GRAPH_LOW "graphicLow"
|
||||
#define GDD_NAME_CONTROL_HIGH "controlHigh"
|
||||
#define GDD_NAME_CONTROL_LOW "controlLow"
|
||||
#define GDD_NAME_ALARM_HIGH "alarmHigh"
|
||||
#define GDD_NAME_ALARM_LOW "alarmLow"
|
||||
#define GDD_NAME_ALARM_WARN_HIGH "alarmHighWarning"
|
||||
#define GDD_NAME_ALARM_WARN_LOW "alarmLowWarning"
|
||||
#define GDD_NAME_VALUE "value"
|
||||
#define GDD_NAME_ENUM "enums"
|
||||
#define GDD_NAME_MENUITEM "menuitem"
|
||||
#define GDD_NAME_STATUS "status"
|
||||
#define GDD_NAME_SEVERITY "severity"
|
||||
#define GDD_NAME_SECONDS "seconds"
|
||||
#define GDD_NAME_NANOSECONDS "nanoseconds"
|
||||
#define GDD_NAME_ALL "all"
|
||||
#define GDD_NAME_ATTRIBUTES "attributes"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
gddApplicationTypeUndefined,
|
||||
gddApplicationTypeProto,
|
||||
gddApplicationTypeNormal
|
||||
} gddApplicationTypeType;
|
||||
|
||||
class gddApplicationTypeTable;
|
||||
|
||||
class gddApplicationTypeDestructor : public gddDestructor
|
||||
{
|
||||
public:
|
||||
gddApplicationTypeDestructor(gddApplicationTypeTable* v) : gddDestructor(v) { }
|
||||
void run(void*);
|
||||
};
|
||||
|
||||
class gddApplicationTypeElement
|
||||
{
|
||||
public:
|
||||
gddApplicationTypeElement(void);
|
||||
~gddApplicationTypeElement(void);
|
||||
|
||||
char* app_name;
|
||||
size_t proto_size;
|
||||
aitIndex total_dds;
|
||||
gdd* proto;
|
||||
gdd* free_list;
|
||||
gddSemaphore sem;
|
||||
gddApplicationTypeType type;
|
||||
aitUint32 user_value;
|
||||
aitUint16* map;
|
||||
aitUint16 map_size;
|
||||
};
|
||||
|
||||
// The app table allows registering a prototype DD for app. This class
|
||||
// allows the user to ask for a DD given a app. The class will manage
|
||||
// a free list of DD buffers if the app has a prototype DD
|
||||
// associated with it. The gddApplicationTypeDestructor allows the DD to be
|
||||
// returned to the free list for the DD app in the app table.
|
||||
|
||||
class gddApplicationTypeTable
|
||||
{
|
||||
public:
|
||||
gddApplicationTypeTable(aitUint32 total_number_of_apps=(1<<9));
|
||||
~gddApplicationTypeTable(void);
|
||||
|
||||
// standard method
|
||||
gddStatus registerApplicationType(const char* const name, aitUint32& app);
|
||||
gddStatus registerApplicationTypeWithProto(const char* const name,
|
||||
gdd* protoDD, aitUint32& app);
|
||||
|
||||
// alternative method to register types
|
||||
aitUint32 registerApplicationType(const char* const name);
|
||||
aitUint32 registerApplicationTypeWithProto(const char* const name,
|
||||
gdd* protoDD);
|
||||
|
||||
// hashing still not used for string names to app types
|
||||
aitUint32 getApplicationType(const char* const name) const;
|
||||
char* getName(aitUint32 app) const;
|
||||
gddStatus mapAppToIndex(aitUint32 container_app,
|
||||
aitUint32 app_to_map, aitUint32& index);
|
||||
|
||||
// copy as best as possible from src to dest, one of the gdd must be
|
||||
// managed for this to succeed
|
||||
gddStatus smartCopy(gdd* dest, gdd* src);
|
||||
|
||||
// old style interface
|
||||
int tagC2I(const char* const ctag, int& tag);
|
||||
int tagC2I(const char* const ctag, int* const tag);
|
||||
int tagI2C(int tag, char* const ctag);
|
||||
int insertApplicationType(int tag, const char* ctag);
|
||||
|
||||
gdd* getDD(aitUint32 app);
|
||||
|
||||
// This should be a protected function, users should
|
||||
// always unreference a DD. Probably can occurs if there is another
|
||||
// manager in the system. This function cannot distinguish between
|
||||
// a DD managed by it or someone else. The AppDestructor will call
|
||||
// this function indirectly by unreferencing the DD.
|
||||
gddStatus freeDD(gdd*);
|
||||
|
||||
aitUint32 maxAttributes(void) const { return max_allowed; }
|
||||
aitUint32 totalregistered(void) const { return total_registered; }
|
||||
void describe(FILE*);
|
||||
gddStatus storeValue(aitUint32 app, aitUint32 user_value);
|
||||
aitUint32 getValue(aitUint32 app);
|
||||
|
||||
static gddApplicationTypeTable& AppTable(void);
|
||||
static gddApplicationTypeTable app_table;
|
||||
|
||||
protected:
|
||||
void GenerateTypes(void);
|
||||
|
||||
gddStatus copyDD_src(gdd* dest, gdd* src);
|
||||
gddStatus copyDD_dest(gdd* dest, gdd* src);
|
||||
|
||||
private:
|
||||
gddStatus splitApplicationType(aitUint32 r,aitUint32& g,aitUint32& a) const;
|
||||
aitUint32 group(aitUint32 rapp) const;
|
||||
aitUint32 index(aitUint32 rapp) const;
|
||||
int describeDD(gddContainer* dd, FILE* fd, int level, char* tn);
|
||||
|
||||
aitUint32 total_registered;
|
||||
aitUint32 max_allowed;
|
||||
aitUint32 max_groups;
|
||||
|
||||
gddApplicationTypeElement** attr_table;
|
||||
gddSemaphore sem;
|
||||
};
|
||||
|
||||
inline aitUint32 gddApplicationTypeTable::group(aitUint32 rapp) const
|
||||
{ return (rapp&(~(APPLTABLE_GROUP_SIZE-1)))>>APPLTABLE_GROUP_SIZE_POW; }
|
||||
inline aitUint32 gddApplicationTypeTable::index(aitUint32 rapp) const
|
||||
{ return rapp&(APPLTABLE_GROUP_SIZE-1); }
|
||||
|
||||
inline gddStatus gddApplicationTypeTable::splitApplicationType(aitUint32 rapp,
|
||||
aitUint32& g, aitUint32& app) const
|
||||
{
|
||||
g=group(rapp);
|
||||
app=index(rapp);
|
||||
if(rapp>=total_registered) return gddErrorOutOfBounds; else return 0;
|
||||
}
|
||||
|
||||
inline aitUint32 gddApplicationTypeTable::registerApplicationType(
|
||||
const char* const name)
|
||||
{
|
||||
aitUint32 app;
|
||||
registerApplicationType(name,app);
|
||||
return app;
|
||||
}
|
||||
|
||||
inline aitUint32 gddApplicationTypeTable::registerApplicationTypeWithProto(
|
||||
const char* const name, gdd* protoDD)
|
||||
{
|
||||
aitUint32 app;
|
||||
registerApplicationTypeWithProto(name,protoDD,app);
|
||||
return app;
|
||||
}
|
||||
|
||||
gddApplicationTypeTable* gddGenerateApplicationTypeTable(aitUint32 x=(1<<10));
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#ifndef GDD_ERROR_CODES_H
|
||||
#define GDD_ERROR_CODES_H
|
||||
|
||||
/*
|
||||
* Author: Jim Kowalkowski
|
||||
* Date: 2/96
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* $Log$
|
||||
*
|
||||
* *Revision 1.2 1996/06/13 21:32:00 jbk
|
||||
* *Various fixes and correction - including ref_cnt change to unsigned short
|
||||
* *Revision 1.1 1996/05/31 13:15:30 jbk
|
||||
* *add new stuff
|
||||
*
|
||||
*/
|
||||
|
||||
typedef long gddStatus;
|
||||
|
||||
#define gddErrorTypeMismatch -1
|
||||
#define gddErrorNotAllowed -2
|
||||
#define gddErrorAlreadyDefined -3
|
||||
#define gddErrorNewFailed -4
|
||||
#define gddErrorOutOfBounds -5
|
||||
#define gddErrorAtLimit -6
|
||||
#define gddErrorNotDefined -7
|
||||
#define gddErrorNotSupported -8
|
||||
#define gddErrorOverflow -9
|
||||
#define gddErrorUnderflow -10
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,49 @@
|
||||
// Author: Jim Kowalkowski
|
||||
// Date: 2/96
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// $Log$
|
||||
//
|
||||
|
||||
// *Revision 1.2 1996/06/24 03:15:37 jbk
|
||||
// *name changes and fixes for aitString and fixed string functions
|
||||
// *Revision 1.1 1996/05/31 13:15:31 jbk
|
||||
// *add new stuff
|
||||
|
||||
#include "gddNewDel.h"
|
||||
#include <stdio.h>
|
||||
|
||||
gddCleanUp gddBufferCleanUp;
|
||||
|
||||
gddCleanUp::gddCleanUp(void) { }
|
||||
|
||||
gddCleanUp::~gddCleanUp(void) { gddCleanUp::CleanUp(); }
|
||||
|
||||
gddCleanUpNode* gddCleanUp::bufs = NULL;
|
||||
|
||||
gddSemaphore gddCleanUp::lock;
|
||||
|
||||
void gddCleanUp::CleanUp(void)
|
||||
{
|
||||
gddCleanUpNode *p1,*p2;
|
||||
|
||||
for(p1=gddCleanUp::bufs;p1;)
|
||||
{
|
||||
p2=p1;
|
||||
p1=p1->next;
|
||||
free((char*)p2->buffer);
|
||||
delete p2;
|
||||
}
|
||||
}
|
||||
|
||||
void gddCleanUp::Add(void* v)
|
||||
{
|
||||
gddCleanUpNode* p = new gddCleanUpNode;
|
||||
p->buffer=v;
|
||||
lock.take();
|
||||
p->next=gddCleanUp::bufs;
|
||||
gddCleanUp::bufs=p;
|
||||
lock.give();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
#ifndef GDD_NEWDEL_H
|
||||
#define GDD_NEWDEL_H
|
||||
|
||||
/*
|
||||
* Author: Jim Kowalkowski
|
||||
* Date: 2/96
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* $Log$
|
||||
*
|
||||
* *Revision 1.2 1996/06/24 03:15:37 jbk
|
||||
* *name changes and fixes for aitString and fixed string functions
|
||||
* *Revision 1.1 1996/05/31 13:15:33 jbk
|
||||
* *add new stuff
|
||||
*
|
||||
*/
|
||||
|
||||
// this file if formatted with tab stop = 4
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "gddUtils.h"
|
||||
|
||||
// Avoid using templates at the cost of very poor readability.
|
||||
// This forces the user to have a static data member named "gddNewDel_freelist"
|
||||
// This also forces the user to have a data member named "gddNewDel_next"
|
||||
|
||||
// To use this stuff:
|
||||
//
|
||||
// ** In class description header file:
|
||||
// class myClass
|
||||
// {
|
||||
// public:
|
||||
// gdd_NEWDEL_FUNC(myClass)
|
||||
// private:
|
||||
// gdd_NEWDEL_DATA(myClass)
|
||||
// };
|
||||
//
|
||||
// ** In source file where functions for class are written:
|
||||
// gdd_NEWDEL_STAT(myClass)
|
||||
// gdd_NEWDEL_DEL(myClass)
|
||||
// gdd_NEWDEL_NEW(myClass)
|
||||
|
||||
#define gdd_CHUNK_NUM 20
|
||||
#define gdd_CHUNK(mine) (gdd_CHUNK_NUM*sizeof(mine))
|
||||
|
||||
// private data to add to a class
|
||||
#define gdd_NEWDEL_DATA(clas) \
|
||||
clas* newdel_next; \
|
||||
static clas* newdel_freelist; \
|
||||
static gddSemaphore lock;
|
||||
|
||||
// public interface for the new/delete stuff
|
||||
#define gdd_NEWDEL_FUNC(clas) void* operator new(size_t); \
|
||||
void operator delete(void*); \
|
||||
clas* next(void) { return newdel_next; } \
|
||||
void setNext(clas* n) { newdel_next=n; }
|
||||
|
||||
// declaration of the static variable for the free list
|
||||
#define gdd_NEWDEL_STAT(clas) \
|
||||
clas* clas::newdel_freelist=NULL; \
|
||||
gddSemaphore clas::lock;
|
||||
|
||||
// code for the delete function
|
||||
#define gdd_NEWDEL_DEL(clas) void clas::operator delete(void* v) { \
|
||||
clas* dn = (clas*)v; \
|
||||
if(dn->newdel_next==(clas*)(-1)) free((char*)v); \
|
||||
else { \
|
||||
clas::lock.take(); \
|
||||
dn->newdel_next=clas::newdel_freelist; clas::newdel_freelist=dn; \
|
||||
clas::lock.give(); \
|
||||
} \
|
||||
}
|
||||
|
||||
// following function assumes that reading/writing address is atomic
|
||||
|
||||
// code for the new function
|
||||
#define gdd_NEWDEL_NEW(clas) void* clas::operator new(size_t size) { \
|
||||
int tot; \
|
||||
clas *nn,*dn; \
|
||||
if(!clas::newdel_freelist) { \
|
||||
tot=gdd_CHUNK_NUM; \
|
||||
nn=(clas*)malloc(gdd_CHUNK(clas)); \
|
||||
gddCleanUp::Add(nn); \
|
||||
for(dn=nn;--tot;dn++) dn->newdel_next=dn+1; \
|
||||
clas::lock.take(); \
|
||||
(dn)->newdel_next=clas::newdel_freelist; \
|
||||
clas::newdel_freelist=nn; \
|
||||
clas::lock.give(); \
|
||||
} \
|
||||
if(size==sizeof(clas)) { \
|
||||
clas::lock.take(); \
|
||||
dn=clas::newdel_freelist; \
|
||||
clas::newdel_freelist=clas::newdel_freelist->newdel_next; \
|
||||
clas::lock.give(); \
|
||||
dn->newdel_next=NULL; \
|
||||
} else { \
|
||||
dn=(clas*)malloc(size); \
|
||||
dn->newdel_next=(clas*)(-1); \
|
||||
} \
|
||||
return (void*)dn; \
|
||||
}
|
||||
|
||||
class gddCleanUpNode
|
||||
{
|
||||
public:
|
||||
void* buffer;
|
||||
gddCleanUpNode* next;
|
||||
};
|
||||
|
||||
class gddCleanUp
|
||||
{
|
||||
public:
|
||||
gddCleanUp(void);
|
||||
~gddCleanUp(void);
|
||||
|
||||
static void Add(void*);
|
||||
static void CleanUp(void);
|
||||
private:
|
||||
static gddCleanUpNode* bufs;
|
||||
static gddSemaphore lock;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,499 @@
|
||||
// Author: Jim Kowalkowski
|
||||
// Date: 2/96
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// $Log$
|
||||
//
|
||||
|
||||
// *Revision 1.3 1996/06/24 03:15:38 jbk
|
||||
// *name changes and fixes for aitString and fixed string functions
|
||||
// *Revision 1.2 1996/06/13 21:32:00 jbk
|
||||
// *Various fixes and correction - including ref_cnt change to unsigned short
|
||||
// *Revision 1.1 1996/05/31 13:15:35 jbk
|
||||
// *add new stuff
|
||||
|
||||
#include <stdio.h>
|
||||
#include "gdd.h"
|
||||
|
||||
// -----------------------test routines------------------------
|
||||
|
||||
#ifdef NO_DUMP_TEST
|
||||
void gdd::dump(void) { }
|
||||
#else
|
||||
void gdd::dump(void)
|
||||
{
|
||||
gddScaler* sdd;
|
||||
gddAtomic* add;
|
||||
gddContainer* cdd;
|
||||
|
||||
if(isScaler())
|
||||
{
|
||||
sdd=(gddScaler*)this;
|
||||
sdd->dump();
|
||||
return;
|
||||
}
|
||||
if(isAtomic())
|
||||
{
|
||||
add=(gddAtomic*)this;
|
||||
add->dump();
|
||||
return;
|
||||
}
|
||||
if(isContainer())
|
||||
{
|
||||
cdd=(gddContainer*)this;
|
||||
cdd->dump();
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef NO_DUMP_TEST
|
||||
void gdd::dumpInfo(void) { }
|
||||
#else
|
||||
void gdd::dumpInfo(void)
|
||||
{
|
||||
unsigned i;
|
||||
aitIndex f,c;
|
||||
long sz_tot,sz_data,sz_elem;
|
||||
|
||||
sz_tot = getTotalSizeBytes();
|
||||
sz_data = getDataSizeBytes();
|
||||
sz_elem = getDataSizeElements();
|
||||
|
||||
fprintf(stderr,"----------dump This=%8.8x---------\n",(unsigned int)this);
|
||||
fprintf(stderr," app=%d, prim=%d",applicationType(),primitiveType());
|
||||
fprintf(stderr," dim=%d\n",dimension());
|
||||
fprintf(stderr," tot=%ld, data=%ld, elem=%ld ",sz_tot,sz_data,sz_elem);
|
||||
fprintf(stderr," ref count=%d\n",ref_cnt);
|
||||
|
||||
for(i=0;i<dimension();i++)
|
||||
{
|
||||
getBound(i,f,c);
|
||||
fprintf(stderr," (%d) %8.8x first=%d count=%d\n",i,&bounds[i],f,c);
|
||||
}
|
||||
|
||||
if(isScaler()) fprintf(stderr," Is a Scaler\n");
|
||||
if(isAtomic()) fprintf(stderr," Is a Atomic\n");
|
||||
if(isContainer()) fprintf(stderr," Is a Container\n");
|
||||
|
||||
if(!isContainer() && !isScaler() && !isAtomic())
|
||||
fprintf(stderr,"--------------------------------------\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef NO_DUMP_TEST
|
||||
void gddAtomic::dump(void) { }
|
||||
#else
|
||||
void gddAtomic::dump(void)
|
||||
{
|
||||
aitFloat64* f64; aitFloat32* f32;
|
||||
aitUint32* ui32; aitInt32* i32;
|
||||
aitUint16* ui16; aitInt16* i16;
|
||||
aitUint8* ui8; aitInt8* i8;
|
||||
char* str;
|
||||
|
||||
gdd::dumpInfo();
|
||||
|
||||
switch(primitiveType())
|
||||
{
|
||||
case aitEnumFloat64:
|
||||
getRef(f64);
|
||||
if(f64) fprintf(stderr," Convert: float64 %8.8x %lf ",f64,f64[0]);
|
||||
f64=*this;
|
||||
if(f64) fprintf(stderr," Normal: float64 %8.8x %lf\n",f64,f64[0]);
|
||||
break;
|
||||
case aitEnumFloat32:
|
||||
getRef(f32);
|
||||
if(f32) fprintf(stderr," Convert: float32 %8.8x %f ",f32,f32[0]);
|
||||
f32=*this;
|
||||
if(f32) fprintf(stderr," Normal: float32 %8.8x %f\n",f32,f32[0]);
|
||||
break;
|
||||
case aitEnumUint32:
|
||||
getRef(ui32);
|
||||
if(ui32) fprintf(stderr," Convert: uint32 %8.8x %d ",ui32,ui32[0]);
|
||||
ui32=*this;
|
||||
if(ui32) fprintf(stderr," Normal: uint32 %8.8x %d\n",ui32,ui32[0]);
|
||||
break;
|
||||
case aitEnumInt32:
|
||||
getRef(i32);
|
||||
if(i32) fprintf(stderr," Convert: int32 %8.8x %d ",i32,i32[0]);
|
||||
i32=*this;
|
||||
if(i32) fprintf(stderr," Normal: int32 %8.8x %d\n",i32,i32[0]);
|
||||
break;
|
||||
case aitEnumUint16:
|
||||
getRef(ui16);
|
||||
if(ui16) fprintf(stderr," Convert: uint16 %8.8x %hu ",ui16,ui16[0]);
|
||||
ui16=*this;
|
||||
if(ui16) fprintf(stderr," Normal: uint16 %8.8x %hu\n",ui16,ui16[0]);
|
||||
break;
|
||||
case aitEnumInt16:
|
||||
getRef(i16);
|
||||
if(i16) fprintf(stderr," Convert: int16 %8.8x %hd ",i16,i16[0]);
|
||||
i16=*this;
|
||||
if(i16) fprintf(stderr," Normal: int16 %8.8x %hd\n",i16,i16[0]);
|
||||
break;
|
||||
case aitEnumUint8:
|
||||
getRef(ui8);
|
||||
if(ui8) fprintf(stderr," Convert: uint8 %8.8x %d ",ui8,ui8[0]);
|
||||
ui8=*this;
|
||||
if(ui8) fprintf(stderr," Normal: uint8 %8.8x %d\n",ui8,ui8[0]);
|
||||
break;
|
||||
case aitEnumInt8:
|
||||
getRef(i8);
|
||||
if(i8) fprintf(stderr," Convert: int8 %8.8x %d ",i8,i8[0]);
|
||||
i8=*this;
|
||||
if(i8) fprintf(stderr," Normal: int8 %8.8x %d\n",i8,i8[0]);
|
||||
break;
|
||||
case aitEnumString:
|
||||
getRef(str);
|
||||
if(str) fprintf(stderr," <%s>\n",str);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr," unknown primitive type\n"); break;
|
||||
}
|
||||
fprintf(stderr,"-------------------------------------\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef NO_DUMP_TEST
|
||||
void gddScaler::dump(void) { }
|
||||
#else
|
||||
void gddScaler::dump(void)
|
||||
{
|
||||
aitFloat64 f64; aitFloat32 f32; aitUint32 ui32; aitInt32 i32;
|
||||
aitUint16 ui16; aitInt16 i16; aitUint8 ui8; aitInt8 i8;
|
||||
|
||||
gdd::dumpInfo();
|
||||
|
||||
switch(primitiveType())
|
||||
{
|
||||
case aitEnumFloat64:
|
||||
get(f64); if(f64) fprintf(stderr," Convert: float64 %lf ",f64);
|
||||
f64=*this; if(f64) fprintf(stderr," Normal: float64 %lf\n",f64);
|
||||
break;
|
||||
case aitEnumFloat32:
|
||||
get(f32); if(f32) fprintf(stderr," Convert: float32 %f ",f32);
|
||||
f32=*this; if(f32) fprintf(stderr," Normal: float32 %f\n",f32);
|
||||
break;
|
||||
case aitEnumUint32:
|
||||
get(ui32); if(ui32) fprintf(stderr," Convert: uint32 %d ",ui32);
|
||||
ui32=*this; if(ui32) fprintf(stderr," Normal: uint32 %d\n",ui32);
|
||||
break;
|
||||
case aitEnumInt32:
|
||||
get(i32); if(i32) fprintf(stderr," Convert: int32 %d ",i32);
|
||||
i32=*this; if(i32) fprintf(stderr," Normal: int32 %d\n",i32);
|
||||
break;
|
||||
case aitEnumUint16:
|
||||
get(ui16); if(ui16) fprintf(stderr," Convert: uint16 %hu ",ui16);
|
||||
ui16=*this; if(ui16) fprintf(stderr," Normal: uint16 %hu\n",ui16);
|
||||
break;
|
||||
case aitEnumInt16:
|
||||
get(i16); if(i16) fprintf(stderr," Convert: int16 %hd ",i16);
|
||||
i16=*this; if(i16) fprintf(stderr," Normal: int16 %hd\n",i16);
|
||||
break;
|
||||
case aitEnumUint8:
|
||||
get(ui8); if(ui8) fprintf(stderr," Convert: uint8 %2.2x ",ui8);
|
||||
ui8=*this; if(ui8) fprintf(stderr," Normal: uint8 %2.2x\n",ui8);
|
||||
break;
|
||||
case aitEnumInt8:
|
||||
get(i8); if(i8) fprintf(stderr," Convert: int8 %d ",i8);
|
||||
i8=*this; if(i8) fprintf(stderr," Normal: int8 %d\n",i8);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr," unknown primitive type\n"); break;
|
||||
}
|
||||
fprintf(stderr,"--------------------------------------\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef NO_DUMP_TEST
|
||||
void gdd::test() { }
|
||||
#else
|
||||
void gdd::test()
|
||||
{
|
||||
aitInt32 i32[3] = { -32,4,3 };
|
||||
aitIndex bnds = 3;
|
||||
gddAtomic* add = (gddAtomic*)this;
|
||||
gddAtomic* dd = new gddAtomic(98,aitEnumInt32,1,3);
|
||||
|
||||
reset(aitEnumInt32,1,&bnds);
|
||||
add->put(i32);
|
||||
fprintf(stderr,"----TESTING DD DUMP:\n");
|
||||
add->dump();
|
||||
|
||||
// test copy(), copyInfo(), Dup()
|
||||
fprintf(stderr,"----TESTING COPYINFO(): (1)COPYINFO, (2)ORIGINAL\n");
|
||||
dd->copyInfo(this); dd->dump(); add->dump();
|
||||
fprintf(stderr,"----TESTING DUP(): (1)DUP, (2)ORIGINAL\n");
|
||||
dd->clear(); dd->Dup(this); dd->dump(); add->dump();
|
||||
fprintf(stderr,"----TESTING COPY(): (1)COPY, (2)ORIGINAL\n");
|
||||
dd->clear(); dd->copy(this); dd->dump(); add->dump();
|
||||
dd->unreference();
|
||||
|
||||
// test flatten functions and Convert functions
|
||||
size_t sz = getTotalSizeBytes();
|
||||
aitUint8* buf = new aitUint8[sz];
|
||||
gddAtomic* pdd = (gddAtomic*)buf;
|
||||
flattenWithAddress(buf,sz);
|
||||
fprintf(stderr,"----TESTING FLATTENWITHADDRESS():\n");
|
||||
pdd->dump();
|
||||
fprintf(stderr,"----CONVERTADDRESSTOOFFSETS() THEN BACK AND DUMP:\n");
|
||||
pdd->convertAddressToOffsets();
|
||||
pdd->convertOffsetsToAddress();
|
||||
pdd->dump();
|
||||
pdd->unreference();
|
||||
delete buf;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NO_DUMP_TEST
|
||||
class gddAtomicDestr : public gddDestructor
|
||||
{
|
||||
public:
|
||||
gddAtomicDestr(void) { }
|
||||
void run(void*);
|
||||
};
|
||||
|
||||
void gddAtomicDestr::run(void* v)
|
||||
{
|
||||
fprintf(stderr,"**** gddAtomicDestr::run from gddAtomic::test %8.8x\n",v);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef NO_DUMP_TEST
|
||||
void gddAtomic::test(void) { }
|
||||
#else
|
||||
void gddAtomic::test(void)
|
||||
{
|
||||
aitFloat32 f32[6] = { 32.0,2.0,1.0, 7.0,8.0,9.0 };
|
||||
aitFloat64 f64[6] = { 64.0,5.0,4.0, 10.0,11.0,12.0 };
|
||||
aitInt8 i8[6] = { -8,2,1, 13,14,15 };
|
||||
aitInt16 i16[6] = { -16,3,2, 16,17,18 };
|
||||
aitInt32 i32[6] = { -32,4,3, 19,20,21 };
|
||||
aitUint8 ui8[6] = { 8,5,4, 22,23,24 };
|
||||
aitUint16 ui16[6] = { 16,6,5, 25,26,27 };
|
||||
aitUint32 ui32[6] = { 32,7,6, 28,29,30 };
|
||||
aitIndex bnds[2] = { 2,3 };
|
||||
|
||||
// Rules:
|
||||
// reset() clear out everything and set data pointer to NULL
|
||||
// put() will auto allocate if data pointer is NULL, otherwise copy
|
||||
// putRef() will clear current data pointer and set new one
|
||||
|
||||
// if the data pointer is NULL when put() is called, then a
|
||||
// generic gddDestructor will be created to delete the buffer
|
||||
|
||||
reset(aitEnumFloat32,2,bnds);
|
||||
put(f32); dump();
|
||||
putRef(f32,new gddAtomicDestr); dump();
|
||||
|
||||
reset(aitEnumFloat64,2,bnds);
|
||||
put(f64); dump();
|
||||
putRef(f64,new gddAtomicDestr); dump();
|
||||
|
||||
reset(aitEnumInt8,2,bnds);
|
||||
put(i8); dump();
|
||||
putRef(i8,new gddAtomicDestr); dump();
|
||||
|
||||
reset(aitEnumUint8,2,bnds);
|
||||
put(ui8); dump();
|
||||
putRef(ui8,new gddAtomicDestr); dump();
|
||||
|
||||
reset(aitEnumInt16,2,bnds);
|
||||
put(i16); dump();
|
||||
putRef(i16,new gddAtomicDestr); dump();
|
||||
|
||||
reset(aitEnumUint16,2,bnds);
|
||||
put(ui16); dump();
|
||||
putRef(ui16,new gddAtomicDestr); dump();
|
||||
|
||||
reset(aitEnumInt32,2,bnds);
|
||||
put(i32); dump();
|
||||
putRef(i32,new gddAtomicDestr); dump();
|
||||
|
||||
reset(aitEnumUint32,2,bnds);
|
||||
put(ui32); dump();
|
||||
putRef(ui32,new gddAtomicDestr); dump();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef NO_DUMP_TEST
|
||||
void gddScaler::test(void) { }
|
||||
#else
|
||||
void gddScaler::test(void)
|
||||
{
|
||||
int i;
|
||||
aitFloat32 fa32,f32 = 32.0;
|
||||
aitFloat64 fa64,f64 = 64.0;
|
||||
aitInt8 ia8,i8 = -8;
|
||||
aitInt16 ia16,i16 = -16;
|
||||
aitInt32 ia32,i32 = -32;
|
||||
aitUint8 uia8,ui8 = 8;
|
||||
aitUint16 uia16,ui16 = 16;
|
||||
aitUint32 uia32,ui32 = 32;
|
||||
|
||||
// printf("get float32 = %f\n",fa32);
|
||||
// printf("op= float32 = %f\n",fa32);
|
||||
|
||||
fprintf(stderr,"float32====");
|
||||
for(i=0;i<aitConvertTotal;i++)
|
||||
{
|
||||
setPrimType((aitEnum)i);
|
||||
put(f32);
|
||||
get(fa32);
|
||||
dump();
|
||||
*this=f32;
|
||||
fa32=*this;
|
||||
dump();
|
||||
}
|
||||
fprintf(stderr,"float64====");
|
||||
for(i=0;i<aitConvertTotal;i++)
|
||||
{
|
||||
setPrimType((aitEnum)i);
|
||||
put(f64); get(fa64); dump(); *this=f64; fa64=*this; dump();
|
||||
}
|
||||
fprintf(stderr,"int8====");
|
||||
for(i=0;i<aitConvertTotal;i++)
|
||||
{
|
||||
setPrimType((aitEnum)i);
|
||||
put(i8); get(ia8); dump(); *this=i8; ia8=*this; dump();
|
||||
}
|
||||
fprintf(stderr,"uint8====");
|
||||
for(i=0;i<aitConvertTotal;i++)
|
||||
{
|
||||
setPrimType((aitEnum)i);
|
||||
put(ui8); get(uia8); dump(); *this=ui8; uia8=*this; dump();
|
||||
}
|
||||
fprintf(stderr,"int16====");
|
||||
for(i=0;i<aitConvertTotal;i++)
|
||||
{
|
||||
setPrimType((aitEnum)i);
|
||||
put(i16); get(ia16); dump(); *this=i16; ia16=*this; dump();
|
||||
}
|
||||
fprintf(stderr,"uint16====");
|
||||
for(i=0;i<aitConvertTotal;i++)
|
||||
{
|
||||
setPrimType((aitEnum)i);
|
||||
put(ui16); get(uia16); dump(); *this=ui16; uia16=*this; dump();
|
||||
}
|
||||
fprintf(stderr,"int32====");
|
||||
for(i=0;i<aitConvertTotal;i++)
|
||||
{
|
||||
setPrimType((aitEnum)i);
|
||||
put(i32); get(ia32); dump(); *this=i32; ia32=*this; dump();
|
||||
}
|
||||
fprintf(stderr,"uint32====");
|
||||
for(i=0;i<aitConvertTotal;i++)
|
||||
{
|
||||
setPrimType((aitEnum)i);
|
||||
put(ui32); get(uia32); dump(); *this=ui32; uia32=*this; dump();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef NO_DUMP_TEST
|
||||
void gddContainer::dump(void) { }
|
||||
#else
|
||||
void gddContainer::dump(void)
|
||||
{
|
||||
int i;
|
||||
gdd* dd;
|
||||
gddAtomic* add;
|
||||
gddScaler* sdd;
|
||||
gddContainer* cdd;
|
||||
|
||||
fprintf(stderr,"----------dumping container:\n");
|
||||
gdd::dumpInfo();
|
||||
fprintf(stderr," total in container = %d\n",total());
|
||||
|
||||
// should use a cursor
|
||||
|
||||
for(i=0;dd=getDD(i);i++)
|
||||
{
|
||||
if(dd->isAtomic()) { add=(gddAtomic*)dd; add->dump(); }
|
||||
if(dd->isScaler()) { sdd=(gddScaler*)dd; sdd->dump(); }
|
||||
if(dd->isContainer()) { cdd=(gddContainer*)dd; cdd->dump(); }
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef NO_DUMP_TEST
|
||||
void gddContainer::test(void) { }
|
||||
#else
|
||||
void gddContainer::test(void)
|
||||
{
|
||||
gddScaler* sdd1 = new gddScaler(1,aitEnumInt32);
|
||||
gddScaler* sdd2 = new gddScaler(2,aitEnumInt16);
|
||||
gddAtomic* add1 = new gddAtomic(3,aitEnumFloat32,1,3);
|
||||
gddContainer* cdd1;
|
||||
|
||||
aitInt16 i16 = 5;
|
||||
aitInt32 i32 = 6;
|
||||
aitFloat32 f32[3] = { 7.0, 8.0, 9.0 };
|
||||
aitUint8* buf;
|
||||
size_t sz;
|
||||
|
||||
*sdd1=i32; *sdd2=i16; *add1=f32;
|
||||
|
||||
// insert two scalers and an atomic into the container
|
||||
fprintf(stderr,"*INSERT %8.8x %8.8x %8.8x\n",sdd1,sdd2,add1);
|
||||
clear();
|
||||
sdd1->reference(); add1->reference(); sdd2->reference();
|
||||
insert(sdd1); insert(sdd2); insert(add1); dump();
|
||||
|
||||
fprintf(stderr,"=====TESTING CURSOR:\n");
|
||||
gddCursor cur = getCursor();
|
||||
gdd* dd;
|
||||
int i;
|
||||
for(i=0;dd=cur[i];i++) fprintf(stderr,"%8.8x ",dd);
|
||||
fprintf(stderr,"\n");
|
||||
for(dd=cur.first();dd;dd=cur.next()) fprintf(stderr,"%8.8x ",dd);
|
||||
fprintf(stderr,"\n");
|
||||
|
||||
remove(0); remove(0); remove(0); dump();
|
||||
sdd1->reference(); add1->reference(); sdd2->reference();
|
||||
insert(add1); insert(sdd1); insert(sdd2); dump();
|
||||
|
||||
sz = getTotalSizeBytes();
|
||||
buf = new aitUint8[sz];
|
||||
|
||||
fprintf(stderr,"=====TESTING FLATTEN FUNCTION BUFFER=%8.8x:\n",buf);
|
||||
flattenWithAddress(buf,sz);
|
||||
cdd1=(gddContainer*)buf;
|
||||
cdd1->dump();
|
||||
fprintf(stderr,"=====CHANGE ADDRESSES TO OFFSETS:\n");
|
||||
cdd1->convertAddressToOffsets();
|
||||
fprintf(stderr,"=====CHANGE OFFSETS TO ADDRESSES:\n");
|
||||
cdd1->convertOffsetsToAddress();
|
||||
fprintf(stderr,"=====RE-DUMP OF FLATTENED CONTAINER:\n");
|
||||
cdd1->dump();
|
||||
fprintf(stderr,"=====RE-DUMP OF ORIGINAL CONTAINER:\n");
|
||||
dump();
|
||||
cdd1->unreference();
|
||||
delete buf;
|
||||
|
||||
// test copy(), Dup(), copyInfo()
|
||||
fprintf(stderr,"=======CREATING TEST CONTAINER FOR *COPY* TEST:\n");
|
||||
cdd1 = new gddContainer;
|
||||
fprintf(stderr,"=======COPYINFO():\n");
|
||||
cdd1->copyInfo(this); cdd1->dump();
|
||||
fprintf(stderr,"=======DUP():\n");
|
||||
cdd1->Dup(this); cdd1->dump();
|
||||
fprintf(stderr,"=======COPY():\n");
|
||||
cdd1->copy(this); cdd1->dump();
|
||||
fprintf(stderr,"=======UNREFERENCE THE TEST CONTAINER:\n");
|
||||
cdd1->unreference();
|
||||
|
||||
fprintf(stderr,"=====DUMPING ORIGINAL:\n");
|
||||
dump();
|
||||
clear();
|
||||
|
||||
fprintf(stderr,"=======TEST COMPLETE, DELETE STUFF:\n");
|
||||
fprintf(stderr," first scaler:\n "); sdd1->unreference();
|
||||
fprintf(stderr," first atomic:\n "); add1->unreference();
|
||||
fprintf(stderr," second scaler:\n "); sdd2->unreference();
|
||||
dump();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
#ifndef GDD_UTILS_H
|
||||
#define GDD_UTILS_H
|
||||
|
||||
/*
|
||||
* Author: Jim Kowalkowski
|
||||
* Date: 2/96
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* $Log$
|
||||
*
|
||||
* *Revision 1.2 1996/06/24 03:15:39 jbk
|
||||
* *name changes and fixes for aitString and fixed string functions
|
||||
* *Revision 1.1 1996/05/31 13:15:36 jbk
|
||||
* *add new stuff
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef vxWorks
|
||||
#include <vxWorks.h>
|
||||
#include <vme.h>
|
||||
#include <sysLib.h>
|
||||
#include <semLib.h>
|
||||
#endif
|
||||
|
||||
#include "aitTypes.h"
|
||||
|
||||
typedef enum { gddSemEmpty, gddSemFull } gddSemType;
|
||||
|
||||
#if 0
|
||||
#ifdef vxWorks
|
||||
#undef vxWorks
|
||||
#define __temp_vxWorks__ 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Semaphores default to "Full"
|
||||
|
||||
class gddSemaphore
|
||||
{
|
||||
public:
|
||||
gddSemaphore(void);
|
||||
gddSemaphore(gddSemType);
|
||||
~gddSemaphore(void);
|
||||
|
||||
void give(void);
|
||||
void take(void);
|
||||
void take(aitUint32 usec);
|
||||
private:
|
||||
#ifdef vxWorks
|
||||
SEM_ID sem;
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef vxWorks
|
||||
inline gddSemaphore::gddSemaphore(void)
|
||||
{ sem=semBCreate(SEM_Q_PRIORITY,SEM_FULL); }
|
||||
inline gddSemaphore::gddSemaphore(gddSemType s)
|
||||
{
|
||||
if(s==gddSemEmpty) sem=semBCreate(SEM_Q_PRIORITY,SEM_EMPTY);
|
||||
else sem=semBCreate(SEM_Q_PRIORITY,SEM_FULL);
|
||||
}
|
||||
inline gddSemaphore::~gddSemaphore(void) { semDelete(sem); }
|
||||
inline void gddSemaphore::give(void) { semGive(sem); }
|
||||
inline void gddSemaphore::take(void) { semTake(sem,WAIT_FOREVER); }
|
||||
inline void gddSemaphore::take(aitUint32 usec)
|
||||
{ semTake(sem,usec/(sysClkRateGet()*1000000)); }
|
||||
#else
|
||||
inline gddSemaphore::gddSemaphore(void) { }
|
||||
inline gddSemaphore::gddSemaphore(gddSemType) { }
|
||||
inline gddSemaphore::~gddSemaphore(void) { }
|
||||
inline void gddSemaphore::give(void) { }
|
||||
inline void gddSemaphore::take(void) { }
|
||||
inline void gddSemaphore::take(aitUint32) { }
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
class gddIntLock
|
||||
{
|
||||
public:
|
||||
private:
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef __temp_vxWorks__
|
||||
#define vxWorks 1
|
||||
#undef __temp_vxWorks__
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
// Author: Jim Kowalkowski
|
||||
// Date: 2/96
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// $Log$
|
||||
//
|
||||
|
||||
// *Revision 1.2 1996/06/24 03:15:40 jbk
|
||||
// *name changes and fixes for aitString and fixed string functions
|
||||
// *Revision 1.1 1996/05/31 13:15:37 jbk
|
||||
// *add new stuff
|
||||
|
||||
#include "gddAppTable.h"
|
||||
|
||||
#if 0
|
||||
#ifndef GDD_NO_EPICS
|
||||
#include "dbrMapper.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
FILE* fd;
|
||||
|
||||
gddApplicationTypeTable& tt = gddApplicationTypeTable::AppTable();
|
||||
|
||||
if(argc<2)
|
||||
{
|
||||
fprintf(stderr,"You must enter a file name on command line\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if((fd=fopen(argv[1],"w"))==NULL)
|
||||
{
|
||||
fprintf(stderr,"Cannot open file %s\n",argv[1]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if 0
|
||||
#ifndef GDD_NO_EPICS
|
||||
gddMakeMapDBR(tt);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
tt.describe(fd);
|
||||
fclose(fd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
OUTPUT_FORMAT("a.out-sunos-big")
|
||||
OUTPUT_ARCH(m68k)
|
||||
__DYNAMIC = 0;
|
||||
SECTIONS
|
||||
{
|
||||
.text 0x00:
|
||||
{
|
||||
CREATE_OBJECT_SYMBOLS
|
||||
*(.text)
|
||||
}
|
||||
.data SIZEOF(.text) + ADDR(.text) :
|
||||
{
|
||||
*(.data)
|
||||
CONSTRUCTORS
|
||||
}
|
||||
.bss SIZEOF(.data) + ADDR(.data) :
|
||||
{
|
||||
*(.bss)
|
||||
*(COMMON)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user