Skip to content

Commit 03c21aa

Browse files
Formating all .cs files removing tabs
1 parent 6a0c9ee commit 03c21aa

File tree

26 files changed

+1618
-1618
lines changed

26 files changed

+1618
-1618
lines changed

examples/cs101-master-tcp/Program.cs

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -8,91 +8,91 @@
88

99
namespace cs101_master_tcp
1010
{
11-
class MainClass
12-
{
11+
class MainClass
12+
{
1313

14-
private static bool rcvdRawMessageHandler (object parameter, byte[] message, int messageSize)
15-
{
16-
Console.WriteLine ("RECV " + BitConverter.ToString (message, 0, messageSize));
14+
private static bool rcvdRawMessageHandler (object parameter, byte[] message, int messageSize)
15+
{
16+
Console.WriteLine ("RECV " + BitConverter.ToString (message, 0, messageSize));
1717

18-
return true;
19-
}
18+
return true;
19+
}
2020

21-
private static void linkLayerStateChanged (object parameter, int address, lib60870.linklayer.LinkLayerState newState)
22-
{
23-
Console.WriteLine ("LL state event: " + newState.ToString ());
24-
}
21+
private static void linkLayerStateChanged (object parameter, int address, lib60870.linklayer.LinkLayerState newState)
22+
{
23+
Console.WriteLine ("LL state event: " + newState.ToString ());
24+
}
2525

26-
private static bool asduReceivedHandler(object parameter, int address, ASDU asdu)
27-
{
28-
Console.WriteLine (asdu.ToString ());
26+
private static bool asduReceivedHandler(object parameter, int address, ASDU asdu)
27+
{
28+
Console.WriteLine (asdu.ToString ());
2929

30-
return true;
31-
}
30+
return true;
31+
}
3232

3333

34-
public static void Main (string[] args)
35-
{
36-
bool running = true;
34+
public static void Main (string[] args)
35+
{
36+
bool running = true;
3737

38-
// use Ctrl-C to stop the programm
39-
Console.CancelKeyPress += delegate(object? sender, ConsoleCancelEventArgs e) {
40-
e.Cancel = true;
41-
running = false;
42-
};
38+
// use Ctrl-C to stop the programm
39+
Console.CancelKeyPress += delegate(object? sender, ConsoleCancelEventArgs e) {
40+
e.Cancel = true;
41+
running = false;
42+
};
4343

44-
string hostname = "127.0.0.1";
45-
int tcpPort = 2404;
44+
string hostname = "127.0.0.1";
45+
int tcpPort = 2404;
4646

47-
if (args.Length > 0)
48-
hostname = args [0];
47+
if (args.Length > 0)
48+
hostname = args [0];
4949

50-
if (args.Length > 1)
51-
int.TryParse (args [1], out tcpPort);
50+
if (args.Length > 1)
51+
int.TryParse (args [1], out tcpPort);
5252

53-
// Setup virtual serial port
54-
TcpClientVirtualSerialPort port = new TcpClientVirtualSerialPort(hostname, tcpPort);
55-
port.DebugOutput = false;
56-
port.Start ();
53+
// Setup virtual serial port
54+
TcpClientVirtualSerialPort port = new TcpClientVirtualSerialPort(hostname, tcpPort);
55+
port.DebugOutput = false;
56+
port.Start ();
5757

58-
// Setup balanced CS101 master
59-
LinkLayerParameters llParameters = new LinkLayerParameters();
60-
llParameters.AddressLength = 1;
61-
llParameters.UseSingleCharACK = true;
58+
// Setup balanced CS101 master
59+
LinkLayerParameters llParameters = new LinkLayerParameters();
60+
llParameters.AddressLength = 1;
61+
llParameters.UseSingleCharACK = true;
6262

63-
CS101Master master = new CS101Master (port, LinkLayerMode.BALANCED, llParameters);
64-
master.DebugOutput = false;
65-
master.OwnAddress = 1;
63+
CS101Master master = new CS101Master (port, LinkLayerMode.BALANCED, llParameters);
64+
master.DebugOutput = false;
65+
master.OwnAddress = 1;
6666
master.SlaveAddress = 3;
67-
master.SetASDUReceivedHandler (asduReceivedHandler, null);
68-
master.SetLinkLayerStateChangedHandler (linkLayerStateChanged, null);
69-
master.SetReceivedRawMessageHandler (rcvdRawMessageHandler, null);
67+
master.SetASDUReceivedHandler (asduReceivedHandler, null);
68+
master.SetLinkLayerStateChangedHandler (linkLayerStateChanged, null);
69+
master.SetReceivedRawMessageHandler (rcvdRawMessageHandler, null);
7070

71-
long lastTimestamp = SystemUtils.currentTimeMillis ();
71+
long lastTimestamp = SystemUtils.currentTimeMillis ();
7272

73-
// This will start a separate thread!
74-
// alternativley you can you master.Run() inside the loop
75-
master.Start ();
73+
// This will start a separate thread!
74+
// alternativley you can you master.Run() inside the loop
75+
master.Start ();
7676

77-
while (running) {
77+
while (running) {
7878

79-
if ((SystemUtils.currentTimeMillis() - lastTimestamp) >= 5000) {
79+
if ((SystemUtils.currentTimeMillis() - lastTimestamp) >= 5000) {
8080

81-
lastTimestamp = SystemUtils.currentTimeMillis ();
81+
lastTimestamp = SystemUtils.currentTimeMillis ();
8282

83-
if (master.GetLinkLayerState () == lib60870.linklayer.LinkLayerState.AVAILABLE) {
84-
master.SendInterrogationCommand (CauseOfTransmission.ACTIVATION, 1, 20);
85-
} else {
86-
Console.WriteLine ("Link layer: " + master.GetLinkLayerState ().ToString ());
87-
}
88-
}
83+
if (master.GetLinkLayerState () == lib60870.linklayer.LinkLayerState.AVAILABLE) {
84+
master.SendInterrogationCommand (CauseOfTransmission.ACTIVATION, 1, 20);
85+
} else {
86+
Console.WriteLine ("Link layer: " + master.GetLinkLayerState ().ToString ());
87+
}
88+
}
8989

90-
Thread.Sleep (100);
91-
}
90+
Thread.Sleep (100);
91+
}
9292

93-
master.Stop ();
93+
master.Stop ();
9494

95-
port.Stop ();
96-
}
97-
}
95+
port.Stop ();
96+
}
97+
}
9898
}

0 commit comments

Comments
 (0)