@@ -649,12 +649,14 @@ End
649
649
// Parses all procedure windows and write into the decl and line waves
650
650
Function /S parseProcedure ( procedure, [ checksumIsCalculated] )
651
651
STRUCT procedure & procedure
652
- Variable checksumIsCalculated
652
+ Variable checkSumIsCalculated
653
653
654
654
if ( ParamIsDefault ( checksumIsCalculated))
655
- checksumIsCalculated = 0
655
+ checkSumIsCalculated = 0
656
+ endif
657
+ if ( ! checkSumIsCalculated)
658
+ DebugPrint ( "CheckSum needs to be calculated" )
656
659
endif
657
- DebugPrint ( "Checksum recalc:" + num2str ( checksumIsCalculated))
658
660
659
661
// start timer
660
662
Variable timer = timerStart ()
@@ -720,10 +722,19 @@ static Function saveResults(procedure)
720
722
endif
721
723
End
722
724
725
+ // Load the specified procedure from storage waves
726
+ //
727
+ // return errorCode
728
+ // 1 Load successfull
729
+ // 0 save state loaded with zero elements
730
+ // -1 Could not load save state
731
+ // -2 CheckSum missmatch. CheckSum has been calculated and was stored in
732
+ // global variable
723
733
static Function saveLoad ( procedure)
724
734
STRUCT procedure & procedure
725
735
726
736
Variable numResults
737
+ string CheckSum
727
738
728
739
Wave /T declWave = getDeclWave ()
729
740
Wave /I lineWave = getLineWave ()
@@ -732,72 +743,72 @@ static Function saveLoad(procedure)
732
743
Wave /T SaveStringsWave = getSaveStrings ()
733
744
Wave SaveVariablesWave = getSaveVariables ()
734
745
746
+ // if maximum storage capacity was reached (procedure.row == -1) or
747
+ // Element not found (procedure.row == endofWave) --> nothing loadable
735
748
if (( procedure. row < 0 ) || ( procedure. row == Dimsize ( SaveStringsWave, 0 )) || ( Dimsize ( SaveStringsWave, 0 ) == 0 ))
736
- // if maximum storage capacity was reached (procedure.row == -1) or Element not found (procedure.row == endofWave) there is nothing to load.
737
749
debugPrint ( "save state not found" )
738
750
return -1
739
- elseif ( SaveVariablesWave[ procedure. row][ 0 ] == 0 )
740
- // procedure marked as non valid by AfterRecompileHook
741
- // checksum needs to be compared.
751
+ endif
752
+ if ( isCompiled () && ! SaveVariablesWave[ procedure. row][ 0 ])
753
+ // procedure marked as not valid by
754
+ // AfterCompiledHook --> updatePanel --> saveReParse
755
+ // --> CheckSum needs to be compared.
742
756
743
- // getting checksum
744
- if ( setChecksum ( procedure) != 1 )
745
- debugPrint ( "error creating variable" )
757
+ if ( ! setChecksum ( procedure))
758
+ debugPrint ( "error creating CheckSum" )
746
759
return -1
747
760
endif
748
- // comparing checksum
749
- if ( cmpstr ( SaveStringsWave[ procedure. row][ 1 ] , getChecksum ()) != 0 )
750
- // checksum changed. return -2 to indicate that calculation was already done by setChecksum.
751
- debugPrint ( "Checksum missmatch: Procedure has to be reloaded." )
761
+ CheckSum = getCheckSum ()
762
+ if ( !! cmpstr ( SaveStringsWave[ procedure. row][ 1 ] , CheckSum))
763
+ debugPrint ( "CheckSum missmatch: Procedure has to be reloaded." )
752
764
return -2
753
- else
754
- //mark as valid
755
- debugPrint ( "Checksum match: Procedure marked valid." )
756
- SaveVariablesWave[ procedure. row][ 0 ] = 1
757
765
endif
766
+ debugPrint ( "CheckSum match: " + CheckSum)
767
+
768
+ SaveVariablesWave[ procedure. row][ 0 ] = 1
769
+ debugPrint ( "Procedure " + procedure. fullname + " marked as valid." )
758
770
endif
759
771
760
- // load results from free waves
761
772
numResults = Dimsize ( SaveWavesWave[ procedure. row][ 0 ] , 0 )
762
773
Redimension / N= ( numResults, -1 ) declWave, lineWave
763
- if ( numResults > 0 )
764
- WAVE /T load0 = SaveWavesWave[ procedure. row][ 0 ]
765
- WAVE /I load1 = SaveWavesWave[ procedure. row][ 1 ]
766
- declWave[][ 0 ] = load0 [ p][ 0 ]
767
- declWave[][ 1 ] = load0 [ p][ 1 ]
768
- lineWave[] = load1 [ p]
769
- debugPrint ( "save state loaded successfully" )
770
- return 1
771
- else
774
+ if ( numResults == 0 )
772
775
debugPrint ( "no elements in save state" )
773
776
return 0
774
777
endif
778
+
779
+ WAVE /T load0 = SaveWavesWave[ procedure. row][ 0 ]
780
+ WAVE /I load1 = SaveWavesWave[ procedure. row][ 1 ]
781
+ declWave[][ 0 ] = load0 [ p][ 0 ]
782
+ declWave[][ 1 ] = load0 [ p][ 1 ]
783
+ lineWave[] = load1 [ p]
784
+
785
+ debugPrint ( "save state loaded successfully" )
786
+ return 1
775
787
End
776
788
777
789
// Identifier = module#procedure
778
790
static Function getSaveRow ( Identifier)
779
791
String Identifier
780
792
781
793
Wave /T SaveStrings = getSaveStrings ()
782
- Variable found, endOfWave
794
+ Variable found, endOfWave, element
783
795
784
796
FindValue / TEXT= Identifier/ TXOP=4/ Z SaveStrings
785
- if ( V_value == -1 )
786
- // element not found
797
+ if ( V_Value == -1 )
798
+ debugPrint ( "Element not found" )
787
799
return Dimsize ( SaveStrings, 0 )
788
- else
789
- // element found at position V_value
790
-
791
- // check for inconsistency.
792
- if ( V_value > CsaveMaximum )
793
- DebugPrint ( "Storage capacity exceeded" )
794
- // should only happen if(CsaveMaximum) was touched on runtime.
795
- // Redimension/Deletion of Wave could be possible.
796
- return ( CsaveMaximum - 1 )
797
- endif
798
-
799
- return V_value
800
800
endif
801
+ element = V_Value
802
+
803
+ // check for inconsistency.
804
+ if ( element > CsaveMaximum )
805
+ debugPrint ( "Storage capacity exceeded" )
806
+ // should only happen if(CsaveMaximum) was touched on runtime.
807
+ // Redimension/Deletion of Wave could be possible.
808
+ return ( CsaveMaximum - 1 )
809
+ endif
810
+
811
+ return element
801
812
End
802
813
803
814
// drop first item at position 0. push all elements upward by 1 element. Free last Position.
@@ -1116,6 +1127,8 @@ End
1116
1127
1117
1128
static Function setParsingTime ( numTime)
1118
1129
Variable numTime
1130
+
1131
+ debugPrint ( "parsing time:" + num2str ( numTime))
1119
1132
return setGlobalVar ( "parsingTime" , numTime)
1120
1133
End
1121
1134
0 commit comments