//定义委托
public delegate void SetFlexCellCallback(FlexCell.Grid g);
//声明委托
SetFlexCellCallback _SetFlexCellCallback;
//声明线程
private void btnCheck_Click(object sender, EventArgs e)
{
_SetFlexCellCallback = new SetFlexCellCallback(StartServer);
thread = new Thread(DoStartServer);
if (thread.ThreadState != ThreadState.Running)
{
thread.Start();
}
}
private void DoStartServer()
{
this.BeginInvoke(_SetFlexCellCallback, new object[] { grid1 });
}
/// <summary>
/// 启动服务
/// </summary>
private void StartServer(FlexCell.Grid grid1)
{
#region
grid1.Cols = 9;
grid1.ExtendLastCol = true;
grid1.Rows = 17;
grid1.Cell(0, 1).Text = "EL-";
grid1.Cell(0, 2).Text = "EL+";
grid1.Cell(0, 3).Text = "ORG";
grid1.Cell(0, 4).Text = "STP";
grid1.Cell(0, 5).Text = "STA";
grid1.Cell(0, 6).Text = "SD-";
grid1.Cell(0, 7).Text = "SD+";
for (int k = 1; k <= 7; k++)
{
grid1.Column(k).Width = 50;
}
Image H = Resource.H12;
Image L = Resource.L12;
grid1.Images.Add(H, "H");
grid1.Images.Add(L, "L");
#endregion
while (true)
{
#region Step 1
//if (GetMotorStatusForAxis(1, 2) && Sig(2) && !Sig(1) && !stop)
//{
// Dmc1000.d1000_out_bit(1, 0);//控制第一个马达起动
// //Dmc1000.d1000_out_bit(2, 0);
//}
//if (GetMotorStatusForAxis(1, 2) && !Sig(2))
//{
// Dmc1000.d1000_out_bit(1, 1);//控制第一个马达停止
// //Dmc1000.d1000_out_bit(2, 1);
//}
#endregion
for (int i = 0; i < 16; i++)
{
grid1.Cell(i, 1).Text = Dmc1000.d1000_get_axis_status(i).ToString();
for (int j = 0; j <= 6; j++)
{
grid1.Cell(i + 1, j + 1).Text = GetMotorStatusForAxis(i, j) ? "1" : "0";
if (grid1.Cell(i + 1, j + 1).Text == "1")
grid1.Cell(i + 1, j + 1).SetImage("H");
else
grid1.Cell(i + 1, j + 1).SetImage("L");
}
}
}
}
public delegate void SetFlexCellCallback(FlexCell.Grid g);
//声明委托
SetFlexCellCallback _SetFlexCellCallback;
//声明线程
private void btnCheck_Click(object sender, EventArgs e)
{
_SetFlexCellCallback = new SetFlexCellCallback(StartServer);
thread = new Thread(DoStartServer);
if (thread.ThreadState != ThreadState.Running)
{
thread.Start();
}
}
private void DoStartServer()
{
this.BeginInvoke(_SetFlexCellCallback, new object[] { grid1 });
}
/// <summary>
/// 启动服务
/// </summary>
private void StartServer(FlexCell.Grid grid1)
{
#region
grid1.Cols = 9;
grid1.ExtendLastCol = true;
grid1.Rows = 17;
grid1.Cell(0, 1).Text = "EL-";
grid1.Cell(0, 2).Text = "EL+";
grid1.Cell(0, 3).Text = "ORG";
grid1.Cell(0, 4).Text = "STP";
grid1.Cell(0, 5).Text = "STA";
grid1.Cell(0, 6).Text = "SD-";
grid1.Cell(0, 7).Text = "SD+";
for (int k = 1; k <= 7; k++)
{
grid1.Column(k).Width = 50;
}
Image H = Resource.H12;
Image L = Resource.L12;
grid1.Images.Add(H, "H");
grid1.Images.Add(L, "L");
#endregion
while (true)
{
#region Step 1
//if (GetMotorStatusForAxis(1, 2) && Sig(2) && !Sig(1) && !stop)
//{
// Dmc1000.d1000_out_bit(1, 0);//控制第一个马达起动
// //Dmc1000.d1000_out_bit(2, 0);
//}
//if (GetMotorStatusForAxis(1, 2) && !Sig(2))
//{
// Dmc1000.d1000_out_bit(1, 1);//控制第一个马达停止
// //Dmc1000.d1000_out_bit(2, 1);
//}
#endregion
for (int i = 0; i < 16; i++)
{
grid1.Cell(i, 1).Text = Dmc1000.d1000_get_axis_status(i).ToString();
for (int j = 0; j <= 6; j++)
{
grid1.Cell(i + 1, j + 1).Text = GetMotorStatusForAxis(i, j) ? "1" : "0";
if (grid1.Cell(i + 1, j + 1).Text == "1")
grid1.Cell(i + 1, j + 1).SetImage("H");
else
grid1.Cell(i + 1, j + 1).SetImage("L");
}
}
}
}