@@ -13,7 +13,7 @@ partial class SmartScope
1313 const double AWG_SAMPLE_PERIOD_0 = 10e-9 ; //10ns
1414 const int AWG_SAMPLES_MAX = 2048 ;
1515 const int AWG_SAMPLES_MIN = 1 ;
16- const UInt32 AWG_STRETCHER_MAX = UInt32 . MaxValue ;
16+ const Int32 AWG_STRETCHER_MAX = 256 * 256 * 256 - 1 ;
1717 public bool DataOutOfRange { get ; private set ; }
1818
1919 /// <summary>
@@ -83,7 +83,7 @@ public int GeneratorNumberOfSamples
8383 }
8484 }
8585
86- public UInt32 GeneratorStretching
86+ public Int32 GeneratorStretching
8787 {
8888 set
8989 {
@@ -94,15 +94,13 @@ public UInt32 GeneratorStretching
9494 FpgaSettingsMemory [ REG . GENERATOR_DECIMATION_B0 ] . Set ( ( byte ) ( value & 0xFF ) ) ;
9595 FpgaSettingsMemory [ REG . GENERATOR_DECIMATION_B1 ] . Set ( ( byte ) ( ( value >> 8 ) & 0xFF ) ) ;
9696 FpgaSettingsMemory [ REG . GENERATOR_DECIMATION_B2 ] . Set ( ( byte ) ( ( value >> 16 ) & 0xFF ) ) ;
97- FpgaSettingsMemory [ REG . GENERATOR_DECIMATION_B3 ] . Set ( ( byte ) ( ( value >> 24 ) & 0xFF ) ) ;
9897 }
9998 get
10099 {
101100 return
102- ( UInt32 ) ( FpgaSettingsMemory [ REG . GENERATOR_DECIMATION_B0 ] . GetByte ( ) ) +
103- ( UInt32 ) ( FpgaSettingsMemory [ REG . GENERATOR_DECIMATION_B1 ] . GetByte ( ) << 8 ) +
104- ( UInt32 ) ( FpgaSettingsMemory [ REG . GENERATOR_DECIMATION_B2 ] . GetByte ( ) << 16 ) +
105- ( UInt32 ) ( FpgaSettingsMemory [ REG . GENERATOR_DECIMATION_B3 ] . GetByte ( ) << 24 ) ;
101+ ( Int32 ) ( FpgaSettingsMemory [ REG . GENERATOR_DECIMATION_B0 ] . GetByte ( ) ) +
102+ ( Int32 ) ( FpgaSettingsMemory [ REG . GENERATOR_DECIMATION_B1 ] . GetByte ( ) << 8 ) +
103+ ( Int32 ) ( FpgaSettingsMemory [ REG . GENERATOR_DECIMATION_B2 ] . GetByte ( ) << 16 ) ;
106104 }
107105 }
108106
@@ -150,21 +148,21 @@ public double GeneratorFrequencyMin
150148 return 1.0 / ( ( AWG_SAMPLES_MAX - 1 ) * AWG_SAMPLE_PERIOD_0 * ( ( double ) ( AWG_STRETCHER_MAX ) + 1 ) ) ;
151149 }
152150 }
153- public UInt32 GeneratorStretcherForFrequency ( double frequency )
151+ public Int32 GeneratorStretcherForFrequency ( double frequency )
154152 {
155153 if ( frequency > GeneratorFrequencyMax || frequency < GeneratorFrequencyMin )
156154 throw new ValidationException ( String . Format ( "AWG frequency {0} out of range [{1},{2}]" , frequency , GeneratorFrequencyMin , GeneratorFrequencyMax ) ) ;
157155
158156 double numberOfSamplesAtFullRate = Math . Floor ( 1 / ( AWG_SAMPLE_PERIOD_0 * frequency ) ) ;
159- return ( UInt32 ) Math . Floor ( numberOfSamplesAtFullRate / AWG_SAMPLES_MAX ) ; ;
157+ return ( Int32 ) Math . Floor ( numberOfSamplesAtFullRate / AWG_SAMPLES_MAX ) ; ;
160158 }
161159 public int GeneratorNumberOfSamplesForFrequency ( double frequency )
162160 {
163161 if ( frequency > GeneratorFrequencyMax || frequency < GeneratorFrequencyMin )
164162 throw new ValidationException ( String . Format ( "AWG frequency {0} out of range [{1},{2}]" , frequency , GeneratorFrequencyMin , GeneratorFrequencyMax ) ) ;
165163
166164 double numberOfSamplesAtFullRate = Math . Floor ( 1 / ( AWG_SAMPLE_PERIOD_0 * frequency ) ) ;
167- UInt32 stretcher = GeneratorStretcherForFrequency ( frequency ) ;
165+ Int32 stretcher = GeneratorStretcherForFrequency ( frequency ) ;
168166 return ( int ) Math . Floor ( numberOfSamplesAtFullRate / ( stretcher + 1 ) ) ;
169167 }
170168 public double GeneratorFrequency
@@ -186,7 +184,7 @@ public double GeneratorSamplePeriod
186184 {
187185 set {
188186 double samples = value / AWG_SAMPLE_PERIOD_0 ;
189- UInt32 samplesRounded = ( UInt32 ) Math . Floor ( samples ) ;
187+ Int32 samplesRounded = ( Int32 ) Math . Floor ( samples ) ;
190188 GeneratorStretching = samplesRounded ;
191189 }
192190 get {
0 commit comments