1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
using System;
using System.Collections.Generic;
using System.Text;
using webmodbus.WebReference;
using System.Windows.Forms;
using System.Threading;
namespace webmodbus
{
public class ThreadLecture {
ModbusXmlDa service;
ModbusXmlDa port;
int[] result;
Label adrLabel;
string msg = "Il y a une erreur";
public ThreadLecture(string Text)
{
adrLabel.Text = Text;
try{
service = new ModbusXmlDa();
port = GetModbusXmlDaSoap();
}
catch (System.Web.Services.Protocols.SoapHeaderException exSoapH)
{ MessageBox.Show(exSoapH.Message, msg); }
catch (System.Web.Services.Protocols.SoapException exSoap)
{ MessageBox.Show(exSoap.Message, msg); }
catch (System.Net.WebException exWeb)
{ MessageBox.Show(exWeb.Message, msg); }
catch (System.InvalidCastException exC)
{ MessageBox.Show(exC.Message, msg); }
catch (SystemException ex) { MessageBox.Show(ex.Message, msg); }
}
public void run(){
try{
while(!Interrupted()){
result = port.ReadMultipleRegisters(0, 126, 1);
//adrLabel.Text(result.getInt.get(0).toString());
//sleep(200);
}
}
catch (System.Web.Services.Protocols.SoapHeaderException exSoapH)
{ MessageBox.Show(exSoapH.Message, msg); }
catch (System.Web.Services.Protocols.SoapException exSoap)
{ MessageBox.Show(exSoap.Message, msg); }
catch (System.Net.WebException exWeb)
{ MessageBox.Show(exWeb.Message, msg); }
catch (System.InvalidCastException exC)
{ MessageBox.Show(exC.Message, msg); }
catch (SystemException ex) { MessageBox.Show(ex.Message, msg); }
}
}
} |