-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLokBeispiel.cs
76 lines (51 loc) · 2.3 KB
/
LokBeispiel.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
75
76
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
namespace TCPEcos
{
internal static class LokBeispiel
{
internal static async void StartAsync(int lokNummer, TcpClient client)
{
Console.WriteLine("Zug 335 abfahren!");
StreamWriter tcpwriter = new StreamWriter(client.GetStream());
await tcpwriter.WriteAsync("queryObjects(10, name, addr, protocol)");
await tcpwriter.FlushAsync();
await tcpwriter.WriteAsync($"request({lokNummer}, control, force)");
await tcpwriter.FlushAsync();
await tcpwriter.WriteAsync($"set({lokNummer}, func[0, 1]) \nset({lokNummer}, func[1, 1]) \nset({lokNummer}, func[11,1])" +
$"\nset({lokNummer}, func[10,1]) \nset({lokNummer}, func[27,0])");
await tcpwriter.FlushAsync();
Thread.Sleep(5000);
await tcpwriter.WriteAsync($"set({lokNummer}, speed[127])");
await tcpwriter.FlushAsync();
Thread.Sleep(40000);
await tcpwriter.WriteAsync($"set({lokNummer}, speed[100])");
await tcpwriter.FlushAsync();
Thread.Sleep(5000);
await tcpwriter.WriteAsync($"set({lokNummer}, speed[80])");
await tcpwriter.FlushAsync();
Thread.Sleep(5000);
await tcpwriter.WriteAsync($"set({lokNummer}, speed[60])");
await tcpwriter.FlushAsync();
Thread.Sleep(5000);
await tcpwriter.WriteAsync($"set({lokNummer}, speed[40])");
await tcpwriter.FlushAsync();
Thread.Sleep(5000);
await tcpwriter.WriteAsync($"set({lokNummer}, speed[20])");
await tcpwriter.FlushAsync();
Thread.Sleep(5000);
await tcpwriter.WriteAsync($"set({lokNummer}, speed[0])");
await tcpwriter.FlushAsync();
Thread.Sleep(10000);
await tcpwriter.WriteAsync($"set({lokNummer}, func[1, 0]) \nset({lokNummer}, func[0, 0]) \nset({lokNummer}, func[11,0])" +
$"\nset({lokNummer}, func[10,0]) \nset({lokNummer}, func[27,1])");
await tcpwriter.FlushAsync();
tcpwriter.Close();
client.Close();
}
}
}