Ejemplo n.º 1
0
        /// <summary>
        /// Парсит полученные данные с контроллера
        /// </summary>
        /// <param name="readBuffer"></param>
        private static void ParseInfo(IList <byte> readBuffer)
        {
            int ttm = (int)(((readBuffer[22] * 65536) + (readBuffer[21] * 256) + (readBuffer[20])) / 2.1);

            if (ttm > 5000)
            {
                return;
            }

            //TODO: иногда в МК2 бывает глюк, поэтому защитимся от него, костылем
            //if (readBuffer[10] == 0x58 && readBuffer[11] == 0x02 && readBuffer[22] == 0x20 && readBuffer[23] == 0x02) return;

            deviceInfo.FreebuffSize = readBuffer[1];


            deviceInfo.shpindel_MoveSpeed = 0;

            if (Setting.DeviceModel == DeviceModel.MK1)
            {
                deviceInfo.shpindel_MoveSpeed = (int)(((readBuffer[22] * 65536) + (readBuffer[21] * 256) + (readBuffer[20])) / 2.1);
            }

            if (Setting.DeviceModel == DeviceModel.MK2)
            {
                deviceInfo.shpindel_MoveSpeed = (int)(((readBuffer[22] * 65536) + (readBuffer[21] * 256) + (readBuffer[20])) / 1.341);
            }



            deviceInfo.AxesX_PositionPulse = (readBuffer[27] * 16777216) + (readBuffer[26] * 65536) + (readBuffer[25] * 256) + (readBuffer[24]);
            deviceInfo.AxesY_PositionPulse = (readBuffer[31] * 16777216) + (readBuffer[30] * 65536) + (readBuffer[29] * 256) + (readBuffer[28]);
            deviceInfo.AxesZ_PositionPulse = (readBuffer[35] * 16777216) + (readBuffer[34] * 65536) + (readBuffer[33] * 256) + (readBuffer[32]);

            deviceInfo.AxesX_LimitMax = (readBuffer[15] & (1 << 0)) != 0;
            deviceInfo.AxesX_LimitMin = (readBuffer[15] & (1 << 1)) != 0;
            deviceInfo.AxesY_LimitMax = (readBuffer[15] & (1 << 2)) != 0;
            deviceInfo.AxesY_LimitMin = (readBuffer[15] & (1 << 3)) != 0;
            deviceInfo.AxesZ_LimitMax = (readBuffer[15] & (1 << 4)) != 0;
            deviceInfo.AxesZ_LimitMin = (readBuffer[15] & (1 << 5)) != 0;

            deviceInfo.NuberCompleatedInstruction = readBuffer[9] * 16777216 + (readBuffer[8] * 65536) + (readBuffer[7] * 256) + (readBuffer[6]);

            SuperByte bb = new SuperByte(readBuffer[19]);

            deviceInfo.shpindel_Enable = bb.Bit0;

            SuperByte bb2 = new SuperByte(readBuffer[14]);

            deviceInfo.Estop = bb2.Bit7;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Запуск движения без остановки
        /// </summary>
        /// <param name="x">Ось Х (доступные значения "+" "0" "-")</param>
        /// <param name="y">Ось Y (доступные значения "+" "0" "-")</param>
        /// <param name="z">Ось Z (доступные значения "+" "0" "-")</param>
        /// <param name="speed"></param>
        public static void StartManualMove(string x, string y, string z, int speed)
        {
            if (!Connected)
            {
                //stringError = "Для выключения шпинделя, нужно вначале установить связь с контроллером";
                //return false;
                return;
            }

            //if (!IsFreeToTask)
            //{
            //    return;
            //}

            SuperByte axesDirection = new SuperByte(0x00);

            //поставим нужные биты
            if (x == "-")
            {
                axesDirection.SetBit(0, true);
            }
            if (x == "+")
            {
                axesDirection.SetBit(1, true);
            }
            if (y == "-")
            {
                axesDirection.SetBit(2, true);
            }
            if (y == "+")
            {
                axesDirection.SetBit(3, true);
            }
            if (z == "-")
            {
                axesDirection.SetBit(4, true);
            }
            if (z == "+")
            {
                axesDirection.SetBit(5, true);
            }

            //DataClear();
            //DataAdd(BinaryData.pack_BE(axesDirection.valueByte, speed));
            SendBinaryData(BinaryData.pack_BE(axesDirection.ValueByte, speed, x, y, z));
            //Task_Start();
        }