Subversion Repositories f9daq

Compare Revisions

No changes between revisions

Ignore whitespace Rev 211 → Rev 212

/cvi/instr/AitSipmDAQ/Ait.cws
0,0 → 1,286
[Workspace Header]
Version = 1302
Pathname = "/c/home/rok/NativeExportsSample/AitSipmDAQ/Ait.cws"
CVI Dir = "/c/program files/national instruments/cvi2013"
CVI Shared Dir = "/C/Program Files/National Instruments/Shared/CVI"
CVI Pub Local Dir = "/C/ProgramData/National Instruments/CVI2013"
CVI Pub Global Dir = "/C/ProgramData/National Instruments/CVI"
IVI Standard Root Dir = "/C/Program Files/IVI Foundation/IVI"
IVI Standard Root 64-bit Dir = "/C/Program Files/IVI Foundation/IVI"
VXIplug&play Framework Dir = "/C/Program Files/IVI Foundation/VISA/winnt"
VXIplug&play Framework 64-bit Dir = "/C/Program Files/IVI Foundation/VISA/win64"
Number of Projects = 1
Active Project = 1
Project 0001 = "Ait.prj"
Drag Bar Left = 184
Window Top = 174
Window Left = 296
Window Bottom = 965
Window Right = 1638
Maximized = True
Maximized Children = True
Max32 Number Of Errors = 20
Track Include File Dependencies = True
Prompt For Missing Includes = True
Stop On First Error File = False
Bring Up Err Win At Start = True
Bring Up Err Win For Errors = False
Save Changes Before Running = "Always"
Save Changes Before Compiling = "Always"
Hide Windows = False
Break At First Statement = False
Sort Type = "File Name"
Number of Opened Files = 9
Window Confinement Region Enabled = True
MainColumnWidth = 167
FileDateColumnWidth = 70
FileSizeColumnWidth = 70
 
[Project Header 0001]
Version = 1302
Don't Update DistKit = False
Platform Code = 4
Build Configuration = "Debug"
Warn User If Debugging Release = 1
Batch Build Release = False
Batch Build Debug = False
 
[File 0001]
Path = "/c/home/CVI/instr/HISTO/H1D.fp"
File Type = "Function Panel"
Disk Date = 3568701422
In Projects = "1,"
Window Top = 268
Window Left = 131
Window Height = 400
Window Width = 400
 
[File 0002]
Path = "/c/home/CVI/instr/HISTO/H2D.fp"
File Type = "Function Panel"
Disk Date = 3568701422
In Projects = "1,"
Window Top = 154
Window Left = 71
Window Height = 400
Window Width = 400
 
[File 0003]
Path = "/c/home/CVI/instr/HISTO/H3D.fp"
File Type = "Function Panel"
Disk Date = 3568701422
In Projects = "1,"
Window Top = 230
Window Left = 111
Window Height = 400
Window Width = 400
 
[File 0004]
Path = "/c/home/CVI/instr/MIKRO/MIKRO.fp"
File Type = "Function Panel"
Disk Date = 3228636098
In Projects = "1,"
 
[File 0005]
Path = "/c/home/rok/NativeExportsSample/AitSipmDAQ/AitInterface.c"
File Type = "CSource"
Disk Date = 3568367969
In Projects = "1,"
Window Top = 192
Window Left = 91
Window Z-Order = 5
Source Window State = "1,915,915,915,9,23,23,0,0,80,0,704,0,0,0,25,863,0,902,17,349,683,1,13,"
 
[File 0006]
Path = "/c/home/CVI/instr/MIKRO/MIKRO.c"
File Type = "CSource"
Disk Date = 3293361296
In Projects = ""
Window Top = 31
Window Z-Order = 6
Source Window State = "1,0,0,0,0,0,0,0,0,70,0,0,0,0,0,28,30,0,110,21,400,600,1,0,"
 
[File 0007]
Path = "/c/home/CVI/instr/HISTO/H2D.c"
File Type = "CSource"
Disk Date = 3568701422
In Projects = ""
Window Top = 31
Window Z-Order = 4
Source Window State = "1,302,302,302,2,26,2,0,0,70,0,0,0,0,0,28,246,0,288,27,400,600,1,0,"
 
[File 0008]
Path = "/c/home/CVI/instr/HISTO/H1D.c"
File Type = "CSource"
Disk Date = 3568716552
In Projects = ""
Window Top = 64
Window Left = 26
Window Z-Order = 3
Source Window State = "1,271,274,274,0,0,0,0,3,80,0,0,0,0,0,25,248,0,271,21,349,683,1,0,"
 
[File 0009]
Path = "/c/home/CVI/instr/HISTO/H1D.h"
File Type = "Include"
Disk Date = 3568701422
In Projects = ""
Window Top = 95
Window Left = 42
Window Z-Order = 9
Source Window State = "1,75,75,75,15,23,23,0,3,80,0,0,0,0,0,25,54,0,75,15,349,683,1,0,"
 
[File 0010]
Path = "/c/home/CVI/instr/HISTO/H2D.h"
File Type = "Include"
Disk Date = 3568701422
In Projects = ""
Window Top = 126
Window Left = 58
Window Z-Order = 8
Source Window State = "1,93,93,93,14,22,22,0,3,80,0,0,0,0,0,25,73,0,93,14,349,683,1,0,"
 
[File 0011]
Path = "/c/Program Files/National Instruments/CVI2013/include/utility.h"
File Type = "Include"
Disk Date = 3486528000
In Projects = ""
Window Top = 33
Window Left = 10
Window Z-Order = 7
Source Window State = "1,700,700,700,14,46,46,0,3,80,0,0,0,0,0,25,688,0,700,14,349,683,1,0,"
 
[File 0012]
Path = "/c/home/rok/NativeExportsSample/AitSipmDAQ/AitGui.uir"
File Type = "User Interface Resource"
Disk Date = 3568717028
In Projects = "1,"
Window Top = 40
Window Left = 11
Window Height = 349
Window Width = 683
Window Z-Order = 2
 
[File 0013]
Path = "/c/home/rok/NativeExportsSample/AitSipmDAQ/AitGui.c"
File Type = "CSource"
Disk Date = 3568717844
In Projects = "1,"
Window Top = 33
Window Left = 10
Window Z-Order = 1
Source Window State = "1,668,668,668,35,39,39,0,0,212,0,1,0,1,0,63,637,0,666,81,349,587,1,0,"
 
[File 0014]
Path = "/c/home/rok/NativeExportsSample/AitSipmDAQ/AitMduManager.lib"
File Type = "Library"
Disk Date = 3567588825
In Projects = "1,"
 
[File 0015]
Path = "/c/home/rok/NativeExportsSample/AitSipmDAQ/AitInterface.h"
File Type = "Include"
Disk Date = 3567772136
In Projects = "1,"
Window Top = 154
Window Left = 71
Source Window State = "1,14,15,14,5,26,5,0,0,0,0,0,0,0,0,0,11,0,14,15,349,771,1,0,"
 
[Tab Order]
Tab 0001 = "/c/home/CVI/instr/MIKRO/MIKRO.c"
Tab 0002 = "/c/home/CVI/instr/HISTO/H2D.c"
Tab 0003 = "/c/home/CVI/instr/HISTO/H1D.c"
Tab 0004 = "/c/home/CVI/instr/HISTO/H1D.h"
Tab 0005 = "/c/home/CVI/instr/HISTO/H2D.h"
Tab 0006 = "/c/Program Files/National Instruments/CVI2013/include/utility.h"
Tab 0007 = "/c/home/rok/NativeExportsSample/AitSipmDAQ/AitInterface.c"
Tab 0008 = "/c/home/rok/NativeExportsSample/AitSipmDAQ/AitGui.c"
Tab 0009 = "/c/home/rok/NativeExportsSample/AitSipmDAQ/AitGui.uir"
 
[Default Build Config 0001 Debug]
Generate Browse Info = True
Enable Uninitialized Locals Runtime Warning = True
Batch Build = False
Profile = "Disabled"
Debugging Level = "Standard"
Execution Trace = "Disabled"
Command Line Args = ""
Working Directory = ""
Environment Options = ""
External Process Path = ""
 
[Default Build Config 0001 Release]
Generate Browse Info = True
Enable Uninitialized Locals Runtime Warning = True
Batch Build = False
Profile = "Disabled"
Debugging Level = "Standard"
Execution Trace = "Disabled"
Command Line Args = ""
Working Directory = ""
Environment Options = ""
External Process Path = ""
 
[Default Build Config 0001 Debug64]
Generate Browse Info = True
Enable Uninitialized Locals Runtime Warning = True
Batch Build = False
Profile = "Disabled"
Debugging Level = "Standard"
Execution Trace = "Disabled"
Command Line Args = ""
Working Directory = ""
Environment Options = ""
External Process Path = ""
 
[Default Build Config 0001 Release64]
Generate Browse Info = True
Enable Uninitialized Locals Runtime Warning = True
Batch Build = False
Profile = "Disabled"
Debugging Level = "Standard"
Execution Trace = "Disabled"
Command Line Args = ""
Working Directory = ""
Environment Options = ""
External Process Path = ""
 
[Build Dependencies 0001]
Number of Dependencies = 0
 
[Build Options 0001]
Generate Browse Info = True
Enable Uninitialized Locals Runtime Warning = True
Execution Trace = "Disabled"
Profile = "Disabled"
Debugging Level = "Standard"
Break On Library Errors = True
Break On First Chance Exceptions = False
 
[Execution Target 0001]
Execution Target Address = "Local desktop computer"
Execution Target Port = 0
Execution Target Type = 0
 
[SCC Options 0001]
Use global settings = True
SCC Provider = ""
SCC Project = ""
Local Path = ""
Auxiliary Path = ""
Perform Same Action For .h File As For .uir File = "Ask"
Perform Same Action For .cds File As For .prj File = "Ask"
Username = ""
Comment = ""
Use Default Username = False
Use Default Comment = False
Suppress CVI Error Messages = False
Always show confirmation dialog = True
 
[DLL Debugging Support 0001]
External Process Path = ""
 
[Command Line Args 0001]
Command Line Args = ""
Working Directory = ""
Environment Options = ""
 
/cvi/instr/AitSipmDAQ/Ait.exe
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/cvi/instr/AitSipmDAQ/Ait.prj
0,0 → 1,507
[Project Header]
Version = 1302
Pathname = "/c/home/rok/NativeExportsSample/AitSipmDAQ/Ait.prj"
CVI Dir = "/c/program files/national instruments/cvi2013"
CVI Shared Dir = "/C/Program Files/National Instruments/Shared/CVI"
CVI Pub Local Dir = "/C/ProgramData/National Instruments/CVI2013"
CVI Pub Global Dir = "/C/ProgramData/National Instruments/CVI"
IVI Standard Root Dir = "/C/Program Files/IVI Foundation/IVI"
VXIplug&play Framework Dir = "/C/Program Files/IVI Foundation/VISA/winnt"
IVI Standard Root 64-bit Dir = "/C/Program Files/IVI Foundation/IVI"
VXIplug&play Framework 64-bit Dir = "/C/Program Files/IVI Foundation/VISA/win64"
Number of Files = 9
Target Type = "Executable"
Flags = 2064
Copied From Locked InstrDrv Directory = False
Copied from VXIPNP Directory = False
Locked InstrDrv Name = ""
Don't Display Deploy InstrDrv Dialog = False
 
[Folders]
Folder 0 = "User Interface Files"
FolderEx 0 = "User Interface Files"
Folder 1 = "Source Files"
FolderEx 1 = "Source Files"
Folder 2 = "Library Files"
FolderEx 2 = "Library Files"
Folder 3 = "Include Files"
FolderEx 3 = "Include Files"
Folder 4 = "Instrument Files"
FolderEx 4 = "Instrument Files"
 
[File 0001]
File Type = "User Interface Resource"
Res Id = 1
Path Is Rel = True
Path Rel To = "Project"
Path Rel Path = "AitGui.uir"
Path = "/c/home/rok/NativeExportsSample/AitSipmDAQ/AitGui.uir"
Exclude = False
Project Flags = 0
Folder = "User Interface Files"
Folder Id = 0
 
[File 0002]
File Type = "CSource"
Res Id = 2
Path Is Rel = True
Path Rel To = "Project"
Path Rel Path = "AitGui.c"
Path = "/c/home/rok/NativeExportsSample/AitSipmDAQ/AitGui.c"
Exclude = False
Compile Into Object File = False
Project Flags = 0
Folder = "Source Files"
Folder Id = 1
 
[File 0003]
File Type = "CSource"
Res Id = 3
Path Is Rel = True
Path Rel To = "Project"
Path Rel Path = "AitInterface.c"
Path = "/c/home/rok/NativeExportsSample/AitSipmDAQ/AitInterface.c"
Exclude = False
Compile Into Object File = False
Project Flags = 0
Folder = "Source Files"
Folder Id = 1
 
[File 0004]
File Type = "Library"
Res Id = 4
Path Is Rel = True
Path Rel To = "Project"
Path Rel Path = "AitMduManager.lib"
Path = "/c/home/rok/NativeExportsSample/AitSipmDAQ/AitMduManager.lib"
Exclude = False
Project Flags = 0
Folder = "Library Files"
Folder Id = 2
 
[File 0005]
File Type = "Include"
Res Id = 5
Path Is Rel = True
Path Rel To = "Project"
Path Rel Path = "AitInterface.h"
Path = "/c/home/rok/NativeExportsSample/AitSipmDAQ/AitInterface.h"
Exclude = False
Project Flags = 0
Folder = "Include Files"
Folder Id = 3
 
[File 0006]
File Type = "Function Panel"
Res Id = 6
Path Is Rel = True
Path Rel To = "Project"
Path Rel Path = "../../../CVI/instr/HISTO/H1D.fp"
Path = "/c/home/CVI/instr/HISTO/H1D.fp"
Exclude = False
Project Flags = 0
Folder = "Instrument Files"
Folder Id = 4
 
[File 0007]
File Type = "Function Panel"
Res Id = 7
Path Is Rel = True
Path Rel To = "Project"
Path Rel Path = "../../../CVI/instr/HISTO/H2D.fp"
Path = "/c/home/CVI/instr/HISTO/H2D.fp"
Exclude = False
Project Flags = 0
Folder = "Instrument Files"
Folder Id = 4
 
[File 0008]
File Type = "Function Panel"
Res Id = 8
Path Is Rel = True
Path Rel To = "Project"
Path Rel Path = "../../../CVI/instr/HISTO/H3D.fp"
Path = "/c/home/CVI/instr/HISTO/H3D.fp"
Exclude = False
Project Flags = 0
Folder = "Instrument Files"
Folder Id = 4
 
