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

    }
}