private void ACK_Parse(object[] parameters) { try { ICs sntID = uWAVE.ICsByMessageID((string)parameters[0]); LocalError_Enum errID = (LocalError_Enum)(int)parameters[1]; IsWaitingLocal = false; if (sntID == ICs.IC_H2D_RC_REQUEST) { IsWaitingRemote = true; } ACKReceived.Rise(this, new ACKReceivedEventArgs(sntID, errID)); } catch (Exception ex) { OnInfoEvent(ex); } }
private bool TrySend(string message, ICs queryID) { bool result = IsCommandMode && port.IsOpen && !IsWaitingLocal; if (result) { try { port.SendData(message); IsWaitingLocal = true; lastQueryID = queryID; result = true; OnInfoEvent(string.Format("<< {0}", message)); } catch (Exception ex) { OnInfoEvent(ex); } } return(result); }
private void timer_Tick(object sender, EventArgs e) { if (IsWaitingLocal) { if (++waitingLocalCnt > waitingLocalMaxCnt) { IsWaitingLocal = false; DeviceTimeout.Rise(this, new DeviceTimeoutEventArgs(lastQueryID)); lastQueryID = ICs.IC_INVALID; } } if (IsWaitingRemote) { if (++waitingRemoteCnt > waitingRemoteMaxCnt) { IsWaitingRemote = false; // Device timeout handler, because it probably has caused by poor connection between the modem and this wrapper DeviceTimeout.Rise(this, new DeviceTimeoutEventArgs(ICs.IC_H2D_RC_REQUEST)); } } }
public ACKReceivedEventArgs(ICs sntID, LocalError_Enum errID) { SentenceID = sntID; ErrorID = errID; }
public DeviceTimeoutEventArgs(ICs sntID) { SentenceID = sntID; }
private void port_NewNMEAMessageReceived(object sender, NewNMEAMessageEventArgs e) { bool isParsed = false; NMEASentence result = null; OnInfoEvent(string.Format(">> {0}", e.Message)); try { result = NMEAParser.Parse(e.Message); isParsed = true; } catch (Exception ex) { OnInfoEvent(string.Format("\"{0}\" caused \"{1}\", TargetSite: {2}", e.Message, ex.Message, ex.TargetSite)); } if (isParsed) { if (result is NMEAProprietarySentence) { NMEAProprietarySentence pResult = (result as NMEAProprietarySentence); if (pResult.Manufacturer == ManufacturerCodes.UWV) { ICs sentenceID = uWAVE.ICsByMessageID(pResult.SentenceIDString); if (sentenceID != ICs.IC_INVALID) { if (parsers.ContainsKey(sentenceID)) { parsers[sentenceID](pResult.parameters); } else { // skip unsupported sentence if (UnknownSentenceReceived != null) { UnknownSentenceReceived.Rise(this, new UnknownSentenceEventArgs(result)); } else { OnInfoEvent(string.Format("WARNING: unsupported sentence identifier \"{0}\" (\"{1}\") in \"{2}\"", sentenceID, pResult.SentenceIDString, e.Message)); } } } else { // skip unknown sentence ID if (UnknownSentenceReceived != null) { UnknownSentenceReceived.Rise(this, new UnknownSentenceEventArgs(result)); } else { OnInfoEvent(string.Format("WARNING: unsupported sentence identifier \"{0}\" in \"{1}\"", pResult.SentenceIDString, e.Message)); } } } else { // skip unsupported manufacturer ID if (UnknownSentenceReceived != null) { UnknownSentenceReceived.Rise(this, new UnknownSentenceEventArgs(result)); } else { OnInfoEvent(string.Format("WARNING: unsupported manufacturer identifier \"{0}\" in \"{1}\"", pResult.SentenceIDString, e.Message)); } } } else { // skip standard sentence if (UnknownSentenceReceived != null) { UnknownSentenceReceived.Rise(this, new UnknownSentenceEventArgs(result)); } else { OnInfoEvent(string.Format("WARNING: unsupported standard sentence \"{0}\"", e.Message)); } } } }
public ApplicationUserManager(ICs <ApplicationUser> store) : base(store) { }