예제 #1
0
        /// <summary>
        /// 从ARM获取Y和Y1的位置
        /// </summary>
        /// <param name="position"></param>
        private bool GetYHomePosition(ref MotionDebugInfoFromARM position)
        {
            byte[] val     = new byte[64];
            uint   bufsize = (uint)val.Length;
            int    ret     = CoreInterface.GetEpsonEP0Cmd(0x43, val, ref bufsize, 0, 0);

            if (ret == 0)
            {
                MessageBox.Show(ResString.GetResString("GetYhomepositionfialed"));
                return(false);
            }
            else
            {
                int xposIndex = 2;
                position.xPosition  = (val[xposIndex + 3] << 24) + (val[xposIndex + 2] << 16) + (val[xposIndex + 1] << 8) + val[xposIndex + 0];
                xposIndex          += 4;
                position.yPosition  = (val[xposIndex + 3] << 24) + (val[xposIndex + 2] << 16) + (val[xposIndex + 1] << 8) + val[xposIndex + 0];
                xposIndex          += 4;
                position.zPosition  = (val[xposIndex + 3] << 24) + (val[xposIndex + 2] << 16) + (val[xposIndex + 1] << 8) + val[xposIndex + 0];
                xposIndex          += 4;
                position.fPosition  = (val[xposIndex + 3] << 24) + (val[xposIndex + 2] << 16) + (val[xposIndex + 1] << 8) + val[xposIndex + 0];
                xposIndex          += 4;
                position.y1Position = (val[xposIndex + 3] << 24) + (val[xposIndex + 2] << 16) + (val[xposIndex + 1] << 8) + val[xposIndex + 0];
                return(true);
            }
        }
예제 #2
0
        /// <summary>
        /// 获取/刷新界面
        /// </summary>
        /// <param name="isActive">是否时按钮点击触发的</param>
        void RefreshView(object isActive)
        {
            try
            {
                if ((bool)isActive)
                {
                    btnRefresh.Enabled = false;
                }
                const int  port = 1;
                const byte PRINTER_PIPECMDSIZE = 26;
                byte[]     m_pData             = new byte[PRINTER_PIPECMDSIZE + 2];
                //First Send Begin Updater
                m_pData[0] = 2;
                m_pData[1] = 0x2c; //Move cmd
                CoreInterface.SetPipeCmdPackage(m_pData, m_pData[0], port);

                Thread.Sleep(1000);
                BYHXPrinterManager.MotionDebugInfo info;
                string labChangeText   = ResString.GetResString("FactoryTool_labChange");
                string groupBox_XText  = ResString.GetResString("FactoryTool_PossionX");
                string groupBox_YText  = ResString.GetResString("FactoryTool_PossionY");
                string groupBox_Y2Text = ResString.GetResString("FactoryTool_PossionY2");
                string groupBox_ZText  = ResString.GetResString("FactoryTool_PossionZ");
                if (GetXAndYPos(out info))
                {
                    if (!isDoubleYAxis)
                    {
                        groupBox_Y.Text = string.Format(groupBox_YText, info.yPos);
                        if ((bool)isActive)
                        {
                            labChange_Y.Text = string.Format(labChangeText, info.yPos - currpos_Y);
                            currpos_Y        = info.yPos;
                        }
                    }
                    groupBox_X.Text = string.Format(groupBox_XText, info.xPos);
                    groupBox_Z.Text = string.Format(groupBox_ZText, info.nDebugInt1);
                    if ((bool)isActive)
                    {
                        labChange_X.Text = string.Format(labChangeText, info.xPos - currpos_X);
                        labChange_Z.Text = string.Format(labChangeText, info.nDebugInt1 - currpos_Z);
                        currpos_X        = info.xPos;
                        currpos_Z        = info.nDebugInt1;
                    }
                }
                if (isDoubleYAxis)
                {
                    MotionDebugInfoFromARM motionDebugInfo = new MotionDebugInfoFromARM();
                    if (GetYHomePosition(ref motionDebugInfo))
                    {
                        groupBox_Y.Text  = string.Format(groupBox_YText, motionDebugInfo.yPosition);
                        groupBox_Y2.Text = string.Format(groupBox_Y2Text, motionDebugInfo.y1Position);
                        if ((bool)isActive)
                        {
                            labChange_Y.Text  = string.Format(labChangeText, motionDebugInfo.yPosition - currpos_Y);
                            labChange_Y2.Text = string.Format(labChangeText, motionDebugInfo.y1Position - currpos_Y2);
                            currpos_Y         = motionDebugInfo.yPosition;
                            currpos_Y2        = motionDebugInfo.y1Position;
                        }
                    }
                }

                byte[] buf    = new byte[8 + 32];
                uint   lenght = (uint)buf.Length;
                CoreInterface.GetEpsonEP0Cmd(0x82, buf, ref lenght, 0, 8);
                CoreInterface.GetEpsonEP0Cmd(0x82, buf, ref lenght, 0, 9);

                int[]  pwmList     = new int[6];
                int[]  GratingList = new int[6];
                byte[] Buffer      = new byte[64];
                uint   len         = (uint)Buffer.Length;
                if (CoreInterface.GetEpsonEP0Cmd(0x94, Buffer, ref len, 0, 1) != 0)
                {
                    for (int i = 0; i < 6; i++)
                    {
                        pwmList[i] = BitConverter.ToInt32(Buffer, 2 + i * 4);

                        GratingList[i] = BitConverter.ToInt32(Buffer, 2 + (7 + i) * 4);
                    }

                    labelPWMValue1.Text = pwmList[0].ToString();
                    labelPWMValue2.Text = pwmList[1].ToString();
                    labelPWMValue3.Text = pwmList[2].ToString();
                    labelPWMValue5.Text = pwmList[4].ToString();

                    labelGValue1.Text = GratingList[0].ToString();
                    labelGValue2.Text = GratingList[1].ToString();
                    labelGValue3.Text = GratingList[2].ToString();
                    labelGValue5.Text = GratingList[4].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                if ((bool)isActive)
                {
                    btnRefresh.Enabled = true;
                }
            }
        }