/****************************************************************************** * * Title : globalDefinitions.c * Version 0.0 * * Description: Definition struct of global variables. * Related files: almost all in rcc.prj but * most important for CommonControlLoop.c, rccMain.c and loadExitHost.c * * Author: Lukas Tomasek, tomasekl@fzu.cz * ******************************************************************************/ #ifndef GLOBAL_DEFINITIONS_H /* multiple-inclusion protection */ #define GLOBAL_DEFINITIONS_H /****************************************************************************** * Header files * ******************************************************************************/ #include "hostDefinitions.h" #include "primParamsStruct.h" #include "commandParamsStruct.h" #include "commandListDefinitions.h" #include "primParams.h" /****************************************************************************** * Definitions * ******************************************************************************/ /*============================================================================= * MENU: Options->Compiler Defines: * * /DI_AM_NT_HOST /DI_AM_TEST_STAND /DWINDOWS_NT /DLAB_WINDOWS_CVI /DPROTO_ROD * /DSCT_ROD or /PIXEL_ROD * *============================================================================*/ /* common input/output data directory */ #define RCC_SUBDIR "Rcc\\" #define HELP_DIR "TestStandUserGuide\\" #define COMMON_DATA_SUBDIR "Data\\" #define ROD_SUBDIR COMMON_DATA_SUBDIR"Rod\\Slot#" #define FPGA_DATA_SUBDIR COMMON_DATA_SUBDIR"Fpga\\" #define TESTING_DATA_SUBDIR COMMON_DATA_SUBDIR"Testing\\" #define TEMPORARY_DATA_SUBDIR COMMON_DATA_SUBDIR"Temporary\\" #define DSP_PRG_DATA_SUBDIR COMMON_DATA_SUBDIR"DSPProgram\\rodRun\\" #define TIM_REG_TXT_FILE_SUBDIR RCC_SUBDIR"TimRegsDescription\\" #define ROD_REG_TXT_FILE_SUBDIR RCC_SUBDIR"MDSPRegFieldsDescription\\" #define LISTRINGS_SUBDIR COMMON_DATA_SUBDIR"ListRings\\" #define MODULECFG_SUBDIR COMMON_DATA_SUBDIR"ModuleConfig\\" #define HISTO_SUBDIR TESTING_DATA_SUBDIR"calibration\\" /* * Output errorFile - common for all hosts. * Contains all error messages from rcc process (see errorHandler.c). */ #define ERROR_FILE_NAME COMMON_DATA_SUBDIR"ErrorFile\\CommonErrorFile.txt" /* data path definition */ #define ERROR_BUFFER_FILE_NAME "ErrorBuffer-slot#" #define INFO_BUFFER_FILE_NAME "InfoBuffer-slot#" #define DIAG_BUFFER_FILE_NAME "DiagBuffer-slot#" #define XFER_BUFFER_FILE_NAME "XferBuffer-slot#" #define FLASH_CFG_FILE "flashDefault.cfg" //#define FLASH_DEFAULT_SETTINGS_FILE FPGA_DATA_SUBDIR"flashDefault.cfg" #define LISTRINGS_CFG_FILE "listRingsDefault.cfg" //#define LISTRINGS_DEFAULT_FILE LISTRINGS_SUBDIR"listRingsDefault.cfg" #define PRIMITIVE_BUFFER_FILE_NAME "PrimBuffer-slot#" #define PRIMLIST_TABLE_FILE_NAME "PrimList-slot#" #define REPLY_BUFFER_FILE_NAME "ReplyBuffer-slot#" #define COMMAND_LIST_FILE_NAME "CommandList-slot#" #define COMMAND_STATUS_FILE_NAME "CommandStatus-slot#" /* external executables */ #define EXTERNAL_EDITOR "notepad.exe" /* text editor/viewer */ #define DATA_FILE_CREATOR "DataFileCreator\\dataFileCreator.exe" /* binary file creator */ #define VME_RESOURCE_MANAGER "Resman.exe" /* NI VME resource manager */ #define VME_RESOURCE_MANAGER_2 "C:\\Program Files\\National Instruments\\VXI\\Resman.exe" #define BIN_VIEWER "Witched\\Witched.exe " /* binary viewer */ /* crate definitions */ #define FIRST_ROD_VME_SLOT 5 /* first VME slot available for ROD */ #define LAST_ROD_VME_SLOT 21 /* first VME slot available for ROD */ #define TIM_SLOT_NUMBER 13 #define ALL_RODS 0 /* slotNumber "0" means all loaded rods in primListEditor and commandListEditor */ /****************************************************************************** * Macros * ******************************************************************************/ /* maximum number of rods in the crate */ #define MAXRODS (LAST_ROD_VME_SLOT-FIRST_ROD_VME_SLOT+1) /* ~geographical addressing; +TIM slot included! */ #define HOST_INDEX(slotNumber) ((slotNumber)-FIRST_ROD_VME_SLOT) /****************************************************************************** * Type definitions * ******************************************************************************/ /*------------------------ PRIM_FUNCTION_TYPE -------------------------------*/ typedef enum{ /* primitive function options */ PRIM_PANEL_TO_TABLE=0, /* copies prim params from panel to primList table */ PRIM_PARAMS_TO_TABLE=1,/* copies prim params to table - usefull when you need to generate primList table without GUI */ PRIM_TABLE_TO_PANEL=2, /* copies prim params from primList to panel */ PRIM_BUILD=3, /* builds primitive from primTable in primListBuilding thread */ REP_DATA_PROCESS=4, /* reply data processing in repListProcessing thread */ WRITE_TO_FILE=5, READ_FROM_FILE=6, } PRIM_FUNC_OPTION; typedef enum{ /* primitive function options */ MASTER_DSP=0xFF, SLAVE_DSP0=0, SLAVE_DSP1=1, SLAVE_DSP2=2, SLAVE_DSP3=3, } DSP_TYPE; typedef enum{ /* */ REFRESH_OFF=0, REFRESH_ON=1, REFRESH_RUNTIME=2, } DISPLAY_REFRESH_OPTION; /* * Common primitive function type definition: * Pointer to primitive data in primListBuffer/repListBuffer * inputParameter=DSP_TYPE for REP_DATA_PROCESS of maxLength of PrimListBuffer in bytes for function option PRIM_BUILD * (data buffer overflow protection). */ typedef ERROR_ID PRIM_FUNCTION_TYPE(PRIM_FUNC_OPTION funcOption, struct PRIM_TABLE *primTable, void *primitive, UINT32 inputParameter, UINT8 slotNumber); #define PRIM_FUNC_DEFINED /*-------------------- struct GLOBAL_PROGRAM_OPTIONS -------------------------*/ struct GLOBAL_PROGRAM_OPTIONS{ volatile int programExit; /* exit program */ volatile int stopCommLoop; /* stop communicationLoop thread flag */ volatile int commLoopRunning;/* communicationLoop thread running status */ volatile DISPLAY_REFRESH_OPTION displayRefresh;/* GUI option - refresh display from timer callback */ volatile int dspMonitorOn; volatile int fpgaMonitorOn; volatile double displayRefreshPeriodInSec; /* refresh period in sec - synchronized with communnication Loop */ volatile double dspMonitorPeriodInSec; volatile double fpgaMonitorPeriodInSec; volatile int dspAckSetTimeoutOn; /* dspAck timeout on/off */ volatile int vme; //vme defined volatile int masterChecksum; /* calc. primList and repList checksum*/ volatile int slaveChecksum; /* calc. primList and repList checksum*/ volatile int saveLists; /* save last primList and repList to file */ volatile int intelNotMotorola; volatile int disableVmeError; }; /*-------------------- struct GLOBAL_PROGRAM_OPTIONS -------------------------*/ /* * Global LabWindows panel handles */ struct GLOBAL_UIR_PANELS{ int main; int fpga; int flash; int vmeMemory; int masterDspMemory; int slaveDspMemory; int loadHost; int flashInfo; /* flash info panel */ int writeBuffVme; int writeBuffMaster; int writeBuffSlave; int primListEdit; int slaveList; int commandListEdit; int commandEdit[LAST_COMMAND_ID+1]; int primEdit[NUM_PRIMITIVES]; /* primitive params windows */ int error; int tim; int distributionPlot; int histoCreator; }; /*======================== struct GLOBAL_VARIABLES ===========================*/ struct GLOBAL_VARIABLES{ volatile unsigned char hostCount; /* actual number of Hosts/Rods loaded */ /* pointers to host structs */ struct HOST *(host[MAXRODS]); /* pooling timeouts in seconds */ double dspAckSetTimeout; /* timeout for primitive list execution by MDSP; can be disabled by option.dspAckSetTimeoutOn=0 flag(default) */ double dspAckClearTimeout; double textBuffTimeout; double rodInitTimeout; struct GLOBAL_PROGRAM_OPTIONS option; /* global program options in MainWindow*/ /* array of pointers to primitive functions */ PRIM_FUNCTION_TYPE (*primFunction[NUM_PRIMITIVES]); /* array of pointers to command functions */ COMMAND_FUNCTION_TYPE (*commandFunction[LAST_COMMAND_ID+1]); /* * Global threads info */ struct THREAD_INFO communLoopThread; struct THREAD_INFO mainThread; /* \ * Global thread priority */ int cmdListExecThreadPriority; /* * CriticalSections - prevent some parts of the code * (common hardware - VME, common data - errorFile); * from simultaneous multiple access from more than * one thread */ CRITICAL_SECTION saveToErrorFileCriticalSection; CRITICAL_SECTION vmeAccessCriticalSection; struct GLOBAL_UIR_PANELS panel; /* GUI panel handlers */ volatile int errPanelInstalled; /* protection from displaying multiple error popups */ int uirReturnCode; /* user interface return code */ unsigned int editPrimitiveId; /* Id of the primitive currently opened/edited in ListEdit window */ unsigned int editCommandId; /* Id of the command currently opened/edited in commandListEdit window */ /* * Dynamic memory pointers (for vme/master/slave memory access panels) */ UINT32 (*masterMemoryRead); UINT32 (*masterMemoryWrite); UINT32 (*slaveMemoryRead); UINT32 (*slaveMemoryWrite); UINT32 (*vmeMemoryRead); UINT32 (*vmeMemoryWrite); /* data directories */ char mainDir[PATHNAME_LENGTH]; /* project directory */ char rodDataDir[MAXRODS][PATHNAME_LENGTH]; char rodGeneralDataDir[PATHNAME_LENGTH]; char errorFileName[PATHNAME_LENGTH]; char commonDataDir[PATHNAME_LENGTH]; char testingDataDir[PATHNAME_LENGTH]; char fpgaDataDir[PATHNAME_LENGTH]; char dspPrgDataDir[PATHNAME_LENGTH]; char listRingsDir[PATHNAME_LENGTH]; char moduleCfgDir[PATHNAME_LENGTH]; char histoDir[PATHNAME_LENGTH]; }; /****************************************************************************** * Global Variable Declarations * ******************************************************************************/ extern struct GLOBAL_VARIABLES global; /******************************************************************************/ #endif /* GLOBAL_DEFINITIONS_H */