/// <summary> /// 读点位信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void readPointBtn_Click(object sender, EventArgs e) { if (comm.GetScomState()) { ReadPointsData(); isReadPoint = true; offsetBtn.Enabled = true; } }
private void solingScrew_Load(object sender, EventArgs e) { comm.ScomInit(); //dianpi1.ModbusTcpInit(); listBox1.Items.Add(dianpi1.ErrorStr); listBox1.Items.Add(dianpi2.ErrorStr); TableInit(); XYCharInit(); comm.scomDataReceived += new SerialComm.ScomDataReceivedHandler(CommDataReceived); comm.bitDataReceived += new SerialComm.BitDataReceivedHandler(WrDataReceived); comm.wordDataReceived += new SerialComm.WordDataReceivedHandler(DmDataReceived); dianpi1.modTcpDataReceived += new ProExpertDev.ModTcpDataReceivedHandler(ModbusDataReceived); dianpi1.shortDataReceived += new ProExpertDev.ShortDataReceiveHandle(ShortDataReceived); dianpi2.modTcpDataReceived += new ProExpertDev.ModTcpDataReceivedHandler(ModbusDataReceived); dianpi2.shortDataReceived += new ProExpertDev.ShortDataReceiveHandle(ShortDataReceived); //comm.ScomSendData("@00TS--PC to PLC communication test success--"); //comm.ScomSendData("@00RD20000002"); //comm.ScomSendData("@00WD20000100"); //comm.ScomSendData("@00FA00000000001018207D0000002"); comm.ScomSendData("@00FA0000000000101310021000001"); //读W33.00的值 //comm.ScomSendData("@00FA000000000010231002101000101"); //写W33.01,置1 //comm.ScomSendData("@00FA00000000001028220000000010256"); //comm.ScomSendData("@00FA0000000000102820bb80000010082"); InitProductInfo(); //初始化产品信息 GetTorsionLimit(ref torsionDown, ref torsionUp); //从设置文件中获取扭力的上下限 if (comm.GetScomState()) { listBox1.Items.Add("串口打开成功"); tcpTimer.Enabled = true; //串口打开成功就要向下发送数据了,只有同PLC的串口通信上了,才会有后续的扭力读取等操作,所以在此打开定时器 } else { listBox1.Items.Add("串口打开失败"); } if (dianpi1.Connected) { listBox1.Items.Add("电批1控制器连接成功"); } else { listBox1.Items.Add("电批1控制器连接失败"); } if (dianpi2.Connected) { listBox1.Items.Add("电批2控制器连接成功"); } else { listBox1.Items.Add("电批2控制器连接失败"); } tcpTimer.Enabled = true; }