Exemple #1
0
        public frmC机械手(Form _Owner, int iTop)
        {
            InitializeComponent();

            this.MdiParent = _Owner;
            cForm.iTop     = iTop;
            LoadWins();
            this.Top = (int)cForm.m_Location.Y + cForm.iTop;

            CMach.MachByStation(40);
            this.DoubleBuffered = true;

            CStation Sta = frmMain.staComm.GetStaByStaName("NJ301");

            SPLC  = (CProtcolFINS)Sta;
            DI074 = frmMain.staComm.GetVarByStaNameVarName("NJ301", "DI074");
            DI075 = frmMain.staComm.GetVarByStaNameVarName("NJ301", "DI075");
            DI076 = frmMain.staComm.GetVarByStaNameVarName("NJ301", "DI076");
            DI110 = frmMain.staComm.GetVarByStaNameVarName("NJ301", "DI110");
            DI111 = frmMain.staComm.GetVarByStaNameVarName("NJ301", "DI111");

            //启动端口数据收发线程
            CTran.Setting = CMach.Setting;
            CTran.fm      = this;
            CTran.Open();
            TPortThread              = new Thread(new ThreadStart(CTPortThread));
            TPortThread.Name         = "TPortThread";
            TPortThread.IsBackground = true;
            TPortThread.Start();
            splitContainer2.Visible = false;
        }
Exemple #2
0
        private void frmC机械手_MouseDown(object sender, MouseEventArgs e)
        {
            int    i      = 0;
            PointF MouseP = new PointF(e.X, e.Y);;

            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                for (i = ListTuYuan.Count - 1; i > -1; i--)
                {
                    CBase obj = (CBase)ListTuYuan[i];
                    if (obj.ElementType == LCElementType.Ring)
                    {
                        if (obj.Selected(MouseP))
                        {
                            CRing nRing = (CRing)obj;

                            string       sVar = "AV" + nRing.ShowText.PadLeft(3, '0');
                            CStation     Sta  = frmMain.staComm.GetStaByStaName("NJ301");
                            CProtcolFINS SPLC = (CProtcolFINS)Sta;
                            SPLC.SendAODO(sVar, 0, "DO");
                            break;
                        }
                    }
                }
            }
        }
Exemple #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            CVar              nVar1 = frmMain.staComm.GetVarByStaNameVarName(sListStaName[0], "I_W");
            CVar              nVar2 = frmMain.staComm.GetVarByStaNameVarName(sListStaName[1], "I_W");
            CVar              nVar3 = frmMain.staComm.GetVarByStaNameVarName(sListStaName[2], "I_W");
            CStation          Sta1  = frmMain.staComm.GetStaByStaName(sListStaName[0]);
            CProtcolModbusTCP STCP1 = (CProtcolModbusTCP)Sta1;
            CStation          Sta2  = frmMain.staComm.GetStaByStaName(sListStaName[1]);
            CProtcolModbusTCP STCP2 = (CProtcolModbusTCP)Sta2;
            CStation          Sta3  = frmMain.staComm.GetStaByStaName(sListStaName[2]);
            CProtcolModbusTCP STCP3 = (CProtcolModbusTCP)Sta3;

            double iValue1 = nVar1.GetDoubleValue() + Convert.ToDouble(textBox1.Text);
            int    fSend1  = (int)Math.Round(iValue1 / nVar1.RatioValue);

            STCP1.SendAODO(nVar1.ByteAddr, (int)fSend1, 6);

            double iValue2 = nVar2.GetDoubleValue() + Convert.ToDouble(textBox2.Text);
            int    fSend2  = (int)Math.Round(iValue2 / nVar2.RatioValue);

            STCP2.SendAODO(nVar3.ByteAddr, (int)fSend2, 6);

            double iValue3 = nVar3.GetDoubleValue() + Convert.ToDouble(textBox3.Text);
            int    fSend3  = (int)Math.Round(iValue3 / nVar3.RatioValue);

            STCP3.SendAODO(nVar3.ByteAddr, (int)fSend3, 6);
        }
