Exemple #1
0
 public void ParseData(int portnr, string data)
 {
     //Console.WriteLine(portnr.ToString(), Environment.NewLine);
     //Console.WriteLine(data, Environment.NewLine);
     try
     {
         data = data.TrimStart();
         double   Weight;
         string   StringWeight;
         string[] Sdata = data.Split(' ');
         StringWeight = Sdata[0];
         if (StringWeight.Contains("-"))
         {
             Weight = 0;
         }
         else
         {
             if (StringWeight.Contains("."))
             {
                 string[] Sdata2 = StringWeight.Split('.');
                 StringWeight = Sdata2[0] + Sdata2[1];
             }
             Console.WriteLine(StringWeight, Environment.NewLine);
             Weight = Convert.ToDouble(StringWeight) * GewichtsClasse;
         }
         Weeg tmpweeg = ((Weeg)WeegArray[portnr]);
         tmpweeg.ParseStableWeight(Weight);
     }
     catch (Exception ee)
     {
         Console.WriteLine(ee.ToString(), Environment.NewLine);
         Console.WriteLine("error parse");
     }
 }
Exemple #2
0
 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;
 }
Exemple #3
0
 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;
 }