15 public static partial class Examples
36 public static int IP_Assigner(gclib gclib,
string serial_num,
byte address)
38 bool controller_found =
false;
42 Console.WriteLine(
"Searching...");
45 requests = gclib.GIpRequests();
47 foreach (
string request
in requests)
49 Console.WriteLine(request);
52 }
while (requests.Count() < 1);
54 foreach (
string request
in requests)
56 string[] controller_params = request.Split(
new string[] {
", " }, StringSplitOptions.None);
61 if (controller_params.Count() < 5)
63 Console.WriteLine(
"Unexpected controller format");
67 string mac = controller_params[2];
68 string ip = controller_params[4];
71 if (serial_num == controller_params[1])
73 Console.WriteLine(
"Controller Match Found");
74 controller_found =
true;
77 string[] ip_bytes = ip.Split(
'.');
80 string new_ip = $
"{ip_bytes[0]}.{ip_bytes[1]}.{ip_bytes[2]}.{address}";
83 gclib.GAssign(new_ip, mac);
91 Console.WriteLine(
"IP Address assigned");
94 Console.WriteLine(gclib.GInfo());
100 if (!controller_found)
101 Console.Write(
"No controller matched the entered serial number");
const int GALIL_EXAMPLE_OK
Examples success code.
const int GALIL_EXAMPLE_ERROR
Examples error code.
static int IP_Assigner(gclib gclib, string serial_num, byte address)
Assigns controller an IP Adress given a serial number and a 1 byte address.