Exemple #4
0
        private void FillDGV(DataGridView dGV)
        {
            CStation          Sta  = frmMain.staComm.GetStaByStaName(sListStaName[0]);
            CProtcolModbusTCP STCP = (CProtcolModbusTCP)Sta;

            dGV.RowCount = sListVarName.Length + 3;
            for (int i = 0; i < sListVarName.Length; i++)
            {
                dGV.Rows[i].Cells[0].Value = sListVarName[i];
                dGV.Rows[i].Cells[1].Value = frmMain.staComm.GetVarByStaNameVarName(sListStaName[0], sListVarName[i]).ByteAddr;
                dGV.Rows[i].Cells[2].Value = frmMain.staComm.GetVarByStaNameVarName(sListStaName[0], sListVarName[i]).GetStringValue(sListDF[i]);
                dGV.Rows[i].Cells[3].Value = frmMain.staComm.GetVarByStaNameVarName(sListStaName[1], sListVarName[i]).GetStringValue(sListDF[i]);
                dGV.Rows[i].Cells[4].Value = frmMain.staComm.GetVarByStaNameVarName(sListStaName[2], sListVarName[i]).GetStringValue(sListDF[i]);
            }
            dGV.Rows[sListVarName.Length + 1].Cells[1].ReadOnly = false;
            dGV.Rows[sListVarName.Length + 2].Cells[1].ReadOnly = false;

            dGV.Rows[sListVarName.Length + 1].Cells[0].Value = "手写";
            dGV.Rows[sListVarName.Length + 2].Cells[0].Value = "手写";

            dGV.Rows[0].DefaultCellStyle.BackColor = Color.LightGray;
            dGV.Rows[1].DefaultCellStyle.BackColor = Color.LightGray;

            dGV.Rows[sListVarName.Length + 1].DefaultCellStyle.BackColor = Color.Lime;
            dGV.Rows[sListVarName.Length + 2].DefaultCellStyle.BackColor = Color.Lime;
        }
Exemple #5
0
        private void frm设置_Load(object sender, EventArgs e)
        {
            CStation Sta = frmMain.staComm.GetStaByStaName("NJ301");

            SPLC = (CProtcolFINS)Sta;
            //SPLC.SendReadIdle();

            LoadXML();
            FillGrid();
        }
Exemple #6
0
        public frmC生长室维护(Form _Owner, int iTop)
        {
            InitializeComponent();
            CStation Sta = frmMain.staComm.GetStaByStaName("NJ301");

            SPLC = (CProtcolFINS)Sta;

            this.MdiParent = _Owner;
            LoadWins();
            LoadFromPLC();
            button1.Visible = false;
            this.Top        = (int)cForm.m_Location.Y + iTop;

            this.DoubleBuffered = true;
        }
Exemple #7
0
        public frmC温度控制(Form _Owner, int iTop)
        {
            InitializeComponent();

            this.MdiParent      = _Owner;
            this.DoubleBuffered = true;

            this.Top = iTop;
            CStation Sta = frmMain.staComm.GetStaByStaName("NJ301");

            SPLC = (CProtcolFINS)Sta;
            FillDGV(dGV1);

            FillGrid2();
        }
        private void butAdd1_Click(object sender, EventArgs e)
        {
            butApply.Enabled = true;
            Button nBut = (Button)sender;
            int    i    = Convert.ToInt32(nBut.Name.Substring(6, 1)) - 1;

            TreeNode node  = treeView1.SelectedNode;
            string   sType = node.Name.Substring(0, 3);

            if (sType == "Var")
            {
                int      iSta = Convert.ToInt32(node.Parent.Name.Substring(4));
                int      iVar = Convert.ToInt32(node.Name.Substring(4));
                CStation sta2 = frmMain.staComm.ListStation[iSta];
                CVar     nVar = sta2.StaDevice.ListDevVar[iVar];
                if (nVar != null)
                {
                    foreach (CLSCurve cCur in ListCur)
                    {
                        if (nVar == cCur.cVar)
                        {
                            MessageBox.Show("该变量已添加!", "错误");
                            return;
                        }
                    }
                    CLSCurve nCur = new CLSCurve(nVar);
                    nCur.iYAxis = i;
                    if (iSelIndex <= i)
                    {
                        iSelIndex = i + 1;
                    }
                    for (int j = 0; j < ListCur.Count; j++)
                    {
                        if (i < ListCur[j].iYAxis)
                        {
                            ListCur.Insert(j, nCur);
                            RefreshDGW(ListCur.IndexOf(nCur));
                            return;
                        }
                    }
                    ListCur.Add(nCur);
                    RefreshDGW(ListCur.IndexOf(nCur));
                }
            }
        }
