Skip to content

Commit

Permalink
Fix. Thread-safe operations.
Browse files Browse the repository at this point in the history
  • Loading branch information
Am6er committed Jun 11, 2024
1 parent 0a9103c commit 7ec2f8b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
4 changes: 2 additions & 2 deletions BecquerelMonitor/BecquerelMonitor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
<MinimumRequiredVersion>2022.07.08.7</MinimumRequiredVersion>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>index.html</WebPage>
<ApplicationRevision>3</ApplicationRevision>
<ApplicationVersion>2024.06.07.3</ApplicationVersion>
<ApplicationRevision>1</ApplicationRevision>
<ApplicationVersion>2024.06.11.1</ApplicationVersion>
<UseApplicationTrust>true</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
Expand Down
4 changes: 2 additions & 2 deletions BecquerelMonitor/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

[assembly: AssemblyVersion("2024.06.07.3")]
[assembly: AssemblyVersion("2024.06.11.1")]
[assembly: AssemblyProduct("BecquerelMonitor")]
[assembly: AssemblyCopyright("free")]
[assembly: AssemblyTrademark("none")]
[assembly: AssemblyConfiguration("")]
[assembly: Guid("40110b38-4882-47c1-ad94-a71e58dcb5f8")]
[assembly: AssemblyFileVersion("2024.06.07.3")]
[assembly: AssemblyFileVersion("2024.06.11.1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyCompany("free")]
[assembly: CompilationRelaxations(8)]
Expand Down
7 changes: 2 additions & 5 deletions BecquerelMonitor/RadiaCodeIn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -648,11 +648,8 @@ public void run()
sendTroubleShoot($"Spectrum real time: {packet.TIME_S}");
sendTroubleShoot($"Spectrum calibration: A0={packet.A0} A1={packet.A1} A2={packet.A2}");
packet.SPECTRUM.CopyTo(hystogram_buffered, 0);
ulong sum = 0;
Parallel.For(0, hystogram_buffered.Length, i =>
{
sum += (ulong)hystogram_buffered[i];
});
ulong sum = (ulong)hystogram_buffered.Sum();

if (packet.TIME_S != 0) this.cps = sum / packet.TIME_S;
sendTroubleShoot($"Spectrum cps: {this.cps}");
sendTroubleShoot($"Spectrum total counts: {sum}");
Expand Down
4 changes: 2 additions & 2 deletions BecquerelMonitor/Utils/SpectrumAriphmetics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ public EnergySpectrum Substract(EnergySpectrum bgenergySpectrum)
{
substractedEnergySpectrum.Spectrum[i] = 0;
}
substractedEnergySpectrum.TotalPulseCount += substractedEnergySpectrum.Spectrum[i];
});
substractedEnergySpectrum.TotalPulseCount = substractedEnergySpectrum.Spectrum.Sum();
substractedEnergySpectrum.ValidPulseCount = substractedEnergySpectrum.TotalPulseCount;
} else
{
Expand All @@ -170,8 +170,8 @@ public EnergySpectrum Substract(EnergySpectrum bgenergySpectrum)
substractedEnergySpectrum.Spectrum[i] = 0;
}
}
substractedEnergySpectrum.TotalPulseCount += substractedEnergySpectrum.Spectrum[i];
});
substractedEnergySpectrum.TotalPulseCount = substractedEnergySpectrum.Spectrum.Sum();
substractedEnergySpectrum.ValidPulseCount = substractedEnergySpectrum.TotalPulseCount;
}
return substractedEnergySpectrum;
Expand Down

0 comments on commit 7ec2f8b

Please sign in to comment.