public IEnumerator loadDatasetCoroutine() { Landmark landmark = exp.getLandmark(); while (!isSetup || !landmark.getDat().isLoaded() || !landmark.getXML().isLoaded()) { yield return(null); } t = TrackerManager.Instance.GetTracker <ObjectTracker>(); if (dataSets.ContainsKey(landmark)) { ds = dataSets[landmark]; } else { ds = t.CreateDataSet(); IFileManager iFileManager = ServiceLocator.getIFileManager(); iFileManager.pushDirectory(iFileManager.getBaseDirectory()); // TODO: FIX ISSUE w/ LOADING FROM RESOURCES if (ds.Load(CachedLoader.convertWebToLocalPath(landmark.getXML().getPath(), PathType.RELATIVE), VuforiaUnity.StorageType.STORAGE_ABSOLUTE)) { dataSets[landmark] = ds; } else { IFileManager fm = ServiceLocator.getIFileManager(); string paXML = "tmp.xml", paDat = "tmp.dat"; Reference <string> fileXML = landmark.getXML(); Reference <byte[]> fileDat = landmark.getDat(); fm.writeToFile(paXML, fileXML.getResource()); fm.writeToFile(paDat, fileDat.getResource()); if (ds.Load(paXML, VuforiaUnity.StorageType.STORAGE_ABSOLUTE)) { dataSets[landmark] = ds; } else { ds = null; } fm.deleteFile(paXML); fm.deleteFile(paDat); } iFileManager.popDirectory(); } if (ds != null) { t.Stop(); t.ActivateDataSet(ds); t.Start(); IEnumerable <TrackableBehaviour> tbs = TrackerManager.Instance.GetStateManager().GetTrackableBehaviours(); foreach (TrackableBehaviour tb in tbs) { // change general name to include trackable name GameObject tbg = tb.gameObject; DefaultTrackableEventThing dtet = GameObjectUtility.GetComponent <DefaultTrackableEventThing>(tbg); TurnOffThing tot = GameObjectUtility.GetComponent <TurnOffThing>(tbg); if (tb.TrackableName == exp.getId()) { defaultTracker = dtet; dtet.enabled = true; if (tb.name != tb.TrackableName) { tb.name = tb.TrackableName; planeGroup = new GameObject("planeGroup"); planeGroup.transform.parent = tbg.transform; planeGroup.transform.localPosition = new Vector3(0f, 0f, 0f); planeGroup.transform.localRotation = Quaternion.identity; overlayPlane = GameObject.CreatePrimitive(PrimitiveType.Plane); overlayPlane.transform.parent = planeGroup.gameObject.transform; } else { planeGroup = GameObjectUtility.GetChild(tbg, "planeGroup"); overlayPlane = GameObjectUtility.GetChild(tbg, "Plane"); } planeGroup.SetActive(true); } else { dtet.enabled = false; GameObject planeGroup = GameObjectUtility.GetChild(tbg, "planeGroup"); if (planeGroup != null) { planeGroup.SetActive(false); } } } } else { debugMessage = "Failed to load Vuforia!"; } }
public RunRecipeDialogViewModel(RunRecipeDialogModel modelIn, MRecipe recipe) { _model = modelIn; _terminableTaskExecutor = new TerminableTaskExecutor(); _processTerminableTaskExecutor = new TerminableTaskExecutor(); _dxfCachedLoader = new CachedLoader <List <IMarkGeometry> >(); RecipeInfo = new ObservableCollection <RecipeProcessEntityInfo>(); _fiducialFinder = new FiducialFinder(); _processTimer.Elapsed += _processTimer_Elapsed; IsPaused = false; IsRunning = false; try { IsLoading = true; SelectedSubProcessInfo = null; RecipeVm = recipe; GenerateRecipeInfo(); Render(); } catch (Exception exp) { _model.Log(exp); _model.Log("Failed to load recipe"); } finally { IsLoading = false; } StartRecipeCommand = new DelegateCommand( () => { StartProcess(); } ); RestartCommand = new DelegateCommand( async() => { if (IsRunning) { Abort(); // wait a second for running tasks to stop await Task.Delay(1000); } StartProcess(); } ); PauseContinueCommand = new DelegateCommand( () => { try { if (!IsPaused) { DispatcherMessageBox.ShowBox( "The process will be paused when it is safe to do so.", "Pause Request" ); PrintLog("Process Paused ..."); } else { PrintLog("Continue Process"); } IsPaused = !IsPaused; } finally { } } ); AbortRecipeCommand = new DelegateCommand( () => { Abort(); } ); }