[File 0009]
File Type = "Function Panel"
Res Id = 9
Path Is Rel = True
Path Rel To = "Project"
Path Rel Path = "../../../CVI/instr/MIKRO/MIKRO.fp"
Path = "/c/home/CVI/instr/MIKRO/MIKRO.fp"
Exclude = False
Project Flags = 0
Folder = "Instrument Files"
Folder Id = 4
 
[Custom Build Configs]
Num Custom Build Configs = 0
 
[Default Build Config Debug]
Config Name = "Debug"
Is 64-Bit = False
Is Release = False
Default Calling Convention = "cdecl"
Optimization Level = "Optimize for speed (level 2)"
Require Prototypes = True
Show Warning IDs in Build Output = False
Selected Warning Level = "Common"
Warning List None = ""
Warning List Common = ""
Warning List Extended = ""
Warning List All = ""
Warning Mode = 0
Enable Unreferenced Identifiers Warning = True
Enable Pointer Mismatch Warning = True
Enable Unreachable Code Warning = True
Enable Assignment In Conditional Warning = True
Uninitialized Locals Compile Warning = "Aggressive"
Require Return Values = True
Enable C99 Extensions = True
Enable OpenMP Extensions = False
Stack Size = 250000
Stack Reserve = 1048576
Stack Commit = 4096
Image Base Address = 4194304
Image Base Address x64 = 4194304
Compiler Defines = "/DWIN32_LEAN_AND_MEAN"
Sign = False
Sign Store = ""
Sign Certificate = ""
Sign Timestamp URL = ""
Sign URL = ""
Manifest Embed = False
Icon File Is Rel = False
Icon File = ""
Application Title = ""
Use IVI Subdirectories for Import Libraries = False
Use VXIPNP Subdirectories for Import Libraries = False
Use Dflt Import Lib Base Name = True
Where to Copy DLL = "Do not copy"
Custom Directory to Copy DLL Is Rel = False
Custom Directory to Copy DLL = ""
Generate Source Documentation = "None"
Runtime Support = "Full Runtime Support"
Runtime Binding = "Shared"
Embed Project .UIRs = False
Generate Map File = False
Embed Timestamp = True
Create Console Application = False
Using LoadExternalModule = False
DLL Exports = "Include File Symbols"
Register ActiveX Server = False
Numeric File Version = "1,0,0,0"
Numeric Prod Version = "1,0,0,0"
Comments = ""
Comments Ex = ""
Company Name = ""
Company Name Ex = "%company"
File Description = "Ait (Debug x86)"
File Description Ex = "%application (%rel_dbg %arch)"
File Version = "1.0"
File Version Ex = "%f1.%f2"
Internal Name = "Ait"
Internal Name Ex = "%basename"
Legal Copyright = "Copyright © 2017"
Legal Copyright Ex = "Copyright © %company %Y"
Legal Trademarks = ""
Legal Trademarks Ex = ""
Original Filename = "Ait.exe"
Original Filename Ex = "%filename"
Private Build = ""
Private Build Ex = ""
Product Name = " Ait"
Product Name Ex = "%company %application"
Product Version = "1.0"
Product Version Ex = "%p1.%p2"
Special Build = ""
Special Build Ex = ""
Add Type Lib To DLL = False
Include Type Lib Help Links = False
TLB Help Style = "HLP"
Type Lib FP File Is Rel = False
Type Lib FP File = ""
 
[Default Build Config Release]
Config Name = "Release"
Is 64-Bit = False
Is Release = True
Default Calling Convention = "cdecl"
Optimization Level = "Optimize for speed (level 2)"
Require Prototypes = True
Show Warning IDs in Build Output = False
Selected Warning Level = "Common"
Warning List None = ""
Warning List Common = ""
Warning List Extended = ""
Warning List All = ""
Warning Mode = 0
Enable Unreferenced Identifiers Warning = True
Enable Pointer Mismatch Warning = True
Enable Unreachable Code Warning = True
Enable Assignment In Conditional Warning = True
Uninitialized Locals Compile Warning = "Aggressive"
Require Return Values = True
Enable C99 Extensions = True
Enable OpenMP Extensions = False
Stack Size = 250000
Stack Reserve = 1048576
Stack Commit = 4096
Image Base Address = 4194304
Image Base Address x64 = 4194304
Compiler Defines = "/DWIN32_LEAN_AND_MEAN"
Sign = False
Sign Store = ""
Sign Certificate = ""
Sign Timestamp URL = ""
Sign URL = ""
Manifest Embed = False
Icon File Is Rel = False
Icon File = ""
Application Title = ""
Use IVI Subdirectories for Import Libraries = False
Use VXIPNP Subdirectories for Import Libraries = False
Use Dflt Import Lib Base Name = True
Where to Copy DLL = "Do not copy"
Custom Directory to Copy DLL Is Rel = False
Custom Directory to Copy DLL = ""
Generate Source Documentation = "None"
Runtime Support = "Full Runtime Support"
Runtime Binding = "Shared"
Embed Project .UIRs = False
Generate Map File = False
Embed Timestamp = True
Create Console Application = False
Using LoadExternalModule = False
DLL Exports = "Include File Symbols"
Register ActiveX Server = False
Add Type Lib To DLL = False
Include Type Lib Help Links = False
TLB Help Style = "HLP"
Type Lib FP File Is Rel = False
Type Lib FP File = ""
 
[Default Build Config Debug64]
Config Name = "Debug64"
Is 64-Bit = True
Is Release = False
Default Calling Convention = "cdecl"
Optimization Level = "Optimize for speed (level 2)"
Require Prototypes = True
Show Warning IDs in Build Output = False
Selected Warning Level = "Common"
Warning List None = ""
Warning List Common = ""
Warning List Extended = ""
Warning List All = ""
Warning Mode = 0
Enable Unreferenced Identifiers Warning = True
Enable Pointer Mismatch Warning = True
Enable Unreachable Code Warning = True
Enable Assignment In Conditional Warning = True
Uninitialized Locals Compile Warning = "Aggressive"
Require Return Values = True
Enable C99 Extensions = True
Enable OpenMP Extensions = False
Stack Size = 250000
Stack Reserve = 1048576
Stack Commit = 4096
Image Base Address = 4194304
Image Base Address x64 = 4194304
Compiler Defines = "/DWIN32_LEAN_AND_MEAN"
Sign = False
Sign Store = ""
Sign Certificate = ""
Sign Timestamp URL = ""
Sign URL = ""
Manifest Embed = False
Icon File Is Rel = False
Icon File = ""
Application Title = ""
Use IVI Subdirectories for Import Libraries = False
Use VXIPNP Subdirectories for Import Libraries = False
Use Dflt Import Lib Base Name = True
Where to Copy DLL = "Do not copy"
Custom Directory to Copy DLL Is Rel = False
Custom Directory to Copy DLL = ""
Generate Source Documentation = "None"
Runtime Support = "Full Runtime Support"
Runtime Binding = "Shared"
Embed Project .UIRs = False
Generate Map File = False
Embed Timestamp = True
Create Console Application = False
Using LoadExternalModule = False
DLL Exports = "Include File Symbols"
Register ActiveX Server = False
Add Type Lib To DLL = False
Include Type Lib Help Links = False
TLB Help Style = "HLP"
Type Lib FP File Is Rel = False
Type Lib FP File = ""
 
[Default Build Config Release64]
Config Name = "Release64"
Is 64-Bit = True
Is Release = True
Default Calling Convention = "cdecl"
Optimization Level = "Optimize for speed (level 2)"
Require Prototypes = True
Show Warning IDs in Build Output = False
Selected Warning Level = "Common"
Warning List None = ""
Warning List Common = ""
Warning List Extended = ""
Warning List All = ""
Warning Mode = 0
Enable Unreferenced Identifiers Warning = True
Enable Pointer Mismatch Warning = True
Enable Unreachable Code Warning = True
Enable Assignment In Conditional Warning = True
Uninitialized Locals Compile Warning = "Aggressive"
Require Return Values = True
Enable C99 Extensions = True
Enable OpenMP Extensions = False
Stack Size = 250000
Stack Reserve = 1048576
Stack Commit = 4096
Image Base Address = 4194304
Image Base Address x64 = 4194304
Compiler Defines = "/DWIN32_LEAN_AND_MEAN"
Sign = False
Sign Store = ""
Sign Certificate = ""
Sign Timestamp URL = ""
Sign URL = ""
Manifest Embed = False
Icon File Is Rel = False
Icon File = ""
Application Title = ""
Use IVI Subdirectories for Import Libraries = False
Use VXIPNP Subdirectories for Import Libraries = False
Use Dflt Import Lib Base Name = True
Where to Copy DLL = "Do not copy"
Custom Directory to Copy DLL Is Rel = False
Custom Directory to Copy DLL = ""
Generate Source Documentation = "None"
Runtime Support = "Full Runtime Support"
Runtime Binding = "Shared"
Embed Project .UIRs = False
Generate Map File = False
Embed Timestamp = True
Create Console Application = False
Using LoadExternalModule = False
DLL Exports = "Include File Symbols"
Register ActiveX Server = False
Add Type Lib To DLL = False
Include Type Lib Help Links = False
TLB Help Style = "HLP"
Type Lib FP File Is Rel = False
Type Lib FP File = ""
 
[Compiler Options]
Default Calling Convention = "cdecl"
Require Prototypes = True
Require Return Values = True
Enable Pointer Mismatch Warning = True
Enable Unreachable Code Warning = True
Enable Unreferenced Identifiers Warning = True
Enable Assignment In Conditional Warning = True
O Option Compatible With 5.0 = False
Enable C99 Extensions = True
Uninitialized Locals Compile Warning = "Aggressive"
Precompile Prefix Header = False
Prefix Header File = ""
 
[Run Options]
Stack Size = 250000
Stack Commit = 4096
Image Base Address = 4194304
Image Base Address x64 = 4194304
 
[Compiler Defines]
Compiler Defines = "/DWIN32_LEAN_AND_MEAN"
 
[Create Executable]
Executable File_Debug Is Rel = True
Executable File_Debug Rel To = "Project"
Executable File_Debug Rel Path = "Ait.exe"
Executable File_Debug = "/c/home/rok/NativeExportsSample/AitSipmDAQ/Ait.exe"
Executable File_Release Is Rel = True
Executable File_Release Rel To = "Project"
Executable File_Release Rel Path = "Ait.exe"
Executable File_Release = "/c/home/rok/NativeExportsSample/AitSipmDAQ/Ait.exe"
Executable File_Debug64 Is Rel = True
Executable File_Debug64 Rel To = "Project"
Executable File_Debug64 Rel Path = "Ait.exe"
Executable File_Debug64 = "/c/home/rok/NativeExportsSample/AitSipmDAQ/Ait.exe"
Executable File_Release64 Is Rel = True
Executable File_Release64 Rel To = "Project"
Executable File_Release64 Rel Path = "Ait.exe"
Executable File_Release64 = "/c/home/rok/NativeExportsSample/AitSipmDAQ/Ait.exe"
Icon File Is Rel = False
Icon File = ""
Application Title = ""
DLL Exports = "Include File Symbols"
Use IVI Subdirectories for Import Libraries = False
Use VXIPNP Subdirectories for Import Libraries = False
Use Dflt Import Lib Base Name = True
Where to Copy DLL = "Do not copy"
Custom Directory to Copy DLL Is Rel = False
Custom Directory to Copy DLL = ""
Generate Source Documentation = "None"
Add Type Lib To DLL = False
Include Type Lib Help Links = False
TLB Help Style = "HLP"
Type Lib FP File Is Rel = False
Type Lib FP File = ""
Type Lib Guid = ""
Runtime Support = "Full Runtime Support"
Instrument Driver Support Only = False
Embed Project .UIRs = False
Generate Map File = False
 
[External Compiler Support]
UIR Callbacks File Option = 0
Using LoadExternalModule = False
Create Project Symbols File = True
UIR Callbacks Obj File Is Rel = False
UIR Callbacks Obj File = ""
Project Symbols H File Is Rel = False
Project Symbols H File = ""
Project Symbols Obj File Is Rel = False
Project Symbols Obj File = ""
 
[ActiveX Server Options]
Specification File Is Rel = False
Specification File = ""
Source File Is Rel = False
Source File = ""
Include File Is Rel = False
Include File = ""
IDL File Is Rel = False
IDL File = ""
Register ActiveX Server = False
 
[Signing Info]
Sign = False
Sign Debug Build = False
Store = ""
Certificate = ""
Timestamp URL = ""
URL = ""
 
[Manifest Info]
Embed = False
 
[tpcSection]
tpcEnabled = 0
tpcOverrideEnvironment = 0
tpcEnabled x64 = 0
tpcOverrideEnvironment x64 = 0
 
/cvi/instr/AitSipmDAQ/AitGui.c
0,0 → 1,942
#include <formatio.h>
#include <cvirte.h>
#include <userint.h>
#include "AitGui.h"
#include "XYSCAN.h"
 
#include <stdbool.h>
#include "AitInterface.h"
#include "AitMduManager_DEF.h"
 
#include "H1D.h"
#include "H2D.h"
#include "H3D.h"
 
 
typedef unsigned short ushort;
typedef unsigned int uint;
 
static int ait;
static int xyscan;
//#define MIKRO
 
#ifdef MIKRO
#include "MIKRO.h"
#endif
 
static int daq_on;
static int plothandle[4]= {0,0,0, 0};
static int tfID;
static int controlID;
static int verbose;
 
#define MAX_THREADS 10
 
static CmtThreadPoolHandle poolHandle = 0;
 
 
/*
 
x: 140000 280000
 
*/
 
//**************************** missing declarations in the library
char strbuf[0xFF];
 
int gLog=0;
 
int printf(const char *format, ...) {
va_list aptr;
int ret;
FILE *flog;
 
va_start(aptr, format);
ret = vsprintf(strbuf, format, aptr);
va_end(aptr);
SetCtrlVal(ait,AIT_STDIO,strbuf);
 
if (gLog) {
flog = fopen ("stdio.log", "a");
fprintf (flog, "%s", strbuf);
fclose (flog);
}
return(ret);
}
 
 
 
static int timeout=0;
int CVICALLBACK SetTimeoutCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
switch (event) {
case EVENT_TIMER_TICK:
timeout=1;
printf("#### Timeout\n");
break;
}
return 0;
}
 
 
 
static void start_timer (double tout) {
timeout = 0;
SetCtrlAttribute (ait, AIT_TIMER, ATTR_INTERVAL, tout);
SetCtrlAttribute (ait, AIT_TIMER, ATTR_ENABLED, 1);
}
 
static void stop_timer ( void ) {
SetCtrlAttribute (ait, AIT_TIMER, ATTR_ENABLED, 0);
//DRSSetTimeout();
}
 
 
 
