示例#1
0
        public void SendCommand(CNCComands cmd, byte value = 0)
        {
            lock (_lockobject)
            {
                Sender.SendByte((byte)cmd, value);

                if (Sender.CanRead && (cmd == CNCComands.Start || cmd == CNCComands.Home || cmd == CNCComands.GetTemp || cmd == CNCComands.SetWaitTemp || cmd == CNCComands.SearchHome))
                {
                    var result = Sender.ReadByte();
                }
            }
        }
示例#2
0
        public void SendXYZE(int x, int y, int z, int e)
        {
            int ax = x < 0 ? -x: x;
            int ay = y < 0 ? -y: y;
            int az = z < 0 ? -z: z;
            int ae = e < 0 ? -e: e;


            if (ax != 0)
            {
                CNCComands cmd = x < 0 ? CNCComands.SubX : CNCComands.AddX;
                for (int i = 0; i < ax / 255; i++)
                {
                    SendCommand(cmd, 255);
                }
                SendCommand(cmd, (byte)(ax % 255));
            }

            if (ay != 0)
            {
                CNCComands cmd = y < 0 ? CNCComands.SubY : CNCComands.AddY;
                for (int i = 0; i < ay / 255; i++)
                {
                    SendCommand(cmd, 255);
                }
                SendCommand(cmd, (byte)(ay % 255));
            }

            if (az != 0)
            {
                CNCComands cmd = z < 0 ? CNCComands.SubZ : CNCComands.AddZ;
                for (int i = 0; i < az / 255; i++)
                {
                    SendCommand(cmd, 255);
                }
                SendCommand(cmd, (byte)(az % 255));
            }

            if (ae != 0)
            {
                CNCComands cmd = e < 0 ? CNCComands.SubE : CNCComands.AddE;
                for (int i = 0; i < ae / 255; i++)
                {
                    SendCommand(cmd, 255);
                }
                SendCommand(cmd, (byte)(ae % 255));
            }



            SendCommand(CNCComands.Start, 0);
        }
示例#3
0
        public void SendCommand(CNCComands cmd, byte value = 0)
        {
            lock (_lockobject)
            {
                Sender.SendByte((byte)cmd, value);


                if (Sender.CanRead && (cmd == CNCComands.Start || cmd == CNCComands.Home || cmd == CNCComands.GetTemp || cmd == CNCComands.SetWaitTemp || cmd == CNCComands.SearchHome))
                {
                    var result = Sender.ReadByte();
                }
            }
        }
示例#4
0
        public byte SendCommandWithReturn(CNCComands cmd, byte value = 0)
        {
            lock (_lockobject)
            {
                if (!Sender.CanRead)
                {
                    return(0);
                }

                Sender.SendByte((byte)cmd, value);

                var result = Sender.ReadByte();

                return(result);
            }
        }
示例#5
0
        public byte SendCommandWithReturn(CNCComands cmd, byte value = 0)
        {
            lock (_lockobject)
            {
                if (!Sender.CanRead)
                    return 0;

                Sender.SendByte((byte)cmd,value);

                var result = Sender.ReadByte();

                return result;
            }
        }