public static string GetSECSErrorMessage(SECSErrors err) { if (SECSErrorsMessage.errorMessageDict.ContainsKey(err)) { return(SECSErrorsMessage.errorMessageDict[err]); } return(""); }
internal void CallSECSEvent(SECSEventType type, SECSTransaction trans, SECSErrors err, string errmsg) { if (type == SECSEventType.Error || type == SECSEventType.Warn) { this.logger.Error(string.Format("SystemBytes: {0}, ERRCODE: {1}, ERRDESC: {2}.", (trans != null) ? trans.SystemBytes.ToString() : "null", err, errmsg)); } if (this.OnSECSEvent != null) { this.OnSECSEvent(this, type, trans, err, errmsg); } }
internal void NotifyEVENT(SECSEventType type, SECSTransaction trans, SECSErrors err) { lock (this.syncObject) { SECS1EventArgs args = new SECS1EventArgs { EventType = type, ErrorCode = err, ErrorMsg = SECSErrorsMessage.GetSECSErrorMessage(err), Trans = trans }; this.eventQueue.Enqueue(args); } }
internal void NotifyERROR(SECSErrors err, SECSMessage msg) { lock (this.syncObject) { SECS1EventArgs args = new SECS1EventArgs { EventType = SECSEventType.Error, ErrorCode = err, ErrorMsg = SECSErrorsMessage.GetSECSErrorMessage(err) }; if (msg != null) { args.Trans = msg.Transaction; } else { args.Trans = null; } this.eventQueue.Enqueue(args); } }
private void RemoveConversationTimeout(SECSEventType eventtype, SECSTransaction trans, SECSErrors err) { if (eventtype == SECSEventType.PrimaryRcvd && trans != null && trans.Primary != null && err == SECSErrors.None) { string str = string.Format("S{0}F{1}", trans.Primary.Stream, trans.Primary.Function); if (this.conversactionReflect.ContainsKey(str)) { lock (this.syncConversation) { int num = -1; for (int i = 0; i < this.conversationList.Count; i++) { if (this.conversationList[i].Transaction1 == this.conversactionReflect[str]) { num = i; break; } } if (num != -1) { this.conversationList.RemoveAt(num); } } } } }
public bool PreHandleSECSEvent(SECSEventType eventtype, SECSTransaction trans, SECSErrors err) { this.UpdateMatchedSecondary(eventtype, trans); if (!this.IsHost) { if (!this.CheckS9F1Exception(eventtype, trans)) { return(false); } if (!this.CheckS9F357Exception(eventtype, trans)) { return(false); } if (eventtype == SECSEventType.Error && err == SECSErrors.T3TimeOut) { this.SendS9Fx(9, trans.Primary.Header); return(true); } this.AddConversationTimeout(eventtype, trans, err); this.RemoveConversationTimeout(eventtype, trans, err); } return(true); }
private void AddConversationTimeout(SECSEventType eventtype, SECSTransaction trans, SECSErrors err) { if (eventtype == SECSEventType.SecondarySent && err == SECSErrors.None && trans != null && trans.Secondary != null) { string str = string.Format("S{0}F{1}", trans.Secondary.Stream, trans.Secondary.Function); if (this.conversactionConfigure.ContainsKey(str)) { if (str == "S3F12") { if (trans.Secondary.Root.Item(2).IsEmpty) { return; } if ((int)trans.Secondary.Root.Item(2).Value != 2) { return; } } else { if (trans.Secondary.Root.IsEmpty) { return; } if ((int)trans.Secondary.Root.Value != 0) { return; } } SECSS9FxMonitor.ConversactionItem item = new SECSS9FxMonitor.ConversactionItem { Transaction1 = this.conversactionConfigure[str].Transaction1, Transaction2 = this.conversactionConfigure[str].Transaction2, Transaction = trans }; try { item.EDID = trans.Primary.Root.Item(1).Value.ToString(); item.EDID = this.conversactionConfigure[str].EDID + ": " + item.EDID; } catch (Exception) { item.EDID = this.conversactionConfigure[str].EDID; } lock (this.syncConversation) { item.DeadLine = DateTime.Now.AddSeconds(45.0); this.conversationList.Add(item); } } } }
async private void OnSECSEventHandler(SECSPort secsPort, SECSEventType type, SECSTransaction trans, SECSErrors err, string errmsg) { try { XElement xmlMessage = secsPort.Library.TransToXElement(trans); switch (type) { case SECSEventType.PrimaryRcvd: if (err == SECSErrors.None) { if (secsPortList.Count < 1) { xmlMessage.Element("Primary").Add(new XElement("UnitName", _unitID)); } else { xmlMessage.Element("Primary").Add(new XElement("UnitName", secsPortList.First(j => j.Value.DeviceID == secsPort.DeviceID).Key)); } await Task.Factory.StartNew(() => DispatchPrimaryInGEMMessage(secsPort.Name, trans, xmlMessage)); } //else //_logWriter.Write(String.Format("Error Code: {0}. {1}", trans.Name, errmsg), "ApplicationException", 0, 8000, System.Diagnostics.TraceEventType.Error, "Primary Recvd Error!"); //BOE_CIS20EventSource.Log.ReceiveSECSIIMessage(trans.Name, xmlMessage.Element("Primary").ToString()); //_logWriter.Write(xmlMessage.Element("Primary"), "SECSII", 0, 7000, System.Diagnostics.TraceEventType.Information, "Rcvd " + trans.Name); break; case SECSEventType.SecondaryRcvd: string transName = ParseMessageName(trans.Primary.Stream, trans.Secondary.Function); //S9F* SecsDriver 会自动恢复,不用自己处理 //if (err == SECSErrors.T3TimeOut && trans.Name == "S1F14") //{ // _dispatchGEMMessage.CommunicationFailure("S1F14", null); //} await Task.Factory.StartNew(() => DispatchSecondaryInGEMMessage(transName, xmlMessage)); //_logWriter.Write(xmlMessage.Element("Secondary"), "SECSII", 0, 7000, System.Diagnostics.TraceEventType.Information, "Rcvd " + transName); break; case SECSEventType.PrimarySent: //_logWriter.Write(xmlMessage.Element("Primary"), "SECSII", 0, 7000, System.Diagnostics.TraceEventType.Information, "Sent " + trans.Name); break; case SECSEventType.SecondarySent: //_logWriter.Write(xmlMessage.Element("Secondary"), "SECSII", 0, 7000, System.Diagnostics.TraceEventType.Information, "Reply " + ParseMessageName(trans.Primary.Stream, trans.Secondary.Function)); break; case SECSEventType.HSMSDisconnected: DispatchSecondaryInGEMMessage("S99F1", null); //_logWriter.Write("HSMS is Disconnected", "SECSII"); break; case SECSEventType.HSMSConnected: DispatchSecondaryInGEMMessage("S1F13", null); //_logWriter.Write("HSMS is Connected", "SECSII"); break; case SECSEventType.Error: if (err == SECSErrors.T3TimeOut && trans.Name == "S1F13") { DispatchSecondaryInGEMMessage("S1F14", xmlMessage); } if (err == SECSErrors.ReadError || err == SECSErrors.WriteError) { DispatchSecondaryInGEMMessage("S99F2", null); } string name = ""; if (trans != null) { //if (err == SECSErrors.T3TimeOut) // name = ParseMessageName(trans.Primary.Stream, trans.Secondary.Function); //else name = trans.Name; } //_logWriter.Write(String.Format(" ErrorCode: {0} {1}", err, errmsg), "ApplicationException", 0, 8000, System.Diagnostics.TraceEventType.Error, name + ": SECSDriver Error!"); break; } } catch (NullReferenceException n) { } catch (Exception e) { } //Logging }
private void Secs1Port_OnSECS1Event(SECSEventType eventtype, SECSTransaction trans, SECSErrors err, string errmsg) { if (this.s9FxMonitor.PreHandleSECSEvent(eventtype, trans, err)) { this.CallSECSEvent(eventtype, trans, err, errmsg); } }
private void HsmsPort_OnHSMSEvent(SECSEventType eventtype, SECSTransaction trans, SECSErrors err, string errmsg) { if (eventtype == SECSEventType.HSMSConnected) { this.isConnected = true; } else if (eventtype == SECSEventType.HSMSDisconnected) { this.isConnected = false; } if (this.s9FxMonitor.PreHandleSECSEvent(eventtype, trans, err)) { this.CallSECSEvent(eventtype, trans, err, errmsg); } }
private void eventExecutor_OnSECS1Event(SECSEventType eventtype, SECSTransaction trans, SECSErrors err, string errmsg) { if (this.OnSECS1Event != null) { this.OnSECS1Event(eventtype, trans, err, errmsg); } }