/// <summary>
        /// 加载本地的卡塞数据,只读取插栏基准位,和所有位置的偏差
        /// </summary>
        public static void LoadCstData()
        {
            try
            {
                //清空数据
                CSTLocation.ClearCstData();
                //加载插栏基准位
                ReadIni_DblList("StdInsert", "Col", CSTLocation.Path_StdInsert_INI, out CSTLocation.StdInsert_L);
                //加载插栏偏差
                int intNum = IniFile.I_I.ReadIniInt("CST", "Num", CSTLocation.Path_InsertDev_INI);
                for (int i = 0; i < intNum; i++)
                {
                    //加1是为了从第一列开始记录,方便人员理解和查看
                    ReadIni_DblList("Col" + (i + 1).ToString(), "Row", CSTLocation.Path_InsertDev_INI, out List <double> p_L);
                    CSTLocation.InsertDev_L.Add(p_L);
                }

                if (CSTLocation.StdInsert_L.Count != Protocols.confCSTCol ||
                    CSTLocation.InsertDev_L.Count != Protocols.confCSTCol)
                {
                    ShowAlarm("插栏数据加载失败,请重新上卡塞");
                }
                else
                {
                    ShowState("插栏数据加载成功!");
                }
            }
            catch (Exception ex)
            {
                ShowAlarm("插栏数据加载失败,请重新上卡塞");
                Log.L_I.WriteError("MainWindow", ex);
            }
        }
Exemple #2
0
        /// <summary>
        /// 卡塞高度补偿计算
        /// </summary>
        /// <returns></returns>
        private bool CalcDevHeight()
        {
            try
            {
                CSTLocation.HeightDev_L = CSTLocation.CalcHeightDeviation(
                    ModelParams.confCSTCol, CSTLocation.TopDev_L, ModelParams.DirZ);
                WriteIni_HeightDev();
                CSTLocation.LayerSpacing_L = CSTLocation.CalcLayerSpacing(
                    ModelParams.confCSTCol, ModelParams.confCSTRow, ModelParams.confLayerSpacing,
                    CSTLocation.TopDev_L, CSTLocation.BottomDev_L);
                WriteIni_LayerSpacing();
                CSTLocation.KeelHeightDev_L = CSTLocation.CalcKeelHeightDeviation(
                    ModelParams.confCSTCol, CSTLocation.TopDev_L, CSTLocation.BottomDev_L);
                WriteIni_KeelHeightDev();

                LogicPLC.L_I.WriteRegData3((int)DataRegister3.InsertComZ1 + CSTLocation.CurrentCstNo - 1,
                                           CSTLocation.HeightDev_L.Count, CSTLocation.HeightDev_L.ToArray());
                LogicPLC.L_I.WriteRegData3((int)DataRegister3.KeelSpacing1 + (CSTLocation.CurrentCstNo - 1) * 6,
                                           CSTLocation.LayerSpacing_L.Count, CSTLocation.LayerSpacing_L.ToArray());

                if (ModelParams.IfRecordData)
                {
                    RecordCSTData("HeightDev", CSTLocation.HeightDev_L);
                    RecordCSTData("LayerSpacing", CSTLocation.LayerSpacing_L);
                    RecordCSTData("KeelHeight", CSTLocation.KeelHeightDev_L);
                }

                return(true);
            }
            catch (Exception ex)
            {
                Log.L_I.WriteError(NameClass, ex);
                return(false);
            }
        }
        /// <summary>
        /// 记录左右横拍的数据
        /// </summary>
        /// <param name="trigerSource_e"></param>
        /// <param name="pos"></param>
        /// <param name="htResult"></param>
        /// <returns></returns>
        public StateComprehensive_enum CalcKeel(int pos, Hashtable htResult)
        {
            try
            {
                BaseResult result = htResult[CSTMatch3] as BaseResult;

                if (pos == 1)
                {
                    //CSTLocation.SetLeftDevEnable(result.DeltaX * AMP);
                    CSTLocation.SetLeftDevEnable((result.X_L[0] - Protocols.CstStdValue.DblValue1) * AMP);
                }
                else if (pos == 2)
                {
                    //CSTLocation.SetRightDevEnable(result.DeltaX * AMP);
                    CSTLocation.SetRightDevEnable((result.X_L[0] - Protocols.CstStdValue.DblValue1) * AMP);
                }

                return(DealResult(1, @"龙骨识别成功"));
            }
            catch (Exception ex)
            {
                Log.L_I.WriteError("DealComprehensiveResult", ex);
                return(DealResult(2, @"龙骨计算异常"));
            }
        }
Exemple #4
0
 void ChangCSTSationNum(int id)
 {
     ShowState(string.Format("切换卡塞,当前卡塞{0}", id));
     //ParInsertRegData.P_I.CurStationNo = id;
     CSTLocation.CurrentCstNo = id;
     CSTLocation.ResetCstData();
 }
Exemple #5
0
 /// <summary>
 /// 获取每列插栏基准位
 /// </summary>
 private void GetStdInsertPos()
 {
     try
     {
         double stdPos = LogicPLC.L_I.ReadRegData2((int)DataRegister2.StdCSTPos1 + CSTLocation.CurrentCstNo - 1);
         CSTLocation.StdInsert_L = CSTLocation.CreateKeelStdPos(
             stdPos, ModelParams.confCSTCol, ModelParams.confKeelInterval,
             ModelParams.confCol1Interval, ModelParams.DirInsert);
     }
     catch (Exception ex)
     {
         Log.L_I.WriteError(NameClass, ex);
     }
 }
