public void loadNetFile(String filename) { int counter = 0; string filepath = ""; if (filename == "") { filename = "devices0.csv"; } string line; string[] aline; int did; string name; MapLocation loc; int x, y, z, room; DeviceType dt; NetworkInfo net; try { // todo save old network incase of errors this.network = new ArrayList(); System.IO.StreamReader file = new System.IO.StreamReader(filename); while ((line = file.ReadLine()) != null) { Console.WriteLine(line); aline = line.Split(','); did = int.Parse(aline[0]); name = aline[1]; dt = dvert(aline[2]); x = int.Parse(aline[3]); y = int.Parse(aline[4]); z = int.Parse(aline[5]); room = int.Parse(aline[6]); loc = new MapLocation(x, y, z, room); net = new NetworkInfo(); network.Add(makeDevice(did, name, dt, loc, net)); counter++; } file.Close(); } catch (IOException e) { Console.WriteLine(e.Message); } }
public Device makeDevice(string name, DeviceType dt, MapLocation loc, NetworkInfo net) { // name, type, location, // network info Device d = new Device(); d.did = 0; d.name = name; d.type = dt; d.loc = loc; d.net = net; return(d); }
public Device makeDevice(string name, DeviceType dt, int x, int y) { // name, type, location, // network info MapLocation l = new MapLocation(); l.x = x; l.y = y; NetworkInfo n = new NetworkInfo(); Device d = new Device(); d.did = 0; d.name = name; d.type = dt; d.loc = l; d.net = n; return(d); }