static void Main(string[] args) { #if DEBUG args = new string[1]; args[0] = "cableCloud.json"; #endif try { CableCloud cableCloud = new CableCloud(args[0]); } catch (Exception e) { Console.WriteLine(e); } finally { while (true) { Console.ReadLine(); } } }
private static void PrintSendInformation(OutSocket outputSocket, int destinationPort) { string timeStamp = CableCloud.GetTimeStamp(); Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(timeStamp + " | Sent to node " + outputSocket.getNodeName() + " to port " + destinationPort.ToString() + Environment.NewLine); }
static void Main(string[] args) { Console.WriteLine(); // Invoke this sample with an arbitrary set of command line arguments. string[] arguments = Environment.GetCommandLineArgs(); CableCloud cableCloud = new CableCloud(); cableCloud.LoadConfig(arguments[1]); Thread reading = new Thread(cableCloud.ReadCommandLines); Thread thread = new Thread(cableCloud.StartServer); thread.Start(); reading.Start(); }
static void Main(string[] args) { Console.BackgroundColor = ConsoleColor.Yellow; Console.ForegroundColor = ConsoleColor.Black; Console.Clear(); CableCloud cloud = new CableCloud(); char key = 'a'; do { key = Console.ReadKey().KeyChar; }while (key == 'c'); cloud.targetNetworkObjects.FindAll(x => x.TargetSocket != null).All(x => { x.TargetSocket.Disconnect(false); return(true); }); }
public Form1(string filePath) { InitializeComponent(); Cloud = new CableCloud(filePath); CableViewer.Items.AddRange(Cloud.fields.fieldStrings().ToArray()); for (int i = 0; i < Cloud.fields.forwarding.Count; i++) { if (Cloud.fields.forwarding[i].enable) { CableViewer.SetItemChecked(i, true); } } CableViewer.CheckOnClick = true; }
public Form1(string filePath, string structurePath) { InitializeComponent(); Cloud = new CableCloud(filePath, structurePath); CableViewer.Items.AddRange(Cloud.GetFieldStrings()); for (int i = 0; i < Cloud.CountFields(); i++) { if (Cloud.isFieldActive(i)) { CableViewer.SetItemChecked(i, true); } } CableViewer.CheckOnClick = true; CableViewer.SelectedIndexChanged += new System.EventHandler(CableViewer_SelectedIndexChanged); }
/// <summary> /// Main /// </summary> /// <param name="args">Nieużywane</param> static void Main(string[] args) { CableCloud cc = new CableCloud(); cc.Listen(); cc.SetPortTable(cc.receivedData); cc.PrintPortTable(); cc.SendData("127.0.0.30", 10000, "potwierdzam"); while (true) { //TODO: sprawdzać w tablicy dokąd wysłać dalej i zrobić tam senddata cc.Listen(); } }
public void ListenForIncomingData() { byte[] bytes; while (true) { bytes = new byte[4]; int inputSize = ReceiveInputSize(); byte[] receivedData = receiveData(inputSize); int sourcePort = GetSourcePort(receivedData); string timeStamp = CableCloud.GetTimeStamp(); Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.Magenta; Console.WriteLine(timeStamp + " | Recieved from node " + nodeName + " from port " + sourcePort.ToString()); SendingManager.Send(receivedData, nodeName, sourcePort); } }
public CableCloudGUI() { // display exceptions in english Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; InitializeComponent(); logTextBox.Document.Blocks.Remove(logTextBox.Document.Blocks.FirstBlock); var args = Environment.GetCommandLineArgs(); if (args.Length != 2) { MessageBox.Show("Wrong number of arguments!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); Environment.Exit(1); } var filePath = args[1]; cableCloud = new CableCloud(filePath); cableCloud.window = this; connectedPairs = new List <CableBetweenPairOfNodes>(); foreach (var cable in cableCloud.Config.StatusOfCableBetweenNodes) { // e.g. H1:1111-R2:2222, WORKING var node1 = cable.Key.Split(':')[0]; var port1 = cable.Key.Split('-')[0].Split(':')[1]; var node2 = cable.Key.Split(':')[1].Split('-')[1]; var port2 = cable.Key.Split(':')[2]; var status = cable.Value; connectedPairs.Add(new CableBetweenPairOfNodes(node1, port1, node2, port2, status)); } connectedPairs.Sort((x, y) => { int compare = x.Node1.CompareTo(y.Node1); if (compare != 0) { return(compare); } return(x.Node2.CompareTo(y.Node2)); }); tableOfCables.ItemsSource = connectedPairs; }
public static void LoadCableCloudConfig(CableCloud cableCloud, String filename) { var jsonFile = File.ReadAllText(filename); CableCloudModel cableCloudModel = JsonSerializer.Deserialize <CableCloudModel>(jsonFile); cableCloud.CableCloudEndPoint = new IPEndPoint(IPAddress.Parse(cableCloudModel.IpAddress.ToString()), cableCloudModel.Port); cableCloud.ConnectedCableList = new Dictionary <int, CableCloud.Cable>(); cableCloud.IPlist = new Dictionary <string, IPEndPoint>(); foreach (CableModel element in cableCloudModel.cableList) { cableCloud.ConnectedCableList.Add(element.PortIn, new CableCloud.Cable(element.NodeOutName, element.Port2Out, element.Capacity)); } foreach (IPListModel element in cableCloudModel.ipList) { cableCloud.IPlist.Add(element.NodeName, new IPEndPoint(IPAddress.Parse(element.IpAddress), element.Port)); } }
static void Main(string[] args) { CableCloud cableCloud = new CableCloud(args[0]); }