Exemple #9
0
        public void LoadFromXML()
        {
            /// 创建XmlDocument类的实例
            XmlDocument myxmldoc = new XmlDocument();
            string      sPath    = CProject.sPrjPath + "\\Alarm.xml";

            myxmldoc.Load(sPath);

            string     xpath   = "System/" + CProject.sPrjName;
            XmlElement PrjNode = (XmlElement)myxmldoc.SelectSingleNode(xpath);

            ListVarAlarm.Clear();
            foreach (XmlElement StaNode in PrjNode.ChildNodes)
            {
                if (StaNode.Name == "Alarms")
                {
                    continue;
                }
                CStation nSta = frmMain.staComm.GetStaByStaName(StaNode.Name);
                if (nSta == null)
                {
                    continue;
                }
                xpath = "Alarms/Vars";
                XmlElement VarsNode = (XmlElement)StaNode.SelectSingleNode(xpath);
                if (VarsNode == null)
                {
                    continue;
                }
                foreach (XmlElement VarNode in VarsNode.ChildNodes)
                {
                    CVar nVar = frmMain.staComm.GetVarByStaNameVarName(nSta.Name, VarNode.Name);
                    if (nVar == null)
                    {
                        continue;
                    }
                    CVarAlarm newAlarm = new CVarAlarm();
                    newAlarm.LoadFromNode(VarNode);

                    ListVarAlarm.Add(newAlarm);
                    nVar.VarAlarm = newAlarm;
                }//end foreach (XmlElement VarNode in VarsNode.ChildNodes)
            }
        }
Exemple #10
0
        private void UpdatePLCValue()
        {
            CStation Sta = frmMain.staComm.GetStaByStaName("NJ301");

            for (int i = 0; i < dGV1.RowCount; i++)
            {
                string sName = dGV1.Rows[i].Cells[1].Value.ToString();
                CVar   nVar  = frmMain.staComm.GetVarByStaNameVarName("NJ301", sName);
                if (nVar == null)
                {
                    continue;
                }

                int k = 6;
                if (nVar.Name == "A_52" || nVar.Name == "A_53" || nVar.Name == "A_54" || nVar.Name == "A_55")
                {
                    dGV1.Rows[i].Cells[k++].Value = (((float)nVar.PLCValue[3] / 10)).ToString("f1");
                    dGV1.Rows[i].Cells[k++].Value = (((float)nVar.PLCValue[4] / 10)).ToString("f1");
                    dGV1.Rows[i].Cells[k++].Value = (((float)nVar.PLCValue[5] / 10)).ToString("f1");
                }
                else
                {
                    dGV1.Rows[i].Cells[k++].Value = nVar.PLCValue[3].ToString();
                    dGV1.Rows[i].Cells[k++].Value = nVar.PLCValue[4].ToString();
                    dGV1.Rows[i].Cells[k++].Value = nVar.PLCValue[5].ToString();
                }
            }

            num1022.Value = Math.Min(num1022.Maximum, SPLC.System[21]); //源瓶吹扫次数
            num1023.Value = Math.Min(num1023.Maximum, SPLC.System[22]); //源瓶吹扫时间s
            num1032.Value = Math.Min(num1032.Maximum, SPLC.System[31]); //生长室吹扫次数
            num1033.Value = Math.Min(num1033.Maximum, SPLC.System[32]); //生长室吹扫时间s

            num1026.Value = Math.Min(num1026.Maximum, SPLC.System[25]); //进样室抽气压力(torr)
            num1027.Value = Math.Min(num1027.Maximum, SPLC.System[26]); //进样室充气压力(sccm)
            num1028.Value = Math.Min(num1028.Maximum, SPLC.System[27]); //进样室吹扫次数设定
            num1030.Value = Math.Min(num1030.Maximum, SPLC.System[29]); //进样室Idle设定压力
            num1031.Value = Math.Min(num1031.Maximum, SPLC.System[30]); //大气压值
            num1036.Value = Math.Min(num1036.Maximum, SPLC.System[35]); //Hot Idle伺服速度设定值

            CBox1013.SelectedIndex = Math.Min(SPLC.System[12], 1);      //程序完成后运行
            CBox1014.SelectedIndex = Math.Min(SPLC.System[13], 1);      //程序退出后运行
        }
