/// <summary> /// 定时器刷新处理数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void timer1_Tick(object sender, EventArgs e) { //你的定时处理 //建立与plc连接 int result = Sharp7AndPlcComm.ConnectToPlc(client); //判断通讯状态 Sharp7AndPlcComm.JudgeCommStu(result, ref labCommStu); //如果通讯成功,则调用读取或写入函数 if (result == 0) { // ReadPlcData.ReadValveSignals(ref ellipses, client, ref txtReadServoPos); //WritePlcData.WriteDb(client, ref txtWriteServoPos); } else//如果通讯失败,清除所有气缸信号 { ReadPlcData.ClearValveSignals(client, ref ellipses); } }
/// <summary> /// 定时器刷新处理数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void timer1_Tick(object sender, EventArgs e) { //你的定时处理 //建立与plc连接 result = Sharp7AndPlcComm.ConnectToPlc(client); //判断通讯状态 Sharp7AndPlcComm.JudgeCommStu(result, ref labCommStu); //如果通讯成功,则调用读取或写入函数 if (result == 0) { ReadPlcData.ReadValveSignals(client, ref ellipses, readValveDbNum, readValveDbByteLength, readValveDbStartElement, readValveDbStartBit); position.Text = ReadPlcData.ReadManualData(client, 14, 208, 52); WritePlcData.WriteDb(client, ref setPosition, ref setSpeed, 14, new int[] { 60, 68 }); //WritePlcData.WriteDb(client, ref txtWriteServoPos); //WritePlcData.BtnToPLC(client,ref btns, writeBtnDbNum, writeBtnDbStartElement, writeBtnDbStartBit); } else//如果通讯失败,清除所有气缸信号 { ReadPlcData.ClearValveSignals(client, ref ellipses); } }