Exemplo n.º 1
0
        private void LdsWorkFunctionSet1()
        {
            int          nIndex = 1;
            int          nCmd   = 0;
            const string cmdReg = "R211";

            const string Angle_Join_Reg = "R213";
            const string bool_Join_Reg  = "R212";

            const string Intensity6m_Reg = "R272";
            const string bool_6m_Reg     = "R268";

            try
            {
                while (!cts.IsCancellationRequested)
                {
                    bool bRet = false;
                    nCmd = PLC.ReadInt(cmdReg);
                    switch (nCmd)
                    {
                    case 1:     //计算对接角度
                        bRet = GetTune2JoinAngle(nIndex, out double Angle);
                        PLC.WriteDint(Angle_Join_Reg, /*Convert.ToInt32(Angle * 1000)*/ 765);
                        PLC.WriteInt(bool_Join_Reg, bRet ? 2 : 1);
                        PLC.WriteInt(cmdReg, nCmd + 1);
                        ShowInfo($"计算LDS1的对接角度结果{bRet},{Angle}");
                        break;

                    case 5:     //获取强度值
                        bRet = GetLaserIntensityValue(nIndex, out int intensityValue);
                        PLC.WriteDint(Intensity6m_Reg, /*intensityValue*/ 99);
                        PLC.WriteInt(bool_6m_Reg, bRet ? 2 : 1);
                        PLC.WriteInt(cmdReg, nCmd + 1);
                        ShowInfo($"读取LDS1的6.5米处水平强度值{bRet},{intensityValue}");
                        break;

                    case 100:
                        ReadResutFromPLC(nIndex);
                        PLC.WriteInt(cmdReg, nCmd + 1);
                        break;

                    default:
                        break;
                    }
                    Thread.Sleep(100);
                }
                ShowInfo($"LDS1的服务器正常退出");
            }
            catch (Exception ex)
            {
                ShowInfo($"LDS1的服务器异常终止:{ex.Message}");
            }
        }
Exemplo n.º 2
0
        private void LdsWorkFunctionSet1()
        {
            int          nIndex = 1;
            int          nCmd   = 0;
            const string cmdReg = "R310";

            int C1 = 0;
            int C2 = 0;

            const string bool_Calib2m = "R311";
            const string bool_Calib4m = "R366";

            try
            {
                while (!cts.IsCancellationRequested)
                {
                    bool bRet = false;
                    nCmd = PLC.ReadInt(cmdReg);
                    switch (nCmd)
                    {
                    case 1:     //读取2米强度值
                        bRet = GetCenterFocus(nIndex, out C1);
                        PLC.WriteInt(bool_Calib2m, bRet ? 2 : 1);
                        PLC.WriteInt(cmdReg, nCmd + 1);
                        ShowInfo("读取LDS1的2米处激光中心值");
                        break;

                    case 3:     //读取4米强度值
                        bRet = GetCenterFocus(nIndex, out C1);
                        PLC.WriteInt(bool_Calib4m, bRet ? 2 : 1);
                        PLC.WriteInt(cmdReg, nCmd + 1);
                        ShowInfo("读取LDS1的4米处激光中心值");
                        break;

                    case 5:     //计算结果给LDS
                        bRet = SetLDSCalidData(nIndex, C1, C2);
                        PLC.WriteInt(cmdReg, nCmd + 1);
                        ShowInfo("计算结果写入LDS1");
                        //结果写在哪
                        break;

                    case 100:
                        ReadResutFromPLC(nIndex);
                        PLC.WriteInt(cmdReg, nCmd + 1);
                        break;

                    default:
                        break;
                    }
                    Thread.Sleep(100);
                }
                ShowInfo("LDS1的服务器被用户退出");
            }
            catch (Exception ex)
            {
                ShowInfo($"LDS1的服务器异常终止:{ex.Message}");
            }
        }
