コード例 #1
0
ファイル: VechileMngr.cs プロジェクト: pigmon/AllPath
    public void FetchData()
    {
        Dictionary <int, VehicleStates> all_path_param = new Dictionary <int, VehicleStates>();

        List <int> vid_list = new List <int>(dict_updgram.Keys);

        for (int i = 0; i < vid_list.Count; i++)
        {
            int           vid   = vid_list[i];
            G.UplinkDGram dgram = new G.UplinkDGram();
            net_agent.FetchData(vid, ref dgram);
            dict_updgram[vid] = dgram;

            // for AllPathCtrl
            double x         = dgram.m_path_x * 0.0001;
            double y         = dgram.m_path_y * 0.0001;
            double heading   = dgram.m_path_heading * 0.01;
            int    path_id   = dgram.m_path_id;
            bool   b_request = dgram.m_ctrl_info > 0;

            VehicleStates stats = new VehicleStates(x, y, heading, path_id, b_request);
            all_path_param.Add(vid, stats);
        }

        truck_mngr.UpdateVehicleStates(all_path_param);
    }
コード例 #2
0
 /// <summary>
 /// 当接收到车辆回传信息报文后,更新所有车辆的位置、航向角、当前路径ID及是否有接管请求。
 /// </summary>
 /// <param name="_dict">[VehicleID:VehicleStates]形式的字典,来源于车辆上行报文</param>
 public void UpdateVehicleStates(Dictionary <int, VehicleStates> _dict)
 {
     lock (__LOCKOBJ__)
     {
         foreach (KeyValuePair <int, VehicleStates> pair in _dict)
         {
             int vid = pair.Key;
             if (m_vehicle_states.ContainsKey(vid))
             {
                 Vector2 real_pos = new Vector2((float)pair.Value.x, (float)pair.Value.y);
                 Vector2 gui_pos  = MapBG.CoordTrans_TruckPos_Texture2D(real_pos);
                 m_vehicle_states[vid] = new VehicleStates(gui_pos.x, gui_pos.y, -1 * (pair.Value.heading + 90), pair.Value.current_path, pair.Value.request);
             }
         }
     }
 }