void CVICALLBACK EndOfThread ( CmtThreadPoolHandle poolhandle,
CmtThreadFunctionID functionID, unsigned int event,
int value, void *callbackData ) {
 
daq_on=0;
//SetDimming(0);
printf("End of Thread \n");
return ;
 
}
 
int AitInit() {
InitializeConnection();
return 0;
}
 
 
int AitValidEvent() {
 
return 1;
};
 
int AitToFile(FILE *fp, int n) {
const int bsize=10000 ;
unsigned short a[bsize] ;
unsigned short buffer[2]={0x1};
buffer[1] = (unsigned short)(n*CHANNELS*2);
for (int eventNum = 0; eventNum < n; eventNum++) {
for (int channel = 0; channel < CHANNELS; channel++) {
int index = channel+ CHANNELS * eventNum;
if (index<bsize)
a[index] = ExtractAdcData(eventNum, channel);
}
}
fwrite(buffer, 2*sizeof(short),1,fp);
return fwrite(a, 1,buffer[1],fp);
};
 
int AitFillHistograms(int events) {
ushort rawAdcData = 0;
ushort adcData = 0;
int channelReceived = 0;
int channelExpected = 0;
bool includeSaturated = 0; // cbIncludeSaturated.Checked;
ushort max[CHANNELS];
ushort min[CHANNELS];
ushort average[CHANNELS];
int total[CHANNELS];
for (int i = 0; i < CHANNELS; i++) {
min[i] = 0xFFFF;
max[i] = 0;
total[i] = 0;
}
 
double threshold, xysumcut;
GetCtrlVal (ait, AIT_ADCTHRESHOLD, &threshold);
GetCtrlVal (ait, AIT_XYCUT, &xysumcut);
 
for (int eventNum = 0; eventNum < events; eventNum++) {
 
int sum = 0;
double a[4]= {0,0,0,0} ;
for (int channel = 0; channel < CHANNELS; channel++) {
 
rawAdcData = ExtractAdcData(eventNum, channel);
if (addChannelNum == true) {
channelReceived = (rawAdcData >> 12) & 0xF;
channelExpected = (channel & 0xF);
if (channelReceived != channelExpected) {
 
AddMessage("ERROR in Event %d : Expected channel %d, received %d -ANALYSIS STOPPED", eventNum, channelExpected, channelReceived);
 
//EnableRegisterScanTimer(true);
return eventNum;
}
}
adcData = (ushort)(rawAdcData & 0x0FFF); // remove channel number
//if ((includeSaturated == true) || ((includeSaturated == false) && (adcData < (ADCMAX - 2))))
 
if (adcData>threshold) H1D_Fill(channel, adcData,1);
a[channel]=adcData;
total[channel] = total[channel] + adcData;
if (adcData > max[channel])
max[channel] = adcData;
else if (adcData < min[channel])
min[channel] = adcData;
 
sum += adcData;
}
if (sum>threshold) {
H1D_Fill(10, sum, 1 );
double x = a[0]/(a[0]+a[1]);
double y = a[2]/(a[2]+a[3]);
if (sum>xysumcut) H2D_Fill(0, x, y , 1 );
}
histogramTotalEvents++;
}
//tbAdcStatistics.Clear();
for (int channel = 0; channel < CHANNELS; channel++) {
average[channel] = (ushort)(total[channel] / events);
 
if (verbose) AddMessage(" {channel:%d} : {min:0x%d} {max:0x%d} {max-min:%d} {average:%d}\n", channel + 1, min[channel], max[channel], max[channel] - min[channel], average[channel]);
//if (channel < (CHANNELS - 1))
// tbAdcStatistics.AppendText(Environment.NewLine);
 
}
//SetTextboxToTop(tbAdcStatistics);
return 1;
};
 
 
int CVICALLBACK RefreshGraphs (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
switch (event) {
case EVENT_TIMER_TICK:
// if (!daq_on ) return 0;
case EVENT_COMMIT: {
int ch=0;
int logy=0;
int updateplots=0;
GetCtrlVal(ait,AIT_CH, &ch);
GetCtrlVal(ait,AIT_LOGY, &logy);
GetCtrlVal(ait,AIT_UPDATEPLOTS, &updateplots);
if (!updateplots) return 0;
if (logy){
SetCtrlAttribute (ait, AIT_GRAPH, ATTR_YMAP_MODE, VAL_LOG);
SetCtrlAttribute (ait, AIT_GRAPHSUM, ATTR_YMAP_MODE, VAL_LOG);
} else {
SetCtrlAttribute (ait, AIT_GRAPH, ATTR_YMAP_MODE, VAL_LINEAR);
SetCtrlAttribute (ait, AIT_GRAPHSUM, ATTR_YMAP_MODE, VAL_LINEAR);
}
H1D_Draw(ch,ait,AIT_GRAPH,&plothandle[0]);
H1D_Draw(10,ait,AIT_GRAPHSUM,&plothandle[1]);
H2D_Draw(0,ait,AIT_GRAPHXY,&plothandle[2]);
 
}
 
break;
 
}
return 0;
}
 
 
 
int CVICALLBACK daq(void *functionData) {
 
 
int neve;
char filename[0xff];
char fname[0xff];
char pname[0xff];
 
 
 
int pfreq;
int enabledoutput;
int neveold = 0;
double rate;
int *args = (int *) functionData;
 
GetCtrlVal(ait, AIT_FILENAME, fname );
GetCtrlVal(ait, AIT_PATHNAME, pname );
sprintf(filename,"%s/%s", pname, fname);
 
GetCtrlVal(ait,AIT_NEVE, &neve);
GetCtrlVal(ait,AIT_DEBUG, &verbose);
GetCtrlVal(ait,AIT_PFREQ, &pfreq);
GetCtrlVal(ait,AIT_ENABLEDOUTPUT, &enabledoutput);
 
int range=0;
int nch = range;
GetCtrlVal(ait,AIT_MAX, &range);
if (range>512) nch = 512;
for (int i=0; i<4; i++) {
char name[0xFF];
sprintf(name,"adc%d", i);
H1D_Init(i, name,name, range, 0 , range);
H1D_SetTitleX(0,"ADC");
H1D_SetTitleY(0,"N");
}
H1D_Init(10, "adcsum","adcsum", range, 0 , 4*range);
H1D_SetTitleX(0,"ADC");
H1D_SetTitleY(0,"N");
 
H2D_Init(0, "cog","Center of gravity", 256, 0 ,1, 256, 0 ,1);
H2D_SetTitleX(0,"x");
H2D_SetTitleY(0,"y");
 
 
 
FILE *fp= NULL;
 
if (enabledoutput) {
if (args[0]) fp = fopen(filename,"wb");
else fp = fopen(filename,"ab");
}
 
 
 
time_t t=0,told=0, tstart=0;
 
if (!AitInit()) {
ReadRegisters();
 
// Update UI
int csrDetector = ReadSD4Register(ADDR_CSR_DETECTOR);
 
int value = ((GetBit(csrDetector, BIT_CSR_DET_ADCGAIN2) ? 1 : 0) << 1) |
((GetBit(csrDetector, BIT_CSR_DET_ADCGAIN1) ? 1 : 0) << 0);
SetCtrlVal (ait, AIT_GETADCGAIN, value);
double valued = GetThreshold();
SetCtrlVal (ait, AIT_GETADCTHRESHOLD, valued);
valued = GetIntegrationTime();
SetCtrlVal (ait, AIT_GETADCINTEGRATIONTIME, valued);
valued = GetHvVoltage(ADDR_HV_VMON);
SetCtrlVal (ait, AIT_BIASMON, valued);
value =
((GetBit(csrDetector, BIT_CSR_DET_SUMGAIN4) ? 1 : 0) << 3) |
((GetBit(csrDetector, BIT_CSR_DET_SUMGAIN3) ? 1 : 0) << 2) |
((GetBit(csrDetector, BIT_CSR_DET_SUMGAIN2) ? 1 : 0) << 1) |
((GetBit(csrDetector, BIT_CSR_DET_SUMGAIN1) ? 1 : 0) << 0);
SetCtrlVal (ait, AIT_GETADCSUMGAIN, value);
 
RefreshGraphs (ait, 0 , EVENT_COMMIT ,NULL, 0, 0 );
daq_on=1;
//RefreshGraphs (ait, 0 , EVENT_TIMER_TICK ,NULL, 0, 0 );
time(&tstart);
told=tstart;
int i=0;
for (i=0; i<neve; i++) {
start_timer(1);// 1 s timeout
// Set ADC reset
ResetAdc(true);
// Clear ADC reset
ResetAdc(false);
int eventsAcquired = Acquire(pfreq);
stop_timer();
if (!daq_on) break;
if (timeout) {
i--;
printf("INFO Timeout\n");
continue;
}
int isvalid =1;
if (eventsAcquired < 1) {
printf("Acquired events %d\n", eventsAcquired);
isvalid = 0;
} else {
AitFillHistograms(eventsAcquired);
if (verbose) ShowEvent(1);
}
 
int nb = ( isvalid && fp ) ? AitToFile( fp , pfreq ) : 0;
SetCtrlVal(ait,AIT_CEVE,i);
if (!isvalid) i--;
time(&t);
if (t!=told ) {
rate = (i-neveold);
printf("%d events in %2.2f min (%d s) Rate %f Hz %s ",i+1, (double)(t-tstart)/60.,(t-tstart), rate , ctime(&t));
neveold = i;
RefreshGraphs (ait, 0 , EVENT_COMMIT ,NULL, 0, 0 );
double daqBlocksize = GetAdcEventSize() * pfreq * 2.0;
double daqTimeMs = BlockTransferTime();
double daqTransferRate = daqBlocksize / daqTimeMs;
SetCtrlVal(ait,AIT_DAQBLOCKSIZE, daqBlocksize);
SetCtrlVal(ait,AIT_DAQTIMEMS,daqTimeMs);
SetCtrlVal(ait,AIT_DAQTRANSFERRATE,daqTransferRate);
}
told=t;
 
 
 
}
time(&t);
printf("%d events in %2.2f min (%d s) %s",i+1, (double)(t-tstart)/60.,t-tstart, ctime(&t));
 
}
 
if (fp) fclose(fp);
 
RefreshGraphs (ait, 0 , EVENT_TIMER_TICK ,NULL, 0, 0 );
return 0;
 
}
 
 
int CVICALLBACK scan(void *functionData) {
 
int dx[3]={0,0,0};
int nx[3]={0,0,0};
int x0[3]={0,0,0};
int ix[3]={0,0,0};
int idx[3]={0,0,0};
unsigned short size;
unsigned short posrec={0x2};
unsigned short runbuf={0x3};
int n[3];
char filename[0xFF];
char fname[0xff];
char pname[0xff];
int enabledoutput;
FILE *fp;
GetCtrlVal(ait, AIT_FILENAME, fname );
GetCtrlVal(ait, AIT_PATHNAME, pname );
sprintf(filename,"%s/%s", pname, fname);
GetCtrlVal(ait,AIT_ENABLEDOUTPUT, &enabledoutput);
int fsize;
if ( GetFileInfo(filename,&fsize) ) {
MessagePopup ("Warning", "File exist. Remove it first or choose another file");
return 0;
}
GetCtrlVal(xyscan, SCAN_STEPX, &dx[0]);
GetCtrlVal(xyscan, SCAN_STEPY, &dx[1]);
GetCtrlVal(xyscan, SCAN_NSTEPSX, &nx[0]);
GetCtrlVal(xyscan, SCAN_NSTEPSY, &nx[1]);
GetCtrlVal(xyscan, SCAN_STARTX, &x0[0]);
GetCtrlVal(xyscan, SCAN_STARTY, &x0[1]);
 
if (enabledoutput) {
fp = fopen(filename,"ab");
if (fp) {
size=36;
fwrite(&runbuf, sizeof(unsigned short),1 ,fp);
fwrite(&size , sizeof(unsigned short),1 ,fp);
fwrite(x0 , 1,4*3 ,fp);
fwrite(dx , 1,4*3 ,fp);
fwrite(nx , 1,4*3 ,fp);
fclose(fp);
}
}
for (int j=0; j<nx[1]; j++) {
SetCtrlVal (xyscan, SCAN_IY, j);
ix[1]= x0[1]+j*dx[1];
#ifdef MIKRO
MIKRO_MoveTo(2,ix[1]);
MIKRO_GetPosition(2,&n[1]);
SetCtrlVal (xyscan, SCAN_YP, n[1]);
#endif
for (int i=0; i<nx[0]; i++) {
SetCtrlVal (xyscan, SCAN_IX, i);
ix[0]= x0[0]+i*dx[0];
#ifdef MIKRO
MIKRO_MoveTo(1,ix[0]);
MIKRO_GetPosition(1,&n[0]);
SetCtrlVal (xyscan, SCAN_XP, n[0]);
if (enabledoutput) {
fp = fopen(filename,"ab");
if (fp) {
time_t mtime;
idx[0]=i;
idx[1]=j;
size=24+sizeof(mtime);
fwrite(&posrec, sizeof(unsigned short),1 ,fp);
fwrite(&size , sizeof(unsigned short),1 ,fp);
fwrite(n , 1,4*3 ,fp);
fwrite(idx , 1,4*3 ,fp);
time(&mtime);
fwrite(&mtime , sizeof(time_t),1 ,fp);
fclose(fp);
}
}
#endif
int newfile=0;
daq(&newfile);
if (!daq_on) break;
}
if (!daq_on) break;
}
 
return 0;
}
 
 
int main (int argc, char *argv[]) {
short port;
if (InitCVIRTE (0, argv, 0) == 0)
return -1; /* out of memory */
if ((ait = LoadPanel (0, "AitGui.uir", AIT)) < 0)
return -1;
if ((xyscan = LoadPanel (0, "XYSCAN.uir", SCAN)) < 0)
return -1;
SetStdioPort (CVI_STDIO_WINDOW);
SetSleepPolicy(VAL_SLEEP_MORE);
CmtNewThreadPool (MAX_THREADS, &poolHandle);
DisplayPanel (ait);
DisplayPanel (xyscan);
AitInit();
#ifdef MIKRO
GetCtrlVal(xyscan, SCAN_PORT, &port);
if (MIKRO_Open (port)) MessagePopup ("Error", "Mikro Port Not found !\n Change in the GUI") ;
MIKRO_Init(1,0);
MIKRO_Init(2,0);
#endif
RunUserInterface ();
#ifdef MIKRO
MIKRO_Close ();
#endif
DiscardPanel (ait);
DiscardPanel (xyscan);
return 0;
}
 
