GPS への接続

2016/9/1 (木)

'GPSへの接続
Public m_pRealTimeFeedManager As IRealTimeFeedManager
Public m_pRealTimeFeed As IRealTimeFeed
 
'イベントの取得
Public WithEvents g_pRealTimeFeedManagerEvents As RealTimeFeedManager
 
'GPSへの接続と測位開始
Public Sub StartGPS()
    Set m_pRealTimeFeed = New GpsFeed
'    Set m_pRealTimeFeedManager = New RealTimeFeedManager
     
'    'GPS情報をマップに表示する場合に使用
'    Dim pGpsDisplayProperties As IGpsDisplayProperties
'    Set pGpsDisplayProperties = m_pRealTimeFeedManager
'
'    m_pRealTimeFeedManager.Map = pMap
     
    'GpsFeedの取得
    Dim pGpsFeed As IGpsFeed
    Set pGpsFeed = m_pRealTimeFeed
'    Set pGpsFeed = m_pRealTimeFeedManager.GpsFeed
     
    Dim pGpsConnection As IGpsConnection
    Set pGpsConnection = pGpsFeed.Connection
     
    'GPSへの接続情報を指定
    pGpsConnection.CommPort = 1                                     'COM1ポート
    pGpsConnection.BaudRate = esriGpsBaudRate.esriGpsBaudRate9600   'ボーレート
    pGpsConnection.DataBits = 8                                     'データ ビット
    pGpsConnection.Parity = esriGpsParity.esriGpsParityNone         'パリティ
    pGpsConnection.StopBits = esriGpsStopBits.esriGpsStopBits1      'ストップ ビット
         
    '測位開始
'    Set m_pRealTimeFeedManager.RealTimeFeed = m_pRealTimeFeedManager.GpsFeed
    m_pRealTimeFeed.Start
    m_pRealTimeFeedManager.RealTimeFeed.Start
         
End Sub
 
'GPS情報の取得
Public Sub GetGPSInfo()
    Dim pRealTimeFeed As IRealTimeFeed
'    Set pRealTimeFeed = m_pRealTimeFeedManager.RealTimeFeed
    Set pRealTimeFeed = m_pRealTimeFeed
     
    Debug.Print pRealTimeFeed.CurrentPosition.Longitude, pRealTimeFeed.CurrentPosition.Latitude
 
End Sub
 
'GPSの停止
Public Sub StopGPS()
    Dim pRealTimeFeed As IRealTimeFeed
'    Set pRealTimeFeed = m_pRealTimeFeedManager.RealTimeFeed
    Set pRealTimeFeed = m_pRealTimeFeed
    pRealTimeFeed.Stop
End Sub
 
'サンプル プログラム
'http://resources.esri.com/help/9.3/arcgisdesktop/com/samples/applications/gpsnavigator/faf0845a-931d-4c2f-bb99-bb0bf6776e7f.htm

関連記事

  • この記事を書いた人

羽田 康祐

伊達と酔狂でエクストリーム スポーツに挑む GIS エンジニア。 GIS、IT、趣味に関して日々の出来事で学んだ記憶を記録するためにブログを書いています。同じ問題に出会った方の参考になっていただければ幸いです。GIS を使った自己紹介はこちら

-プログラミング, ArcGIS
-,

Copyright© WINGFIELD since1981 , 2019 All Rights Reserved.