更新
This commit is contained in:
@@ -643,22 +643,15 @@ namespace TabletTester2025.ViewModels
|
||||
if (startTime == DateTime.MinValue)
|
||||
return false;
|
||||
|
||||
double minutes = (DateTime.Now - startTime).TotalMinutes;
|
||||
if (channel == 1)
|
||||
{
|
||||
Dissolution1Percent = value;
|
||||
DissolutionPercent = value;
|
||||
AddDissolutionPoint(_dissolution1Times, _dissolution1Values, _dissolution1Series, minutes, value);
|
||||
Dissolution1RSquared = CalculateRSquared(_dissolution1Times, _dissolution1Values);
|
||||
DissolutionRSquared = Dissolution1RSquared;
|
||||
}
|
||||
else
|
||||
{
|
||||
Dissolution2Percent = value;
|
||||
DissolutionPercent = value;
|
||||
AddDissolutionPoint(_dissolution2Times, _dissolution2Values, _dissolution2Series, minutes, value);
|
||||
Dissolution2RSquared = CalculateRSquared(_dissolution2Times, _dissolution2Values);
|
||||
DissolutionRSquared = Dissolution2RSquared;
|
||||
}
|
||||
|
||||
DissolutionCurveStatus = "";
|
||||
@@ -677,30 +670,11 @@ namespace TabletTester2025.ViewModels
|
||||
return double.IsFinite(value) && value >= 0 && value <= 150;
|
||||
}
|
||||
|
||||
private static void AddDissolutionPoint(List<double> times, List<double> values, LineSeries series, double minutes, double value)
|
||||
{
|
||||
if (times.Count > 0 && minutes <= times[^1])
|
||||
return;
|
||||
|
||||
times.Add(minutes);
|
||||
values.Add(value);
|
||||
series.Points.Add(new DataPoint(minutes, value));
|
||||
}
|
||||
|
||||
private void CreateDissolutionSampleSchedule(int channel)
|
||||
{
|
||||
RemoveDissolutionSamples(channel);
|
||||
|
||||
var sampleTimes = App.CurrentPharmaParams.DissolutionSampleTimes?
|
||||
.Where(t => t > 0)
|
||||
.Distinct()
|
||||
.OrderBy(t => t)
|
||||
.ToArray();
|
||||
|
||||
if (sampleTimes == null || sampleTimes.Length == 0)
|
||||
sampleTimes = new[] { 5, 10, 15, 30, 45, 60 };
|
||||
|
||||
foreach (int minute in sampleTimes)
|
||||
foreach (double minute in ResolveDissolutionSampleTimes(channel))
|
||||
{
|
||||
DissolutionSamplePoints.Add(new DissolutionSamplePoint
|
||||
{
|
||||
@@ -710,6 +684,48 @@ namespace TabletTester2025.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private List<double> ResolveDissolutionSampleTimes(int channel)
|
||||
{
|
||||
int durationMin = channel == 1 ? Dissolution1TimeMin : Dissolution2TimeMin;
|
||||
double intervalMin = channel == 1 ? Dissolution1SampleIntervalMin : Dissolution2SampleIntervalMin;
|
||||
durationMin = Math.Max(1, durationMin);
|
||||
|
||||
var configuredTimes = App.CurrentPharmaParams.DissolutionSampleTimes?
|
||||
.Where(t => t > 0)
|
||||
.Select(t => (double)t)
|
||||
.ToList();
|
||||
|
||||
var times = configuredTimes != null && configuredTimes.Count > 0
|
||||
? configuredTimes
|
||||
: GenerateIntervalSampleTimes(durationMin, intervalMin);
|
||||
|
||||
times.Add(Math.Min(30, durationMin));
|
||||
if (durationMin >= 30)
|
||||
times.Add(30);
|
||||
times.Add(durationMin);
|
||||
|
||||
return times
|
||||
.Where(t => t > 0 && t <= durationMin)
|
||||
.Distinct()
|
||||
.OrderBy(t => t)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
private static List<double> GenerateIntervalSampleTimes(int durationMin, double intervalMin)
|
||||
{
|
||||
if (!double.IsFinite(intervalMin) || intervalMin <= 0)
|
||||
intervalMin = 5;
|
||||
|
||||
var times = new List<double>();
|
||||
for (double time = intervalMin; time <= durationMin + 0.0001; time += intervalMin)
|
||||
times.Add(Math.Min(time, durationMin));
|
||||
|
||||
if (times.Count == 0 || Math.Abs(times[^1] - durationMin) > 0.0001)
|
||||
times.Add(durationMin);
|
||||
|
||||
return times;
|
||||
}
|
||||
|
||||
private void RemoveDissolutionSamples(int channel)
|
||||
{
|
||||
for (int i = DissolutionSamplePoints.Count - 1; i >= 0; i--)
|
||||
@@ -1576,6 +1592,7 @@ namespace TabletTester2025.ViewModels
|
||||
|
||||
private async Task FinalizeDissolutionChannelAsync(int channel)
|
||||
{
|
||||
RefreshDissolutionSeries(channel);
|
||||
var times = channel == 1 ? _dissolution1Times : _dissolution2Times;
|
||||
var values = channel == 1 ? _dissolution1Values : _dissolution2Values;
|
||||
if (values.Count == 0)
|
||||
|
||||
@@ -502,7 +502,7 @@
|
||||
GridLinesVisibility="Horizontal">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="通道" Binding="{Binding ChannelName}" Width="90"/>
|
||||
<DataGridTextColumn Header="计划时间(min)" Binding="{Binding ScheduledTimeMin, StringFormat=F0}" Width="120"/>
|
||||
<DataGridTextColumn Header="计划时间(min)" Binding="{Binding ScheduledTimeMin, StringFormat=F1}" Width="120"/>
|
||||
<DataGridTextColumn Header="实际时间(min)" Binding="{Binding ActualTimeMin, StringFormat=F2}" Width="120"/>
|
||||
<DataGridTextColumn Header="溶出度(%)" Binding="{Binding Percent, StringFormat=F2}" Width="120"/>
|
||||
<DataGridTextColumn Header="记录时间" Binding="{Binding RecordedAt, StringFormat=HH:mm:ss}" Width="110"/>
|
||||
|
||||
Reference in New Issue
Block a user