public static iFAB.assemblyDetail TransformJoinData(CyPhy.JoinData jd) { var rtn = new iFAB.assemblyDetail() { id = IDPrefix + jd.Guid.ToString(), name = jd.Name, description = jd.Attributes.Description, Items = new List<object>() }; if (jd is CyPhy.WeldedJoin || jd.Kind == "WeldedJoin") { CyPhy.WeldedJoin wj = jd as CyPhy.WeldedJoin; if (wj == null) wj = CyPhyClasses.WeldedJoin.Cast(jd.Impl); iFAB.welded w = new iFAB.welded() { inspectionRequirement = d_InspectionRequirement[wj.Attributes.InspectionRequirement], jointType = (iFAB.jointType)Enum.Parse(typeof(iFAB.jointType), wj.Attributes.JointType.ToString()), length = new iFAB.length() { Value = decimal.Parse(wj.Attributes.Length.ToString()), unit = (iFAB.lengthUnit)Enum.Parse(typeof(iFAB.lengthUnit), wj.Attributes.LengthUnit.ToString()) }, weldPenetration = (iFAB.weldPenetration)Enum.Parse(typeof(iFAB.weldPenetration), wj.Attributes.WeldPenetration.ToString()), weldType = (iFAB.weldType)Enum.Parse(typeof(iFAB.weldType), wj.Attributes.WeldType.ToString()), twoSided = wj.Attributes.TwoSided }; rtn.Items.Add(w); } else if (jd is CyPhy.BrazedJoin || jd.Kind == "BrazedJoin") { CyPhy.BrazedJoin bj = jd as CyPhy.BrazedJoin; if (bj == null) bj = CyPhyClasses.BrazedJoin.Cast(jd.Impl); iFAB.brazed b = new iFAB.brazed() { fillerMaterial = bj.Attributes.FillerMaterial, fluxMaterial = bj.Attributes.FluxMaterial, length = new iFAB.length() { Value = decimal.Parse(bj.Attributes.Length.ToString()), unit = (iFAB.lengthUnit)Enum.Parse(typeof(iFAB.lengthUnit), bj.Attributes.LengthUnit.ToString()), } }; rtn.Items.Add(b); } else if (jd is CyPhy.SolderedJoin || jd.Kind == "SolderedJoin") { CyPhy.SolderedJoin sj = jd as CyPhy.SolderedJoin; if (sj == null) sj = CyPhyClasses.SolderedJoin.Cast(jd.Impl); iFAB.soldered s = new iFAB.soldered() { fillerMaterial = sj.Attributes.FillerMaterial, fluxMaterial = sj.Attributes.FluxMaterial, length = new iFAB.length() { Value = decimal.Parse(sj.Attributes.Length.ToString()), unit = (iFAB.lengthUnit)Enum.Parse(typeof(iFAB.lengthUnit), sj.Attributes.LengthUnit.ToString()) } }; rtn.Items.Add(s); } else if (jd is CyPhy.GluedJoin || jd.Kind == "GluedJoin") { CyPhy.GluedJoin gj = jd as CyPhy.GluedJoin; if (gj == null) gj = CyPhyClasses.GluedJoin.Cast(jd.Impl); iFAB.glued g = new iFAB.glued() { length = new iFAB.length() { Value = decimal.Parse(gj.Attributes.Length.ToString()), unit = (iFAB.lengthUnit)Enum.Parse(typeof(iFAB.lengthUnit), gj.Attributes.LengthUnit.ToString()) }, material = gj.Attributes.Material, volume = new iFAB.volume() { Value = decimal.Parse(gj.Attributes.Volume.ToString()), unit = (iFAB.volumeUnit)Enum.Parse(typeof(iFAB.volumeUnit), gj.Attributes.VolumeUnit.ToString()) } }; rtn.Items.Add(g); } else if (jd is CyPhy.MechanicalJoin || jd.Kind == "MechanicalJoin") { CyPhy.MechanicalJoin mj = jd as CyPhy.MechanicalJoin; if (mj == null) mj = CyPhyClasses.MechanicalJoin.Cast(jd.Impl); iFAB.mechanical m = new iFAB.mechanical() { fasteningMethod = d_FasteningMethod[mj.Attributes.FasteningMethod], fasteningQuantity = mj.Attributes.FasteningQuantity.ToString(), force = new iFAB.force() { Value = decimal.Parse(mj.Attributes.Force.ToString()), unit = d_ForceUnits[mj.Attributes.ForceUnit] }, torque = new iFAB.torque() { Value = decimal.Parse(mj.Attributes.Torque.ToString()), unit = d_TorqueUnits[mj.Attributes.TorqueUnit] }, linkingPart = new List<partReference>() }; foreach (CyPhy.Fastener f in mj.Children.FastenerCollection) { iFAB.partReference pr = new partReference(); // If this refers to a Component model, get that guy's AVMID. // If not, use the AVMID provided in the attribute of this object. if (f.Referred.Component != null) pr.id = f.Referred.Component.Attributes.AVMID; else pr.id = f.Attributes.AVMID; for (int i = 0; i < f.Attributes.Quantity; i++) m.linkingPart.Add(pr); } rtn.Items.Add(m); } else throw new NotSupportedException("JoinData export not supported for object of type " + jd.Impl.MetaBase.Name); return rtn; }
public static bool Deserialize(string xml, out glued obj) { System.Exception exception = null; return Deserialize(xml, out obj, out exception); }
/// <summary> /// Deserializes workflow markup into an glued object /// </summary> /// <param name="xml">string workflow markup to deserialize</param> /// <param name="obj">Output glued object</param> /// <param name="exception">output Exception value if deserialize failed</param> /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns> public static bool Deserialize(string xml, out glued obj, out System.Exception exception) { exception = null; obj = default(glued); try { obj = Deserialize(xml); return true; } catch (System.Exception ex) { exception = ex; return false; } }
public static bool LoadFromFile(string fileName, out glued obj) { System.Exception exception = null; return LoadFromFile(fileName, out obj, out exception); }
/// <summary> /// Deserializes xml markup from file into an glued object /// </summary> /// <param name="fileName">string xml file to load and deserialize</param> /// <param name="obj">Output glued object</param> /// <param name="exception">output Exception value if deserialize failed</param> /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns> public static bool LoadFromFile(string fileName, out glued obj, out System.Exception exception) { exception = null; obj = default(glued); try { obj = LoadFromFile(fileName); return true; } catch (System.Exception ex) { exception = ex; return false; } }
public static iFAB.assemblyDetail TransformJoinData(CyPhy.JoinData jd) { var rtn = new iFAB.assemblyDetail() { id = IDPrefix + jd.Guid.ToString(), name = jd.Name, description = jd.Attributes.Description, Items = new List <object>() }; if (jd is CyPhy.WeldedJoin || jd.Kind == "WeldedJoin") { CyPhy.WeldedJoin wj = jd as CyPhy.WeldedJoin; if (wj == null) { wj = CyPhyClasses.WeldedJoin.Cast(jd.Impl); } iFAB.welded w = new iFAB.welded() { inspectionRequirement = d_InspectionRequirement[wj.Attributes.InspectionRequirement], jointType = (iFAB.jointType)Enum.Parse(typeof(iFAB.jointType), wj.Attributes.JointType.ToString()), length = new iFAB.length() { Value = decimal.Parse(wj.Attributes.Length.ToString()), unit = (iFAB.lengthUnit)Enum.Parse(typeof(iFAB.lengthUnit), wj.Attributes.LengthUnit.ToString()) }, weldPenetration = (iFAB.weldPenetration)Enum.Parse(typeof(iFAB.weldPenetration), wj.Attributes.WeldPenetration.ToString()), weldType = (iFAB.weldType)Enum.Parse(typeof(iFAB.weldType), wj.Attributes.WeldType.ToString()), twoSided = wj.Attributes.TwoSided }; rtn.Items.Add(w); } else if (jd is CyPhy.BrazedJoin || jd.Kind == "BrazedJoin") { CyPhy.BrazedJoin bj = jd as CyPhy.BrazedJoin; if (bj == null) { bj = CyPhyClasses.BrazedJoin.Cast(jd.Impl); } iFAB.brazed b = new iFAB.brazed() { fillerMaterial = bj.Attributes.FillerMaterial, fluxMaterial = bj.Attributes.FluxMaterial, length = new iFAB.length() { Value = decimal.Parse(bj.Attributes.Length.ToString()), unit = (iFAB.lengthUnit)Enum.Parse(typeof(iFAB.lengthUnit), bj.Attributes.LengthUnit.ToString()), } }; rtn.Items.Add(b); } else if (jd is CyPhy.SolderedJoin || jd.Kind == "SolderedJoin") { CyPhy.SolderedJoin sj = jd as CyPhy.SolderedJoin; if (sj == null) { sj = CyPhyClasses.SolderedJoin.Cast(jd.Impl); } iFAB.soldered s = new iFAB.soldered() { fillerMaterial = sj.Attributes.FillerMaterial, fluxMaterial = sj.Attributes.FluxMaterial, length = new iFAB.length() { Value = decimal.Parse(sj.Attributes.Length.ToString()), unit = (iFAB.lengthUnit)Enum.Parse(typeof(iFAB.lengthUnit), sj.Attributes.LengthUnit.ToString()) } }; rtn.Items.Add(s); } else if (jd is CyPhy.GluedJoin || jd.Kind == "GluedJoin") { CyPhy.GluedJoin gj = jd as CyPhy.GluedJoin; if (gj == null) { gj = CyPhyClasses.GluedJoin.Cast(jd.Impl); } iFAB.glued g = new iFAB.glued() { length = new iFAB.length() { Value = decimal.Parse(gj.Attributes.Length.ToString()), unit = (iFAB.lengthUnit)Enum.Parse(typeof(iFAB.lengthUnit), gj.Attributes.LengthUnit.ToString()) }, material = gj.Attributes.Material, volume = new iFAB.volume() { Value = decimal.Parse(gj.Attributes.Volume.ToString()), unit = (iFAB.volumeUnit)Enum.Parse(typeof(iFAB.volumeUnit), gj.Attributes.VolumeUnit.ToString()) } }; rtn.Items.Add(g); } else if (jd is CyPhy.MechanicalJoin || jd.Kind == "MechanicalJoin") { CyPhy.MechanicalJoin mj = jd as CyPhy.MechanicalJoin; if (mj == null) { mj = CyPhyClasses.MechanicalJoin.Cast(jd.Impl); } iFAB.mechanical m = new iFAB.mechanical() { fasteningMethod = d_FasteningMethod[mj.Attributes.FasteningMethod], fasteningQuantity = mj.Attributes.FasteningQuantity.ToString(), force = new iFAB.force() { Value = decimal.Parse(mj.Attributes.Force.ToString()), unit = d_ForceUnits[mj.Attributes.ForceUnit] }, torque = new iFAB.torque() { Value = decimal.Parse(mj.Attributes.Torque.ToString()), unit = d_TorqueUnits[mj.Attributes.TorqueUnit] }, linkingPart = new List <partReference>() }; foreach (CyPhy.Fastener f in mj.Children.FastenerCollection) { iFAB.partReference pr = new partReference(); // If this refers to a Component model, get that guy's AVMID. // If not, use the AVMID provided in the attribute of this object. if (f.Referred.Component != null) { pr.id = f.Referred.Component.Attributes.AVMID; } else { pr.id = f.Attributes.AVMID; } for (int i = 0; i < f.Attributes.Quantity; i++) { m.linkingPart.Add(pr); } } rtn.Items.Add(m); } else { throw new NotSupportedException("JoinData export not supported for object of type " + jd.Impl.MetaBase.Name); } return(rtn); }