using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using elelab; namespace NNLightTest { public partial class Form1 : Form { public Form1() { InitializeComponent(); pick.MyDelegateEvent += testPicked; } /// /// 点亮一组标签 /// void lightsLabels() { elelab.pick.init_port(); //开始一组亮灯操作 int port = 13; //端口号 int[] ids; //标签ID int[] address;//标签坐标(行、列) int[] counts;//显示数量 bool result;//亮灯结果 int color;//灯的颜色 0 不亮 1 红灯 2 绿灯 3 蓝灯 4 红闪 5 绿闪 6 蓝闪 //点亮红灯 color = 1; ids = new int[] { 1, 1 }; address = new int[] { 11, 22 }; counts = new int[] { 5, 8 }; result = elelab.pick.lightLabels(port, color, ids, address, counts); //点亮绿灯 color = 2; ids = new int[] { 1, 2, 3 }; address = new int[] { 11, 22, 31 }; counts = new int[] { 5, 6, 7 }; result = elelab.pick.lightLabels(port, color, ids, address, counts); } delegate void showStatus(); void testPicked(int portNo, int eleId, int color, int eleAddress, int count) { if (InvokeRequired) { this.Invoke(new showStatus(delegate() { showResult( portNo , eleId, color, eleAddress, count); })); } else { showResult( portNo , eleId, color, eleAddress, count); } } void showResult(int portNo, int eleId, int color, int eleAddress, int count) { label1.Text = string.Format("返回结果: \n 端口:{0} \n 标签ID:{1} \n 颜色:{2} \n 地址:{3} \n 数量:{4}" ,portNo, eleId, color, eleAddress, count); } private void btnLights_Click(object sender, EventArgs e) { lightsLabels(); } } }