private void frmChild_MouseDown(object sender, MouseEventArgs e)//鼠标点击 { int i = 0; PointF MouseP = new PointF((e.X - frmMain.iLeftD) / frmMain.iWinFoucs, (e.Y - frmMain.iTopD) / frmMain.iWinFoucs); 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)) { CStation Sta = frmMain.staComm.GetStaByStaName("NJ301"); CProtcolFINS SPLC = (CProtcolFINS)Sta; if (SPLC.System[0] == 7) { return; } CRing nRing = (CRing)obj; string sVar = "AV" + nRing.ShowText.PadLeft(3, '0'); SPLC.SendAODO(sVar, 0, "DO"); break; } } } } }
public void nCon_ValueChanged(object sender, EventArgs e)//微调框数值改变 { NumericUpDown nCon = (NumericUpDown)sender; string sVar = nCon.Name; int iValue = (int)nCon.Value; CStation Sta = frmMain.staComm.GetStaByStaName("NJ301"); CProtcolFINS SPLC = (CProtcolFINS)Sta; SPLC.SendAODO(sVar, iValue, "AO"); }
//根据板块类型和协议类型创建子站 public static CStation CreateStation(string sPortType, string sPortProtocol) { CStation newSta = null; switch (sPortType) { case "串口": if (sPortProtocol == "Modbus_RTU") { newSta = new CProtcolModbusRTU(); } else if (sPortProtocol == "恒温槽RE215") { newSta = new CProtcolRE215(); } else if (sPortProtocol == "真空硅901P") { newSta = new CProtcol901P(); } else { newSta = null; } break; case "TCP": if (sPortProtocol == "Modbus_TCP") { newSta = new CProtcolModbusTCP(); } else if (sPortProtocol == "FINS_TCP") { newSta = new CProtcolFINS(); } else { return(null); } break; default: break; } return(newSta); }