/// <summary> /// Send indication report from a specific sensor to every mars client subscribed /// </summary> /// <param name="sensorName">configured sensor name</param> /// <param name="detections">Report's content</param> public void SendIndicationReport(string sensorName, params IndicationType[] detections) { if (detections.Length > 0) { foreach (var mars in _marsClients) { if (mars.Value.SubscriptionTypes != null) { if (mars.Value.SubscriptionTypes.Contains(SubscriptionTypeType.OperationalIndication)) { if (detections.Length > 400) { detections = detections.Take(400).ToArray(); } DeviceIndicationReport indicationReport = CreateIndicationReport(detections, sensorName); if (indicationReport != null) { SendSingleIndicationReport(indicationReport, mars.Key); } } } } _lastDetectionReceived = detections.Last(); } }
/// <remarks/> public System.IAsyncResult BegindoDeviceIndicationReport(DeviceIndicationReport DeviceIndicationReport, System.AsyncCallback callback, object asyncState) { doDeviceIndicationReportRequest inValue = new doDeviceIndicationReportRequest(); inValue.DeviceIndicationReport = DeviceIndicationReport; return(((SNSR_STDSOAPPort)(this)).BegindoDeviceIndicationReport(inValue, callback, asyncState)); }
/// <remarks/> public DeviceStatusReport doDeviceIndicationReport(DeviceIndicationReport DeviceIndicationReport) { doDeviceIndicationReportRequest inValue = new doDeviceIndicationReportRequest(); inValue.DeviceIndicationReport = DeviceIndicationReport; doCommandMessageResponse retVal = ((SNSR_STDSOAPPort)(this)).doDeviceIndicationReport(inValue); return(retVal.DeviceStatusReport); }
private void SendSingleIndicationReport(DeviceIndicationReport report, string marsName) { if (_marsClients.ContainsKey(marsName)) { if (!ValidateMessages || report.IsValid(out var exception)) { _marsClients[marsName].SoapClient.BegindoDeviceIndicationReport(report, null, null); MessageSent?.BeginInvoke(report, marsName, null, null); } else { ValidationErrorOccured?.Invoke(this, new InvalidMessageException(report, exception)); } } }
private IndicationType[] ExtractIndications(DeviceIndicationReport indicationReport) { List <IndicationType> indications = new List <IndicationType>(); foreach (var deviceReport in indicationReport.Items.OfType <DeviceIndicationReport>()) { indications.AddRange(ExtractIndications(deviceReport)); } foreach (var sensorReport in indicationReport.Items.OfType <SensorIndicationReport>()) { indications.AddRange(sensorReport.IndicationType); } return(indications.ToArray()); }
private DeviceIndicationReport CreateIndicationReport(IndicationType[] detections, string sensorName = null) { List <IndicationType> indications = new List <IndicationType>(); int i = 0; double azimuth = 0; foreach (IndicationType indication in detections) { // add direction to aerial detections if (indication.Item is AerialTrackDetectionType trackDetectionType) { // calculate azimuth by previous location if (i > 0 && detections[i - 1].ID == indication.ID) { IndicationType previous = detections[i - 1]; if (previous.Item is AerialTrackDetectionType aerialTrack) { System.Windows.Point a = UnitConverter.LocationToPoint(trackDetectionType.Location); System.Windows.Point b = UnitConverter.LocationToPoint(aerialTrack.Location); azimuth = UnitConverter.DegreeToMils(UnitConverter.RadianToDegree(CalculateAzimuth(a, b))); } } // if no previous, look for the last aerial detection with the same ID else if (_lastDetectionReceived != null && _lastDetectionReceived.ID == indication.ID) { if (_lastDetectionReceived.Item is AerialTrackDetectionType aerialTrack) { System.Windows.Point a = UnitConverter.LocationToPoint(trackDetectionType.Location); System.Windows.Point b = UnitConverter.LocationToPoint(aerialTrack.Location); azimuth = UnitConverter.DegreeToMils(UnitConverter.RadianToDegree(CalculateAzimuth(a, b))); } } trackDetectionType.Direction = new AzimuthType { Units = AngularUnitsType.Mils, Value = azimuth, }; } indications.Add(indication); i++; } // create identification items DeviceIdentificationType deviceIdentificationType; SensorIdentificationType sensorIdentification; if (sensorName != null) { // if device hub if (DeviceConfiguration.DeviceConfiguration1 != null) { // find wanted device (sensorName == device name) DeviceConfiguration deviceConfiguration = DeviceConfiguration.DeviceConfiguration1.FirstOrDefault(x => x.DeviceIdentification.DeviceName == sensorName); deviceIdentificationType = deviceConfiguration?.DeviceIdentification; // take first sensor SensorConfiguration sensorConfiguration = deviceConfiguration?.SensorConfiguration.FirstOrDefault(); sensorIdentification = sensorConfiguration?.SensorIdentification; } else { // take first device deviceIdentificationType = DeviceConfiguration.DeviceIdentification; // find wanted sensor (sensorName == sensor name) SensorConfiguration sensorConfiguration = DeviceConfiguration.SensorConfiguration.FirstOrDefault(x => x.SensorIdentification.SensorName == sensorName); sensorIdentification = sensorConfiguration?.SensorIdentification; } } else { deviceIdentificationType = DeviceConfiguration.DeviceIdentification; SensorConfiguration sensorConfiguration = DeviceConfiguration.SensorConfiguration.FirstOrDefault(); sensorIdentification = sensorConfiguration?.SensorIdentification; } SensorIndicationReport sensorIndication = new SensorIndicationReport { IndicationType = indications.ToArray(), SensorIdentification = sensorIdentification }; object content; // if device hub if (DeviceConfiguration.DeviceConfiguration1 != null) { content = new DeviceIndicationReport { DeviceIdentification = deviceIdentificationType, ProtocolVersion = ProtocolVersionType.Item22, Items = new object[] { sensorIndication } }; } else { content = sensorIndication; } // main device DeviceIndicationReport indicationReport = new DeviceIndicationReport { DeviceIdentification = DeviceConfiguration.DeviceIdentification, Items = new[] { content, } }; return(indicationReport); }
/// <remarks/> public doDeviceIndicationReportRequest(DeviceIndicationReport DeviceIndicationReport) { this.DeviceIndicationReport = DeviceIndicationReport; }