diff --git a/Adwin.c.old b/Adwin.c.old deleted file mode 100644 index 2162312..0000000 --- a/Adwin.c.old +++ /dev/null @@ -1,1449 +0,0 @@ -/****************************************************************************************************** -* Collection of subroutines for the control of the ADwin measurement data acquisition -* -* Created : 22.08.1996 from Martin Hotze -* -* Modified: 01.04.1998 from HPB -******************************************************************* -* Version 1.00 M.S. 13.06.2001 Same function names as other adwin-developer driver -* Version 1.01 M.S. 07.08.2001 DeviceNo is now a variable (earlier version it was a define) -* Version 1.02 M.S. 17.05.2002 Five new functions (Get_Known_DeviceNo, Get_Known_USB_SerialNo, ADwin_Debug_Mode_Off, -* ADwin_Debug_Mode_On, GetFifo_Packed_Short, GetFifo_Packed_Long) -* -* Function of the DLL ADwin32(32-bit, respectively) -* ===================================================================== -* Attention! the file "ADWIN32.DLL" respectively have to be included in a -* subdirectory that can be accessed by Windows ( at best in " \windows" or "\winnt") -* in order to use these functions the program "ADwin9.btl" (or ADwin4.btl or ADwin5.btl or ADwin8.btl -* respectively) has to be loaded to -* the ADwin system! -* The DLL ADwin32.dll respectively include all functions necessary for -* the data transfer between PC and the ADwin system. -* -* To Change from ADwin.c ->ADwin.cpp use #include "stdafx.h" -*******************************************************************************************************/ - -//#include "stdafx.h" // necessary for MFC projects -#include "windows.h" -#include "Adwin.h" - - -#define kFailedToLoadDLLError 1 -#define kCouldNotFindFunction 1 - -/* The variable "DeviceNo" is declared and inizialized to the default value of 0x150. - This variable is responsible for all accesses to the ADwin-system(s). */ -short DeviceNo = 0x2; // Device number -int FirstTime = 1; - - -static HINSTANCE DLLHandle; -long (FAR PASCAL *Clear_Process_Ptr)(short ProcessNo, short Device_No); -long (FAR PASCAL *Boot_Ptr)(char my_FAR *Filename, short Device_No, long Memsize, short msgbox); -short (FAR PASCAL *Load_Process_Ptr)(char my_FAR *Filename, short Device_No, short msgbox); -short (FAR PASCAL *Start_Process_Ptr)(short Index, short Device_No); -short (FAR PASCAL *Stop_Process_Ptr)(short Index, short Device_No); -short (FAR PASCAL *Set_Par_Ptr)(short Index, long Value, short Device_No); -short (FAR PASCAL *Set_FPar_Ptr)(short Index, float Value, short Device_No); -long (FAR PASCAL *Get_Par_Ptr)(short Index, short Device_No); -float (FAR PASCAL *Get_FPar_Ptr)(short Index, short Device_No); -short (FAR PASCAL *Get_Data_Ptr)(void *Data, short typ, short DataNo, long Startindex, long Count ,short Device_No); -short (FAR PASCAL *Set_Data_Ptr)(void *Data, short typ, short DataNo, long Startindex, long Count ,short Device_No); -short (FAR PASCAL *Save_Fast_Ptr)(char my_FAR *Filename, short DataNo, long Startindex, long Count, short Mode, short Device_No); -short (FAR PASCAL *Get_Fifo_Ptr)(void *Data, short typ, short FifoNo, long Count ,short Device_No); -short (FAR PASCAL *Set_Fifo_Ptr)(void *Data, short typ, short FifoNo, long Count ,short Device_No); -long (FAR PASCAL *Get_Fifo_Count_Ptr)(short FifoNo, short Device_No); -long (FAR PASCAL *Get_Fifo_Empty_Ptr)(short FifoNo, short Device_No); -short (FAR PASCAL *Fifo_Clear_Ptr)(short FifoNo, short Device_No); -short (FAR PASCAL *Get_ADC_Ptr)(short Channel, short Device_No); -short (FAR PASCAL *Set_DAC_Ptr)(short Channel, unsigned short Value, short Device_No); -long (FAR PASCAL *Get_Digin_Ptr)(short Device_No); -short (FAR PASCAL *Set_Digout_Ptr)(short Value, short Device_No); -long (FAR PASCAL *Get_Digout_Ptr)(short Device_No); -short (FAR PASCAL *Auslastung_Ptr)(short Device_No); -short (FAR PASCAL *Workload_Ptr)(long Priority, short Device_No); -short (FAR PASCAL *ADTest_Version_Ptr)(short Device_No, short msgbox); -long (FAR PASCAL *AD_Memory_Ptr)(short Device_No); -long (FAR PASCAL *AD_Memory_all_Ptr)(short Mem_Spec,short Device_No); -short (FAR PASCAL *AD_Net_Connect_Ptr)(char my_FAR *Protocol, char my_FAR *Address, char my_FAR *Endpoint, char my_FAR *Password, long Message); -short (FAR PASCAL *AD_Net_Disconnect_Ptr)(void); -short (FAR PASCAL *ADProzessorTyp_Ptr)(short Device_No); -long (FAR PASCAL *AD_GetErrorCode_Ptr)(void); -char (FAR PASCAL *AD_GetErrorText_Ptr)(long ErrorCode, char *text, long lenght); -short (FAR PASCAL *Get_ADBPar_All_Ptr)(short Startindex, short Count, long *Array, short Device_No); -short (FAR PASCAL *Get_ADBFPar_All_Ptr)(short Startindex, short Count, float *Array, short Device_No); -long (FAR PASCAL *Get_Data_Length_Ptr)(short DataNo, short Device_No); -long (FAR PASCAL *ADSetLanguage_Ptr)(long language); -long (FAR PASCAL *GetData_String_Ptr)(char *Data, long MaxCount,short DataNo, short Device_No); -long (FAR PASCAL *String_Length_Ptr)(short DataNo, short Device_No); -long (FAR PASCAL *SetData_String_Ptr)(char *Data,short DataNo, short Device_No); -short (FAR PASCAL *GetData_Packed_Ptr)(void *Data, short Typ, short DataNo, long Startindex, long Count, short Device_No); -short (FAR PASCAL *Get_List_Ptr)(void *Destination,short typ, short Startindex, short proc,long Count, short Device_No); -short (FAR PASCAL *Set_List_Ptr)(void *Source,short typ,short Startindex, long Count, short Device_No); -short (FAR PASCAL *Start_Ptr)(short Index, short Device_No); -short (FAR PASCAL *Stop_Ptr)(short Index, short Device_No); -short (FAR PASCAL *Get_Known_Deviceno_Ptr)(short *Devices, long *Count_Devices); -long (FAR PASCAL *Get_Known_USB_SerialNo_Ptr)(long *SerialNo); -int (FAR PASCAL *ADwin_Debug_Mode_On_Ptr)(char my_FAR *Filename, long Size); -int (FAR PASCAL *ADwin_Debug_Mode_Off_Ptr)(void); - - /* Error message from the DLL On(1)/Off(0) */ -short message=1; /* Error message if funktion fails */ - /* Iserv, ADBPrLoad and Test. 0 = don't show error message */ - /* 1 = show error message */ - -/*************************************************/ -/* Load DLL and get the address of the function */ -/*************************************************/ -int LoadDLLIfNeeded(void) -{ - //If adwin32.dll handle exist, don't load pointers again - if (DLLHandle) - return 0; - - DLLHandle = LoadLibrary("adwin32.dll"); - if (DLLHandle == NULL) { - return kFailedToLoadDLLError; - } - if ((Boot_Ptr = (long (FAR PASCAL *)(char my_FAR *, short, long, short))GetProcAddress(DLLHandle,"ADboot"))==0) - goto FunctionNotFoundError; - if ((Load_Process_Ptr = (short (FAR PASCAL *)(char my_FAR *, short, short))GetProcAddress(DLLHandle,"ADBload"))==0) - goto FunctionNotFoundError; - if ((Start_Process_Ptr = (short (FAR PASCAL *)(short, short))GetProcAddress(DLLHandle,"ADB_Start"))==0) - goto FunctionNotFoundError; - if ((Stop_Process_Ptr = (short (FAR PASCAL *)(short, short))GetProcAddress(DLLHandle,"ADB_Stop"))==0) - goto FunctionNotFoundError; - if ((Set_Par_Ptr = (short (FAR PASCAL *)(short, long, short))GetProcAddress(DLLHandle,"Set_ADBPar"))==0) - goto FunctionNotFoundError; - if ((Set_FPar_Ptr = (short (FAR PASCAL *)(short, float, short))GetProcAddress(DLLHandle,"Set_ADBFPar"))==0) - goto FunctionNotFoundError; - if ((Get_Par_Ptr = (long (FAR PASCAL *)(short, short))GetProcAddress(DLLHandle,"Get_ADBPar"))==0) - goto FunctionNotFoundError; - if ((Get_FPar_Ptr = (float (FAR PASCAL *)(short, short))GetProcAddress(DLLHandle,"Get_ADBFPar"))==0) - goto FunctionNotFoundError; - if ((Get_Data_Ptr = (short (FAR PASCAL *)(void*, short, short, long, long, short))GetProcAddress(DLLHandle,"Get_Data"))==0) - goto FunctionNotFoundError; - if ((Set_Data_Ptr = (short (FAR PASCAL *)(void*, short, short, long, long, short))GetProcAddress(DLLHandle,"Set_Data"))==0) - goto FunctionNotFoundError; - if ((Save_Fast_Ptr = (short (FAR PASCAL *)(char my_FAR *, short, long, long, short, short))GetProcAddress(DLLHandle,"SaveFast"))==0) - goto FunctionNotFoundError; - if ((Get_Fifo_Ptr = (short (FAR PASCAL *)(void*, short, short, long, short))GetProcAddress(DLLHandle,"Get_Fifo"))==0) - goto FunctionNotFoundError; - if ((Set_Fifo_Ptr = (short (FAR PASCAL *)(void*, short, short, long, short))GetProcAddress(DLLHandle,"Set_Fifo"))==0) - goto FunctionNotFoundError; - if ((Get_Fifo_Count_Ptr = (long (FAR PASCAL *)(short, short))GetProcAddress(DLLHandle,"Get_Fifo_Count"))==0) - goto FunctionNotFoundError; - if ((Get_Fifo_Empty_Ptr = (long (FAR PASCAL *)(short, short))GetProcAddress(DLLHandle,"Get_Fifo_Empty"))==0) - goto FunctionNotFoundError; - if ((Fifo_Clear_Ptr = (short (FAR PASCAL *)(short, short))GetProcAddress(DLLHandle,"Clear_Fifo"))==0) - goto FunctionNotFoundError; - if ((Get_ADC_Ptr = (short (FAR PASCAL *)(short, short))GetProcAddress(DLLHandle,"Get_ADC"))==0) - goto FunctionNotFoundError; - if ((Set_DAC_Ptr = (short (FAR PASCAL *)(short, unsigned short, short))GetProcAddress(DLLHandle,"Set_DAC"))==0) - goto FunctionNotFoundError; - if ((Get_Digin_Ptr = (long (FAR PASCAL *)(short))GetProcAddress(DLLHandle,"Get_Digin"))==0) - goto FunctionNotFoundError; - if ((Set_Digout_Ptr = (short (FAR PASCAL *)(short, short))GetProcAddress(DLLHandle,"Set_Digout"))==0) - goto FunctionNotFoundError; - if ((Get_Digout_Ptr = (long (FAR PASCAL *)(short))GetProcAddress(DLLHandle,"Get_Digout"))==0) - goto FunctionNotFoundError; - if ((Auslastung_Ptr = (short (FAR PASCAL *)(short))GetProcAddress(DLLHandle,"AD_Auslastung"))==0) - goto FunctionNotFoundError; - if ((Workload_Ptr = (short (FAR PASCAL *)(long, short))GetProcAddress(DLLHandle,"AD_Workload"))==0) - goto FunctionNotFoundError; - if ((ADTest_Version_Ptr = (short (FAR PASCAL *)(short, short))GetProcAddress(DLLHandle,"ADTest_Version"))==0) - goto FunctionNotFoundError; - if ((AD_Memory_Ptr = (long (FAR PASCAL *)(short))GetProcAddress(DLLHandle,"AD_Memory"))==0) - goto FunctionNotFoundError; - if ((AD_Memory_all_Ptr = (long (FAR PASCAL *)(short, short))GetProcAddress(DLLHandle,"AD_Memory_all"))==0) - goto FunctionNotFoundError; - if ((AD_Net_Connect_Ptr = (short (FAR PASCAL *)(char my_FAR *, char my_FAR *, char my_FAR *, char my_FAR *, long))GetProcAddress(DLLHandle,"AD_Net_Connect"))==0) - goto FunctionNotFoundError; - if ((AD_Net_Disconnect_Ptr = (short (FAR PASCAL *)(void))GetProcAddress(DLLHandle,"AD_Net_Disconnect"))==0) - goto FunctionNotFoundError; - if ((AD_GetErrorCode_Ptr = (long (FAR PASCAL *)(void))GetProcAddress(DLLHandle,"ADGetErrorCode"))==0) - goto FunctionNotFoundError; - if ((AD_GetErrorText_Ptr = (char (FAR PASCAL *)(long, char *, long))GetProcAddress(DLLHandle,"ADGetErrorText"))==0) - goto FunctionNotFoundError; - if ((Get_ADBPar_All_Ptr = (short (FAR PASCAL *)(short, short, long *, short))GetProcAddress(DLLHandle,"Get_ADBPar_All"))==0) - goto FunctionNotFoundError; - if ((Get_ADBFPar_All_Ptr = (short (FAR PASCAL *)(short, short, float *, short))GetProcAddress(DLLHandle,"Get_ADBFPar_All"))==0) - goto FunctionNotFoundError; - if ((Get_Data_Length_Ptr = (long (FAR PASCAL *)(short, short))GetProcAddress(DLLHandle,"Get_Data_Length"))==0) - goto FunctionNotFoundError; - if ((ADSetLanguage_Ptr = (long (FAR PASCAL *)(long))GetProcAddress(DLLHandle,"ADSetLanguage"))==0) - goto FunctionNotFoundError; - if ((GetData_String_Ptr = (long (FAR PASCAL *)(char *, long, short, short))GetProcAddress(DLLHandle,"Get_Data_String"))==0) - goto FunctionNotFoundError; - if ((String_Length_Ptr = (long (FAR PASCAL *)(short, short))GetProcAddress(DLLHandle,"Get_Data_String_Length"))==0) - goto FunctionNotFoundError; - if ((SetData_String_Ptr = (long (FAR PASCAL *)(char *, short, short))GetProcAddress(DLLHandle,"Set_Data_String"))==0) - goto FunctionNotFoundError; - if ((GetData_Packed_Ptr = (short (FAR PASCAL *)(void *, short, short, long, long, short))GetProcAddress(DLLHandle,"Get_Data_packed"))==0) - goto FunctionNotFoundError; - if ((ADProzessorTyp_Ptr = (short (FAR PASCAL *)(short Device_No))GetProcAddress(DLLHandle,"ProzessorTyp"))==0) - goto FunctionNotFoundError; - if ((Clear_Process_Ptr = (long (FAR PASCAL *)(short, short))GetProcAddress(DLLHandle,"Clear_Process"))==0) - goto FunctionNotFoundError; - if ((Get_List_Ptr = (short (FAR PASCAL *)(void *, short, short, short, long, short))GetProcAddress(DLLHandle,"Get_List"))==0) - goto FunctionNotFoundError; - if ((Set_List_Ptr = (short (FAR PASCAL *)(void *, short, short, long, short))GetProcAddress(DLLHandle,"Set_List"))==0) - goto FunctionNotFoundError; - if ((Start_Ptr = (short (FAR PASCAL *)(short, short))GetProcAddress(DLLHandle,"Start"))==0) - goto FunctionNotFoundError; - if ((Stop_Ptr = (short (FAR PASCAL *)(short, short))GetProcAddress(DLLHandle,"Stop"))==0) - goto FunctionNotFoundError; - if ((Get_Known_Deviceno_Ptr = (short (FAR PASCAL *)(short *, long *))GetProcAddress(DLLHandle,"Get_Known_Deviceno"))==0) - goto FunctionNotFoundError; - if ((Get_Known_USB_SerialNo_Ptr = (long (FAR PASCAL *)(long *))GetProcAddress(DLLHandle,"Get_Known_USB_SerialNo"))==0) - goto FunctionNotFoundError; - if ((ADwin_Debug_Mode_On_Ptr = (int (FAR PASCAL *)(char my_FAR *, long))GetProcAddress(DLLHandle,"adwin_debug_mode_on"))==0) - goto FunctionNotFoundError; - if ((ADwin_Debug_Mode_Off_Ptr = (int (FAR PASCAL *)(void))GetProcAddress(DLLHandle,"adwin_debug_mode_off"))==0) - goto FunctionNotFoundError; - - return 0; - -/* Error handling */ -FunctionNotFoundError: - if (FirstTime==1) - { - MessageBox(NULL, "You need a new Version of your ADwin32.dll!\nAt least ADwin32.dll from 14.5.2001!\nYour ADwin32.dll will removed!","ADwin32.dll to old!", MB_ICONWARNING); - FirstTime = 0; /* No more messages */ - } - FreeLibrary(DLLHandle); /* Remove the DLL */ - DLLHandle = 0; - - return kCouldNotFindFunction; -} - -/*****************************************/ -/* Connection code to the DLL functions */ -/*****************************************/ - - -/* Down-loads the operating system (BTL-file) to the ADwin-System */ -/* ============================================================================== */ -long Iserv(char my_FAR *Filename, long Memsize) -{ - long dllLoadError; - if ((dllLoadError = (long)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Boot_Ptr)(Filename, DeviceNo, Memsize, message); /* Boot the ADwin card */ -} - -/* Down-loads the operating system (BTL-file) to the ADwin-System */ -/* ============================================================================== */ -long Boot(char my_FAR *Filename, long Memsize) -{ - long dllLoadError; - if ((dllLoadError = (long)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (Iserv(Filename, Memsize)); /* Boot the ADwin card */ -} - -long ADboot(char my_FAR *Filename, short DeviceNo1, long Memsize) -{ - long dllLoadError; - if ((dllLoadError = (long)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Boot_Ptr)(Filename, DeviceNo1, Memsize, message); /* Boot the ADwin card */ -} - -/* Loads an ADbasic-process (a bin file generated by ADbasic) to the ADwin board */ -/* ============================================================================== */ -short ADBPrLoad(char my_FAR *Filename) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Load_Process_Ptr)(Filename, DeviceNo, message); /* Load bin file */ -} - -/* Loads an ADbasic-process (a bin file generated by ADbasic) to the ADwin board */ -/* ============================================================================== */ -short ADBload(char my_FAR *Filename,short DeviceNo1,short msgbox) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Load_Process_Ptr)(Filename, DeviceNo1, msgbox); /* Load bin file */ -} - -/* Loads an ADbasic-process (a bin file generated by ADbasic) to the ADwin board */ -/* ============================================================================== */ -short Load_Process(char my_FAR *Filename) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Load_Process_Ptr)(Filename, DeviceNo, message); /* Load bin file */ -} - -/* Starts process number "ProcessNo" on the ADwin-System */ -/* ============================================================================== */ -short ADBStart (short ProcessNo) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Start_Process_Ptr)(ProcessNo, DeviceNo); /* Start process */ -} - -/* Starts process number "ProcessNo" on the ADwin-System */ -/* ============================================================================== */ -short Start_Process(short ProcessNo) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Start_Process_Ptr)(ProcessNo, DeviceNo); /* Start process */ -} - -/* Stops process number "ProcessNo" on the ADwin-System */ -/* ============================================================================== */ -short ADBStop (short ProcessNo) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Stop_Process_Ptr)(ProcessNo, DeviceNo); /* Stop process */ -} - -/* Stops process number "ProcessNo" on the ADwin-System */ -/* ============================================================================== */ -short Stop_Process(short ProcessNo) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Stop_Process_Ptr)(ProcessNo, DeviceNo); /* Stop process */ -} - -/* Sets a parameter (PAR_"Index") on the ADwin-System to "Value" */ -/* ============================================================================== */ -short SetPar (short Index, long Value) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Set_Par_Ptr)(Index, Value, DeviceNo); /* Set parameter */ -} - -/* Sets a parameter (PAR_"Index") on the ADwin-System to "Value" */ -/* ============================================================================== */ -short Set_Par (short Index, long Value) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Set_Par_Ptr)(Index, Value, DeviceNo); /* Set parameter */ -} - -/* Sets a float parameter (FPAR_"Index") on the ADwin-System to "Value" */ -/* ============================================================================== */ -short SetFPar (short Index, float Value) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Set_FPar_Ptr)(Index, Value, DeviceNo); /* Set float parameter */ -} - -/* Sets a parameter (FPAR_"Index") on the ADwin-System to "Value" */ -/* ============================================================================== */ -short Set_FPar (short Index, float Value) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Set_FPar_Ptr)(Index, Value, DeviceNo); /* Set float parameter */ -} - -/* Returns the value of parameter (PAR_"Index") from the ADwin-System */ -/* ============================================================================== */ -long GetPar(short Index) -{ - long dllLoadError; - if ((dllLoadError = (long)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Get_Par_Ptr)(Index,DeviceNo); /* Get parameter */ -} - -/* Returns the value of parameter (PAR_"Index") from the ADwin-System */ -/* ============================================================================== */ -long Get_Par(short Index) -{ - long dllLoadError; - if ((dllLoadError = (long)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Get_Par_Ptr)(Index,DeviceNo); /* Get parameter */ -} - -/* Returns float value of parameter (FPAR_"Index") from the ADwin-System */ -/* ============================================================================== */ -float GetFPar(short Index) -{ - int dllLoadError; - if ((dllLoadError = LoadDLLIfNeeded())!=0) - return (float)dllLoadError; - - return (*Get_FPar_Ptr)(Index, DeviceNo); /* Get float parameter */ -} - -/* Returns float value of parameter (FPAR_"Index") from the ADwin-System */ -/* ============================================================================== */ -float Get_FPar(short Index) -{ - int dllLoadError; - if ((dllLoadError = LoadDLLIfNeeded())!=0) - return (float)dllLoadError; - - return (*Get_FPar_Ptr)(Index, DeviceNo); /* Get float parameter */ -} - -/* Element/e aus einem ADbasic Datensatz vom Transputer holen. - Übergabe in short ARRAY / wird in Doku nicht mehr beschrieben */ -/* ==============================================================================*/ -short GetData(short DataNo, short Data[], long Startindex, long Count ) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Get_Data_Ptr)(Data, 1, DataNo, Startindex, Count, DeviceNo); /* Datensatz holen / get array of data */ -} - - -/* Returns array-element(s) of long-type from ADwin-System-array (DATA_"DataNo") */ -/* ============================================================================== */ -short GetlData(short DataNo, long Data[], long Startindex, long Count) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Get_Data_Ptr)(Data, 2, DataNo, Startindex, Count, DeviceNo); -} - -/* Returns array-element(s) of long-type from ADwin-System-array (DATA_"DataNo") */ -/* ============================================================================== */ -short GetData_Long (short DataNo, long Data[], long Startindex, long Count) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Get_Data_Ptr)(Data, 2, DataNo, Startindex, Count, DeviceNo); -} - -/* Returns array-element(s) of double-type from ADwin-System-array (DATA_"DataNo") */ -/* ============================================================================== */ -short GetData_Double (short DataNo, double Data[],long Startindex, long Count) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Get_Data_Ptr)(Data, 6, DataNo, Startindex, Count, DeviceNo); -} - -/* Returns array-element(s) of float-type from ADwin-System-array (DATA_"DataNo") */ -/* ============================================================================== */ -short GetfData(short DataNo, float Data[], long Startindex, long Count) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Get_Data_Ptr)(Data, 5, DataNo, Startindex, Count, DeviceNo); -} - - -/* Returns array-element(s) of float-type from ADwin-System-array (DATA_"DataNo") */ -/* ============================================================================== */ -short GetData_Float (short DataNo, float Data[], long Startindex, long Count) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Get_Data_Ptr)(Data, 5, DataNo, Startindex, Count, DeviceNo); -} - -/* Sets array-element(s) of ADwin-System from short-array */ -/* ============================================================================== */ -short SetData(short DataNo, short Data[], long Startindex, long Count) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Set_Data_Ptr)(Data, 1, DataNo, Startindex, Count, DeviceNo); -} - -/* Sets array-element(s) of ADwin-System from long-array */ -/* ============================================================================== */ -short SetlData(short DataNo, long Data[], long Startindex, long Count) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Set_Data_Ptr)(Data, 2, DataNo, Startindex, Count, DeviceNo); -} - -/* Sets array-element(s) of ADwin-System from long-array */ -/* ============================================================================== */ -short SetData_Long(short DataNo, long Data[], long Startindex, long Count) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Set_Data_Ptr)(Data, 2, DataNo, Startindex, Count, DeviceNo); -} - -/* Sets array-element(s) of ADwin-System from double-array */ -/* ============================================================================== */ -short SetData_Double(short DataNo, double Data[], long Startindex, long Count) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Set_Data_Ptr)(Data, 6, DataNo, Startindex, Count, DeviceNo); -} - -/* Sets array-element(s) of ADwin-System from float-array */ -/* ============================================================================== */ -short SetfData(short DataNo, float Data[], long Startindex, long Count) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Set_Data_Ptr)(Data, 5, DataNo, Startindex, Count, DeviceNo); -} - -/* Sets array-element(s) of ADwin-System from float-array */ -/* =============================================================================== */ -short SetData_Float(short DataNo, float Data[], long Startindex, long Count) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Set_Data_Ptr)(Data, 5, DataNo, Startindex, Count, DeviceNo); -} - -/* Writes array-elements of ADwin-System immediately to harddisk */ -/* ============================================================================ */ -short Data2File(char my_FAR *Filename, short DataNo, long Startindex, long Count, short Mode) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Save_Fast_Ptr)(Filename, DataNo, Startindex, Count, Mode, DeviceNo); -} - -/* Fetching the short-element(s) from a ADwin-System FIFO */ -/* ============================================================================== */ -short GetFifo(short FifoNo, short Data[], long Count) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Get_Fifo_Ptr)(Data, 1, FifoNo, Count, DeviceNo); -} - -/* Fetching the long-element(s) from a ADwin-System FIFO */ -/* ============================================================================== */ -short GetlFifo(short FifoNo, long Data[], long Count) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Get_Fifo_Ptr)(Data, 2, FifoNo, Count, DeviceNo); -} - -/* Fetching the long-element(s) from a ADwin-System FIFO */ -/* ============================================================================== */ -short GetFifo_Long(short FifoNo, long Data[], long Count) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Get_Fifo_Ptr)(Data, 2, FifoNo, Count, DeviceNo); -} - -/* Fetching the double-element(s) from a ADwin-System FIFO */ -/* ============================================================================== */ -short GetFifo_Double(short FifoNo, double Data[], long Count) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Get_Fifo_Ptr)(Data, 6, FifoNo, Count, DeviceNo); -} - -/* Fetching the float-element(s) from a ADwin-System FIFO */ -/* ============================================================================== */ -short GetfFifo(short FifoNo, float Data[], long Count) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Get_Fifo_Ptr)(Data, 5, FifoNo, Count, DeviceNo); -} - -/* Fetching the float-element(s) from a ADwin-System FIFO */ -/* ============================================================================== */ -short GetFifo_Float(short FifoNo, float Data[], long Count) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Get_Fifo_Ptr)(Data, 5, FifoNo, Count, DeviceNo); -} - -/* Sets FIFO-element(s) of ADwin-System from short-array */ -/* ============================================================================== */ -short SetFifo(short FifoNo, short Data[], long Count) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Set_Fifo_Ptr)(Data, 1, FifoNo, Count, DeviceNo); -} - -/* Sets FIFO-element(s) of ADwin-System from long-array */ -/* ============================================================================== */ -short SetlFifo(short FifoNo, long Data[], long Count) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Set_Fifo_Ptr)(Data, 2, FifoNo, Count, DeviceNo); -} - -/* Sets FIFO-element(s) of ADwin-System from long-array */ -/* ============================================================================== */ -short SetFifo_Long(short FifoNo, long Data[], long Count) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Set_Fifo_Ptr)(Data, 2, FifoNo, Count, DeviceNo); -} - -/* Sets FIFO-element(s) of ADwin-System from double-array */ -/* ============================================================================== */ -short SetFifo_Double(short FifoNo, double Data[], long Count) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Set_Fifo_Ptr)(Data, 6, FifoNo, Count, DeviceNo); -} - -/* Sets FIFO-element(s) of ADwin-System from float-array */ -/* ============================================================================== */ -short SetfFifo(short FifoNo, float Data[], long Count) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Set_Fifo_Ptr)(Data, 5, FifoNo, Count, DeviceNo); -} - -/* Sets FIFO-element(s) of ADwin-System from float-array */ -/* ============================================================================== */ -short SetFifo_Float(short FifoNo, float Data[], long Count) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Set_Fifo_Ptr)(Data, 5, FifoNo, Count, DeviceNo); -} - -/* Getting the number of elements in the FIFO */ -/* ============================================================================== */ -long GetFifoCount(short FifoNo) -{ - long dllLoadError; - if ((dllLoadError = (long)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Get_Fifo_Count_Ptr)(FifoNo, DeviceNo); -} - -/* Getting the number of elements in the FIFO */ -/* ============================================================================== */ -long Fifo_Full(short FifoNo) -{ - long dllLoadError; - if ((dllLoadError = (long)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Get_Fifo_Count_Ptr)(FifoNo, DeviceNo); -} - -/* Returns number of free elements in FIFO */ -/* ============================================================================== */ -long GetFifoEmpty(short FifoNo) -{ - long dllLoadError; - if ((dllLoadError = (long)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Get_Fifo_Empty_Ptr)(FifoNo, DeviceNo); -} - -/* Returns number of free elements in FIFO */ -/* ============================================================================== */ -long Fifo_Empty (short FifoNo) -{ - long dllLoadError; - if ((dllLoadError = (long)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Get_Fifo_Empty_Ptr)(FifoNo, DeviceNo); -} - -/* Initiats read and write pointer of FIFO */ -/* ============================================================================== */ -short ClearFifo (short FifoNo) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Fifo_Clear_Ptr)(FifoNo, DeviceNo); -} - -/* Initiats read and write pointer of FIFO */ -/* ============================================================================== */ -short Fifo_Clear (short FifoNo) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Fifo_Clear_Ptr)(FifoNo, DeviceNo); -} - -/* Returns measured value of analog input channel */ -/* ============================================================================== */ -unsigned short ADC(short Value) -{ - unsigned short dllLoadError; - if ((dllLoadError = (unsigned short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Get_ADC_Ptr)(Value, DeviceNo); /* Messergebnis abholen */ -} - - -/* Sets analog output "Channel" to value "Value" (in digits) */ -/* ============================================================================== */ -short SetDAC(short Channel, unsigned short Value) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Set_DAC_Ptr)(Channel, Value, DeviceNo); -} - -/* Sets analog output "Channel" to value "Value" (in digits) */ -/* ============================================================================== */ -short DAC(short Channel, unsigned short Value) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Set_DAC_Ptr)(Channel, Value, DeviceNo); -} - -/* Returns state of digital inputs (bits 0...15) */ -/* ============================================================================== */ -long DigIn() -{ - long dllLoadError; - if ((dllLoadError = (long)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Get_Digin_Ptr)(DeviceNo); /* Ergebnis abholen */ -} - -/* Returns state of digital inputs (bits 0...15) */ -/* ============================================================================== */ -long Get_Digin() -{ - long dllLoadError; - if ((dllLoadError = (long)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Get_Digin_Ptr)(DeviceNo); /* Ergebnis abholen */ -} - -/* Outputs the value which is found in "Value" on the digital outputs */ -/* ============================================================================== */ -short SetDigOut (short Value) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Set_Digout_Ptr)(Value, DeviceNo); -} - -/* Outputs the value which is found in "Value" on the digital outputs */ -/* ============================================================================== */ -short Set_Digout (short Value) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Set_Digout_Ptr)(Value, DeviceNo); -} - -/* Returning the value of the digital outputs */ -/* ============================================================================== */ -long DigOut() -{ - long dllLoadError; - if ((dllLoadError = (long)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Get_Digout_Ptr)(DeviceNo); /* Ergebnis abholen */ -} - -/* Returning the value of the digital outputs */ -/* ============================================================================== */ - -long Get_Digout() -{ - long dllLoadError; - if ((dllLoadError = (long)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Get_Digout_Ptr)(DeviceNo); /* Ergebnis abholen */ -} - -/* Returns how busy the CPU is (processor usage in percent) */ -/* ============================================================================== */ -short Auslast() -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Auslastung_Ptr)(DeviceNo); /* Ergebnis abholen */ -} - -/* Returns how busy the CPU is (processor usage in percent) */ -/* ============================================================================== */ -short Workload(long Priority) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Workload_Ptr)(Priority, DeviceNo); /* Ergebnis abholen */ -} - -/* Checks if the CPU is accessible (previously booted and running) */ -/* ============================================================================== */ -short Test() -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*ADTest_Version_Ptr)(DeviceNo, message); -} - -/* Checks if the CPU is accessible (previously booted and running) */ -/* ============================================================================== */ -short Test_Version() -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*ADTest_Version_Ptr)(DeviceNo, message); -} - -/* checks the momentary free memory of the ADwin-System return value is the */ -/* free memory in byte only for T4,T5 and T8 */ -/* ============================================================================== */ -long Freemem() -{ - long dllLoadError; - if ((dllLoadError = (long)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*AD_Memory_Ptr)(DeviceNo); /* Get Freemem */ -} - -/* Returns value of free memory from the ADwin-9 System(in bytes) */ -/* ============================================================================== */ -long Freemem_T9(short Mem_Spec) -{ - long dllLoadError; - if ((dllLoadError = (long)LoadDLLIfNeeded())!=0) - return dllLoadError; - - switch(Mem_Spec) - { - case 0: - return (*AD_Memory_Ptr)(DeviceNo); /* T2, T4, T5, T8 */ - case 1: - return ((*AD_Memory_all_Ptr)(Mem_Spec, DeviceNo)*6); /* T9-PM */ - case 3: - case 4: - return ((*AD_Memory_all_Ptr)(Mem_Spec, DeviceNo)*4); /* T9-DM_Local, T9-DM_Extern */ - default: - return 255; - } -} - -/* Returns value of free memory from the ADwin-2, -4, -5 ,-8 and -9 System(in bytes) */ -/* ================================================================================= */ -long Free_Mem(short Mem_Spec) -{ - long dllLoadError; - if ((dllLoadError = (long)LoadDLLIfNeeded())!=0) - return dllLoadError; - - switch(Mem_Spec) - { - case 0: - return (*AD_Memory_Ptr)(DeviceNo); /* T2, T4, T5, T8 */ - case 1: - return ((*AD_Memory_all_Ptr)(Mem_Spec, DeviceNo)*6); /* T9-PM */ - case 3: - case 4: - return ((*AD_Memory_all_Ptr)(Mem_Spec, DeviceNo)*4); /* T9-DM_Local, T9-DM_Extern */ - default: - return 255; - } -} - -/* Error messages for Test, ADBload, Boot & Net_Connect 0/1 -> (off/on) */ -/* ============================================================================== */ -void ErrMessage(short OnOff) -{ - message=OnOff; -} - -/* Error messages for Test, ADBload, Boot & Net_Connect 0/1 -> (off/on) */ -/* ============================================================================== */ -void Show_Errors(short OnOff) -{ - message=OnOff; -} - -/* Gets access to the ADwin board in another server via network. */ -/* On this server the program ADserver has to run, which will be provided */ -/* together with ADbasic. */ -/* ============================================================================== */ -short Net_Connect(char my_FAR *Protocol, char my_FAR *Address, char my_FAR *Endpoint, char my_FAR *Password) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*AD_Net_Connect_Ptr)(Protocol, Address, Endpoint, Password, message); -} - -/* Disconnects network access to the ADwin-card */ -/* in another server */ -/* ============================================================================== */ -short Net_Disconnect() -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*AD_Net_Disconnect_Ptr)(); -} - -/* Gets the error code of the last error occured */ -/* ============================================================================== */ -long Get_Last_Error() -{ - long dllLoadError; - if ((dllLoadError = (long)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*AD_GetErrorCode_Ptr)(); -} - -/* Gets the error text of the "Last error" */ -/* ============================================================================== */ -char* Get_Last_Error_Text(long Last_Error) -{ - long merker; - static char Fehlertext[255]; - short dllLoadError; - - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return "dllLoadError in Get_Last_Error_Text"; - - merker = sizeof(Fehlertext); - (*AD_GetErrorText_Ptr)(Last_Error, Fehlertext, merker); - - return Fehlertext; - -} - -/* Returns the Processortype */ -/* ============================================================================== */ -short Processor_Type() -{ - short merker,Processor_Type; - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - merker = (*ADProzessorTyp_Ptr)(DeviceNo); - Processor_Type = merker; - - if (merker == 146) - Processor_Type = 5; - if (merker == 1000) - Processor_Type = 9; - // The other processor types are returned direct with the correct number - - return (Processor_Type); -} - -/* Clear the Process */ -/* ============================================================================== */ -long Clear_Process(short ProcessNo) -{ - long dllLoadError; - if ((dllLoadError = (long)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Clear_Process_Ptr)(ProcessNo,DeviceNo); -} - -/* Returns the Processstatus */ -/* ============================================================================== */ -long Process_Status(short ProcessNo) -{ - long ProcessStatus; - short erg; - - erg = (short)(-100 + ProcessNo); - ProcessStatus = Get_Par(erg); - - return (ProcessStatus); -} - -/* Gets a block of ADwin long parameters into a long array */ -/* ============================================================================== */ -short Get_Par_Block(long Array[], short Startindex, short Count) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Get_ADBPar_All_Ptr)(Startindex, Count, Array, DeviceNo); -} - -/* Gets a block of ADwin integer parameters into a long array */ -/* ============================================================================== */ -short Get_FPar_Block(float Array[], short Startindex, short Count) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Get_ADBFPar_All_Ptr)(Startindex, Count, Array, DeviceNo); -} - -/* Gets all 80 long parameters (Par_1 - Par_80) into a long array */ -/* ============================================================================== */ -short Get_Par_All(long Array[]) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Get_ADBPar_All_Ptr)(1, 80, Array, DeviceNo); -} - -/* Gets all 80 float parameters (Par_1 - Par_80) into a long array */ -/* ============================================================================== */ -short Get_FPar_All(float Array[]) -{ - short dllLoadError; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - return (*Get_ADBFPar_All_Ptr)(1, 80, Array, DeviceNo); -} - -/* Gets all 80 float parameters (FPar_1 - FPar_80) into a double array */ -/* ============================================================================== */ -short Get_FPar_All_Double(double Array[]) -{ - short res; - float fArray[80]; - short dllLoadError, i; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - res = (*Get_ADBFPar_All_Ptr)(1, 80, fArray, DeviceNo); - - for (i=0; i<80; i++) - { - Array[i] = fArray[i]; - } - - return res; -} - -/* Gets a block of ADwin float parameters into a double array */ -/* ============================================================================== */ -short Get_FPar_Block_Double(double Array[], short Startindex, short Count) -{ - short res; - float fArray[80]; - short dllLoadError, i; - if ((dllLoadError = (short)LoadDLLIfNeeded())!=0) - return dllLoadError; - - res = (*Get_ADBFPar_All_Ptr)(Startindex, Count, fArray, DeviceNo); - - for (i=0; i -#include "Scan.h" -#include -#include "GUIDesign.h" -#include "GUIDesign2.h" -#include "AnalogSettings2.h" -#include "DigitalSettings2.h" - -//Clipboard for copy/paste functions -double TimeClip; -struct AnalogTableClip{ - int fcn; //fcn is an integer refering to a function to use. - // 0-step, 1-linear, 2- exp, 3- 'S' curve - double fval; //the final value - double tscale; //the timescale to approach final value - } AnalogClip[NUMBERANALOGCHANNELS+1]; -int DigClip[NUMBERDIGITALCHANNELS+1]; -ddsoptions_struct ddsclip; -extern int Active_DDS_PANEL; - -//****************************************************************** -int CVICALLBACK QuitCallback (int panel, int control, int event, - void *callbackData, int eventData1, int eventData2) -{ - switch (event) - { - case EVENT_COMMIT: - QuitUserInterface(1); - break; - } - return 0; -} - -//****************************************************************** - -void CVICALLBACK ANALOGSET_CALLBACK (int menuBar, int menuItem, void *callbackData, - int panel) -{ - ChangedVals=TRUE; - DisplayPanel(panelHandle2); -} -//****************************************************************** - -void CVICALLBACK DIGITALSET_CALLBACK (int menuBar, int menuItem, void *callbackData, - int panel) -{ - ChangedVals=TRUE; - DisplayPanel(panelHandle3); -} -//****************************************************************** - -void CVICALLBACK MENU_CALLBACK (int menuBar, int menuItem, void *callbackData, - int panel) -{ - switch(menuItem) - { - case MENU_FILE_SAVESET: - SaveSettings(); - break; - - case MENU_FILE_LOADSET: - LoadSettings(); - break; - - } -} - -//****************************************************************** -void LoadSettings(void) -{ - int status; - //If .ini exists, then open the file dialog. Else just open the file dialog. Add a method to load - //last used settings on program startup. - FILE *fpini; - char fname[100]="",c,fsavename[500]=""; - static char defaultdir[200]="C:\\UserDate\\Data"; - int i=0,j=0,k=0,inisize=0; - //Check if .ini file exists. Load it if it does. - if(!(fpini=fopen("gui.ini","r"))==NULL) - { - while (fscanf(fpini,"%c",&c) != -1) fname[inisize++] = c; //Read the contained name - } - fclose(fpini); - - status=FileSelectPopup (defaultdir, "*.pan", "", "Load Settings", VAL_LOAD_BUTTON, 0, 0, 1, 1,fsavename ); - if(!(status==0)) - { - RecallPanelState(PANEL, fsavename, 1); - LoadArrays(fsavename,strlen( fsavename)); - } - else - { - MessagePopup ("File Error", "No file was selected"); - } - DrawNewTable(0); - strcpy(defaultdir,""); - -} -//******************************************************************************************* -void LoadLastSettings(int check) -{ - //If .ini exists, then open the file dialog. Else just open the file dialog. Add a method to load - //last used settings on program startup. - FILE *fpini; - char fname[100]="",c,fsavename[500]="",loadname[100]=""; - int i=0,j=0,k=0,inisize=0; - //Check if .ini file exists. Load it if it does. - if(!(fpini=fopen("gui.ini","r"))==NULL) - { - while (fscanf(fpini,"%c",&c) != -1) fname[inisize++] = c; //Read the contained name - } - fclose(fpini); - - c=fname[inisize-1]; - strncpy(loadname,fname,inisize-2); - if((check==0)||(c==49)) // 49 is the ascii code for "1" - { - RecallPanelState(PANEL, loadname, 1); - LoadArrays(fname,strlen( loadname)); - } - //SetWindowText(cWnd,fname); Figure out this API call some day - DrawNewTable(0); -} -//********************************************************************************************* - -void SaveSettings(void) -{ - // Save settings: First look for file .ini This will be a simple 1 line file staating the name of the last file - //saved. Load this up and use as the starting name in the file dialog. - FILE *fpini; - char fname[100]="",c,fsavename[500]=""; - static char defaultdir[200]="C:\\UserDate\\Data"; - int i=0,j=0,k=0,inisize=0,status,loadonboot=0; - //Check if .ini file exists. Load it if it does. - if(!(fpini=fopen("gui.ini","r"))==NULL) // if "proto.ini" exists, then read it Just contains a filename. - { //If not, do nothing - while (fscanf(fpini,"%c",&c) != -1) fname[inisize++] = c; //Read the contained name - } - fclose(fpini); - - status=FileSelectPopup (defaultdir, "*.pan", "", "Save Settings", VAL_SAVE_BUTTON, 0, 0, 1, 1,fsavename); - GetMenuBarAttribute (menuHandle, MENU_FILE_BOOTLOAD, ATTR_CHECKED, &loadonboot); - if(!(status==0)) - { - SavePanelState(PANEL, fsavename, 1); - if(!(fpini=fopen("gui.ini","w"))==NULL) - { - fprintf(fpini,fsavename); - fprintf(fpini,"\n%d",loadonboot); - } - fclose(fpini); - SaveArrays(fsavename, strlen(fsavename)); - } - else - { - MessagePopup ("File Error", "No file was selected"); - } - strcpy(defaultdir,""); -} -//********************************************************************* -int CVICALLBACK ANALOGTABLE_CALLBACK (int panel, int control, int event, - void *callbackData, int eventData1, int eventData2) -{ - int cx=0,cy=0,pixleft=0,pixtop=0; - Point cpoint={0,0}; - char buff[80]=""; - int leftbuttondown,rightbuttondown,keymod; - int panel_to_display; - - ChangedVals=TRUE; - switch (event) - { - case EVENT_LEFT_DOUBLE_CLICK: - cpoint.x=0;cpoint.y=0; - GetActiveTableCell(panelHandle, PANEL_ANALOGTABLE, &cpoint); - //now set the indicators in the control panel title..ie units - currentx=cpoint.x; - currenty=cpoint.y; - currentpage=GetPage(); - - if((currenty>NUMBERANALOGCHANNELS)&&(currenty<=NUMBERANALOGCHANNELS+NUMBERDDS)) { - Active_DDS_Panel=currenty-NUMBERANALOGCHANNELS; - - SetDDSControlPanel(Active_DDS_Panel); - panel_to_display = panelHandle6; - } - else { - - SetControlPanel(); - panel_to_display = panelHandle4; - - } - - sprintf(buff,"x:%d y:%d z:%d",currentx,currenty,currentpage); - SetPanelAttribute (panel_to_display, ATTR_TITLE, buff); - //Read the mouse position and open window there. - GetGlobalMouseState (&panelHandle, &pixleft, &pixtop, &leftbuttondown, - &rightbuttondown, &keymod); - SetPanelAttribute (panel_to_display, ATTR_LEFT, pixleft); - SetPanelAttribute (panel_to_display, ATTR_TOP, pixtop); - - DisplayPanel(panel_to_display); - - break; - } - return 0; -} -//******************************************************************************************** -int GetPage(void) -{ - return currentpage; - //Scan and find out what page we are on.... -} -//******************************************************************************************** - void DrawNewTable(int isdimmed) -//if isdimmed=0 Draw everything -//if isdimmed=1 Dim out appropriate columns.... -// Make isdimmed a global I guess... -// May 12, 2005: Updated to change color of cell that is active by a parameter scan. This cell (ANalog, Time or DDS) now -// turns dark yellow. might pick a better color. -{ - int i,j,k,m,cfcn,picmode,page,cmode,pic; - int analogtable_visible = 0; - int digtable_visible = 0; - double vlast=0,vnow=0; - int dimset=0,nozerofound,val; - - int ispicture=1,celltype=0; //celtype has 3 values. 0=Numerc, 1=String, 2=Picture - int ColourTable[25]={VAL_BLACK,VAL_GRAY,VAL_GRAY,VAL_GRAY,0x00B0B0B0,0x00B0B0B0,0x00B0B0B0,VAL_GRAY,VAL_GRAY,VAL_GRAY,0x00B0B0B0,0x00B0B0B0,0x00B0B0B0, - VAL_GRAY,VAL_GRAY,VAL_GRAY,0x00B0B0B0,0x00B0B0B0,0x00B0B0B0,VAL_GRAY,VAL_GRAY,VAL_GRAY,0x00B0B0B0,0x00B0B0B0,0x00B0B0B0}; - - Point pval={0,0}; - GetCtrlAttribute (panelHandle, PANEL_ANALOGTABLE, ATTR_VISIBLE, &analogtable_visible); - GetCtrlAttribute (panelHandle, PANEL_DIGTABLE, ATTR_VISIBLE, &digtable_visible); - SetCtrlAttribute (panelHandle, PANEL_ANALOGTABLE, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_DIGTABLE, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_TIMETABLE, ATTR_VISIBLE, 0); - page=GetPage(); - - GetCtrlVal(panelHandle, PANEL_TGL_NUMERICTABLE,&celltype); - if(celltype==2) {ispicture=1;} - else { ispicture=0;} - - CheckActivePages(); - if(ischecked[page]==0) - { - SetCtrlAttribute (panelHandle, PANEL_ANALOGTABLE, ATTR_DIMMED, 1); - SetCtrlAttribute (panelHandle, PANEL_DIGTABLE, ATTR_DIMMED, 1); - SetCtrlAttribute (panelHandle, PANEL_TIMETABLE, ATTR_DIMMED, 1); - } - else - { - SetCtrlAttribute (panelHandle, PANEL_ANALOGTABLE, ATTR_DIMMED, 0); - SetCtrlAttribute (panelHandle, PANEL_DIGTABLE, ATTR_DIMMED, 0); - SetCtrlAttribute (panelHandle, PANEL_TIMETABLE, ATTR_DIMMED, 0); - } - picmode=0; - for(i=1;i<=14;i++) - { - - SetTableCellAttribute (panelHandle, PANEL_TIMETABLE, MakePoint(i,1),ATTR_CELL_DIMMED, 0); - for(j=1;j<=NUMBERANALOGCHANNELS;j++) - { - SetTableCellAttribute (panelHandle, PANEL_ANALOGTABLE, MakePoint(i,j), - ATTR_CELL_TYPE, VAL_CELL_NUMERIC); - SetTableCellAttribute (panelHandle, PANEL_ANALOGTABLE, MakePoint(i,j), - ATTR_CTRL_VAL, AnalogTable[i][j][page].fval); - - SetTableCellAttribute (panelHandle, PANEL_ANALOGTABLE, MakePoint(i,j),ATTR_CELL_DIMMED, 0); - SetTableCellAttribute (panelHandle, PANEL_DIGTABLE, MakePoint(i,j),ATTR_CELL_DIMMED, 0); - cmode=AnalogTable[i][j][page].fcn; - vlast=AnalogTable[i-1][j][page].fval; - vnow=AnalogTable[i][j][page].fval; - - SetTableCellAttribute (panelHandle, PANEL_ANALOGTABLE,MakePoint(i,j), ATTR_TEXT_BGCOLOR,ColourTable[j]); - if(cmode==1) - { - if(vnow==0) - { - SetTableCellAttribute (panelHandle, PANEL_ANALOGTABLE,MakePoint(i,j), ATTR_TEXT_BGCOLOR,ColourTable[j]); - } - else - { - SetTableCellAttribute (panelHandle, PANEL_ANALOGTABLE,MakePoint(i,j), ATTR_TEXT_BGCOLOR,VAL_RED); - } - } - if(cmode==2) // linear ramp - { - SetTableCellAttribute (panelHandle, PANEL_ANALOGTABLE,MakePoint(i,j), ATTR_TEXT_BGCOLOR,VAL_GREEN); - } - if(cmode==3) // exponential ramp - { - SetTableCellAttribute (panelHandle, PANEL_ANALOGTABLE,MakePoint(i,j), ATTR_TEXT_BGCOLOR,VAL_BLUE); - } - if(cmode==4) // constant jerk function - { - SetTableCellAttribute (panelHandle, PANEL_ANALOGTABLE,MakePoint(i,j), ATTR_TEXT_BGCOLOR,VAL_MAGENTA); - } - if(cmode==5)// Sine wave output - { - SetTableCellAttribute (panelHandle, PANEL_ANALOGTABLE,MakePoint(i,j), ATTR_TEXT_BGCOLOR,VAL_CYAN); - } - if(cmode==6) - { - SetTableCellAttribute (panelHandle, PANEL_ANALOGTABLE,MakePoint(i,j), ATTR_TEXT_BGCOLOR,VAL_YELLOW); - - } - - - if(DigTableValues[i][j][page]==1) - { - SetTableCellAttribute (panelHandle, PANEL_DIGTABLE,MakePoint(i,j), ATTR_TEXT_BGCOLOR,VAL_RED); - } - else - { - SetTableCellVal (panelHandle, PANEL_DIGTABLE, MakePoint(i,j), 0); - SetTableCellAttribute (panelHandle, PANEL_DIGTABLE,MakePoint(i,j), ATTR_TEXT_BGCOLOR,ColourTable[j]); - } - //Done digital drawing. - } - -//***************update DDS row******************** -/*DDS1*/SetTableCellVal (panelHandle, PANEL_ANALOGTABLE, MakePoint(i,25), 0); - //if(ispicture==0) - { - SetTableCellVal(panelHandle,PANEL_ANALOGTABLE,MakePoint(i,25),ddstable[i][page].start_frequency); - } - SetTableCellAttribute (panelHandle, PANEL_ANALOGTABLE, MakePoint(i,25),ATTR_CELL_DIMMED, 0); - SetTableCellAttribute (panelHandle, PANEL_DIGTABLE, MakePoint(i,25),ATTR_CELL_DIMMED, 0); - - if (ddstable[i][page].amplitude == 0.0 || ddstable[i][page].is_stop) - { - //make grey - SetTableCellAttribute (panelHandle, PANEL_ANALOGTABLE,MakePoint(i,25), ATTR_TEXT_BGCOLOR,VAL_WHITE); - } - else - { - if (ddstable[i][page].start_frequency>ddstable[i][page].end_frequency) - { - //ramping down - SetTableCellAttribute (panelHandle, PANEL_ANALOGTABLE,MakePoint(i,25), ATTR_TEXT_BGCOLOR,VAL_BLUE); - } - else - { - //ramping up - SetTableCellAttribute (panelHandle, PANEL_ANALOGTABLE,MakePoint(i,25), ATTR_TEXT_BGCOLOR,VAL_GREEN); - } - } -/*DDS2*/SetTableCellVal (panelHandle, PANEL_ANALOGTABLE, MakePoint(i,26), 0); - //if(ispicture==0) - { - SetTableCellVal(panelHandle,PANEL_ANALOGTABLE,MakePoint(i,26),dds2table[i][page].start_frequency); - } - SetTableCellAttribute (panelHandle, PANEL_ANALOGTABLE, MakePoint(i,26),ATTR_CELL_DIMMED, 0); - SetTableCellAttribute (panelHandle, PANEL_DIGTABLE, MakePoint(i,26),ATTR_CELL_DIMMED, 0); - - if (dds2table[i][page].amplitude == 0.0 || dds2table[i][page].is_stop) - { - //make grey - SetTableCellAttribute (panelHandle, PANEL_ANALOGTABLE,MakePoint(i,26), ATTR_TEXT_BGCOLOR,VAL_WHITE); - } - else - { - if (dds2table[i][page].start_frequency>dds2table[i][page].end_frequency) - { - //ramping down - SetTableCellAttribute (panelHandle, PANEL_ANALOGTABLE,MakePoint(i,26), ATTR_TEXT_BGCOLOR,VAL_BLUE); - } - else - { - //ramping up - SetTableCellAttribute (panelHandle, PANEL_ANALOGTABLE,MakePoint(i,26), ATTR_TEXT_BGCOLOR,VAL_GREEN); - } - } -/*DDS3*/SetTableCellVal (panelHandle, PANEL_ANALOGTABLE, MakePoint(i,27), 0); - //if(ispicture==0) - { - SetTableCellVal(panelHandle,PANEL_ANALOGTABLE,MakePoint(i,27),dds3table[i][page].start_frequency); - } - SetTableCellAttribute (panelHandle, PANEL_ANALOGTABLE, MakePoint(i,27),ATTR_CELL_DIMMED, 0); - SetTableCellAttribute (panelHandle, PANEL_DIGTABLE, MakePoint(i,27),ATTR_CELL_DIMMED, 0); - - if (dds3table[i][page].amplitude == 0.0 || dds3table[i][page].is_stop) - { - //make grey - SetTableCellAttribute (panelHandle, PANEL_ANALOGTABLE,MakePoint(i,27), ATTR_TEXT_BGCOLOR,VAL_WHITE); - } - else - { - if (dds3table[i][page].start_frequency>dds3table[i][page].end_frequency) - { - //ramping down - SetTableCellAttribute (panelHandle, PANEL_ANALOGTABLE,MakePoint(i,27), ATTR_TEXT_BGCOLOR,VAL_BLUE); - } - else - { - //ramping up - SetTableCellAttribute (panelHandle, PANEL_ANALOGTABLE,MakePoint(i,27), ATTR_TEXT_BGCOLOR,VAL_GREEN); - } - } -//***************update DDS row******************** - - // update the times row - SetTableCellVal(panelHandle,PANEL_TIMETABLE,MakePoint(i,1),TimeArray[i][page]); - } - //now check if we need to dim out any columns(of timetable,AnalogTable and DigTable - if(isdimmed==1) - { - nozerofound=1; - for(i=1;i<=14;i++) - { - dimset=0; - if((nozerofound==0)||(TimeArray[i][page]==0)) - { - nozerofound=0; - dimset=1; - } - else if((nozerofound==1)&&(TimeArray[i][page]<0)) - { - dimset=1; - } - SetTableCellAttribute(panelHandle,PANEL_TIMETABLE,MakePoint(i,1),ATTR_CELL_DIMMED,dimset); - if(ispicture==0) {picmode=0;} - if(ispicture==1) {picmode=2;} - if(dimset==1) {picmode=2;} - - for(j=1;j<=NUMBERANALOGCHANNELS;j++) - { - SetTableCellAttribute (panelHandle, PANEL_ANALOGTABLE, MakePoint(i,j),ATTR_CELL_DIMMED, dimset); - SetTableCellAttribute (panelHandle, PANEL_DIGTABLE, MakePoint(i,j),ATTR_CELL_DIMMED, dimset); - SetTableCellAttribute (panelHandle, PANEL_ANALOGTABLE, MakePoint(i,j),ATTR_CELL_TYPE,picmode); - } - } - } - SetCtrlAttribute (panelHandle, PANEL_ANALOGTABLE, ATTR_VISIBLE, analogtable_visible); - SetCtrlAttribute (panelHandle, PANEL_DIGTABLE, ATTR_VISIBLE, digtable_visible); - SetCtrlAttribute (panelHandle, PANEL_TIMETABLE, ATTR_VISIBLE, 1); - - for(m=1;m<=14;m++) - { - SetTableCellAttribute(panelHandle,PANEL_TIMETABLE,MakePoint(m,1),ATTR_TEXT_BGCOLOR,VAL_WHITE); - } - - if((currentpage==PScan.Page)&&(PScan.Scan_Active==TRUE))//display the cell active for a parameter scan - { - switch(PScan.ScanMode) - { - case 0: - SetTableCellAttribute (panelHandle, PANEL_ANALOGTABLE, MakePoint(PScan.Column,PScan.Row),ATTR_TEXT_BGCOLOR, VAL_DK_YELLOW); - break; - case 1: - SetTableCellAttribute(panelHandle,PANEL_TIMETABLE,MakePoint(PScan.Column,1),ATTR_TEXT_BGCOLOR,VAL_DK_YELLOW); - break; - case 2: - SetTableCellAttribute (panelHandle, PANEL_ANALOGTABLE, MakePoint(PScan.Column,25),ATTR_TEXT_BGCOLOR, VAL_DK_YELLOW); - break; - } - } - - if(currentpage==10) - { - SetCtrlAttribute (panelHandle, PANEL_NUM_INSERTIONPAGE, ATTR_DIMMED, 0); - SetCtrlAttribute (panelHandle, PANEL_NUM_INSERTIONCOL, ATTR_DIMMED, 0); - } - else - { - SetCtrlAttribute (panelHandle, PANEL_NUM_INSERTIONPAGE, ATTR_DIMMED, 1); - SetCtrlAttribute (panelHandle, PANEL_NUM_INSERTIONCOL, ATTR_DIMMED, 1); - } - -} - -//************************************************************************************* -int CVICALLBACK TOGGLE1_CALLBACK (int panel, int control, int event, - void *callbackData, int eventData1, int eventData2) -{ - - switch (event) - { - case EVENT_COMMIT: - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE1, 1); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE2, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE3, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE4, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE5, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE6, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE7, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE8, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE9, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE10, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_1, ATTR_VISIBLE, 1); - SetCtrlAttribute (panelHandle, PANEL_LABEL_2, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_3, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_4, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_5, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_6, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_7, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_8, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_9, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_10, ATTR_VISIBLE, 0); - currentpage=1; - ChangedVals=TRUE; - DrawNewTable(isdimmed); - - - break; - } - return 0; -} - -int CVICALLBACK TOGGLE2_CALLBACK (int panel, int control, int event, - void *callbackData, int eventData1, int eventData2) -{ - switch (event) - { - case EVENT_COMMIT: - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE1, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE2, 1); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE3, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE4, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE5, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE6, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE7, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE8, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE9, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE10, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_1, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_2, ATTR_VISIBLE, 1); - SetCtrlAttribute (panelHandle, PANEL_LABEL_3, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_4, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_5, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_6, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_7, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_8, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_9, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_10, ATTR_VISIBLE, 0); - ChangedVals=TRUE; - currentpage=2; - DrawNewTable(isdimmed); - break; - } - return 0; -} - -int CVICALLBACK TOGGLE3_CALLBACK (int panel, int control, int event, - void *callbackData, int eventData1, int eventData2) -{ - switch (event) - { - case EVENT_COMMIT: - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE1, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE2, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE3, 1); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE4, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE5, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE6, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE7, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE8, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE9, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE10, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_1, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_2, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_3, ATTR_VISIBLE, 1); - SetCtrlAttribute (panelHandle, PANEL_LABEL_4, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_5, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_6, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_7, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_8, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_9, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_10, ATTR_VISIBLE, 0); - ChangedVals=TRUE; - currentpage=3; - DrawNewTable(isdimmed); - break; - } - return 0; -} - -int CVICALLBACK TOGGLE4_CALLBACK (int panel, int control, int event, - void *callbackData, int eventData1, int eventData2) -{ - switch (event) - { - case EVENT_COMMIT: - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE1, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE2, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE3, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE4, 1); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE5, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE6, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE7, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE8, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE9, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE10, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_1, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_2, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_3, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_4, ATTR_VISIBLE, 1); - SetCtrlAttribute (panelHandle, PANEL_LABEL_5, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_6, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_7, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_8, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_9, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_10, ATTR_VISIBLE, 0); - ChangedVals=TRUE; - currentpage=4; - DrawNewTable(isdimmed); - break; - } - return 0; -} - -int CVICALLBACK TOGGLE5_CALLBACK (int panel, int control, int event, - void *callbackData, int eventData1, int eventData2) -{ - switch (event) - { - case EVENT_COMMIT: - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE1, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE2, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE3, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE4, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE5, 1); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE6, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE7, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE8, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE9, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE10, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_1, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_2, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_3, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_4, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_5, ATTR_VISIBLE, 1); - SetCtrlAttribute (panelHandle, PANEL_LABEL_6, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_7, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_8, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_9, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_10, ATTR_VISIBLE, 0); - ChangedVals=TRUE; - currentpage=5; - DrawNewTable(isdimmed); - break; - } - return 0; -} - -int CVICALLBACK TOGGLE6_CALLBACK (int panel, int control, int event, - void *callbackData, int eventData1, int eventData2) -{ - switch (event) - { - case EVENT_COMMIT: - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE1, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE2, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE3, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE4, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE5, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE6, 1); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE7, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE8, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE9, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE10, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_1, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_2, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_3, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_4, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_5, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_6, ATTR_VISIBLE, 1); - SetCtrlAttribute (panelHandle, PANEL_LABEL_7, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_8, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_9, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_10, ATTR_VISIBLE, 0); - ChangedVals=TRUE; - currentpage=6; - DrawNewTable(isdimmed); - break; - } - return 0; -} - -int CVICALLBACK TOGGLE7_CALLBACK (int panel, int control, int event, - void *callbackData, int eventData1, int eventData2) -{ - switch (event) - { - case EVENT_COMMIT: - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE1, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE2, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE3, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE4, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE5, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE6, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE7, 1); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE8, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE9, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE10, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_1, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_2, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_3, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_4, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_5, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_6, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_7, ATTR_VISIBLE, 1); - SetCtrlAttribute (panelHandle, PANEL_LABEL_8, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_9, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_10, ATTR_VISIBLE, 0); - ChangedVals=TRUE; - currentpage=7; - DrawNewTable(isdimmed); - break; - } - return 0; -} - -int CVICALLBACK TOGGLE8_CALLBACK (int panel, int control, int event, - void *callbackData, int eventData1, int eventData2) -{ - switch (event) - { - case EVENT_COMMIT: - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE1, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE2, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE3, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE4, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE5, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE6, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE7, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE8, 1); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE9, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE10, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_1, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_2, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_3, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_4, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_5, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_6, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_7, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_8, ATTR_VISIBLE, 1); - SetCtrlAttribute (panelHandle, PANEL_LABEL_9, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_10, ATTR_VISIBLE, 0); - ChangedVals=TRUE; - currentpage=8; - DrawNewTable(isdimmed); - break; - } - return 0; -} - - -int CVICALLBACK TOGGLE9_CALLBACK (int panel, int control, int event, - void *callbackData, int eventData1, int eventData2) -{ - switch (event) - { - case EVENT_COMMIT: - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE1, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE2, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE3, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE4, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE5, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE6, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE7, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE8, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE9, 1); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE10, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_1, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_2, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_3, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_4, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_5, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_6, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_7, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_8, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_9, ATTR_VISIBLE, 1); - SetCtrlAttribute (panelHandle, PANEL_LABEL_10, ATTR_VISIBLE, 0); - ChangedVals=TRUE; - currentpage=9; - DrawNewTable(isdimmed); - break; - } - return 0; -} - - -int CVICALLBACK TOGGLE10_CALLBACK (int panel, int control, int event, - void *callbackData, int eventData1, int eventData2) -{ - switch (event) - { - case EVENT_COMMIT: - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE1, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE2, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE3, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE4, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE5, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE6, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE7, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE8, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE9, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE10, 1); - - SetCtrlAttribute (panelHandle, PANEL_LABEL_1, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_2, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_3, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_4, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_5, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_6, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_7, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_8, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_9, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_10, ATTR_VISIBLE, 1); - - ChangedVals=TRUE; - currentpage=10; - DrawNewTable(isdimmed); - break; - } - return 0; -} - - - -void CheckActivePages(void) -{ - int bool; - GetCtrlVal (panelHandle, PANEL_CHECKBOX, &bool); - ischecked[1]=bool; - GetCtrlVal (panelHandle, PANEL_CHECKBOX_2, &bool); - ischecked[2]=bool; - GetCtrlVal (panelHandle, PANEL_CHECKBOX_3, &bool); - ischecked[3]=bool; - GetCtrlVal (panelHandle, PANEL_CHECKBOX_4, &bool); - ischecked[4]=bool; - GetCtrlVal (panelHandle, PANEL_CHECKBOX_5, &bool); - ischecked[5]=bool; - GetCtrlVal (panelHandle, PANEL_CHECKBOX_6, &bool); - ischecked[6]=bool; - GetCtrlVal (panelHandle, PANEL_CHECKBOX_7, &bool); - ischecked[7]=bool; - GetCtrlVal (panelHandle, PANEL_CHECKBOX_8, &bool); - ischecked[8]=bool; - GetCtrlVal (panelHandle, PANEL_CHECKBOX_9, &bool); - ischecked[9]=bool; - GetCtrlVal (panelHandle, PANEL_CHECKBOX_10, &bool); - ischecked[10]=bool; - - -} -//*************************************************************************************************** - -int CVICALLBACK DIGTABLE_CALLBACK (int panel, int control, int event, - void *callbackData, int eventData1, int eventData2) -{ - int status=0,i_pict=0,page,digval; - Point pval={0,0}; - - ChangedVals=1; - page=GetPage(); - switch (event) - { - case EVENT_LEFT_DOUBLE_CLICK: - GetActiveTableCell(PANEL,PANEL_DIGTABLE,&pval); - //GetTableCellVal(PANEL,PANEL_DIGTABLE,pval,&i_pict); - digval=DigTableValues[pval.x][pval.y][page]; - if(digval==0) - { - // SetTableCellVal(PANEL,PANEL_DIGTABLE,pval,pic_don); - SetTableCellAttribute (panelHandle, PANEL_DIGTABLE,pval, ATTR_TEXT_BGCOLOR,VAL_RED); - DigTableValues[pval.x][pval.y][page]=1; - } - else - { - SetTableCellAttribute (panelHandle, PANEL_DIGTABLE,pval, ATTR_TEXT_BGCOLOR,VAL_GRAY); - //SetTableCellVal(PANEL,PANEL_DIGTABLE,pval,0); - DigTableValues[pval.x][pval.y][page]=0; - } - break; - } - return 0; -} -//*************************************************************************************************** -int CVICALLBACK TIMETABLE_CALLBACK (int panel, int control, int event, - void *callbackData, int eventData1, int eventData2) -{ - double dval,oldtime,ratio,tscaleold; - Point pval={0,0}; - int page,i,j; - int ctrlmode; - ChangedVals=1; - switch (event) - { - case EVENT_VAL_CHANGED: - //EVENT_VAL_CHANGED only seems to pick up the last changed values, or values changed using the - //controls (i.e. increment arrows). Similar problems with other events...reading all times(for the page) - // at a change event seems to work. - page=GetPage(); - - for(i=1;i<=14;i++) - { - oldtime=TimeArray[i][page]; - GetTableCellVal(PANEL,PANEL_TIMETABLE,MakePoint(i,1),&dval); - - TimeArray[i][page]=dval; - //now rescale the time scale for waveform fcn. Go over all 16 analog channels - ratio=dval/oldtime; - if(oldtime==0) {ratio=1;} - - for(j=1;j<=NUMBERANALOGCHANNELS;j++) - { - tscaleold=AnalogTable[i][j][page].tscale; // use this and next line to auto-scale the time - AnalogTable[i][j][page].tscale=tscaleold*ratio; - // AnalogTable[i][j][page].tscale=dval; //use this line to force timescale to period - } - - //set the delta time value for the dds array - // ddstable[i][page].delta_time = dval/1000; - - } - break; - case EVENT_LEFT_DOUBLE_CLICK: - isdimmed=0; - DrawNewTable(isdimmed); - break; - } - return 0; -} -//*************************************************************************************************** - -int CVICALLBACK CMD_RUN_CALLBACK (int panel, int control, int event, - void *callbackData, int eventData1, int eventData2) -{ - int repeat=0; - switch (event) - { - case EVENT_COMMIT: - PScan.Scan_Active=FALSE; - SaveLastGuiSettings(); - ChangedVals=TRUE; - scancount=0; - GetCtrlVal(panelHandle,PANEL_TOGGLEREPEAT,&repeat); - if(repeat==1) - { - SetCtrlAttribute (panelHandle, PANEL_TIMER, ATTR_ENABLED, 1); - //activate timer - } - else - { - SetCtrlAttribute (panelHandle, PANEL_TIMER, ATTR_ENABLED, 0); - //deactivate timer - } - RunOnce(); - break; - } - - return 0; -} -//********************************************************************************* -int CVICALLBACK CMD_SCAN_CALLBACK (int panel, int control, int event, - void *callbackData, int eventData1, int eventData2) -{ // basically a copy of CMD_RUN but activate SCAN flag, and reset flag counter -// maybe we should just integrate scan into run - int repeat=0; - switch (event) - { - case EVENT_COMMIT: - UpdateScanValue(TRUE); // sending value of 1 resets the scan counter. - PScan.Scan_Active=TRUE; - SaveLastGuiSettings(); - ChangedVals=TRUE; - repeat=TRUE; - SetCtrlVal(panelHandle,PANEL_TOGGLEREPEAT,repeat); - SetCtrlAttribute (panelHandle, PANEL_TIMER, ATTR_ENABLED, 1); - RunOnce(); - break; - } - - return 0; -} -//********************************************************************************* - -void CVICALLBACK MENU_DEBUG_CALLBACK (int menuBar, int menuItem, void *callbackData, - int panel) -{ - int status; - GetCtrlAttribute (panelHandle, PANEL_DEBUG, ATTR_VISIBLE, &status); - if(status==0){status=1;} - else{status=0;} - SetCtrlAttribute (panelHandle, PANEL_DEBUG, ATTR_VISIBLE, status); -} - -void CVICALLBACK TITLE1_CALLBACK (int menuBar, int menuItem, void *callbackData, - int panel) -{ - char buff[80]; - int status; - status=PromptPopup ("Enter control button label", "Enter a new label for Phase 1 control button",buff, sizeof buff-2); - if(status==0) - { - status = SetCtrlAttribute (panelHandle, PANEL_TB_SHOWPHASE1,ATTR_OFF_TEXT, buff); - status = SetCtrlAttribute (panelHandle, PANEL_TB_SHOWPHASE1,ATTR_ON_TEXT, buff); - } -} - -void CVICALLBACK TITLE2_CALLBACK (int menuBar, int menuItem, void *callbackData, - int panel) -{ - char buff[80]; - int status; - status=PromptPopup ("Enter control button label", "Enter a new label for Phase 2 control button",buff, sizeof buff-2); - if(status==0) - { - status = SetCtrlAttribute (panelHandle, PANEL_TB_SHOWPHASE2,ATTR_OFF_TEXT, buff); - status = SetCtrlAttribute (panelHandle, PANEL_TB_SHOWPHASE2,ATTR_ON_TEXT, buff); - } -} - -void CVICALLBACK TITLE3_CALLBACK (int menuBar, int menuItem, void *callbackData, - int panel) -{ - char buff[80]; - int status; - status=PromptPopup ("Enter control button label", "Enter a new label for Phase 3 control button",buff, sizeof buff-2); - if(status==0) - { - status = SetCtrlAttribute (panelHandle, PANEL_TB_SHOWPHASE3,ATTR_OFF_TEXT, buff); - status = SetCtrlAttribute (panelHandle, PANEL_TB_SHOWPHASE3,ATTR_ON_TEXT, buff); - } -} - -void CVICALLBACK TITLE4_CALLBACK (int menuBar, int menuItem, void *callbackData, - int panel) -{ - char buff[80]; - int status; - status=PromptPopup ("Enter control button label", "Enter a new label for Phase 4 control button",buff, sizeof buff-2); - if(status==0) - { - status = SetCtrlAttribute (panelHandle, PANEL_TB_SHOWPHASE4,ATTR_OFF_TEXT, buff); - status = SetCtrlAttribute (panelHandle, PANEL_TB_SHOWPHASE4,ATTR_ON_TEXT, buff); - } -} - -void CVICALLBACK TITLE5_CALLBACK (int menuBar, int menuItem, void *callbackData, - int panel) -{ - char buff[80]; - int status; - status=PromptPopup ("Enter control button label", "Enter a new label for Phase 1 control button",buff, sizeof buff-2); - if(status==0) - { - status = SetCtrlAttribute (panelHandle, PANEL_TB_SHOWPHASE5,ATTR_OFF_TEXT, buff); - status = SetCtrlAttribute (panelHandle, PANEL_TB_SHOWPHASE5,ATTR_ON_TEXT, buff); - } -} - -void CVICALLBACK TITLE6_CALLBACK (int menuBar, int menuItem, void *callbackData, - int panel) -{ - char buff[80]; - int status; - status=PromptPopup ("Enter control button label", "Enter a new label for Phase 6 control button",buff, sizeof buff-2); - if(status==0) - { - status = SetCtrlAttribute (panelHandle, PANEL_TB_SHOWPHASE6,ATTR_OFF_TEXT, buff); - status = SetCtrlAttribute (panelHandle, PANEL_TB_SHOWPHASE6,ATTR_ON_TEXT, buff); - } -} - -void CVICALLBACK TITLE7_CALLBACK (int menuBar, int menuItem, void *callbackData, - int panel) -{ - char buff[80]; - int status; - status=PromptPopup ("Enter control button label", "Enter a new label for Phase 7 control button",buff, sizeof buff-2); - if(status==0) - { - status = SetCtrlAttribute (panelHandle, PANEL_TB_SHOWPHASE7,ATTR_OFF_TEXT, buff); - status = SetCtrlAttribute (panelHandle, PANEL_TB_SHOWPHASE7,ATTR_ON_TEXT, buff); - } -} - -void CVICALLBACK TITLE8_CALLBACK (int menuBar, int menuItem, void *callbackData, - int panel) -{ - char buff[80]; - int status; - status=PromptPopup ("Enter control button label", "Enter a new label for Phase 8 control button",buff, sizeof buff-2); - if(status==0) - { - status = SetCtrlAttribute (panelHandle, PANEL_TB_SHOWPHASE8,ATTR_OFF_TEXT, buff); - status = SetCtrlAttribute (panelHandle, PANEL_TB_SHOWPHASE8,ATTR_ON_TEXT, buff); - } -} - -void CVICALLBACK TITLE9_CALLBACK (int menuBar, int menuItem, void *callbackData, - int panel) -{ - char buff[80]; - int status; - status=PromptPopup ("Enter control button label", "Enter a new label for Phase 9 control button",buff, sizeof buff-2); - if(status==0) - { - status = SetCtrlAttribute (panelHandle, PANEL_TB_SHOWPHASE9,ATTR_OFF_TEXT, buff); - status = SetCtrlAttribute (panelHandle, PANEL_TB_SHOWPHASE9,ATTR_ON_TEXT, buff); - } -} - -void CVICALLBACK TITLEX_CALLBACK (int menuBar, int menuItem, void *callbackData, - int panel) -{ - - char buff[80]; - int status; - status=PromptPopup ("Enter control button label", "Enter a new label for Phase 10 control button",buff, sizeof buff-2); - if(status==0) - { - status = SetCtrlAttribute (panelHandle, PANEL_TB_SHOWPHASE10,ATTR_OFF_TEXT, buff); - status = SetCtrlAttribute (panelHandle, PANEL_TB_SHOWPHASE10,ATTR_ON_TEXT, buff); - } -} - - - -void CVICALLBACK SETGD5_CALLBACK (int menuBar, int menuItem, void *callbackData, - int panel) -{ - SetMenuBarAttribute (menuHandle, MENU_UPDATEPERIOD_SETGD5, ATTR_CHECKED, 1); - SetMenuBarAttribute (menuHandle, MENU_UPDATEPERIOD_SETGD10, ATTR_CHECKED, 0); - SetMenuBarAttribute (menuHandle, MENU_UPDATEPERIOD_SETGD100, ATTR_CHECKED, 0); - SetMenuBarAttribute (menuHandle, MENU_UPDATEPERIOD_SETGD1000, ATTR_CHECKED, 0); - EventPeriod=0.005; - -} - -void CVICALLBACK SETGD10_CALLBACK (int menuBar, int menuItem, void *callbackData, - int panel) -{ - SetMenuBarAttribute (menuHandle, MENU_UPDATEPERIOD_SETGD5, ATTR_CHECKED, 0); - SetMenuBarAttribute (menuHandle, MENU_UPDATEPERIOD_SETGD10, ATTR_CHECKED, 1); - SetMenuBarAttribute (menuHandle, MENU_UPDATEPERIOD_SETGD100, ATTR_CHECKED, 0); - SetMenuBarAttribute (menuHandle, MENU_UPDATEPERIOD_SETGD1000, ATTR_CHECKED, 0); - EventPeriod=0.010; -} - -void CVICALLBACK SETGD100_CALLBACK (int menuBar, int menuItem, void *callbackData, - int panel) -{ -SetMenuBarAttribute (menuHandle, MENU_UPDATEPERIOD_SETGD5, ATTR_CHECKED, 0); - SetMenuBarAttribute (menuHandle, MENU_UPDATEPERIOD_SETGD10, ATTR_CHECKED, 0); - SetMenuBarAttribute (menuHandle, MENU_UPDATEPERIOD_SETGD100, ATTR_CHECKED, 1); - SetMenuBarAttribute (menuHandle, MENU_UPDATEPERIOD_SETGD1000, ATTR_CHECKED, 0); - EventPeriod=0.100; -} - -void CVICALLBACK SETGD1000_CALLBACK (int menuBar, int menuItem, void *callbackData, - int panel) -{ - SetMenuBarAttribute (menuHandle, MENU_UPDATEPERIOD_SETGD5, ATTR_CHECKED, 0); - SetMenuBarAttribute (menuHandle, MENU_UPDATEPERIOD_SETGD10, ATTR_CHECKED, 0); - SetMenuBarAttribute (menuHandle, MENU_UPDATEPERIOD_SETGD100, ATTR_CHECKED, 0); - SetMenuBarAttribute (menuHandle, MENU_UPDATEPERIOD_SETGD1000, ATTR_CHECKED, 1); - EventPeriod=1.00; -} - -//********************************************************************************************************* -void RunOnce (void) -//here we need to first scan through all the active pages... -// dim out unused columns -// Build the meta-tables. (2D instead of 3D) -// Build the update list -// -{ - //could/should change these following defs and use malloc instead. - double MetaTimeArray[500]; - int MetaDigitalArray[NUMBERDIGITALCHANNELS+1][500]; -// struct AnVals{ -// int fcn; //fcn is an integer refering to a function to use. -// // 0-step, 1-linear, 2- exp, 3- 'S' curve -// double fval; //the final value -// double tscale; //the timescale to approach final value -// } MetaAnalogArray[16][500]; - struct AnVals MetaAnalogArray[NUMBERANALOGCHANNELS+1][500]; - ddsoptions_struct MetaDDSArray[500]; - ddsoptions_struct MetaDDS2Array[500]; - dds3options_struct MetaDDS3Array[500]; - int i,j,k,mindex,tsize; - int insertpage,insertcolumn,x,y,lastpagenum,FinalPageToUse; - BOOL nozerofound,nozerofound_2; - //********* - int ResetToZeroAtEnd[30]; - - //**************** - isdimmed=TRUE; - lastpagenum=10; - //if(Scan_Active==TRUE) {UpdateScanValue(FALSE);} - GetCtrlVal (panelHandle, PANEL_NUM_INSERTIONPAGE, &insertpage); - GetCtrlVal (panelHandle, PANEL_NUM_INSERTIONCOL, &insertcolumn); - //Lets build the times list first...so we know how long it will be. - //check each page...find used columns and dim out unused....(with 0 or negative values) - SetCtrlAttribute(panelHandle,PANEL_ANALOGTABLE,ATTR_TABLE_MODE,VAL_COLUMN); - mindex=0; - FinalPageToUse=NUMBEROFPAGES-2;//issues with '0 or 1 indexing' - if(insertpage==NUMBEROFPAGES-1) - { - FinalPageToUse++; - } - //go through for each page - for(k=1;k<=FinalPageToUse;k++)// numberofpages-1 because last page is 'mobile' - { - nozerofound=1; - if(ischecked[k]==1) //if the page is selected - { - //go through for each time column - for(i=1;i<14;i++) - { - // printf("%d\t%d\n",k,i); - if((i==insertcolumn)&&(k==insertpage)&&(k!=NUMBEROFPAGES-1)) - { - nozerofound_2=TRUE; - if(ischecked[lastpagenum]==1) - { - for(x=1;x<=14;x++) - { - if((nozerofound==TRUE)&&(nozerofound_2==TRUE)&&(TimeArray[x][lastpagenum]>0)) - { - mindex++; - MetaTimeArray[mindex]=TimeArray[x][lastpagenum]; - for(y=1;y<=NUMBERANALOGCHANNELS;y++) - { - MetaAnalogArray[y][mindex].fcn=AnalogTable[x][y][lastpagenum].fcn; - MetaAnalogArray[y][mindex].fval=AnalogTable[x][y][lastpagenum].fval; - MetaAnalogArray[y][mindex].tscale=AnalogTable[x][y][lastpagenum].tscale; - MetaDigitalArray[y][mindex]=DigTableValues[x][y][lastpagenum]; - } - MetaDDSArray[mindex] = ddstable[x][lastpagenum]; - MetaDDS2Array[mindex] = dds2table[x][lastpagenum]; - MetaDDS3Array[mindex] = dds3table[x][lastpagenum]; - } - else if(TimeArray[x][lastpagenum]==0) - { - nozerofound_2=0; - } - } - } - -/*end A */ } - - - if((nozerofound==1)&&(TimeArray[i][k]>0)) - //ignore all columns after the first - // time 0 - { - mindex++; //increase the number of columns counter - MetaTimeArray[mindex]=TimeArray[i][k]; - //go through for each analog channel - for(j=1;j<=NUMBERANALOGCHANNELS;j++) - { - MetaAnalogArray[j][mindex].fcn=AnalogTable[i][j][k].fcn; - MetaAnalogArray[j][mindex].fval=AnalogTable[i][j][k].fval; - MetaAnalogArray[j][mindex].tscale=AnalogTable[i][j][k].tscale; - MetaDigitalArray[j][mindex]=DigTableValues[i][j][k]; - } - /* ddsoptions_struct contains floats and ints, so shallow copy is ok */ - MetaDDSArray[mindex] = ddstable[i][k]; - MetaDDS2Array[mindex] = dds2table[i][k]; - MetaDDS3Array[mindex] = dds3table[i][k]; - MetaDDSArray[mindex].delta_time=TimeArray[i][k]/1000; - MetaDDS2Array[mindex].delta_time=TimeArray[i][k]/1000; - MetaDDS3Array[mindex].delta_time=TimeArray[i][k]/1000; - // Don't know why the preceding line is necessary... - // But the time information wasn't always copied in... or it was erased elsewhere - } - else if (TimeArray[i][k]==0) - { - nozerofound=0; - } - } - } - } - isdimmed=TRUE; - - - DrawNewTable(1); - tsize=mindex; //tsize is the number of columns - - - BuildUpdateList(MetaTimeArray,MetaAnalogArray,MetaDigitalArray,MetaDDSArray,MetaDDS2Array,MetaDDS3Array,tsize); - -} -//********************************************************************************************************* -//By: Stefan Myrskog -//Edited: Aug8, 2005 -//Change: Force all panel controls related to scanning to hide. -int CVICALLBACK CMDSTOP_CALLBACK (int panel, int control, int event, - void *callbackData, int eventData1, int eventData2) -{ - - SetCtrlAttribute (panelHandle, PANEL_DECORATION_BOX, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_NUM_SCANVAL, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_NUM_SCANSTEP, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_NUM_SCANITER, ATTR_VISIBLE, 0); - switch (event) - { - case EVENT_COMMIT: - SetCtrlAttribute (panelHandle, PANEL_TIMER, ATTR_ENABLED, 0); - SetCtrlVal(panelHandle,PANEL_TOGGLEREPEAT,0); - //check to see if we need to export a Scan history - if(PScan.Scan_Active==TRUE) - { - ExportScanBuffer(); - } - break; - } - return 0; -} - -int CVICALLBACK TIMER_CALLBACK (int panel, int control, int event, - void *callbackData, int eventData1, int eventData2) -{ - switch (event) - { - case EVENT_TIMER_TICK: - SetCtrlAttribute (panelHandle, PANEL_TIMER, ATTR_ENABLED, 0); - //disable timer and re-enable in the runonce (or update list) loop, if the repeat butn is pressed. - //reset the timer too and set a timer time of 50ms? - - if(PScan.Scan_Active==TRUE) - { - UpdateScanValue(FALSE); - } - RunOnce(); - - break; - } - return 0; -} - -void CVICALLBACK BOOTADWIN_CALLBACK (int menuBar, int menuItem, void *callbackData, - int panel) -{ - - Boot("C:\\ADWIN\\ADWIN10.BTL",0); - processnum=Load_Process("TransferData.TA1"); -} - -void CVICALLBACK BOOTLOAD_CALLBACK (int menuBar, int menuItem, void *callbackData, - int panel) -{ - int ischecked=0; - GetMenuBarAttribute (menuHandle, MENU_FILE_BOOTLOAD, ATTR_CHECKED,&ischecked); - SetMenuBarAttribute (menuHandle, MENU_FILE_BOOTLOAD, ATTR_CHECKED,abs(ischecked-1)); - -} - -//********************************************************************************************** -void CVICALLBACK CLEARPANEL_CALLBACK (int menuBar, int menuItem, void *callbackData, - int panel) -{ - // add code to clear all the analog and digital information..... - int i=0,j=0,k=0,status=0; - - status=ConfirmPopup("Clear Panel","Do you really want to clear the panel?") ; - if(status==1) - { - ChangedVals=1; - for(i=1;i<=14;i++) - { - for(j=1;j<=NUMBERANALOGCHANNELS;j++) - { - for(k=0;k=17)&&(digchannel<=24)) - { - digval2=digval2+DMat[k][i]*pow(2,(DChName[k].chnum-16)-1); - } - } - if(!(digval==LastDVal)) - { - nupcurrent++; - nuptotal++; - ChNum[nuptotal]=33; //***********change this!!! to 99, or 98 or 255 or something - ChVal[nuptotal]=digval; // also update the ADBasic code - } - LastDVal=digval; - if(!(digval2==LastDVal2)) - { - nupcurrent++; - nuptotal++; - ChNum[nuptotal]=34; //***********change this!!! to 99, or 98 or 255 or something - ChVal[nuptotal]=digval2; // also update the ADBasic code - } - LastDVal2=digval2; - count++; - UpdateNum[count]=nupcurrent; - - //end of first scan - //now do the remainder of the loop...but just the complicated fcns - t=0; - while(t=0) - { - nupcurrent++; - nuptotal++; - ChNum[nuptotal] = 31; //dummy channel - ChVal[nuptotal] = tmp_dds; - - } //done the DDS1 - - tmp_dds = get_dds_cmd(dds_cmd_seq_AD9858, count-1-start_offset); //dds translator(zero base) runs 1 behind this counter - if (tmp_dds>=0) - { - nupcurrent++; - nuptotal++; - ChNum[nuptotal] = 32; //dummy channel - ChVal[nuptotal] = tmp_dds; - - } //done the DDS2 - - - while(k0.001) - { - nupcurrent++; - nuptotal++; - ChNum[nuptotal]=AChName[c].chnum; - ChVal[nuptotal]=AChName[c].tbias+NewAval*AChName[c].tfcn; - LastAval[k]=TempChVal2; - } - } - count++; - UpdateNum[count]=nupcurrent; - }//Done this element of the TMatrix - }//done scanning over times array - //draw in DEBUG box - bigger=count; - if(nuptotal>bigger) {bigger=nuptotal;} - GetMenuBarAttribute (menuHandle, MENU_PREFS_COMPRESSION, ATTR_CHECKED, &UseCompression); - GetMenuBarAttribute (menuHandle, MENU_PREFS_SHOWARRAY, ATTR_CHECKED, &ArraysToDebug); - newcount=0; - if(UseCompression) - { - OptimizeTimeLoop(UpdateNum,count,&newcount); - } - - - if(ArraysToDebug) - { - //fp=fopen("outarraymerge.txt","w"); - imax=newcount; - if(newcount==0) {imax=count;} - if(imax>1000){imax=1000;} - for(i=1;itimescale) { value=Vfinal;} - else {value=Vinit+slope*tms;} - break; - case 3 ://exponential - amplitude=Vfinal-Vinit; - newtime =timescale; - if(UseSimpleTiming==TRUE) - { - newtime=timescale/fabs(log(fabs(amplitude))-log(0.001)); - } - value=Vfinal-amplitude*exp(-tms/newtime); - break; - case 4 : - amplitude=Vfinal-Vinit; - aconst=3*amplitude/pow(timescale,2); - bconst=-2*amplitude/pow(timescale,3); - if(tms>timescale) - { - value=Vfinal; - } - else - { - value=Vinit+(aconst*pow(tms,2)+bconst*pow(tms,3)); - } - break; - case 5 : // generate a sinewave. Use Vfinal as the amplitude and timescale as the frequency - // ignore the 'Simple Timing' option...use the user entered value. - - amplitude=Vfinal; - // frequency=timescale; //consider it to be Hertz (tms is time in milliseconds) - value=amplitude * sin(2*3.14159*frequency*tms/1000); - } - // Check if the value exceeds the limits. - return value; -} -//******************************************************************************************** - -int CVICALLBACK DISPLAYDIAL_CALLBACK (int panel, int control, int event, - void *callbackData, int eventData1, int eventData2) -{ - int dialval=0; - switch (event) - { - case EVENT_COMMIT: - GetCtrlVal (panelHandle, PANEL_DISPLAYDIAL, &dialval); - // Now change the size of the tables depending on the dial value. - - - SetChannelDisplayed(dialval); - - break; - } - return 0; -} - - -/************************************************************************ -Author: Stefan -------- -Date Created: August 2004 -------- -Description: Resizes the analog table on the gui -------- -Return Value: void -------- -Parameters: new top, left and height values for the list box -*************************************************************************/ -void ReshapeAnalogTable( int top,int left,int height) -{ - int j,istext=0,celltype=0,tempint; - - - - //resize the analog table and all it's related list boxes - SetCtrlAttribute (panelHandle, PANEL_ANALOGTABLE, ATTR_HEIGHT, height); - SetCtrlAttribute (panelHandle, PANEL_ANALOGTABLE, ATTR_LEFT, left); - SetCtrlAttribute (panelHandle, PANEL_ANALOGTABLE, ATTR_TOP, top); - - SetCtrlAttribute (panelHandle, PANEL_TBL_ANAMES, ATTR_LEFT, left-165); - SetCtrlAttribute (panelHandle, PANEL_TBL_ANAMES, ATTR_HEIGHT, height); - SetCtrlAttribute (panelHandle, PANEL_TBL_ANAMES, ATTR_TOP, top); - - SetCtrlAttribute (panelHandle, PANEL_TBL_ANALOGUNITS, ATTR_HEIGHT, height); - SetCtrlAttribute (panelHandle, PANEL_TBL_ANALOGUNITS, ATTR_TOP, top); - SetCtrlAttribute (panelHandle, PANEL_TBL_ANALOGUNITS, ATTR_LEFT, left+705); - - // move the DDS offsets - tempint=height/27; - SetCtrlAttribute (panelHandle, PANEL_NUM_DDS_OFFSET,ATTR_TOP,top+height-3*tempint-6); - SetCtrlAttribute (panelHandle, PANEL_NUM_DDS_OFFSET,ATTR_LEFT,960); - SetCtrlAttribute (panelHandle, PANEL_NUM_DDS2_OFFSET,ATTR_TOP,top+height-2*tempint-5); - SetCtrlAttribute (panelHandle, PANEL_NUM_DDS2_OFFSET,ATTR_LEFT,960); - SetCtrlAttribute (panelHandle, PANEL_NUM_DDS3_OFFSET,ATTR_TOP,top+height-1*tempint-4); - SetCtrlAttribute (panelHandle, PANEL_NUM_DDS3_OFFSET,ATTR_LEFT,960); - - - for (j=1;j<=NUMBERANALOGCHANNELS+NUMBERDDS;j++) - { - SetTableRowAttribute (panelHandle, PANEL_ANALOGTABLE, j,ATTR_SIZE_MODE, VAL_USE_EXPLICIT_SIZE); - SetTableRowAttribute (panelHandle, PANEL_ANALOGTABLE, j, ATTR_ROW_HEIGHT, (height)/(NUMBERANALOGCHANNELS+NUMBERDDS)); - SetTableRowAttribute (panelHandle, PANEL_TBL_ANAMES, j,ATTR_SIZE_MODE, VAL_USE_EXPLICIT_SIZE); - SetTableRowAttribute (panelHandle, PANEL_TBL_ANAMES, j, ATTR_ROW_HEIGHT, (height)/(NUMBERANALOGCHANNELS+NUMBERDDS)); - SetTableRowAttribute (panelHandle, PANEL_TBL_ANALOGUNITS, j,ATTR_SIZE_MODE, VAL_USE_EXPLICIT_SIZE); - SetTableRowAttribute (panelHandle, PANEL_TBL_ANALOGUNITS, j, ATTR_ROW_HEIGHT, (height)/(NUMBERANALOGCHANNELS+NUMBERDDS)); - } -} - - -/************************************************************************ -Author: Stefan -------- -Date Created: August 2004 -------- -Description: Resizes the digital table on the gui -------- -Return Value: void -------- -Parameters: new top, left and height values for the list box -*************************************************************************/ -void ReshapeDigitalTable( int top,int left,int height) -{ - int j; - - SetCtrlAttribute (panelHandle, PANEL_DIGTABLE, ATTR_HEIGHT, height); - SetCtrlAttribute (panelHandle, PANEL_DIGTABLE, ATTR_LEFT, left); - SetCtrlAttribute (panelHandle, PANEL_DIGTABLE, ATTR_TOP, top); - SetCtrlAttribute (panelHandle, PANEL_TBL_DIGNAMES, ATTR_TOP, top); - SetCtrlAttribute (panelHandle, PANEL_TBL_DIGNAMES, ATTR_LEFT, left-165); - SetCtrlAttribute (panelHandle, PANEL_TBL_DIGNAMES, ATTR_HEIGHT, height); - - for (j=1;j<=NUMBERDIGITALCHANNELS;j++) - { - SetTableRowAttribute (panelHandle, PANEL_DIGTABLE, j, ATTR_ROW_HEIGHT, (height)/(NUMBERDIGITALCHANNELS)); - SetTableRowAttribute (panelHandle, PANEL_TBL_DIGNAMES, j, ATTR_ROW_HEIGHT, (height)/(NUMBERDIGITALCHANNELS)); - } - -} - - -/************************************************************************ -Author: David McKay -------- -Date Created: August 23, 2004 -------- -Date Modified: August 23, 2004 -------- -Description: Sets how to display the data, graphically or numerically -------- -Return Value: void -------- -Parameter1: -int display_setting: type of display -VAL_CELL_NUMERIC : graphic -VAL_CELL_PICTURE : numeric -*************************************************************************/ -void SetDisplayType(int display_setting) -{ - - int i,j; - - //set button status - if (display_setting == VAL_CELL_NUMERIC) - { - SetCtrlVal(panelHandle, PANEL_TGL_NUMERICTABLE, 0); - } - else if (display_setting == VAL_CELL_PICTURE) - { - SetCtrlVal(panelHandle, PANEL_TGL_NUMERICTABLE, 1); - } - -// printf("called Display Type with value: %d \n",display_setting); - for(i=1;i<=14;i++) - { - for(j=1;j<=NUMBERANALOGCHANNELS;j++) - { - SetTableCellAttribute (panelHandle, PANEL_ANALOGTABLE, MakePoint(i,j), - ATTR_CELL_TYPE, display_setting); - } - } -} - - -/************************************************************************ -Author: David McKay -------- -Date Created: August 23, 2004 -------- -Date Modified: August 23, 2004 -------- -Description: Sets which channel to display: analog, digital or both -------- -Return Value: void -------- -Parameter1: -int display_setting: channel to display -1: both -2: analog -3: digital -*************************************************************************/ -void SetChannelDisplayed(int display_setting) -{ - int toppos1,toppos2,leftpos,heightpos; - //hide everything - SetCtrlAttribute (panelHandle, PANEL_DIGTABLE, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_ANALOGTABLE, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_TBL_ANAMES, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_TBL_ANALOGUNITS, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_TBL_DIGNAMES, ATTR_VISIBLE, 0); - //ATTR_LABEL_VISIBLE - - switch (display_setting) - { - case 1: //both - heightpos=410; // 380 for 25 rows works... use 410 for 27 rows - toppos1=155; - leftpos=170; - toppos2=1280-100-heightpos; - toppos2=155+380+50; - ReshapeAnalogTable(toppos1,170,heightpos); //passed top, left and height - ReshapeDigitalTable(toppos2,170,heightpos-30); - - SetCtrlAttribute (panelHandle, PANEL_DIGTABLE, ATTR_VISIBLE, 1); - SetCtrlAttribute (panelHandle, PANEL_ANALOGTABLE, ATTR_VISIBLE, 1); - SetCtrlAttribute (panelHandle, PANEL_TBL_ANAMES, ATTR_VISIBLE, 1); - SetCtrlAttribute (panelHandle, PANEL_TBL_ANALOGUNITS, ATTR_VISIBLE, 1); - SetCtrlAttribute (panelHandle, PANEL_TBL_DIGNAMES, ATTR_VISIBLE, 1); - - break; - - case 2: //analog table - - ReshapeAnalogTable(155,170,600); //passed top, left and height - - - SetCtrlAttribute (panelHandle, PANEL_ANALOGTABLE, ATTR_VISIBLE, 1); - SetCtrlAttribute (panelHandle, PANEL_TBL_ANAMES, ATTR_VISIBLE, 1); - SetCtrlAttribute (panelHandle, PANEL_TBL_ANALOGUNITS, ATTR_VISIBLE, 1); - break; - - case 3: // digital table - - - //passed top, left and height - ReshapeDigitalTable(155,170,600); - - SetCtrlAttribute (panelHandle, PANEL_DIGTABLE, ATTR_VISIBLE, 1); - SetCtrlAttribute (panelHandle, PANEL_TBL_DIGNAMES, ATTR_VISIBLE, 1); - break; - - } - - SetCtrlVal(panelHandle, PANEL_DISPLAYDIAL, display_setting); - - DrawNewTable(0); - - return; - -} -//*********************************************************************************************** -double CheckIfWithinLimits(double OutputVoltage, int linenumber) -{ - double NewOutput; - NewOutput=OutputVoltage; - if(OutputVoltage>AChName[linenumber].maxvolts) NewOutput=AChName[linenumber].maxvolts; - if(OutputVoltage0)) - //ignore all columns after the first time=0 - { - mindex++; //increase the number of columns counter - MetaTimeArray[mindex]=TimeArray[i][k]; - - //go through for each analog channel - for(j=1;j<=NUMBERANALOGCHANNELS;j++) - { - MetaAnalogArray[j][mindex].fcn=AnalogTable[i][j][k].fcn; - MetaAnalogArray[j][mindex].fval=AnalogTable[i][j][k].fval; - MetaAnalogArray[j][mindex].tscale=AnalogTable[i][j][k].tscale; - MetaDigitalArray[j][mindex]=DigTableValues[i][j][k]; - DDScurrent[mindex]=ddstable[i][k].amplitude; - DDSfreq1[mindex]=ddstable[i][k].start_frequency; - DDSfreq2[mindex]=ddstable[i][k].end_frequency; - DDSstop[mindex]=ddstable[i][k].is_stop; - } - } - else if (TimeArray[i][k]==0) - { - nozerofound=0; - } - } - } - } - tsize=mindex; //tsize is the number of columns - // now write to file - // write header - sprintf(bigbuff,"Time(ms)"); - for(i=1;i<=tsize;i++) - { - strcat(bigbuff,","); - sprintf(buff,"%f",MetaTimeArray[i]); - strcat(bigbuff,buff); - } - strcat(bigbuff,"\n"); - fprintf(fexport,bigbuff); - //done header, now write analog lines - for(j=1;j<=24;j++) - { - sprintf(bigbuff,AChName[j].chname); - for(i=1;i<=tsize;i++) - { - strcat(bigbuff,","); - strncat(bigbuff,fcnmode+MetaAnalogArray[j][i].fcn-1,1); - sprintf(buff,"%3.2f",MetaAnalogArray[j][i].fval); - strcat(bigbuff,buff); - } - strcat(bigbuff,"\n"); - fprintf(fexport,bigbuff); - } - //done analog lines, now write DDS - sprintf(bigbuff,"DDS"); - for(i=1;i<=tsize;i++) - { - strcat(bigbuff,","); - if(DDSstop[i]==TRUE) - { - strcat(bigbuff,"OFF"); - } - else - { - strcat(bigbuff,"ma"); - sprintf(buff,"%4.2f",DDScurrent[i]); - strcat(bigbuff,buff); - strcat(bigbuff,"_FA"); - sprintf(buff,"%4.2f",DDSfreq1[i]); - strcat(bigbuff,buff); - strcat(bigbuff,"_FB"); - sprintf(buff,"%4.2f",DDSfreq2[i]); - strcat(bigbuff,buff); - } - } - fprintf(fexport,bigbuff); - //done DDS, now do digital - for(j=1;j<=NUMBERDIGITALCHANNELS;j++) - { - sprintf(bigbuff,DChName[j].chname); - for(i=1;i<=tsize;i++) - { - strcat(bigbuff,","); - sprintf(buff,"%d",MetaDigitalArray[j][i]); - - strcat(bigbuff,buff); - } - strcat(bigbuff,"\n"); - fprintf(fexport,bigbuff); - } - fclose(fexport); -} - -//*********************************************************************************************** - -void CVICALLBACK CONFIG_EXPORT_CALLBACK (int menuBar, int menuItem, void *callbackData, - int panel) -{ - - FILE *fconfig; - int i=0,j=0,k=0; - int xval=16,yval=16,zval=10; - char buff[500],buff2[100],fconfigname[200],buff3[31]; - - - - FileSelectPopup ("", "*.config", "", "Save Configuration", VAL_SAVE_BUTTON, 0, 0, 1, 1,fconfigname ); - - - if((fconfig=fopen(fconfigname,"w"))==NULL) - { - // InsertListItem(panelHandle,PANEL_DEBUG,-1,buff,1); - MessagePopup("Save Error","Failed to save configuration file"); - } - // write out analog channel info - sprintf(buff,"Analog Channels\n"); - fprintf(fconfig,buff); - sprintf(buff,"Row,Channel,Name,tbias,tfcn,MaxVolts,MinVolts,Units\n"); - fprintf(fconfig,buff); - for(i=1;i<=24;i++) - { - strncpy(buff3,AChName[i].chname,30); - sprintf(buff,"%d,%d,%s,%f,%f,%f,%f,%s\n",i,AChName[i].chnum,buff3,AChName[i].tbias - ,AChName[i].tfcn,AChName[i].maxvolts,AChName[i].minvolts,AChName[i].units); - fprintf(fconfig,buff); - } - // Write out digital Channel info - sprintf(buff,"Digital Channels\n"); - fprintf(fconfig,buff); - sprintf(buff,"Row,Channel,Name\n"); - fprintf(fconfig,buff); - - for(i=1;i<=24;i++) - { - sprintf(buff,"%d,%d,%s\n",i,DChName[i].chnum,DChName[i].chname); - fprintf(fconfig,buff); - } - - - fclose(fconfig); -} - - -void CVICALLBACK MENU_ALLLOW_CALLBACK (int menuBar, int menuItem, void *callbackData, - int panel) -{ -} - -void CVICALLBACK MENU_HOLD_CALLBACK (int menuBar, int menuItem, void *callbackData, - int panel) -{ -} - -void CVICALLBACK MENU_BYCHANNEL_CALLBACK (int menuBar, int menuItem, void *callbackData, - int panel) -{ -} -//************************************************************************************************************** -void OptimizeTimeLoop(int *UpdateNum,int count, int *newcount) -{ - int i=0,k=0; // i is the counter through the original UpdateNum list - int j=0; // t is the counter through the NewUpdateNum list - int t=0; - int LowZeroThreshold,HighZeroThreshold; - int LastFound=0; - int numberofzeros; - i=1; - t=1; - LowZeroThreshold=0; // minimum number of consecutive zero's to encounter before optimizing - HighZeroThreshold=100000; // maximum number of consecutive zero's to optimize - // We do not want to exceed the counter on the ADwin - // ADwin uses a 40MHz clock, 1 ms implies counter set to 40,000 - while( iHighZeroThreshold) - { - numberofzeros=numberofzeros-HighZeroThreshold; - UpdateNum[t]=-HighZeroThreshold; - t++; - } - UpdateNum[t]=-numberofzeros; - t++; - UpdateNum[t]=UpdateNum[i+j]; - t++; - i=i+j+1; - } - } - else - { - UpdateNum[t]=-(count+1-i-j); - i=i+j+1; - } - - } - } - *newcount=t; -} -//************************************************************************************************************** - -int CVICALLBACK NUM_INSERTIONPAGE_CALLBACK (int panel, int control, int event, - void *callbackData, int eventData1, int eventData2) -{ - switch (event) - { - case EVENT_COMMIT: - ChangedVals=TRUE; - } - return 0; -} - -int CVICALLBACK NUM_INSERTIONCOL_CALLBACK (int panel, int control, int event, - void *callbackData, int eventData1, int eventData2) -{ - switch (event) - { - case EVENT_COMMIT: - ChangedVals=TRUE; - break; - } - return 0; -} - -void CVICALLBACK COMPRESSION_CALLBACK (int menuBar, int menuItem, void *callbackData, - int panel) -{ - BOOL UseCompression; - GetMenuBarAttribute (menuHandle, MENU_PREFS_COMPRESSION, ATTR_CHECKED, &UseCompression); - if(UseCompression) - { - SetMenuBarAttribute (menuHandle, MENU_PREFS_COMPRESSION, ATTR_CHECKED, FALSE); - } - else - { - SetMenuBarAttribute (menuHandle, MENU_PREFS_COMPRESSION, ATTR_CHECKED, TRUE); - } -} - - -void CVICALLBACK SHOWARRAY_CALLBACK (int menuBar, int menuItem, void *callbackData, - int panel) -{ - BOOL ShowArray; - GetMenuBarAttribute (menuHandle, MENU_PREFS_SHOWARRAY, ATTR_CHECKED, &ShowArray); - if(ShowArray) - { - SetMenuBarAttribute (menuHandle, MENU_PREFS_SHOWARRAY, ATTR_CHECKED, FALSE); - } - else - { - SetMenuBarAttribute (menuHandle, MENU_PREFS_SHOWARRAY, ATTR_CHECKED, TRUE); - } - - -} - -void CVICALLBACK DDS_OFF_CALLBACK (int menuBar, int menuItem, void *callbackData, - int panel) -{ - int i=0,j=0; - for(j=0;jScanVal.Start) - { - ScanUp=TRUE; - if(ScanVal.Step<0) {ScanVal.Step=-ScanVal.Step;} - } - else - { - ScanUp=FALSE; // ie. we scan downwards - if(ScanVal.Step>0) {ScanVal.Step=-ScanVal.Step;} - } - } - - // numsteps to depend on mode - numsteps=ceil(abs(((double)ScanVal.Start-(double)ScanVal.End)/(double)ScanVal.Step)); - - PScan.ScanDone=FALSE; - timesdid++; - ScanVal.Current_Iteration++; - - if((ScanVal.Current_Iteration>=ScanVal.Iterations)&&(ScanVal.Current_Step=ScanVal.End)&& (ScanUp==TRUE)) - { - ScanVal.Current_Value=ScanVal.End; - } - - if((ScanVal.Current_Value<=ScanVal.End)&& (ScanUp==FALSE)) - { - ScanVal.Current_Value=ScanVal.End; - } - //if using the scan table, replace current value with desired value... - GetCtrlVal(panelHandle7,SCANPANEL_CHECK_USE_LIST,&UseList); - if(UseList) - { - iteration=ScanVal.Current_Iteration; - GetTableCellVal(panelHandle, PANEL_SCAN_TABLE, MakePoint(1,iteration+1), &cellval); - SetTableCellAttribute (panelHandle, PANEL_SCAN_TABLE,MakePoint(1,iteration+1), ATTR_TEXT_BGCOLOR, - VAL_LT_GRAY); - SetTableCellAttribute (panelHandle, PANEL_SCAN_TABLE,MakePoint(1,iteration), ATTR_TEXT_BGCOLOR, - VAL_WHITE); - ScanVal.Current_Value=cellval; - - } - - - //insert values into table - switch(PScan.ScanMode) - { - - case 0: - AnalogTable[cx][cy][cz].fval=ScanVal.Current_Value; - AnalogTable[cx][cy][cz].fcn=PScan.Analog.Analog_Mode; - break; - case 1: - TimeArray[cx][cz]=ScanVal.Current_Value; - break; - case 2: - ddstable[cx][cz].amplitude=PScan.DDS.Current; - ddstable[cx][cz].start_frequency=PScan.DDS.Base_Freq; - ddstable[cx][cz].end_frequency=ScanVal.Current_Value; - break; - } - GetSystemTime(&hour,&minute,&second); - ScanBuffer[counter].Step=ScanVal.Current_Step; - ScanBuffer[counter].Iteration=ScanVal.Current_Iteration; - ScanBuffer[counter].Value=ScanVal.Current_Value; - ScanBuffer[0].BufferSize=counter; - sprintf(ScanBuffer[counter].Time,"%d:%d:%d",hour,minute,second); - counter++; - // display on screen - SetCtrlVal (panelHandle, PANEL_NUM_SCANVAL, ScanVal.Current_Value); - SetCtrlVal (panelHandle, PANEL_NUM_SCANSTEP, ScanVal.Current_Step); - SetCtrlVal (panelHandle, PANEL_NUM_SCANITER, ScanVal.Current_Iteration); - - //check for end condition - if(ScanUp) - { - if((ScanVal.Current_Value>=ScanVal.End)&&(ScanVal.Current_Iteration>=ScanVal.Iterations-1)) - { //Done Scan - PScan.ScanDone=TRUE; // Flag used in RunOnce() to initiate a stop - } - } - else - { - if((ScanVal.Current_Value<=ScanVal.End)&&(ScanVal.Current_Iteration>=ScanVal.Iterations-1)) - { //Done Scan - PScan.ScanDone=TRUE; // Flag used in RunOnce() to initiate a stop - - } - } - - // if the scan is done, then cleanup - if(PScan.ScanDone==TRUE) - { // reset initial values in the tables - AnalogTable[cx][cy][cz].fval=PScan.Analog.Start_Of_Scan; - TimeArray[cx][cz]=PScan.Time.Start_Of_Scan; - ddstable[cx][cz].end_frequency=PScan.DDS.Start_Of_Scan; - // hide the scan information - SetCtrlAttribute (panelHandle, PANEL_DECORATION_BOX, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_NUM_SCANVAL, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_NUM_SCANSTEP, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_NUM_SCANITER, ATTR_VISIBLE, 0); - ExportScanBuffer(); - } - -} -//************************************************************************************************************** - -void CVICALLBACK SCANSETTING_CALLBACK (int menuBar, int menuItem, void *callbackData, - int panel) -{ - InitializeScanPanel(); -} - -//************************************************************************************************************** - -void CVICALLBACK NOTECHECK_CALLBACK (int menuBar, int menuItem, void *callbackData, - int panel) -{ - BOOL status; - GetMenuBarAttribute (menuHandle, MENU_SETTINGS_NOTECHECK, ATTR_CHECKED,&status); - SetMenuBarAttribute (menuHandle, MENU_SETTINGS_NOTECHECK, ATTR_CHECKED,!status); - SetCtrlAttribute (panelHandle, PANEL_LABNOTE_TXT, ATTR_VISIBLE, !status); - //SetCtrlAttribute (panelHandle, MENU_NOTECHECK, ATTR_VISIBLE, !status); - - -} - -void CVICALLBACK STREAM_CALLBACK (int menuBar, int menuItem, void *callbackData, - int panel) -{ - BOOL status; - char fstreamdir[250]; - GetMenuBarAttribute (menuHandle, MENU_PREFS_STREAM_SETTINGS, ATTR_CHECKED,&status); - SetMenuBarAttribute (menuHandle, MENU_PREFS_STREAM_SETTINGS, ATTR_CHECKED,!status); - if (!status==TRUE) - { - DirSelectPopup ("","Select Stream Folder", 1, 1,fstreamdir); - } -} -//************************************************************************************************************** -void ExportScanBuffer(void) -{ - int i,j,status; - FILE *fbuffer; - char fbuffername[250],buff[500]; - int step,iter,mode; - double val; - char date[100]; - - status=FileSelectPopup("", "*.scan", "", "Save Scan Buffer", VAL_SAVE_BUTTON, 0, 0, 1, 1,fbuffername ); - if(status>0) - { - if((fbuffer=fopen(fbuffername,"w"))==NULL) - { - MessagePopup("Save Error","Failed to save configuration file"); - } - switch(PScan.ScanMode) - { - case 0: - sprintf(buff,"Analog Scan\nRow,%d,Column,%d,Page,%d\n",PScan.Row,PScan.Column,PScan.Page); - break; - case 1: - sprintf(buff,"Time Scan\nColumn,%d,Page,%d\n",PScan.Column,PScan.Page); - break; - case 2: - sprintf(buff,"DDS Scan\nColumn,%d,Page,%d\n",PScan.Column,PScan.Page); - break; - } - fprintf(fbuffer,buff); - sprintf(buff,"Cycle,Value,Step,Iteration,Time\n"); - fprintf(fbuffer,buff); - for(i=0;i<=ScanBuffer[0].BufferSize;i++) - { - - val=ScanBuffer[i].Value; - step=ScanBuffer[i].Step; - iter=ScanBuffer[i].Iteration; - sprintf(date,ScanBuffer[i].Time); - sprintf(buff,"%d,%f,%d,%d,%s\n",i,val,step,iter,date); - fprintf(fbuffer,buff); - } - } - fclose(fbuffer); -} -//************************************************************************************************************** - - diff --git a/GUIDesign_dbg.cdb b/GUIDesign_dbg.cdb deleted file mode 100644 index f65afd0..0000000 Binary files a/GUIDesign_dbg.cdb and /dev/null differ diff --git a/main.c.bakoct29 b/main.c.bakoct29 deleted file mode 100644 index 9cbb7e2..0000000 --- a/main.c.bakoct29 +++ /dev/null @@ -1,270 +0,0 @@ -//Things to do: -// in analog control If timescale too long then prompt for overwrite of following cell -// overall - Verify that channel values aren't used twice.. -// - Let choose negative channel to turn off. -// - Rewrite Analog table to be textual..use tect or BG color to indicate mode -// - Use proportionality constants -// -// fix bug where the 16th row of the analog (and probably digital) panel arent being updated. -// guess of what needs to be fixed: Drawpanel, make update list -// load, save arrays ? Analog/digital setup - - -/* -Caveats: -If making any changes to the program, be aware of several inconsistencies. -Adwin software is base 1 for arrays -C (LabWindows) is base 0 for arrays, -however some controls for LabWindows are base 1 : Tables -and some are base 0 : Listboxes - - - -//Update History -Apr 15: Run button flashes with ADwin is operating. -Apr 29: Fixed Digital line 16. Loop counted to 15, should have been 16 -May 04: Adding code to delete/insert columns. -May 06: Added Copy/Paste fcns for column. Doesn't work 100% yet.... test that channels 16 work for dig. and analog. -May 10: Fixed a bug where the arrays weren't properly initialized, causing strange values to be written to the adwin - Added flashing led's to notify when the ADwin is doing something -May 13: Fixed 16th line of the panel, now is actually output. Bug was result of inconsistency with arrays. - i.e. Base 0 vs base 1. - - fixed by increasing the internal array size to 17 and starting from 1. (dont read element 0) -May 18: Improved performance. Added a variable (ChangedVals) that is 0 when no changes have been made since - the last run. If ChangedVals==0, then don't recreate/resend the arrays, shortens delay between runs. -June24: Add support for more analog output cards. Change the #define NUMBEROFANALOGCHANNELS xx to reflect the number of channels. - NOTE: You need to change this in every .c file. - Still need to update the code to use a different channel for digital. (currently using 17, which will be overwritten - if using more than 16 analog channels. -July26: Begin adding code to control the DDS (AD9854 from Analog Devices) - Use an extra line on the analog table (17 or 25) as the DDS control interface -Aug 24: David McKay adds DDS control section. COntrolled using the 25th line of the analog table -Oct 26 -*/ - -#define ALLOC_GLOBALS -#include "main.h" -#include "Adwin.h" -#include -#define VAR_DECLS 1 -#include "vars.h" -//#include -//#include -//#include - -//**************INITIALIZE GLOBALS*********************************************************************** - -extern int currentx=0,currenty=0,currentpage=0; -extern int ischecked[10]={0},isdimmed=0; -extern int ChangedVals=1; -extern struct AnalogTableValues AnalogTable[17][NUMBERANALOGCHANNELS+1][10]={1,0,1}; - // the structure is the values/elements contained at each point in the - // analog panel. The array aval, is set up as [x][y][page] - -extern int DigTableValues[17][NUMBERDIGITALCHANNELS+1][10]={0}; -extern int ChMap[NUMBERANALOGCHANNELS+1]={0}; // The channel mapping (for analog). i.e. if we program line 1 as channel - // 12, the ChMap[12]=1 - -extern double TimeArray[17][10]={0}; -extern struct AnalogChannelProperties AChName[NUMBERANALOGCHANNELS+1]={0,"","",0,1}; - -extern double EventPeriod=DefaultEventPeriod; - -extern struct DDSClock DDSFreq = {15.036, 8, 120.288}; - -//************DONE GLOBALS****************************************************************** -int main (int argc, char *argv[]) -{ - int i,j,k; - if (InitCVIRTE (0, argv, 0) == 0) - return -1; /* out of memory */ - if ((panelHandle = LoadPanel (0, "GUIDesign.uir", PANEL)) < 0) - return -1; - if ((panelHandle2 = LoadPanel (0, "AnalogSettings.uir", PANEL)) < 0) - return -1; - if ((panelHandle3 = LoadPanel (0, "DigitalSettings.uir", PANEL)) < 0) - return -1; - if ((panelHandle4 = LoadPanel (0, "AnalogControl.uir", PANEL)) < 0) - return -1; - if ((panelHandle5 = LoadPanel (0, "DDSSettings.uir", PANEL)) < 0) - return -1; - if ((panelHandle6 = LoadPanel (0, "DDSControl.uir", PANEL)) < 0) - return -1; - - //initialize the dds array - for (i=0;i<17;i++) - { - ddstable[i] = (DDSOPTIONS *) malloc(sizeof(DDSOPTIONS) * 10); - } - - //Load bitmaps - SetCtrlAttribute (panelHandle, PANEL_DEBUG, ATTR_VISIBLE, 0); - // Initialize arrays (to avoid undefined elements causing -99 to be written) - for (j=0;j<=NUMBERANALOGCHANNELS;j++) { //ramp over # of analog chanels - AChName[j].tfcn=1; - AChName[j].tbias=0; - AChName[j].resettozero=1; - for(i=0;i<=16;i++){ // ramp over # of cells per page - for(k=0;k<=9;k++){ // ramp over pages - AnalogTable[i][j][k].fcn=1; - AnalogTable[i][j][k].fval=0.0; - AnalogTable[i][j][k].tscale=1; - if (j<=16) {DigTableValues[i][j][k]=0;} - } - } - } - - //initialize ddstable - for (i=0;i<17;i++) - { - for (j=0;j<10;j++) - { - ddstable[i][j].frequency1 = 0; - ddstable[i][j].frequency2 = 0; - ddstable[i][j].current = 0; - ddstable[i][j].transition_type = LINEAR; - ddstable[i][j].is_update = FALSE; - ddstable[i][j].delta_time = 0; - ddstable[i][j].is_stop = FALSE; - ddstable[i][j].start_time = 0; - ddstable[i][j].new_settings = FALSE; - } - } - - // done initializing - - - LoadLastSettings(1); - - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE1, 1); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE2, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE3, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE4, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE5, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE6, 0); - SetCtrlVal (panelHandle, PANEL_TB_SHOWPHASE7, 0); - - EventPeriod=1.00; - ClearListCtrl(panelHandle,PANEL_DEBUG); - menuHandle=GetPanelMenuBar(panelHandle); - SetMenuBarAttribute (menuHandle, MENU_UPDATEPERIOD_SETGD5, ATTR_CHECKED, 0); - SetMenuBarAttribute (menuHandle, MENU_UPDATEPERIOD_SETGD10, ATTR_CHECKED, 0); - SetMenuBarAttribute (menuHandle, MENU_UPDATEPERIOD_SETGD100, ATTR_CHECKED, 0); - SetMenuBarAttribute (menuHandle, MENU_UPDATEPERIOD_SETGD1000, ATTR_CHECKED, 1); - currentpage=1; - - // autochange the size of the analog table on main panel -// DrawNewTable(0); - Initialization(); - DisplayPanel (panelHandle); - RunUserInterface (); - DiscardPanel (panelHandle); - - //clean up DDS Table - for (i=0;i<17;i++) - { - free(ddstable[i]); - } - - return 0; -} -//********************************************************************************** -void Initialization() -{ - int i=0,cellheight=0,fontsize=0; - int j=0; - char str_list_val[5]; - - //Add in any extra rows (if the number of channels increases) - InsertTableRows (panelHandle, PANEL_ANALOGTABLE, 16, - NUMBERANALOGCHANNELS-16, VAL_CELL_PICTURE); - InsertTableRows (panelHandle, PANEL_DIGTABLE, 16, - NUMBERDIGITALCHANNELS-16, VAL_CELL_PICTURE); - - - // Change Analog Settings window - SetCtrlAttribute (panelHandle2, ANLGPANEL_NUM_ACH_LINE,ATTR_MAX_VALUE, NUMBERANALOGCHANNELS); - SetCtrlAttribute (panelHandle2, ANLGPANEL_NUM_ACHANNEL,ATTR_MAX_VALUE, NUMBERANALOGCHANNELS); - - // change GUI - - SetCtrlAttribute (panelHandle, PANEL_ANALOGTABLE, ATTR_NUM_VISIBLE_ROWS, NUMBERANALOGCHANNELS+1); - SetCtrlAttribute (panelHandle, PANEL_DIGTABLE, ATTR_NUM_VISIBLE_ROWS, NUMBERDIGITALCHANNELS); - - SetCtrlAttribute (panelHandle, PANEL_TBL_ANAMES, ATTR_VISIBLE_LINES, NUMBERANALOGCHANNELS+1); - SetCtrlAttribute (panelHandle, PANEL_TBL_ANALOGUNITS, ATTR_VISIBLE_LINES, NUMBERANALOGCHANNELS+1); - SetCtrlAttribute (panelHandle, PANEL_TBL_DIGNAMES, ATTR_VISIBLE_LINES, NUMBERDIGITALCHANNELS); - - - SetCtrlAttribute (panelHandle, PANEL_LABEL_1, ATTR_VISIBLE, 1); - SetCtrlAttribute (panelHandle, PANEL_LABEL_2, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_3, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_4, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_5, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_6, ATTR_VISIBLE, 0); - SetCtrlAttribute (panelHandle, PANEL_LABEL_7, ATTR_VISIBLE, 0); - - - - - - SetCtrlAttribute (panelHandle, PANEL_LABEL_1, ATTR_LEFT, 165); - SetCtrlAttribute (panelHandle, PANEL_LABEL_1, ATTR_TOP, 88); - SetCtrlAttribute (panelHandle, PANEL_LABEL_2, ATTR_LEFT, 165); - SetCtrlAttribute (panelHandle, PANEL_LABEL_2, ATTR_TOP, 88); - SetCtrlAttribute (panelHandle, PANEL_LABEL_3, ATTR_LEFT, 165); - SetCtrlAttribute (panelHandle, PANEL_LABEL_3, ATTR_TOP, 88); - SetCtrlAttribute (panelHandle, PANEL_LABEL_4, ATTR_LEFT, 165); - SetCtrlAttribute (panelHandle, PANEL_LABEL_4, ATTR_TOP, 88); - SetCtrlAttribute (panelHandle, PANEL_LABEL_5, ATTR_LEFT,165); - SetCtrlAttribute (panelHandle, PANEL_LABEL_5, ATTR_TOP, 88); - SetCtrlAttribute (panelHandle, PANEL_LABEL_6, ATTR_LEFT, 165); - SetCtrlAttribute (panelHandle, PANEL_LABEL_6, ATTR_TOP, 88); - SetCtrlAttribute (panelHandle, PANEL_LABEL_7, ATTR_LEFT, 165); - SetCtrlAttribute (panelHandle, PANEL_LABEL_7, ATTR_TOP, 88); - - - - - - for (i=1;i<=NUMBERDIGITALCHANNELS;i++) - { - SetTableCellVal (panelHandle, PANEL_TBL_DIGNAMES, MakePoint(2,i), i); - } - - SetAnalogChannels(); - for (i=1;i<=NUMBERANALOGCHANNELS;i++) - { - SetTableCellVal (panelHandle, PANEL_TBL_ANAMES, MakePoint(2,i), i); - } - - DrawNewTable(0); - - //set to display both analog and digital channels - SetChannelDisplayed(1); - - //set to graphical display - SetDisplayType(VAL_CELL_PICTURE); - SetCtrlAttribute (panelHandle, PANEL_ANALOGTABLE,ATTR_ENABLE_POPUP_MENU, 0); - return; - -} -//*************************************************************************************************** -void ConvertIntToStr(int int_val, char *int_str) -{ - - int i,j; - - for (i=j=floor(log10(int_val));i>=0;i--) - { - int_str[i] = (char) (((int) '0') + floor(((int) floor((int_val/pow(10,(j-i))))%10))); - } - - int_str[j+1] = '\0'; - - return; - - -} - -