@@ -664,10 +664,19 @@ static Function saveResults(procedure)
664
664
endif
665
665
End
666
666
667
+ // Load the specified procedure from storage waves
668
+ //
669
+ // return errorCode
670
+ // 1 Load successfull
671
+ // 0 save state loaded with zero elements
672
+ // -1 Could not load save state
673
+ // -2 CheckSum missmatch. CheckSum has been calculated and was stored in
674
+ // global variable
667
675
static Function saveLoad ( procedure)
668
676
STRUCT procedure & procedure
669
677
670
678
Variable numResults
679
+ string CheckSum
671
680
672
681
Wave /T declWave = getDeclWave ()
673
682
Wave /I lineWave = getLineWave ()
@@ -676,72 +685,72 @@ static Function saveLoad(procedure)
676
685
Wave /T SaveStringsWave = getSaveStrings ()
677
686
Wave SaveVariablesWave = getSaveVariables ()
678
687
688
+ // if maximum storage capacity was reached (procedure.row == -1) or
689
+ // Element not found (procedure.row == endofWave) --> nothing loadable
679
690
if (( procedure. row < 0 ) || ( procedure. row == Dimsize ( SaveStringsWave, 0 )) || ( Dimsize ( SaveStringsWave, 0 ) == 0 ))
680
- // if maximum storage capacity was reached (procedure.row == -1) or Element not found (procedure.row == endofWave) there is nothing to load.
681
691
debugPrint ( "save state not found" )
682
692
return -1
683
- elseif ( isCompiled () && ! SaveVariablesWave[ procedure. row][ 0 ])
684
- // procedure marked as non valid by AfterRecompileHook
685
- // checksum needs to be compared.
693
+ endif
694
+ if ( isCompiled () && ! SaveVariablesWave[ procedure. row][ 0 ])
695
+ // procedure marked as not valid by
696
+ // AfterCompiledHook --> updatePanel --> saveReParse
697
+ // --> CheckSum needs to be compared.
686
698
687
- // getting checksum
688
- if ( setChecksum ( procedure) != 1 )
689
- debugPrint ( "error creating variable" )
699
+ if ( ! setChecksum ( procedure))
700
+ debugPrint ( "error creating CheckSum" )
690
701
return -1
691
702
endif
692
- // comparing checksum
693
- if ( cmpstr ( SaveStringsWave[ procedure. row][ 1 ] , getChecksum ()) != 0 )
694
- // checksum changed. return -2 to indicate that calculation was already done by setChecksum.
695
- debugPrint ( "Checksum missmatch: Procedure has to be reloaded." )
703
+ CheckSum = getCheckSum ()
704
+ if ( !! cmpstr ( SaveStringsWave[ procedure. row][ 1 ] , CheckSum))
705
+ debugPrint ( "CheckSum missmatch: Procedure has to be reloaded." )
696
706
return -2
697
- else
698
- //mark as valid
699
- debugPrint ( "Checksum match: Procedure marked valid." )
700
- SaveVariablesWave[ procedure. row][ 0 ] = 1
701
707
endif
708
+ debugPrint ( "CheckSum match: " + CheckSum)
709
+
710
+ SaveVariablesWave[ procedure. row][ 0 ] = 1
711
+ debugPrint ( "Procedure " + procedure. fullname + " marked as valid." )
702
712
endif
703
713
704
- // load results from free waves
705
714
numResults = Dimsize ( SaveWavesWave[ procedure. row][ 0 ] , 0 )
706
715
Redimension / N= ( numResults, -1 ) declWave, lineWave
707
- if ( numResults > 0 )
708
- WAVE /T load0 = SaveWavesWave[ procedure. row][ 0 ]
709
- WAVE /I load1 = SaveWavesWave[ procedure. row][ 1 ]
710
- declWave[][ 0 ] = load0 [ p][ 0 ]
711
- declWave[][ 1 ] = load0 [ p][ 1 ]
712
- lineWave[] = load1 [ p]
713
- debugPrint ( "save state loaded successfully" )
714
- return 1
715
- else
716
+ if ( numResults == 0 )
716
717
debugPrint ( "no elements in save state" )
717
718
return 0
718
719
endif
720
+
721
+ WAVE /T load0 = SaveWavesWave[ procedure. row][ 0 ]
722
+ WAVE /I load1 = SaveWavesWave[ procedure. row][ 1 ]
723
+ declWave[][ 0 ] = load0 [ p][ 0 ]
724
+ declWave[][ 1 ] = load0 [ p][ 1 ]
725
+ lineWave[] = load1 [ p]
726
+
727
+ debugPrint ( "save state loaded successfully" )
728
+ return 1
719
729
End
720
730
721
731
// Identifier = module#procedure
722
732
static Function getSaveRow ( Identifier)
723
733
String Identifier
724
734
725
735
Wave /T SaveStrings = getSaveStrings ()
726
- Variable found, endOfWave
736
+ Variable found, endOfWave, element
727
737
728
738
FindValue / TEXT= Identifier/ TXOP=4/ Z SaveStrings
729
- if ( V_value == -1 )
730
- // element not found
739
+ if ( V_Value == -1 )
740
+ debugPrint ( "Element not found" )
731
741
return Dimsize ( SaveStrings, 0 )
732
- else
733
- // element found at position V_value
734
-
735
- // check for inconsistency.
736
- if ( V_value > CsaveMaximum )
737
- DebugPrint ( "Storage capacity exceeded" )
738
- // should only happen if(CsaveMaximum) was touched on runtime.
739
- // Redimension/Deletion of Wave could be possible.
740
- return ( CsaveMaximum - 1 )
741
- endif
742
-
743
- return V_value
744
742
endif
743
+ element = V_Value
744
+
745
+ // check for inconsistency.
746
+ if ( element > CsaveMaximum )
747
+ debugPrint ( "Storage capacity exceeded" )
748
+ // should only happen if(CsaveMaximum) was touched on runtime.
749
+ // Redimension/Deletion of Wave could be possible.
750
+ return ( CsaveMaximum - 1 )
751
+ endif
752
+
753
+ return element
745
754
End
746
755
747
756
// drop first item at position 0. push all elements upward by 1 element. Free last Position.
@@ -1060,6 +1069,8 @@ End
1060
1069
1061
1070
static Function setParsingTime ( numTime)
1062
1071
Variable numTime
1072
+
1073
+ debugPrint ( "parsing time:" + num2str ( numTime))
1063
1074
return setGlobalVar ( "parsingTime" , numTime)
1064
1075
End
1065
1076
0 commit comments