-
Notifications
You must be signed in to change notification settings - Fork 1
/
ETCS_LEVEL.cs
74 lines (73 loc) · 2.29 KB
/
ETCS_LEVEL.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using Orts.Simulation.Signalling;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ORTS.Scripting.Script
{
public class ETCS_LEVEL : CsSignalScript
{
public override void Initialize()
{
SetLevels();
}
public void SetLevels()
{
var levels = new List<string>();
var levelNames = new List<string>{"N0", "N1", "N2", "ASFA", "LZB", "EBICAB"};
var levelPriorities = new List<string>{"N2", "N1", "LZB", "EBICAB", "ASFA", "N0"};
for (int i=levelNames.Count-1; i>=0; i--)
{
if (HasHead(i+1)) levels.Add(levelNames[i]);
}
switch (SignalTypeName.ToLowerInvariant())
{
case "etcs_level0":
levels.Add("N0");
levels.Add("ASFA");
break;
case "etcs_level1":
levels.Add("N0");
levels.Add("ASFA");
levels.Add("N1");
break;
}
var orderedLevels = levels.OrderBy(x => levelPriorities.IndexOf(x)).ToList();
for (int i=0; i<orderedLevels.Count; i++)
{
int num = 0;
switch (orderedLevels[i])
{
case "N0":
num = 1;
break;
case "N1":
num = 2;
break;
case "N2":
num = 3;
break;
case "N3":
num = 4;
break;
case "ASFA":
num = 5;
break;
case "LZB":
num = 15;
break;
case "EBICAB":
num = 24;
break;
}
SharedVariables[602+i] = num;
}
SharedVariables[602+orderedLevels.Count] = 0;
}
public override void Update()
{
SharedVariables[601] = RouteSet ? NextSignalId("NORMAL") : -1;
}
}
}