private static bool ConvertCyPhyDataTypeEnum(DataTypeEnum xDataType, out CyPhyClasses.Property.AttributesClass.DataType_enum cyphyDataType)
 {
     if (xDataType == DataTypeEnum.Real)
     {
         cyphyDataType = CyPhyClasses.Property.AttributesClass.DataType_enum.Float;
     }
     else
     {
         var valid = Enum.TryParse(xDataType.ToString(), true, out cyphyDataType);
         return(valid);
     }
     return(true);
 }
Esempio n. 2
0
        /// <summary>
        /// Creates a CyPhy property for each technical detail kept on file for an OctoPart component
        /// </summary>
        public void AddOctoPartTechSpecsToComponent(CyPhy.Component comp, MfgBom.Bom.Part part)
        {
            dynamic dynJson = Newtonsoft.Json.JsonConvert.DeserializeObject(part.TechnicalSpecifications);

            if (dynJson != null)
            {
                foreach (var spec in dynJson)
                {
                    CyPhyClasses.Property.AttributesClass.DataType_enum type =
                        DeterminePropertyDataType((string)spec.Value.metadata.datatype, (string)spec.Value.metadata.key);

                    if (spec.Value.value.Count > 0)
                    {
                        BuildCyPhyProperty(comp, (string)spec.Value.metadata.key, (string)spec.Value.value[0], type, false);
                    }
                    // TODO: Add symbols if applicable ?
                    // spec.metadata.unit  // <-- returns null or {name, symbol}
                }

                #region layout

                // find the largest current X value so our new elements are added to the right of existing design elements
                // choose the greater value of PARAMETER_START_X and greatest_current_x, to handle case where models
                // have not yet been added (give user more space before the property list).
                greatest_current_x = 0;
                foreach (var child in GetCurrentDesignElement().AllChildren)
                {
                    foreach (MgaPart item in (child.Impl as MgaFCO).Parts)
                    {
                        int    read_x, read_y;
                        string read_str;
                        item.GetGmeAttrs(out read_str, out read_x, out read_y);
                        greatest_current_x = (read_x > greatest_current_x) ? read_x : greatest_current_x;
                    }
                }

                int PARAMETER_START = (PARAMETER_START_X > greatest_current_x) ? PARAMETER_START_X : greatest_current_x;

                int num_parsed_properties = 0;
                foreach (var property in comp.Children.PropertyCollection)
                {
                    foreach (MgaPart item in (property.Impl as MgaFCO).Parts)
                    {
                        item.SetGmeAttrs(null, PARAMETER_START, PARAMETER_START_Y + (num_parsed_properties * PARAMETER_ADJUST_Y));
                    }
                    num_parsed_properties++;
                }

                #endregion
            }
        }
Esempio n. 3
0
 public void BuildCyPhyProperty(CyPhy.Component comp,
                                string name,
                                string value,
                                CyPhyClasses.Property.AttributesClass.DataType_enum type,
                                bool is_prominent)
 {
     if (CheckPropertyDoesNotExist(comp, name))
     {
         CyPhy.Property property = ISIS.GME.Dsml.CyPhyML.Classes.Property.Create(comp);
         property.Name                   = name;
         property.Attributes.Value       = value;
         property.Attributes.DataType    = type;
         property.Attributes.IsProminent = is_prominent;
     }
 }