void tracker_DetectionsReceived(object sender, SonitorEventArgs e) { var msg = (DetectionsMessage)e.Message; DataReceived(this, new DataEventArgs(msg)); foreach (var detection in msg.Detections) { if (!CheckIfTagExists(detection)) return; CheckDetectorChanges(detection); CheckBatteryData(detection); CheckTagButtonData(detection); CheckTagMove(detection); Detection(Detectors[detection.HostName], new DetectionEventArgs { Aplitude = detection.Amplitude, Confidence = detection.ConfidenceLevel, Detector = Detectors[detection.HostName], Tag = Tags[detection.TagId], TimeStamp = detection.DateTime }); } }
void tracker_DetectorsReceived(object sender, SonitorEventArgs e) { var msg = (DetectorsMessage)e.Message; DataReceived(this, new DataEventArgs(msg)); foreach (var det in msg.Detectors) { bool updated = false; Detectors.AddOrUpdate(det.HostName, det, (k, v) => { Detectors[det.HostName] = det; DetectorStateChanged(this, new DetectorEventArgs(Detectors[det.HostName])); updated = true; return det; } ); if (!updated) DetectorAdded(this, new DetectorEventArgs(Detectors[det.HostName])); } }
void tracker_DetectorStatusReceived(object sender, SonitorEventArgs e) { var msg = (DetectorStatusMessage)e.Message; DataReceived(this, new DataEventArgs(msg)); foreach (var state in msg.DetectorStates) { Detectors[state.HostName].Channel = state.Channel; Detectors[state.HostName].Status = (state.Online ? OperationStatus.Online : OperationStatus.Offline); DetectorStateChanged(this, new DetectorEventArgs(Detectors[state.HostName])); } }
void tracker_MapsReceived(object sender, SonitorEventArgs e) { var msg = (MapsMessage)e.Message; DataReceived(this, new DataEventArgs(msg)); }
void tracker_ProtocolReceived(object sender, SonitorEventArgs e) { var msg = (ProtocolVersionMessage)e.Message; DataReceived(this, new DataEventArgs(msg)); }
void tracker_TagsReceived(object sender, SonitorEventArgs e) { var msg = (TagsMessage)e.Message; DataReceived(this, new DataEventArgs(msg)); foreach (var tag in msg.Tags) { bool updated = false; Tags.AddOrUpdate(tag.Id, tag, (k, v) => { Tags[tag.Id] = tag; TagStateChanged(null, new TagEventArgs(tag)); return tag; }); if (updated) TagAdded(null, new TagEventArgs(tag)); } }