APICycleVDP/GenCycleVDP/Resources/GenData.cs
2024-09-19 13:26:06 +03:00

132 lines
3.8 KiB
C#

using System;
using System.Collections.Generic;
namespace GenCycleVDP.Resources
{
internal static class GenData
{
private static readonly Random random = new();
private static readonly Dictionary<CycleStatus, (Func<CycleStatus> NextState, int Duration, (int min, int offset))> genDataMap = new()
{
{
CycleStatus.EndTechCycle,
(() => random.Next(100) < 50
? CycleStatus.VacForMeltingScarp
: CycleStatus.VacForWelding,
15,
(7 * 60, 5 * 60))
},
{
CycleStatus.LoadUnload,
(() => CycleStatus.VacForWelding,
15,
(3 * 60, 2 * 60))
},
{
CycleStatus.VacForWelding,
(() => CycleStatus.Welding,
10,
(11 * 60, 1 * 60))
},
{
CycleStatus.Welding,
(() => CycleStatus.CoolingWelding,
13,
(4 * 60, 3 * 60))
},
{
CycleStatus.CoolingWelding,
(() => CycleStatus.CheckWelding,
7,
(4 * 60, 3 * 60))
},
{
CycleStatus.CheckWelding,
(() => random.Next(100) < 20
? CycleStatus.Welding
: CycleStatus.VacForMelting,
5,
(7 * 60, 2 * 60))
},
{
CycleStatus.VacForMelting,
(() => CycleStatus.DilutionVat,
10,
(11 * 60, 1 * 60))
},
{
CycleStatus.DilutionVat,
(() => CycleStatus.Melting,
5,
(2 * 60, 1 * 60))
},
{
CycleStatus.Melting,
(() => CycleStatus.BringShrinkageCavity,
60,
(40 * 60, 30 * 60))
},
{
CycleStatus.BringShrinkageCavity,
(() => CycleStatus.CoolingIngot,
15,
(5 * 60, 3 * 60))
},
{
CycleStatus.CoolingIngot,
(() => CycleStatus.EndTechCycle,
30,
(20 * 60, 10 * 60))
},
{
CycleStatus.VacForMeltingScarp,
(() => CycleStatus.MeltingScarp,
10,
(11 * 60, 1 * 60))
},
{
CycleStatus.MeltingScarp,
(() => CycleStatus.CoolingMeltingScarp,
20,
(4 * 60, 3 * 60))
},
{
CycleStatus.CoolingMeltingScarp,
(() => CycleStatus.LoadUnload,
15,
(4 * 60, 3 * 60))
},
};
public static CycleStatus GetNextCycle(CycleStatus currCycle)
{
CycleStatus nextCycle = CycleStatus.EndTechCycle;
if(genDataMap.TryGetValue(currCycle, out var data))
{
nextCycle = data.NextState();
}
return nextCycle;
}
public static int GetDuration(CycleStatus currCycle)
{
int duration = 15;
if (genDataMap.TryGetValue(currCycle, out var data))
{
duration = data.Duration;
}
return duration;
}
public static int GetDeviation(CycleStatus currCycle)
{
int deviation = random.Next(7 * 60) - (5 * 60);
if (genDataMap.TryGetValue(currCycle, out var data))
{
deviation = random.Next(data.Item3.min) - data.Item3.offset;
}
return deviation;
}
}
}