-
Notifications
You must be signed in to change notification settings - Fork 4
/
TGMT.cs
61 lines (50 loc) · 1.84 KB
/
TGMT.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
using AtsEx.Extensions.MapStatements;
using AtsEx.PluginHost;
using AtsEx.PluginHost.Plugins;
using AtsEx.PluginHost.Plugins.Extensions;
using BveTypes.ClassWrappers;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using TGMT_CBTC.HMI;
using TGMT_CBTC.OBCU;
namespace TGMT_CBTC {
[Plugin(PluginType.Extension)]
public class TGMT : AssemblyPluginBase, IExtension {
private Scenario Scenario { get; set; }
public OBCU.OBCU OBCU { get; private set; }
private HMIWindow hmiWindow = new HMIWindow();
private KeyHandler keyHandler = new KeyHandler();
public TGMT(PluginBuilder builder) : base(builder) {
BveHacker.ScenarioCreated += OnScenarioCreated;
TGMTPainter.Initialize();
hmiWindow.Show();
keyHandler.Init(BveHacker);
keyHandler.AtoStartPressed += OnAtoStartPressed;
}
private void OnScenarioCreated(ScenarioCreatedEventArgs e) {
Scenario = e.Scenario;
OBCU = new OBCU.OBCU(Scenario);
}
TimeSpan paintTimeDelay = TimeSpan.FromMilliseconds(1000);
public override TickResult Tick(TimeSpan elapsed) {
OBCU.Tick(elapsed, Scenario);
paintTimeDelay += elapsed;
if (paintTimeDelay >= TimeSpan.FromMilliseconds(1000 / 8)) {
Bitmap hmiBitmap = TGMTPainter.PaintHMI(OBCU).Bitmap;
hmiWindow.DrawBitmap(hmiBitmap);
paintTimeDelay = TimeSpan.Zero;
}
return new ExtensionTickResult();
}
private void OnAtoStartPressed(object sender, EventArgs e) {
OBCU.OnAtoStartPressed(Scenario);
}
public override void Dispose() {
TGMTPainter.Dispose();
hmiWindow.Dispose();
}
}
}