//读胶料温度
private void ReadJLWD(out float JLWD1, out float JLWD2, out float JLWD3, out float JLWD4, out float JLWD5)
{
JLWD1 = 0;
JLWD2 = 0;
JLWD3 = 0;
JLWD4 = 0;
JLWD5 = 0;
_serialPortJLWD.PortName = "COM1";
_serialPortJLWD.BaudRate = 9600;
_serialPortJLWD.DataBits = 8;
_serialPortJLWD.StopBits = StopBits.One;
_serialPortJLWD.Parity = Parity.Even;
_serialPortJLWD.Open();
if (_serialPortJLWD.IsOpen)
{
string strCmd = "01 03 00 00 00 02 C4 0B";
//02 03 00 00 00 02 38 C4
//03 03 00 00 00 02 E9 C5
//04 03 00 00 00 02 5E C4
string[] strs = strCmd.Split(new char[] { ' ' });
byte[] cmdBytes = new byte[strs.Length];
byte[] send_read = StringToByte(strCmd);
for (int i = 0; i < cmdBytes.Length; i++)
{
cmdBytes[i] = Convert.ToByte(strs[i], 16);
}
_serialPortJLWD.Write(cmdBytes, 0, cmdBytes.Length);
System.Threading.Thread.Sleep(500);
int lenth = _serialPortJLWD.BytesToRead;
byte[] buffer = new byte[lenth];
_serialPortJLWD.Read(buffer, 0, lenth);
JLWD1 = float.Parse(buffer[6].ToString());
}
_serialPortJLWD.Close();
}