MachineControllor.cs
1.4 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
//所有控制机器发送指令的类
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 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
}
}