int CVICALLBACK StopCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
switch (event) {
case EVENT_COMMIT:
daq_on=0;
break;
}
return 0;
}
 
 
int CVICALLBACK StartCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
ThreadFunctionPtr mythread = NULL;
switch (event) {
 
case EVENT_COMMIT:
 
controlID= control;
if (panel == ait && control == AIT_START) {
mythread = daq;
}
if (panel == xyscan && control == SCAN_SCAN) mythread = scan;
if (mythread!=NULL) {
printf("New Thread panel=%d button=%d\n", panel, control);
 
// SetDimming(1);
 
CmtScheduleThreadPoolFunctionAdv (poolHandle, mythread, &controlID,
DEFAULT_THREAD_PRIORITY,
EndOfThread,
EVENT_TP_THREAD_FUNCTION_END,
NULL, RUN_IN_SCHEDULED_THREAD,
&tfID);
}
break;
}
return 0;
}
 
 
 
int CVICALLBACK ExitCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
switch (event) {
case EVENT_COMMIT:
QuitUserInterface (0);
break;
}
return 0;
}
 
int CVICALLBACK ReadCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
switch (event) {
case EVENT_COMMIT:
 
 
 
ReadRegisters();
break;
}
return 0;
}
 
int CVICALLBACK ChangeChannelCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
int ch=0;
switch (event) {
case EVENT_COMMIT:
 
int logy=0;
GetCtrlVal(ait,AIT_CH, &ch);
GetCtrlVal(ait,AIT_LOGY, &logy);
if (logy){
SetCtrlAttribute (ait, AIT_GRAPH, ATTR_YMAP_MODE, VAL_LOG);
SetCtrlAttribute (ait, AIT_GRAPHSUM, ATTR_YMAP_MODE, VAL_LOG);
} else {
SetCtrlAttribute (ait, AIT_GRAPH, ATTR_YMAP_MODE, VAL_LINEAR);
SetCtrlAttribute (ait, AIT_GRAPHSUM, ATTR_YMAP_MODE, VAL_LINEAR);
}
H1D_Draw(ch,ait,AIT_GRAPH,&plothandle[0]);
break;
}
return 0;
}
 
 
 
 
 
int CVICALLBACK InitCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
switch (event) {
case EVENT_COMMIT:
AitInit();
break;
}
return 0;
}
 
int CVICALLBACK QuickCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
switch (event) {
case EVENT_COMMIT:
switch (control) {
case AIT_QUICKSETUP_1:
QuickSetupContinuous();
SetCtrlVal(ait,AIT_TRGTYPE, 0);
break;
case AIT_QUICKSETUP_2:
QuickSetupDiscriminator();
SetCtrlVal(ait,AIT_TRGTYPE, 2);
break;
case AIT_QUICKSETUP_3:
QuickSetupTriggerOff();
break;
 
 
}
float bias = GetHvVoltage(ADDR_HV_VMON);
SetCtrlVal (panel, AIT_BIASMON, bias);
double value = GetIntegrationTime();
SetCtrlVal (panel, AIT_GETADCINTEGRATIONTIME, value);
value = GetThreshold();
SetCtrlVal (panel, AIT_GETADCTHRESHOLD, value);
int csrDetector = ReadSD4Register(ADDR_CSR_DETECTOR);
 
int ivalue = ((GetBit(csrDetector, BIT_CSR_DET_ADCGAIN2) ? 1 : 0) << 1) |
((GetBit(csrDetector, BIT_CSR_DET_ADCGAIN1) ? 1 : 0) << 0);
SetCtrlVal (panel, AIT_GETADCGAIN, ivalue);
ivalue =
((GetBit(csrDetector, BIT_CSR_DET_SUMGAIN4) ? 1 : 0) << 3) |
((GetBit(csrDetector, BIT_CSR_DET_SUMGAIN3) ? 1 : 0) << 2) |
((GetBit(csrDetector, BIT_CSR_DET_SUMGAIN2) ? 1 : 0) << 1) |
((GetBit(csrDetector, BIT_CSR_DET_SUMGAIN1) ? 1 : 0) << 0);
SetCtrlVal (panel, AIT_GETADCSUMGAIN, ivalue);
break;
}
return 0;
}
 
 
 
int CVICALLBACK MoveStageCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
int axis=0, step=1000, direction=1;
switch (event) {
case EVENT_COMMIT:
 
if (panel == xyscan) {
switch (control) {
case SCAN_BR :
axis = 1;
direction = 1;
GetCtrlVal(panel, SCAN_STEPX, &step);
break;
case SCAN_BL :
axis = 1;
direction = -1;
GetCtrlVal(panel, SCAN_STEPX, &step);
break;
case SCAN_BU :
axis = 2;
direction = 1;
GetCtrlVal(panel, SCAN_STEPY, &step);
break;
case SCAN_BD :
axis = 2;
direction = -1;
GetCtrlVal(panel, SCAN_STEPY, &step);
break;
}
#ifdef MIKRO
{
int n=0;
MIKRO_MoveFor(axis, direction*step );
MIKRO_GetPosition(axis,&n);
if (axis == 1) SetCtrlVal (panel, SCAN_XP, n);
if (axis == 2) SetCtrlVal (panel, SCAN_YP, n);
}
#endif // MIKRO
}
 
break;
}
return 0;
}
 
 
 
 
 
int CVICALLBACK GoXCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
int n2;
switch (event) {
case EVENT_COMMIT:
GetCtrlVal (panel, SCAN_XG, &n2);
#ifdef MIKRO
MIKRO_MoveTo(1,n2);
MIKRO_GetPosition(1,&n2);
 
#endif
SetCtrlVal (panel, SCAN_XP, n2);
break;
}
return 0;
}
 
int CVICALLBACK GoYCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
int n2;
switch (event) {
case EVENT_COMMIT:
GetCtrlVal (panel, SCAN_YG, &n2);
#ifdef MIKRO
MIKRO_MoveTo(2,n2);
MIKRO_GetPosition(2,&n2);
 
#endif
SetCtrlVal (panel, SCAN_YP, n2);
break;
}
return 0;
}
 
int CVICALLBACK GetCurrentPositionCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
 
 
switch (event) {
case EVENT_COMMIT: {
#ifdef MIKRO
int n[2];
MIKRO_GetPosition(1,&n[0]);
SetCtrlVal (panel, SCAN_XP, n[0]);
MIKRO_GetPosition(2,&n[1]);
SetCtrlVal (panel, SCAN_YP, n[1]);
#endif
break;
}
}
return 0;
}
 
int CVICALLBACK HomeCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
switch (event) {
case EVENT_COMMIT:
#ifdef MIKRO
MIKRO_ReferenceMove(1);
MIKRO_ReferenceMove(2);
GetCurrentPositionCB(panel, control, event, NULL, 0, 0);
#endif
break;
}
return 0;
}
 
int CVICALLBACK SetBiasCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
double bias=0;
switch (event) {
case EVENT_COMMIT:
GetCtrlVal (panel, AIT_BIAS, &bias);
SetHvVoltage(ADDR_HV_CTRL, bias);
bias = GetHvVoltage(ADDR_HV_VMON);
SetCtrlVal (panel, AIT_BIASMON, bias);
break;
}
return 0;
}
 
int CVICALLBACK SetHvOnCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
int state=0;
double bias;
switch (event) {
case EVENT_COMMIT:
GetCtrlVal (panel, control, &state);
if (state) SetHvOn(true);
else SetHvOn(false);
bias = GetHvVoltage(ADDR_HV_VMON);
SetCtrlVal (panel, AIT_BIASMON, bias);
break;
}
return 0;
}
 
int CVICALLBACK SetAdcIntegrationTimeCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
 
switch (event) {
case EVENT_COMMIT: {
double value;
GetCtrlVal (panel, AIT_ADCINTEGRATIONTIME, &value);
SetIntegrationTime(value);
value = GetIntegrationTime();
SetCtrlVal (panel, AIT_GETADCINTEGRATIONTIME, value);
}
break;
}
return 0;
}
 
int CVICALLBACK SetAdcThresholdCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
switch (event) {
case EVENT_COMMIT: {
double value;
GetCtrlVal (panel, AIT_ADCTHRESHOLD, &value);
SetThreshold(value);
value = GetThreshold();
SetCtrlVal (panel, AIT_GETADCTHRESHOLD, value);
}
break;
}
return 0;
}
 
int CVICALLBACK SetAdcGainCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
switch (event) {
case EVENT_COMMIT: {
int value;
GetCtrlVal (panel, AIT_ADCGAIN, &value);
SetAdcGain(value);
int csrDetector = ReadSD4Register(ADDR_CSR_DETECTOR);
 
value = ((GetBit(csrDetector, BIT_CSR_DET_ADCGAIN2) ? 1 : 0) << 1) |
((GetBit(csrDetector, BIT_CSR_DET_ADCGAIN1) ? 1 : 0) << 0);
SetCtrlVal (panel, AIT_GETADCGAIN, value);
}
break;
}
return 0;
}
 
int CVICALLBACK SetAdcSumGainCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
switch (event) {
case EVENT_COMMIT:{
int value;
GetCtrlVal (panel, AIT_ADCSUMGAIN, &value);
SetSumGain(value);
int csrDetector = ReadSD4Register(ADDR_CSR_DETECTOR);
value =
((GetBit(csrDetector, BIT_CSR_DET_SUMGAIN4) ? 1 : 0) << 3) |
((GetBit(csrDetector, BIT_CSR_DET_SUMGAIN3) ? 1 : 0) << 2) |
((GetBit(csrDetector, BIT_CSR_DET_SUMGAIN2) ? 1 : 0) << 1) |
((GetBit(csrDetector, BIT_CSR_DET_SUMGAIN1) ? 1 : 0) << 0);
SetCtrlVal (panel, AIT_GETADCSUMGAIN, value);
}
 
break;
}
return 0;
}
 
int CVICALLBACK SetDiscriminatorTypeCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
switch (event) {
case EVENT_COMMIT:{
int trgtype;
GetCtrlVal(ait,AIT_TRGTYPE, &trgtype);
EnableTrigger(trgtype);
}
break;
}
return 0;
}
 
int CVICALLBACK ResetCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
switch (event) {
case EVENT_COMMIT:
ReconfigureDevice() ;
ReconnectDevice();
//ResetDevice() ;
break;
}
return 0;
}
 
int CVICALLBACK OpenScanCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
switch (event) {
case EVENT_COMMIT:
DisplayPanel (xyscan);
break;
}
return 0;
}
 
int CVICALLBACK OpenMainCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2) {
switch (event) {
case EVENT_COMMIT:
DisplayPanel (ait);
break;
}
return 0;
}
/cvi/instr/AitSipmDAQ/AitGui.h
0,0 → 1,98
/**************************************************************************/
/* LabWindows/CVI User Interface Resource (UIR) Include File */
/* */
/* WARNING: Do not add to, delete from, or otherwise modify the contents */
/* of this include file. */
/**************************************************************************/
 
#include <userint.h>
 
#ifdef __cplusplus
extern "C" {
#endif
 
/* Panels and Controls: */
 
#define AIT 1
#define AIT_OPENSCAN 2 /* control type: command, callback function: OpenScanCB */
#define AIT_RESET 3 /* control type: command, callback function: ResetCB */
#define AIT_EXIT 4 /* control type: command, callback function: ExitCB */
#define AIT_SETADCSUMGAIN 5 /* control type: command, callback function: SetAdcSumGainCB */
#define AIT_SETADCGAIN 6 /* control type: command, callback function: SetAdcGainCB */
#define AIT_SETADCINTEGRATIONTIME 7 /* control type: command, callback function: SetAdcIntegrationTimeCB */
#define AIT_SETADCTHRESHOLD 8 /* control type: command, callback function: SetAdcThresholdCB */
#define AIT_SETBIAS 9 /* control type: command, callback function: SetBiasCB */
#define AIT_STOP 10 /* control type: command, callback function: StopCB */
#define AIT_QUICKSETUP_3 11 /* control type: command, callback function: QuickCB */
#define AIT_PATHNAME 12 /* control type: string, callback function: (none) */
#define AIT_FILENAME 13 /* control type: string, callback function: (none) */
#define AIT_QUICKSETUP_2 14 /* control type: command, callback function: QuickCB */
#define AIT_PFREQ 15 /* control type: numeric, callback function: (none) */
#define AIT_QUICKSETUP_1 16 /* control type: command, callback function: QuickCB */
#define AIT_INIT 17 /* control type: command, callback function: InitCB */
#define AIT_READ 18 /* control type: command, callback function: ReadCB */
#define AIT_UPDATEPLOTS 19 /* control type: radioButton, callback function: (none) */
#define AIT_LOGY 20 /* control type: radioButton, callback function: (none) */
#define AIT_ENABLEDOUTPUT 21 /* control type: radioButton, callback function: (none) */
#define AIT_DEBUG 22 /* control type: radioButton, callback function: (none) */
#define AIT_START 23 /* control type: command, callback function: StartCB */
#define AIT_MAX 24 /* control type: numeric, callback function: (none) */
#define AIT_CH 25 /* control type: numeric, callback function: ChangeChannelCB */
#define AIT_ADCSUMGAIN 26 /* control type: numeric, callback function: (none) */
#define AIT_NEVE 27 /* control type: numeric, callback function: (none) */
#define AIT_ADCGAIN 28 /* control type: numeric, callback function: (none) */
#define AIT_ADCINTEGRATIONTIME 29 /* control type: numeric, callback function: (none) */
#define AIT_ADCTHRESHOLD 30 /* control type: numeric, callback function: (none) */
#define AIT_XYCUT 31 /* control type: numeric, callback function: (none) */
#define AIT_BIAS 32 /* control type: numeric, callback function: (none) */
#define AIT_GRAPHXY 33 /* control type: graph, callback function: (none) */
#define AIT_GETADCSUMGAIN 34 /* control type: numeric, callback function: (none) */
#define AIT_GRAPHSUM 35 /* control type: graph, callback function: (none) */
#define AIT_GRAPH 36 /* control type: graph, callback function: (none) */
#define AIT_GETADCGAIN 37 /* control type: numeric, callback function: (none) */
#define AIT_GETADCINTEGRATIONTIME 38 /* control type: numeric, callback function: (none) */
#define AIT_GETADCTHRESHOLD 39 /* control type: numeric, callback function: (none) */
#define AIT_BIASMON 40 /* control type: numeric, callback function: (none) */
#define AIT_DAQTRANSFERRATE 41 /* control type: numeric, callback function: (none) */
#define AIT_DAQTIMEMS 42 /* control type: numeric, callback function: (none) */
#define AIT_DAQBLOCKSIZE 43 /* control type: numeric, callback function: (none) */
#define AIT_CEVE 44 /* control type: numeric, callback function: (none) */
#define AIT_STDIO 45 /* control type: textBox, callback function: (none) */
#define AIT_TIMER 46 /* control type: timer, callback function: SetTimeoutCB */
#define AIT_TRGTYPE 47 /* control type: ring, callback function: SetDiscriminatorTypeCB */
#define AIT_RTIMER 48 /* control type: timer, callback function: (none) */
 
 
/* Control Arrays: */
 
/* (no control arrays in the resource file) */
 
 
/* Menu Bars, Menus, and Menu Items: */
 
/* (no menu bars in the resource file) */
 
 
/* Callback Prototypes: */
 
int CVICALLBACK ChangeChannelCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
int CVICALLBACK ExitCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
int CVICALLBACK InitCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
int CVICALLBACK OpenScanCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
int CVICALLBACK QuickCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
int CVICALLBACK ReadCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
int CVICALLBACK ResetCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
int CVICALLBACK SetAdcGainCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
int CVICALLBACK SetAdcIntegrationTimeCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
int CVICALLBACK SetAdcSumGainCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
int CVICALLBACK SetAdcThresholdCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
int CVICALLBACK SetBiasCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
int CVICALLBACK SetDiscriminatorTypeCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
int CVICALLBACK SetTimeoutCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
int CVICALLBACK StartCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
int CVICALLBACK StopCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
 
 
#ifdef __cplusplus
}
#endif
/cvi/instr/AitSipmDAQ/AitGui.uir
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/cvi/instr/AitSipmDAQ/AitInterface.c
0,0 → 1,1103
// NativeExportsConsumerApp.cpp : Defines the entry point for the console application.
//
#include <utility.h>
#include <stdlib.h>
#include <stdio.h>
#include "AitMduManager.h"
#include "AitMduManager_DEF.h"
 
