protected void str144_Receive(object sender, TcpIpEventArgs e) { if (scApp.getEQObjCacheManager().getLine().ServerPreStop) { return; } int threadID = System.Threading.Thread.CurrentThread.ManagedThreadId; Stopwatch sw = scApp.StopwatchPool.GetObject(); string lockTraceInfo = string.Format("VH ID:{0},Pack ID:{1},Seq Num:{2},ThreadID:{3}," , eqpt.VEHICLE_ID , e.iPacketID , e.iSeqNum.ToString() , threadID.ToString()); try { sw.Start(); LogManager.GetLogger("LockInfo").Debug(string.Concat(lockTraceInfo, "Wait Lock In")); //TODO Wait Lock In SCUtility.LockWithTimeout(str144_lockObj, SCAppConstants.LOCK_TIMEOUT_MS, str144_ReceiveProcess, sender, e); //Lock Out } catch (Exception ex) { LogManager.GetLogger("LockInfo").Error(string.Concat(lockTraceInfo, "Lock Exception")); logger.Error(ex, "(str144_Receive) Exception"); } finally { long ElapsedMilliseconds = sw.ElapsedMilliseconds; LogManager.GetLogger("LockInfo").Debug(string.Concat(lockTraceInfo, "Lock Out. ElapsedMilliseconds:", ElapsedMilliseconds.ToString())); scApp.StopwatchPool.PutObject(sw); } }
protected void str134_ReceiveProcess(object sender, TcpIpEventArgs e) { ID_134_TRANS_EVENT_REP recive_str = (ID_134_TRANS_EVENT_REP)e.objPacket; SCUtility.RecodeReportInfo(eqpt.VEHICLE_ID, 0, recive_str); scApp.VehicleBLL.setAndPublishPositionReportInfo2Redis(eqpt.VEHICLE_ID, recive_str); }
protected void str144_Process(object sender, TcpIpEventArgs e) { ID_144_STATUS_CHANGE_REP recive_str = (ID_144_STATUS_CHANGE_REP)e.objPacket; dynamic receive_process = scApp.VehicleService.Receive; receive_process.StatusReport(bcfApp, eqpt, recive_str, e.iSeqNum); }
protected void str138_Receive(object sender, TcpIpEventArgs e) { ID_138_GUIDE_INFO_REQUEST recive_str = (ID_138_GUIDE_INFO_REQUEST)e.objPacket; dynamic receive_process = scApp.VehicleService.Receive; receive_process.GuideInfoRequest(bcfApp, eqpt, recive_str, e.iSeqNum); }
protected void str136_Process(object sender, TcpIpEventArgs e) { ID_136_TRANS_EVENT_REP recive_str = (ID_136_TRANS_EVENT_REP)e.objPacket; dynamic receive_process = scApp.VehicleService.Receive; receive_process.TranEventReport(bcfApp, eqpt, recive_str, e.iSeqNum); }
protected void str134_Receive(object sender, TcpIpEventArgs e) { if (scApp.getEQObjCacheManager().getLine().ServerPreStop) { return; } try { ID_134_TRANS_EVENT_REP recive_str = (ID_134_TRANS_EVENT_REP)e.objPacket; SCUtility.RecodeReportInfo(eqpt.VEHICLE_ID, 0, recive_str); int current_seq_num = e.iSeqNum; int pre_position_seq_num = eqpt.PrePositionSeqNum; bool need_process_position = true; lock (eqpt.PositionRefresh_Sync) { need_process_position = checkPositionSeqNum(current_seq_num, pre_position_seq_num); eqpt.PrePositionSeqNum = current_seq_num; } if (!need_process_position) { LogHelper.Log(logger: logger, LogLevel: LogLevel.Warn, Class: nameof(EQTcpIpMapAction), Device: Service.VehicleService.DEVICE_NAME_AGV, Data: $"The vehicles updata position report of seq num is old,by pass this one.old seq num;{pre_position_seq_num},current seq num:{current_seq_num}", VehicleID: eqpt.VEHICLE_ID, CarrierID: eqpt.CST_ID); return; } scApp.VehicleBLL.setAndPublishPositionReportInfo2Redis(eqpt.VEHICLE_ID, recive_str); } catch (Exception ex) { logger.Error(ex, "(str134_Receive) Exception"); } }
protected void str132_Process(object sender, TcpIpEventArgs e) { ID_132_TRANS_COMPLETE_REPORT recive_str = (ID_132_TRANS_COMPLETE_REPORT)e.objPacket; dynamic receive_process = scApp.VehicleService.Receive; receive_process.CommandCompleteReport(tcpipAgentName, bcfApp, eqpt, recive_str, e.iSeqNum); }
protected void str172_Receive(object sender, TcpIpEventArgs e) { ID_172_RANGE_TEACHING_COMPLETE_REPORT recive_gpp = (ID_172_RANGE_TEACHING_COMPLETE_REPORT)e.objPacket; dynamic receive_process = scApp.VehicleService.Receive; receive_process.RangeTeachingCompleteReport("", bcfApp, eqpt, recive_gpp, e.iSeqNum); }
public void NotifySetTcpSocketSaeaSession(TcpSocketSaeaClient _session) { ClientSession = _session; TcpIpEventArgs arg = new TcpIpEventArgs(0, 0, null); onTcpIpConnected(arg); }
protected void str152_Receive(object sender, TcpIpEventArgs e) { dynamic receive_process = scApp.VehicleService.Receive; ID_152_AVOID_COMPLETE_REPORT recive_str = (ID_152_AVOID_COMPLETE_REPORT)e.objPacket; receive_process.AvoidCompleteReport(bcfApp, eqpt, recive_str, e.iSeqNum); }
protected void str174_Receive(object sender, TcpIpEventArgs e) { ID_174_ADDRESS_TEACH_REPORT recive_gpp = (ID_174_ADDRESS_TEACH_REPORT)e.objPacket; dynamic receive_process = scApp.VehicleService.Receive; receive_process.AddressTeachReport(bcfApp, eqpt, recive_gpp, e.iSeqNum); }
//todo 需掛上實際資料 protected void str102_Receive(object sender, TcpIpEventArgs e) { //Boolean resp_cmp = false; //STR_VHMSG_VHCL_KISO_VERSION_REP recive_str = TCPUtility._Packet2Str<STR_VHMSG_VHCL_KISO_VERSION_REP>((byte[])e.objPacket, eqpt.TcpIpAgentName); //STR_VHMSG_VHCL_KISO_VERSION_RESP reply_str = new STR_VHMSG_VHCL_KISO_VERSION_RESP() //{ // SeqNum = recive_str.SeqNum, // PacketID = VHMSGIF.ID_VHCL_KISO_VERSION_RESPONSE, // RespCode = 0 //}; //string vhVerionTime = new string(recive_str.VerionStr); //DateTime.TryParse(vhVerionTime, out eqpt.VhBasisDataVersionTime); //resp_cmp = ITcpIpControl.sendSecondary(bcfApp, tcpipAgentName, reply_str); //Console.WriteLine("Recive"); //if (resp_cmp // && eqpt.VHStateMach.CanFire(SCAppConstants.E_VH_EVENT.doDataSync)) //{ // eqpt.VHStateMach.Fire(SCAppConstants.E_VH_EVENT.doDataSync); // doDataSysc(); //} }
public void DecodReciveRawData(byte[] raw_data) { byte[] bytPacketDatas = null; int data_coune = raw_data.Length; int PacketID = 0; UInt16 SeqNum = 0; object objPacket = null; //while (data_coune >= LEN_MESSAGE_SIZE) //{ string result = TCPUtility.PrcConvBytes2HexStr(raw_data, raw_data.Length, " "); Console.WriteLine(reciveCount++); Console.WriteLine(result); // Check Message Header if ((raw_data[0] == '@') && (raw_data[1] == 'P') && (raw_data[2] == 'K') && (raw_data[3] == 'T')) { //bytPacketDatas = TCPUtility.PrcGetPacketFromMessage(raw_data); bytPacketDatas = TCPUtility.PrcGetPacketFromMessage_New(raw_data); PacketID = TCPUtility.PrcGetPacketID(bytPacketDatas); SeqNum = TCPUtility.PrcGetPacketSeqNum(bytPacketDatas); objPacket = bytPacketDatas; TcpIpEventArgs arg = new TcpIpEventArgs(PacketID, SeqNum, objPacket); onTcpIpReceive(PacketID, arg); dataSeqNoOrderToComfirm(PacketID, SeqNum); } //data_coune -= LEN_MESSAGE_SIZE; //Array.Copy(raw_data, LEN_MESSAGE_SIZE, raw_data, 0, data_coune); //} }
protected void str134_ReceiveProcess(object sender, TcpIpEventArgs e) { ID_134_TRANS_EVENT_REP recive_str = (ID_134_TRANS_EVENT_REP)e.objPacket; //TODO 需比較是否有位置重複的問題 => OK //if (!SCUtility.isMatche(eqpt.CUR_SEC_ID, recive_str.CurrentAdrID) || !SCUtility.isMatche(eqpt.CUR_SEC_ID, recive_str.CurrentSecID)) //{ SCUtility.RecodeReportInfo(eqpt.VEHICLE_ID, 0, recive_str); if (recive_str.SecDistance > IGNORE_SECTION_DISTANCE) { scApp.VehicleBLL.setAndPublishPositionReportInfo2Redis(eqpt.VEHICLE_ID, recive_str); } else { LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(EQTcpIpMapAction), Device: "OHxC", Data: $"ignore vh:{eqpt.VEHICLE_ID} of position report,because current section distance:{recive_str.SecDistance} less then {IGNORE_SECTION_DISTANCE}", VehicleID: eqpt.VEHICLE_ID); } //scApp.VehicleBLL.setPositionReportInfo2Redis(eqpt.VEHICLE_ID, recive_str); //scApp.VehicleBLL.PublishPositionReportInfo2Redis(eqpt.VEHICLE_ID, recive_str); //} //dynamic service = scApp.BlockControlServer; //dynamic service = scApp.VehicleService; //ID_134_TRANS_EVENT_REP recive_str = (ID_134_TRANS_EVENT_REP)e.objPacket; //service.PositionReport(bcfApp, eqpt, recive_str, e.iSeqNum); }
//todo 需掛上實際資料 protected void str194_Receive(object sender, TcpIpEventArgs e) { ID_194_ALARM_REPORT recive_gpp = (ID_194_ALARM_REPORT)e.objPacket; dynamic service = scApp.VehicleService; service.AlarmReport(bcfApp, eqpt, recive_gpp, e.iSeqNum); }
protected void str144_Process(object sender, TcpIpEventArgs e) { dynamic service = scApp.VehicleService; ID_144_STATUS_CHANGE_REP recive_str = (ID_144_STATUS_CHANGE_REP)e.objPacket; scApp.VehicleBLL.setAndPublishPositionReportInfo2Redis(eqpt.VEHICLE_ID, recive_str); service.StatusReport(bcfApp, eqpt, recive_str, e.iSeqNum); }
public async void NotifyCloseTcpSocketSaeaSession(TcpSocketSaeaClient _session) { await ClientSession.Close(); ClientSession = null; TcpIpEventArgs arg = new TcpIpEventArgs(0, 0, null); onTcpIpDisconnected(arg); }
protected void str132_Process(object sender, TcpIpEventArgs e) { ID_132_TRANS_COMPLETE_REPORT recive_str = (ID_132_TRANS_COMPLETE_REPORT)e.objPacket; scApp.VehicleBLL.setAndPublishPositionReportInfo2Redis(eqpt.VEHICLE_ID, recive_str); dynamic service = scApp.VehicleService; service.CommandCompleteReport(tcpipAgentName, bcfApp, eqpt, recive_str, e.iSeqNum); }
/// <summary> /// 通知Reply TimeOut /// </summary> /// <param name="e"></param> public void onReplyTimeout(TcpIpEventArgs e) { ImsgStateMachine.Fire(E_Msg_EVENT.TimeOutHappend); if (TcpIpReplyTimeOut != null) { ChangeEventStruct eventStruct = new ChangeEventStruct() { EventHandler = TcpIpReplyTimeOut, EventArgs = e }; triggerEvent(eventStruct); } }
protected void ReplyTimeOutHandler(object sender, TcpIpEventArgs e) { TcpIpExceptionEventArgs excptionArg = e as TcpIpExceptionEventArgs; if (e == null) { return; } scApp.AlarmBLL.onMainAlarm(SCAppConstants.MainAlarmCode.VH_WAIT_REPLY_TIME_OUT_0_1_2 , eqpt.VEHICLE_ID , e.iPacketID , e.iSeqNum); }
public void onErrorHappend(TcpIpEventArgs e) { ImsgStateMachine.Fire(E_Msg_EVENT.ErrorHappend); if (TcpIpSendError != null) { ChangeEventStruct eventStruct = new ChangeEventStruct() { EventHandler = TcpIpSendError, EventArgs = e }; triggerEvent(eventStruct); } }
protected void SendErrorHandler(object sender, TcpIpEventArgs e) { TcpIpExceptionEventArgs excptionArg = e as TcpIpExceptionEventArgs; if (e == null) { return; } scApp.AlarmBLL.onMainAlarm(SCAppConstants.MainAlarmCode.VH_SEND_MSG_ERROR_0_1_2 , eqpt.VEHICLE_ID , e.iPacketID , e.iSeqNum); }
protected void str136_Process(object sender, TcpIpEventArgs e) { //dynamic service = scApp.BlockControlServer; dynamic service = scApp.VehicleService; ID_136_TRANS_EVENT_REP recive_str = (ID_136_TRANS_EVENT_REP)e.objPacket; //switch (recive_str.EventType) //{ // default: // scApp.VehicleBLL.setAndPublishPositionReportInfo2Redis(eqpt.VEHICLE_ID, recive_str); // break; //} scApp.VehicleBLL.setAndPublishPositionReportInfo2Redis(eqpt.VEHICLE_ID, recive_str); service.TranEventReport(bcfApp, eqpt, recive_str, e.iSeqNum); }
protected void str134_Receive_new(object sender, TcpIpEventArgs e) { if (scApp.getEQObjCacheManager().getLine().ServerPreStop) { return; } try { str134_ReceiveProcess(sender, e); } catch (Exception ex) { logger.Error(ex, "(str134_Receive) Exception"); } }
protected void str134_Receive(object sender, TcpIpEventArgs e) { if (scApp.getEQObjCacheManager().getLine().ServerPreStop) { return; } try { ID_134_TRANS_EVENT_REP recive_str = (ID_134_TRANS_EVENT_REP)e.objPacket; SCUtility.RecodeReportInfo(eqpt.VEHICLE_ID, 0, recive_str); dynamic receive_process = scApp.VehicleService.Receive; receive_process.PositionReport(bcfApp, eqpt, recive_str, e.iSeqNum); } catch (Exception ex) { logger.Error(ex, "(str134_Receive) Exception"); } }
public void DecodReciveRawData_Google(byte[] raw_data) { byte[] bytPacketDatas = raw_data; UInt16 PacketID = 0; UInt16 SeqNum = 0; object objPacket = null; string result = TCPUtility.PrcConvBytes2HexStr(bytPacketDatas, bytPacketDatas.Length, " "); Console.WriteLine(reciveCount++); Console.WriteLine(result); unPackWrapperMsg(bytPacketDatas, out PacketID, out SeqNum, out objPacket); TcpIpEventArgs arg = new TcpIpEventArgs(PacketID, SeqNum, objPacket); onTcpIpReceive(PacketID, arg); dataSeqNoOrderToComfirm(PacketID, SeqNum); }
protected void str152_Receive(object sender, TcpIpEventArgs e) { ID_152_AVOID_COMPLETE_REPORT recive_str = (ID_152_AVOID_COMPLETE_REPORT)e.objPacket; if (checkAvoidCompletePositionInfoIsCorrect(recive_str)) { scApp.VehicleBLL.setAndPublishPositionReportInfo2Redis(eqpt.VEHICLE_ID, recive_str); } else { LogHelper.Log(logger: logger, LogLevel: LogLevel.Debug, Class: nameof(EQTcpIpMapAction), Device: "AGVC", Data: $"Avoid complete info not correct,by pass it", VehicleID: eqpt.VEHICLE_ID, CarrierID: eqpt.CST_ID); } dynamic service = scApp.VehicleService; service.AvoidCompleteReport(bcfApp, eqpt, recive_str, e.iSeqNum); }
/// <summary> /// 通知Receive stream function /// </summary> /// <param name="PacketID">通知的Stream Function</param> /// <param name="e"></param> public void onTcpIpReceive(int PacketID, TcpIpEventArgs e) { EventHandler <TcpIpEventArgs> tmpEventHandler = null; lock (RealTcpIpReceivedDic) { if (RealTcpIpReceivedDic.ContainsKey(PacketID)) { tmpEventHandler = RealTcpIpReceivedDic[PacketID]; } } if (tmpEventHandler != null) { ChangeEventStruct eventStruct = new ChangeEventStruct() { EventHandler = tmpEventHandler, EventArgs = e }; triggerEvent(eventStruct); } }
//todo 需掛上實際資料 protected void str162_Receive(object sender, TcpIpEventArgs e) { //Boolean resp_cmp = false; //STR_VHMSG_INDIVIDUAL_DOWNLOAD_REQ recive_str = TCPUtility._Packet2Str<STR_VHMSG_INDIVIDUAL_DOWNLOAD_REQ>((byte[])e.objPacket, eqpt.TcpIpAgentName); ////todo 修改成正確的內容 //STR_VHMSG_INDIVIDUAL_DOWNLOAD_REP reply_str = new STR_VHMSG_INDIVIDUAL_DOWNLOAD_REP() //{ // SeqNum = recive_str.SeqNum, // PacketID = VHMSGIF.ID_TRANS_EVENT_RESPONSE, // OffsetAddrPos = 10000, // OffsetGuideFL = 20000, // OffsetGuideFR = 30000, // OffsetGuideRL = 40000, // OffsetGuideRR = 50000 //}; //resp_cmp = ITcpIpControl.sendSecondary(bcfApp, tcpipAgentName, reply_str); //Console.WriteLine("Recive"); //if (resp_cmp) // eqpt.VHStateMach.Fire(SCAppConstants.E_VH_EVENT.CompensationDataRep); }
/// <summary> /// 通知SECS Connected /// </summary> /// <param name="e"></param> public void onTcpIpConnected(TcpIpEventArgs e) { IsConnection = true; EventHandler <TcpIpEventArgs> tmpEventHandler = null; lock (RealTcpIpConnetedDic) { if (RealTcpIpConnetedDic.ContainsKey(ConnectedEventName.Trim())) { tmpEventHandler = RealTcpIpConnetedDic[ConnectedEventName]; } } if (tmpEventHandler != null) { ChangeEventStruct eventStruct = new ChangeEventStruct() { EventHandler = tmpEventHandler, EventArgs = e }; triggerEvent(eventStruct); } }