diff --git a/slsDetectorGui/forms/form_tab_settings.ui b/slsDetectorGui/forms/form_tab_settings.ui index b17a600ee..01d951982 100755 --- a/slsDetectorGui/forms/form_tab_settings.ui +++ b/slsDetectorGui/forms/form_tab_settings.ui @@ -214,6 +214,46 @@ Very Low Gain + + + G1_HG + + + + + G1_LG + + + + + G2_HC_HG + + + + + G2_HC_LG + + + + + G2_LC_HG + + + + + G2_LC_LG + + + + + G4_HG + + + + + G4_LG + + Undefined diff --git a/slsDetectorGui/include/qTabSettings.h b/slsDetectorGui/include/qTabSettings.h index a8076eda0..1b29ebbae 100755 --- a/slsDetectorGui/include/qTabSettings.h +++ b/slsDetectorGui/include/qTabSettings.h @@ -41,6 +41,14 @@ private: FORCESWITCHG1, FORCESWITCHG2, VERLOWGAIN, + G1_HIGHGAIN, + G1_LOWGAIN, + G2_HIGHCAP_HIGHGAIN, + G2_HIGHCAP_LOWGAIN, + G2_LOWCAP_HIGHGAIN, + G2_LOWCAP_LOWGAIN, + G4_HIGHGAIN, + G4_LOWGAIN, UNDEFINED, UNINITIALIZED, NUMSETTINGS diff --git a/slsDetectorGui/src/qTabSettings.cpp b/slsDetectorGui/src/qTabSettings.cpp index 10489db8e..59172de8f 100755 --- a/slsDetectorGui/src/qTabSettings.cpp +++ b/slsDetectorGui/src/qTabSettings.cpp @@ -20,7 +20,6 @@ void qTabSettings::SetupWidgetWindow() { // enabling according to det type switch(det->getDetectorType().squash()) { - case slsDetectorDefs::MOENCH: case slsDetectorDefs::MYTHEN3: lblSettings->setEnabled(false); comboSettings->setEnabled(false); @@ -83,11 +82,21 @@ void qTabSettings::SetupDetectorSettings() { item[(int)FORCESWITCHG1]->setEnabled(true); item[(int)FORCESWITCHG2]->setEnabled(true); break; - case slsDetectorDefs::GOTTHARD2: + case slsDetectorDefs::GOTTHARD2: item[(int)DYNAMICGAIN]->setEnabled(true); item[(int)FIXGAIN1]->setEnabled(true); item[(int)FIXGAIN2]->setEnabled(true); - break; + break; + case slsDetectorDefs::MOENCH: + item[(int)G1_HIGHGAIN]->setEnabled(true); + item[(int)G1_LOWGAIN]->setEnabled(true); + item[(int)G2_HIGHCAP_HIGHGAIN]->setEnabled(true); + item[(int)G2_HIGHCAP_LOWGAIN]->setEnabled(true); + item[(int)G2_LOWCAP_HIGHGAIN]->setEnabled(true); + item[(int)G2_LOWCAP_LOWGAIN]->setEnabled(true); + item[(int)G4_HIGHGAIN]->setEnabled(true); + item[(int)G4_LOWGAIN]->setEnabled(true); + break; default: FILE_LOG(logDEBUG) << "Unknown detector type. Exiting GUI."; qDefs::Message(qDefs::CRITICAL, diff --git a/slsDetectorServers/moenchDetectorServer/CMakeLists.txt b/slsDetectorServers/moenchDetectorServer/CMakeLists.txt index 2952e41ac..f7a99301c 100644 --- a/slsDetectorServers/moenchDetectorServer/CMakeLists.txt +++ b/slsDetectorServers/moenchDetectorServer/CMakeLists.txt @@ -12,7 +12,8 @@ add_executable(moenchDetectorServer_virtual ../slsDetectorServer/src/ALTERA_PLL.c ../slsDetectorServer/src/LTC2620.c ../slsDetectorServer/src/MAX1932.c - ../slsDetectorServer/src/programFpgaBlackfin.c + ../slsDetectorServer/src/programFpgaBlackfin.c + ../slsDetectorServer/src/readDefaultPattern.c ) include_directories( diff --git a/slsDetectorServers/moenchDetectorServer/DefaultPattern.txt b/slsDetectorServers/moenchDetectorServer/DefaultPattern.txt new file mode 100755 index 000000000..5cf148cc8 --- /dev/null +++ b/slsDetectorServers/moenchDetectorServer/DefaultPattern.txt @@ -0,0 +1,414 @@ +patword 0x0000 0x0000000000000000 +patword 0x0001 0x0000000000000000 +patword 0x0002 0x0008000900080000 +patword 0x0003 0x0008000900080000 +patword 0x0004 0x0008000900080000 +patword 0x0005 0x0008000900080000 +patword 0x0006 0x0008000900080000 +patword 0x0007 0x0008000900080000 +patword 0x0008 0x0008000900080000 +patword 0x0009 0x0008000900080000 +patword 0x000a 0x0008000900080000 +patword 0x000b 0x0008000900080000 +patword 0x000c 0x0008000900080000 +patword 0x000d 0x0008000900080000 +patword 0x000e 0x0008000900080000 +patword 0x000f 0x0008000900080000 +patword 0x0010 0x0008000900080000 +patword 0x0011 0x0008000900080000 +patword 0x0012 0x0008000900080000 +patword 0x0013 0x0008000900080000 +patword 0x0014 0x0008000900080000 +patword 0x0015 0x0008000900080000 +patword 0x0016 0x0008400900080020 +patword 0x0017 0x0008400900080020 +patword 0x0018 0x0008599f0418503a +patword 0x0019 0x0008599f0418503a +patword 0x001a 0x0108599f0418503a +patword 0x001b 0x0108599f0418503a +patword 0x001c 0x0108599f0418503a +patword 0x001d 0x0108599f0418503a +patword 0x001e 0x0108599f0418503a +patword 0x001f 0x0108599f0418503a +patword 0x0020 0x0108599f0418503a +patword 0x0021 0x0108599f0418503a +patword 0x0022 0x0108599f0418503a +patword 0x0023 0x0108599f0418503a +patword 0x0024 0x0108599f0418503a +patword 0x0025 0x0108599f0418503a +patword 0x0026 0x0108599f0418503a +patword 0x0027 0x0108599f0418503a +patword 0x0028 0x0108599f0418503a +patword 0x0029 0x0108599f0418503a +patword 0x002a 0x0108599f0418503a +patword 0x002b 0x0108599f0418503a +patword 0x002c 0x0108599f0418503a +patword 0x002d 0x0108599f0418503a +patword 0x002e 0x0108599f0418503a +patword 0x002f 0x0108599f0418503a +patword 0x0030 0x0108599f0418503a +patword 0x0031 0x0108599f0418503a +patword 0x0032 0x0108599f0418503a +patword 0x0033 0x0108599f0418503a +patword 0x0034 0x0108599f0418503a +patword 0x0035 0x0108599f0418503a +patword 0x0036 0x0108599f0418503a +patword 0x0037 0x0108599f0418503a +patword 0x0038 0x0108599f0418503a +patword 0x0039 0x0108599f0418503a +patword 0x003a 0x0108599f0418503a +patword 0x003b 0x0108599f0418503a +patword 0x003c 0x0108599f0418503a +patword 0x003d 0x0108599f0418503a +patword 0x003e 0x0108599f0418503a +patword 0x003f 0x0108599f0418503a +patword 0x0040 0x0108599f0418503a +patword 0x0041 0x0108599f0418503a +patword 0x0042 0x0108599f0418503a +patword 0x0043 0x0108599f0418503a +patword 0x0044 0x0108599f0418503a +patword 0x0045 0x0108599f0418503a +patword 0x0046 0x0108599f0418503a +patword 0x0047 0x0108599f0418503a +patword 0x0048 0x0108599f0418503a +patword 0x0049 0x0108599f0418503a +patword 0x004a 0x0108599f0418503a +patword 0x004b 0x0108599f0418503a +patword 0x004c 0x0108599f0418503a +patword 0x004d 0x0108599f0418503a +patword 0x004e 0x0108599f0418503a +patword 0x004f 0x0108599f0418503a +patword 0x0050 0x0108599f0418503a +patword 0x0051 0x0108599f0418503a +patword 0x0052 0x0108599f0418503a +patword 0x0053 0x0108599f0418503a +patword 0x0054 0x0108599f0418503a +patword 0x0055 0x0108599f0418503a +patword 0x0056 0x0108599f0418503a +patword 0x0057 0x0108599f0418503a +patword 0x0058 0x0108599f0418503a +patword 0x0059 0x0108599f0418503a +patword 0x005a 0x0108599f0418503a +patword 0x005b 0x0108599f0418503a +patword 0x005c 0x0108599f0418503a +patword 0x005d 0x0108599f0418503a +patword 0x005e 0x0108599f0418503a +patword 0x005f 0x0108599f0418503a +patword 0x0060 0x0108599f0418503a +patword 0x0061 0x0108599f0418503a +patword 0x0062 0x0108599f0418503a +patword 0x0063 0x0108599f0418503a +patword 0x0064 0x0108599f0418503a +patword 0x0065 0x0108599f0418503a +patword 0x0066 0x0108599f0418503a +patword 0x0067 0x0108599f0418503a +patword 0x0068 0x0108599f0418503a +patword 0x0069 0x0108599f0418503a +patword 0x006a 0x0108599f0418503a +patword 0x006b 0x0108599f0418503a +patword 0x006c 0x0108599f0418503a +patword 0x006d 0x0108599f0418503a +patword 0x006e 0x0108599f0418503a +patword 0x006f 0x0108599f0418503a +patword 0x0070 0x0108599f0418503a +patword 0x0071 0x0108599f0418503a +patword 0x0072 0x0108599f0418503a +patword 0x0073 0x0108599f0418503a +patword 0x0074 0x0108599f0418503a +patword 0x0075 0x0108599f0418503a +patword 0x0076 0x0108599f0418503a +patword 0x0077 0x0108599f0418503a +patword 0x0078 0x0108599f0418503a +patword 0x0079 0x0108599f0418503a +patword 0x007a 0x0108599f0418503a +patword 0x007b 0x0108599f0418503a +patword 0x007c 0x0108599f0418503a +patword 0x007d 0x0108599f0418503a +patword 0x007e 0x010859960418503a +patword 0x007f 0x010859960418503a +patword 0x0080 0x010859960418503a +patword 0x0081 0x010859960418503a +patword 0x0082 0x010859960418503a +patword 0x0083 0x010859960418503a +patword 0x0084 0x010859960418503a +patword 0x0085 0x010859960418503a +patword 0x0086 0x010859960418503a +patword 0x0087 0x010859960418503a +patword 0x0088 0x010859960418503a +patword 0x0089 0x010859960418503a +patword 0x008a 0x010859960418503a +patword 0x008b 0x010859960418503a +patword 0x008c 0x010859960418503a +patword 0x008d 0x010859960418503a +patword 0x008e 0x010859960418503a +patword 0x008f 0x010859960418503a +patword 0x0090 0x010859960418503a +patword 0x0091 0x010859960418503a +patword 0x0092 0x010819960418501a +patword 0x0093 0x010819960418501a +patword 0x0094 0x010819960418501a +patword 0x0095 0x010819960418501a +patword 0x0096 0x030819960418501a +patword 0x0097 0x030819960418501a +patword 0x0098 0x030819960418501a +patword 0x0099 0x030819960418501a +patword 0x009a 0x030819960418501a +patword 0x009b 0x030819960418501a +patword 0x009c 0x030819960418501a +patword 0x009d 0x030819960418501a +patword 0x009e 0x030819960418501a +patword 0x009f 0x030819960418501a +patword 0x00a0 0x030819960418501a +patword 0x00a1 0x030819960418501a +patword 0x00a2 0x030819960418501a +patword 0x00a3 0x030819960418501a +patword 0x00a4 0x030819960418501a +patword 0x00a5 0x030819960418501a +patword 0x00a6 0x030819960418501a +patword 0x00a7 0x030819960418501a +patword 0x00a8 0x030819960418501a +patword 0x00a9 0x030819960418501a +patword 0x00aa 0x030819960418501a +patword 0x00ab 0x030819960418501a +patword 0x00ac 0x030819960008501a +patword 0x00ad 0x030819960008501a +patword 0x00ae 0x030819960008501a +patword 0x00af 0x030819960008501a +patword 0x00b0 0x030819960008501a +patword 0x00b1 0x030819960008501a +patword 0x00b2 0x030819960008501a +patword 0x00b3 0x030819960008501a +patword 0x00b4 0x030819960008501a +patword 0x00b5 0x030819960008501a +patword 0x00b6 0x030819960008501a +patword 0x00b7 0x030819960008501a +patword 0x00b8 0x030819960008501a +patword 0x00b9 0x030819960008501a +patword 0x00ba 0x030819960008501a +patword 0x00bb 0x030819960008501a +patword 0x00bc 0x030819960008501a +patword 0x00bd 0x030819960008501a +patword 0x00be 0x030819960008501a +patword 0x00bf 0x030819960008501a +patword 0x00c0 0x0308199f0008501a +patword 0x00c1 0x0308199f0008501a +patword 0x00c2 0x0308199f0008501a +patword 0x00c3 0x0308199f0008501a +patword 0x00c4 0x0308199f0008501a +patword 0x00c5 0x0308199f0008501a +patword 0x00c6 0x0308199f0008501a +patword 0x00c7 0x0308199f0008501a +patword 0x00c8 0x0308199f0008501a +patword 0x00c9 0x0308199f0008501a +patword 0x00ca 0x0308199f0008501a +patword 0x00cb 0x0308199f0008501a +patword 0x00cc 0x0308199f0008501a +patword 0x00cd 0x0308199f0008501a +patword 0x00ce 0x0308199f0008501a +patword 0x00cf 0x0308199f0008501a +patword 0x00d0 0x0308199f0008501a +patword 0x00d1 0x0308199f0008501a +patword 0x00d2 0x0308199f0008501a +patword 0x00d3 0x0308199f0008501a +patword 0x00d4 0x0308599f0008503a +patword 0x00d5 0x0308599f0008503a +patword 0x00d6 0x030c599f000850ba +patword 0x00d7 0x030c599f000850ba +patword 0x00d8 0x030c599f000850ba +patword 0x00d9 0x030c599f000850ba +patword 0x00da 0x030c599f000850ba +patword 0x00db 0x030c599f000850ba +patword 0x00dc 0x030c599f000850ba +patword 0x00dd 0x030c599f000850ba +patword 0x00de 0x030c599f000850ba +patword 0x00df 0x030c599f000850ba +patword 0x00e0 0x030c599f000850ba +patword 0x00e1 0x030c599f000850ba +patword 0x00e2 0x030c599f000850ba +patword 0x00e3 0x030c599f000850ba +patword 0x00e4 0x030c599f000850ba +patword 0x00e5 0x030c599f000850ba +patword 0x00e6 0x030c599f000850ba +patword 0x00e7 0x030c599f000850ba +patword 0x00e8 0x030c599f000850ba +patword 0x00e9 0x030c599f000850ba +patword 0x00ea 0x030c799f010858ba +patword 0x00eb 0x030c799f010858ba +patword 0x00ec 0x030c599f000850ba +patword 0x00ed 0x030c599f000850ba +patword 0x00ee 0x030c599f000850ba +patword 0x00ef 0x030c599f000850ba +patword 0x00f0 0x030c599f000850ba +patword 0x00f1 0x030c599f000850ba +patword 0x00f2 0x030c599f000850ba +patword 0x00f3 0x030c599f000850ba +patword 0x00f4 0x030c599f000850ba +patword 0x00f5 0x030c599f000850ba +patword 0x00f6 0x030c599f000850ba +patword 0x00f7 0x030c599f000850ba +patword 0x00f8 0x030c599f000850ba +patword 0x00f9 0x030c599f000850ba +patword 0x00fa 0x030c599f000850ba +patword 0x00fb 0x030c599f000850ba +patword 0x00fc 0x030c599f000850ba +patword 0x00fd 0x030c599f000850ba +patword 0x00fe 0x030c599f000850ba +patword 0x00ff 0x030c599f000850ba +patword 0x0100 0x030c599f000850ba +patword 0x0101 0x030c599f000850ba +patword 0x0102 0x030c599f400850ba +patword 0x0103 0x030c599f400850ba +patword 0x0104 0x030c599f600850ba +patword 0x0105 0x030c599f400850ba +patword 0x0106 0x030c599f400850ba +patword 0x0107 0x030c599f400850ba +patword 0x0108 0x870c599f682e50ba +patword 0x0109 0x870c599f482850ba +patword 0x010a 0x870c599f000e50ba +patword 0x010b 0x870c599f000850ba +patword 0x010c 0x870c599f000e50ba +patword 0x010d 0x870c599f000850ba +patword 0x010e 0x870c599f000e50ba +patword 0x010f 0x870c599f000850ba +patword 0x0110 0x870c599f000e50ba +patword 0x0111 0x870c599f000850ba +patword 0x0112 0x870c599f000e50ba +patword 0x0113 0x870c599f000850ba +patword 0x0114 0x870c599f000e50ba +patword 0x0115 0x870c599f000850ba +patword 0x0116 0x870c599f000e50ba +patword 0x0117 0x870c599f000850ba +patword 0x0118 0x870c599f000e50ba +patword 0x0119 0x870c599f000850ba +patword 0x011a 0x870c599f000e50ba +patword 0x011b 0x870c599f000850ba +patword 0x011c 0x870c599f000e50ba +patword 0x011d 0x870c599f000850ba +patword 0x011e 0x870c599f000e50ba +patword 0x011f 0x870c599f000850ba +patword 0x0120 0x870c599f000e50ba +patword 0x0121 0x870c599f000850ba +patword 0x0122 0x870c599f200e50ba +patword 0x0123 0x870c599f000850ba +patword 0x0124 0x870c599f000e50ba +patword 0x0125 0x870c599f000850ba +patword 0x0126 0x870c599f000e50ba +patword 0x0127 0x870c599f000850ba +patword 0x0128 0x870c599f000e50ba +patword 0x0129 0x870c599f000850ba +patword 0x012a 0x870c599f000e50ba +patword 0x012b 0x870c599f000850ba +patword 0x012c 0x870c599f000e50ba +patword 0x012d 0x870c599f000850ba +patword 0x012e 0x870c599f000e50ba +patword 0x012f 0x870c599f000850ba +patword 0x0130 0x870c599f000e50ba +patword 0x0131 0x870c599f000850ba +patword 0x0132 0x870c599f000e50ba +patword 0x0133 0x870c599f000850ba +patword 0x0134 0x870c599f000e50ba +patword 0x0135 0x870c599f000850ba +patword 0x0136 0x870c599f000e50ba +patword 0x0137 0x870c599f000850ba +patword 0x0138 0x870c599f000e50ba +patword 0x0139 0x870c599f000850ba +patword 0x013a 0x870c599f282e50ba +patword 0x013b 0x870c599f082850ba +patword 0x013c 0x870c599f000e50ba +patword 0x013d 0x870c599f000850ba +patword 0x013e 0x870c599f000e50ba +patword 0x013f 0x870c599f000850ba +patword 0x0140 0x870c599f000e50ba +patword 0x0141 0x870c599f000850ba +patword 0x0142 0x870c599f000e50ba +patword 0x0143 0x870c599f000850ba +patword 0x0144 0x870c599f000e50ba +patword 0x0145 0x870c599f000850ba +patword 0x0146 0x870c599f000e50ba +patword 0x0147 0x870c599f000850ba +patword 0x0148 0x870c599f000e50ba +patword 0x0149 0x870c599f000850ba +patword 0x014a 0x870c599f000e50ba +patword 0x014b 0x870c599f000850ba +patword 0x014c 0x870c599f000e50ba +patword 0x014d 0x870c599f000850ba +patword 0x014e 0x870c599f000e50ba +patword 0x014f 0x870c599f000850ba +patword 0x0150 0x870c599f000e50ba +patword 0x0151 0x870c599f000850ba +patword 0x0152 0x870c599f000e50ba +patword 0x0153 0x870c599f000850ba +patword 0x0154 0x870c599f200e50ba +patword 0x0155 0x870c599f000850ba +patword 0x0156 0x870c599f000e50ba +patword 0x0157 0x870c599f000850ba +patword 0x0158 0x870c599f000e50ba +patword 0x0159 0x870c599f000850ba +patword 0x015a 0x870c599f000e50ba +patword 0x015b 0x870c599f000850ba +patword 0x015c 0x870c599f000e50ba +patword 0x015d 0x870c599f000850ba +patword 0x015e 0x870c599f000e50ba +patword 0x015f 0x870c599f000850ba +patword 0x0160 0x870c599f000e50ba +patword 0x0161 0x870c599f000850ba +patword 0x0162 0x870c599f000e50ba +patword 0x0163 0x870c599f000850ba +patword 0x0164 0x870c599f000e50ba +patword 0x0165 0x870c599f000850ba +patword 0x0166 0x870c599f000e50ba +patword 0x0167 0x870c599f000850ba +patword 0x0168 0x870c599f000e50ba +patword 0x0169 0x870c599f000850ba +patword 0x016a 0x870c599f000e50ba +patword 0x016b 0x870c599f000850ba +patword 0x016c 0x070c599f000850ba +patword 0x016d 0x070c599f000850ba +patword 0x016e 0x000c599f000850ba +patword 0x016f 0x000c599f000850ba +patword 0x0170 0x0008599f200e503a +patword 0x0171 0x0008599f0008503a +patword 0x0172 0x0008599f200e503a +patword 0x0173 0x0008599f0008503a +patword 0x0174 0x0008599f0008503a +patword 0x0175 0x0008599f0008503a +patword 0x0176 0x0008599f0008503a +patword 0x0177 0x0008599f0008503a +patword 0x0178 0x0008599f0008503a +patword 0x0179 0x0008599f0008503a +patword 0x017a 0x0008599f0008503a +patword 0x017b 0x0008599f0008503a +patword 0x017c 0x0008599f0008503a +patword 0x017d 0x0008599f0008503a +patword 0x017e 0x0008599f0008503a +patword 0x017f 0x0008599f0008503a +patword 0x0180 0x0008599f0008503a +patword 0x0181 0x0008599f0008503a +patword 0x0182 0x0008599f0008503a +patword 0x0183 0x0008599f0008503a +patword 0x0184 0x0008599f0008503a +patword 0x0185 0x0008599f0008503a +patword 0x0186 0x0008599f0008503a +patword 0x0187 0x0008599f0008503a +patword 0x0188 0x0008599f0008503a +patword 0x0189 0x0008599f0008503a +patword 0x018a 0x0008599f0008503a +patword 0x018b 0x0008599f0008503a +patword 0x018c 0x0008599f0008503a +patword 0x018d 0x0008599f0008503a +patioctrl 0x8f0effff6dbffdbf +patclkctrl 0x0000000000000000 +patlimits 0x0000 0x018c +patloop0 0x013a 0x016b +patnloop0 199 +patloop1 0x0400 0x0400 +patnloop1 0 +patloop2 0x0400 0x0400 +patnloop2 0 +patwait0 0x00aa +patwaittime0 10000 +patwait1 0x0400 +patwaittime1 0 +patwait2 0x0400 +patwaittime2 0 + diff --git a/slsDetectorServers/moenchDetectorServer/Makefile b/slsDetectorServers/moenchDetectorServer/Makefile index 5285f2ea2..9589da771 100755 --- a/slsDetectorServers/moenchDetectorServer/Makefile +++ b/slsDetectorServers/moenchDetectorServer/Makefile @@ -12,7 +12,7 @@ DESTDIR ?= bin INSTMODE = 0777 SRCS = slsDetectorFunctionList.c -SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)communication_funcs_UDP.c $(main_src)UDPPacketHeaderGenerator.c $(main_src)AD9257.c $(main_src)ALTERA_PLL.c $(main_src)LTC2620.c $(main_src)MAX1932.c $(main_src)programFpgaBlackfin.c +SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)communication_funcs_UDP.c $(main_src)UDPPacketHeaderGenerator.c $(main_src)AD9257.c $(main_src)ALTERA_PLL.c $(main_src)LTC2620.c $(main_src)MAX1932.c $(main_src)programFpgaBlackfin.c $(main_src)readDefaultPattern.c OBJS = $(SRCS:.c=.o) diff --git a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer index 5f32a8451..439291dda 100755 Binary files a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer and b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer differ diff --git a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c index 77513d918..6c0bcc36f 100755 --- a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c @@ -9,6 +9,7 @@ #include "MAX1932.h" // hv #include "ALTERA_PLL.h" // pll #include "blackfin.h" +#include "readDefaultPattern.h" #include "common.h" #include @@ -55,6 +56,7 @@ uint32_t clkFrequency[NUM_CLOCKS] = {40, 20, 20, 200}; int dacValues[NDAC] = {}; // software limit that depends on the current chip on the ctb int vLimit = 0; +enum detectorSettings thisSettings = UNINITIALIZED; int highvoltage = 0; int nSamples = 1; int detPos[2] = {0, 0}; @@ -521,6 +523,8 @@ void setupDetector() { initError = FAIL; } setPipeline(ADC_CLK, DEFAULT_PIPELINE); + loadDefaultPattern(DEFAULT_PATTERN_FILE); + setSettings(DEFAULT_SETTINGS); } int updateDatabytesandAllocateRAM() { @@ -862,10 +866,99 @@ int64_t getMeasurementTime() { } - /* parameters - settings */ + +enum detectorSettings setSettings(enum detectorSettings sett){ + if (sett == UNINITIALIZED) + return thisSettings; + + // set settings + if(sett != GET_SETTINGS) { + switch (sett) { + case G1_HIGHGAIN: + FILE_LOG(logINFO, ("Set settings - G1_HIGHGAIN\n")); + setPatternMask(G1_HIGHGAIN_PATMASK); + break; + case G1_LOWGAIN: + FILE_LOG(logINFO, ("Set settings - G1_LOWGAIN\n")); + setPatternMask(G1_LOWGAIN_PATMASK); + break; + case G2_HIGHCAP_HIGHGAIN: + FILE_LOG(logINFO, ("Set settings - G2_HIGHCAP_HIGHGAIN\n")); + setPatternMask(G2_HIGHCAP_HIGHGAIN_PATMASK); + break; + case G2_HIGHCAP_LOWGAIN: + FILE_LOG(logINFO, ("Set settings - G2_HIGHCAP_LOWGAIN\n")); + setPatternMask(G2_HIGHCAP_LOWGAIN_PATMASK); + break; + case G2_LOWCAP_HIGHGAIN: + FILE_LOG(logINFO, ("Set settings - G2_LOWCAP_HIGHGAIN\n")); + setPatternMask(G2_LOWCAP_HIGHGAIN_PATMASK); + break; + case G2_LOWCAP_LOWGAIN: + FILE_LOG(logINFO, ("Set settings - G2_LOWCAP_LOWGAIN\n")); + setPatternMask(G2_LOWCAP_LOWGAIN_PATMASK); + break; + case G4_HIGHGAIN: + FILE_LOG(logINFO, ("Set settings - G4_HIGHGAIN\n")); + setPatternMask(G4_HIGHGAIN_PATMASK); + break; + case G4_LOWGAIN: + FILE_LOG(logINFO, ("Set settings - G4_LOWGAIN\n")); + setPatternMask(G4_LOWGAIN_PATMASK); + break; + default: + FILE_LOG(logERROR, ("This settings is not defined for this detector %d\n", (int)sett)); + return -1; + } + setPatternBitMask(DEFAULT_PATSETBIT); + thisSettings = sett; + } + + return getSettings(); +} + enum detectorSettings getSettings() { - return UNDEFINED; + + uint64_t patsetbit = getPatternBitMask(); + if (patsetbit != DEFAULT_PATSETBIT) { + FILE_LOG(logERROR, ("Patsetbit is 0x%llx, and not 0x%llx. Undefined Settings!\n", patsetbit, DEFAULT_PATSETBIT)); + thisSettings = UNDEFINED; + return thisSettings; + } + + uint64_t patsetmask = getPatternMask(); + switch (patsetmask) { + case G1_HIGHGAIN_PATMASK: + thisSettings = G1_HIGHGAIN; + break; + case G1_LOWGAIN_PATMASK: + thisSettings = G1_LOWGAIN; + break; + case G2_HIGHCAP_HIGHGAIN_PATMASK: + thisSettings = G2_HIGHCAP_HIGHGAIN; + break; + case G2_HIGHCAP_LOWGAIN_PATMASK: + thisSettings = G2_HIGHCAP_LOWGAIN; + break; + case G2_LOWCAP_HIGHGAIN_PATMASK: + thisSettings = G2_LOWCAP_HIGHGAIN; + break; + case G2_LOWCAP_LOWGAIN_PATMASK: + thisSettings = G2_LOWCAP_LOWGAIN; + break; + case G4_HIGHGAIN_PATMASK: + thisSettings = G4_HIGHGAIN; + break; + case G4_LOWGAIN_PATMASK: + thisSettings = G4_LOWGAIN; + break; + default: + FILE_LOG(logERROR, ("Patsetmask is 0x%llx. Undefined Settings!\n", patsetmask)); + thisSettings = UNDEFINED; + break; + } + return thisSettings; } /* parameters - dac, adc, hv */ @@ -1690,6 +1783,7 @@ void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) { void setPatternMask(uint64_t mask) { + FILE_LOG(logINFO, ("Setting pattern mask to 0x%llx\n", mask)); set64BitReg(mask, PATTERN_MASK_LSB_REG, PATTERN_MASK_MSB_REG); } @@ -1698,6 +1792,7 @@ uint64_t getPatternMask() { } void setPatternBitMask(uint64_t mask) { + FILE_LOG(logINFO, ("Setting pattern bit mask to 0x%llx\n", mask)); set64BitReg(mask, PATTERN_SET_LSB_REG, PATTERN_SET_MSB_REG); } @@ -1706,6 +1801,7 @@ uint64_t getPatternBitMask() { } + /* aquisition */ int startStateMachine(){ diff --git a/slsDetectorServers/moenchDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/moenchDetectorServer/slsDetectorServer_defs.h index 2641a83d2..427a74223 100755 --- a/slsDetectorServers/moenchDetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/moenchDetectorServer/slsDetectorServer_defs.h @@ -60,6 +60,7 @@ enum CLKINDEX {RUN_CLK, ADC_CLK, SYNC_CLK, DBIT_CLK, NUM_CLOCKS}; #define NSAMPLES_PER_ROW (25) /** Default Parameters */ +#define DEFAULT_PATTERN_FILE ("DefaultPattern.txt") #define DEFAULT_DATA_BYTES (NCHIP * NCHAN * NUM_BITS_PER_PIXEL) #define DEFAULT_NUM_SAMPLES (5000) #define DEFAULT_EXPTIME (0) @@ -77,6 +78,18 @@ enum CLKINDEX {RUN_CLK, ADC_CLK, SYNC_CLK, DBIT_CLK, NUM_CLOCKS}; #define DEFAULT_DBIT_CLK (20) #define DEFAULT_ADC_PHASE_DEG (30) #define DEFAULT_PIPELINE (14) +#define DEFAULT_SETTINGS (G4_HIGHGAIN) + +// settings +#define DEFAULT_PATSETBIT (0x40800000115ULL) +#define G1_HIGHGAIN_PATMASK (0x40800000101ULL) +#define G1_LOWGAIN_PATMASK (0x40000000100ULL) +#define G2_HIGHCAP_HIGHGAIN_PATMASK (0x00800000001ULL) +#define G2_HIGHCAP_LOWGAIN_PATMASK (0x00000000000ULL) +#define G2_LOWCAP_HIGHGAIN_PATMASK (0x40800000115ULL) +#define G2_LOWCAP_LOWGAIN_PATMASK (0x40000000114ULL) +#define G4_HIGHGAIN_PATMASK (0x00800000015ULL) +#define G4_LOWGAIN_PATMASK (0x00000000014ULL) #define HIGHVOLTAGE_MIN (60) #define HIGHVOLTAGE_MAX (200) // min dac val diff --git a/slsDetectorServers/slsDetectorServer/include/readDefaultPattern.h b/slsDetectorServers/slsDetectorServer/include/readDefaultPattern.h new file mode 100755 index 000000000..a1554236a --- /dev/null +++ b/slsDetectorServers/slsDetectorServer/include/readDefaultPattern.h @@ -0,0 +1,22 @@ +#pragma once + +#include +#include + +int loadDefaultPattern(char* fname); + +int default_writePatternWord(char* line, uint32_t addr, uint64_t word); + +int default_writePatternIOControl(char* line, uint64_t arg); + +int default_writePatternClkControl(char* line, uint64_t arg); + +int default_setPatternLoopLimits(char* line, uint32_t startAddr, uint32_t stopAddr); + +int default_setPatternLoopAddresses(char* line, int level, uint32_t startAddr, uint32_t stopAddr); + +int default_setPatternLoopCycles(char* line, int level, int numLoops); + +int default_setPatternWaitAddresses(char* line, int level, uint32_t addr); + +int default_setPatternWaitTime(char* line, int level, uint64_t waittime); \ No newline at end of file diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index 71696a9c7..9483c33b1 100755 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -257,7 +257,7 @@ int64_t getMeasurementTime(); int setModule(sls_detector_module myMod, char* mess); int getModule(sls_detector_module *myMod); #endif -#if (!defined(CHIPTESTBOARDD)) && (!defined(MOENCHD)) && (!defined(MYTHEN3D)) +#if (!defined(CHIPTESTBOARDD)) && (!defined(MYTHEN3D)) enum detectorSettings setSettings(enum detectorSettings sett); #endif #if !defined(MYTHEN3D) @@ -403,6 +403,9 @@ uint64_t getPatternMask(); void setPatternBitMask(uint64_t mask); uint64_t getPatternBitMask(); #endif +#ifdef MOENCHD +extern int loadDefaultPattern(char* fname); // readDefaultPattern.h +#endif // jungfrau specific - powerchip, autocompdisable, clockdiv, asictimer, clock, pll, flashing firmware #ifdef JUNGFRAUD diff --git a/slsDetectorServers/slsDetectorServer/src/readDefaultPattern.c b/slsDetectorServers/slsDetectorServer/src/readDefaultPattern.c new file mode 100755 index 000000000..a50b3c5b5 --- /dev/null +++ b/slsDetectorServers/slsDetectorServer/src/readDefaultPattern.c @@ -0,0 +1,414 @@ +#include "readDefaultPattern.h" +#include "sls_detector_defs.h" +#include "slsDetectorServer_defs.h" +#include "ansi.h" +#include "clogger.h" + +#include + +extern char initErrorMessage[MAX_STR_LENGTH]; +extern int initError; + +extern uint64_t writePatternIOControl(uint64_t word); +extern uint64_t writePatternClkControl(uint64_t word); +extern uint64_t writePatternWord(int addr, uint64_t word); +extern int setPatternWaitAddress(int level, int addr); +extern uint64_t setPatternWaitTime(int level, uint64_t t); +extern void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop); + + +int loadDefaultPattern(char* fname) { + if (initError == FAIL) { + return initError; + } + + FILE* fd = fopen(fname, "r"); + if(fd == NULL) { + sprintf(initErrorMessage, "Could not open pattern file [%s].\n", fname); + initError = FAIL; + FILE_LOG(logERROR, ("%s\n\n", initErrorMessage)); + return FAIL; + } + FILE_LOG(logINFOBLUE, ("Reading default pattern file %s\n", fname)); + + + // Initialization + const size_t LZ = 256; + char line[LZ]; + memset(line, 0, LZ); + char command[LZ]; + + // keep reading a line + while (fgets(line, LZ, fd)) { + + // ignore comments + if (line[0] == '#') { + FILE_LOG(logDEBUG1, ("Ignoring Comment\n")); + continue; + } + + // ignore empty lines + if (strlen(line) <= 1) { + FILE_LOG(logDEBUG1, ("Ignoring Empty line\n")); + continue; + } + + FILE_LOG(logDEBUG1, ("Command to process: (size:%d) %.*s\n", + strlen(line), strlen(line) -1, line)); + memset(command, 0, LZ); + + // patword + if (!strncmp(line, "patword", strlen("patword"))) { + uint32_t addr = 0; + uint64_t word = 0; + + // cannot scan values + if (sscanf(line, "%s 0x%x 0x%llx", command, &addr, &word) != 3) { + sprintf(initErrorMessage, "Could not scan patword arguments from default " + "pattern file. Line:[%s].\n", line); + break; + } + + if (default_writePatternWord(line, addr, word) == FAIL) { + break; + } + } + + // patioctrl + if (!strncmp(line, "patioctrl", strlen("patioctrl"))) { + uint64_t arg = 0; + + // cannot scan values + if (sscanf(line, "%s 0x%llx", command, &arg) != 2) { + sprintf(initErrorMessage, "Could not scan patioctrl arguments from default " + "pattern file. Line:[%s].\n", line); + break; + } + + if (default_writePatternIOControl(line, arg) == FAIL) { + break; + } + } + + // patclkctrl + if (!strncmp(line, "patclkctrl", strlen("patclkctrl"))) { + uint64_t arg = 0; + + // cannot scan values + if (sscanf(line, "%s 0x%llx", command, &arg) != 2) { + sprintf(initErrorMessage, "Could not scan patclkctrl arguments from default " + "pattern file. Line:[%s].\n", line); + break; + } + + if (default_writePatternClkControl(line, arg) == FAIL) { + break; + } + } + + // patlimits + if (!strncmp(line, "patlimits", strlen("patlimits"))) { + uint32_t startAddr = 0; + uint32_t stopAddr = 0; + + // cannot scan values + if (sscanf(line, "%s 0x%x 0x%x", command, &startAddr, &stopAddr) != 3) { + sprintf(initErrorMessage, "Could not scan patlimits arguments from default " + "pattern file. Line:[%s].\n", line); + break; + } + + if (default_setPatternLoopLimits(line, startAddr, stopAddr) == FAIL) { + break; + } + } + + // patloop + if ((!strncmp(line, "patloop0", strlen("patloop0"))) || + (!strncmp(line, "patloop1", strlen("patloop1"))) || + (!strncmp(line, "patloop2", strlen("patloop2")))) { + + // level + int level = -1; + if (!strncmp(line, "patloop0", strlen("patloop0"))) { + level = 0; + } else if (!strncmp(line, "patloop1", strlen("patloop1"))) { + level = 1; + } else { + level = 2; + } + + uint32_t startAddr = 0; + uint32_t stopAddr = 0; + // cannot scan values + if (sscanf(line, "%s 0x%x 0x%x", command, &startAddr, &stopAddr) != 3) { + sprintf(initErrorMessage, "Could not scan patloop%d arguments from default " + "pattern file. Line:[%s].\n", level, line); + break; + } + + if (default_setPatternLoopAddresses(line, level, startAddr, stopAddr) == FAIL) { + break; + } + } + + // patnloop + if ((!strncmp(line, "patnloop0", strlen("patnloop0"))) || + (!strncmp(line, "patnloop1", strlen("patnloop1"))) || + (!strncmp(line, "patnloop2", strlen("patnloop2")))) { + + // level + int level = -1; + if (!strncmp(line, "patnloop0", strlen("patnloop0"))) { + level = 0; + } else if (!strncmp(line, "patnloop1", strlen("patnloop1"))) { + level = 1; + } else { + level = 2; + } + + int numLoops = -1; + // cannot scan values + if (sscanf(line, "%s %d", command, &numLoops) != 2) { + sprintf(initErrorMessage, "Could not scan patnloop%d arguments from default " + "pattern file. Line:[%s].\n", level, line); + break; + } + + if (default_setPatternLoopCycles(line, level, numLoops) == FAIL) { + break; + } + } + + // patwait + if ((!strncmp(line, "patwait0", strlen("patwait0"))) || + (!strncmp(line, "patwait1", strlen("patwait1"))) || + (!strncmp(line, "patwait2", strlen("patwait2")))) { + + // level + int level = -1; + if (!strncmp(line, "patwait0", strlen("patwait0"))) { + level = 0; + } else if (!strncmp(line, "patwait1", strlen("patwait1"))) { + level = 1; + } else { + level = 2; + } + + uint32_t addr = 0; + // cannot scan values + if (sscanf(line, "%s 0x%x", command, &addr) != 2) { + sprintf(initErrorMessage, "Could not scan patwait%d arguments from default " + "pattern file. Line:[%s].\n", level, line); + break; + } + + if (default_setPatternWaitAddresses(line, level, addr) == FAIL) { + break; + } + } + + // patwaittime + if ((!strncmp(line, "patwaittime0", strlen("patwaittime0"))) || + (!strncmp(line, "patwaittime1", strlen("patwaittime1"))) || + (!strncmp(line, "patwaittime2", strlen("patwaittime2")))) { + + // level + int level = -1; + if (!strncmp(line, "patwaittime0", strlen("patwaittime0"))) { + level = 0; + } else if (!strncmp(line, "patwaittime1", strlen("patwaittime1"))) { + level = 1; + } else { + level = 2; + } + + uint64_t waittime = 0; + + // cannot scan values + if (sscanf(line, "%s %lld", command, &waittime) != 2) { + sprintf(initErrorMessage, "Could not scan patwaittime%d arguments from default " + "pattern file. Line:[%s].\n", level, line); + break; + } + + if (default_setPatternWaitTime(line, level, waittime) == FAIL) { + break; + } + } + + memset(line, 0, LZ); + } + fclose(fd); + + if (strlen(initErrorMessage)) { + initError = FAIL; + FILE_LOG(logERROR, ("%s\n\n", initErrorMessage)); + } else { + FILE_LOG(logINFOBLUE, ("Successfully read default pattern file\n")); + } + return initError; +} + + +int default_writePatternWord(char* line, uint32_t addr, uint64_t word) { + //validations + if (addr < 0 || addr >= MAX_PATTERN_LENGTH) { + sprintf(initErrorMessage, "Cannot set pattern word from default " + "pattern file. Addr must be between 0 and 0x%x. Line:[%s]\n", + MAX_PATTERN_LENGTH, line); + return FAIL; + } + writePatternWord(addr, word); + // cannot validate for moench, ctb ( same as executing pattern word) + return OK; +} + +int default_writePatternIOControl(char* line, uint64_t arg) { + uint64_t retval = writePatternIOControl(arg); + if (retval != arg) { + sprintf(initErrorMessage, "Could not set patioctrl from default pattern " + "file. Set 0x%llx, read 0x%llx. Line:[%s]\n", arg, retval, line); + return FAIL; + } + return OK; +} + + +int default_writePatternClkControl(char* line, uint64_t arg) { + uint64_t retval = writePatternClkControl(arg); + if (retval != arg) { + sprintf(initErrorMessage, "Could not set patclkctrl from default pattern " + "file. Set 0x%llx, read 0x%llx. Line:[%s]\n", arg, retval, line); + return FAIL; + } + return OK; +} + +int default_setPatternLoopLimits(char* line, uint32_t startAddr, uint32_t stopAddr) { + //validations + if (startAddr < 0 || startAddr >= MAX_PATTERN_LENGTH || + stopAddr < 0 || stopAddr >= MAX_PATTERN_LENGTH) { + sprintf(initErrorMessage, "Cannot set patlimits from default " + "pattern file. Addr must be between 0 and 0x%x. Line:[%s]\n", + MAX_PATTERN_LENGTH, line); + return FAIL; + } + int numLoops = -1; + int r_startAddr = startAddr, r_stopAddr = stopAddr; + setPatternLoop(-1, &r_startAddr, &r_stopAddr, &numLoops); + + // validate + if (r_startAddr != startAddr || r_stopAddr != stopAddr) { + sprintf(initErrorMessage, "Could not set patlimits from default pattern " + "file. Read start addr:0x%x, stop addr: 0x%x. Line:[%s]\n", + r_startAddr, r_stopAddr, line); + return FAIL; + } + return OK; +} + +int default_setPatternLoopAddresses(char* line, int level, uint32_t startAddr, uint32_t stopAddr) { + //validations + if (level < 0 || level > 2) { + sprintf(initErrorMessage, "Cannot set patloop from default " + "pattern file. Level must be between 0 and 2. Line:[%s]\n", + line); + return FAIL; + } + if (startAddr < 0 || startAddr >= MAX_PATTERN_LENGTH || + stopAddr < 0 || stopAddr >= MAX_PATTERN_LENGTH) { + sprintf(initErrorMessage, "Cannot set patloop (level: %d) from default " + "pattern file. Addr must be between 0 and 0x%x. Line:[%s]\n", + level, MAX_PATTERN_LENGTH, line); + return FAIL; + } + int numLoops = -1; + int r_startAddr = startAddr, r_stopAddr = stopAddr; + setPatternLoop(level, &r_startAddr, &r_stopAddr, &numLoops); + + // validate + if (r_startAddr != startAddr || r_stopAddr != stopAddr) { + sprintf(initErrorMessage, "Could not set patloop (level: %d) from default " + "pattern file. Read start addr:0x%x, stop addr: 0x%x. Line:[%s]\n", + level, r_startAddr, r_stopAddr, line); + return FAIL; + } + return OK; +} + +int default_setPatternLoopCycles(char* line, int level, int numLoops) { + //validations + if (level < 0 || level > 2) { + sprintf(initErrorMessage, "Cannot set patnloop from default " + "pattern file. Level must be between 0 and 2. Line:[%s]\n", + line); + return FAIL; + } + if (numLoops < 0) { + sprintf(initErrorMessage, "Cannot set patnloop from default " + "pattern file. Iterations must be between > 0. Line:[%s]\n", + line); + return FAIL; + } + int startAddr = -1; + int stopAddr = -1; + int r_numLoops = numLoops; + setPatternLoop(level, &startAddr, &stopAddr, &r_numLoops); + + // validate + if (r_numLoops != numLoops) { + sprintf(initErrorMessage, "Could not set patnloop (level: %d) from default " + "pattern file. Read %d loops. Line:[%s]\n", + level, r_numLoops, line); + return FAIL; + } + return OK; +} + +int default_setPatternWaitAddresses(char* line, int level, uint32_t addr) { + //validations + if (level < 0 || level > 2) { + sprintf(initErrorMessage, "Cannot set patwait address from default " + "pattern file. Level must be between 0 and 2. Line:[%s]\n", + line); + return FAIL; + } + if (addr < 0 || addr >= MAX_PATTERN_LENGTH) { + sprintf(initErrorMessage, "Cannot set patwait address (level: %d) from default " + "pattern file. Addr must be between 0 and 0x%x. Line:[%s]\n", + level, MAX_PATTERN_LENGTH, line); + return FAIL; + } + + int retval = setPatternWaitAddress(level, addr); + + // validate + if (retval != addr) { + sprintf(initErrorMessage, "Could not set patwait address (level: %d) from default " + "pattern file. Read addr: 0x%x. Line:[%s]\n", + level, retval, line); + return FAIL; + } + return OK; +} + +int default_setPatternWaitTime(char* line, int level, uint64_t waittime) { + //validations + if (level < 0 || level > 2) { + sprintf(initErrorMessage, "Cannot set patwaittime from default " + "pattern file. Level must be between 0 and 2. Line:[%s]\n", + line); + return FAIL; + } + uint64_t retval = setPatternWaitTime(level, waittime); + + // validate + if (retval != waittime) { + sprintf(initErrorMessage, "Could not set patwaittime (level: %d) from default " + "pattern file. Read %lld wait time. Line:[%s]\n", + level, retval, line); + return FAIL; + } + return OK; +} diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 42137d235..7c709d39e 100755 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -1670,7 +1670,7 @@ int set_settings(int file_des) { if (receiveData(file_des, &isett, sizeof(isett), INT32) < 0) return printSocketReadError(); -#if defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(MYTHEN3D) +#if defined(CHIPTESTBOARDD) || defined(MYTHEN3D) functionNotImplemented(); #else FILE_LOG(logDEBUG1, ("Setting settings %d\n", isett)); @@ -1698,6 +1698,15 @@ int set_settings(int file_des) { case DYNAMICGAIN: case FIXGAIN1: case FIXGAIN2: +#elif MOENCHD + case G1_HIGHGAIN: + case G1_LOWGAIN: + case G2_HIGHCAP_HIGHGAIN: + case G2_HIGHCAP_LOWGAIN: + case G2_LOWCAP_HIGHGAIN: + case G2_LOWCAP_LOWGAIN: + case G4_HIGHGAIN: + case G4_LOWGAIN: #endif break; default: @@ -2818,7 +2827,7 @@ int send_update(int file_des) { if (n < 0) return printSocketReadError(); // settings -#if defined(EIGERD) || defined(JUNGFRAUD) || defined(GOTTHARDD) +#if defined(EIGERD) || defined(JUNGFRAUD) || defined(GOTTHARDD) || defined(GOTTHARD2D)|| defined(MOENCHD) i32 = (int)getSettings(); n = sendData(file_des,&i32,sizeof(i32),INT32); if (n < 0) return printSocketReadError(); diff --git a/slsDetectorSoftware/include/Detector.h b/slsDetectorSoftware/include/Detector.h index ce8128602..8cbe0cd55 100644 --- a/slsDetectorSoftware/include/Detector.h +++ b/slsDetectorSoftware/include/Detector.h @@ -101,6 +101,8 @@ class Detector { /** [Jungfrau] Options:DYNAMICGAIN, DYNAMICHG0, FIXGAIN1, FIXGAIN2, FORCESWITCHG1, FORCESWITCHG2 * [Gotthard] Options: DYNAMICGAIN, HIGHGAIN, LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN * [Gotthard2] Options: DYNAMICGAIN, FIXGAIN1, FIXGAIN2 + * [Moench] Options: G1_HIGHGAIN, G1_LOWGAIN, G2_HIGHCAP_HIGHGAIN, G2_HIGHCAP_LOWGAIN, + * G2_LOWCAP_HIGHGAIN, G2_LOWCAP_LOWGAIN, G4_HIGHGAIN, G4_LOWGAIN */ void setSettings(defs::detectorSettings value, Positions pos = {}); diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index d5d072df0..2c83f5679 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -1013,10 +1013,14 @@ class CmdProxy { "\n\tSerial number or MAC of detector (hex)."); INTEGER_COMMAND(settings, getSettings, setSettings, sls::StringTo, - "[standard, fast, highgain, dynamicgain, lowgain, mediumgain, veryhighgain, dynamichg0, fixgain1, fixgain2, forceswitchg1, forceswitchg2, verylowgain]" - "\n\t[Jungfrau] - Detector Settings [dynamicgain | dynamichg0 | fixgain1 | fixgain2 | forceswitchg1 | forceswitchg2]" - "\n\t[Gotthard] - Detector Settings [dynamicgain | highgain | lowgain | mediumgain | veryhighgain]" - "\n\t[Gotthard2] - Detector Settings [dynamicgain | fixgain1 | fixgain2]" + "[standard, fast, highgain, dynamicgain, lowgain, mediumgain, veryhighgain, dynamichg0, " + "fixgain1, fixgain2, forceswitchg1, forceswitchg2, verylowgain, g1_hg, g1_lg, g2_hc_hg, g2_hc_lg, " + "g2_lc_hg, g2_lc_lg, g4_hg, g4_lg]" + "\n\t Detector Settings" + "\n\t[Jungfrau] - [dynamicgain | dynamichg0 | fixgain1 | fixgain2 | forceswitchg1 | forceswitchg2]" + "\n\t[Gotthard] - [dynamicgain | highgain | lowgain | mediumgain | veryhighgain]" + "\n\t[Gotthard2] - [dynamicgain | fixgain1 | fixgain2]" + "\n\t[Moench] - [g1_hg | g1_lg | g2_hc_hg | g2_hc_lg | g2_lc_hg | g2_lc_lg | g4_hg | g4_lg]" "\n\t[Eiger] Use threshold or thresholdnotb."); /* acquisition parameters */ diff --git a/slsDetectorSoftware/src/slsDetector.cpp b/slsDetectorSoftware/src/slsDetector.cpp index 1a9c36e21..fe4a9ab49 100755 --- a/slsDetectorSoftware/src/slsDetector.cpp +++ b/slsDetectorSoftware/src/slsDetector.cpp @@ -758,8 +758,9 @@ void slsDetector::updateCachedDetectorVariables() { shm()->dynamicRange = i32; // settings - if (shm()->myDetectorType == EIGER || - shm()->myDetectorType == JUNGFRAU || shm()->myDetectorType == GOTTHARD) { + if (shm()->myDetectorType == EIGER || shm()->myDetectorType == JUNGFRAU || + shm()->myDetectorType == GOTTHARD || shm()->myDetectorType == GOTTHARD2 || + shm()->myDetectorType == MOENCH) { n += client.Receive(&i32, sizeof(i32)); shm()->currentSettings = static_cast(i32); } diff --git a/slsDetectorSoftware/src/slsDetector.h b/slsDetectorSoftware/src/slsDetector.h index ff7cb8953..86cfe127f 100755 --- a/slsDetectorSoftware/src/slsDetector.h +++ b/slsDetectorSoftware/src/slsDetector.h @@ -407,6 +407,8 @@ class slsDetector : public virtual slsDetectorDefs { /** [Jungfrau] Options:DYNAMICGAIN, DYNAMICHG0, FIXGAIN1, FIXGAIN2, FORCESWITCHG1, FORCESWITCHG2 * [Gotthard] Options: DYNAMICGAIN, HIGHGAIN, LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN * [Gotthard2] Options: DYNAMICGAIN, FIXGAIN1, FIXGAIN2 + * [Moench] Options: G1_HIGHGAIN, G1_LOWGAIN, G2_HIGHCAP_HIGHGAIN, G2_HIGHCAP_LOWGAIN, + * G2_LOWCAP_HIGHGAIN, G2_LOWCAP_LOWGAIN, G4_HIGHGAIN, G4_LOWGAIN * [Eiger] Only stores them locally in shm Options: STANDARD, HIGHGAIN, LOWGAIN, VERYHIGHGAIN, VERYLOWGAIN */ detectorSettings setSettings(detectorSettings isettings); diff --git a/slsDetectorSoftware/tests/CMakeLists.txt b/slsDetectorSoftware/tests/CMakeLists.txt index 4a7d7287d..111c82122 100755 --- a/slsDetectorSoftware/tests/CMakeLists.txt +++ b/slsDetectorSoftware/tests/CMakeLists.txt @@ -9,6 +9,7 @@ target_sources(tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/test-CmdProxy-gotthard2.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test-CmdProxy-gotthard.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test-CmdProxy-chiptestboard.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test-CmdProxy-moench.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test-CmdProxy-global.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test-Result.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test-CmdParser.cpp diff --git a/slsDetectorSoftware/tests/test-CmdProxy-moench.cpp b/slsDetectorSoftware/tests/test-CmdProxy-moench.cpp new file mode 100644 index 000000000..b7d62c1d9 --- /dev/null +++ b/slsDetectorSoftware/tests/test-CmdProxy-moench.cpp @@ -0,0 +1,103 @@ +#include "CmdProxy.h" +#include "Detector.h" +#include "catch.hpp" +#include "sls_detector_defs.h" +#include + +#include "Result.h" +#include "ToString.h" +#include "test-CmdProxy-global.h" +#include "tests/globals.h" +#include "versionAPI.h" + +using sls::CmdProxy; +using sls::Detector; +using test::GET; +using test::PUT; + +TEST_CASE("Setting and reading back MOENCH dacs", "[.cmd][.dacs]") { + // vbp_colbuf, vipre, vin_cm", vb_sda, vcasc_sfp, vout_cm, vipre_cds, ibias_sfp + + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::MOENCH) { + SECTION("vbp_colbuf") { test_dac(defs::VBP_COLBUF, "vbp_colbuf", 1300); } + SECTION("vipre") { test_dac(defs::VIPRE, "vipre", 1000); } + SECTION("vin_cm") { test_dac(defs::VIN_CM, "vin_cm", 1400); } + SECTION("vb_sda") { test_dac(defs::VB_SDA, "vb_sda", 680); } + SECTION("vcasc_sfp") { test_dac(defs::VCASC_SFP, "vcasc_sfp", 1428); } + SECTION("vout_cm") { test_dac(defs::VOUT_CM, "vout_cm", 1200); } + SECTION("vipre_cds") { test_dac(defs::VIPRE_CDS, "vipre_cds", 800); } + SECTION("ibias_sfp") { test_dac(defs::IBIAS_SFP, "ibias_sfp", 900); } + + // eiger + REQUIRE_THROWS(proxy.Call("vthreshold", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vsvp", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vsvn", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vtr", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vrf", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vrs", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vtgstv", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcmp_ll", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcmp_lr", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcal", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcmp_rl", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcmp_rr", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("rxb_rb", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("rxb_lb", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcp", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcn", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vis", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("iodelay", {}, -1, GET)); + // jungfrau + REQUIRE_THROWS(proxy.Call("vb_comp", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vdd_prot", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vin_com", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vref_prech", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vb_pixbuf", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vb_ds", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vref_ds", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vref_comp", {}, -1, GET)); + // gotthard + REQUIRE_THROWS(proxy.Call("vref_ds", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcascn_pb", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcascp_pb", {}, -1, GET)); + //REQUIRE_THROWS(proxy.Call("vout_cm", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcasc_out", {}, -1, GET)); + //REQUIRE_THROWS(proxy.Call("vin_cm", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vref_comp", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("ib_test_c", {}, -1, GET)); + // mythen3 + REQUIRE_THROWS(proxy.Call("vpreamp", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vshaper", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vshaperneg", {}, -1, GET)); + //REQUIRE_THROWS(proxy.Call("vipre", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("viinsh", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vdcsh", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vth1", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vth2", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vth3", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vpl", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vph", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vtrim", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcassh", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcas", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vicin", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vipre_out", {}, -1, GET)); + // gotthard2 + REQUIRE_THROWS(proxy.Call("vref_h_adc", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vb_comp_fe", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vb_comp_adc", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcom_cds", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vref_rstore", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vb_opa_1st", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vref_comp_fe", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcom_adc1", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vref_l_adc", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vref_cds", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vb_cs", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vb_opa_fd", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vcom_adc2", {}, -1, GET)); + } +} diff --git a/slsSupportLib/include/ToString.h b/slsSupportLib/include/ToString.h index e22d1732a..cde6dc972 100644 --- a/slsSupportLib/include/ToString.h +++ b/slsSupportLib/include/ToString.h @@ -91,6 +91,22 @@ inline std::string ToString(const defs::detectorSettings s) { return std::string("forceswitchg2"); case defs::VERYLOWGAIN: return std::string("verylowgain"); + case defs::G1_HIGHGAIN: + return std::string("g1_hg"); + case defs::G1_LOWGAIN: + return std::string("g1_lg"); + case defs::G2_HIGHCAP_HIGHGAIN: + return std::string("g2_hc_hg"); + case defs::G2_HIGHCAP_LOWGAIN: + return std::string("g2_hc_lg"); + case defs::G2_LOWCAP_HIGHGAIN: + return std::string("g2_lc_hg"); + case defs::G2_LOWCAP_LOWGAIN: + return std::string("g2_lc_lg"); + case defs::G4_HIGHGAIN: + return std::string("g4_hg"); + case defs::G4_LOWGAIN: + return std::string("g4_lg"); case defs::UNDEFINED: return std::string("undefined"); case defs::UNINITIALIZED: @@ -459,6 +475,22 @@ inline defs::detectorSettings StringTo(const std::string& s) { return defs::FORCESWITCHG2; if (s == "verylowgain") return defs::VERYLOWGAIN; + if (s == "g1_hg") + return defs::G1_HIGHGAIN; + if (s == "g1_lg") + return defs::G1_LOWGAIN; + if (s == "g2_hc_hg") + return defs::G2_HIGHCAP_HIGHGAIN; + if (s == "g2_hc_lg") + return defs::G2_HIGHCAP_LOWGAIN; + if (s == "g2_lc_hg") + return defs::G2_LOWCAP_HIGHGAIN; + if (s == "g2_lc_lg") + return defs::G2_LOWCAP_LOWGAIN; + if (s == "g4_hg") + return defs::G4_HIGHGAIN; + if (s == "g4_lg") + return defs::G4_LOWGAIN; throw sls::RuntimeError("Unknown setting " + s); } diff --git a/slsSupportLib/include/sls_detector_defs.h b/slsSupportLib/include/sls_detector_defs.h index 07e30f8f9..48cc39268 100755 --- a/slsSupportLib/include/sls_detector_defs.h +++ b/slsSupportLib/include/sls_detector_defs.h @@ -364,20 +364,28 @@ class slsDetectorDefs { detector settings indexes */ enum detectorSettings { - GET_SETTINGS = -1, /**< return current detector settings */ - STANDARD, /**< standard settings */ - FAST, /**< fast settings */ - HIGHGAIN, /**< highgain settings */ - DYNAMICGAIN, /**< dynamic gain settings */ - LOWGAIN, /**< low gain settings */ - MEDIUMGAIN, /**< medium gain settings */ - VERYHIGHGAIN, /**< very high gain settings */ - DYNAMICHG0, /**< dynamic high gain 0 */ - FIXGAIN1, /**< fix gain 1 */ - FIXGAIN2, /**< fix gain 2 */ - FORCESWITCHG1, /**< force switch gain 1 */ - FORCESWITCHG2, /**< force switch gain 2 */ - VERYLOWGAIN, /**< very low gain settings */ + GET_SETTINGS = -1, + STANDARD, + FAST, + HIGHGAIN, + DYNAMICGAIN, + LOWGAIN, + MEDIUMGAIN, + VERYHIGHGAIN, + DYNAMICHG0, + FIXGAIN1, + FIXGAIN2, + FORCESWITCHG1, + FORCESWITCHG2, + VERYLOWGAIN, + G1_HIGHGAIN, + G1_LOWGAIN, + G2_HIGHCAP_HIGHGAIN, + G2_HIGHCAP_LOWGAIN, + G2_LOWCAP_HIGHGAIN, + G2_LOWCAP_LOWGAIN, + G4_HIGHGAIN, + G4_LOWGAIN, UNDEFINED = 200, /**< undefined or custom settings */ UNINITIALIZED /**< uninitialiazed (status at startup) */ }; diff --git a/slsSupportLib/include/versionAPI.h b/slsSupportLib/include/versionAPI.h index 0c81f31b6..8f6161275 100644 --- a/slsSupportLib/include/versionAPI.h +++ b/slsSupportLib/include/versionAPI.h @@ -9,4 +9,4 @@ #define APIGUI 0x200227 #define APICTB 0x200227 #define APIGOTTHARD2 0x200228 -#define APIMOENCH 0x200302 +#define APIMOENCH 0x200303