//Unhandled Exception: System.Runtime.InteropServices.MarshalDirectiveException:
//Cannot marshal 'return value': Invalid managed/unmanaged type combination.
#ifdef _CVI_
#include <ansi_c.h>
 
#define AddMessageI(x) AddMessage("%s %d\n", #x, x);
#define AddMessageF(x) AddMessage("%s %f\n", #x, x);
#define AddMessageX(x) AddMessage("%s 0x%x\n", #x, x);
#define AddMessageS(x) AddMessage("%s %s\n", #x, x);
 
int sprintf_s(const char *dest, int len, const char *format, ...) {
va_list aptr;
int ret;
 
 
va_start(aptr, format);
ret = vsnprintf(dest, len, format, aptr);
va_end(aptr);
return(ret);
}
 
 
#endif
 
typedef unsigned short ushort;
typedef unsigned int uint;
#ifdef __cplusplus
extern "C"
{
#endif
__declspec(dllimport) void NE_Rainbow();
#ifdef __cplusplus
}
#endif
 
#ifndef _CVI_
 
#ifdef _DEBUG
#pragma comment(lib, "../NativeExports/bin/Debug/NativeExports.lib")
#else
#pragma comment(lib, "../NativeExports/bin/Release/NativeExports.lib")
#endif
 
#endif
 
//private MduManager SD4;
uint deviceId = 0;
int deviceIndex = -1;
int adcBufferLen;
ushort *adcBuffer;
int histograms[4][0xFFF];
int histogramtotal[0xFFF * 4];
 
int histogramTotalEvents = 0;
 
const double MONADC_SCALE = 65535.0; // 16-bit monitor ADC
const double DAC_SCALE = 65535.0; // 16-bit DAC
const double MONADC_VRANGE = 2.5; // 2.5V ADC voltage range
const double DISCR_OFFSETRANGE = 250.0; // +/- 250mV discriminator offset range
const double DISCR_THRESHOLDRANGE = 1000.0; // 0-1000mV discriminator threshold range
const double HV_IRANGE = 5.0; // 0-5.0mA HV current monitor range
const double HV_VRANGE = 80.0; // 0-80V HV voltage control range
const int INTEGRATOR_LSB = 10; // 10ns integrator time resolution
const double RAMPRATESCALE = 61036.0; // Ramp rate register setting = (rate in V/s) / RAMPRATESCALE
const char statusNoDevice[0xFF] = "No Device Connected";
const char statusReconfig[0xFF] = "Reconfiguring Device ... ";
const char statusReset[0xFF] = "Resetting Device ... ";
const char statusReconnect[0xFF] = "Reconnecting Device ... ";
const char statusDone[0xFF] = "Done";
 
 
const int CHANNELS = 4; // 4-Channel DAQ
const int ADCMAX = 4096; // 12-bit ADC
 
bool addTimeStamp = false; // updated by ReadRegisters
bool addEventCount = false; // updated by ReadRegisters
bool addChannelNum = false; // updated by ReadRegisters
 
int TIMESTAMP_LSB = 10; // 10ns time stamp resolution
 
 
 
void Sleep(int musec) {
Delay(musec/1000.);
}
 
/*
void AddMessage( const char * message)
{
printf("%s\n", message);
}
*/
 
int AddMessage(const char *format, ...) {
va_list aptr;
int ret;
 
char strbuf[0xFF];
 
va_start(aptr, format);
ret = vsprintf(strbuf, format, aptr);
va_end(aptr);
// SetCtrlVal(p1h,P1_STDIO,strbuf);
 
printf("%s", strbuf);
 
return(ret);
}
 
 
//----------------------------------------
// Utilities
//----------------------------------------
ushort SetBit(ushort data, int bitIndex, bool bitValue) {
if (bitValue == true)
return (ushort)(data | (1 << bitIndex));
else
return (ushort)(data & ~(1 << bitIndex));
}
 
bool GetBit(int data, int bitIndex) {
return (data & (1 << bitIndex)) != 0;
}
 
ushort ReadSD4Register(int reg) {
return SD4_Read(deviceId, reg);
}
 
uint ReadSD4Register32(int addrHi, int addrLo) {
uint dataHi = (uint)SD4_Read(deviceId, addrHi);
uint dataLo = (uint)SD4_Read(deviceId, addrLo);
return (dataHi << 16) | dataLo;
}
 
void WriteSD4Register(int address, ushort data) {
SD4_Write(deviceId, address, data);
}
 
void WriteSD4Register32(int addrHi, int addrLo, uint data) {
WriteSD4Register(addrHi, (ushort)(data >> 16));
WriteSD4Register(addrLo, (ushort)data);
}
 
 
void ReadModifyWrite(int reg, int bitIndex, bool bitValue) {
ushort regData = ReadSD4Register(reg);
regData = SetBit(regData, bitIndex, bitValue);
WriteSD4Register(reg, regData);
}
 
double LimitSetting(double value, double min, double max) {
double limited = value;
if (limited > max) limited = max;
if (limited < min) limited = min;
return limited;
}
 
 
 
int ReadAdcBuffer()
{
//if (adcBuffer == NULL)
// return -1;
int bytes = 0;
//printf("In\n%d\n%d\n%d\n", deviceId, ADDR_BUFFER, adcBufferLen);
adcBuffer = SD4_ReadUShortArray(deviceId, ADDR_BUFFER, adcBufferLen, &bytes);
return bytes/2;
}
int ReadAdcByteBuffer()
{
if (adcBuffer == NULL)
return -1;
int bytes = 0;
char * byteBuffer = SD4_ReadByteArray(deviceId, ADDR_BUFFER, adcBufferLen * 2, &bytes);
int byteIndex = 0;
int words = bytes / 2;
ushort dataword = 0;
for (int i = 0; i < words; i++)
{
dataword = (ushort)(byteBuffer[byteIndex++] << 8);
adcBuffer[i] = (ushort)(dataword | byteBuffer[byteIndex++]);
}
return words;
}
 
 
 
 
 
//----------------------------------------
// Monitor ADC
//----------------------------------------
 
double GetVoltage(int reg) {
return ReadSD4Register(reg) * MONADC_VRANGE / MONADC_SCALE;
}
 
double GetDetectorTemperature() {
// Temperature = 500mV + 1mV per degree C
return (GetVoltage(ADDR_BASE_TEMPERATURE) - 0.5) / 0.01;
}
 
double GetHvVoltage(int reg) {
return GetVoltage(reg) / MONADC_VRANGE * HV_VRANGE;
}
 
double GetHvCurrentInUa() {
// 2.5V ADC input voltage = 5000 microamps
return GetVoltage(ADDR_HV_IMON) * 2000.0;
}
 
double GetVoltage75(int reg) {
// 2.5V ADC input voltage = 7.5V monitor voltage
return GetVoltage(reg) * 3.0;
}
 
 
 
//----------------------------------------
// Discriminator, Sum
//----------------------------------------
 
void SetSumGain(int gain) {
ushort csrDetector = ReadSD4Register(ADDR_CSR_DETECTOR);
bool g1 = GetBit(gain, 0);
bool g2 = GetBit(gain, 1);
bool g3 = GetBit(gain, 2);
bool g4 = GetBit(gain, 3);
csrDetector = SetBit(csrDetector, BIT_CSR_DET_SUMGAIN1, g1);
csrDetector = SetBit(csrDetector, BIT_CSR_DET_SUMGAIN2, g2);
csrDetector = SetBit(csrDetector, BIT_CSR_DET_SUMGAIN3, g3);
csrDetector = SetBit(csrDetector, BIT_CSR_DET_SUMGAIN4, g4);
WriteSD4Register(ADDR_CSR_DETECTOR, (ushort)csrDetector);
}
 
void SetSumCoupling(bool acCoupling) {
ReadModifyWrite(ADDR_CSR_DETECTOR, BIT_CSR_DET_SUMCOUPLING, acCoupling);
}
 
void SetThreshold(double thresholdInMillivolts) {
thresholdInMillivolts = LimitSetting(thresholdInMillivolts, -DISCR_THRESHOLDRANGE, DISCR_THRESHOLDRANGE);
WriteSD4Register(ADDR_DISCR_THRESHOLD, (ushort)(thresholdInMillivolts * DAC_SCALE / DISCR_THRESHOLDRANGE));
}
 
double GetThreshold() {
return ReadSD4Register(ADDR_DISCR_THRESHOLD) / DAC_SCALE * DISCR_THRESHOLDRANGE;
}
 
double GetSumOffsetInMv() {
// Sum offsets are with respect to the positive sum output polarity.
return (ReadSD4Register(ADDR_DISCR_OFFSET) / DAC_SCALE * (DISCR_OFFSETRANGE * 2)) - DISCR_OFFSETRANGE;
}
 
void SetSumOffset(double milliVolts) {
// Sum offsets are with respect to the positive sum output polarity.
// Actual output offset is multiplied by the selectable gain stage.
WriteSD4Register(ADDR_DISCR_OFFSET, (ushort)((milliVolts + DISCR_OFFSETRANGE) * DAC_SCALE / (DISCR_OFFSETRANGE * 2)));
}
 
 
 
//----------------------------------------
// Trigger
//----------------------------------------
 
void SetTriggerInterval(int triggerInterval) {
WriteSD4Register32(ADDR_TG_INTERVALHI, ADDR_TG_INTERVALLO, (uint)(triggerInterval / INTEGRATOR_LSB));
}
 
void SetTriggerBurst(int triggerBurst) {
WriteSD4Register32(ADDR_TG_COUNTHI, ADDR_TG_COUNTLO, (uint)triggerBurst);
}
 
void EnableTrigger(int bitIndex) {
WriteSD4Register(ADDR_CSR_TRIGGER, SetBit(0, bitIndex, true));
}
 
void DisableTriggers() {
WriteSD4Register(ADDR_CSR_TRIGGER, 0);
}
 
void SetDeadTime(int deadTimeInNs) {
WriteSD4Register(ADDR_DEADTIME, (ushort)(deadTimeInNs / INTEGRATOR_LSB));
}
 
 
 
//----------------------------------------
// Integrators, ADCs
//----------------------------------------
 
void SetIntegrationTime(int integrationTime) {
WriteSD4Register(ADDR_ITIME, (ushort)(integrationTime / INTEGRATOR_LSB));
}
 
int GetIntegrationTime() {
return ReadSD4Register(ADDR_ITIME) * INTEGRATOR_LSB;
}
 
void SetAdcCoupling(bool acCoupling) {
ReadModifyWrite(ADDR_CSR_DETECTOR, BIT_CSR_DET_ADCCOUPLING, acCoupling);
}
 
void ResetAdc(bool reset) {
ushort cmd = 0;
cmd = SetBit(cmd, BIT_CSR_MAIN_ADCRESET, reset);
WriteSD4Register(ADDR_CSR_MAIN, cmd);
}
 
double GetAdcOffsetInMv(int reg) {
// ADC offset polarity is with respect to the positive ADC polarity (integrator output), not the main negative input signal polarity.
// Actual output offset is multiplied by the selectable gain stage.
return DISCR_OFFSETRANGE - (ReadSD4Register(reg) / DAC_SCALE * (DISCR_OFFSETRANGE * 2));
}
 
void SetAdcOffset(int reg, double milliVolts) {
// ADC offset polarity is with respect to the positive ADC polarity (integrator output), not the main negative input signal polarity.
// Actual output offset is multiplied by the selectable gain stage.
WriteSD4Register(reg, (ushort)((DISCR_OFFSETRANGE - milliVolts) * DAC_SCALE / (DISCR_OFFSETRANGE * 2)));
}
 
 
 
//----------------------------------------
// Event ID
//----------------------------------------
 
void AddEventCount(bool addEventCount) {
ReadModifyWrite(ADDR_EVENTID, BIT_EVENTID_COUNT, addEventCount);
}
 
void AddTimeStamp(bool addTimeStamp) {
ReadModifyWrite(ADDR_EVENTID, BIT_EVENTID_TIME, addTimeStamp);
}
 
void AddChannelNumber(bool addChannelNumber) {
ReadModifyWrite(ADDR_EVENTID, BIT_EVENTID_CHNUM, addChannelNumber);
}
 
 
 
//----------------------------------------
// Detector VA
//----------------------------------------
 
void SetDetectorVaOn(bool on) {
ReadModifyWrite(ADDR_CSR_DETECTOR, BIT_CSR_DET_VAENABLE, on);
}
 
void SetDetectorVaHiRange(bool range) {
ReadModifyWrite(ADDR_CSR_DETECTOR, BIT_CSR_DET_VAHIRNG, range);
}
 
 
 
//----------------------------------------
// High Voltage
//----------------------------------------
 
void SetHvCurrentLimit(double milliamps) {
milliamps = LimitSetting(milliamps, 0, HV_IRANGE);
WriteSD4Register(ADDR_HV_ILIMIT, (ushort)(milliamps * DAC_SCALE / HV_IRANGE));
}
 
