MachineControllor.cs
2.0 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//所有控制机器发送指令的类
using System.Threading;
using System;
namespace MachineDll
{
public class MachineControllor
{
private readonly SerialPortSetting _ItsSerialPort;
public MachineControllor(SerialPortSetting itsSerialPort)
{
_ItsSerialPort = itsSerialPort;
}
#region NewControlPorts
public void OpenY0()
{
_ItsSerialPort.SendString("%01#WCSY00001**");
}
public void CloseY0()
{
_ItsSerialPort.SendString("%01#WCSY00000**");
}
public void OpenY1()
{
_ItsSerialPort.SendString("%01#WCSY00011**");
}
public void CloseY1()
{
_ItsSerialPort.SendString("%01#WCSY00010**");
}
public void OpenY2()
{
_ItsSerialPort.SendString("%01#WCSY00021**");
}
public void CloseY2()
{
_ItsSerialPort.SendString("%01#WCSY00020**");
}
public void OpenY1Y2()
{//过滤
_ItsSerialPort.SendIOString("01 0F 00 64 00 04 01 06 CF 5C");
}
public void OpenY0Y2()
{//清洗
_ItsSerialPort.SendIOString("01 0F 00 64 00 04 01 05 8F 5D");
}
public void CloseAll()
{//关闭
_ItsSerialPort.SendIOString("01 0F 00 64 00 04 01 00 4F 5E");
}
public double SendAIString()
{//读AI数据
double data = _ItsSerialPort.ReadAIString("01 03 02 58 00 08 C4 67");
return data;
}
public bool ReadX0()
{
_ItsSerialPort.SendString("%01#RCSX0000**");
Thread.Sleep(50);
string response = _ItsSerialPort.ReadExisting();
//%01$RC021\r ---response示例
return !response[6].Equals('0');
}
public void TestCommand(string s)
{
_ItsSerialPort.SendString(s);
}
#endregion
}
}