void wuliaotingzhiEventHandler() { if (InvokeRequired) { Invoke(new Turntable.StrongPress(wuliaotingzhiEventHandler)); return; } if (MSStoptTimer.Enabled) { MSStoptTimer.Enabled = false; } Turntable.Instance.stopShakePan(); Turntable.Instance.Stop(); PCI408.PCI408_write_outbit(Card.cardNo, Card.hd, Card.On); PCI408.PCI408_write_outbit(Card.cardNo, Card.ld, Card.Off); //PCI408.PCI408_write_outbit(Card.cardNo, Card.ssd, Card.Off); foreach (var c in ccameras) { if (c.isopen) { c.StopGrabbing(); c.isfirst = false; } } BtnStart.Enabled = true; }
private void BtnPanCtrl_Click(object sender, EventArgs e) { if (!Panstart) { Turntable.Instance.Start(); speed = speed < 1000 ? 1000 : speed; PCI408.PCI408_write_SEVON_PIN(Card.cardNo, Card.On); PCI408.PCI408_set_profile(Card.cardNo, 1000, speed, Card.acc, Card.acc); PCI408.PCI408_vmove(Card.cardNo, 0, Card.maxspeed); PCI408.PCI408_write_outbit(Card.cardNo, Card.chuiqizongkaiguan, Card.On); BtnPanCtrl.Text = "停止运动"; } else { Turntable.Instance.Stop(); PCI408.PCI408_decel_stop(Card.cardNo, Card.acc); PCI408.PCI408_write_outbit(Card.cardNo, Card.chuiqizongkaiguan, Card.Off); Thread.Sleep(5000); BtnPanCtrl.Text = "转盘启动测试"; } Panstart = !Panstart; }
private void MSStoptTimer_OnTime(object sender, EventArgs e) { //振动盘直震停止 BtnStart.Enabled = true; //玻璃盘停止 Turntable.Instance.Stop(); MSStoptTimer.Enabled = false; for (int xjh = 0; xjh < Turntable.Instance.PosArray.Count(); xjh++) { PCI408.PCI408_compare_clear_points_Extern(0, (ushort)(xjh + 1)); PCI408.PCI408_compare_config_Extern(Card.cardNo, (ushort)(xjh + 1), 1, Card.zhouhao, Turntable.Instance.IOs[xjh]); PCI408.PCI408_compare_set_pulsetimes_Extern(0, (ushort)(xjh + 1), 20); } foreach (var c in ccameras) { if (c.isopen) { c.StopGrabbing(); c.isfirst = false; } } Turntable.Instance.isStart = false; Turntable.Instance.chuchushuju(); PCI408.PCI408_write_outbit(Card.cardNo, Card.hd, Card.On); PCI408.PCI408_write_outbit(Card.cardNo, Card.ld, Card.Off); //PCI408.PCI408_write_outbit(Card.cardNo, Card.ssd, Card.Off); }
public void cardInitial()//20170621 { for (ushort i = 0; i < 32; i++) { PCI408.PCI408_write_outbit(Card.cardNo, (ushort)(Card.Out1 + i), Card.Off); } }
private void timer2_Tick(object sender, EventArgs e) { int k = Dmc2210.d2210_read_inbit(Card.cardNo, Card.jiting); //int kk = PCI408.PCI408_check_done(Card.zhouhao); if (k == 0) { //if (kk == 0) //{ //Dmc2210.d2210_write_outbit(Card.cardNo, Card.shusongdai, Card.Off); PCI408.PCI408_write_outbit(Card.cardNo, Card.hd, Card.On); PCI408.PCI408_write_outbit(Card.cardNo, Card.shakePan, Card.Off); PCI408.PCI408_write_outbit(Card.cardNo, Card.ld, Card.Off); //} } //else if (kk ==1 &&BtnStart.Enabled == false &&getup ==false ) //{ // getup = true; // Console.WriteLine("ssss"); // Thread.Sleep(5000); // //Dmc2210.d2210_write_outbit(Card.cardNo, Card.shusongdai, Card.On); // PCI408.PCI408_write_outbit(Card.cardNo, Card.ld, Card.On); // PCI408.PCI408_write_outbit(Card.cardNo, Card.hd, Card.Off); // PCI408.PCI408_write_outbit(Card.cardNo, Card.shakePan, Card.On); // getup = false; //} }
public void stopShakePan() { //Turntable.Instance.cardInitial(); PCI408.PCI408_write_outbit(Card.cardNo, Card.shakePan, Card.Off); //Thread.Sleep(4500); //isStart = false; }
public void startShakePan() { int j = PCI408.PCI408_check_done(Card.cardNo); if (j == 0) { PCI408.PCI408_write_outbit(Card.cardNo, Card.shakePan, Card.On); } }
private void MSStartTimer_OnTime(object sender, EventArgs e) { //振动盘直震启动 Turntable.Instance.startShakePan(); MSStartTimer.Enabled = false; MSStartTimer.Enabled = false; PCI408.PCI408_write_outbit(Card.cardNo, Card.hd, Card.Off); PCI408.PCI408_write_outbit(Card.cardNo, Card.ld, Card.On); //PCI408.PCI408_write_outbit(Card.cardNo, Card.ssd, Card.On); }
void zhizhenLowSensor_OnTimerEvent(object sender, EventArgs e) { int state = PCI408.PCI408_read_inbit(Card.cardNo, Card.zhizhenSensor); if (state != Card.On) { SpeedTime.Start(); PCI408.PCI408_write_SEVON_PIN(Card.cardNo, Card.On); PCI408.PCI408_set_profile(Card.cardNo, Card.minspeed, Card.maxspeed, Card.acc, Card.acc); PCI408.PCI408_vmove(Card.cardNo, 0, Card.maxspeed); PCI408.PCI408_write_outbit(Card.cardNo, Card.chuiqizongkaiguan, Card.On); zhuanpanStateRuning = true; zhizhenLowSensor.timer.Stop(); } }
public void Start() { if (!isStart) { for (int i = 0; i < IOs.Count; i++) { PCI408.PCI408_write_outbit(Card.cardNo, IOs[i], Card.Off); } thread = new Thread(Run); thread.IsBackground = true; thread.Priority = ThreadPriority.Highest; thread.Start(); isStart = true; } SpeedTime.Start(); //PCI408.PCI408_write_SEVON_PIN(Card.cardNo, Card.On); PCI408.PCI408_set_profile(Card.cardNo, Card.minspeed, Card.maxspeed, Card.acc, Card.acc); PCI408.PCI408_vmove(Card.cardNo, 0, Card.maxspeed); zhuanPanIsRun = true; }
public void servoAlarmClear() { PCI408.PCI408_write_outbit(Card.cardNo, Card.servoRes, Card.On); Thread.Sleep(100); PCI408.PCI408_write_outbit(Card.cardNo, Card.servoRes, Card.Off); }
public Turntable() { wkb = new HSSFWorkbook(); sheet = wkb.CreateSheet("检测结果(Measure Data)"); tjcjg = DateTime.Now; sheetrr = sheet.CreateRow(sheetr); xjzsr[0] = 2; xjzsr[1] = 34; xjzsr[2] = 30; //31 xjzsr[3] = 3; //21 xjzsr[4] = 4; //32 sheetcc = sheetrr.CreateCell(sheetc); watchdog.OnTimerEvent += new MyTimer.OnTimerEventHandler(watchdog_OnTimerEvent); zhuanPanIsRun = false; zhizhenLowSensor = new MyTimer(); StartDelay.OnTimerEvent += new MyTimer.OnTimerEventHandler(StartDelay_OnTimerEvent); zhizhenLowSensor.OnTimerEvent += new MyTimer.OnTimerEventHandler(zhizhenLowSensor_OnTimerEvent); MySerialPort = new SerialPort(); MySerialPort.DataReceived += new SerialDataReceivedEventHandler(MySerialPort_DataReceived); isbussy = false; nutqueue = new List <Nut>(); isStart = false; jcqdls = new jcqdl[5]; bjgd = new long[5]; for (int jcqdlsl = 0; jcqdlsl < 5; jcqdlsl++) { jcqdls[jcqdlsl] = new jcqdl(); jcqdls[jcqdlsl].xjjcqdl = new Queue <long>(); bjgd[jcqdlsl] = 0; } xjfws = new xjfw[7]; for (int xjfwi = 0; xjfwi < 5; xjfwi++) { xjfws[xjfwi] = new xjfw(); xjfws[xjfwi].ID = xjfwi; xjfws[xjfwi].t1 = DateTime.Now; xjfws[xjfwi].t2 = DateTime.Now; } copos = new coppos[7]; for (int k = 0; k < 5; k++) { copos[k] = new coppos(); copos[k].ID = k; // copos[k].onwrite = false; } timers = new MyTimer[7]; for (int i = 0; i < timers.Length; i++) { timers[i] = new MyTimer(); timers[i].ID = i; //timers[i].OnTimerEvent += new MyTimer.OnTimerEventHandler(OnTimer); } dpdl = new List <int> [5]; for (int i = 0; i < 5; i++) { dpdl[i] = new List <int>(); } for (ushort i = 0; i < 9; i++) { PCI408.PCI408_write_outbit(Card.cardNo, (ushort)(Card.Out1 + i), Card.Off); } PCI408.PCI408_set_position(Card.cardNo, 0); PCI408.PCI408_set_pulse_outmode(Card.cardNo, 0); //SpeedTime.Tick += new EventHandler(SpeedTime_OnTime); SpeedTime.Enabled = true; SpeedTime.Interval = 5000; zhuanpanStateRuning = false; //if (!MySerialPort.IsOpen) //{ // MySerialPort.BaudRate = 9600; // MySerialPort.StopBits = StopBits.One; // MySerialPort.Parity = Parity.None; // MySerialPort.PortName = "COM1"; // MySerialPort.DataBits = 8; // MySerialPort.ReceivedBytesThreshold = 21; // MySerialPort.ReadBufferSize = 512; // MySerialPort.Open(); //} }
private void kongzhiwaibu() { kzwbmlt11 = DateTime.Now; kzwbmlts = kzwbmlt11 - kzwbmlt12; int kzwbml; kzwbml = kzwbmlts.Days * 86400 + kzwbmlts.Hours * 3600 + kzwbmlts.Minutes * 60 + kzwbmlts.Seconds; if (kzwbml > 240) { Onwuliao(); baojing = new Thread(bjzx); baojing.Start(); isStart = false; } djzt = PCI408.PCI408_check_done(Card.cardNo); if (djzt == 1) { if (kzwbhdzt == 1) { PCI408.PCI408_write_outbit(Card.cardNo, Card.hd, Card.On); PCI408.PCI408_write_outbit(Card.cardNo, Card.shakePan, Card.Off); kzwbhdzt = 0; } if (kzwbldzt == 1) { PCI408.PCI408_write_outbit(Card.cardNo, Card.ld, Card.Off); kzwbldzt = 1; } } else { if (kzwbldzt == 1) { PCI408.PCI408_write_outbit(Card.cardNo, Card.ld, Card.On); kzwbldzt = 0; } if (kzwbhdzt == 0) { PCI408.PCI408_write_outbit(Card.cardNo, Card.hd, Card.Off); kzwbhdzt = 1; } } if (sc == 1) { s4 = PCI408.PCI408_read_inbit(Card.cardNo, Card.jsqm); if (s4 == 0) { PCI408.PCI408_write_outbit(Card.cardNo, Card.jsqqg, Card.Off); sc = 0; } } if (sc == 0) { s5 = PCI408.PCI408_read_inbit(Card.cardNo, Card.jsqfw); if (s5 == 0) { PCI408.PCI408_write_outbit(Card.cardNo, Card.jsqqg, Card.On); sc = 1; lmxh2 = DateTime.Now; } } lmxhts = lmxh1 - lmxh2;//20170622 lmxh1 = DateTime.Now; int lmxh; lmxh = lmxhts.Days * 86400 + lmxhts.Hours * 3600 + lmxhts.Minutes * 60 + lmxhts.Seconds; if (lmxh > 60 && sc == 1) { //baojing = new Thread(bjzx); //baojing.Start(); //isStart = false; //lackStop(); ////zhuanpanStateRuning = false; //SpeedTime.Stop(); //Turntable.Instance.Stop(); //zhuanpanStateRuning = false; ////zhizhenLowSensor.timer.Start(); //SpeedTime.Enabled = false; PCI408.PCI408_decel_stop(Card.cardNo, Card.acc); PCI408.PCI408_write_outbit(Card.cardNo, Card.chuiqizongkaiguan, Card.Off); //zhuanPanIsRun = false; //zhizhenLowSensor.timer.Stop(); } }