void SetHvVoltage(int reg, double volts) {
volts = LimitSetting(volts, 0, HV_VRANGE);
WriteSD4Register(reg, (ushort)(volts * DAC_SCALE / HV_VRANGE));
}
 
double GetHvIlimitSetting() {
return ReadSD4Register(ADDR_HV_ILIMIT) / DAC_SCALE * HV_IRANGE;
}
 
double GetHvVoltageSetting() {
return ReadSD4Register(ADDR_HV_CTRL) / DAC_SCALE * HV_VRANGE;
}
 
void SetHvOn(bool hvOn) {
ReadModifyWrite(ADDR_CSR_DETECTOR, BIT_CSR_DET_HVENABLE, hvOn);
}
 
void SetMaximumHvSetting(double volts) {
SetHvVoltage(ADDR_HV_MAX, volts);
}
 
void CycleHvReset() {
// CAUTION: Holding HV in reset will force it to ignore the current limit
ReadModifyWrite(ADDR_CSR_DETECTOR, BIT_CSR_DET_HVRESET, true);
ReadModifyWrite(ADDR_CSR_DETECTOR, BIT_CSR_DET_HVRESET, false);
}
 
void SetRampRate(double voltsPerSecond) {
WriteSD4Register(ADDR_HV_RAMPRATE, (ushort)(RAMPRATESCALE / voltsPerSecond));
}
 
double GetRampRate() {
return RAMPRATESCALE / (ReadSD4Register(ADDR_HV_RAMPRATE) + 1);
}
 
void SetAdcGain(int gain) {
ushort csrDetector = ReadSD4Register(ADDR_CSR_DETECTOR);
bool g1 = GetBit(gain, 0);
bool g2 = GetBit(gain, 1);
csrDetector = SetBit(csrDetector, BIT_CSR_DET_ADCGAIN1, g1);
csrDetector = SetBit(csrDetector, BIT_CSR_DET_ADCGAIN2, g2);
WriteSD4Register(ADDR_CSR_DETECTOR, (ushort)csrDetector);
}
 
void SetAdcOffsets(int offsetInMv) {
//nudOffset1.Value = offsetInMv;
//nudOffset2.Value = offsetInMv;
//nudOffset3.Value = offsetInMv;
//nudOffset4.Value = offsetInMv;
SetAdcOffset(ADDR_OFFSET1, offsetInMv);
SetAdcOffset(ADDR_OFFSET2, offsetInMv);
SetAdcOffset(ADDR_OFFSET3, offsetInMv);
SetAdcOffset(ADDR_OFFSET4, offsetInMv);
}
 
void QuickSetupContinuous() {
// Set ADC reset
ResetAdc(true);
 
// Clear ADC reset
ResetAdc(false);
 
// Set trigger dead time to 200ns
SetDeadTime(200);
 
// Set event ID
AddTimeStamp(true);
AddEventCount(true);
AddChannelNumber(true);
 
// Enable detector amplifier voltage
SetDetectorVaHiRange(false);
SetDetectorVaOn(true);
 
/*
// Set HV current limit
double iLimit = 2.5;
nudHvIlimit.Value = (decimal)iLimit;
SetHvCurrentLimit(iLimit);
 
// Reset any HV faults
CycleHvReset();
 
// Enable bias voltage
SetHvOn(false);
SetHvOn(true);
 
// Set bias voltage
double hvVoltage = 30.0;
nudHvVoltage.Value = (decimal)hvVoltage;
SetHvVoltage(ADDR_HV_CTRL, hvVoltage);
*/
 
// Set integration time
int integrationTime = 350;
//nudIntegrationTime.Value = integrationTime;
SetIntegrationTime(integrationTime);
 
// Set discriminator threshold
int threshold = 50;
//nudThreshold.Value = threshold;
SetThreshold(threshold);
 
// Set sum coupling
SetSumCoupling(true);
 
// Set sum gain
int sumGain = 3;
//nudSumGain.Value = sumGain;
SetSumGain(sumGain);
 
// Set sum offset
int offset = 0;
//nudSumOffset.Value = offset;
SetSumOffset(offset);
 
// Set ADC coupling
SetAdcCoupling(false);
 
// Set ADC gains
int gain = 1;
//nudAdcGain.Value = gain;
SetAdcGain(gain);
 
// Set all ADC offsets
SetAdcOffsets(5);
 
// Set internal trigger interval
int triggerInterval = 1000;
//nudTriggerInterval.Value = triggerInterval;
SetTriggerInterval(triggerInterval);
 
// Enable continuous trigger
EnableTrigger(BIT_CSR_TRIG_CONTINUOUS);
 
// Begin continuous acquisition
//nudEventsPerAcquisition.Value = 50000;
//cbAcquireContinuous.Checked = true;
 
// Update histogram offsets
//SetAllHistogramOffsets(0);
}
 
 
void QuickSetupDiscriminator() {
// Set ADC reset
ResetAdc(true);
 
// Clear ADC reset
ResetAdc(false);
 
// Set trigger dead time to 300ns
SetDeadTime(500);
 
// Set event ID
AddTimeStamp(true);
AddEventCount(true);
AddChannelNumber(true);
 
// Enable detector amplifier voltage
SetDetectorVaHiRange(true);
SetDetectorVaOn(true);
 
// Set HV current limit
double iLimit = 2.5;
//nudHvIlimit.Value = (decimal)iLimit;
SetHvCurrentLimit(iLimit);
 
// Reset any HV faults
CycleHvReset();
 
// Enable bias voltage
SetHvOn(false);
SetHvOn(true);
 
// Set bias voltage
double hvVoltage = 28.0;
//nudHvVoltage.Value = (decimal)hvVoltage;
SetHvVoltage(ADDR_HV_CTRL, hvVoltage);
 
// Set integration time
int integrationTime = 350;
//nudIntegrationTime.Value = integrationTime;
SetIntegrationTime(integrationTime);
 
// Set discriminator threshold
int threshold = 50;
//nudThreshold.Value = threshold;
SetThreshold(threshold);
 
// Set sum coupling
SetSumCoupling(true);
 
// Set sum gain
int sumGain = 3;
//nudSumGain.Value = sumGain;
SetSumGain(sumGain);
 
// Set sum offset
int offset = 0;
//nudSumOffset.Value = offset;
SetSumOffset(offset);
 
// Set ADC coupling
SetAdcCoupling(false);
 
// Set ADC gains
int gain = 1;
//nudAdcGain.Value = gain;
SetAdcGain(gain);
 
// Set all ADC offsets
SetAdcOffsets(5);
 
// Clear histograms
//ClearHistograms();
 
// Enable discriminator trigger
EnableTrigger(BIT_CSR_TRIG_DISCR);
 
// Begin continuous acquisition
//nudEventsPerAcquisition.Value = 1000;
//cbAcquireContinuous.Checked = true;
 
// Update histogram offsets
//SetAllHistogramOffsets(0);
}
 
void QuickSetupTriggerOff() {
//cbAcquireContinuous.Checked = false;
DisableTriggers();
SetHvOn(false);
SetDetectorVaOn(false);
}
 
void ReadRegisters() {
if (deviceIndex < 0)
return;
 
// Voltages
double lHvImon = GetHvCurrentInUa();
double HvVmon = GetHvVoltage(ADDR_HV_VMON);
double HvVmax = GetHvVoltage(ADDR_HV_MAX);
double lDetPva = GetVoltage75(ADDR_BASE_PVA);
double lDetNva = GetVoltage75(ADDR_BASE_NVA);
double lPva = GetVoltage75(ADDR_MAIN_PVA);
double lNva = GetVoltage75(ADDR_MAIN_NVA);
double l12V = GetVoltage(ADDR_MAIN_P12);
double l33V = GetVoltage75(ADDR_MAIN_P33);
double l50V = GetVoltage75(ADDR_MAIN_P50);
double Temperature = GetDetectorTemperature();
double lRampRate = GetRampRate();
 
 
AddMessageF(lHvImon);
AddMessageF(HvVmon);
AddMessageF(HvVmax);
AddMessageF(lDetPva);
AddMessageF(lDetNva);
AddMessageF(lPva);
AddMessageF(lNva);
AddMessageF(l12V);
AddMessageF(l33V);
AddMessageF(l50V);
AddMessageF(Temperature);
AddMessageF(lRampRate);
 
 
 
 
 
// Integration time
int lItime = GetIntegrationTime();
 
// Buffer memory used
int lBufferWords = ReadSD4Register(ADDR_BUFFERWORDS);
 
// Offsets
double lOffset1 = GetAdcOffsetInMv(ADDR_OFFSET1);
double lOffset2 = GetAdcOffsetInMv(ADDR_OFFSET2);
double lOffset3 = GetAdcOffsetInMv(ADDR_OFFSET3);
double lOffset4 = GetAdcOffsetInMv(ADDR_OFFSET4);
double lSumOffset = GetSumOffsetInMv();
 
// Main CSR
int csrMain = ReadSD4Register(ADDR_CSR_MAIN);
int lPvaStatus = GetBit(csrMain, BIT_CSR_MAIN_PVA);
int lNvaStatus = GetBit(csrMain, BIT_CSR_MAIN_NVA);
int l12vStatus = GetBit(csrMain, BIT_CSR_MAIN_P12);
int l33vStatus = GetBit(csrMain, BIT_CSR_MAIN_P33);
int l5vStatus = GetBit(csrMain, BIT_CSR_MAIN_P50);
 
 
AddMessageF(lOffset1);
AddMessageF(lOffset2);
AddMessageF(lOffset3);
AddMessageF(lOffset4);
AddMessageF(lSumOffset);
AddMessageX(csrMain);
AddMessageX(lNvaStatus);
AddMessageX(lNvaStatus);
AddMessageX(l12vStatus);
AddMessageX(l33vStatus);
AddMessageX(l5vStatus);
 
AddMessageI(lBufferWords);
AddMessageI(lItime);
 
// Trigger CSR
// Assumes only one trigger source is active
char lTriggerSource[0xFF]="";
int csrTrigger = ReadSD4Register(ADDR_CSR_TRIGGER);
if (GetBit(csrTrigger, BIT_CSR_TRIG_CONTINUOUS))
sprintf_s(lTriggerSource, 0xFF, "CONTINUOUS");
else if (GetBit(csrTrigger, BIT_CSR_TRIG_BURST))
sprintf_s(lTriggerSource, 0xFF, "BURST");
else if (GetBit(csrTrigger, BIT_CSR_TRIG_DISCR))
sprintf_s(lTriggerSource, 0xFF, "DISCRIMINATOR");
else if (GetBit(csrTrigger, BIT_CSR_TRIG_EXTERNAL))
sprintf_s(lTriggerSource, 0xFF, "EXTERNAL");
else
sprintf_s(lTriggerSource, 0xFF, "OFF");
 
// Event ID CSR
int csrEventId = ReadSD4Register(ADDR_EVENTID);
addTimeStamp = GetBit(csrEventId, BIT_EVENTID_TIME);
addEventCount = GetBit(csrEventId, BIT_EVENTID_COUNT);
addChannelNum = GetBit(csrEventId, BIT_EVENTID_CHNUM);
//lTimeStamp.Text = addTimeStamp ? "+" : "";
//lEventCount.Text = addEventCount ? "+" : "";
//lChannelNum.Text = addChannelNum ? "+" : "";
AddMessageS(lTriggerSource);
AddMessageI(addTimeStamp);
AddMessageI(addEventCount);
AddMessageI(addEventCount);
// Trigger generator
int lTriggerInterval = ReadSD4Register32(ADDR_TG_INTERVALHI, ADDR_TG_INTERVALLO) * 10;
int lTrigCount = ReadSD4Register32(ADDR_TG_COUNTHI, ADDR_TG_COUNTLO);
ushort dum = 0;
WriteSD4Register(ADDR_TC_COUNTLO, dum); // latch counters by writing to any counter register
int lTriggers = ReadSD4Register32(ADDR_TC_COUNTHI, ADDR_TC_COUNTLO);
int lTriggerRate = ReadSD4Register32(ADDR_TC_RATEHI, ADDR_TC_RATELO);
int lAdcConversions = ReadSD4Register32(ADDR_CONV_COUNTHI, ADDR_CONV_COUNTLO);
double lThreshold = GetThreshold();
double lHvIlimit = GetHvIlimitSetting();
double lHvVoltage = GetHvVoltageSetting();
 
 
AddMessageI(lTriggerInterval);
AddMessageI(lTrigCount);
AddMessageI(lTriggers);
AddMessageI(lTriggerRate);
AddMessageI(lAdcConversions);
AddMessageF(lThreshold);
AddMessageF(lHvIlimit);
AddMessageF(lHvVoltage);
 
 
 
// Detector CSR
int csrDetector = ReadSD4Register(ADDR_CSR_DETECTOR);
int lHvEnabled = GetBit(csrDetector, BIT_CSR_DET_HVENABLE);
int lHvOn = GetBit(csrDetector, BIT_CSR_DET_HVGOOD);
int lSumCoupling = GetBit(csrDetector, BIT_CSR_DET_SUMCOUPLING);
int lSumGain =
((GetBit(csrDetector, BIT_CSR_DET_SUMGAIN4) ? 1 : 0) << 3) |
((GetBit(csrDetector, BIT_CSR_DET_SUMGAIN3) ? 1 : 0) << 2) |
((GetBit(csrDetector, BIT_CSR_DET_SUMGAIN2) ? 1 : 0) << 1) |
((GetBit(csrDetector, BIT_CSR_DET_SUMGAIN1) ? 1 : 0) << 0);
int lAdcCoupling = GetBit(csrDetector, BIT_CSR_DET_ADCCOUPLING);
int lAdcGain = ((GetBit(csrDetector, BIT_CSR_DET_ADCGAIN2) ? 1 : 0) << 1) |
((GetBit(csrDetector, BIT_CSR_DET_ADCGAIN1) ? 1 : 0) << 0);
int lAmpEnabled = GetBit(csrDetector, BIT_CSR_DET_VAENABLE);
int lAmpLevel = GetBit(csrDetector, BIT_CSR_DET_VAHIRNG);
int lDetPvaStatus = GetBit(csrDetector, BIT_CSR_DET_PVAGOOD);
int lDetNvaStatus = GetBit(csrDetector, BIT_CSR_DET_NVAGOOD);
int lTemperatureOn = GetBit(csrDetector, BIT_CSR_DET_TEMPVALID);
AddMessageI(lHvEnabled);
AddMessageI(lHvOn);
AddMessageI(lSumCoupling);
AddMessageI(lSumGain);
AddMessageI(lAdcCoupling);
AddMessageI(lAdcGain );
AddMessageI(lAmpEnabled);
AddMessageI(lAmpLevel);
AddMessageI(lDetPvaStatus );
AddMessageI(lDetNvaStatus);
AddMessageI(lTemperatureOn);
}
 
 
 
