YouTube | Facebook | X(Twitter) | RSS

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上級技術者、Esri認定インストラクター、CompTIA CTT+ Classroom Trainer、潜水士、PADIダイブマスター、四アマ。WordPress は 2.1 からのユーザーで歴だけは長い。 代表著書『"地図リテラシー入門―地図の正しい読み方・描き方がわかる』 GIS を使った自己紹介はこちら。ESRIジャパン(株)所属、元青山学院大学非常勤講師を兼務。日本地図学会第31期常任委員。発言は個人の見解です。

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