//AxisHome axihome = new AxisHome(1, 13, -4000, 100, 1, 0); private void Btn_Test_Click(object sender, EventArgs e) { if (Card_flag) { if (Btn_Test.Text == "Test") { Btn_Test.Text = "Stop"; for (int i = 0; i < 8; i++) { headcard.SetPos(i, 0); } StartTest(); StartRTest(); } else { Btn_Test.Text = "Test"; StopTest(); StopRTest(); } } else { SetText("请初始化板卡!", -1); } }
private int home() { HZC_Head08Card headcard = new HZC_Head08Card(1, 7); int status = 0; switch (home_flag) { case 0: headcard.SetPos(axis, 0); headcard.SetEncPos(axis, 0); if (headcard.GetAxisSensor(homesensorid) == sensorstate) { home_flag = 1; } else { home_flag = 20; } break; case 1: //处于感应状态 //headcard.PfMove(axis, pulse, 0); headcard.CnstMove(axis, speed1, -10000); home_flag = 2; break; case 2: int s = -1; s = headcard.GetAxisSensor(homesensorid); if (s != sensorstate) { headcard.AbortMoving(axis); sw.StartStopWatch(150); while (!sw.TimeUp()) { ; } home_flag = 3; } break; case 3: headcard.SearchForhomepos(axis, 0, 450, 300); sw.StartStopWatch(300); home_flag = 4; break; case 4: //if (headcard.GetStatus(axis) != 0) break; while (!sw.TimeUp()) { ; } if (headcard.GetAxisSensor(homesensorid) == 0) { headcard.SetPos(axis, 0); } else { home_flag = 3; break; } home_flag = 0; status = 1; break; case 20: //未感应状态 headcard.CnstMove(axis, speed1, 10000); home_flag = 21; break; case 21: //headcard.CnstMove(axis, 100, 1000); if (headcard.GetAxisSensor(homesensorid) == sensorstate) { headcard.AbortMoving(axis); sw.StartStopWatch(150); while (!sw.TimeUp()) { ; } home_flag = 1; } break; } return(status); }