public static void NetworkLayerSendMultiFrame(object obj) { string strSendBytes = DataFormatConvert.ListToStr(BufferMultiFrameSend.ListNetLayerByteData); int nSendTimes = 0; try { while (true) { if (BufferMultiFrameSend.Offset < BufferMultiFrameSend.ListNetLayerByteData.Count && BufferMultiFrameSend.RemainFrameCount > 0 && (MainWindow.m_OperateType == OperateType.WriteAllMasterPara || //ParaManageWnd.IsUpdateAllPara || MainWindow.m_OperateType == OperateType.WriteAllMasterAdjustPara || MainWindow.m_OperateType == OperateType.WriteMasterControlPara)) // (BufferMultiFrameSend.RemainFrameCount != 0) { if (BufferMultiFrameSend.Offset > 0) // 非首帧 { DataLinkLayer.ActionDllSendFuc(BufferMultiFrameSend.SendConsecutiveFrame()); } else { DataLinkLayer.ActionDllSendFuc(BufferMultiFrameSend.SendFirstFrame()); } BufferMultiFrameSend.RemainFrameCount--; } else { if (MainWindow.m_OperateType != OperateType.WriteAllMasterPara) //(!ParaManageWnd.IsUpdateAllPara) // 关闭参数管理窗口,停止设置参数 清空发送数据 { BufferMultiFrameSend.ClearMessage(); } break; } Thread.Sleep(200); } } catch (Exception ex) { } }
private void ReadDataByID(AppLayerEvent appLayEvent) { int offset = 0; int nDid = DataFormatConvert.GetIntData(appLayEvent.listData, offset, 2); offset += 2; if (nDid == DIDNumber.MasterTelemDID) { MasterRemoteTest(appLayEvent, offset); } else if (((nDid - DIDNumber.PackTelemDID) / 0x400 >= 0) && (nDid - DIDNumber.PackTelemDID) / 0x400 <= 0x0F && (nDid - DIDNumber.PackTelemDID) % 0x400 == 0)//pack DID范围 { } else if (nDid >= DIDNumber.MasterParaDID && nDid < DIDNumber.MasterAdjustDID) //(nDid == DefinitionID.MasterParaDID)//主控参数 { } else if (nDid == DIDNumber.PackParaDID)//pack参数 { } else if (nDid >= DIDNumber.MasterAdjustDID && nDid < DIDNumber.MasterCtrlDID) // 主控校准DID起止(1600, 17FF) { if (nDid == DIDNumber.MasterAdjustDID) // 更新全部 { } else { } } else if (nDid == DIDNumber.PackAdjustDID)//Pack校准 { } else if (nDid == DIDNumber.ReadMasterTimeDID) { ReadMasterTime(appLayEvent, offset); } }
public void treatRecvFrame(AppLayerEvent appLayEvent) { if (appLayEvent.A_PCI == 0x7F) { BlinkCommStatus(CommunicationStatus.RcvError); return; } string strRecv = DataFormatConvert.ListToStr(appLayEvent.listData); BlinkCommStatus(CommunicationStatus.RcvOk); byte sID = (byte)(appLayEvent.A_PCI - 0x40); int offset = 0; switch (sID) { case ServicesID.ReadDataByIdentifier: ReadDataByID(appLayEvent); break; case ServicesID.WriteDataByIdentifier: int responseDid1 = AppLayProtocol.GetIntData(appLayEvent.listData, offset, 2); if (responseDid1 >= DIDNumber.MasterParaDID && responseDid1 < 0x14AE) { } else if (responseDid1 >= DIDNumber.MasterAdjustDID && responseDid1 < DIDNumber.MasterCtrlDID) { } else { } break; case ServicesID.InputOutputControlByIdentifier: int responseDid2 = AppLayProtocol.GetIntData(appLayEvent.listData, offset, 2); if (responseDid2 == DIDNumber.BMSSysTimeDID && MainWindow.m_OperateType == OperateType.ReadBmsTime) //if (responseDid2 == studioConfig.CurrentDid) { } else if (responseDid2 >= DIDNumber.MasterCtrlDID && responseDid2 <= 0x18FF) { } break; case ServicesID.DiagnosticSessionControl: //会话切换 if ((DiagnosticSessionType)appLayEvent.listData[0] == DiagnosticSessionType.ExtendedDiagnosticSession || (DiagnosticSessionType)appLayEvent.listData[0] == DiagnosticSessionType.DefaultSession || (DiagnosticSessionType)appLayEvent.listData[0] == DiagnosticSessionType.ProgrammingSession) { switch (MainWindow.m_OperateType) { case OperateType.WriteMasterPara: case OperateType.WriteAllMasterPara: case OperateType.WriteMasterAdjustPara: case OperateType.WriteAllMasterAdjustPara: case OperateType.WriteMasterControlPara: case OperateType.ReadBmsTime: break; default: break; } } break; case ServicesID.SecurityAccess: //安全访问服务 SecurityAccess(appLayEvent); break; case ServicesID.ClearDiagnosticInformation: //清楚DTC信息 break; case ServicesID.ReadDTCInformation: //读取DTC信息 ReadDTCInfo(appLayEvent); break; case ServicesID.TesterPresent: //诊断仪在线 break; case ServicesID.RoutineControl: // 请求下载 break; case ServicesID.RequestDownload: break; case ServicesID.TransferData: break; default: break; } }