public void agvSerialRemoteCall(object sender, RemoteCallEventArgs e) { Station startStation = null; Station targetStation = null; Station endStation = null; string s = (e.Station_ID).ToString(); if (e.Call_type < 5 && e.Call_type > 8) { return; } writeLine("remote call type " + e.Call_type + " station " + e.Station_ID); switch (e.Call_type) { case 5: startStation = this.newCanvas.Scheduler.GStartStation; targetStation = this.newCanvas.StationDic["S" + e.Station_ID]; endStation = this.newCanvas.StationDic["F28"]; break; case 6: startStation = this.newCanvas.Scheduler.RStartStation; targetStation = this.newCanvas.StationDic["S" + e.Station_ID]; endStation = this.newCanvas.StationDic["F29"]; break; case 7: startStation = this.newCanvas.Scheduler.PStartStation; targetStation = this.newCanvas.StationDic["S" + e.Station_ID]; endStation = this.newCanvas.StationDic["F30"]; break; case 8: startStation = this.newCanvas.Scheduler.GOStartStation; targetStation = this.newCanvas.StationDic["S" + e.Station_ID]; endStation = this.newCanvas.StationDic["F31"]; break; } //RoadTableFrameHandler serialHander = new RoadTableFrameHandler(); Control[] a; Button b; try { //serialHander.planRoadTable(e.Call_type, startStation, targetStation, endStation, this.newCanvas.AdjList, this.serialPort1, this.newCanvas); this.newCanvas.Scheduler.CallStyle = e.Call_type; a = this.newCanvas.Controls.Find("S" + s, false); b = (Button)a[0]; if (b != null) { Invoke(new PerformClick(b.PerformClick)); } //writeLine("站点" + s + "呼叫"); } catch (Exception x) { Console.WriteLine(x.Message); } }
public void handleOneByte(byte b) { serialBuf.Add(b); if (serialBuf[0] != 0x68) { serialBuf.RemoveAt(0); } if (serialBuf.Count < 8) { return; } callEventArgs = null; stateReportEventArgs = null; if (serialBuf[1] == 0xE5 && serialBuf.Count == 8)//呼叫器呼叫 { if (serialBuf != null) { callEventArgs = new RemoteCallEventArgs(serialBuf[5], serialBuf[6]); } } else if (serialBuf[1] == 0xE3)//状态上报 { if (serialBuf.Count < 20) { return; } else if (serialBuf.Count == 20) { stateReportEventArgs = new CarStateReportEventArgs(serialBuf[5], serialBuf[6], serialBuf[7], serialBuf[8], serialBuf[9], serialBuf[10], serialBuf[11], serialBuf[12], serialBuf[13], serialBuf[14]); } } try { if ((null != remoteCallEvent) && (callEventArgs != null)) { remoteCallEvent(this, callEventArgs); serialBuf.Clear();//有效帧 } else if ((null != stateReportEventArgs) && (null != carStateReportEvent)) { carStateReportEvent(this, stateReportEventArgs); serialBuf.Clear(); } else { serialBuf.RemoveAt(0); } } catch (Exception x) { Console.WriteLine(x.Message); } }