Exemplo n.º 3
0
        private void LdsWorkFunctionSet1()
        {
            int nIndex = 1;
            int nCmd   = 0;

            const string cmdReg = "R13";
            const string boolResult_Unlock_Reg = "R15";

            const string barcodeResult_Reg      = "R20";
            const string boolResult_Barcode_Reg = "R19";

            const string boolResult_AdjustPower_Reg = "R67";

            try
            {
                nAdjustCount[nIndex - 1] = 0;
                nCmd = 5;
                while (!cts.IsCancellationRequested)
                {
                    bool bRet = false;
                    //nCmd = PLC.ReadInt(cmdReg);
                    Console.WriteLine("22222");
                    Thread.Sleep(100);
                    continue;
                    switch (nCmd)
                    {
                    case 1:
                        bRet = UnLock(nIndex);
                        PLC.WriteDint(boolResult_Unlock_Reg, bRet ? 2 : 1);
                        PLC.WriteInt(cmdReg, nCmd + 1);
                        ShowInfo($"LDS1解锁结果:{bRet}");
                        nCmd = 2;
                        break;

                    case 3:
                        bRet = GetBarcode(nIndex, out string barcode);
                        PLC.WriteString(barcodeResult_Reg, barcode);
                        PLC.WriteInt(boolResult_Barcode_Reg, bRet ? 2 : 1);
                        PLC.WriteInt(cmdReg, nCmd + 1);
                        ShowInfo($"LDS1读取条码结果:{bRet}");
                        break;

                    case 5:
                        bRet = AdjustPowerValue(nIndex);
                        PLC.WriteInt(boolResult_AdjustPower_Reg, bRet ? 2 : 1);
                        PLC.WriteInt(cmdReg, nCmd + 1);
                        ShowInfo($"LDS1调整激光功率结果:{bRet}");
                        nCmd = 6;
                        break;

                    case 100:
                        ReadResutFromPLC(nIndex);
                        PLC.WriteInt(cmdReg, nCmd + 1);
                        break;

                    default:
                        break;
                    }
                    Thread.Sleep(30);
                }
                ShowInfo($"LDS1的服务器被用户退出");
            }
            catch (Exception ex)
            {
                ShowInfo($"LDS1的服务器异常终止:{ex.Message}");
            }
        }
Exemplo n.º 4
0
        private void LdsWorkFunctionSet1()
        {
            int          nIndex = 1;
            int          nCmd   = 0;
            const string cmdReg = "R107";

            const string Angle_Join_Reg = "R109";
            const string bool_Join_Reg  = "R108";

            const string Angle_Blob_Reg = "R164";
            const string Bool_Blob_Reg  = "R163";

            const string Intensity2m_Reg = "R171";
            const string bool_2m_Reg     = "R173";

            const string Intensity6m_Reg = "R171";
            const string bool_6m_Reg     = "R173";

            try
            {
                while (!cts.IsCancellationRequested)
                {
                    bool bRet = false;
                    nCmd = PLC.ReadInt(cmdReg);
                    switch (nCmd)
                    {
                    case 1:     //计算对接角度
                        bRet = GetTune1JoinAngle(nIndex, out double Angle);
                        PLC.WriteDint(Angle_Join_Reg, /*Convert.ToInt32(Angle * 1000)*/ 123);
                        PLC.WriteInt(bool_Join_Reg, bRet ? 2 : 1);
                        PLC.WriteInt(cmdReg, nCmd + 1);
                        ShowInfo($"LDS1拍照并计算对接角度结果{bRet},{Angle}");
                        break;

                    case 3:     //计算光斑角度
                        bRet = GetBlobAngle(nIndex, out double BlobAngle);
                        PLC.WriteDint(Angle_Blob_Reg, /*Convert.ToInt32(BlobAngle * 1000)*/ 11111111);
                        PLC.WriteInt(Bool_Blob_Reg, bRet ? 2 : 1);
                        PLC.WriteInt(cmdReg, nCmd + 1);
                        ShowInfo($"LDS1拍照并计算光板角度结果{bRet},{BlobAngle}");
                        break;

                    case 5:     //获取2米水平强度值
                        bRet = GetLaserIntensity(nIndex, EnumTarget.T2, out int InstensityValue2m);
                        PLC.WriteDint(Intensity2m_Reg, /*InstensityValue2m*/ 777777);
                        PLC.WriteInt(bool_2m_Reg, bRet ? 2 : 1);
                        PLC.WriteInt(cmdReg, nCmd + 1);
                        ShowInfo($"LDS1获取2米处的水平强度值结果{bRet},{InstensityValue2m}");
                        break;

                    case 7:     //获取6米水平强度值
                        bRet = GetLaserIntensity(nIndex, EnumTarget.T6, out int InstensityValue6m);
                        PLC.WriteDint(Intensity6m_Reg, /*InstensityValue6m*/ 76);
                        PLC.WriteInt(bool_6m_Reg, bRet ? 2 : 1);
                        PLC.WriteInt(cmdReg, nCmd + 1);
                        ShowInfo($"LDS1获取6.5米处的水平强度值结果{bRet},{InstensityValue6m}");
                        break;

                    case 100:
                        ReadResutFromPLC(nIndex);
                        PLC.WriteInt(cmdReg, nCmd + 1);
                        break;

                    default:
                        break;
                    }
                    Thread.Sleep(100);
                }
                ShowInfo($"LDS1的服务器正常退出");
            }
            catch (Exception ex)
            {
                ShowInfo($"LDS1的服务器异常终止:{ex.Message}");
            }
        }