Exemple #6
0
        /// <summary>
        /// 计算最终插栏的X偏差
        /// </summary>
        /// <returns></returns>
        private bool CalcDevX()
        {
            try
            {
                //计算龙骨单列偏差
                CSTLocation.KeelDev_L = CSTLocation.CalcKeelDeviation(
                    ModelParams.KeelCol, ModelParams.confCSTRow, CSTLocation.TopDev_L, CSTLocation.BottomDev_L);
                WriteIni_KeelDev();
                //计算卡塞单列偏差
                CSTLocation.ColDev_L = CSTLocation.CalcColDeviation(
                    ModelParams.confCSTCol, CSTLocation.TopDev_L);
                WriteIni_ColDev();
                //偏差相加
                CSTLocation.InsertDev_L = CSTLocation.MixDeviation(
                    ModelParams.confCSTCol, ModelParams.confCSTRow,
                    CSTLocation.KeelDev_L, CSTLocation.ColDev_L, ModelParams.DirPhoto, ModelParams.CstIsMirrorX);
                WriteIni_InsertDev();
                CSTLocation.KeelSpacingDev_L = CSTLocation.CalcKeelSpacingDeviation(
                    ModelParams.confCSTCol, CSTLocation.TopDev_L, CSTLocation.BottomDev_L);
                WriteIni_KeelSpacingDev();

                if (ModelParams.IfRecordData)
                {
                    RecordCSTData("KeelDev", CSTLocation.KeelDev_L);
                    RecordCSTData("ColDev", CSTLocation.ColDev_L);
                    RecordCSTData("InsertDev", CSTLocation.InsertDev_L);
                    RecordCSTData("KeelSpacing", CSTLocation.KeelSpacingDev_L);
                }

                return(true);
            }
            catch (Exception ex)
            {
                Log.L_I.WriteError(NameClass, ex);
                return(false);
            }
        }
Exemple #7
0
        void SendInsertData(int num)
        {
            try
            {
                if (ParStateSoft.StateMachine_e == StateMachine_enum.NullRun)
                {
                    ShowState("空跑,默认发送插栏数据0");
                    LogicPLC.L_I.WriteRegData3((int)DataRegister3.InsertData, 145.5);
                    LogicPLC.L_I.WriteRegData1((int)DataRegister1.InsertDataConfirm, 1);
                    return;
                }

                double stdCom = 0;
                double com    = 0;

                stdCom = Protocols.stdInsertComX1;
                com    = Protocols.adjInsertComX1 + stdCom;// + Protocols.InsertTempComX;

                ShowState(string.Format("插栏基准补偿:{0},总补偿:{1}", stdCom, com));
                LogicPLC.L_I.WriteRegData3((int)DataRegister3.InsertStdCom, stdCom);

                ShowState(string.Format("即将发送卡塞{0}插栏坐标", CSTLocation.CurrentCstNo));
                int numInsert = Convert.ToInt32(
                    LogicPLC.L_I.ReadRegData1((int)DataRegister1.CurrentInsertSum));
                //int numInsert = num;
                int intCol = numInsert / Protocols.confCSTRow;
                int intRow = numInsert % Protocols.confCSTRow;

                #region  择偏差
                double curDev      = CSTLocation.InsertDev_L[intCol][intRow];
                double realTimeDev = 0;
                if (CSTLocation.GetRealTimeDev(Protocols.DirPhoto, Protocols.CstIsMirrorX, out realTimeDev))
                {
                    ShowState(string.Format("理论偏差:{0},实时偏差:{1}", curDev, realTimeDev));
                    if (Math.Abs(curDev - realTimeDev) < 1)
                    {
                        curDev = realTimeDev;
                        ShowState("实时偏差有效");
                    }
                    else
                    {
                        ShowState("实时偏差与理论偏差过大,不启用");
                    }
                }
                else
                {
                    ShowState(string.Format("实时偏差无效"));
                }
                #endregion

                //读取插栏坐标X方向
                double insertPos = CSTLocation.StdInsert_L[intCol] + curDev + com;
                ShowState(string.Format("计算偏差:{0},补偿{1}",
                                        curDev.ToString("f3"), (com).ToString("f3")));
                ShowState(string.Format("当前插栏位置:第{0}列,第{1}行", intCol + 1, intRow + 1));
                LogicPLC.L_I.WriteRegData3((int)DataRegister3.InsertData, insertPos);
                LogicPLC.L_I.WriteRegData1((int)DataRegister1.InsertDataConfirm, 1);
                ShowState("已发送插栏坐标X:" + insertPos.ToString("f3"));
                if (intRow == 0)
                {
                    ClearTempCom?.Invoke();
                }
            }
            catch (Exception ex)
            {
            }
        }
Exemple #8
0
 void ChangeCol()
 {
     CSTLocation.SetLeftDevEnable();
     CSTLocation.SetRightDevEnable();
     ClearTempCom?.Invoke();
 }