Migrate to .NET8 GenCycleVDP
Migrate generator to .NET8
This commit is contained in:
20
GenCycleVDP/Resources/CycleStatus.cs
Normal file
20
GenCycleVDP/Resources/CycleStatus.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
namespace GenCycleVDP.Resources
|
||||
{
|
||||
public enum CycleStatus : ushort
|
||||
{
|
||||
EndTechCycle = 0,
|
||||
LoadUnload = 1,
|
||||
VacForWelding = 2,
|
||||
Welding = 5,
|
||||
CoolingWelding = 6,
|
||||
CheckWelding = 7,
|
||||
VacForMelting = 8,
|
||||
DilutionVat = 9,
|
||||
Melting = 10,
|
||||
BringShrinkageCavity = 11,
|
||||
CoolingIngot = 12,
|
||||
VacForMeltingScarp = 14,
|
||||
MeltingScarp = 15,
|
||||
CoolingMeltingScarp = 16
|
||||
}
|
||||
}
|
131
GenCycleVDP/Resources/GenData.cs
Normal file
131
GenCycleVDP/Resources/GenData.cs
Normal file
@@ -0,0 +1,131 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user