好友
阅读权限10
听众
最后登录1970-1-1
|
凌凌壹
发表于 2020-5-8 10:29
工具 VS2019 博图 V16 (300PLC) 语言c#
界面功能:通讯 ,读写,简单加了一曲线图。
关于:PID整定(机缘巧合下一个学弟要做个小项目,我就试了试,比较简单后期慢慢更新。)
没有实物(实物太贵现阶段是没办法直棱起来的)只能做测试用。(有大佬有实物的的话可以帮忙做测试,小弟在此先谢过了。)
付百度云连接:链接: https://pan.baidu.com/s/16qA8WFRfLG8n3Vay9S37rQ 提取码: tfpt
百度云链接: 提取码: tfpt
付部分程序:
#region 初始化
public Form1()
{
InitializeComponent();
CheckForIllegalCrossThreadCalls = false;
this.realTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
timerClock.Start();
this.buttonConnect.Enabled = false;
this.buttonDisconnect.Enabled = false;
this.groupBox2.Enabled = false;
this.groupBox3.Enabled = false;
}
//界面初始化
private void Form1_Load(object sender, EventArgs e)
{
this.comboBoxPLCType.SelectedIndex = -1;
}
//初始化图表
private void userCurve1_Load(object sender, EventArgs e)
{
userCurve1.SetLeftCurve("A", new float[0], Color.Tomato);
userCurve1.SetLeftCurve("B", new float[0], Color.Blue);
}
//时钟
private void timerClock_Tick(object sender, EventArgs e)
{
this.realTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
#endregion
#region 事件
//连接按钮
private void buttonConnect_Click(object sender, EventArgs e)
{
RequiredFieldValIDAtor();
try
{
if (siemensPLCSelected != SiemensPLCS.S200Smart)
{
siemensTcpNet.Rack = byte.Parse(this.textBoxRack.Text);
siemensTcpNet.Slot = byte.Parse(this.textBoxSlot.Text);
}
OperateResult connect = siemensTcpNet.ConnectServer();
if (connect.IsSuccess)
{
this.connectTips.Text = "设备连接成功:已连接至IP:"
+ this.textBoxPLCIP.Text.Trim() + " 的"
+ this.comboBoxPLCType.Text.Trim()
+ "PLC设备";
this.connectTips.ForeColor = Color.Green;
Connect_Load();
}
else
{
this.connectTips.Text = "设备连接失败:未连接至IP:"
+ this.textBoxPLCIP.Text.Trim() + " 的"
+ this.comboBoxPLCType.Text.Trim()
+ "PLC设备";
this.connectTips.ForeColor = Color.Red;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
//连接初始化
private void Connect_Load()
{
//界面使能
this.groupBox2.Enabled = true;
this.groupBox3.Enabled = true;
this.buttonDisconnect.Enabled = true;
this.buttonConnect.Enabled = false;
//创建线程
th = new Thread(DataRefresh);
th.IsBackground = true;
th.Start();
//计数时钟
countTimer.Start();
}
//断开连接
private void buttonDisconnect_Click(object sender, EventArgs e)
{
OperateResult ConnectClose = siemensTcpNet.ConnectClose();
if (ConnectClose.IsSuccess)
{
//连接使能,断开关闭
buttonConnect.Enabled = true;
buttonDisconnect.Enabled = false;
this.groupBox2.Enabled = false;
this.groupBox3.Enabled = false;
//提示字符串
this.connectTips.Text = "设备已断开连接";
this.connectTips.ForeColor = Color.Red;
//计数时钟
countTimer.Stop();
//线程
th.Abort();
}
}
#endregion |
-
这是界面图片
免费评分
-
查看全部评分
|
发帖前要善用【论坛搜索】功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。 |
|
|
|
|