public override string ToString() { StringBuilder sb = new StringBuilder(); foreach (Parameter p in this) { string sValue = string.Empty; ParameterBool pBool = p as ParameterBool; if (null != pBool) { sValue = pBool.Value.ToString(); } ParameterInt pInt = p as ParameterInt; if (null != pInt) { sValue = pInt.Value.ToString(); } ParameterDouble pDouble = p as ParameterDouble; if (null != pDouble) { sValue = pDouble.Value.ToString(); } ParameterMulti pMulti = p as ParameterMulti; if (null != pMulti) { sValue = pMulti.Value.ToString() + " " + string.Join("|", pMulti.ValueList); } sb.AppendFormat("{0} = {1}\n", p.Name, sValue); } return(sb.ToString()); }
public override Parameter Clone() { ParameterDouble param = new ParameterDouble(Name, Description, HasValueMin, _valueMin, HasValueMax, _valueMax, ValueDefault); param._value = _value; return(param); }
public double GetDoubleParameterValue(string name) { ParameterDouble param = GetParameterByName(name) as ParameterDouble; if (null == param) { throw new ParameterInvalidType(name, "ParameterDouble"); } return(param.Value); }
public void SetDoubleParameter(string name, double value) { ParameterDouble param = GetParameterByName(name) as ParameterDouble; if (null == param) { throw new ParameterInvalidType(name, "ParameterDouble"); } param.Value = value; }
/// <summary> /// Try to get outer dimensions to use for palletisation /// </summary> /// <param name="stack">Parameter stack</param> /// <param name="length">Length</param> /// <param name="width">Width</param> /// <param name="height">Height</param> /// <returns>true if a valid set of dimensions could be retrieved</returns> public bool GetDimensions(ParameterStack stack, ref double length, ref double width, ref double height) { if (null != _ext1) { // search three parameters A/L, B, H bool foundL = false, foundW = false, foundH = false; foreach (Pic.Plugin.Parameter param in stack) { ParameterDouble paramDouble = param as ParameterDouble; if (null == paramDouble) { continue; } if (0 == string.Compare(paramDouble.Name.ToLower(), "a") || 0 == string.Compare(paramDouble.Name.ToLower(), "l")) { foundL = true; length = paramDouble.Value; } else if (0 == string.Compare(paramDouble.Name.ToLower(), "b")) { foundW = true; width = paramDouble.Value; } else if (0 == string.Compare(paramDouble.Name.ToLower(), "h")) { foundH = true; height = paramDouble.Value; } } // to support palletization, all three parameters must be found return(foundL && foundW && foundH); } else if (null != _ext2) { if (_ext2.IsSupportingPalletization) { double[] dim; _ext2.OuterDimensions(stack, out dim); length = dim[0]; width = dim[1]; height = dim[2]; return(true); } } else if (null != _ext3) { if (_ext3.IsSupportingPalletization) { double[] dim; _ext3.OuterDimensions(stack, out dim); length = dim[0]; width = dim[1]; height = dim[2]; return(true); } } return(false); }
public string GetInsertionCode() { Pic.Plugin.ParameterStack stackIn = _component.BuildParameterStack(null); string csCode = string.Empty; csCode += "\n"; csCode += "\t\t{ // " + _component.Name + "\n"; csCode += "\t\t\tIPlugin pluginIn = Host.GetPluginByGuid(\"" + _component.Guid.ToString() + "\");\n"; csCode += "\t\t\tParameterStack stackIn = Host.GetInitializedParameterStack(pluginIn);\n"; foreach (Parameter param in stackIn) { // double ParameterDouble paramDouble = param as ParameterDouble; if (null != paramDouble) { csCode += "\t\t\tstackIn.SetDoubleParameter(\"" + paramDouble.Name + "\"," + paramDouble.ValueDefault.ToString() + ");\t\t// " + paramDouble.Description + "\n"; } // bool ParameterBool paramBool = param as ParameterBool; if (null != paramBool) { csCode += "\t\t\tstackIn.SetBoolParameter(\"" + paramBool.Name + "\"," + (paramBool.ValueDefault ? "true" : "false") + ");\t\t// " + paramBool.Description + "\n"; } // int ParameterInt paramInt = param as ParameterInt; if (null != paramInt) { csCode += "\t\t\tstackIn.SetIntParameter(\"" + paramInt.Name + "\"," + paramInt.ValueDefault.ToString() + ");\t\t// " + paramInt.Description + "\n"; } // multi ParameterMulti paramMulti = param as ParameterMulti; if (null != paramMulti) { csCode += "\t\t\tstackIn.SetMultiParameter(\"" + paramMulti.Name + "\"," + paramMulti.Value.ToString() + ");\t\t// " + paramMulti.Description + "\n"; } } csCode += "\t\t\tbool reflectionX = false, reflectionY = false;\n"; csCode += "\t\t\tTransform2D transfReflect = (reflectionY ? Transform2D.ReflectionY : Transform2D.Identity) * (reflectionX ? Transform2D.ReflectionX : Transform2D.Identity);\n"; csCode += "\t\t\tpluginIn.CreateFactoryEntities(fTemp, stackIn,\n"; csCode += "\t\t\t\t Transform2D.Translation(new Vector2D(0.0, 0.0))\n"; csCode += "\t\t\t\t *Transform2D.Rotation(0.0)\n"; csCode += "\t\t\t\t *transfReflect);\n"; csCode += "\t\t}\n"; return(csCode); }
public void AddDoubleParameter(string name, string description, double valueDefault, bool hasMinValue, double valueMin, bool hasMaxValue, double valueMax) { ParameterDouble param = new ParameterDouble(); param.Name = name; param.Description = description; param.ValueDefault = valueDefault; param.Value = valueDefault; if (hasMinValue) { param.ValueMin = valueMin; } if (hasMaxValue) { param.ValueMax = valueMax; } _parameterList.Add(param); }
public ParameterStack GetParameters(IComponentSearchMethod compSearchMethod) { ParameterStack parameters = _instance.Parameters; if (null != compSearchMethod) { foreach (Parameter p in parameters) { try { ParameterDouble pd = p as ParameterDouble; if (null != pd) { parameters.SetDoubleParameter(pd.Name, compSearchMethod.GetDoubleParameterDefaultValue(Guid, pd.Name)); } ParameterBool pb = p as ParameterBool; if (null != pb) { parameters.SetBoolParameter(pb.Name, compSearchMethod.GetBoolParameterDefaultValue(Guid, pb.Name)); } ParameterInt pi = p as ParameterInt; if (null != pi) { parameters.SetIntegerParameter(pb.Name, compSearchMethod.GetIntParameterDefaultValue(Guid, pi.Name)); } ParameterMulti pm = p as ParameterMulti; if (null != pm) { parameters.SetMultiParameter(pm.Name, 0); } } catch (Exception /*ex*/) { } } } return(parameters); }
public void AddDoubleParameter(string name, string description, double valueDefault, bool hasMinValue, double valueMin, bool hasMaxValue, double valueMax) { ParameterDouble param = new ParameterDouble(); param.Name = name; param.Description = description; param.ValueDefault = valueDefault; param.Value = valueDefault; if (hasMinValue) param.ValueMin = valueMin; if (hasMaxValue) param.ValueMax = valueMax; _parameterList.Add(param); }
public override Parameter Clone() { ParameterDouble param = new ParameterDouble(Name, Description, _hasValueMin, _valueMin, _hasValueMax, _valueMax, _valueDefault); param._value = _value; return param; }
public ParameterStack GetInitializedParameterStack(IPlugin plugin) { // check if already available in cache ParameterStack stack = null; stack = ComponentLoader.GetStackFromCache(plugin.Guid); if (null == stack) { if (!(_searchMethod is IComponentSearchMethod)) { throw new PluginException("Component loader was not initialized with a valid plugin search method."); } IPluginExt1 pluginExt1 = plugin as IPluginExt1; IPluginExt2 pluginExt2 = plugin as IPluginExt2; IPluginExt3 pluginExt3 = plugin as IPluginExt3; // get parameter stack if (null != pluginExt1) { stack = plugin.Parameters; } else if (null != pluginExt2) { stack = pluginExt2.BuildParameterStack(null); } else if (null != pluginExt3) { stack = pluginExt3.BuildParameterStack(null); } // check parameter stack if (null == stack) { throw new PluginException("Failed to build initial parameter stack."); } // load parameter values from plugins foreach (Parameter param in stack) { try { ParameterDouble pd = param as ParameterDouble; if (null != pd) { stack.SetDoubleParameter(pd.Name, _searchMethod.GetDoubleParameterDefaultValue(plugin.Guid, pd.Name)); } ParameterBool pb = param as ParameterBool; if (null != pb) { stack.SetBoolParameter(pb.Name, _searchMethod.GetBoolParameterDefaultValue(plugin.Guid, pb.Name)); } ParameterInt pi = param as ParameterInt; if (null != pi) { stack.SetIntParameter(pi.Name, _searchMethod.GetIntParameterDefaultValue(plugin.Guid, pi.Name)); } ParameterMulti pm = param as ParameterMulti; if (null != pm) { stack.SetMultiParameter(pm.Name, _searchMethod.GetMultiParameterDefaultValue(plugin.Guid, pm.Name)); } } catch (Exception /*ex*/) { } } // save in cache ComponentLoader.InsertParameterStackInCache(plugin.Guid, stack); } return(stack.Clone()); }