private void sgworld_OnObjectAction(string ObjectID, IAction66 Action) { //throw new NotImplementedException(); //Console.WriteLine("ObjectID:" + ObjectID + ",action:" + Action.Code.ToString()); if ((Action.Code == ActionCode.AC_WAYPOINT_REACHED) && (sgworld.ProjectTree.GetItemName(ObjectID) == "Train")) //if (sgworld.ProjectTree.GetItemName(ObjectID) == "Train" && Action.Code == ActionCode.AC_WAYPOINT_REACHED) { //mDynamicTrain.Pause = true; //Console.WriteLine(sgworld.ProjectTree.GetItemName(ObjectID)); mNavTrain.GotoNext(mNavTrain_OnFlyTo); } }
void OnProjectTreeAction(string ID, IAction66 Action) { string projectName; if (Action.Code.Equals(ActionCode.AC_SELCHANGED)) { try { projectName = sgworld.ProjectTree.GetItemName(ID); //var branch = sgworld.ProjectTree.FindItem("MiddleLine"); //if (projectName.Equals("Train")) //{ // //sgworld.ProjectTree.SetVisibility(branch, false); // sgworld.Navigate.FlyTo(GlobalVar.gScene.mDynamicTrain, ActionCode.AC_FLYTO); // flyingTick++; // return; //} //sgworld.ProjectTree.SetVisibility(branch, true); foreach (CRailwayProject item in gRWScene.mProjectList) //for (int j = 0; j < CRailwayScene.mProjectList.Count; j++) { if (item.ProjectName.Equals(projectName, StringComparison.InvariantCultureIgnoreCase)) { sgworld.Navigate.FlyTo(sgworld.Creator.CreatePosition(item.mLongitude_Mid, item.mLatitude_Mid, 0, AltitudeTypeCode.ATC_TERRAIN_RELATIVE)); //textBox2.Text = "Project Name\t" + item.mProjectName + "\r\nProject Type\t" + item.mProfessionalName + // "\r\nStart Position\t" + item.mMileage_Start_Des + "\r\nEnd_Position\t" + item.mMileage_End_Des; //timerFlyto.Tag = item.mSerialNo; //timerFlyto.Start(); //System.Threading.Thread.Sleep(2000); //showWebPage(item.mSerialNo); break; } } //flyingTick = 0; } catch (Exception ex) { Console.WriteLine(ex.Message.ToString()); } } }
private void sgworld_OnObjectAction(string ObjectID, IAction66 Action) { //throw new NotImplementedException(); Console.WriteLine("ObjectID:" + ObjectID + ",action:" + Action.Code.ToString()); if (Action.Code == ActionCode.AC_WAYPOINT_REACHED) { //mDynamicTrain.Pause = true; count++; if (count == 200 - 1) { Console.WriteLine("Stop"); //trainFly = true; sgworld.Navigate.FlyTo(sgworld.Creator.CreatePosition(gRWScene.mProjectList[2].mLongitude_Start, gRWScene.mProjectList[2].mLatitude_Start, 0, AltitudeTypeCode.ATC_TERRAIN_RELATIVE, 90, -35.0, 0, 800)); trainBack = true; //System.Threading.Thread.Sleep(20000); //Console.WriteLine("Fly"); //sgworld.Navigate.FlyTo(mDynamicTrain); timerSyncronize.Interval = 20000; } //if (count == 400 - 1) //{ // //System.Threading.Thread.Sleep(20000); // Console.WriteLine("Fly"); // sgworld.Navigate.FlyTo(mDynamicTrain); //} } //else if (Action.Code == ActionCode.AC_STOP) //{ // //trainTime.Start(); // //trainTime.Interval = 20000; // System.Threading.Thread.Sleep(20000); // //timerSyncronize.Interval=20000; // Console.WriteLine("Fly"); // sgworld.Navigate.FlyTo(mDynamicTrain); //} }
private void Sgworld_OnObjectAction(string ObjectID, IAction66 Action) { double d; if (Action.Code == ActionCode.AC_WAYPOINT_REACHED) { string strObjID = sgworld.ProjectTree.GetItemName(ObjectID); if (strObjID.Equals("TrainObj0")) { #if DEBUG Console.WriteLine("计数:" + mTrainWayPointCount + " of " + mTrainWayPointTotal); #endif mTrainWayPointCount = Math.Min(mTrainWayPointCount, mTrainWayPointTotal - 1); if (mTrainWayPointCount % 15 == 14) { RandomFollow(); } //double dis = CoordinateConverter.getUTMDistance(mDynamicTrain[0].Position.X, mDynamicTrain[0].Position.Y, mNavigationList[mNavNextIndex].Longitude, mNavigationList[mNavNextIndex].Latitude); //根据GPS确定里程, mSceneData.mMainPath.getPathMileagebyGPS(rx[mTrainWayPointCount], ry[mTrainWayPointCount], out mMainMileage, out d); //mDynamicTrain[0].Waypoints[mTrainWayPointTotal- mTrainWayPointCount] //mCurrentMileage = rm[mTrainWayPointCount]; mDistoNext = rm[mTrainWayPointTotal - 1] - rm[mTrainWayPointCount]; //#if DEBUG // if (Math.Abs(mDistoNext - dis) > 100) // Console.WriteLine("Something wrong in " + mTrainWayPointCount + " dis " + mDistoNext + " vs " + dis); //#endif string dkcode; double dkm; mSceneData.mMainPath.getDKCodebyPathMileage(mMainMileage, out dkcode, out dkm); string str = mNavigationList[mNavNextIndex].ObjectRef.ToString(); // 更新显示面板 panelInfo.mtotalProj = mNavigationList.Count; panelInfo.mcurrentProj = mNavNextIndex; panelInfo.mdkCode = CRailwayLineList.CombiDKCode(dkcode, dkm); panelInfo.mdistance = Math.Round(mDistoNext, 2); panelInfo.mnextProj = str; panelInfo.mconsLog = mSceneData.GetStrConsByGPS(rx[mTrainWayPointCount], ry[mTrainWayPointCount], 5000); panelInfo.updatePanel(); // 更新2D进度 panel2D.update2DPanel(mMainMileage, 500); if (mDistoNext < 500) // 可能 { ReachOnePlace(); //double dis = CoordinateConverter.getUTMDistance(mDynamicTrain[0].Position.X, mDynamicTrain[0].Position.Y, mNavigationList[mNavIndex + 1].Longitude, mNavigationList[mNavIndex + 1].Latitude); //#if DEBUG // Console.WriteLine("计数:" + mTrainWayPointCount + " of " + mTrainWayPointTotal + "count dis "+ mDistoNext + "\t gis dis" + dis); //#endif // if (mTrainWayPointTotal - mTrainWayPointCount <= 1) // { //#if DEBUG // ModelInfo.Helper.LogHelper.WriteLog(mNavIndex + ":train到达 " + mNavigationList[mNavIndex].ObjectRef.ToString() ); //#endif // //for (int j = 0; j < mDynamicTrain.Length; j++) // //{ // // mDynamicTrain[j].Pause = true; // //} // //mDistoNext = 0; // } } mTrainWayPointCount++; } else if (strObjID.Equals("VirtualObj")) { mVirtualWayPointCount--; if (isOnOneWay && mVirtualOnly) { double dis = CoordinateConverter.getUTMDistance(mVirtualObj.Position.X, mVirtualObj.Position.Y, mNavigationList[mNavNextIndex].Longitude, mNavigationList[mNavNextIndex].Latitude); if (dis < 100 || mVirtualWayPointCount == 0) { #if DEBUG ModelInfo.Helper.LogHelper.WriteLog(mNavIndex + "virtual到达 " + mNavigationList[mNavNextIndex].ObjectRef.ToString() + " 距离为 " + dis); #endif //sgworld.OnObjectAction -= Sgworld_OnObjectAction; ReachOnePlace(); } } } } }