Exemplo n.º 1
0
 public static T GetPrm <T>(string name, bool isShowAlarm = true)
 {
     try
     {
         if (typeof(T) == typeof(bool))
         {
             return((T)Convert.ChangeType(ParamSetMgr.GetInstance().GetBoolParam(name), typeof(bool)));
         }
         else if (typeof(T) == typeof(int))
         {
             return((T)Convert.ChangeType(ParamSetMgr.GetInstance().GetIntParam(name), typeof(int)));
         }
         else if (typeof(T) == typeof(double))
         {
             return((T)Convert.ChangeType(ParamSetMgr.GetInstance().GetDoubleParam(name), typeof(double)));
         }
         else if (typeof(T) == typeof(string))
         {
             return((T)Convert.ChangeType(ParamSetMgr.GetInstance().GetStringParam(name), typeof(string)));
         }
     }
     catch
     {
         if (isShowAlarm)
         {
             MessageBox.Show($"找不到 {typeof(T)} 类型参数名:{name},现已使用默认值:{default(T)},若是重要参数请手动添加", "参数加载错误");
         }
     }
     return(default(T));
 }
Exemplo n.º 2
0
        public override bool FindMark(HObject Image, HTuple Mold, ref double row, ref double col)
        {
            HTuple AngleStar    = ParamSetMgr.GetInstance().GetDoubleParam("点胶匹配开始角度");
            HTuple AngleExtent  = ParamSetMgr.GetInstance().GetDoubleParam("点胶匹配结束角度");
            HTuple Score        = ParamSetMgr.GetInstance().GetDoubleParam("点胶匹配分数");
            HTuple NumLevels    = ParamSetMgr.GetInstance().GetDoubleParam("点胶匹配等级");
            HTuple CenterRow    = new HTuple();
            HTuple CenterColumn = new HTuple();
            HTuple CenterAngle  = new HTuple();
            HTuple CenterScore  = new HTuple();

            try
            {
                HOperatorSet.FindNccModel(Image, Mold, AngleStar, AngleExtent, Score, 1, 0.5, "true", NumLevels, out CenterRow, out CenterColumn, out CenterAngle, out CenterScore);
                if (CenterScore != null && CenterScore.D != 0)
                {
                    row = CenterRow.D;
                    col = CenterColumn.D;
                    return(true);
                }
                else
                {
                    row = 0;
                    col = 0;
                    return(false);
                }
            }
            catch
            {
                row = 0;
                col = 0;
                return(false);
            }
        }