//----------------------------------------
// Message list
//----------------------------------------
 
 
 
 
//----------------------------------------
// MDU Events
//----------------------------------------
/*
private void AitDeviceAttached(object sender, EventArgs e)
{
MduManager.DeviceChangedEventArgs aitEventArgs = e as MduManager.DeviceChangedEventArgs;
AddMessage(String.Format("Attached : Index={0}, ID={1:X8}", aitEventArgs.DeviceIndex, aitEventArgs.DeviceId));
UpdateDeviceList();
}
 
private void AitDeviceRemoved(object sender, EventArgs e)
{
MduManager.DeviceChangedEventArgs aitEventArgs = e as MduManager.DeviceChangedEventArgs;
AddMessage(String.Format("Removed : Index={0}, ID={1:X8}", aitEventArgs.DeviceIndex, aitEventArgs.DeviceId));
UpdateDeviceList();
}
 
*/
 
//----------------------------------------
// Device Control
//----------------------------------------
 
void GetDeviceId() {
deviceIndex = 0;
deviceId = 1;
/*
if (tscbDeviceList.SelectedIndex >= 0)
{
deviceIndex = 0; // tscbDeviceList.SelectedIndex;
deviceId = 1; //UInt32.Parse((string)tscbDeviceList.SelectedItem, System.Globalization.NumberStyles.HexNumber);
}
else
{
deviceIndex = -1;
deviceId = 0;
}
*/
}
 
int UpdateDeviceList()
{
deviceIndex = -1;
deviceId = 0;
int deviceCount = 0;
uint * devIds = SD4_GetDeviceList(&deviceCount);
for (int i = 0; i < deviceCount; i++) {
printf("Device %d = 0x%8x\t", i, devIds[i]);
deviceId = devIds[i];
deviceIndex = i;
}
return deviceCount;
}
 
 
void ResetDevice() {
if (deviceIndex >= 0) {
AddMessage(statusReset);
SD4_ResetFpga(deviceIndex);
Sleep(500);
UpdateDeviceList();
AddMessage(statusReset);
AddMessage(statusDone);
}
else
AddMessage(statusNoDevice);
}
 
void ReconnectDevice() {
if (deviceIndex >= 0) {
AddMessage(statusReconnect);
SD4_Reconnect(deviceIndex);
Sleep(500);
AddMessage(statusReconnect);
AddMessage(statusDone);
}
else
AddMessage(statusNoDevice);
}
 
void ReconfigureDevice() {
if (deviceIndex >= 0) {
AddMessage(statusReconfig);
SD4_Reconfigure(deviceIndex);
Sleep(500);
SD4_ResetFpga(deviceIndex);
UpdateDeviceList();
AddMessage(statusReconfig);
AddMessage(statusDone);
}
else
AddMessage(statusNoDevice);
}
 
//----------------------------------------
// Initialize Device Connection
//----------------------------------------
 
void InitializeConnection() {
int ndevices = 0;
unsigned int * devlist = SD4_FindDevices(&ndevices);
printf("Found %d devices\t", ndevices);
//SD4.DeviceAttached += new EventHandler(AitDeviceAttached);
//SD4.DeviceRemoved += new EventHandler(AitDeviceRemoved);
//tscbDeviceList.SelectedIndexChanged += new EventHandler(tscbDeviceList_SelectedIndexChanged);
printf("Updated devices %d\n", UpdateDeviceList());
 
// Set above the maximum bias voltage to prevent accidental over-bias.
// For example for 30V bias, set to 32V. For 70V bias, set to 72V
SetMaximumHvSetting(32.0);
 
// Set TTL port to 0
WriteSD4Register(ADDR_TTLPORT, 0);
 
// Set HV ramp rate to 20 V/s
SetRampRate(20);
 
// 1 second register scan interval
//SetupTimer(1.0);
 
}
 
 
int GetAdcEventSize() {
int eventSize = CHANNELS;
if (addTimeStamp == true)
eventSize += 3; // 3 16-bit words for time stamp
if (addEventCount == true)
eventSize += 2; // 2 16-bit words for event count
return eventSize;
}
 
int GetEventPosition(int eventNum) {
int adcBoardEventSize = GetAdcEventSize();
return adcBoardEventSize * eventNum;
}
 
ushort ExtractAdcData(int eventNum, int channel) {
int index = GetEventPosition(eventNum) + channel;
return adcBuffer[index];
}
 
long ExtractTimeStamp(int eventNum) {
int index = GetEventPosition(eventNum) + CHANNELS;
long timestamp = 0;
for (int i = 0; i < 3; i++)
timestamp = (timestamp << 16) | adcBuffer[index++];
return timestamp;
}
 
int ExtractEventCount(int eventNum) {
int offset = 0;
if (addTimeStamp == true)
offset += 3;
int index = GetEventPosition(eventNum) + CHANNELS + offset;
int eventCount = adcBuffer[index];
eventCount = (eventCount << 16) | adcBuffer[index + 1];
return eventCount;
}
 
void ShowEvent(int eventNumber) {
if (eventNumber < 1)
return;
eventNumber--;
char lAdcTimeStamp[0xFF]="";
char lAdcAbsTimeStamp[0xFF]="";
char lAdcEventCount[0xFF]="";
//tbAdcData.Clear();
int eventPosition = GetEventPosition(eventNumber);
for (int channel = 0; channel < CHANNELS; channel++) {
int data = ExtractAdcData(eventNumber, channel);
AddMessage("AdcData event %d channel:%d data:%d\n", eventNumber, channel + 1, data);
}
if (addTimeStamp == true) {
long reference = ExtractTimeStamp(0);
long timeStamp = ExtractTimeStamp(eventNumber);
sprintf_s(lAdcTimeStamp, 0xFF, "%d", ((timeStamp - reference) * TIMESTAMP_LSB));
sprintf_s(lAdcAbsTimeStamp, 0xFF, "%d", (timeStamp * TIMESTAMP_LSB));
}
else {
sprintf_s(lAdcTimeStamp, 0xFF, "%s", "----");
sprintf_s(lAdcAbsTimeStamp, 0xFF, "%s", "----");
}
if (addEventCount == true) {
sprintf_s(lAdcEventCount, 0xFF, "%d", ExtractEventCount(eventNumber));
}
else {
sprintf_s(lAdcEventCount, 0xFF, "%s", "----");
}
//SetTextboxToTop(tbAdcData);
}
 
int BlockTransferTime() {
return SD4_BlockTransferTime();
}
void InitInterface(int events) {
adcBufferLen = GetAdcEventSize() * events;
//adcBuffer = (ushort *)malloc(sizeof(ushort) * adcBufferLen);
/*
for (int i = 0; i < 0xFFF; i++) {
for (int j = 0; j < 4; j++) histograms[j][i] = 0;
}
for (int i = 0; i < 4 * 0xFFF; i++) {
histogramtotal[i] = 0;
}
*/
histogramTotalEvents = 0;
}
 
int Acquire(int events) {
//InitializeConnection();
// Acquire
InitInterface(events);
//int wordsAcquired = ReadAdcByteBuffer(); // use only to test byte buffer read operation
int wordsAcquired = ReadAdcBuffer();
if (wordsAcquired != adcBufferLen) {
char msg[0xFF];
AddMessage("ERROR: Timeout with possible data loss (%d/%d words received; Block Error = %d)\n", wordsAcquired, adcBufferLen, SD4_BlockError());
return 0;
}
 
/*
lTransferRate.Text = String.Format("{0:f2}", transferRate);
lAcquisitionSize.Text = String.Format("{0:f2}", blocksize / 1e6); // block size in MB
lAcquisitionTime.Text = String.Format("{0:f2}", microseconds / 1e6);
*/
return events;
}
 
void GetStatistics(int events) {
ushort rawAdcData = 0;
ushort adcData = 0;
int channelReceived = 0;
int channelExpected = 0;
bool includeSaturated = 0; // cbIncludeSaturated.Checked;
ushort max[CHANNELS];
ushort min[CHANNELS];
ushort average[CHANNELS];
int total[CHANNELS];
for (int i = 0; i < CHANNELS; i++) {
min[i] = 0xFFFF;
max[i] = 0;
total[i] = 0;
}
for (int eventNum = 0; eventNum < events; eventNum++) {
 
int sum = 0;
for (int channel = 0; channel < CHANNELS; channel++) {
rawAdcData = ExtractAdcData(eventNum, channel);
if (addChannelNum == true) {
channelReceived = (rawAdcData >> 12) & 0xF;
channelExpected = (channel & 0xF);
if (channelReceived != channelExpected) {
 
AddMessage("ERROR in Event %d : Expected channel %d, received %d -ANALYSIS STOPPED", eventNum, channelExpected, channelReceived);
 
//EnableRegisterScanTimer(true);
return;
}
}
adcData = (ushort)(rawAdcData & 0x0FFF); // remove channel number
if ((includeSaturated == true) || ((includeSaturated == false) && (adcData < (ADCMAX - 2))))
histograms[channel][adcData]++;
total[channel] = total[channel] + adcData;
if (adcData > max[channel])
max[channel] = adcData;
else if (adcData < min[channel])
min[channel] = adcData;
 
sum += adcData;
}
histogramtotal[sum]++;
histogramTotalEvents++;
}
//tbAdcStatistics.Clear();
for (int channel = 0; channel < CHANNELS; channel++) {
average[channel] = (ushort)(total[channel] / events);
 
AddMessage(" {channel:%d} : {min:0x%d} {max:0x%d} {max-min:%d} {average:%d}\n", channel + 1, min[channel], max[channel], max[channel] - min[channel], average[channel]);
//if (channel < (CHANNELS - 1))
// tbAdcStatistics.AppendText(Environment.NewLine);
 
}
//SetTextboxToTop(tbAdcStatistics);
}
 
void SetupAcquisition(int neve) {
//EnableRegisterScanTimer(false);
//nudEventSelect.Minimum = 0;
//nudEventSelect.Maximum = 0;
int eventsAcquired = Acquire(neve);
if (eventsAcquired < 1){
printf("Acquired events %d\n", eventsAcquired);
return;
}
GetStatistics(eventsAcquired);
ShowEvent(1);
//ShowHistograms();
//nudEventSelect.Minimum = 1;
//nudEventSelect.Maximum = eventsAcquired;
//EnableRegisterScanTimer(true);
}
 
 
 
 
 
int _tmain(int argc, char **argv) {
 
 
int events = 1000;
 
InitInterface(events);
SetupAcquisition(1);
 
//NE_Rainbow();
printf("xxx\n");
//NE_Call(9);
int b = 9;
int k = 0;//NE_Func(b);
printf("yyy %d %d\n", b, k);
return 0;
}
/cvi/instr/AitSipmDAQ/AitInterface.h
0,0 → 1,106
#ifndef AITINTERFACE_H
#define AITINTERFACE_H
 
void SetupAcquisition(int neve);
void GetStatistics(int events);
int Acquire(int events);
void InitInterface(int events);
void ShowEvent(int eventNumber);
int ExtractEventCount(int eventNum);
long ExtractTimeStamp(int eventNum);
unsigned short ExtractAdcData(int eventNum,int channel);
int GetEventPosition(int eventNum);
int GetAdcEventSize();
void InitializeConnection();
void ReconfigureDevice();
void ReconnectDevice();
void ResetDevice();
int UpdateDeviceList();
void GetDeviceId();
void ReadRegisters();
void QuickSetupTriggerOff();
void QuickSetupDiscriminator();
void QuickSetupContinuous();
void SetAdcOffsets(int offsetInMv);
void SetAdcGain(int gain);
double GetRampRate();
void SetRampRate(double voltsPerSecond);
void CycleHvReset();
void SetMaximumHvSetting(double volts);
void SetHvOn(bool hvOn);
double GetHvVoltageSetting();
double GetHvIlimitSetting();
void SetHvVoltage(int reg,double volts);
void SetHvCurrentLimit(double milliamps);
void SetDetectorVaHiRange(bool range);
void SetDetectorVaOn(bool on);
void AddChannelNumber(bool addChannelNumber);
extern bool addTimeStamp;
void AddTimeStamp(bool addTimeStamp);
extern bool addEventCount;
void AddEventCount(bool addEventCount);
void SetAdcOffset(int reg,double milliVolts);
double GetAdcOffsetInMv(int reg);
void ResetAdc(bool reset);
void SetAdcCoupling(bool acCoupling);
int GetIntegrationTime();
void SetIntegrationTime(int integrationTime);
void SetDeadTime(int deadTimeInNs);
void DisableTriggers();
void EnableTrigger(int bitIndex);
void SetTriggerBurst(int triggerBurst);
void SetTriggerInterval(int triggerInterval);
void SetSumOffset(double milliVolts);
double GetSumOffsetInMv();
double GetThreshold();
void SetThreshold(double thresholdInMillivolts);
void SetSumCoupling(bool acCoupling);
void SetSumGain(int gain);
double GetVoltage75(int reg);
double GetHvCurrentInUa();
double GetHvVoltage(int reg);
double GetDetectorTemperature();
double GetVoltage(int reg);
int ReadAdcByteBuffer();
int ReadAdcBuffer();
int BlockTransferTime();
double LimitSetting(double value,double min,double max);
void ReadModifyWrite(int reg,int bitIndex,bool bitValue);
void WriteSD4Register32(int addrHi,int addrLo,unsigned int data);
void WriteSD4Register(int address,unsigned short data);
unsigned int ReadSD4Register32(int addrHi,int addrLo);
unsigned short ReadSD4Register(int reg);
bool GetBit(int data,int bitIndex);
unsigned short SetBit(unsigned short data,int bitIndex,bool bitValue);
void Sleep(int musec);
extern int TIMESTAMP_LSB;
extern bool addChannelNum;
extern const int ADCMAX;
extern const int CHANNELS;
extern const char statusDone[0xFF];
extern const char statusReconnect[0xFF];
extern const char statusReset[0xFF];
extern const char statusReconfig[0xFF];
extern const char statusNoDevice[0xFF];
extern const double RAMPRATESCALE;
extern const int INTEGRATOR_LSB;
extern const double HV_VRANGE;
extern const double HV_IRANGE;
extern const double DISCR_THRESHOLDRANGE;
extern const double DISCR_OFFSETRANGE;
extern const double MONADC_VRANGE;
extern const double DAC_SCALE;
extern const double MONADC_SCALE;
extern int histogramTotalEvents;
extern int histogramtotal[0xFFF *4];
extern int histograms[4][0xFFF];
extern unsigned short *adcBuffer;
extern int adcBufferLen;
extern int deviceIndex;
extern unsigned int deviceId;
#if defined(_CVI_)
int sprintf_s(const char *dest,int len,const char *format,...);
#endif
int AddMessage(const char *format,...);
 