Exemple #11
0
        private void UpdateValue()
        {
            try
            {
                for (int i = 0; i < dGV1.Rows.Count; i++)
                {
                    string   sSta = (string)dGV1.Rows[i].Cells[0].Value;
                    CStation nSta = frmMain.staComm.GetStaByStaName(sSta);

                    dGV1.Rows[i].Cells[5].Value             = nSta.CommStateS;
                    dGV1.Rows[i].Cells[6].Value             = nSta.RunStateS;
                    dGV1.Rows[i].DefaultCellStyle.BackColor = nSta.CommStateC;
                }
            }
            catch (Exception e)
            {
                //MessageBox.Show(e.Message, "警告");
            }
        }
Exemple #12
0
        private void dGV1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex >= 2 && e.RowIndex > 1)
            {
                DataGridView dGV  = (DataGridView)sender;
                int          iSta = e.ColumnIndex - 2;

                CStation          Sta  = frmMain.staComm.GetStaByStaName(sListStaName[iSta]);
                CProtcolModbusTCP STCP = (CProtcolModbusTCP)Sta;
                if (STCP == null)
                {
                    return;
                }
                try
                {
                    int iVar = e.RowIndex;
                    if (iVar < sListVarName.Length)
                    {
                        CVar  nVar   = frmMain.staComm.GetVarByStaNameVarName(sListStaName[iSta], sListVarName[iVar]);
                        float iValue = Convert.ToSingle(dGV1.Rows[iVar].Cells[2 + iSta].Value);
                        int   fSend  = (int)Math.Round(iValue / nVar.RatioValue);
                        STCP.SendAODO(nVar.ByteAddr, fSend, 6);
                    }
                    else if (iVar == sListVarName.Length + 1 || iVar == sListVarName.Length + 2)
                    {
                        int iValue = Convert.ToInt32(dGV1.Rows[iVar].Cells[2 + iSta].Value);
                        int iAdd   = Convert.ToInt32(dGV.Rows[iVar].Cells[1].Value);
                        if (iAdd > 0)
                        {
                            STCP.SendAODO(iAdd, iValue, 6);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Exemple #13
0
        private void dGV1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            string   sSta = (string)dGV1.Rows[e.RowIndex].Cells[0].Value;
            CStation nSta = frmMain.staComm.GetStaByStaName(sSta);

            if (nSta == null)
            {
                return;
            }
            if (nSta.StaDevice.PortProtocol == "Modbus_TCP")
            {
                CProtcolModbusTCP nnn = (CProtcolModbusTCP)nSta;
                nnn.Show(true);
                nnn.bDebug = false;
            }
            if (nSta.StaDevice.PortProtocol == "FINS_TCP")
            {
                CProtcolFINS nnn = (CProtcolFINS)nSta;
                nnn.Show(true);
                nnn.bDebug = false;
            }
        }