Exemple #1
0
 /// <summary>
 /// Handles the PositionRecieved event of the nmeaInterpreter control.
 /// </summary>
 /// <param name="TxSender">The source of the event.</param>
 /// <param name="e">The <see cref="DotSpatial.Positioning.PositionEventArgs"/> instance containing the event data.</param>
 private void nmeaInterpreter_PositionRecieved(object TxSender, PositionEventArgs e)
 {
     log.Debug("Got NMEA Sentance");
     if (hasFix)
     {
         LocationCylinder currentloc = new LocationCylinder();
         currentloc.CodeValue = LocationCreationCodeList.MACHINE_GPS;
         try
         {
             log.Debug("Updating position object");
             if (!e.Position.IsInvalid && !e.Position.IsEmpty)
             {
                 currentloc.LocationPoint.Point.Lat    = e.Position.Latitude.DecimalDegrees;
                 currentloc.LocationPoint.Point.Lon    = e.Position.Longitude.DecimalDegrees;
                 currentloc.LocationPoint.Point.Height = nmeaInterpreter.Altitude.ToMeters().Value;
                 this.CurrentLocation = currentloc;
                 log.Debug("Lat: " + currentloc.LocationPoint.Point.Lat + "\tLon: " + currentloc.LocationPoint.Point.Lat + "\tHeight: " + currentloc.LocationPoint.Point.Height);
             }
             else
             {
                 log.Error("Position contain no value or is invalid.");
             }
         }
         catch (Exception ex)
         {
             log.Error("Could not update position object", ex);
         }
     }
 }
Exemple #2
0
        private void sendTimer_Tick(object sender, ElapsedEventArgs e)
        {
            this.sendTimer.Stop();
            DEv1_0 de = new DEv1_0();

            de.CombinedConfidentiality = "U";
            de.DateTimeSent            = DateTime.UtcNow;
            de.DistributionID          = PinPointConfig.UnitID;
            de.SenderID = "*****@*****.**";
            de.DistributionReference.Add(PinPointConfig.UnitID + "," + de.SenderID + ",1753-01-01T00:00:00.0000000Z");
            de.DistributionStatus = StatusValue.Actual;
            de.DistributionType   = TypeValue.Update;
            de.Language           = "en-US";

            Event emlc = new Event();

            emlc.EventID = PinPointConfig.UnitID;
            LocationCylinder loc = new LocationCylinder();

            loc.CodeValue = gpsManager.CurrentLocation.CodeValue;
            loc.LocationCylinderHalfHeightValue = -99999;
            loc.LocationCylinderRadiusValue     = -99999;
            loc.LocationPoint.Point.Height      = gpsManager.CurrentLocation.LocationPoint.Point.Height;
            loc.LocationPoint.Point.Lat         = gpsManager.CurrentLocation.LocationPoint.Point.Lat;
            loc.LocationPoint.Point.Lon         = gpsManager.CurrentLocation.LocationPoint.Point.Lon;
            loc.LocationPoint.Point.srsName     = "http://metadata.ces.mil/mdr/ns/GSIP/crs/WGS84E_3D";
            emlc.EventLocation.LocationCylinder = loc;
            emlc.EventMessageDateTime           = DateTime.UtcNow;
            emlc.EventTypeDescriptor.CodeValue  = (EventTypeCodeList)Enum.Parse(typeof(EventTypeCodeList), PinPointConfig.UnitType);
            emlc.EventTypeDescriptor.EventTypeDescriptorExtension.Add(emlc.EventTypeDescriptor.CodeValue.ToString().Replace("_", "."));
            emlc.EventValidityDateTimeRange.StartDate = emlc.EventMessageDateTime;
            emlc.EventValidityDateTimeRange.EndDate   = emlc.EventMessageDateTime.AddMinutes(30);

            ResourceDetail resourceDetail = new ResourceDetail();

            resourceDetail.Status = new ResourceStatus();
            TextStatus textStatus = new TextStatus();

            textStatus.Description = "Foo";
            textStatus.SourceID    = "VA.LCFR";
            resourceDetail.Status.SecondaryStatus = new List <AltStatus>();
            resourceDetail.Status.SecondaryStatus.Add(textStatus);

            //Log.Info(@"Type: " + unitStatus + " and the file is at " + UNITSTATPATH);
            resourceDetail.setPrimaryStatus(ResourcePrimaryStatusCodeList.Available);
            emlc.Details = resourceDetail;



            List <string> keywords = new List <string>();

            keywords.Add("PinPoint AvL");
            keywords.Add(PinPointConfig.UnitID);
            keywords.Add(emlc.EventTypeDescriptor.CodeValue.ToString().Replace("_", "."));
            ContentObject co = new ContentObject("http://edxlsharp.codeplex.com/ValueLists/ContentKeywords", keywords);

            co.XMLContent = new XMLContentType();
            co.XMLContent.EmbeddedXMLContent = new List <XElement>();
            string   str = emlc.ToString();
            XElement xe  = XElement.Parse(str);

            co.XMLContent.AddEmbeddedXML(xe);
            co.ContentDescription = "PinPoint AvL";
            de.ContentObjects.Add(co);
            XmlSerializer     x         = new XmlSerializer(de.GetType());
            XmlWriterSettings xsettings = new XmlWriterSettings();

            xsettings.Indent             = true;
            xsettings.OmitXmlDeclaration = true;

            using (var stream = new StringWriter())
                using (var writer = XmlWriter.Create(stream, xsettings))
                {
                    x.Serialize(writer, de);
                    str = stream.ToString();
                }
            HttpWebRequest  request;
            HttpWebResponse resp;
            //WebProxy proxy;
            string requesturi = PinPointConfig.PostURL;

            request                   = (HttpWebRequest)WebRequest.Create(requesturi);
            request.KeepAlive         = true;
            request.Method            = "POST";
            request.ContentType       = "text/xml";
            request.AllowAutoRedirect = true;
            request.ContentLength     = Encoding.UTF8.GetByteCount(str);

            /*if (!String.IsNullOrWhiteSpace(proxyHostName) && !String.IsNullOrWhiteSpace(proxyPort))
             * {
             * proxy = new WebProxy();
             * proxy.Address = new Uri("http://" + proxyHostName + ":" + proxyPort);
             * if (!string.IsNullOrWhiteSpace(proxyUsername) && !string.IsNullOrEmpty(proxyPassword))
             * {
             *  proxy.Credentials = new NetworkCredential(proxyUsername, proxyPassword);
             * }
             * request.Proxy = proxy;
             * }*/
            try
            {
                SetBody(request, str);
                resp = (HttpWebResponse)request.GetResponse();
                resp.Close();
            }
            catch (Exception ex)
            {
                log.Error("Error in HTTPSender: " + ex.ToString());
            }
            OnSent(EventArgs.Empty);
            this.sendTimer.Start();
        }