public void AddParticle(string internalPath) { // adds pcf files and finds its dependencies string externalPath = FindExternalFile(internalPath); if (externalPath == String.Empty) { CompilePalLogger.LogLineColor($"Failed to find particle manifest file {internalPath}", Brushes.Red); return; } if (AddFile(internalPath, externalPath)) { PCF pcf = ParticleUtils.ReadParticle(externalPath); pcfcount++; foreach (string mat in pcf.MaterialNames) { AddTexture(mat); } foreach (string model in pcf.ModelNames) { AddModel(model); } } else { CompilePalLogger.LogLineColor($"Failed to find particle manifest file {internalPath}", Brushes.Red); return; } }
/// <summary> /// Gets the offset position/rotation values and the PCF of the current Perception root. /// </summary> /// <param name="offsetPosition">Stores the value of the current offset from the root's position.</param> /// <param name="offsetRotation">Stores the value of the current offset from the root's rotation.</param> /// <param name="pcf">Stores the reference to the current root PCF.</param> /// <returns> /// MLResult.Result will be <c>MLResult.Code.Ok</c> if operation completed successfully. /// MLResult.Result will be <c>MLResult.Code.MLPerceptionNotStarted</c> if unable to retrieve the Perception System. /// MLResult.Result will be <c>MLResult.Code.UnspecifiedFailure</c> if failed due to other internal error. /// </returns> public static MLResult GetPerceptionRoot(out Vector3 offsetPosition, out Quaternion offsetRotation, out PCF pcf) { offsetPosition = Vector3.zero; offsetRotation = Quaternion.identity; pcf = new PCF(new MagicLeapNativeBindings.MLCoordinateFrameUID()); if (MLPersistentCoordinateFrames.IsValidInstance()) { try { MLResult.Code resultCode = NativeBindings.MLPerceptionGetRootCoordinateFrame(out MagicLeapNativeBindings.MLCoordinateFrameUID cfuid, out MagicLeapNativeBindings.MLTransform mlTransform); if (MLResult.IsOK(resultCode)) { offsetPosition = MLConvert.ToUnity(mlTransform.Position); offsetRotation = MLConvert.ToUnity(mlTransform.Rotation); return(MLResult.Create(MLResult.Code.Ok)); } else { MLPluginLog.ErrorFormat("MLPersistentCoordinateFrames.GetPerceptionRoot failed. Reason: {0}", MLResult.CodeToString(resultCode)); return(MLResult.Create(resultCode)); } } catch (EntryPointNotFoundException) { MLPluginLog.Error("MLPersistentCoordinateFrames.GetPerceptionRoot failed. Reason: API symbols not found."); return(MLResult.Create(MLResult.Code.UnspecifiedFailure, "MLPersistentCoordinateFrames.GetPerceptionRoot failed. Reason: API symbols not found.")); } } else { MLPluginLog.ErrorFormat("MLPersistentCoordinateFrames.GetPerceptionRoot failed. Reason: No Instance for MLPersistentCoordinateFrames."); return(MLResult.Create(MLResult.Code.UnspecifiedFailure, "MLPersistentCoordinateFrames.GetPerceptionRoot failed. Reason: No Instance for MLPersistentCoordinateFrames.")); } }
/// <summary> /// Retrieves the PCF associated with the given CFUID. /// </summary> /// <param name="cfuid">The CFUID to look up the PCF type with.</param> /// <param name="callback">Delegate used to return the resulting MLResult.Result and the closest found PCF.</param> /// <param name="update">Determines if the PCF should have it's pose and state updated.</param> /// <returns> /// MLResult.Result will be <c>MLResult.Code.Ok</c> if a valid PCF was found. /// MLResult.Result will be <c>MLResult.Code.UnspecifiedFailure</c> if failed due to no API instance being found. /// </returns> public static MLResult FindPCFByCFUID(MagicLeapNativeBindings.MLCoordinateFrameUID cfuid, OnFoundSinglePCFDelegate callback, bool update = true) { if (MLPersistentCoordinateFrames.IsValidInstance()) { if (_instance.mapAllPCFs.ContainsKey(cfuid)) { PCF pcf = _instance.mapAllPCFs[cfuid]; if (update) { MLResult updateResult = pcf.Update(); if (!updateResult.IsOk) { MLPluginLog.ErrorFormat("MLPersistentCoordinateFrames.FindPCFByCFUID failed to update the found PCF. Reason: {0}", updateResult); callback(MLResult.Code.PassableWorldNotFound, pcf); return(updateResult); } } callback(MLResult.Code.Ok, pcf); return(MLResult.Create(MLResult.Code.Ok)); } else { QueryFilter queryFilter = QueryFilter.Create(); queryFilter.TypesMask = PCF.Types.SingleUserSingleSession | PCF.Types.SingleUserMultiSession | PCF.Types.MultiUserMultiSession; queryFilter.MaxResults = int.MaxValue; queryFilter.Sorted = false; FindPCFsByFilter(queryFilter, update: update, callback: (MLResult.Code resultCode, List <PCF> pcfList) => { PCF pcfWithCFUID = pcfList.Find(pcf => pcf.CFUID == cfuid); if (pcfWithCFUID != null) { if (update) { MLResult updateResult = pcfWithCFUID.Update(); if (!updateResult.IsOk) { MLPluginLog.ErrorFormat("MLPersistentCoordinateFrames.FindPCFByCFUID failed to update the found PCF. Reason: {0}", updateResult); callback(MLResult.Code.PassableWorldNotFound, pcfWithCFUID); } } callback(MLResult.Code.Ok, pcfWithCFUID); } else { callback(resultCode, null); } }); return(MLResult.Create(MLResult.Code.Ok)); } } else { MLPluginLog.ErrorFormat("MLPersistentCoordinateFrames.FindPCFByCFUID failed. Reason: No Instance for MLPersistentCoordinateFrames."); return(MLResult.Create(MLResult.Code.UnspecifiedFailure, "MLPersistentCoordinateFrames.FindPCFByCFUID failed. Reason: No Instance for MLPersistentCoordinateFrames.")); } }
private void menuParticles_ItemClick(object sender, ItemClickEventArgs e) { // Manifest generator if (e.Item == menuParticlesManifestGenerator) { PCF.CreateManifest(launcher); XtraMessageBox.Show("Particle manifest generated."); } }
///<summary> /// Returns a single repetition of Pre-Certification Req/Window(IN3-20). /// throws HL7Exception if the repetition number is invalid. /// <param name="rep">The repetition number (this is a repeating field)</param> ///</summary> public PCF GetPreCertificationReqWindow(int rep) { PCF ret = null; try { IType t = this.GetField(20, rep); ret = (PCF)t; } catch (System.Exception ex) { HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected problem obtaining field value. This is a bug.", ex); throw new System.Exception("An unexpected error ocurred", ex); } return(ret); }
/// <summary> Returns a single repetition of Pre-Certification Req/Window (IN3-20).</summary> /// <param name="rep">the repetition number (this is a repeating field) /// </param> /// <throws> HL7Exception if the repetition number is invalid. </throws> public virtual PCF getPreCertificationReqWindow(int rep) { PCF ret = null; try { Type t = this.getField(20, rep); ret = (PCF)t; } catch (System.InvalidCastException) { throw new Exception(); } return(ret); }
///<summary> /// Returns all repetitions of Pre-Certification Req/Window (IN3-20). ///</summary> public PCF[] GetPreCertificationReqWindow() { PCF[] ret = null; try { IType[] t = this.GetField(20); ret = new PCF[t.Length]; for (int i = 0; i < ret.Length; i++) { ret[i] = (PCF)t[i]; } } catch (HL7Exception he) { HapiLogFactory.GetHapiLog(this.GetType()).Error("Unexpected problem obtaining field value. This is a bug.", he); throw new System.Exception("An unexpected error ocurred", he); } catch (System.Exception cce) { HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected problem obtaining field value. This is a bug.", cce); throw new System.Exception("An unexpected error ocurred", cce); } return(ret); }
/// <summary> /// Adds the given PCF to the map of PCFs that are updated every frame as well as the map of all PCFs. /// </summary> /// <param name="pcf">PCF to be updated.</param> public static void QueueForUpdates(PCF pcf) { if (MLPersistentCoordinateFrames.IsValidInstance()) { if (!_instance.mapAllPCFs.ContainsKey(pcf.CFUID)) { _instance.mapAllPCFs.Add(pcf.CFUID, pcf); } if (!_instance.mapTrackedPCFs.ContainsKey(pcf.CFUID)) { _instance.mapTrackedPCFs.Add(pcf.CFUID, pcf); } } else { MLPluginLog.ErrorFormat("MLPersistentCoordinateFrames.QueueForUpdates failed. Reason: No Instance for MLPersistentCoordinateFrames."); } }
public void AddParticle(string internalPath) { // adds pcf files and finds its dependencies string externalPath = FindExternalFile(internalPath); PCF pcf = ParticleUtils.ReadParticle(externalPath); if (AddFile(internalPath, externalPath)) { pcfcount++; foreach (string mat in pcf.MaterialNames) { AddTexture(mat); } foreach (string model in pcf.ModelNames) { AddModel(model); } } }
/// <summary> Returns all repetitions of Pre-Certification Req/Window (IN3-20).</summary> public virtual PCF[] getPreCertificationReqWindow() { PCF[] ret = null; try { Type[] t = this.getField(20); ret = new PCF[t.Length]; for (int i = 0; i < ret.Length; i++) { ret[i] = (PCF)t[i]; } } catch (System.InvalidCastException) { throw new Exception(); } catch (NuGenHL7Exception) { throw new Exception(); } return(ret); }
/// <summary> /// Retrieves the closest known PCF of the types provided by the typesMask to the given position. /// </summary> /// <param name="position">The position of the object we want to anchor.</param> /// <param name="pcf">Stores the resulting PCF.</param> /// <param name="typesMask">The bitmask of which PCF types to consider.</param> /// <param name="update">Determines if the PCF should have it's pose and state updated.</param> /// <returns> /// MLResult.Result will be <c>MLResult.Code.Ok</c> if a valid PCF was found. /// MLResult.Result will be <c>MLResult.Code.InvalidParam</c> if failed due to an invalid input parameter. /// MLResult.Result will be <c>MLResult.Code.PrivilegeDenied</c> if necessary privilege is missing. /// MLResult.Result will be <c>MLResult.Code.UnspecifiedFailure</c> if failed due to other internal error. /// MLResult.Result will be <c>MLResult.Code.PassableWorldLowMapQuality</c> if map quality is too low for content persistence. Continue building the map. /// MLResult.Result will be <c>MLResult.Code.PassableWorldUnableToLocalize</c> if currently unable to localize into any map. Continue building the map. /// </returns> public static MLResult FindClosestPCF(Vector3 position, out PCF pcf, PCF.Types typesMask = PCF.Types.SingleUserSingleSession | PCF.Types.SingleUserMultiSession | PCF.Types.MultiUserMultiSession, bool update = true) { pcf = null; if (MLPersistentCoordinateFrames.IsValidInstance()) { QueryFilter queryFilter = QueryFilter.Create(); queryFilter.TargetPoint = position; queryFilter.TypesMask = typesMask; queryFilter.Sorted = true; MLResult result = FindPCFsByFilter(queryFilter, out List <PCF> pcfList, update); if (!result.IsOk || pcfList.Count == 0) { if (result.Result == MLResult.Code.PassableWorldLowMapQuality || result.Result == MLResult.Code.PassableWorldUnableToLocalize) { MLPluginLog.WarningFormat("Map quality not sufficient enough for MLPersistentCoordinateFrames.FindClosestPCF. Reason: {0}", result); } else { MLPluginLog.ErrorFormat("MLPersistentCoordinateFrames.FindClosestPCF failed. Reason: {0}", result); } } else { pcf = pcfList[0]; } return(result); } else { MLPluginLog.ErrorFormat("MLPersistentCoordinateFrames.FindClosestPCF failed. Reason: No Instance for MLPersistentCoordinateFrames."); return(MLResult.Create(MLResult.Code.UnspecifiedFailure, "MLPersistentCoordinateFrames.FindClosestPCF failed. Reason: No Instance for MLPersistentCoordinateFrames.")); } }
/// <summary> /// Sets the offset position/rotation values from the current Perception root and can also set the PCF to be used as the new Perception root to which all MLSnapshotGetTransform will be relative to. /// </summary> /// <param name="offsetPosition">The offset to set from the root's position.</param> /// <param name="offsetRotation">The offset to set from the root's rotation.</param> /// <param name="pcf">The PCF to set the root to.</param> /// <returns> /// MLResult.Result will be <c>MLResult.Code.Ok</c> if operation completed successfully. /// MLResult.Result will be <c>MLResult.Code.MLPerceptionNotStarted</c> if unable to retrieve the Perception System. /// MLResult.Result will be <c>MLResult.Code.MLPerceptionInvalidPCFRoot</c> if the provided CFUID is not associated with a valid PCF. /// MLResult.Result will be <c>MLResult.Code.UnspecifiedFailure</c> if the CFUID is not valid. /// </returns> public static MLResult.Code SetPerceptionRoot(Vector3 offsetPosition, Quaternion offsetRotation, PCF pcf) { IntPtr cfuidPointer = IntPtr.Zero; IntPtr mlTransformPointer = IntPtr.Zero; try { if (pcf != null) { cfuidPointer = Marshal.AllocHGlobal(Marshal.SizeOf(pcf.CFUID)); Marshal.StructureToPtr(pcf.CFUID, cfuidPointer, false); } MagicLeapNativeBindings.MLTransform rootOffset = new MagicLeapNativeBindings.MLTransform(); rootOffset.Position = MLConvert.FromUnity(offsetPosition); rootOffset.Rotation = MLConvert.FromUnity(offsetRotation); mlTransformPointer = Marshal.AllocHGlobal(Marshal.SizeOf(rootOffset)); Marshal.StructureToPtr(rootOffset, mlTransformPointer, false); MLResult.Code resultCode = NativeBindings.MLPerceptionSetRootCoordinateFrame(cfuidPointer, mlTransformPointer); Marshal.FreeHGlobal(cfuidPointer); Marshal.FreeHGlobal(mlTransformPointer); return(resultCode); } catch (EntryPointNotFoundException) { MLPluginLog.Error("MLPersistentCoordinateFrames.NativeBindings.SetPerceptionRoot failed. Reason: API symbols not found."); Marshal.FreeHGlobal(cfuidPointer); Marshal.FreeHGlobal(mlTransformPointer); return(MLResult.Code.UnspecifiedFailure); } }
/// <summary> /// Returns filtered list of PCFs based on the parameters of the given queryFilter. /// </summary> /// <param name="queryFilter">Parameters used to curate the returned values.</param> /// <param name="pcfList">Stores the resulting list of PCFs.</param> /// <param name="update">Determines if the PCFs should have their pose updated.</param> /// <returns> /// MLResult.Result will be <c>MLResult.Code.Ok</c> if all the PCFs from the current map have been found successfully. /// MLResult.Result will be <c>MLResult.Code.PrivilegeDenied</c> if necessary privilege is missing. /// MLResult.Result will be <c>MLResult.Code.UnspecifiedFailure</c> if failed due to other internal error. /// MLResult.Result will be <c>MLResult.Code.PassableWorldLowMapQuality</c> if map quality is too low for content persistence. Continue building the map. /// MLResult.Result will be <c>MLResult.Code.PassableWorldUnableToLocalize</c> if currently unable to localize into any map. Continue building the map. /// </returns> public static MLResult FindPCFsByFilter(QueryFilter queryFilter, out List <PCF> pcfList, bool update = true) { pcfList = new List <PCF>(); if (MLPersistentCoordinateFrames.IsValidInstance()) { try { uint numPCFs = 0; MLResult.Code resultCode = NativeBindings.MLPersistentCoordinateFrameGetCount(_instance.nativeTracker, ref numPCFs); if (MLResult.IsOK(resultCode) && numPCFs > 0) { MagicLeapNativeBindings.MLCoordinateFrameUID[] cfuidArray = new MagicLeapNativeBindings.MLCoordinateFrameUID[numPCFs]; NativeBindings.QueryFilterNative queryFilterNative = NativeBindings.QueryFilterNative.Create(); queryFilterNative.Data = queryFilter; uint cfuidCount = 0; //// With these conditions the user is asking for all PCFs, no need to use the slower filtered query call. if (queryFilter.TypesMask == (PCF.Types.SingleUserSingleSession | PCF.Types.SingleUserMultiSession | PCF.Types.MultiUserMultiSession) && queryFilter.Radius <= 0 && !queryFilter.Sorted) { resultCode = NativeBindings.MLPersistentCoordinateFrameGetAllEx(_instance.nativeTracker, numPCFs, cfuidArray); cfuidCount = (uint)cfuidArray.Length; } else { resultCode = NativeBindings.MLPersistentCoordinateFrameQuery(_instance.nativeTracker, in queryFilterNative, cfuidArray, out cfuidCount); } if (MLResult.IsOK(resultCode)) { for (int i = 0; i < cfuidCount; ++i) { MagicLeapNativeBindings.MLCoordinateFrameUID pcfCFUID = cfuidArray[i]; if (!pcfCFUID.Equals(MagicLeapNativeBindings.MLCoordinateFrameUID.EmptyFrame)) { PCF pcf = null; if (_instance.mapAllPCFs.ContainsKey(pcfCFUID)) { pcf = _instance.mapAllPCFs[pcfCFUID]; } else { pcf = new PCF(pcfCFUID); _instance.mapAllPCFs.Add(pcfCFUID, pcf); } pcfList.Add(pcf); if (update) { MLResult result = pcf.Update(); if (!result.IsOk) { MLPluginLog.ErrorFormat("MLPersistentCoordinateFrames.FindPCFsByFilter failed to update the found PCF with CFUID {0}, Reason: {1}", pcf.CFUID, result); } } } } return(MLResult.Create(MLResult.Code.Ok)); } else { if (resultCode == MLResult.Code.PassableWorldLowMapQuality || resultCode == MLResult.Code.PassableWorldUnableToLocalize) { MLPluginLog.WarningFormat("Map quality not sufficient enough for MLPersistentCoordinateFrames.FindPCFsByFilter. Reason: {0}", MLResult.CodeToString(resultCode)); } else { MLPluginLog.ErrorFormat("MLPersistentCoordinateFrames.FindPCFsByFilter failed. Reason: {0}", MLResult.CodeToString(resultCode)); } return(MLResult.Create(resultCode, string.Format("MLPersistentCoordinateFrames.FindPCFsByFilter failed. Reason: {0}", MLResult.CodeToString(resultCode)))); } } else { if (resultCode == MLResult.Code.PassableWorldLowMapQuality || resultCode == MLResult.Code.PassableWorldUnableToLocalize) { MLPluginLog.WarningFormat("Map quality not sufficient enough for MLPersistentCoordinateFrames.FindPCFsByFilter. Reason: {0}", MLResult.CodeToString(resultCode)); } else { MLPluginLog.ErrorFormat("MLPersistentCoordinateFrames.FindPCFsByFilter failed. Reason: {0}", MLResult.IsOK(resultCode) ? "No PCFs could be found." : MLResult.CodeToString(resultCode)); } return(MLResult.Create(resultCode, string.Format("MLPersistentCoordinateFrames.FindPCFsByFilter failed. Reason: {0}", MLResult.IsOK(resultCode) ? "No PCFs could be found." : MLResult.CodeToString(resultCode)))); } } catch (EntryPointNotFoundException) { MLPluginLog.Error("MLPersistentCoordinateFrames.FindPCFsByFilter failed. Reason: API symbols not found."); return(MLResult.Create(MLResult.Code.UnspecifiedFailure, "MLPersistentCoordinateFrames.FindPCFsByFilter failed. Reason: API symbols not found.")); } } else { MLPluginLog.ErrorFormat("MLPersistentCoordinateFrames.FindPCFsByFilter failed. Reason: No Instance for MLPersistentCoordinateFrames."); return(MLResult.Create(MLResult.Code.UnspecifiedFailure, "MLPersistentCoordinateFrames.FindPCFsByFilter failed. Reason: No Instance for MLPersistentCoordinateFrames.")); } }
/// <summary> /// Retrieves the PCF associated with the given CFUID. /// </summary> /// <param name="cfuid">The CFUID to look up the PCF type with.</param> /// <param name="pcf">Stores the resulting PCF.</param> /// <param name="update">Determines if the PCF should have it's pose and state updated.</param> /// <returns> /// MLResult.Result will be <c>MLResult.Code.Ok</c> if a valid PCF was found. /// MLResult.Result will be <c>MLResult.Code.InvalidParam</c> if failed due to an invalid input parameter. /// MLResult.Result will be <c>MLResult.Code.PrivilegeDenied</c> if necessary privilege is missing. /// MLResult.Result will be <c>MLResult.Code.UnspecifiedFailure</c> if failed due to other internal error. /// MLResult.Result will be <c>MLResult.Code.PassableWorldLowMapQuality</c> if map quality is too low for content persistence. Continue building the map. /// MLResult.Result will be <c>MLResult.Code.PassableWorldUnableToLocalize</c> if currently unable to localize into any map. Continue building the map. /// </returns> public static MLResult FindPCFByCFUID(MagicLeapNativeBindings.MLCoordinateFrameUID cfuid, out PCF pcf, bool update = true) { pcf = null; if (MLPersistentCoordinateFrames.IsValidInstance()) { if (_instance.mapAllPCFs.ContainsKey(cfuid)) { pcf = _instance.mapAllPCFs[cfuid]; if (update) { MLResult updateResult = pcf.Update(); if (!updateResult.IsOk) { MLPluginLog.ErrorFormat("MLPersistentCoordinateFrames.FindPCFByCFUID failed to update the found PCF. Reason: {0}", updateResult); } return(updateResult); } return(MLResult.Create(MLResult.Code.Ok)); } else { MLResult result = FindAllPCFs(out List <PCF> list, update: false); if (result.IsOk) { pcf = list.Find(PCF => PCF.CFUID == cfuid); if (update && pcf != null) { MLResult updateResult = pcf.Update(); if (!updateResult.IsOk) { MLPluginLog.ErrorFormat("MLPersistentCoordinateFrames.FindPCFByCFUID failed to update the found PCF. Reason: {0}", updateResult); } return(updateResult); } } else { if (result.Result == MLResult.Code.PassableWorldLowMapQuality || result.Result == MLResult.Code.PassableWorldUnableToLocalize) { MLPluginLog.WarningFormat("Map quality not sufficient enough for MLPersistentCoordinateFrames.FindPCFByCFUID. Reason: {0}", result); } else { MLPluginLog.ErrorFormat("MLPersistentCoordinateFrames.FindPCFByCFUID failed. Reason: {0}", result); } } return(result); } } else { MLPluginLog.ErrorFormat("MLPersistentCoordinateFrames.FindPCFByCFUID failed. Reason: No Instance for MLPersistentCoordinateFrames."); return(MLResult.Create(MLResult.Code.UnspecifiedFailure, "MLPersistentCoordinateFrames.FindPCFByCFUID failed. Reason: No Instance for MLPersistentCoordinateFrames.")); } }
private void UpdateSerialPortUI() { SerialPort P = GetSerialPort(comboBox1.Text); if (P == null) { label1.Enabled = false; comboBox2.Enabled = false; label2.Enabled = false; comboBox3.Enabled = false; label3.Enabled = false; comboBox4.Enabled = false; label4.Enabled = false; comboBox5.Enabled = false; checkBox1.Enabled = false; return; } Boolean wasOpen = P.IsOpen; PCF dwProvCapabilities = 0; SP dwSettableParams = 0; BAUD dwSettableBaud = 0; DATABITS wSettableData = 0; SSP wSettableStopParity = 0; try { if (!wasOpen) { P.Open(); } Object o = P.BaseStream.GetType().GetField("commProp", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(P.BaseStream); dwProvCapabilities = (PCF)(o.GetType().GetField("dwProvCapabilities", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).GetValue(o)); dwSettableParams = (SP)(o.GetType().GetField("dwSettableParams", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).GetValue(o)); dwSettableBaud = (BAUD)(o.GetType().GetField("dwSettableBaud", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).GetValue(o)); wSettableData = (DATABITS)(o.GetType().GetField("wSettableData", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).GetValue(o)); wSettableStopParity = (SSP)(o.GetType().GetField("wSettableStopParity", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).GetValue(o)); } catch (Exception ex) { String buf = "Exception\r\n"; while (ex != null) { buf = String.Concat(buf, "\r\n", ex.Message, " [", ex.Source, "]\r\n", ex.StackTrace); ex = ex.InnerException; } MessageBox.Show(buf, "UpdateSerialPortUI()"); } if ((!wasOpen) && (P.IsOpen)) { P.Close(); } if (((dwSettableParams & SP.BAUD) == 0) || (dwSettableBaud == 0)) { label1.Enabled = false; comboBox2.Enabled = false; } else { label1.Enabled = true; comboBox2.Enabled = true; String s = comboBox2.Text; if ((s == null) || (s.Length == 0)) { s = "9600"; } comboBox2.Items.Clear(); if ((dwSettableBaud & BAUD._075) != 0) { comboBox2.Items.Add("75"); } if ((dwSettableBaud & BAUD._110) != 0) { comboBox2.Items.Add("110"); } if ((dwSettableBaud & BAUD._134_5) != 0) { comboBox2.Items.Add("134.5"); } if ((dwSettableBaud & BAUD._150) != 0) { comboBox2.Items.Add("150"); } if ((dwSettableBaud & BAUD._300) != 0) { comboBox2.Items.Add("300"); } if ((dwSettableBaud & BAUD._600) != 0) { comboBox2.Items.Add("600"); } if ((dwSettableBaud & BAUD._1200) != 0) { comboBox2.Items.Add("1200"); } if ((dwSettableBaud & BAUD._1800) != 0) { comboBox2.Items.Add("1800"); } if ((dwSettableBaud & BAUD._2400) != 0) { comboBox2.Items.Add("2400"); } if ((dwSettableBaud & BAUD._4800) != 0) { comboBox2.Items.Add("4800"); } if ((dwSettableBaud & BAUD._7200) != 0) { comboBox2.Items.Add("7200"); } if ((dwSettableBaud & BAUD._9600) != 0) { comboBox2.Items.Add("9600"); } if ((dwSettableBaud & BAUD._14400) != 0) { comboBox2.Items.Add("14400"); } if ((dwSettableBaud & BAUD._19200) != 0) { comboBox2.Items.Add("19200"); } if ((dwSettableBaud & BAUD._38400) != 0) { comboBox2.Items.Add("38400"); } if ((dwSettableBaud & BAUD._56K) != 0) { comboBox2.Items.Add("56000"); } if ((dwSettableBaud & BAUD._57600) != 0) { comboBox2.Items.Add("57600"); } if ((dwSettableBaud & BAUD._115200) != 0) { comboBox2.Items.Add("115200"); } if ((dwSettableBaud & BAUD._128K) != 0) { comboBox2.Items.Add("128000"); } comboBox2.DropDownStyle = ((dwSettableBaud & BAUD.USER) != 0) ? ComboBoxStyle.DropDown : ComboBoxStyle.DropDownList; if ((s != null) && (s.Length != 0)) { Boolean f = false; for (Int32 i = 0; i < comboBox2.Items.Count; i++) { if (String.Compare(s, comboBox2.Items[i] as String, StringComparison.OrdinalIgnoreCase) == 0) { comboBox2.SelectedIndex = i; f = true; break; } } if (!f) { if ((dwSettableBaud & BAUD.USER) != 0) { comboBox2.Text = s; } else { comboBox2.SelectedIndex = 0; } } } else { comboBox2.SelectedIndex = 0; } } if (((dwSettableParams & SP.DATABITS) == 0) || (wSettableData == 0)) { label2.Enabled = false; comboBox3.Enabled = false; } else { label2.Enabled = true; comboBox3.Enabled = true; String s = comboBox3.Text; if ((s == null) || (s.Length == 0)) { s = "8"; } comboBox3.Items.Clear(); if ((wSettableData & DATABITS._5) != 0) { comboBox3.Items.Add("5"); } if ((wSettableData & DATABITS._6) != 0) { comboBox3.Items.Add("6"); } if ((wSettableData & DATABITS._7) != 0) { comboBox3.Items.Add("7"); } if ((wSettableData & DATABITS._8) != 0) { comboBox3.Items.Add("8"); } if ((wSettableData & DATABITS._16) != 0) { comboBox3.Items.Add("16"); } if ((s != null) && (s.Length != 0)) { Boolean f = false; for (Int32 i = 0; i < comboBox3.Items.Count; i++) { if (String.Compare(s, comboBox3.Items[i] as String, StringComparison.OrdinalIgnoreCase) == 0) { comboBox3.SelectedIndex = i; f = true; break; } } if (!f) { comboBox3.SelectedIndex = 0; } } else { comboBox3.SelectedIndex = 0; } } if (((dwSettableParams & SP.PARITY) == 0) || ((wSettableStopParity & SSP.PARITY_MASK) == 0)) { label3.Enabled = false; comboBox4.Enabled = false; } else { label3.Enabled = true; comboBox4.Enabled = true; String s = comboBox4.Text; if ((s == null) || (s.Length == 0)) { s = "None"; } comboBox4.Items.Clear(); if ((wSettableStopParity & SSP.PARITY_NONE) != 0) { comboBox4.Items.Add("None"); } if ((wSettableStopParity & SSP.PARITY_EVEN) != 0) { comboBox4.Items.Add("Even"); } if ((wSettableStopParity & SSP.PARITY_ODD) != 0) { comboBox4.Items.Add("Odd"); } if ((wSettableStopParity & SSP.PARITY_MARK) != 0) { comboBox4.Items.Add("Mark"); } if ((wSettableStopParity & SSP.PARITY_SPACE) != 0) { comboBox4.Items.Add("Space"); } if ((s != null) && (s.Length != 0)) { Boolean f = false; for (Int32 i = 0; i < comboBox4.Items.Count; i++) { if (String.Compare(s, comboBox4.Items[i] as String, StringComparison.OrdinalIgnoreCase) == 0) { comboBox4.SelectedIndex = i; f = true; break; } } if (!f) { comboBox4.SelectedIndex = 0; } } else { comboBox4.SelectedIndex = 0; } } if (((dwSettableParams & SP.STOPBITS) == 0) || ((wSettableStopParity & SSP.STOPBITS_MASK) == 0)) { label4.Enabled = false; comboBox5.Enabled = false; } else { label4.Enabled = true; comboBox5.Enabled = true; String s = comboBox5.Text; if ((s == null) || (s.Length == 0)) { s = "1"; } comboBox5.Items.Clear(); if ((wSettableStopParity & SSP.STOPBITS_10) != 0) { comboBox5.Items.Add("1"); } if ((wSettableStopParity & SSP.STOPBITS_15) != 0) { comboBox5.Items.Add("1.5"); } if ((wSettableStopParity & SSP.STOPBITS_20) != 0) { comboBox5.Items.Add("2"); } if ((s != null) && (s.Length != 0)) { Boolean f = false; for (Int32 i = 0; i < comboBox5.Items.Count; i++) { if (String.Compare(s, comboBox5.Items[i] as String, StringComparison.OrdinalIgnoreCase) == 0) { comboBox5.SelectedIndex = i; f = true; break; } } if (!f) { comboBox5.SelectedIndex = 0; } } else { comboBox5.SelectedIndex = 0; } } if (((dwSettableParams & SP.HANDSHAKING) == 0) || ((dwProvCapabilities & PCF.RTSCTS) == 0)) { checkBox1.Enabled = false; } else { checkBox1.Enabled = true; } }
/// <summary> /// Sets the offset position/rotation values from the current Perception root and can also set the PCF to be used as the new Perception root to which all MLSnapshotGetTransform will be relative to. /// </summary> /// <param name="offsetPosition">The offset to set from the root's position.</param> /// <param name="offsetRotation">The offset to set from the root's rotation.</param> /// <param name="pcf">The PCF to set the root to.</param> /// <returns> /// MLResult.Result will be <c>MLResult.Code.Ok</c> if operation completed successfully. /// MLResult.Result will be <c>MLResult.Code.MLPerceptionNotStarted</c> if unable to retrieve the Perception System. /// MLResult.Result will be <c>MLResult.Code.MLPerceptionInvalidPCFRoot</c> if the provided CFUID is not associated with a valid PCF. /// MLResult.Result will be <c>MLResult.Code.UnspecifiedFailure</c> if the CFUID is not valid. /// </returns> public static MLResult SetPerceptionRoot(Vector3 offsetPosition, Quaternion offsetRotation, PCF pcf = null) { if (MLPersistentCoordinateFrames.IsValidInstance()) { MLResult.Code resultCode = NativeBindings.SetPerceptionRoot(offsetPosition, offsetRotation, pcf); if (!MLResult.IsOK(resultCode)) { MLPluginLog.ErrorFormat("MLPersistentCoordinateFrames.SetPerceptionRoot failed. Reason: {0}", MLResult.CodeToString(resultCode)); return(MLResult.Create(MLResult.Code.UnspecifiedFailure, string.Format("MLPersistentCoordinateFrames.SetPerceptionRoot failed. Reason: {0}", MLResult.CodeToString(resultCode)))); } return(MLResult.Create(resultCode)); } else { MLPluginLog.ErrorFormat("MLPersistentCoordinateFrames.SetPerceptionRoot failed. Reason: No Instance for MLPersistentCoordinateFrames."); return(MLResult.Create(MLResult.Code.UnspecifiedFailure, "MLPersistentCoordinateFrames.SetPerceptionRoot failed. Reason: No Instance for MLPersistentCoordinateFrames.")); } }