#endif
/cvi/instr/AitSipmDAQ/AitInterface.lib
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/cvi/instr/AitSipmDAQ/AitMduManager.dll
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/cvi/instr/AitSipmDAQ/AitMduManager.h
0,0 → 1,48
#ifndef AITMDUMANAGER_H
#define AITMDUMANAGER_H
#define DLLIMPORT __declspec(dllimport)
#ifdef _CVI_
#include <stdbool.h>
#endif
#ifdef __cplusplus
extern "C"
{
#endif
 
DLLIMPORT int SD4_BlockError();
DLLIMPORT unsigned int SD4_GetBlockTimeout();
DLLIMPORT void SD4_SetBlockTimeout(unsigned int);
DLLIMPORT long SD4_BlockTransferTime();
DLLIMPORT unsigned int SD4_GetDriverTimeout();
DLLIMPORT void SD4_SetDriverTimeout(unsigned int);
DLLIMPORT char * SD4_Version();
DLLIMPORT int SD4_WordsTransferred();
 
DLLIMPORT unsigned int* SD4_FindDevices(int * ndevices);
DLLIMPORT int SD4_GetDeviceCount();
DLLIMPORT unsigned int* SD4_GetDeviceList(int * ndevices);
DLLIMPORT char * SD4_GetUsbFirmwareVersionByDevice(unsigned int deviceId);
DLLIMPORT char * SD4_GetUsbFirmwareVersion(int index);
DLLIMPORT bool SD4_IsDeviceAttached(unsigned int deviceId);
DLLIMPORT bool SD4_ProgramFpgaFirmwareByDevice(unsigned int deviceId, char * fpgaFirmware);
DLLIMPORT bool SD4_ProgramFpgaFirmware(int index, char* fpgaFirmware);
DLLIMPORT bool SD4_ProgramUsbFirmware(int index, char* usbFirmware);
DLLIMPORT unsigned short SD4_Read(unsigned int deviceId, int address);
DLLIMPORT char * SD4_ReadByteArray(unsigned int deviceId, int address, int requestedsize, int * elementsread);
DLLIMPORT unsigned short * SD4_ReadUShortArray(unsigned int deviceId, int address, int requestedsize, int * elementsread );
DLLIMPORT void SD4_ReconfigureByDevice(unsigned int deviceId);
DLLIMPORT void SD4_Reconfigure(int index);
DLLIMPORT void SD4_ReconnectByDevice(unsigned int deviceId);
DLLIMPORT void SD4_Reconnect(int index);
DLLIMPORT void SD4_ResetFpga(int index);
DLLIMPORT void SD4_ResetFpgaByDevice(unsigned int deviceId);
DLLIMPORT void SD4_ResetUsb(int index);
DLLIMPORT void SD4_ResetUsbByDevice(unsigned int deviceId);
DLLIMPORT void SD4_Write(unsigned int deviceId, int address, unsigned short data);
DLLIMPORT int SD4_WriteArray(unsigned int deviceId, int address, unsigned short* data);
#ifdef __cplusplus
}
#endif
#endif
 
/cvi/instr/AitSipmDAQ/AitMduManager.lib
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/cvi/instr/AitSipmDAQ/AitMduManager_DEF.h
0,0 → 1,114
#ifndef AITMDUMANAGER_DEF_H
#define AITMDUMANAGER_DEF_H
 
// Registers 0-15 ( RESERVED - DO NOT ACCESS
 
 
//----------------------------------------
// ADC Controller Registers
//----------------------------------------
 
#define ADDR_BASE ( 16)
#define ADDR_CSR_MAIN ( ADDR_BASE + 0) // Main CSR
#define ADDR_BUFFER ( ADDR_BASE + 1) // ADC event buffer
#define ADDR_BUFFERWORDS ( ADDR_BASE + 2) // 16-bit words available in the ADC event buffer
#define ADDR_EVENTID ( ADDR_BASE + 3) // Event ID CSR
#define ADDR_CSR_DETECTOR ( ADDR_BASE + 4) // Detector interface CSR
#define ADDR_TTLPORT ( ADDR_BASE + 5) // TTL I/O port
#define ADDR_ITIME ( ADDR_BASE + 6) // Integration time
#define ADDR_CSR_TRIGGER ( ADDR_BASE + 7) // Trigger CSR
#define ADDR_DEADTIME ( ADDR_BASE + 8) // Trigger dead time
#define ADDR_TG_INTERVALHI ( ADDR_BASE + 9) // Internal trigger generator interval 31:16
#define ADDR_TG_INTERVALLO ( ADDR_BASE + 10) // Internal trigger generator interval 15:0
#define ADDR_TG_COUNTHI ( ADDR_BASE + 11) // Internal trigger generator burst count 31:16
#define ADDR_TG_COUNTLO ( ADDR_BASE + 12) // Internal trigger generator burst count 15:0
#define ADDR_TC_COUNTHI ( ADDR_BASE + 13) // Trigger count 31:16
#define ADDR_TC_COUNTLO ( ADDR_BASE + 14) // Trigger count 15:0
#define ADDR_TC_RATEHI ( ADDR_BASE + 15) // Trigger rate 31:16
#define ADDR_TC_RATELO ( ADDR_BASE + 16) // Trigger rate 15:0
#define ADDR_CONV_COUNTHI ( ADDR_BASE + 17) // ADC conversion count 31:16
#define ADDR_CONV_COUNTLO ( ADDR_BASE + 18) // ADC conversion count 15:0
#define ADDR_CONV_RATEHI ( ADDR_BASE + 19) // ADC conversion rate 31:16
#define ADDR_CONV_RATELO ( ADDR_BASE + 20) // ADC conversion rate 15:0
#define ADDR_DISCR_OFFSET ( ADDR_BASE + 21) // Discriminator offset
#define ADDR_DISCR_THRESHOLD ( ADDR_BASE + 22) // Discriminator threshold
#define ADDR_MAIN_P12 ( ADDR_BASE + 23) // Main +1.2V power supply monitor
#define ADDR_RESERVED2 ( ADDR_BASE + 24) // RESERVED
#define ADDR_MAIN_P33 ( ADDR_BASE + 25) // Main +3.3V power supply monitor
#define ADDR_MAIN_P50 ( ADDR_BASE + 26) // Main +5.0V power supply monitor
#define ADDR_MAIN_PVA ( ADDR_BASE + 27) // Main power supply +VA voltage monitor
#define ADDR_MAIN_NVA ( ADDR_BASE + 28) // Main power supply -VA voltage monitor
#define ADDR_HV_MAX ( ADDR_BASE + 29) // HV maximum allowable control voltage
#define ADDR_HV_RAMPRATE ( ADDR_BASE + 30) // HV ramp rate
#define ADDR_HV_CTRL ( ADDR_BASE + 31) // HV control voltage
#define ADDR_HV_ILIMIT ( ADDR_BASE + 32) // HV current limit
#define ADDR_HV_VMON ( ADDR_BASE + 33) // HV output current monitor
#define ADDR_HV_IMON ( ADDR_BASE + 34) // HV output voltage monitor
#define ADDR_BASE_TEMPERATURE ( ADDR_BASE + 35) // Base temperature monitor
#define ADDR_BASE_PVA ( ADDR_BASE + 36) // Base +VA power supply monitor
#define ADDR_BASE_NVA ( ADDR_BASE + 37) // Base -VA power supply monitor
#define ADDR_OFFSET1 ( ADDR_BASE + 38) // ADC offset 1
#define ADDR_OFFSET2 ( ADDR_BASE + 39) // ADC offset 2
#define ADDR_OFFSET3 ( ADDR_BASE + 40) // ADC offset 3
#define ADDR_OFFSET4 ( ADDR_BASE + 41) // ADC offset 4
 
 
//----------------------------------------
// Main CSR bits
//----------------------------------------
 
// bit 0 ( RESERVED
#define BIT_CSR_MAIN_P12 ( 1) // +1.2V power supply status
// bit 2 ( RESERVED
#define BIT_CSR_MAIN_P33 ( 3) // +3.3V power supply status
#define BIT_CSR_MAIN_P50 ( 4) // +5.0V power supply status
#define BIT_CSR_MAIN_PVA ( 5) // +VA power supply status
#define BIT_CSR_MAIN_NVA ( 6) // -VA power supply status
// bits 12:7 ( RESERVED
#define BIT_CSR_MAIN_BFULL ( 13) // ADC buffer full status
#define BIT_CSR_MAIN_BEMPTY ( 14) // ADC buffer empty status
#define BIT_CSR_MAIN_ADCRESET ( 15) // Reset ADC
 
 
//----------------------------------------
// Event ID CSR bits
//----------------------------------------
 
#define BIT_EVENTID_COUNT ( 0) // Add event count to each Event Block (0(no, 1(yes)
#define BIT_EVENTID_TIME ( 1) // Add time stamp to each Event Block (0(no, 1(yes)
#define BIT_EVENTID_CHNUM ( 2) // Add channel number to each ADC data word (0(no, 1(yes)
// bits 15:3 ( RESERVED
 
 
//----------------------------------------
// Detector interface CSR bits
//----------------------------------------
 
#define BIT_CSR_DET_VAENABLE ( 0) // Detector Module +/-VA enable (0 ( disable, 1 ( enable)
#define BIT_CSR_DET_VAHIRNG ( 1) // Detector Module +/-VA output range (0 ( low range, 1 ( high range)
#define BIT_CSR_DET_HVENABLE ( 2) // Detector Module HV power supply (0 ( disable, 1 ( enable)
#define BIT_CSR_DET_HVRESET ( 3) // Detector Module HV power supply fault reset (0 ( reset off, 1 ( reset on)
#define BIT_CSR_DET_SUMCOUPLING ( 4) // Sum input coupling (0 ( DC, 1 ( AC)
#define BIT_CSR_DET_SUMGAIN1 ( 5) // Sum gain switch 1 (0 ( open, 1 ( closed)
#define BIT_CSR_DET_SUMGAIN2 ( 6) // Sum gain switch 2 (0 ( open, 1 ( closed)
#define BIT_CSR_DET_SUMGAIN3 ( 7) // Sum gain switch 3 (0 ( open, 1 ( closed)
#define BIT_CSR_DET_SUMGAIN4 ( 8) // Sum gain switch 4 (0 ( open, 1 ( closed)
#define BIT_CSR_DET_ADCCOUPLING ( 9) // ADC input coupling (0 ( DC, 1 ( AC)
#define BIT_CSR_DET_ADCGAIN1 ( 10) // ADC gain switch 1 (0 ( open, 1 ( closed)
#define BIT_CSR_DET_ADCGAIN2 ( 11) // ADC gain switch 2 (0 ( open, 1 ( closed)
#define BIT_CSR_DET_HVGOOD ( 12) // Detector Module HV status (0 ( fault, 1 ( good)
#define BIT_CSR_DET_PVAGOOD ( 13) // Detector Module VA status (0 ( fault, 1 ( good)
#define BIT_CSR_DET_NVAGOOD ( 14) // Detector Module VA status (0 ( fault, 1 ( good)
#define BIT_CSR_DET_TEMPVALID ( 15) // Detector Module temperature status (0 ( fault, 1 ( connected)
 
 
//----------------------------------------
// Trigger CSR bits
//----------------------------------------
 
#define BIT_CSR_TRIG_CONTINUOUS ( 0) // Internal continuous trigger (0(off, 1(on)
#define BIT_CSR_TRIG_BURST ( 1) // Internal burst trigger (0(off, 0(on)
#define BIT_CSR_TRIG_DISCR ( 2) // Discriminator trigger (0(off, 0(on)
#define BIT_CSR_TRIG_EXTERNAL ( 3) // External trigger (0(off, 0(on)
// bits 15:4 ( RESERVED
#endif
/cvi/instr/AitSipmDAQ/XYSCAN.h
0,0 → 1,65
/**************************************************************************/
/* LabWindows/CVI User Interface Resource (UIR) Include File */
/* */
/* WARNING: Do not add to, delete from, or otherwise modify the contents */
/* of this include file. */
/**************************************************************************/
 
#include <userint.h>
 
#ifdef __cplusplus
extern "C" {
#endif
 
/* Panels and Controls: */
 
#define SCAN 1
#define SCAN_OPENMAIN 2 /* control type: command, callback function: OpenMainCB */
#define SCAN_BD 3 /* control type: command, callback function: MoveStageCB */
#define SCAN_BR 4 /* control type: command, callback function: MoveStageCB */
#define SCAN_GETPOSITION 5 /* control type: command, callback function: GetCurrentPositionCB */
#define SCAN_SCAN 6 /* control type: command, callback function: StartCB */
#define SCAN_BU 7 /* control type: command, callback function: MoveStageCB */
#define SCAN_HO 8 /* control type: command, callback function: HomeCB */
#define SCAN_BL 9 /* control type: command, callback function: MoveStageCB */
#define SCAN_XG 10 /* control type: numeric, callback function: (none) */
#define SCAN_YG 11 /* control type: numeric, callback function: (none) */
#define SCAN_IX 12 /* control type: numeric, callback function: (none) */
#define SCAN_IY 13 /* control type: numeric, callback function: (none) */
#define SCAN_NSTEPSX 14 /* control type: numeric, callback function: (none) */
#define SCAN_NSTEPSY 15 /* control type: numeric, callback function: (none) */
#define SCAN_STEPX 16 /* control type: numeric, callback function: (none) */
#define SCAN_STEPY 17 /* control type: numeric, callback function: (none) */
#define SCAN_STARTX 18 /* control type: numeric, callback function: (none) */
#define SCAN_STARTY 19 /* control type: numeric, callback function: (none) */
#define SCAN_XP 20 /* control type: numeric, callback function: (none) */
#define SCAN_YP 21 /* control type: numeric, callback function: (none) */
#define SCAN_GY 22 /* control type: command, callback function: GoYCB */
#define SCAN_GX 23 /* control type: command, callback function: GoXCB */
#define SCAN_PORT 24 /* control type: numeric, callback function: (none) */
 
 
/* Control Arrays: */
 
/* (no control arrays in the resource file) */
 
 
/* Menu Bars, Menus, and Menu Items: */
 
/* (no menu bars in the resource file) */
 
 
/* Callback Prototypes: */
 
int CVICALLBACK GetCurrentPositionCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
int CVICALLBACK GoXCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
int CVICALLBACK GoYCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
int CVICALLBACK HomeCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
int CVICALLBACK MoveStageCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
int CVICALLBACK OpenMainCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
int CVICALLBACK StartCB(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
 
 
#ifdef __cplusplus
}
#endif
/cvi/instr/AitSipmDAQ/XYSCAN.uir
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property