public static bool PlcWrite(int adres
{
if (Sys
return true;
string s_adres = (adres + Sys
string s_count = count
string hdr =
string s_data =
string n = (s_data
string dtfram = (hdr + n + s_data);
byte[] msg = Encoding
plcCom
Application
if (Sys
return true;
int byteSend = Sock
System
string smsg = encoding
System
TimeSpan Ctime = new TimeSpan(
do
{
TimeSpan Ptime = (DateTime
if (Ptime > Ctime)
{
MessageBox
return false;
}
Application
} while (Sock
int byteRec = Sock
string rcvstr = System
plcCom
string emsg = rcvstr
if (emsg !=
{
plcCom
MessageBox
}
return true;
}
二
view plainprint?
public static bool PlcRead(int adres
{
if (Sys
return true;
PlcReadBusy = true;
string s_adres = (adres + Sys
string s_count = count
string hdr =
string s_data =
string n = (s_data
string dtfram = (hdr + n + s_data);
byte[] msg = Encoding
if (Sys
{
PlcReadBusy = false;
return true;
}
int byteSend = Sock
System
string smsg = encoding
System
TimeSpan Ctime = new TimeSpan(
do
{
TimeSpan Ptime = (DateTime
if (Ptime > Ctime)
{
MessageBox
PlcReadBusy = false;
return false;
}
Application
} while (Sock
int byteRec = Sock
ReadData = System
plcCom
string emsg = ReadData
if (emsg !=
{
plcCom
PlcReadBusy = false;
return false;
}
ReadData = ReadData
PlcReadBusy = false;
return true;
}
}
From:http://tw.wingwit.com/Article/program/net/201311/13889.html