@@ -532,28 +532,28 @@ Function/S GetPanelControl(channelIndex, channelType, controlType)
532
532
End
533
533
534
534
/// @brief Find the first and last point index of a consecutive range of
535
- /// values in the labnotebook
535
+ /// values in the labnotebook, searches the range from the back
536
536
///
537
537
/// @param[in] wv wave to search
538
538
/// @param[in] col column to look for
539
539
/// @param[in] val value to search
540
- /// @param[in] forwardORBackward find the first(1) or last(0) range
541
540
/// @param[in] entrySourceType type of the labnotebook entry, one of @ref DataAcqModes
542
541
/// @param[out] first point index of the beginning of the range
543
542
/// @param[out] last point index of the end of the range
544
- threadsafe static Function FindRange ( wv, col, val, forwardORBackward, entrySourceType, first, last)
543
+ threadsafe static Function FindRange ( wv, col, val, entrySourceType, first, last)
545
544
WAVE wv
546
- variable col, val, forwardORBackward , entrySourceType
545
+ variable col, val, entrySourceType
547
546
variable & first, & last
548
547
549
- variable numRows, i , sourceTypeCol, firstRow, lastRow
548
+ variable numRows, i , j , sourceTypeCol, firstRow, lastRow, isNumeric , index
550
549
551
- first = NaN
552
- last = NaN
550
+ first = NaN
551
+ last = NaN
552
+ isNumeric = IsNumericWave ( wv)
553
553
554
554
// still correct without startLayer/endLayer coordinates
555
555
// as we always have sweepNumber/etc. in the first layer
556
- if ( IsNaN ( val) && IsNumericWave ( wv ) )
556
+ if ( IsNaN ( val) && isNumeric )
557
557
WAVE /Z indizesSetting = FindIndizes ( wv, col = col, prop = PROP_EMPTY)
558
558
else
559
559
WAVE /Z indizesSetting = FindIndizes ( wv, col = col, var = val)
@@ -563,8 +563,8 @@ threadsafe static Function FindRange(wv, col, val, forwardORBackward, entrySourc
563
563
return NaN
564
564
endif
565
565
566
+ sourceTypeCol = FindDimLabel ( wv, COLS, "EntrySourceType" )
566
567
if ( IsFinite ( entrySourceType))
567
- sourceTypeCol = FindDimLabel ( wv, COLS, "EntrySourceType" )
568
568
569
569
if ( sourceTypeCol >= 0 ) // labnotebook has a entrySourceType column
570
570
[ firstRow, lastRow] = WaveMinAndMax ( indizesSetting)
@@ -614,33 +614,33 @@ threadsafe static Function FindRange(wv, col, val, forwardORBackward, entrySourc
614
614
return NaN
615
615
endif
616
616
617
- if ( forwardORBackward)
618
-
619
- first = indizes[ 0 ]
620
- last = indizes[ 0 ]
621
-
622
- for ( i = 1; i < numRows; i += 1 )
623
- // a forward search stops after the end of the first sequence
624
- if ( indizes[ i ] > last + 1 )
625
- return NaN
626
- endif
627
-
628
- last = indizes[ i ]
629
- endfor
630
- else
617
+ if ( ! IsNumeric)
618
+ WAVE /T wt = wv
619
+ endif
631
620
632
- first = indizes[ numRows - 1 ]
633
- last = indizes[ numRows - 1 ]
621
+ first = indizes[ numRows - 1 ]
622
+ last = indizes[ numRows - 1 ]
634
623
635
- for ( i = numRows - 2; i >= 0; i -= 1 )
636
- // a backward search stops when the beginning of the last sequence was found
637
- if ( indizes[ i ] < first - 1 )
638
- return NaN
624
+ for ( i = numRows - 2; i >= 0; i -= 1 )
625
+ index = indizes[ i ]
626
+ // a backward search stops when the beginning of the last sequence was found
627
+ if ( index < first - 1 )
628
+ if ( IsNumeric)
629
+ for ( j = index + 1; j < first; j += 1 )
630
+ if ( ! IsNaN ( wv[ j][ sourceTypeCol][ 0 ]))
631
+ return NaN
632
+ endif
633
+ endfor
634
+ else
635
+ for ( j = index + 1; j < first; j += 1 )
636
+ if ( ! IsEmpty ( wt[ j][ sourceTypeCol][ 0 ]))
637
+ return NaN
638
+ endif
639
+ endfor
639
640
endif
640
-
641
- first = indizes[ i ]
642
- endfor
643
- endif
641
+ endif
642
+ first = index
643
+ endfor
644
644
End
645
645
646
646
/// @brief Test helper to enforce that every query done for an INDEP_HEADSTAGE setting
@@ -1157,7 +1157,7 @@ threadsafe Function/WAVE GetLastSettingNoCache(values, sweepNo, setting, entrySo
1157
1157
variable settingCol, numLayers, i , sweepCol, numEntries
1158
1158
variable firstValue, lastValue, sourceTypeCol, peakResistanceCol, pulseDurationCol
1159
1159
variable testpulseBlockLength, blockType, hasValidTPPulseDurationEntry
1160
- variable mode
1160
+ variable mode, sweepNoInLNB
1161
1161
1162
1162
if ( ! ParamIsDefault ( rowIndex))
1163
1163
rowIndex = LABNOTEBOOK_MISSING_VALUE
@@ -1184,9 +1184,9 @@ threadsafe Function/WAVE GetLastSettingNoCache(values, sweepNo, setting, entrySo
1184
1184
return $ ""
1185
1185
endif
1186
1186
1187
+ sweepCol = GetSweepColumn ( values)
1187
1188
if ( mode == GET_LB_MODE_NONE || mode == GET_LB_MODE_WRITE)
1188
- sweepCol = GetSweepColumn ( values)
1189
- FindRange ( values, sweepCol, sweepNo, 0, entrySourceType, firstValue, lastValue)
1189
+ FindRange ( values, sweepCol, sweepNo, entrySourceType, firstValue, lastValue)
1190
1190
1191
1191
if ( ! IsFinite ( firstValue) && ! IsFinite ( lastValue)) // sweep number is unknown
1192
1192
return $ ""
@@ -1209,6 +1209,12 @@ threadsafe Function/WAVE GetLastSettingNoCache(values, sweepNo, setting, entrySo
1209
1209
Make / FREE/ N= ( numLayers) lengths
1210
1210
1211
1211
for ( i = lastValue; i >= firstValue; i -= 1 )
1212
+
1213
+ sweepNoInLNB = str2num ( textualValues[ i ][ sweepCol][ 0 ])
1214
+ if ( ! IsNaN ( sweepNoInLNB) && sweepNoInLNB != sweepNo)
1215
+ continue
1216
+ endif
1217
+
1212
1218
if ( IsFinite ( entrySourceType))
1213
1219
if ( ! sourceTypeCol)
1214
1220
sourceTypeCol = FindDimLabel ( textualValues, COLS, "EntrySourceType" )
@@ -1245,6 +1251,10 @@ threadsafe Function/WAVE GetLastSettingNoCache(values, sweepNo, setting, entrySo
1245
1251
1246
1252
for ( i = lastValue; i >= firstValue; i -= 1 )
1247
1253
1254
+ if ( ! IsNaN ( sweepNo) && numericalValues[ i ][ sweepCol][ 0 ] != sweepNo)
1255
+ continue
1256
+ endif
1257
+
1248
1258
if ( IsFinite ( entrySourceType))
1249
1259
if ( ! sourceTypeCol)
1250
1260
sourceTypeCol = FindDimLabel ( numericalValues, COLS, "EntrySourceType" )
0 commit comments