Global Mapper v25.0

Someone have GPS functions in C# GlobalMapperDLLWrapper.cs ?

pytpyt83
pytpyt83 Global Mapper User
edited June 2013 in SDK
I have tried to implement GlobalMapperDLLWrapper.cs with GPS functions but it doesn't work in my project. If someone else have already do this job, tell me please your solution ? Thanks

Comments

  • global_mapper
    global_mapper Administrator
    edited June 2013
    What kind of trouble are you having? We can provide assistance declaring any functions that aren't declared already in the wrapper. The tricky part is probably the callback mechanism, but it's really no different than the progress or message callbacks that should have example declarations in the GlobalMapperDLLWrapper.cs file.

    Thanks,

    Mike
    Global Mapper Guru
    geohelp@bluemarblegeo.com
    Blue Marble Geographics for Coordinate Conversion, Image Reprojection and Vector Translation
  • pytpyt83
    pytpyt83 Global Mapper User
    edited June 2013
    Ok, please, have a look on my file :

    public enum GM_gps_format_t8 : uint
    {
    GM_GPS_FORMAT_AUTODETECT,
    GM_GPS_FORMAT_NMEA,
    GM_GPS_FORMAT_GARMIN,
    GM_GPS_NUM_FORMAT_TYPES
    };

    public delegate void Callback();


    [DllImport(DLLFileName, EntryPoint = "GM_GPSStartTrackingSerial")]
    public static extern GM_Error_t32 GM_GPSStartTrackingSerial
    (
    GM_gps_format_t8 aFormat, // format (NMEA or Garmin)
    uint aPort, // COM port for serial connections
    UInt32 aBaud, // baud rate for serial port
    Callback aCallbackFunc, // optional callback function
    UInt32 aReserved // 32-bit reserved value (must be 0)
    );

    [DllImport(DLLFileName, EntryPoint = "GM_GPSGetLocation")]
    public static extern GM_Error_t32 GM_GPSGetLocation
    (
    out GM_Point_t aCurPos, // out: current GPS location
    byte aGetLatLon // in: retrieve coordinates in lat/lon/WGS84 rather than global coords, i put first bool but a recent post show to use byte in place of bool...
    );


    In Main File, I use it :

    GlobalMapperDLL.GM_Error_t32 monErreur;
    monErreur = GlobalMapperDLL.GM_GPSStartTrackingSerial(GM_gps_format_t8.GM_GPS_FORMAT_NMEA, unPort, bauds, null /*new Callback(myFunction)*/, 0);

    => Result : monErreur = GM_Error_NotRegistered

    I use a tool named "NMEA studio" to generate a valid NMEA stream
  • global_mapper
    global_mapper Administrator
    edited June 2013
    The are a few errors in the declarations. I have just added them all to the main SDK build. Here is what to add:


    /*
    GPS TYPES
    */

    // GPS fix type
    public enum GM_gps_fix_t8 : byte
    {
    GM_GPS_FIX_NO_SOLN, // No GPS solution is available
    GM_GPS_FIX_2D, // a 2-dimensional fix is available
    GM_GPS_FIX_3D, // a 3-dimensional fix is available
    GM_GPS_FIX_2D_DIFF, // a 2-dimensional differential or WAAS fix is available
    GM_GPS_FIX_3D_DIFF, // a 3-dimensional differential or WAAS fix is available

    GM_GPS_NUM_FIX_TYPES
    };

    // Format for GPS connection
    public enum GM_gps_format_t8 : byte
    {
    GM_GPS_FORMAT_AUTODETECT,
    GM_GPS_FORMAT_NMEA,
    GM_GPS_FORMAT_GARMIN,

    GM_GPS_NUM_FORMAT_TYPES
    };

    // GPS event notification enumeration
    public enum GM_gps_event_t32 : uint
    {
    GM_GPS_EVENT_NEW_POS, // a new location is available (event data is GM_Point_t* with current lat/lon)
    GM_GPS_EVENT_STATE_CHANGED, // the GPS state has changed
    GM_GPS_EVENT_END_OF_FILE, // the end of a NMEA data file being replayed has been reached

    GM_GPS_NUM_EVENTS
    };

    // GPS NMEA playback flags
    public enum GM_gps_nmea_flags_t32 : uint
    {
    GM_GPS_NMEA_REALTIME_PLAYBACK = 0x00000001, // playback NMEA data stream in real-time rather than as fast as can be read
    };

    // Callback for being notified of GPS status changes.
    public delegate void GM_GPSCallbackFunc
    (
    GM_gps_event_t32 aEvent,
    IntPtr aEventData
    );

    /*
    GPS RENDERING FUNCTIONS
    */

    // Renders a GPS vessel of the given size to the provided device context
    // at the current GPS location.
    [DllImport(DLLFileName, EntryPoint = "GM_GPSRenderVessel")]
    public static extern GM_Error_t32 GM_GPSRenderVessel
    (
    IntPtr aDC, // (HDC) Device context to draw to
    IntPtr aWorldBounds, // (const GM_Rectangle_t*) IN: World bounds to convert from or NULL for last drawn
    IntPtr aPixelRect, // (const GM_PixelRect_t*) IN: Pixel bounds to convert from or NULL for last drawn
    UInt32 aVesselHeight, // IN: The vessel height in pixels
    UInt32 aVesselWidth, // IN: The vessel width in pixels
    UInt32 aVesselColor // (COLORREF) IN: The color to render the vessel in
    );

    /*
    GPS SETUP FUNCTIONS
    */

    // Replay a recorded GPS track from a NMEA log file
    [DllImport(DLLFileName, EntryPoint = "GM_GPSStartTrackingNMEAFile")]
    public static extern GM_Error_t32 GM_GPSStartTrackingNMEAFile
    (
    String aFilename, // full path to NMEA file to use
    GM_gps_nmea_flags_t32 aNmeaFlags, // flags controlling NMEA playback
    GM_GPSCallbackFunc aCallbackFunc, // optional callback function
    IntPtr aReserved // reserved value (must be NULL)
    );

    // Starts tracking a GPS device connected to a serial port
    [DllImport(DLLFileName, EntryPoint = "GM_GPSStartTrackingSerial")]
    public static extern GM_Error_t32 GM_GPSStartTrackingSerial
    (
    GM_gps_format_t8 aFormat, // format (NMEA or Garmin)
    byte aPort, // COM port for serial connections
    UInt32 aBaud, // baud rate for serial port
    GM_GPSCallbackFunc aCallbackFunc, // optional callback function
    UInt32 aReserved // 32-bit reserved value (must be 0)
    );

    // Starts tracking a GPS device connected to a USB port
    [DllImport(DLLFileName, EntryPoint = "GM_GPSStartTrackingUSB")]
    public static extern GM_Error_t32 GM_GPSStartTrackingUSB
    (
    GM_GPSCallbackFunc aCallbackFunc, // optional callback function
    UInt32 aReserved // 32-bit reserved value (must be 0)
    );

    // Stops tracking any connected GPS device
    [DllImport(DLLFileName, EntryPoint = "GM_GPSStopTracking")]
    public static extern GM_Error_t32 GM_GPSStopTracking();

    /*
    GPS STATE QUERY FUNCTIONS
    */

    // Retrieves the current GPS altitude, if valid
    [DllImport(DLLFileName, EntryPoint = "GM_GPSGetAltitude")]
    public static extern GM_Error_t32 GM_GPSGetAltitude
    (
    ref float aAltitude // out: current GPS altitude in meters
    );

    // Retrieves the current GPS bearing, if valid
    [DllImport(DLLFileName, EntryPoint = "GM_GPSGetBearing")]
    public static extern GM_Error_t32 GM_GPSGetBearing
    (
    ref float aBearing // out: current GPS bearing in radians from due north
    );

    // Retrieves the current GPS fix accuracy statistics
    [DllImport(DLLFileName, EntryPoint = "GM_GPSGetFixInfo")]
    public static extern GM_Error_t32 GM_GPSGetFixInfo
    (
    ref float aHorzPosError, // out: current horizontal position error in meters (0.0 if unknown)
    ref float aVertPosError, // out: current vertical position error in meters (0.0 if unknown)
    ref float aPDOP, // out: current position DOP in meters (0.0 if unknown)
    ref UInt32 aNumSats // out: number of satellites used in fix (0 if unknown)
    );

    // Retrieves the current GPS fix type
    [DllImport(DLLFileName, EntryPoint = "GM_GPSGetFixType")]
    public static extern GM_gps_fix_t8 GM_GPSGetFixType();

    // Retrieves the current GPS location
    [DllImport(DLLFileName, EntryPoint = "GM_GPSGetLocation")]
    public static extern GM_Error_t32 GM_GPSGetLocation
    (
    ref GM_Point_t aCurPos, // out: current GPS location
    byte aGetLatLon // in: retrieve coordinates in lat/lon/WGS84 rather than global coords
    );

    // Retrieves the UTC time of the last GPS fix as a C-style time
    [DllImport(DLLFileName, EntryPoint = "GM_GPSGetTime")]
    public static extern GM_Error_t32 GM_GPSGetTime
    (
    ref Int64 aFixTime // out: fix time (time_t)
    );

    // Retrieves the UTC time of the last GPS fix as a C-style time plus fractional seconds
    [DllImport(DLLFileName, EntryPoint = "GM_GPSGetTimeEx")]
    public static extern GM_Error_t32 GM_GPSGetTimeEx
    (
    ref Int64 aFixTime, // out: fix time (time_t)
    ref double aFractionalSeconds // out: fractional seconds to add to fix time
    );

    // Retrieves the current GPS velocity, if valid
    [DllImport(DLLFileName, EntryPoint = "GM_GPSGetVelocity")]
    public static extern GM_Error_t32 GM_GPSGetVelocity
    (
    ref float aVelocity // out: current GPS velocity in m/s
    );


    However the error you are getting means that you don't have a license for the SDK that is being recognized. Have you purchased a SDK license?

    Thanks,

    Mike
    Global Mapper Guru
    geohelp@bluemarblegeo.com
    Blue Marble Geographics for Coordinate Conversion, Image Reprojection and Vector Translation