|
|
@ -13,13 +13,44 @@ namespace NDSD_Screwdriver
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public partial class MainForm : Form
|
|
|
|
public partial class MainForm : Form
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DOperate DOperate;
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 输出端口操作
|
|
|
|
TcpServer server = TcpServer.Instance;
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
private DOperate DOperate;
|
|
|
|
List<MonitorEntity> monitorEntities;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
Random rand = new Random();
|
|
|
|
/// TCP服务器
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
private TcpServer server = TcpServer.Instance;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 前端列表集合
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
private List<MonitorEntity> monitorEntities;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Random rand = new Random();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
|
|
|
|
///// 判断是否是第一次初始化
|
|
|
|
|
|
|
|
///// </summary>
|
|
|
|
|
|
|
|
//private int flag = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 判断现在操作哪一行
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
public int NowRowIndex = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// RFID列表
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
string[] RFIDs = new string[]
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"1111222233334444",
|
|
|
|
|
|
|
|
"2222222233334444",
|
|
|
|
|
|
|
|
"3333222233334444",
|
|
|
|
|
|
|
|
"4444222233334444",
|
|
|
|
|
|
|
|
"5555222233334444"
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
public MainForm()
|
|
|
|
public MainForm()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -29,86 +60,13 @@ namespace NDSD_Screwdriver
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MessageBox.Show("服务端打开失败!");
|
|
|
|
MessageBox.Show("服务端打开失败!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
monitorEntities = new List<MonitorEntity>()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
new MonitorEntity()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
RowEneieys = new List<RowEneiey>()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
new RowEneiey()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ColumnIndex = 0,
|
|
|
|
|
|
|
|
Color = Brushes.Transparent
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new RowEneiey()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ColumnIndex = 1,
|
|
|
|
|
|
|
|
Value = "11111111",
|
|
|
|
|
|
|
|
Color = Brushes.Transparent
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new RowEneiey()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ColumnIndex = 2,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
RowIndex = 0,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new MonitorEntity()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
RowEneieys = new List<RowEneiey>()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
new RowEneiey()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ColumnIndex = 0,
|
|
|
|
|
|
|
|
Color = Brushes.Transparent
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new RowEneiey()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ColumnIndex = 1,
|
|
|
|
|
|
|
|
Value = "22222222",
|
|
|
|
|
|
|
|
Color = Brushes.Transparent
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new RowEneiey()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ColumnIndex = 2,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
RowIndex = 1,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new MonitorEntity()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
RowEneieys = new List<RowEneiey>()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
new RowEneiey()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ColumnIndex = 0,
|
|
|
|
|
|
|
|
Color = Brushes.Transparent
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new RowEneiey()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ColumnIndex = 1,
|
|
|
|
|
|
|
|
Value = "33333333",
|
|
|
|
|
|
|
|
Color = Brushes.Transparent
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new RowEneiey()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ColumnIndex = 2,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
RowIndex = 2,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 打开DO测试
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
private void DOTest_Click(object sender, EventArgs e)
|
|
|
|
private void DOTest_Click(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ScrewdriverTest screwdriverTest = new ScrewdriverTest(server, DOperate);
|
|
|
|
ScrewdriverTest screwdriverTest = new ScrewdriverTest(server, DOperate);
|
|
|
@ -127,55 +85,63 @@ namespace NDSD_Screwdriver
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MessageBox.Show("服务端释放失败!");
|
|
|
|
MessageBox.Show("服务端释放失败!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 列表回调函数
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="g"></param>
|
|
|
|
|
|
|
|
/// <param name="rowIndex"></param>
|
|
|
|
|
|
|
|
/// <param name="colIndex"></param>
|
|
|
|
|
|
|
|
/// <param name="rectangle"></param>
|
|
|
|
|
|
|
|
/// <param name="value"></param>
|
|
|
|
|
|
|
|
/// <param name="sf"></param>
|
|
|
|
private void ScrewdriverMonitor_OnDrawCellTextEvent(Graphics g, int rowIndex, int colIndex, RectangleF rectangle, string value, StringFormat sf)
|
|
|
|
private void ScrewdriverMonitor_OnDrawCellTextEvent(Graphics g, int rowIndex, int colIndex, RectangleF rectangle, string value, StringFormat sf)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
foreach (MonitorEntity entity in monitorEntities)
|
|
|
|
foreach (MonitorEntity entity in monitorEntities)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (rowIndex == entity.RowIndex)
|
|
|
|
if (rowIndex == entity.RowIndex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
foreach (RowEneiey rowEneiey in entity.RowEneieys)
|
|
|
|
foreach (RowEntity rowEneiey in entity.RowEntitys)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (colIndex == rowEneiey.ColumnIndex)
|
|
|
|
if (colIndex == rowEneiey.ColumnIndex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (colIndex == 2)
|
|
|
|
g.FillRectangle(rowEneiey.Color, rectangle);
|
|
|
|
{
|
|
|
|
g.DrawString(rowEneiey.Value, this.ScrewdriverMonitor.Font, Brushes.Black, rectangle, sf);
|
|
|
|
g.FillRectangle(FormUtils.TestRamColor(), rectangle);
|
|
|
|
|
|
|
|
g.DrawString(rowEneiey.Value, this.ScrewdriverMonitor.Font, Brushes.Black, rectangle, sf);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
g.FillRectangle(rowEneiey.Color, rectangle);
|
|
|
|
|
|
|
|
g.DrawString(rowEneiey.Value, this.ScrewdriverMonitor.Font, Brushes.Black, rectangle, sf);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private void TestButton1_Click(object sender, EventArgs e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
RefreshRoll();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void TestButton2_Click(object sender, EventArgs e)
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 测试按钮
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
|
|
|
private void TestButton1_Click(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
SetNowRowsLightState(FormUtils.TestRamColor());
|
|
|
|
RefreshRoll();
|
|
|
|
RefreshRoll();
|
|
|
|
|
|
|
|
if (++NowRowIndex >= RFIDs.Length)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
NowRowIndex = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void TestButton3_Click(object sender, EventArgs e)
|
|
|
|
private void InitButton_Click(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
RefreshRoll();
|
|
|
|
InitMonitirIntity();
|
|
|
|
|
|
|
|
SetRFIDValue(RFIDs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 刷新列表
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
private void RefreshRoll()
|
|
|
|
private void RefreshRoll()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (int i = 0; i < 5; i++)
|
|
|
|
for (int i = 0; i < RFIDs.Length; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ScrewdriverMonitor.AddRowTop(new string[]{
|
|
|
|
ScrewdriverMonitor.AddRowTop(new string[]{
|
|
|
|
"",
|
|
|
|
"",
|
|
|
@ -184,5 +150,74 @@ namespace NDSD_Screwdriver
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 初始化整个列表
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
private void InitMonitirIntity()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
monitorEntities = new List<MonitorEntity>();
|
|
|
|
|
|
|
|
for (int i = 0; i < RFIDs.Length; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
monitorEntities.Add(new MonitorEntity()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
RowIndex = i,
|
|
|
|
|
|
|
|
RowEntitys = InitRows(i)
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
RefreshRoll();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 初始化一行
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="rowNo">当前的初始化行数</param>
|
|
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
private List<RowEntity> InitRows(int rowNo)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
List<RowEntity> rowEntities = new List<RowEntity>();
|
|
|
|
|
|
|
|
for (int i = 0; i < 3; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
rowEntities.Add(new RowEntity()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ColumnIndex = i,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return rowEntities;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 初始化RFID数据
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="rFIDvalue">RFID列表</param>
|
|
|
|
|
|
|
|
private void SetRFIDValue(string[] rFIDvalue)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
for (int i = 0; i < rFIDvalue.Length; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
monitorEntities[i].RowEntitys[1].Value = rFIDvalue[i];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 设置当前行指示灯的状态以及工作的行
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="lightState"></param>
|
|
|
|
|
|
|
|
private void SetNowRowsLightState(LightState lightState)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
monitorEntities[NowRowIndex].RowEntitys[2].Color = FormUtils.EnumColorToBrush(lightState);
|
|
|
|
|
|
|
|
for (int i = 0; i < RFIDs.Length; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
monitorEntities[NowRowIndex].RowEntitys[0].Value = i == NowRowIndex ? "=>" : "";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void SetNowRowsLightState(Brush brush)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
monitorEntities[NowRowIndex].RowEntitys[2].Color = brush;
|
|
|
|
|
|
|
|
for (int i = 0; i < RFIDs.Length; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
monitorEntities[i].RowEntitys[0].Value = i == NowRowIndex ? "=>" : "";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|