Exemplo n.º 3
0
        public bool GetSFRValue(Bitmap bmp, ref SFRValue SFRValue, ref RectInfo rectInfo, Rectangle[] rectangles, ref LightValue lightValue, bool TestLight = false)
        {
            if (!bLoad)
            {
                return(false);
            }
            AlgorithmBase tempModuleBase = GetAlgByIndexID();

            if (tempModuleBase != null)
            {
                bool result = tempModuleBase.GetSFRValue(bmp, ref SFRValue, ref rectInfo, rectangles, ref lightValue, TestLight);
                if (SFRValue != null)
                {
                    for (int i = 0; i < SFRValue.block.Length; i++)
                    {
                        if (SFRValue.block[i].dValue > ParamSetMgr.GetInstance().GetDoubleParam("SFR最大值"))
                        {
                            SFRValue.block[i].dValue = -1;
                        }
                    }
                }

                return(result);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 4
0
        public StationStep StepTableRun(bool bmanual = false)
        {
            StationStep step = StationStep.Step_Stop;

            ParamSetMgr.GetInstance().SetBoolParam("AA完成", false);
            ParamSetMgr.GetInstance().SetBoolParam("点胶完成", false);
            ParamSetMgr.GetInstance().SetBoolParam("启动AA", false);
            ParamSetMgr.GetInstance().SetBoolParam("启动点胶", false);
            if (!checkSafe())
            {
                Err("安全检测失败,转盘禁止转动!");
                return(step);
            }
            MoveSigleAxisPosWaitInpos(AxisU, TableData.GetInstance().listPoss[nTableRuns % TableData.GetInstance().listPoss.Count], (double)SpeedType.High, 0.1, false, this, 60000);
            nTableRuns++;
            if (nTableRuns == TableData.GetInstance().listPoss.Count)
            {
                nTableRuns = 0;
            }
            TableData.GetInstance().SetAllSationResultFalse();
            TableData.GetInstance().SetALLStartCmd();
            // ParamSetMgr.GetInstance().SetBoolParam("到位启动", true);
            ;
            step = StationStep.Step_WaitAllStationFinsh;
            return(step);
        }
Exemplo n.º 5
0
        public StationStep StepInitRun(bool bmanual = false)
        {
            StationStep step = StationStep.Step_Stop;

            ParamSetMgr.GetInstance().SetBoolParam("转盘站初始化完成", false);
            Info("转盘站 等待其他工位回零");
            WaranResult waranResult = doWhileWaitInit.doSomething(this, doWhileWaitInit, false, null);

            if (waranResult == WaranResult.TimeOut)
            {
                AlarmMgr.GetIntance().WarnWithDlg("转盘站回原点前,点胶工站或者AA工站复位时间过长,请检查,程序将会停止", this, CommonDlg.DlgWaranType.WaranOK, doWhileWaitInit, false);
                ClearAllStep();
                GlobalVariable.g_StationState = StationState.StationStateStop;
                return(step);
            }
            Info("转盘站 开始回零");
            if (!GoTableHome(bmanual))
            {
                Err("转盘站 回零失败");
                throw new Exception("转盘轴回零失败!");
            }
            GoTableReadySafe(bmanual);
            ParamSetMgr.GetInstance().SetBoolParam("转盘站初始化完成", true);
            step = StationStep.Step_WaitAllStationFinsh;
            TableData.GetInstance().SetAllSationResultFalse();
            TableData.GetInstance().SetALLStartCmd();//到位启动
            return(step);
        }
Exemplo n.º 6
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            bool bFind = Directory.Exists(ParamSetMgr.GetInstance().CurrentWorkDir);

            if (!bFind)
            {
                MessageBox.Show("没有产品文件,请设置", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Form_Input form_Input = new Form_Input("产品名称");

            if (DialogResult.OK == form_Input.ShowDialog())
            {
                if (form_Input.InputText != "")
                {
                    string str = ParamSetMgr.GetInstance().CurrentWorkDir + ("\\") + form_Input.InputText + ("\\") + form_Input.InputText + (".xml");
                    Directory.CreateDirectory(ParamSetMgr.GetInstance().CurrentWorkDir + ("\\") + form_Input.InputText);
                    XmlDocument    document = new XmlDocument();
                    XmlDeclaration dec      = document.CreateXmlDeclaration("1.0", "utf-8", "no");
                    document.AppendChild(dec);
                    XmlElement root = document.CreateElement("ParamCfg");
                    document.AppendChild(root);
                    XmlElement item = document.CreateElement("ParamSet");
                    root.AppendChild(item);
                    document.Save(str);
                    treeView_ProdutFile.Nodes[1].Nodes.Add(form_Input.InputText);
                    document.RemoveAll();
                    document = null;
                }
            }
            treeView_ProdutFile.Nodes[0].Expand();
        }
Exemplo n.º 7
0
        private void XmlToAlgIni(string path)
        {
            List <string> paramclasslist            = ParamSetMgr.GetInstance().GetParamClassList();
            Dictionary <string, ParamSet> allparams = ParamSetMgr.GetInstance().GetAllParam();
            string strName = "";

            try
            {
                foreach (var temp in allparams)
                {
                    if (temp.Value._ParamClass == "算法参数")
                    {
                        if (temp.Key.Contains("] ") && temp.Key.Contains("["))
                        {
                            string A = temp.Key.Replace(" ", "");
                            A = temp.Key.Replace("[", "");
                            string[] value = A.Split(']');
                            INIHelper.WriteToIni(value[0].Trim(), value[1].Trim(), temp.Value._strParamVal.ToString(), path);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show($"{strName} 参数异常:{e.Message}", "Warn", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
            }
        }
Exemplo n.º 8
0
        private void UpdateProductList()
        {
            treeView_ProdutFile.Nodes.Clear();
            treeView_ProdutFile.Nodes.Add("当前产品");
            treeView_ProdutFile.Nodes.Add("产品选择");
            if (ParamSetMgr.GetInstance().CurrentProductFile != null && ParamSetMgr.GetInstance().CurrentProductFile != "")
            {
                treeView_ProdutFile.Nodes[0].Nodes.Add(ParamSetMgr.GetInstance().CurrentProductFile);
                treeView_ProdutFile.Nodes[0].ImageIndex = 0;
            }
            DirectoryInfo[] dirInfo = ParamSetMgr.GetInstance().EnumProductFile();

            int pos;

            for (int i = 0; dirInfo != null && i < dirInfo.Length; i++)
            {
                pos = dirInfo[i].FullName.LastIndexOf("\\");
                string str = dirInfo[i].FullName.Substring(pos + 1, dirInfo[i].FullName.Length - pos - 1);
                if (str != ParamSetMgr.GetInstance().CurrentProductFile)
                {
                    treeView_ProdutFile.Nodes[1].Nodes.Add(str);
                }
            }
            treeView_ProdutFile.Nodes[0].Expand();
            if (treeView_ProdutFile.Nodes[0].FirstNode != null && treeView_ProdutFile.Nodes[0].FirstNode.Name != null && treeView_ProdutFile.Nodes[0].FirstNode.Text != "")
            {
                List <string> classList = ParamSetMgr.GetInstance().GetParamClassList();
                foreach (var temp in classList)
                {
                    treeView_ProdutFile.Nodes[0].Nodes[0].Nodes.Add(temp);
                }
            }
            treeView_ProdutFile.Nodes[0].ExpandAll();
            treeView_ProdutFile.Nodes[1].Expand();
        }
        /// <summary>
        /// strBoot为分辨率X,Y,    起始ROI X,Y,    ROI 长宽Width,Height  6个参数逗号隔开
        /// </summary>
        /// <param name="strBoot"></param>
        /// <returns></returns>
        public bool Init(string strBoot)
        {
            Stop();
            int nResolutionX = 0;
            int nResolutionY = 0;

            nResolutionX = ParamSetMgr.GetInstance().GetIntParam("校准相机分辨率X");
            nResolutionY = ParamSetMgr.GetInstance().GetIntParam("校准相机分辨率Y");
            if (strBoot == "")
            {
                strBoot = m_strSn;
            }
            cam = new VideoCaptureDevice(strBoot);
            if (cam != null)
            {
                cam.NewFrame += new NewFrameEventHandler(Cam_NewFrame1);
            }
            foreach (VideoCapabilities capab in cam.VideoCapabilities)
            {
                if (capab.FrameSize.Width == nResolutionX && capab.FrameSize.Height == nResolutionY)
                {
                    cam.VideoResolution = capab;
                    Play();
                    break;
                }
            }



            return(true);
        }
Exemplo n.º 10
0
        public void Read()
        {
            string strVisionConfigPath = VisionMgr.GetInstance().CurrentVisionProcessDir + "VisionMgr" + ".xml";

            if (VisionMgr.GetInstance().CurrentVisionProcessDir == null &&
                ParamSetMgr.GetInstance().CurrentProductFile == null &&
                ParamSetMgr.GetInstance().CurrentProductFile == "" &&
                !Directory.Exists(VisionMgr.GetInstance().CurrentVisionProcessDir))
            {
                Directory.CreateDirectory(VisionMgr.GetInstance().CurrentVisionProcessDir);
            }
            dicVisionType.Clear();
            dicVisionType = (SerialDictionary <string, StepVisionInfo>)AccessXmlSerializer.XmlToObject(strVisionConfigPath, dicVisionType.GetType());

            dicVision.Clear();
            if (dicVisionType == null)
            {
                dicVisionType = new SerialDictionary <string, StepVisionInfo>();
            }
            foreach (var temp in dicVisionType)
            {
                Type     type = AssemblyOperate.GetTypeFromAssembly(temp.Value.VisionType);
                object[] args = new object[]
                {
                    temp.Key
                };
                Add(temp.Key, Activator.CreateInstance(type, args) as VisionSetpBase);
                dicVision[temp.Key].Read();
                dicVision[temp.Key].m_camparam = temp.Value.CamParam;
            }
        }
Exemplo n.º 11
0
        private void LoadProductFile(string strFile)
        {
            if (InvokeRequired)
            {
                this.BeginInvoke(new Action(() => LoadProductFile(strFile)));
            }
            else
            {
                label_CurrentFile.Text = "当前产品:" + strFile;
                //读取工站位置坐标
                ConfigToolMgr.GetInstance().UpdatePointFilePath();
                Dictionary <string, PointInfo> dicPonit = new Dictionary <string, PointInfo>();
                foreach (var tem in StationMgr.GetInstance().GetAllStationName())
                {
                    ConfigToolMgr.GetInstance().ReadPoint(tem, out dicPonit);
                    StationMgr.GetInstance().GetStation(tem).SetStationPointDic(dicPonit);
                }
                ConfigToolMgr.GetInstance().UpdataMoveparamconfigPath();

                ConfigToolMgr.GetInstance().ReadMoveParamConfig();
                ConfigToolMgr.GetInstance().ReadHomeParamConfig();

                VisionMgr.GetInstance().CurrentVisionProcessDir = ParamSetMgr.GetInstance().CurrentWorkDir + "\\" + ParamSetMgr.GetInstance().CurrentProductFile + "\\" + @"Config\Vision\";
                VisionMgr.GetInstance().Read();

                ParamSetMgr.GetInstance().m_eventLoadProductFileUpadata?.Invoke();

                //VisionMgr.GetInstance().PrItemChangedEvent
                GC.Collect();
            }
        }
Exemplo n.º 12
0
        public void UpDataAllIo()
        {
            Dictionary <string, IOMgr.IoDefine> dicInput = IOMgr.GetInstace().GetInputDic();
            int indexIn = 0;

            foreach (var tem in dicInput)
            {
                m_labelControl_IoInput[indexIn++].State = IOMgr.GetInstace().ReadIoInBit(tem.Key);
            }

            Dictionary <string, IOMgr.IoDefine> dicOutput = IOMgr.GetInstace().GetOutputDic();
            int indexOut = 0;

            foreach (var tem in dicOutput)
            {
                if (!ParamSetMgr.GetInstance().GetBoolParam("是否用平行光管或中继镜气缸"))
                {
                    if (tem.Key == "平行光管升降气缸")
                    {
                        continue;
                    }
                }
                m_labelControl_IoOutput[indexOut++].State = IOMgr.GetInstace().ReadIoOutBit(tem.Key);
            }
        }
Exemplo n.º 13
0
        private void Form_CameraDebug_Load(object sender, EventArgs e)
        {
            visionControl1.InitWindow();
            HOperatorSet.SetDraw(visionControl1.GetHalconWindow(), "margin");
            Thread.Sleep(10);
            List <string> camname = CameraMgr.GetInstance().GetCameraNameArr();

            foreach (var temp in camname)
            {
                this.Sel.Items.Add(temp.ToString());
                comboBox_SelCam.Items.Add(temp.ToString());
                CameraMgr.GetInstance().ClaerPr(temp.ToString());
            }
            if (camname.Count > 0)
            {
                comboBox_SelCam.SelectedIndex = 0;
            }

            textBox_exposureTimeVal.Text = CameraMgr.GetInstance().GetCamExposure(comboBox_SelCam.Text).ToString();
            textBox_GainVal.Text         = CameraMgr.GetInstance().GetCamGain(comboBox_SelCam.Text).ToString();
            CameraMgr.GetInstance().BindWindow(comboBox_SelCam.Text, visionControl1);
            CameraMgr.GetInstance().SetAcquisitionMode(comboBox_SelCam.Text);
            UpdataVisionItems();
            ParamSetMgr.GetInstance().m_eventLoadProductFileUpadata += UpdataVisionItems;
        }
 public void CheckBuzzerPlaneAndUp(bool bManual = false)
 {
     if (IOMgr.GetInstace().ReadIoInBit("右装料平台有无感应器"))
     {
         Task task0 = new Task(() =>
         {
             ParamSetMgr.GetInstance().SetBoolParam("右装料平台上升到位", false);
             Info("装料步进运动");
             int pos = MotionMgr.GetInstace().GetAxisPos(AxisZ);
             pos     = pos + (int)(ParamSetMgr.GetInstance().GetDoubleParam("装料步长") * nResolutionZ);
             MoveSigleAxisPosWaitInpos(AxisZ, pos, MotionMgr.GetInstace().GetAxisMovePrm(AxisZ).VelH, 20, bManual, bManual ? null : this);
             ParamSetMgr.GetInstance().SetBoolParam("右装料平台上升到位", true);
         });
         task0.Start();
     }
     else
     {
         Task task = new Task(() =>
         {
             Info("回到原始位置");
             double pos = GetStationPointDic()["装料原始位"].pointZ;
             MoveSigleAxisPosWaitInpos(AxisZ, pos, MotionMgr.GetInstace().GetAxisMovePrm(AxisZ).VelH, 20, bManual, this);
             //AlarmMgr.GetIntance().WarnWithDlg("右剥料工站 装料平台无料,请添加蜂鸣片", bManual ? null : this, CommonDlg.DlgWaranType.WaranOK);
             AlarmMgr.GetIntance().WarnWithDlg("右剥料工站 装料平台无料,请添加蜂鸣片,添加完成点击OK", this, CommonDlg.DlgWaranType.WaranOK);
             FindBuzzer(bManual);
             ParamSetMgr.GetInstance().SetBoolParam("右装料平台上升到位", true);
         });
         task.Start();
         task.Wait();
     }
 }
Exemplo n.º 15
0
        /// <summary>
        /// 在启动/恢复程序前,检查安全门光栅
        /// </summary>
        /// <returns></returns>
        public bool IsSafeDoorAndGrating()
        {
            if (ParamSetMgr.GetInstance().GetBoolParam("启用安全门"))
            {
                if (IOMgr.GetInstace().GetOutputDic().ContainsKey("安全门") && !IOMgr.GetInstace().ReadIoInBit("安全门"))
                {
                    MessageBox.Show("安全门打开", "Warn", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    // WaranResult waranResult = AlarmMgr.GetIntance().WarnWithDlg("安全门打开", null, DlgWaranType.WaranOK);
                    return(false);
                }
            }
            if (IOMgr.GetInstace().GetOutputDic().ContainsKey("气源检测") && IOMgr.GetInstace().GetInputDic().ContainsKey("气源检测"))
            {
                if (!IOMgr.GetInstace().ReadIoInBit("气源检测"))
                {
                    MessageBox.Show("气源检测失败,请打开气源", "Warn", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    // WaranResult waranResult = AlarmMgr.GetIntance().WarnWithDlg("气源检测失败,请打开气源", null, DlgWaranType.WaranOK);
                    return(false);
                }
            }
            if (IOMgr.GetInstace().GetOutputDic().ContainsKey("真空气源检测") && IOMgr.GetInstace().GetInputDic().ContainsKey("真空气源检测"))
            {
                if (!IOMgr.GetInstace().ReadIoInBit("真空气源检测"))
                {
                    MessageBox.Show("真空气源检测失败,请打开真空气源", "Warn", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //  WaranResult waranResult = AlarmMgr.GetIntance().WarnWithDlg("真空气源检测失败,请打开真空气源", null, DlgWaranType.WaranOK);
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 16
0
 private void Form_AxisTest_Load(object sender, EventArgs e)
 {
     dataGridView_AxisParamSet.Location = new Point(0, 0);
     updatadataGridView();
     ParamSetMgr.GetInstance().m_eventLoadProductFileUpadata += updatadataGridView;
     sys.g_eventRightChanged += ChangedUserRight;
     sys.g_User = sys.g_User;
 }
Exemplo n.º 17
0
        private MSerialPort()
        {
            string COMA = ParamSetMgr.GetInstance().GetStringParam("A工位关闭曝光COM");
            string COMB = ParamSetMgr.GetInstance().GetStringParam("B工位关闭曝光COM");

            Para_Port[0] = new SerialPortOperation(COMA, 38400, Parity.None, 8, StopBits.One);
            Para_Port[1] = new SerialPortOperation(COMB, 38400, Parity.None, 8, StopBits.One);
        }
Exemplo n.º 18
0
 private void checkBox_ModeAirRun_CheckedChanged(object sender, EventArgs e)
 {
     if (checkBox_ModeAirRun.Checked)
     {
         checkBox_ModeRun.Checked = false;
     }
     sys.g_AppMode = checkBox_ModeAirRun.Checked ? AppMode.AirRun : AppMode.Run;
     ParamSetMgr.GetInstance().SetBoolParam("系统空跑", sys.g_AppMode == AppMode.AirRun);
 }
Exemplo n.º 19
0
 protected override bool InitStation()
 {
     ParamSetMgr.GetInstance().SetBoolParam("转盘站初始化完成", false);
     ParamSetMgr.GetInstance().SetIntParam("工位选择", -1);
     //ParamSetMgr.GetInstance().SetBoolParam
     ClearAllStep();
     PushMultStep((int)StationStep.Step_Init);
     return(true);
 }
Exemplo n.º 20
0
        public override bool Play(int nID)
        {
            bool result = CameUsb[nID].Play();

            if (ParamSetMgr.GetInstance().GetBoolParam("是否关闭曝光"))
            {
                MSerialPort.GetInstance().CloseExposure(nID);
            }
            return(result);
        }
Exemplo n.º 21
0
        private void Form_ParamSet_Load(object sender, EventArgs e)
        {
            sys.g_eventRightChanged += ChangedUserRight;
            ParamSetMgr.GetInstance().m_eventLoadProductFile += LoadProductFile;
            userRight = UserRight.User_None;
            int width = 0;

            for (int i = 0; i < dataGridView_Param.Columns.Count; i++)
            {
                width += dataGridView_Param.Columns[i].Width;
            }
            dataGridView_Param.Width = width + 35;
            sys.g_User             = sys.g_User;
            label_CurrentFile.Text = "当前产品:" + ParamSetMgr.GetInstance().CurrentProductFile;

            treeView_ProdutFile.Nodes.Add("当前产品");
            treeView_ProdutFile.Nodes.Add("产品选择");
            if (ParamSetMgr.GetInstance().CurrentProductFile != null && ParamSetMgr.GetInstance().CurrentProductFile != "")
            {
                treeView_ProdutFile.Nodes[0].Nodes.Add(ParamSetMgr.GetInstance().CurrentProductFile);
                treeView_ProdutFile.Nodes[0].ImageIndex = 0;
            }



            DirectoryInfo[] dirInfo = ParamSetMgr.GetInstance().EnumProductFile();

            int pos;

            for (int i = 0; dirInfo != null && i < dirInfo.Length; i++)
            {
                pos = dirInfo[i].FullName.LastIndexOf("\\");
                string str = dirInfo[i].FullName.Substring(pos + 1, dirInfo[i].FullName.Length - pos - 1);
                if (str != ParamSetMgr.GetInstance().CurrentProductFile)
                {
                    treeView_ProdutFile.Nodes[1].Nodes.Add(str);
                }
            }
            treeView_ProdutFile.Nodes[0].Expand();
            if (treeView_ProdutFile.Nodes[0].FirstNode != null && treeView_ProdutFile.Nodes[0].FirstNode.Name != null && treeView_ProdutFile.Nodes[0].FirstNode.Text != "")
            {
                List <string> classList = ParamSetMgr.GetInstance().GetParamClassList();
                foreach (var temp in classList)
                {
                    treeView_ProdutFile.Nodes[0].Nodes[0].Nodes.Add(temp);
                }
            }
            treeView_ProdutFile.Nodes[0].ExpandAll();
            treeView_ProdutFile.Nodes[1].Expand();
            // m_path = ParamSetMgr.GetInstance().CurrentWorkFile;
            //加载描述文件
            string path = $"{ParamSetMgr.GetInstance().CurrentWorkDir}\\{ParamSetMgr.GetInstance().CurrentProductFile}\\Description.xml";

            DescriptionClass.paramValue = AccessXmlSerializer.XmlToObject <List <ParamValue> >(path);
        }
Exemplo n.º 22
0
 public void Save()
 {
     tol.nSumProduct          = ParamSetMgr.GetInstance().GetDoubleParam("产品计数");
     tol.nLeftProduct         = ParamSetMgr.GetInstance().GetDoubleParam("左废纸数");
     tol.nRightProduct        = ParamSetMgr.GetInstance().GetDoubleParam("右废纸数");
     tol.nLoadNozzleWorkNum   = ParamSetMgr.GetInstance().GetDoubleParam("上料吸嘴数");
     tol.nUnLoadNozzleWorkNum = ParamSetMgr.GetInstance().GetDoubleParam("下料吸嘴数");
     tol.nLeftNozzleWorkNum   = ParamSetMgr.GetInstance().GetDoubleParam("左贴装吸嘴数");
     tol.nRightNozzleWorkNum  = ParamSetMgr.GetInstance().GetDoubleParam("右贴装吸嘴数");
     AccessXmlSerializer.ObjectToXml("d:\\Sum.xml", this);
 }
Exemplo n.º 23
0
 private void checkBox_UseSafeGate_CheckedChanged(object sender, EventArgs e)
 {
     if (checkBox_UseSafeGate.Checked)
     {
         ParamSetMgr.GetInstance().SetBoolParam("启用安全光栅", true);
     }
     else
     {
         ParamSetMgr.GetInstance().SetBoolParam("启用安全光栅", false);
     }
 }
Exemplo n.º 24
0
        public override bool GetSFRValue(Bitmap bmp, ref SFRValue SFRValue, ref RectInfo rectInfo, Rectangle[] rectangles, ref LightValue lightValue, bool TestLight = false)
        {
            SFRInfo info = new SFRInfo();
            //   Rectangle[] rectangles = new Rectangle[13];
            SFR_C_Info sFR_C_Info = new SFR_C_Info();
            SFR_C_Info YData      = new SFR_C_Info();
            double     frequency  = ParamSetMgr.GetInstance().GetDoubleParam("[SFR] dSFR_Parameter");
            bool       bRet       = false;

            try
            {
                if (bmp == null)
                {
                    return(false);
                }
                Bitmap temp     = (Bitmap)bmp.Clone();
                int    nWidth   = temp.Width;
                int    nHeight  = temp.Height;
                byte[] byBuffer = ImageChangeHelper.Instance.Rgb2Gray(bmp);
                unsafe
                {
                    fixed(byte *byBufferptr = byBuffer)
                    {
                        bRet = ActiveAlignment.CalibrationMode_Collimators(byBufferptr, nWidth, nHeight, ref sFR_C_Info, ref YData);
                    }
                }
                temp.Dispose();
                //sfr 转换
                SFRValue = AlgChangeHelper.Collimator_Info2Value(sFR_C_Info);
                rectInfo = AlgChangeHelper.Collimator_Info2Rect(sFR_C_Info);
            }
            catch { }
            double[] value = new double[5];
            try
            {
                value[0] = YData.block[0].dValue;
                value[1] = YData.block[1].dValue;
                value[2] = YData.block[2].dValue;
                value[3] = YData.block[3].dValue;
                value[4] = YData.block[4].dValue;
            }
            catch (Exception ex)
            {
                value[0] = -1;
                value[1] = -1;
                value[2] = -1;
                value[3] = -1;
                value[4] = -1;
                //return false;
            }
            lightValue.blockValue = value;

            return(bRet);
        }
Exemplo n.º 25
0
        private void button_start_Click(object sender, EventArgs e)
        {
            // ProcessSysIo("启动", true);
            if (GlobalVariable.g_StationState == StationState.StationStateStop)
            {
                if (!IsSafeDoorAndGrating())
                {
                    return;
                }

                ParamSetMgr.GetInstance().SetBoolParam("启动清料", false);
                if (IOMgr.GetInstace().GetOutputDic().ContainsKey("绿灯"))
                {
                    IOMgr.GetInstace().WriteIoBit("绿灯", false);
                }
                if (IOMgr.GetInstace().GetOutputDic().ContainsKey("红灯"))
                {
                    IOMgr.GetInstace().WriteIoBit("红灯", false);
                }
                if (IOMgr.GetInstace().GetOutputDic().ContainsKey("黄灯"))
                {
                    IOMgr.GetInstace().WriteIoBit("黄灯", true);
                }
                if (IOMgr.GetInstace().GetOutputDic().ContainsKey("蜂鸣"))
                {
                    IOMgr.GetInstace().WriteIoBit("蜂鸣", false);
                }
                StationMgr.GetInstance().Run();
                // sys.g_StationState = StationState.StationStateRun;
            }
            else if (GlobalVariable.g_StationState == StationState.StationStateRun)
            {
                // sys.g_StationState = StationState.StationStatePause;
                //暂停
                StationMgr.GetInstance().Pause();
            }
            else if (GlobalVariable.g_StationState == StationState.StationStatePause)
            {
                if (!IsSafeDoorAndGrating())
                {
                    return;
                }
                IOMgr.GetInstace().WriteIoBit("绿灯", false);
                IOMgr.GetInstace().WriteIoBit("红灯", false);
                IOMgr.GetInstace().WriteIoBit("黄灯", true);
                IOMgr.GetInstace().WriteIoBit("蜂鸣", false);
                StationMgr.GetInstance().Resume();
            }
            else if (GlobalVariable.g_StationState == StationState.StationStateEmg)
            {
                MessageBox.Show("发生错误,请先复位", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 26
0
 private APP()
 {
     MotionMgr      = MotionMgr.GetInstace();
     IOMgr          = IOMgr.GetInstace();
     AlarmMgr       = AlarmMgr.GetIntance();
     ConfigToolMgr  = ConfigToolMgr.GetInstance();
     StationMgr     = StationMgr.GetInstance();
     ParamSetMgr    = ParamSetMgr.GetInstance();
     ComMgr         = ComMgr.GetInstance();
     TcpMgr         = TcpMgr.GetInstance();
     SocketSeverMgr = SocketSeverMgr.GetInstace();
 }
Exemplo n.º 27
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            if (!Check())
            {
                return;
            }
            string strParamName       = "";
            string currentProductFile = ParamSetMgr.GetInstance().CurrentWorkDir + ("\\") + ParamSetMgr.GetInstance().CurrentProductFile + ("\\") + ParamSetMgr.GetInstance().CurrentProductFile + (".xml");

            if (!Directory.Exists(ParamSetMgr.GetInstance().CurrentWorkDir + ("\\") + ParamSetMgr.GetInstance().CurrentProductFile))
            {
                MessageBox.Show("没有新建产品文件夹,请新建或另存", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            // if (!File.Exists(currentProductFile))
            //{
            //    MessageBox.Show("没有载入产品文件,请载入", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //    return ;
            //}
            for (int i = 0; i < dataGridView_Param.RowCount; i++)
            {
                if (dataGridView_Param.Rows[i].Cells[0].Value != null && dataGridView_Param.Rows[i].Cells[0].Value.ToString() != "")
                {
                    strParamName = dataGridView_Param.Rows[i].Cells[0].Value.ToString();
                    ParamSet paramSet = new ParamSet()
                    {
                        _enuValType     = dataGridView_Param.Rows[i].Cells[0].Value == null ? ParamSetUnit.doubleUnit : (ParamSetUnit)Enum.Parse(typeof(ParamSetUnit), dataGridView_Param.Rows[i].Cells[1].Value.ToString()),
                        _strParamVal    = dataGridView_Param.Rows[i].Cells[2].Value == null ? "0" : dataGridView_Param.Rows[i].Cells[2].Value.ToString(),
                        _strParamValMax = dataGridView_Param.Rows[i].Cells[3].Value == null ? "0" : dataGridView_Param.Rows[i].Cells[3].Value.ToString(),
                        _strParamValMin = dataGridView_Param.Rows[i].Cells[4].Value == null ? "0" : dataGridView_Param.Rows[i].Cells[4].Value.ToString(),
                        _ParamRight     = dataGridView_Param.Rows[i].Cells[5].Value == null ? UserRight.客户操作员 : (UserRight)Enum.Parse(typeof(UserRight), dataGridView_Param.Rows[i].Cells[5].Value.ToString()),
                        _ParamClass     = dataGridView_Param.Rows[i].Cells[6].Value == null ? "综合" : dataGridView_Param.Rows[i].Cells[6].Value.ToString(),
                    };

                    //if (ParamSetMgr.GetInstance().GetParam(strParamName) != paramSet._strParamVal)
                    //    logger.Info($"用户{sys.g_User._userName},修改参数:{strParamName} ,原来值:{ParamSetMgr.GetInstance().GetParam(strParamName)},现在值:{ paramSet._strParamVal} ");

                    ParamSetMgr.GetInstance().SetParam(strParamName, paramSet);

                    ParamSet ds = new ParamSet()
                    {
                        _enuValType     = dataGridView_Param.Rows[i].Cells[0].Value == null ? ParamSetUnit.doubleUnit : (ParamSetUnit)Enum.Parse(typeof(ParamSetUnit), dataGridView_Param.Rows[i].Cells[1].Value.ToString()),
                        _strParamVal    = dataGridView_Param.Rows[i].Cells[2].Value == null ? "0" : dataGridView_Param.Rows[i].Cells[2].Value.ToString(),
                        _strParamValMax = dataGridView_Param.Rows[i].Cells[3].Value == null ? "0" : dataGridView_Param.Rows[i].Cells[3].Value.ToString(),
                        _strParamValMin = dataGridView_Param.Rows[i].Cells[4].Value == null ? "0" : dataGridView_Param.Rows[i].Cells[4].Value.ToString(),
                        _ParamRight     = dataGridView_Param.Rows[i].Cells[5].Value == null ? UserRight.客户操作员 : (UserRight)Enum.Parse(typeof(UserRight), dataGridView_Param.Rows[i].Cells[5].Value.ToString()),
                        _ParamClass     = dataGridView_Param.Rows[i].Cells[6].Value == null ? "综合" : dataGridView_Param.Rows[i].Cells[6].Value.ToString(),
                    };
                }
            }
            ParamSetMgr.GetInstance().SaveParam(currentProductFile);
        }
Exemplo n.º 28
0
        public static bool ReadVisionData()
        {
            //视觉初始化
            string strVisionConfigPath = AppDomain.CurrentDomain.BaseDirectory + @"config\Vision\" + "VisionMgr" + ".xml";

            VisionMgr.GetInstance().CurrentVisionProcessDir = ParamSetMgr.GetInstance().CurrentWorkDir + "\\" + ParamSetMgr.GetInstance().CurrentProductFile + "\\" + @"Config\Vision\";
            VisionMgr.GetInstance().Read();
            if (VisionMgr.GetInstance().dicVisionType.Count == 0 && bHaveVissionProcess)
            {
                AlarmMgr.GetIntance().WarnWithDlg("视觉处理文件文件丢失", null, CommonDlg.DlgWaranType.WaranOK, null, true);
            }
            return(true);
        }
Exemplo n.º 29
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            if (!Check())
            {
                return;
            }
            string strParamName       = "";
            string currentProductFile = ParamSetMgr.GetInstance().CurrentWorkDir + ("\\") + ParamSetMgr.GetInstance().CurrentProductFile + ("\\") + ParamSetMgr.GetInstance().CurrentProductFile + (".xml");

            if (!Directory.Exists(ParamSetMgr.GetInstance().CurrentWorkDir + ("\\") + ParamSetMgr.GetInstance().CurrentProductFile))
            {
                MessageBox.Show("没有新建产品文件夹,请新建或另存", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (!File.Exists(currentProductFile))
            {
                MessageBox.Show("没有载入产品文件,请载入", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            for (int i = 0; i < dataGridView_Param.RowCount; i++)
            {
                if (dataGridView_Param.Rows[i].Cells[0].Value != null && dataGridView_Param.Rows[i].Cells[0].Value.ToString() != "")
                {
                    strParamName = dataGridView_Param.Rows[i].Cells[0].Value.ToString();
                    ParamSetMgr.GetInstance().SetParam(strParamName, new ParamSet
                    {
                        _enuValType     = dataGridView_Param.Rows[i].Cells[0].Value == null ? ParamSetUnit.doubleUnit : (ParamSetUnit)Enum.Parse(typeof(ParamSetUnit), dataGridView_Param.Rows[i].Cells[1].Value.ToString()),
                        _strParamVal    = dataGridView_Param.Rows[i].Cells[2].Value == null ? "0" : dataGridView_Param.Rows[i].Cells[2].Value.ToString(),
                        _strParamValMax = dataGridView_Param.Rows[i].Cells[3].Value == null ? "0" : dataGridView_Param.Rows[i].Cells[3].Value.ToString(),
                        _strParamValMin = dataGridView_Param.Rows[i].Cells[4].Value == null ? "0" : dataGridView_Param.Rows[i].Cells[4].Value.ToString(),
                        _ParamRight     = dataGridView_Param.Rows[i].Cells[5].Value == null ? UserRight.客户操作员 : (UserRight)Enum.Parse(typeof(UserRight), dataGridView_Param.Rows[i].Cells[5].Value.ToString()),
                        _ParamClass     = dataGridView_Param.Rows[i].Cells[6].Value == null ? "综合" : dataGridView_Param.Rows[i].Cells[6].Value.ToString(),
                    });

                    ParamSet ds = new ParamSet()
                    {
                        _enuValType     = dataGridView_Param.Rows[i].Cells[0].Value == null ? ParamSetUnit.doubleUnit : (ParamSetUnit)Enum.Parse(typeof(ParamSetUnit), dataGridView_Param.Rows[i].Cells[1].Value.ToString()),
                        _strParamVal    = dataGridView_Param.Rows[i].Cells[2].Value == null ? "0" : dataGridView_Param.Rows[i].Cells[2].Value.ToString(),
                        _strParamValMax = dataGridView_Param.Rows[i].Cells[3].Value == null ? "0" : dataGridView_Param.Rows[i].Cells[3].Value.ToString(),
                        _strParamValMin = dataGridView_Param.Rows[i].Cells[4].Value == null ? "0" : dataGridView_Param.Rows[i].Cells[4].Value.ToString(),
                        _ParamRight     = dataGridView_Param.Rows[i].Cells[5].Value == null ? UserRight.客户操作员 : (UserRight)Enum.Parse(typeof(UserRight), dataGridView_Param.Rows[i].Cells[5].Value.ToString()),
                        _ParamClass     = dataGridView_Param.Rows[i].Cells[6].Value == null ? "综合" : dataGridView_Param.Rows[i].Cells[6].Value.ToString(),
                    };
                }
            }
            ParamSetMgr.GetInstance().SaveParam(currentProductFile);
            string path = $"{AppDomain.CurrentDomain.BaseDirectory}NST_ActiveAlignment.ini";

            XmlToAlgIni(path);
            AlgorithmMgr.Instance.LoadConfig(path);
        }
Exemplo n.º 30
0
        private void SaveMotorParam_Click(object sender, EventArgs e)
        {
            if (!Directory.Exists(ParamSetMgr.GetInstance().CurrentWorkDir + ("\\") + ParamSetMgr.GetInstance().CurrentProductFile) ||
                ParamSetMgr.GetInstance().CurrentProductFile == null || ParamSetMgr.GetInstance().CurrentProductFile == "")
            {
                MessageBox.Show("当前产品文件夹不存在,请创建载入或者创建当前产品", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            TMovePrm prm       = new TMovePrm();
            THomePrm homePrm   = new THomePrm();
            int      indexCell = 0;

            for (int index = 0; index < dataGridView_AxisParamSet.RowCount; index++)
            {
                int nAxisNo = Convert.ToInt32(dataGridView_AxisParamSet.Rows[index].Cells[0].Value);

                prm.VelH = Convert.ToDouble(dataGridView_AxisParamSet.Rows[index].Cells[3].Value);
                prm.AccH = Convert.ToDouble(dataGridView_AxisParamSet.Rows[index].Cells[4].Value);
                prm.DccH = Convert.ToDouble(dataGridView_AxisParamSet.Rows[index].Cells[5].Value);

                prm.VelM = Convert.ToDouble(dataGridView_AxisParamSet.Rows[index].Cells[6].Value);
                prm.AccM = Convert.ToDouble(dataGridView_AxisParamSet.Rows[index].Cells[7].Value);
                prm.DccM = Convert.ToDouble(dataGridView_AxisParamSet.Rows[index].Cells[8].Value);

                prm.VelL          = Convert.ToDouble(dataGridView_AxisParamSet.Rows[index].Cells[9].Value);
                prm.AccL          = Convert.ToDouble(dataGridView_AxisParamSet.Rows[index].Cells[10].Value);
                prm.DccL          = Convert.ToDouble(dataGridView_AxisParamSet.Rows[index].Cells[11].Value);
                prm.PlusePerRote  = Convert.ToDouble(dataGridView_AxisParamSet.Rows[index].Cells[12].Value);
                prm.AxisLeadRange = Convert.ToDouble(dataGridView_AxisParamSet.Rows[index].Cells[13].Value);
                MotionMgr.GetInstace().SetAxisMoveParam(nAxisNo, prm);
                MotionMgr.GetInstace().SetAxisName(nAxisNo, dataGridView_AxisParamSet.Rows[index].Cells[1].Value == null ? "NoNamedAxis" : dataGridView_AxisParamSet.Rows[index].Cells[1].Value.ToString());
                string strAxisType = dataGridView_AxisParamSet.Rows[index].Cells[2].Value == null?MotorType.SEVER.ToString() : dataGridView_AxisParamSet.Rows[index].Cells[2].Value.ToString();

                MotionMgr.GetInstace().SetMotorType(nAxisNo, (MotorType)Enum.Parse(typeof(MotorType), strAxisType));

                indexCell                 = 2;
                homePrm._nHomeMode        = Convert.ToInt32(dataGridView_HomeSet.Rows[index].Cells[indexCell++].Value);
                homePrm._bHomeDir         = Convert.ToBoolean(dataGridView_HomeSet.Rows[index].Cells[indexCell++].Value);
                homePrm.VelH              = Convert.ToDouble(dataGridView_HomeSet.Rows[index].Cells[indexCell++].Value);
                homePrm.AccH              = Convert.ToDouble(dataGridView_HomeSet.Rows[index].Cells[indexCell++].Value);
                homePrm.DccH              = Convert.ToDouble(dataGridView_HomeSet.Rows[index].Cells[indexCell++].Value);
                homePrm.VelL              = Convert.ToDouble(dataGridView_HomeSet.Rows[index].Cells[indexCell++].Value);
                homePrm.AccL              = Convert.ToDouble(dataGridView_HomeSet.Rows[index].Cells[indexCell++].Value);
                homePrm.DccL              = Convert.ToDouble(dataGridView_HomeSet.Rows[index].Cells[indexCell++].Value);
                homePrm._iSeachOffstPluse = Convert.ToDouble(dataGridView_HomeSet.Rows[index].Cells[indexCell++].Value);
                MotionMgr.GetInstace().SetAxisHomeParam(nAxisNo, homePrm);
            }
            ConfigToolMgr.GetInstance().SaveMoveParam();
            ConfigToolMgr.GetInstance().SaveHomeParam();
        }