internal bool LoadTrainDatFile(string file) {
string[] lines = File.ReadAllLines(file, Encoding.UTF8);
for (int i = 0; i < lines.Length; i++) {
int semicolon = lines[i].IndexOf(';');
if (semicolon >= 0) {
lines[i] = lines[i].Substring(0, semicolon).Trim();
} else {
lines[i] = lines[i].Trim();
}
}
for (int i = 0; i < lines.Length; i++) {
if (lines[i].Equals("#DEVICE", StringComparison.OrdinalIgnoreCase)) {
if (i < lines.Length - 1) {
int value = int.Parse(lines[i + 1], NumberStyles.Integer, CultureInfo.InvariantCulture);
if (value == 0) {
this.AtsSx = new AtsSx(this);
} else if (value == 1) {
this.AtsSx = new AtsSx(this);
this.AtsP = new AtsP(this);
}
}
if (i < lines.Length - 2) {
int value = int.Parse(lines[i + 2], NumberStyles.Integer, CultureInfo.InvariantCulture);
if (value == 1) {
this.Atc = new Atc(this, false);
} else if (value == 2) {
this.Atc = new Atc(this, true);
}
}
if (i < lines.Length - 3) {
int value = int.Parse(lines[i + 3], NumberStyles.Integer, CultureInfo.InvariantCulture);
if (value == 1) {
this.Eb = new Eb(this);
}
}
}
}
// --- devices ---
List<Device> devices = new List<Device>();
if (this.Eb != null) {
devices.Add(this.Eb);
}
if (this.Atc != null) {
devices.Add(this.Atc);
}
if (this.AtsP != null) {
devices.Add(this.AtsP);
}
if (this.AtsSx != null) {
devices.Add(this.AtsSx);
}
this.Devices = devices.ToArray();
return true;
}