public void init() { ReadFromFile("C:\\weegservice.ini"); Console.WriteLine(ServerDNS, Environment.NewLine); Console.WriteLine(ServerID, Environment.NewLine); Console.WriteLine(GewichtsClasse.ToString(), Environment.NewLine); tcpweeg = new TcpClientWeeg(ServerDNS); try { int i = 0; foreach (string s in SerialPort.GetPortNames()) { Weeg tmpweeg = new Weeg(i, ServerID, tcpweeg); WeegArray.Add(tmpweeg); i++; } portnumbers = i; Console.WriteLine("number of com ports: "); Console.WriteLine(i.ToString(), Environment.NewLine); } catch (Exception ee) { Console.WriteLine(ee.ToString(), Environment.NewLine); } serial = new serial_port[portnumbers]; MyData = new COMServer[portnumbers]; Threads = new Thread[portnumbers]; try { int i = 0; while (i < portnumbers) { Thread t = new Thread(AddSerialPort); t.Start(i); Threads[i] = t; i++; } } catch (Exception ee) { Console.WriteLine(ee.ToString(), Environment.NewLine); } mRun = true; }
public Weeg(int com, string Serverid, TcpClientWeeg tmptcpweeg) { Com = com; ServerID = Serverid; tcpweeg = tmptcpweeg; }