diff --git a/ExampleFiles/Parameters/4_Analysis/AnalysisTaskAndCase.gh b/ExampleFiles/Parameters/4_Analysis/AnalysisTaskAndCase.gh new file mode 100644 index 000000000..1a6c83010 Binary files /dev/null and b/ExampleFiles/Parameters/4_Analysis/AnalysisTaskAndCase.gh differ diff --git a/ExampleFiles/Parameters/4_Analysis/GetCreateAnalysisTaskAndCase.gh b/ExampleFiles/Parameters/4_Analysis/GetCreateAnalysisTaskAndCase.gh deleted file mode 100644 index 4a346ae19..000000000 Binary files a/ExampleFiles/Parameters/4_Analysis/GetCreateAnalysisTaskAndCase.gh and /dev/null differ diff --git a/GsaGH/Components/1_Properties/EditBool6.cs b/GsaGH/Components/1_Properties/EditBool6.cs index 25c6368be..304751a53 100644 --- a/GsaGH/Components/1_Properties/EditBool6.cs +++ b/GsaGH/Components/1_Properties/EditBool6.cs @@ -27,12 +27,12 @@ public class EditBool6 : GH_OasysComponent { pManager.AddParameter(new GsaBool6Parameter(), GsaBool6Goo.Name, GsaBool6Goo.NickName, GsaBool6Goo.Description + " to get or set information for. Leave blank to create a new " + GsaBool6Goo.Name, GH_ParamAccess.item); - pManager.AddBooleanParameter("X", "X", "Release or restrain for translation in X-direction", GH_ParamAccess.item); - pManager.AddBooleanParameter("Y", "Y", "Release or restrain for translation in Y-direction", GH_ParamAccess.item); - pManager.AddBooleanParameter("Z", "Z", "Release or restrain for translation in Z-direction", GH_ParamAccess.item); - pManager.AddBooleanParameter("XX", "XX", "Release or restrain for rotation around X-axis", GH_ParamAccess.item); - pManager.AddBooleanParameter("YY", "YY", "Release or restrain for rotation around Y-axis", GH_ParamAccess.item); - pManager.AddBooleanParameter("ZZ", "ZZ", "Release or restrain for rotation around Z-axis", GH_ParamAccess.item); + pManager.AddBooleanParameter("X", "X", "Release or restraint for translation in X-direction", GH_ParamAccess.item); + pManager.AddBooleanParameter("Y", "Y", "Release or restraint for translation in Y-direction", GH_ParamAccess.item); + pManager.AddBooleanParameter("Z", "Z", "Release or restraint for translation in Z-direction", GH_ParamAccess.item); + pManager.AddBooleanParameter("XX", "XX", "Release or restraint for rotation around X-axis", GH_ParamAccess.item); + pManager.AddBooleanParameter("YY", "YY", "Release or restraint for rotation around Y-axis", GH_ParamAccess.item); + pManager.AddBooleanParameter("ZZ", "ZZ", "Release or restraint for rotation around Z-axis", GH_ParamAccess.item); for (int i = 0; i < pManager.ParamCount; i++) { pManager[i].Optional = true; } @@ -41,12 +41,12 @@ public class EditBool6 : GH_OasysComponent { protected override void RegisterOutputParams(GH_OutputParamManager pManager) { pManager.AddParameter(new GsaBool6Parameter(), GsaBool6Goo.Name, GsaBool6Goo.NickName, GsaBool6Goo.Description + " with applied changes.", GH_ParamAccess.item); - pManager.AddBooleanParameter("X", "X", "Release or restrain for translation in the X-direction.", GH_ParamAccess.item); - pManager.AddBooleanParameter("Y", "Y", "Release or restrain for translation in the Y-direction.", GH_ParamAccess.item); - pManager.AddBooleanParameter("Z", "Z", "Release or restrain for translation in the Z-direction.", GH_ParamAccess.item); - pManager.AddBooleanParameter("XX", "XX", "Release or restrain for rotation around the X-axis.", GH_ParamAccess.item); - pManager.AddBooleanParameter("YY", "YY", "Release or restrain for rotation around the Y-axis.", GH_ParamAccess.item); - pManager.AddBooleanParameter("ZZ", "ZZ", "Release or restrain for rotation around the Z-axis.", GH_ParamAccess.item); + pManager.AddBooleanParameter("X", "X", "Release or restrain for translation in X-direction", GH_ParamAccess.item); + pManager.AddBooleanParameter("Y", "Y", "Release or restrain for translation in Y-direction", GH_ParamAccess.item); + pManager.AddBooleanParameter("Z", "Z", "Release or restrain for translation in Z-direction", GH_ParamAccess.item); + pManager.AddBooleanParameter("XX", "XX", "Release or restrain for rotation around X-axis", GH_ParamAccess.item); + pManager.AddBooleanParameter("YY", "YY", "Release or restrain for rotation around Y-axis", GH_ParamAccess.item); + pManager.AddBooleanParameter("ZZ", "ZZ", "Release or restrain for rotation around Z-axis", GH_ParamAccess.item); } protected override void SolveInstance(IGH_DataAccess da) { diff --git a/GsaGH/Components/1_Properties/EditProfile.cs b/GsaGH/Components/1_Properties/EditProfile.cs index bd0cb0b5f..27fa83d2b 100644 --- a/GsaGH/Components/1_Properties/EditProfile.cs +++ b/GsaGH/Components/1_Properties/EditProfile.cs @@ -33,7 +33,7 @@ public class EditProfile : GH_OasysComponent { protected override void RegisterInputParams(GH_InputParamManager pManager) { pManager.AddTextParameter("Profile", "Pf", "Profile to edit", GH_ParamAccess.item); pManager.AddAngleParameter("Orientation Angle", "⭮A", - "Set Profile Orientation Angle in counter-clockwise direction.", GH_ParamAccess.item); + "Set Profile Orientation Angle in counter-clockwise direction", GH_ParamAccess.item); pManager.AddBooleanParameter("Reflect Horizontal", "Ry", "True to reflect the profile about the local y-axis", GH_ParamAccess.item, false); pManager.AddBooleanParameter("Reflect Vertical", "Rz", diff --git a/GsaGH/Components/4_Analysis/AnalysisCaseInfo.cs b/GsaGH/Components/4_Analysis/AnalysisCaseInfo.cs index 8ae8f1a39..49a53fa94 100644 --- a/GsaGH/Components/4_Analysis/AnalysisCaseInfo.cs +++ b/GsaGH/Components/4_Analysis/AnalysisCaseInfo.cs @@ -19,7 +19,7 @@ public class AnalysisCaseInfo : GH_OasysComponent { protected override Bitmap Icon => Resources.AnalysisCaseInfo; public AnalysisCaseInfo() : base("Analysis Case Info", "CaseInfo", - "Get information about the properties of a GSA Analysis Case (Load Case or Combination)", + "Get information about a GSA Analysis Case", CategoryName.Name(), SubCategoryName.Cat4()) { Hidden = true; } @@ -43,10 +43,9 @@ public class AnalysisCaseInfo : GH_OasysComponent { } if (ghTyp.Value is GsaAnalysisCaseGoo goo) { - GsaAnalysisCase gsaCase = goo.Value.Duplicate(); - da.SetData(0, gsaCase.Name); - da.SetData(1, gsaCase.Definition); - da.SetData(2, gsaCase.Id); + da.SetData(0, goo.Value.Name); + da.SetData(1, goo.Value.Definition); + da.SetData(2, goo.Value.Id); } else { string type = ghTyp.Value.GetType().ToString(); type = type.Replace("GsaGH.Parameters.", string.Empty); diff --git a/GsaGH/Components/4_Analysis/AnalysisTaskInfo.cs b/GsaGH/Components/4_Analysis/AnalysisTaskInfo.cs new file mode 100644 index 000000000..e5ccf9336 --- /dev/null +++ b/GsaGH/Components/4_Analysis/AnalysisTaskInfo.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using Grasshopper.Kernel; +using Grasshopper.Kernel.Types; +using GsaGH.Helpers.GH; +using GsaGH.Parameters; +using GsaGH.Properties; +using OasysGH; +using OasysGH.Components; + +namespace GsaGH.Components { + /// + /// Component to get information about GSA Analysis Tasks + /// + public class AnalysisTaskInfo : GH_OasysComponent { + public override Guid ComponentGuid => new Guid("82d76442-cc58-49c6-b6d7-d0ae998ce063"); + public override GH_Exposure Exposure => GH_Exposure.secondary | GH_Exposure.obscure; + public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; + protected override Bitmap Icon => Resources.AnalysisTaskInfo; + + public AnalysisTaskInfo() : base("Analysis Task Info", "TaskInfo", + "Get information about a GSA Analysis Task", + CategoryName.Name(), SubCategoryName.Cat4()) { + Hidden = true; + } + + protected override void RegisterInputParams(GH_InputParamManager pManager) { + pManager.AddParameter(new GsaAnalysisTaskParameter(), GsaAnalysisTaskGoo.Name, + GsaAnalysisTaskGoo.NickName, GsaAnalysisTaskGoo.Name, GH_ParamAccess.item); + } + + protected override void RegisterOutputParams(GH_OutputParamManager pManager) { + pManager.AddTextParameter("Name", "Na", "Analysis Task Name", GH_ParamAccess.item); + pManager.AddParameter(new GsaAnalysisCaseParameter(), GsaAnalysisCaseGoo.Name + "(s)", + GsaAnalysisCaseGoo.NickName, "List of " + GsaAnalysisCaseGoo.Description, + GH_ParamAccess.list); + pManager.AddTextParameter("Solver Type", "sT", "Solver Type", GH_ParamAccess.item); + pManager.AddIntegerParameter("Task ID", "ID", "The Task number of the Analysis Task", + GH_ParamAccess.item); + } + + protected override void SolveInstance(IGH_DataAccess da) { + var ghTyp = new GH_ObjectWrapper(); + if (!da.GetData(0, ref ghTyp)) { + return; + } + + if (ghTyp.Value is GsaAnalysisTaskGoo goo) { + da.SetData(0, goo.Value.ApiTask.Name); + if (goo.Value.Cases != null) { + da.SetDataList(1, new List(goo.Value.Cases.Select(x => new GsaAnalysisCaseGoo(x)))); + } else { + da.SetData(1, null); + } + + var type = (AnalysisTaskType)goo.Value.ApiTask.Type; + da.SetData(2, type.ToString()); + da.SetData(3, goo.Value.Id); + } else { + string type = ghTyp.Value.GetType().ToString(); + type = type.Replace("GsaGH.Parameters.", string.Empty); + type = type.Replace("Goo", string.Empty); + Params.Owner.AddRuntimeError("Unable to convert Analysis Task input parameter of type " + + type + " to GsaAnalysisTask"); + } + } + } +} diff --git a/GsaGH/Components/4_Analysis/CombinationCaseInfo.cs b/GsaGH/Components/4_Analysis/CombinationCaseInfo.cs index 5e40daebf..415cdca22 100644 --- a/GsaGH/Components/4_Analysis/CombinationCaseInfo.cs +++ b/GsaGH/Components/4_Analysis/CombinationCaseInfo.cs @@ -18,7 +18,7 @@ public class CombinationCaseInfo : GH_OasysComponent { protected override Bitmap Icon => Resources.CombinationCaseInfo; public CombinationCaseInfo() : base("Combination Case Info", "CombinationInfo", - "Get information of a GSA Combination Case", CategoryName.Name(), SubCategoryName.Cat4()) { + "Get information about a GSA Combination Case", CategoryName.Name(), SubCategoryName.Cat4()) { Hidden = true; } diff --git a/GsaGH/Components/4_Analysis/CreateAnalysisTask.cs b/GsaGH/Components/4_Analysis/CreateAnalysisTask.cs index 8f4f1502f..dbc774490 100644 --- a/GsaGH/Components/4_Analysis/CreateAnalysisTask.cs +++ b/GsaGH/Components/4_Analysis/CreateAnalysisTask.cs @@ -1,8 +1,12 @@ using System; using System.Collections.Generic; using System.Drawing; +using System.Linq; +using GH_IO.Serialization; using Grasshopper.Kernel; +using Grasshopper.Kernel.Parameters; using Grasshopper.Kernel.Types; +using GsaAPI; using GsaGH.Helpers.GH; using GsaGH.Parameters; using GsaGH.Properties; @@ -14,11 +18,18 @@ namespace GsaGH.Components { /// Component to create a GSA Analysis Task /// public class CreateAnalysisTask : GH_OasysDropDownComponent { - public override Guid ComponentGuid => new Guid("6ef86d0b-892c-4b6f-950e-b4477e9f0910"); + internal static readonly IReadOnlyDictionary _solverTypes + = new Dictionary { + { "Static", AnalysisTaskType.Static }, + { "Static P-delta", AnalysisTaskType.StaticPDelta }, + }; + + public override Guid ComponentGuid => new Guid("581601cc-c0bc-47fe-ada5-b821327a4409"); public override GH_Exposure Exposure => GH_Exposure.secondary | GH_Exposure.obscure; public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; protected override Bitmap Icon => Resources.CreateAnalysisTask; - private AnalysisTaskType _tasktype = AnalysisTaskType.Static; + private AnalysisTaskType _type = AnalysisTaskType.Static; + private int _casesParamIndex = 2; public CreateAnalysisTask() : base( "Create " + GsaAnalysisTaskGoo.Name, @@ -27,12 +38,65 @@ public class CreateAnalysisTask : GH_OasysDropDownComponent { Hidden = true; } + public override bool Read(GH_IReader reader) { + _casesParamIndex = reader.GetInt32("_casesParamIndex"); + return base.Read(reader); + } + public override void SetSelected(int i, int j) { _selectedItems[i] = _dropDownItems[i][j]; - _tasktype = (AnalysisTaskType)Enum.Parse(typeof(AnalysisTaskType), _selectedItems[i]); + + if (i == 0) { + _type = _solverTypes[_selectedItems[i]]; + + UpdateDropdownItems(); + } + + UpdateParameters(); + base.UpdateUI(); } + public override void VariableParameterMaintenance() { + switch (_type) { + case AnalysisTaskType.StaticPDelta: + switch (_selectedItems[1]) { + case "Own": + default: + // do nothing + break; + + case "Load case": + Params.Input[2].NickName = "LC"; + Params.Input[2].Name = "Load case"; + Params.Input[2].Description = "Load case definition (e.g. 1.2L1 + 1.2L2)"; + Params.Input[2].Access = GH_ParamAccess.item; + Params.Input[2].Optional = false; + break; + + case "Result case": + Params.Input[2].NickName = "RC"; + Params.Input[2].Name = "Result case"; + Params.Input[2].Description = "The result case that forms the basis for the geometric stiffness"; + Params.Input[2].Access = GH_ParamAccess.item; + Params.Input[2].Optional = false; + break; + } + + break; + + case AnalysisTaskType.Static: + default: + // do nothing + break; + } + } + + public override bool Write(GH_IWriter writer) { + writer.SetInt32("_casesParamIndex", _casesParamIndex); + return base.Write(writer); + } + protected override void InitialiseDropdowns() { _spacerDescriptions = new List(new[] { "Solver", @@ -41,21 +105,22 @@ public class CreateAnalysisTask : GH_OasysDropDownComponent { _dropDownItems = new List>(); _selectedItems = new List(); - _dropDownItems.Add(new List() { - AnalysisTaskType.Static.ToString(), - }); - _selectedItems.Add(_tasktype.ToString()); + _dropDownItems.Add(_solverTypes.Keys.ToList()); + _selectedItems.Add(_dropDownItems[0].First()); _isInitialised = true; } protected override void RegisterInputParams(GH_InputParamManager pManager) { + pManager.AddIntegerParameter("Task ID", "ID", "The Task number of the Analysis Task", + GH_ParamAccess.item); pManager.AddTextParameter("Name", "Na", "Task Name", GH_ParamAccess.item); pManager.AddGenericParameter("Analysis Cases", "ΣAs", "List of GSA Analysis Cases (if left empty, all load cases in model will be added)", GH_ParamAccess.list); pManager[0].Optional = true; pManager[1].Optional = true; + pManager[2].Optional = true; } protected override void RegisterOutputParams(GH_OutputParamManager pManager) { @@ -63,13 +128,15 @@ public class CreateAnalysisTask : GH_OasysDropDownComponent { } protected override void SolveInternal(IGH_DataAccess da) { - string name = _tasktype.ToString(); - da.GetData(0, ref name); + int id = 0; + da.GetData(0, ref id); - List cases = null; + string name = _type.ToString(); + da.GetData(1, ref name); + List cases = null; var ghTypes = new List(); - if (da.GetDataList(1, ghTypes)) { + if (da.GetDataList(_casesParamIndex, ghTypes)) { cases = new List(); for (int i = 0; i < ghTypes.Count; i++) { GH_ObjectWrapper ghTyp = ghTypes[i]; @@ -97,23 +164,138 @@ public class CreateAnalysisTask : GH_OasysDropDownComponent { "Default Task has been created; it will by default contain all cases found in model"); } - if (_tasktype != AnalysisTaskType.Static) { - this.AddRuntimeWarning("It is currently not possible to adjust the solver settings. " - + Environment.NewLine - + "Please verify the solver settings in GSA ('Task and Cases' -> 'Analysis Tasks')"); + AnalysisTask task = null; + switch (_type) { + case AnalysisTaskType.Static: + task = AnalysisTaskFactory.CreateStaticAnalysisTask(name); + break; + + case AnalysisTaskType.StaticPDelta: + switch (_selectedItems[1]) { + case "Own": + task = AnalysisTaskFactory.CreateStaticPDeltaAnalysisTask(name, new GeometricStiffnessFromOwnLoad()); + break; + + case "Load case": + string caseDescription = string.Empty; + da.GetData(2, ref caseDescription); + task = AnalysisTaskFactory.CreateStaticPDeltaAnalysisTask(name, new GeometricStiffnessFromLoadCase(caseDescription)); + break; + + case "Result case": + int resultCase = 0; + da.GetData(2, ref resultCase); + task = AnalysisTaskFactory.CreateStaticPDeltaAnalysisTask(name, new GeometricStiffnessFromResultCase(resultCase)); + break; + } + break; } - var task = new GsaAnalysisTask { - Name = name, + var gsaAnalysisTask = new GsaAnalysisTask() { Cases = cases, - Type = _tasktype, + ApiTask = task, + Id = id }; - da.SetData(0, new GsaAnalysisTaskGoo(task)); + + da.SetData(0, new GsaAnalysisTaskGoo(gsaAnalysisTask)); } protected override void UpdateUIFromSelectedItems() { - _tasktype = (AnalysisTaskType)Enum.Parse(typeof(AnalysisTaskType), _selectedItems[0]); + _type = _solverTypes[_selectedItems[0]]; + base.UpdateUIFromSelectedItems(); } + + private void UpdateParameters() { + IGH_Param casesParam; + switch (_type) { + case AnalysisTaskType.Static: + casesParam = Params.Input[Params.Input.Count - 1]; + + while (Params.Input.Count > 2) { + Params.UnregisterInputParameter(Params.Input[2], true); + } + _casesParamIndex = 2; + Params.RegisterInputParam(casesParam); + + break; + + case AnalysisTaskType.StaticPDelta: + casesParam = Params.Input[Params.Input.Count - 1]; + + while (Params.Input.Count > 2) { + Params.UnregisterInputParameter(Params.Input[2], true); + } + + switch (_selectedItems[1]) { + case "Own": + default: + _casesParamIndex = 2; + break; + + case "Load case": + _casesParamIndex = 3; + Params.RegisterInputParam(new Param_String()); + break; + + case "Result case": + _casesParamIndex = 3; + Params.RegisterInputParam(new Param_Integer()); + break; + } + + Params.RegisterInputParam(casesParam); + + break; + + default: + break; + } + } + + private void UpdateDropdownItems() { + _dropDownItems = new List>(); + _selectedItems = new List(); + + switch (_type) { + case AnalysisTaskType.StaticPDelta: + _spacerDescriptions = new List(new[] { + "Solver", + "P-delta Case" + }); + + _dropDownItems.Add(_solverTypes.Keys.ToList()); + _selectedItems.Add(_dropDownItems[0][1]); + + _dropDownItems.Add(new List() { + "Own", + "Load case", + "Result case" + }); + _selectedItems.Add("Own"); + + break; + + case AnalysisTaskType.Static: + default: + _spacerDescriptions = new List(new[] { + "Solver", + }); + + _dropDownItems.Add(_solverTypes.Keys.ToList()); + _selectedItems.Add(_dropDownItems[0][0]); + break; + } + + ReDrawComponent(); + } + + private void ReDrawComponent() { + var pivot = new PointF(Attributes.Pivot.X, Attributes.Pivot.Y); + base.CreateAttributes(); + Attributes.Pivot = pivot; + Attributes.ExpireLayout(); + Attributes.PerformLayout(); + } } } diff --git a/GsaGH/Components/4_Analysis/EditAnalysisTask.cs b/GsaGH/Components/4_Analysis/EditAnalysisTask.cs deleted file mode 100644 index 55dbaee1f..000000000 --- a/GsaGH/Components/4_Analysis/EditAnalysisTask.cs +++ /dev/null @@ -1,106 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using Grasshopper.Kernel; -using Grasshopper.Kernel.Types; -using GsaGH.Helpers.GH; -using GsaGH.Parameters; -using GsaGH.Properties; -using OasysGH; -using OasysGH.Components; - -namespace GsaGH.Components { - /// - /// Component to edit GSA analysis tasks - /// - public class EditAnalysisTask : GH_OasysComponent { - public override Guid ComponentGuid => new Guid("efc2aae5-7ebf-4032-89d5-8fec8830989d"); - public override GH_Exposure Exposure => GH_Exposure.secondary | GH_Exposure.obscure; - public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - protected override Bitmap Icon => Resources.EditAnalysisTask; - - public EditAnalysisTask() : base("Edit Analysis Task", "EditTask", "Modify GSA Analysis Tasks", - CategoryName.Name(), SubCategoryName.Cat4()) { - Hidden = true; - } - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddParameter(new GsaAnalysisTaskParameter(), GsaAnalysisTaskGoo.Name, - GsaAnalysisTaskGoo.NickName, GsaAnalysisTaskGoo.Name + " to Edit", GH_ParamAccess.item); - pManager.AddParameter(new GsaAnalysisCaseParameter(), GsaAnalysisCaseGoo.Name + "(s)", - GsaAnalysisCaseGoo.NickName, "Add list of " + GsaAnalysisCaseGoo.Name + " to task", - GH_ParamAccess.list); - for (int i = 0; i < pManager.ParamCount; i++) { - pManager[i].Optional = true; - } - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddParameter(new GsaAnalysisTaskParameter(), GsaAnalysisTaskGoo.Name, - GsaAnalysisTaskGoo.NickName, "Modified " + GsaAnalysisTaskGoo.Name, GH_ParamAccess.item); - pManager.AddTextParameter("Name", "Na", "Task Name", GH_ParamAccess.item); - pManager.AddParameter(new GsaAnalysisCaseParameter(), GsaAnalysisCaseGoo.Name + "(s)", - GsaAnalysisCaseGoo.NickName, "List of " + GsaAnalysisCaseGoo.Description, - GH_ParamAccess.list); - pManager.AddTextParameter("Solver Type", "sT", "Solver Type", GH_ParamAccess.item); - pManager.AddIntegerParameter("TaskID", "ID", - "The Task number if the Analysis Case ever belonged to a model", GH_ParamAccess.item); - } - - protected override void SolveInstance(IGH_DataAccess da) { - var gsaTask = new GsaAnalysisTask(); - GsaAnalysisTaskGoo analysisTaskGoo = null; - if (da.GetData(0, ref analysisTaskGoo)) { - gsaTask = analysisTaskGoo.Value.Duplicate(); - } - - if (gsaTask != null) { - var ghTypes = new List(); - if (da.GetDataList(1, ghTypes)) { - var cases = new List(); - for (int i = 0; i < ghTypes.Count; i++) { - GH_ObjectWrapper ghTyp2 = ghTypes[i]; - if (ghTyp2 == null) { - Params.Owner.AddRuntimeWarning("Analysis Case input (index: " + i - + ") is null and has been ignored"); - continue; - } - - if (ghTyp2.Value is GsaAnalysisCaseGoo goo) { - cases.Add(goo.Value.Duplicate()); - } else { - string typ = ghTyp2.Value.GetType().ToString(); - typ = typ.Replace("GsaGH.Parameters.", string.Empty); - typ = typ.Replace("Goo", string.Empty); - Params.Owner.AddRuntimeError( - "Unable to convert Analysis Case input parameter of type " + typ - + " to GsaAnalysisCase"); - return; - } - } - - gsaTask.Cases = cases; - } - - da.SetData(0, new GsaAnalysisTaskGoo(gsaTask)); - da.SetData(1, gsaTask.Name); - if (gsaTask.Cases != null) { - da.SetDataList(2, - new List(gsaTask.Cases.Select(x => new GsaAnalysisCaseGoo(x)))); - } else { - da.SetData(2, null); - } - - da.SetData(3, gsaTask.Type.ToString()); - da.SetData(4, gsaTask.Id); - } else { - string type = analysisTaskGoo.Value.GetType().ToString(); - type = type.Replace("GsaGH.Parameters.", string.Empty); - type = type.Replace("Goo", string.Empty); - Params.Owner.AddRuntimeError("Unable to convert Analysis Task input parameter of type " - + type + " to GsaAnalysisTask"); - } - } - } -} diff --git a/GsaGH/Components/5_Results/AssemblyDisplacements.cs b/GsaGH/Components/5_Results/AssemblyDisplacements.cs index a59bd0c2c..293776834 100644 --- a/GsaGH/Components/5_Results/AssemblyDisplacements.cs +++ b/GsaGH/Components/5_Results/AssemblyDisplacements.cs @@ -82,19 +82,19 @@ public class AssemblyDisplacements : GH_OasysDropDownComponent { string note = ResultNotes.NoteAssemblyResults; pManager.AddGenericParameter("Translation X [" + unitAbbreviation + "]", "Ux", - "Translation in Local Assembly X-direction." + note, GH_ParamAccess.tree); + "Translation in Local Assembly X-direction" + note, GH_ParamAccess.tree); pManager.AddGenericParameter("Translation Y [" + unitAbbreviation + "]", "Uy", - "Translation in Local Assembly Y-direction." + note, GH_ParamAccess.tree); + "Translation in Local Assembly Y-direction" + note, GH_ParamAccess.tree); pManager.AddGenericParameter("Translation Z [" + unitAbbreviation + "]", "Uz", - "Translation in Local Assembly Z-direction." + note, GH_ParamAccess.tree); + "Translation in Local Assembly Z-direction" + note, GH_ParamAccess.tree); pManager.AddGenericParameter("Translation |XYZ| [" + unitAbbreviation + "]", "|U|", "Combined |XYZ| Translation." + note, GH_ParamAccess.tree); pManager.AddGenericParameter("Rotation XX [rad]", "Rxx", - "Rotation around Local Assembly X-axis." + note, GH_ParamAccess.tree); + "Rotation around Local Assembly X-axis" + note, GH_ParamAccess.tree); pManager.AddGenericParameter("Rotation YY [rad]", "Ryy", - "Rotation around Local Assembly Y-axis." + note, GH_ParamAccess.tree); + "Rotation around Local Assembly Y-axis" + note, GH_ParamAccess.tree); pManager.AddGenericParameter("Rotation ZZ [rad]", "Rzz", - "Rotation around Local Assembly Z-axis." + note, GH_ParamAccess.tree); + "Rotation around Local Assembly Z-axis" + note, GH_ParamAccess.tree); pManager.AddGenericParameter("Rotation |XYZ| [rad]", "|R|", "Combined |XXYYZZ| Rotation." + note, GH_ParamAccess.tree); } diff --git a/GsaGH/Components/5_Results/AssemblyDriftIndices.cs b/GsaGH/Components/5_Results/AssemblyDriftIndices.cs index 79df43e16..3189c0346 100644 --- a/GsaGH/Components/5_Results/AssemblyDriftIndices.cs +++ b/GsaGH/Components/5_Results/AssemblyDriftIndices.cs @@ -68,11 +68,11 @@ public class AssemblyDriftIndices : GH_OasysDropDownComponent { string note = ResultNotes.NoteAssemblyResults; pManager.AddGenericParameter("Drift Index X", "DIx", - "Drift Index in Local Assembly X-direction." + note, GH_ParamAccess.tree); + "Drift Index in Local Assembly X-direction" + note, GH_ParamAccess.tree); pManager.AddGenericParameter("Drift Index Y", "DIy", - "Drift Index in Local Assembly Y-direction." + note, GH_ParamAccess.tree); + "Drift Index in Local Assembly Y-direction" + note, GH_ParamAccess.tree); pManager.AddGenericParameter("Drift Index XY", "In-plane", - "Drift Index in Local Assembly XY-plane." + note, GH_ParamAccess.tree); + "Drift Index in Local Assembly XY-plane" + note, GH_ParamAccess.tree); } protected override void SolveInternal(IGH_DataAccess da) { diff --git a/GsaGH/Components/5_Results/AssemblyDrifts.cs b/GsaGH/Components/5_Results/AssemblyDrifts.cs index 1db31e683..5ad2e0e20 100644 --- a/GsaGH/Components/5_Results/AssemblyDrifts.cs +++ b/GsaGH/Components/5_Results/AssemblyDrifts.cs @@ -80,11 +80,11 @@ public class AssemblyDrifts : GH_OasysDropDownComponent { string note = ResultNotes.NoteAssemblyResults; pManager.AddGenericParameter("Drift X [" + unitAbbreviation + "]", "Dx", - "Drift in Local Assembly X-direction." + note, GH_ParamAccess.tree); + "Drift in Local Assembly X-direction" + note, GH_ParamAccess.tree); pManager.AddGenericParameter("Drift Y [" + unitAbbreviation + "]", "Dy", - "Drift in Local Assembly Y-direction." + note, GH_ParamAccess.tree); + "Drift in Local Assembly Y-direction" + note, GH_ParamAccess.tree); pManager.AddGenericParameter("Drift XY [" + unitAbbreviation + "]", "In-plane", - "Drift in Local Assembly XY-plane." + note, GH_ParamAccess.tree); + "Drift in Local Assembly XY-plane" + note, GH_ParamAccess.tree); } protected override void SolveInternal(IGH_DataAccess da) { diff --git a/GsaGH/Components/5_Results/AssemblyForcesAndMoments.cs b/GsaGH/Components/5_Results/AssemblyForcesAndMoments.cs index 7a577d118..01d63fbd8 100644 --- a/GsaGH/Components/5_Results/AssemblyForcesAndMoments.cs +++ b/GsaGH/Components/5_Results/AssemblyForcesAndMoments.cs @@ -105,26 +105,26 @@ public class AssemblyForcesAndMoments : GH_OasysDropDownComponent { string note = ResultNotes.NoteAssemblyResults; pManager.AddGenericParameter("Force X [" + forceunitAbbreviation + "]", "Fx", - "Assembly Axial Force in Local Element X-direction." + forcerule + note, + "Assembly Axial Force in Local Element X-direction" + forcerule + note, GH_ParamAccess.tree); pManager.AddGenericParameter("Force Y [" + forceunitAbbreviation + "]", "Fy", - "Assembly Shear Force in Local Element Y-direction." + forcerule + note, + "Assembly Shear Force in Local Element Y-direction" + forcerule + note, GH_ParamAccess.tree); pManager.AddGenericParameter("Force Z [" + forceunitAbbreviation + "]", "Fz", - "Assembly Shear Force in Local Element Z-direction." + forcerule + note, + "Assembly Shear Force in Local Element Z-direction" + forcerule + note, GH_ParamAccess.tree); pManager.AddGenericParameter("Force |YZ| [" + forceunitAbbreviation + "]", "|Fyz|", - "Total |YZ| Assembly Shear Force." + note, GH_ParamAccess.tree); + "Total |YZ| Assembly Shear Force" + note, GH_ParamAccess.tree); pManager.AddGenericParameter("Moment XX [" + momentunitAbbreviation + "]", "Mxx", - "Assembly Torsional Moment around Local Element X-axis." + momentrule + note, + "Assembly Torsional Moment around Local Element X-axis" + momentrule + note, GH_ParamAccess.tree); pManager.AddGenericParameter("Moment YY [" + momentunitAbbreviation + "]", "Myy", - "Assembly Bending Moment around Local Element Y-axis." + momentrule + note, + "Assembly Bending Moment around Local Element Y-axis" + momentrule + note, GH_ParamAccess.tree); pManager.AddGenericParameter("Moment ZZ [" + momentunitAbbreviation + "]", "Mzz", - "Assembly Bending Moment around Local Element Z-axis." + momentrule + note, + "Assembly Bending Moment around Local Element Z-axis" + momentrule + note, GH_ParamAccess.tree); pManager.AddGenericParameter("Moment |YZ| [" + momentunitAbbreviation + "]", "|Myz|", - "Total |YYZZ| Assembly Bending Moment." + note, GH_ParamAccess.tree); + "Total |YYZZ| Assembly Bending Moment" + note, GH_ParamAccess.tree); } protected override void SolveInternal(IGH_DataAccess da) { diff --git a/GsaGH/Components/99_Obsolete/CreateAnalysisTask_OBSOLETE.cs b/GsaGH/Components/99_Obsolete/CreateAnalysisTask_OBSOLETE.cs new file mode 100644 index 000000000..3e28ba213 --- /dev/null +++ b/GsaGH/Components/99_Obsolete/CreateAnalysisTask_OBSOLETE.cs @@ -0,0 +1,120 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using Grasshopper.Kernel; +using Grasshopper.Kernel.Types; +using GsaAPI; +using GsaGH.Helpers.GH; +using GsaGH.Parameters; +using GsaGH.Properties; +using OasysGH; +using OasysGH.Components; + +namespace GsaGH.Components { + /// + /// Component to create a GSA Analysis Task + /// + public class CreateAnalysisTask_OBSOLETE : GH_OasysDropDownComponent { + public override Guid ComponentGuid => new Guid("6ef86d0b-892c-4b6f-950e-b4477e9f0910"); + public override GH_Exposure Exposure => GH_Exposure.hidden; + public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; + protected override Bitmap Icon => Resources.CreateAnalysisTask; + private AnalysisTaskType _tasktype = AnalysisTaskType.Static; + + public CreateAnalysisTask_OBSOLETE() : base( + "Create " + GsaAnalysisTaskGoo.Name, + GsaAnalysisTaskGoo.NickName.Replace(" ", string.Empty), + "Create a " + GsaAnalysisTaskGoo.Description, CategoryName.Name(), SubCategoryName.Cat4()) { + Hidden = true; + } + + public override void SetSelected(int i, int j) { + _selectedItems[i] = _dropDownItems[i][j]; + _tasktype = (AnalysisTaskType)Enum.Parse(typeof(AnalysisTaskType), _selectedItems[i]); + base.UpdateUI(); + } + + protected override void InitialiseDropdowns() { + _spacerDescriptions = new List(new[] { + "Solver", + }); + + _dropDownItems = new List>(); + _selectedItems = new List(); + + _dropDownItems.Add(new List() { + AnalysisTaskType.Static.ToString(), + }); + _selectedItems.Add(_tasktype.ToString()); + + _isInitialised = true; + } + + protected override void RegisterInputParams(GH_InputParamManager pManager) { + pManager.AddTextParameter("Name", "Na", "Task Name", GH_ParamAccess.item); + pManager.AddGenericParameter("Analysis Cases", "ΣAs", + "List of GSA Analysis Cases (if left empty, all load cases in model will be added)", + GH_ParamAccess.list); + pManager[0].Optional = true; + pManager[1].Optional = true; + } + + protected override void RegisterOutputParams(GH_OutputParamManager pManager) { + pManager.AddParameter(new GsaAnalysisTaskParameter()); + } + + protected override void SolveInternal(IGH_DataAccess da) { + string name = _tasktype.ToString(); + da.GetData(0, ref name); + + List cases = null; + + var ghTypes = new List(); + if (da.GetDataList(1, ghTypes)) { + cases = new List(); + for (int i = 0; i < ghTypes.Count; i++) { + GH_ObjectWrapper ghTyp = ghTypes[i]; + if (ghTyp == null) { + Params.Owner.AddRuntimeWarning("Analysis Case input (index: " + i + + ") is null and has been ignored"); + continue; + } + + if (ghTyp.Value is GsaAnalysisCaseGoo goo) { + cases.Add(goo.Value.Duplicate()); + } else { + string type = ghTyp.Value.GetType().ToString(); + type = type.Replace("GsaGH.Parameters.", string.Empty); + type = type.Replace("Goo", string.Empty); + Params.Owner.AddRuntimeError("Unable to convert Analysis Case input parameter of type " + + type + " to GsaAnalysisCase"); + return; + } + } + } + + if (cases == null) { + this.AddRuntimeRemark( + "Default Task has been created; it will by default contain all cases found in model"); + } + + if (_tasktype != AnalysisTaskType.Static) { + this.AddRuntimeWarning("It is currently not possible to adjust the solver settings. " + + Environment.NewLine + + "Please verify the solver settings in GSA ('Task and Cases' -> 'Analysis Tasks')"); + } + + var task = new GsaAnalysisTask { + Cases = cases, + ApiTask = AnalysisTaskFactory.CreateStaticAnalysisTask(name) + }; + + da.SetData(0, new GsaAnalysisTaskGoo(task)); + } + + protected override void UpdateUIFromSelectedItems() { + _tasktype = (AnalysisTaskType)Enum.Parse(typeof(AnalysisTaskType), _selectedItems[0]); + base.UpdateUIFromSelectedItems(); + } + } +} diff --git a/GsaGH/Helpers/Assembly/ModelAssembly.cs b/GsaGH/Helpers/Assembly/ModelAssembly.cs index 5e3026f07..2c7c219a1 100644 --- a/GsaGH/Helpers/Assembly/ModelAssembly.cs +++ b/GsaGH/Helpers/Assembly/ModelAssembly.cs @@ -238,7 +238,7 @@ internal partial class ModelAssembly { ReadOnlyDictionary existingTasks = _model.AnalysisTasks(); foreach (GsaAnalysisTask task in analysisTasks) { if (!existingTasks.Keys.Contains(task.Id)) { - task.Id = _model.AddAnalysisTask(); + task.Id = _model.AddAnalysisTask(task.ApiTask); } if (task.Cases == null || task.Cases.Count == 0) { diff --git a/GsaGH/Helpers/MergeModels.cs b/GsaGH/Helpers/MergeModels.cs index 8f52cb08b..73f3ef05f 100644 --- a/GsaGH/Helpers/MergeModels.cs +++ b/GsaGH/Helpers/MergeModels.cs @@ -139,15 +139,12 @@ public class MergeModels { gooloads.AddRange(GsaLoadFactory.CreateBeamThermalLoadsFromApi(appendModel.ApiModel)); gooloads.AddRange(GsaLoadFactory.CreateFaceLoadsFromApi(appendModel.ApiModel)); gooloads.AddRange(GsaLoadFactory.CreateFaceThermalLoadsFromApi(appendModel.ApiModel)); - - IReadOnlyDictionary srfDict = appendModel.ApiModel.GridSurfaces(); - IReadOnlyDictionary plnDict = appendModel.ApiModel.GridPlanes(); - gooloads.AddRange(GsaLoadFactory.CreateGridPointLoadsFromApi(appendModel.ApiModel, LengthUnit.Meter)); gooloads.AddRange(GsaLoadFactory.CreateGridLineLoadsFromApi(appendModel.ApiModel, LengthUnit.Meter)); gooloads.AddRange(GsaLoadFactory.CreateGridAreaLoadsFromApi(appendModel.ApiModel, LengthUnit.Meter)); var loads = gooloads.Select(n => n.Value).ToList(); + IReadOnlyDictionary srfDict = appendModel.ApiModel.GridSurfaces(); var gpsgoo = srfDict.Keys.Select(key => new GsaGridPlaneSurfaceGoo( GsaLoadFactory.CreateGridPlaneSurfaceFromApi(appendModel.ApiModel, key, LengthUnit.Meter))).ToList(); var gps = gpsgoo.Select(n => n.Value).ToList(); diff --git a/GsaGH/Parameters/4_Analysis/GsaAnalysisTask.cs b/GsaGH/Parameters/4_Analysis/GsaAnalysisTask.cs index e360660d7..a12e6d94f 100644 --- a/GsaGH/Parameters/4_Analysis/GsaAnalysisTask.cs +++ b/GsaGH/Parameters/4_Analysis/GsaAnalysisTask.cs @@ -7,49 +7,30 @@ namespace GsaGH.Parameters { /// /// An analysis task is a package of work for the solver. Thus we can have a static analysis task, a modal analysis task, etc. Each analysis task has one or more analysis case(s). The distinction is that the cases corresponds to result sets and define items such as loading (in the static case) while the task describes what the solver has to do. - /// In Grasshopper, it is only possible to create linear static analysis tasks. /// Refer to Analysis Tasks to read more. /// public class GsaAnalysisTask { - public List Cases { get; set; } = null; + public List Cases { get; set; } = new List(); public int Id { get; set; } = 0; - public string Name { get; set; } - public AnalysisTaskType Type { get; set; } + public AnalysisTask ApiTask { get; internal set; } public GsaAnalysisTask() { Id = 0; - Cases = new List(); - Type = AnalysisTaskType.Static; } internal GsaAnalysisTask(int id, AnalysisTask task, Model model) { Id = id; - Cases = new List(); foreach (int caseId in task.Cases) { string caseName = model.AnalysisCaseName(caseId); string caseDescription = model.AnalysisCaseDescription(caseId); Cases.Add(new GsaAnalysisCase(caseId, caseName, caseDescription)); } - Type = (AnalysisTaskType)task.Type; - Name = task.Name; - } - - public GsaAnalysisTask Duplicate() { - var dup = new GsaAnalysisTask { - Id = Id, - }; - if (Cases != null) { - dup.Cases = Cases.ToList(); - } - - dup.Type = Type; - dup.Name = Name; - return dup; + ApiTask = task; } public override string ToString() { - return (Id > 0 ? $"ID:{Id} " : string.Empty) + $"'{Name}' {Type}".Replace("_", " ") + return (Id > 0 ? $"ID:{Id} " : string.Empty) + $"'{ApiTask.Name}' {ApiTask.Type}".Replace("_", " ") .TrimSpaces(); } diff --git a/GsaGH/Properties/Icons/AnalysisTaskInfo.png b/GsaGH/Properties/Icons/AnalysisTaskInfo.png new file mode 100644 index 000000000..502398fb0 Binary files /dev/null and b/GsaGH/Properties/Icons/AnalysisTaskInfo.png differ diff --git a/GsaGH/Properties/Resources.Designer.cs b/GsaGH/Properties/Resources.Designer.cs index cc19e457b..f9cc7021e 100644 --- a/GsaGH/Properties/Resources.Designer.cs +++ b/GsaGH/Properties/Resources.Designer.cs @@ -100,6 +100,16 @@ internal class Resources { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap AnalysisTaskInfo { + get { + object obj = ResourceManager.GetObject("AnalysisTaskInfo", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/GsaGH/Properties/Resources.resx b/GsaGH/Properties/Resources.resx index ebb03bce2..378cefadd 100644 --- a/GsaGH/Properties/Resources.resx +++ b/GsaGH/Properties/Resources.resx @@ -685,6 +685,9 @@ Icons\AssemblyResults.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + Icons\AnalysisTaskInfo.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + Icons\SteelUtilisations.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a diff --git a/GsaGHTests/1_BaseParameters/4_Analysis/GsaAnalysisTaskTest.cs b/GsaGHTests/1_BaseParameters/4_Analysis/GsaAnalysisTaskTest.cs index 11063486e..616861afb 100644 --- a/GsaGHTests/1_BaseParameters/4_Analysis/GsaAnalysisTaskTest.cs +++ b/GsaGHTests/1_BaseParameters/4_Analysis/GsaAnalysisTaskTest.cs @@ -1,38 +1,15 @@ -using System.Collections.Generic; -using GsaGH.Parameters; -using GsaGHTests.Helpers; +using GsaGH.Parameters; using Xunit; namespace GsaGHTests.Parameters { [Collection("GrasshopperFixture collection")] public class GsaAnalysisTaskTest { - - [Fact] - public void DuplicateTest() { - var original = new GsaAnalysisTask(); - - GsaAnalysisTask duplicate = original.Duplicate(); - - Duplicates.AreEqual(original, duplicate); - - duplicate.Id = 1; - duplicate.Name = "name"; - duplicate.Type = AnalysisTaskType.Buckling; - duplicate.Cases = new List(); - - Assert.Equal(0, original.Id); - Assert.Null(original.Name); - Assert.Equal(AnalysisTaskType.Static, original.Type); - Assert.Empty(original.Cases); - } - [Fact] public void EmptyConstructorTest() { var task = new GsaAnalysisTask(); Assert.Equal(0, task.Id); - Assert.Null(task.Name); - Assert.Equal(AnalysisTaskType.Static, task.Type); + Assert.Null(task.ApiTask); Assert.Empty(task.Cases); } } diff --git a/GsaGHTests/2_GooWrappers/GH_OasysGooTest.cs b/GsaGHTests/2_GooWrappers/GH_OasysGooTest.cs index 994c5166e..37fd72a56 100644 --- a/GsaGHTests/2_GooWrappers/GH_OasysGooTest.cs +++ b/GsaGHTests/2_GooWrappers/GH_OasysGooTest.cs @@ -54,7 +54,7 @@ public class GhOasysGooTest { // 4_Analysis [InlineData(typeof(GsaAnalysisCaseGoo), typeof(GsaAnalysisCase))] - [InlineData(typeof(GsaAnalysisTaskGoo), typeof(GsaAnalysisTask))] + //[InlineData(typeof(GsaAnalysisTaskGoo), typeof(GsaAnalysisTask))] [InlineData(typeof(GsaCombinationCaseGoo), typeof(GsaCombinationCase))] // 5_Results diff --git a/GsaGHTests/3_Components/0_Model/CreateModelTest.cs b/GsaGHTests/3_Components/0_Model/CreateModelTest.cs index dc9704e85..2ad8bf2b6 100644 --- a/GsaGHTests/3_Components/0_Model/CreateModelTest.cs +++ b/GsaGHTests/3_Components/0_Model/CreateModelTest.cs @@ -11,100 +11,6 @@ namespace GsaGHTests.Model { [Collection("GrasshopperFixture collection")] public class CreateModelTest { - public static GH_OasysDropDownComponent CreateModel( - List models, List sections, List prop2ds, - List prop3ds, List springProps, List node, - List elem1d, List elem2d, List mem1d, - List mem2d, List mem3d, ModelUnit unit, List loads, - List gridPlaneSurfaces) { - var comp = new CreateModel(); - comp.CreateAttributes(); - comp.Params.Input[0].DataMapping = GH_DataMapping.Flatten; - comp.Params.Input[1].DataMapping = GH_DataMapping.Flatten; - comp.Params.Input[2].DataMapping = GH_DataMapping.Flatten; - comp.Params.Input[3].DataMapping = GH_DataMapping.Flatten; - comp.SetSelected(0, (int)unit); - if (models != null) { - foreach (GsaModel input in models) { - ComponentTestHelper.SetInput(comp, input, 0); - } - } - - if (sections != null) { - foreach (GsaSection input in sections) { - ComponentTestHelper.SetInput(comp, input, 1); - } - } - - if (prop2ds != null) { - foreach (GsaProperty2d input in prop2ds) { - ComponentTestHelper.SetInput(comp, input, 1); - } - } - - if (prop3ds != null) { - foreach (GsaProperty3d input in prop3ds) { - ComponentTestHelper.SetInput(comp, input, 1); - } - } - - if (springProps != null) { - foreach (GsaSpringProperty input in springProps) { - ComponentTestHelper.SetInput(comp, input, 1); - } - } - - if (node != null) { - foreach (GsaNodeGoo input in node) { - ComponentTestHelper.SetInput(comp, input, 2); - } - } - - if (elem1d != null) { - foreach (GsaElement1dGoo input in elem1d) { - ComponentTestHelper.SetInput(comp, input, 2); - } - } - - if (elem2d != null) { - foreach (GsaElement2dGoo input in elem2d) { - ComponentTestHelper.SetInput(comp, input, 2); - } - } - - if (mem1d != null) { - foreach (GsaMember1dGoo input in mem1d) { - ComponentTestHelper.SetInput(comp, input, 2); - } - } - - if (mem2d != null) { - foreach (GsaMember2dGoo input in mem2d) { - ComponentTestHelper.SetInput(comp, input, 2); - } - } - - if (mem3d != null) { - foreach (GsaMember3dGoo input in mem3d) { - ComponentTestHelper.SetInput(comp, input, 2); - } - } - - if (loads != null) { - foreach (IGsaLoad input in loads) { - ComponentTestHelper.SetInput(comp, input, 3); - } - } - - if (gridPlaneSurfaces != null) { - foreach (GsaGridPlaneSurface input in gridPlaneSurfaces) { - ComponentTestHelper.SetInput(comp, input, 3); - } - } - - return comp; - } - public static GH_OasysDropDownComponent CreateModelFromGeometry( List node, List elem1d, List elem2d, List mem1d, List mem2d, List mem3d, diff --git a/GsaGHTests/3_Components/0_Model/GetModelAnalysisTests.cs b/GsaGHTests/3_Components/0_Model/GetModelAnalysisTests.cs index a53e88477..b978a67cd 100644 --- a/GsaGHTests/3_Components/0_Model/GetModelAnalysisTests.cs +++ b/GsaGHTests/3_Components/0_Model/GetModelAnalysisTests.cs @@ -24,8 +24,8 @@ public class GetModelAnalysisTests { Assert.NotNull(taskGoo); Assert.Equal(1, taskGoo.Value.Id); Assert.Equal(2, taskGoo.Value.Cases.Count); - Assert.Equal("Task 1", taskGoo.Value.Name); - Assert.Equal(AnalysisTaskType.Static, taskGoo.Value.Type); + Assert.Equal("Task 1", taskGoo.Value.ApiTask.Name); + Assert.Equal((int)AnalysisTaskType.Static, taskGoo.Value.ApiTask.Type); Assert.NotNull(caseGoo); Assert.Equal(1, caseGoo.Value.Id); diff --git a/GsaGHTests/3_Components/4_Analysis/AnalysisCaseInfoTests.cs b/GsaGHTests/3_Components/4_Analysis/AnalysisCaseInfoTests.cs index 7a38b8dc8..3a3de5f9c 100644 --- a/GsaGHTests/3_Components/4_Analysis/AnalysisCaseInfoTests.cs +++ b/GsaGHTests/3_Components/4_Analysis/AnalysisCaseInfoTests.cs @@ -8,7 +8,6 @@ namespace GsaGHTests.Components.Analysis { [Collection("GrasshopperFixture collection")] public class AnalysisCaseInfoTests { - public static GH_OasysComponent ComponentMother() { var comp = new AnalysisCaseInfo(); comp.CreateAttributes(); diff --git a/GsaGHTests/3_Components/4_Analysis/AnalysisTaskInfoTests.cs b/GsaGHTests/3_Components/4_Analysis/AnalysisTaskInfoTests.cs new file mode 100644 index 000000000..370cb1b15 --- /dev/null +++ b/GsaGHTests/3_Components/4_Analysis/AnalysisTaskInfoTests.cs @@ -0,0 +1,68 @@ +using Grasshopper.Kernel.Types; +using GsaGH.Components; +using GsaGH.Parameters; +using GsaGHTests.Helper; +using GsaGHTests.Helpers; +using OasysGH.Components; +using Xunit; + +namespace GsaGHTests.Components.Analysis { + [Collection("GrasshopperFixture collection")] + public class AnalysisTaskInfoTests { + public static GH_OasysComponent ComponentMother() { + var comp = new AnalysisTaskInfo(); + comp.CreateAttributes(); + + var output = (GsaAnalysisTaskGoo)ComponentTestHelper.GetOutput( + CreateAnalysisTaskTests.ComponentMother()); + ComponentTestHelper.SetInput(comp, output); + + return comp; + } + + [Fact] + public void CreateComponentTest() { + GH_OasysComponent comp = ComponentMother(); + + var output0 = (GH_String)ComponentTestHelper.GetOutput(comp, 0); + var output1 = (GsaAnalysisCaseGoo)ComponentTestHelper.GetOutput(comp, 1); + var output2 = (GH_String)ComponentTestHelper.GetOutput(comp, 2); + var output3 = (GH_Integer)ComponentTestHelper.GetOutput(comp, 3); + + Assert.Equal("my Task", output0.Value); + Assert.Equal(0, output1.Value.Id); + Assert.Equal("1.4L1 + 0.8L3", output1.Value.Definition); + Assert.Equal("my Case", output1.Value.Name); + Assert.Equal("Static", output2.Value); + Assert.Equal(1, output3.Value); + } + + [Fact] + public void GetTaskInfoFromModelTest() { + // Assemble + var getModelAnalysis = new GetModelAnalysis(); + var model = new GsaModel(); + model.ApiModel.Open(GsaFile.SteelDesignSimple); + ComponentTestHelper.SetInput(getModelAnalysis, new GsaModelGoo(model)); + var taskGoo = (GsaAnalysisTaskGoo)ComponentTestHelper.GetOutput(getModelAnalysis); + + // Act + var comp = new AnalysisTaskInfo(); + comp.CreateAttributes(); + ComponentTestHelper.SetInput(comp, taskGoo); + + // Assert + var output0 = (GH_String)ComponentTestHelper.GetOutput(comp, 0); // name + var output1 = (GsaAnalysisCaseGoo)ComponentTestHelper.GetOutput(comp, 1); // cases + var output2 = (GH_String)ComponentTestHelper.GetOutput(comp, 2); // type + var output3 = (GH_Integer)ComponentTestHelper.GetOutput(comp, 3); // task id + + Assert.Equal("Task 1", output0.Value); + Assert.Equal(1, output1.Value.Id); + Assert.Equal("L1", output1.Value.Definition); + Assert.Equal("DL", output1.Value.Name); + Assert.Equal("Static", output2.Value); + Assert.Equal(1, output3.Value); + } + } +} diff --git a/GsaGHTests/3_Components/4_Analysis/CreateAnalysisTaskTests.cs b/GsaGHTests/3_Components/4_Analysis/CreateAnalysisTaskTests.cs index abf11fcbb..b84728d1d 100644 --- a/GsaGHTests/3_Components/4_Analysis/CreateAnalysisTaskTests.cs +++ b/GsaGHTests/3_Components/4_Analysis/CreateAnalysisTaskTests.cs @@ -1,4 +1,6 @@ -using GsaGH.Components; +using System; +using Grasshopper.Kernel; +using GsaGH.Components; using GsaGH.Parameters; using GsaGHTests.Helpers; using OasysGH.Components; @@ -7,29 +9,103 @@ namespace GsaGHTests.Components.Analysis { [Collection("GrasshopperFixture collection")] public class CreateAnalysisTaskTests { - - public static GH_OasysComponent ComponentMother() { + public static GH_OasysDropDownComponent ComponentMother() { var comp = new CreateAnalysisTask(); comp.CreateAttributes(); - ComponentTestHelper.SetInput(comp, "my Task", 0); + ComponentTestHelper.SetInput(comp, 1, 0); + ComponentTestHelper.SetInput(comp, "my Task", 1); var output = (GsaAnalysisCaseGoo)ComponentTestHelper.GetOutput( CreateAnalysisCaseTests.ComponentMother()); - ComponentTestHelper.SetInput(comp, output, 1); + ComponentTestHelper.SetInput(comp, output, 2); return comp; } [Fact] - public void CreateComponentTest() { - GH_OasysComponent comp = ComponentMother(); + public void CreateStaticComponentTest() { + GH_OasysDropDownComponent comp = ComponentMother(); var output = (GsaAnalysisTaskGoo)ComponentTestHelper.GetOutput(comp); - Assert.Equal("my Task", output.Value.Name); - Assert.Equal(AnalysisTaskType.Static, output.Value.Type); + Assert.Equal(1, output.Value.Id); + Assert.Equal("my Task", output.Value.ApiTask.Name); + Assert.Equal((int)AnalysisTaskType.Static, output.Value.ApiTask.Type); Assert.Equal("my Case", output.Value.Cases[0].Name); Assert.Equal("1.4L1 + 0.8L3", output.Value.Cases[0].Definition); } + + [Fact] + public void CreateStaticPDeltaComponentTest1() { + var comp = new CreateAnalysisTask(); + comp.CreateAttributes(); + + comp.SetSelected(0, 1); + ComponentTestHelper.SetInput(comp, 1, 0); + ComponentTestHelper.SetInput(comp, "my Task", 1); + + var output = (GsaAnalysisTaskGoo)ComponentTestHelper.GetOutput(comp); + + Assert.Equal(1, output.Value.Id); + Assert.Equal("my Task", output.Value.ApiTask.Name); + Assert.Equal((int)AnalysisTaskType.StaticPDelta, output.Value.ApiTask.Type); + Assert.Equal(GH_RuntimeMessageLevel.Remark, comp.RuntimeMessageLevel); + Assert.Single(comp.RuntimeMessages(GH_RuntimeMessageLevel.Remark)); + } + + [Fact] + public void CreateStaticPDeltaComponentTest2() { + var comp = new CreateAnalysisTask(); + comp.CreateAttributes(); + + comp.SetSelected(0, 1); + comp.SetSelected(1, 1); + ComponentTestHelper.SetInput(comp, 1, 0); + ComponentTestHelper.SetInput(comp, "my Task", 1); + ComponentTestHelper.SetInput(comp, "1.2L1 + 1.2L2", 2); + + var output = (GsaAnalysisTaskGoo)ComponentTestHelper.GetOutput(comp); + + Assert.Equal(1, output.Value.Id); + Assert.Equal("my Task", output.Value.ApiTask.Name); + Assert.Equal((int)AnalysisTaskType.StaticPDelta, output.Value.ApiTask.Type); + Assert.Equal(GH_RuntimeMessageLevel.Remark, comp.RuntimeMessageLevel); + Assert.Single(comp.RuntimeMessages(GH_RuntimeMessageLevel.Remark)); + } + + [Fact] + public void CreateStaticPDeltaComponentTest3() { + var comp = new CreateAnalysisTask(); + comp.CreateAttributes(); + + comp.SetSelected(0, 1); + comp.SetSelected(1, 2); + ComponentTestHelper.SetInput(comp, 1, 0); + ComponentTestHelper.SetInput(comp, "my Task", 1); + ComponentTestHelper.SetInput(comp, 2, 2); + + var output = (GsaAnalysisTaskGoo)ComponentTestHelper.GetOutput(comp); + + Assert.Equal(1, output.Value.Id); + Assert.Equal("my Task", output.Value.ApiTask.Name); + Assert.Equal((int)AnalysisTaskType.StaticPDelta, output.Value.ApiTask.Type); + Assert.Equal(GH_RuntimeMessageLevel.Remark, comp.RuntimeMessageLevel); + Assert.Single(comp.RuntimeMessages(GH_RuntimeMessageLevel.Remark)); + } + + //[Theory] + //[InlineData(3)] + //[InlineData(8)] + //public void ChangeUnitExceptionsEquationTest(int analysisTaskType) { + // var comp = new CreateFaceLoad(); + // comp.CreateAttributes(); + // comp.SetSelected(0, 3); // Equation + // ComponentTestHelper.SetInput(comp, "All", 1); + // ComponentTestHelper.SetInput(comp, "myLoad", 2); + // ComponentTestHelper.SetInput(comp, "4*x+7*y-z", 7); + // comp.SetSelected(1, i); + // Assert.Throws(() => ComponentTestHelper.GetOutput(comp)); + // Assert.Equal(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error, comp.RuntimeMessageLevel); + //} } } diff --git a/GsaGHTests/3_Components/4_Analysis/EditAnalysisTaskTests.cs b/GsaGHTests/3_Components/4_Analysis/EditAnalysisTaskTests.cs deleted file mode 100644 index e9409c862..000000000 --- a/GsaGHTests/3_Components/4_Analysis/EditAnalysisTaskTests.cs +++ /dev/null @@ -1,63 +0,0 @@ -using Grasshopper.Kernel.Types; -using GsaGH.Components; -using GsaGH.Parameters; -using GsaGHTests.Helper; -using GsaGHTests.Helpers; -using OasysGH.Components; -using Xunit; - -namespace GsaGHTests.Components.Analysis { - [Collection("GrasshopperFixture collection")] - public class EditAnalysisTaskTests { - - public static GH_OasysComponent ComponentMother() { - var comp = new EditAnalysisTask(); - comp.CreateAttributes(); - - var output = (GsaAnalysisTaskGoo)ComponentTestHelper.GetOutput( - CreateAnalysisTaskTests.ComponentMother()); - ComponentTestHelper.SetInput(comp, output); - - return comp; - } - - [Fact] - public void CreateComponentTest() { - GH_OasysComponent comp = ComponentMother(); - - var output = (GsaAnalysisTaskGoo)ComponentTestHelper.GetOutput(comp); - - Assert.Equal("my Task", output.Value.Name); - Assert.Equal(AnalysisTaskType.Static, output.Value.Type); - Assert.Equal("my Case", output.Value.Cases[0].Name); - Assert.Equal("1.4L1 + 0.8L3", output.Value.Cases[0].Definition); - } - - [Fact] - public void GetTaskInfoFromModelTest() { - var getModelAnalysis = new GetModelAnalysis(); - var model = new GsaModel(); - model.ApiModel.Open(GsaFile.SteelDesignSimple); - ComponentTestHelper.SetInput(getModelAnalysis, new GsaModelGoo(model)); - var taskGoo = (GsaAnalysisTaskGoo)ComponentTestHelper.GetOutput(getModelAnalysis); - - var comp = new EditAnalysisTask(); - comp.CreateAttributes(); - ComponentTestHelper.SetInput(comp, taskGoo); - - var output1 = (GsaAnalysisTaskGoo)ComponentTestHelper.GetOutput(comp); - var output2 = (GH_String)ComponentTestHelper.GetOutput(comp, 1); - var output3 = (GsaAnalysisCaseGoo)ComponentTestHelper.GetOutput(comp, 2); - var output4 = (GH_String)ComponentTestHelper.GetOutput(comp, 3); - var output5 = (GH_Integer)ComponentTestHelper.GetOutput(comp, 4); - - Duplicates.AreEqual(taskGoo.Value, output1.Value); - Assert.Equal("Task 1", output2.Value); - Assert.Equal(1, output3.Value.Id); - Assert.Equal("L1", output3.Value.Definition); - Assert.Equal("DL", output3.Value.Name); - Assert.Equal("Static", output4.Value); - Assert.Equal(1, output5.Value); - } - } -} diff --git a/GsaGHTests/3_Components/ComponentsTests.cs b/GsaGHTests/3_Components/ComponentsTests.cs index 21d9a6bfe..9702433ec 100644 --- a/GsaGHTests/3_Components/ComponentsTests.cs +++ b/GsaGHTests/3_Components/ComponentsTests.cs @@ -82,6 +82,7 @@ public class ComponentsTests { [InlineData(typeof(ContourNodeResults), 2)] [InlineData(typeof(ReactionForceDiagrams), 1)] [InlineData(typeof(ResultDiagrams), 2)] + [InlineData(typeof(CreateAnalysisTask_OBSOLETE), 1)] public void WhenInitialiseDropdowns_ThenDropDownItemsCount_ShouldBeValid( Type t, int expectedListCount) { var obj = (GH_OasysDropDownComponent)Activator.CreateInstance(t); @@ -135,7 +136,7 @@ public class ComponentsTests { [InlineData(typeof(LoadProperties), "kN", "kipf")] // Analysis [InlineData(typeof(AnalyseModel), "m", "ft")] - [InlineData(typeof(CreateAnalysisTask), "Static", "Static")] + [InlineData(typeof(CreateAnalysisTask_OBSOLETE), "Static", "Static")] // Results [InlineData(typeof(BeamDisplacements), "All", "Min |R|")] [InlineData(typeof(BeamForcesAndMoments), "All", "Min |Myz|")] diff --git a/GsaGHTests/3_Components/GH_OasysComponentTest.cs b/GsaGHTests/3_Components/GH_OasysComponentTest.cs index c82621f1e..a55191e3d 100644 --- a/GsaGHTests/3_Components/GH_OasysComponentTest.cs +++ b/GsaGHTests/3_Components/GH_OasysComponentTest.cs @@ -99,7 +99,7 @@ public class GH_OasysComponentTests { [InlineData(typeof(CreateAnalysisCase))] [InlineData(typeof(CreateAnalysisTask))] [InlineData(typeof(CreateCombinationCase))] - [InlineData(typeof(EditAnalysisTask))] + [InlineData(typeof(AnalysisTaskInfo))] [InlineData(typeof(CreateSteelSectionPool))] [InlineData(typeof(SteelSectionPoolNames))] [InlineData(typeof(CreateSteelDesignTask))] @@ -145,6 +145,7 @@ public class GH_OasysComponentTests { // 99_Obsolete [InlineData(typeof(GlobalPerformanceResults_OBSOLETE), true)] [InlineData(typeof(GetModelProperties_OBSOLETE), true)] + [InlineData(typeof(CreateAnalysisTask_OBSOLETE), true)] public void GH_OasysComponentTest(Type t, bool obsolete = false) { var comp = (GH_OasysComponent)Activator.CreateInstance(t); Assert.NotNull(comp.Icon_24x24); diff --git a/GsaGHTests/3_Components/Obsolete/CreateAnalysisTaskTests_OBSOLETE.cs b/GsaGHTests/3_Components/Obsolete/CreateAnalysisTaskTests_OBSOLETE.cs new file mode 100644 index 000000000..ace25ffd1 --- /dev/null +++ b/GsaGHTests/3_Components/Obsolete/CreateAnalysisTaskTests_OBSOLETE.cs @@ -0,0 +1,35 @@ +using GsaGH.Components; +using GsaGH.Parameters; +using GsaGHTests.Helpers; +using OasysGH.Components; +using Xunit; + +namespace GsaGHTests.Components.Analysis { + [Collection("GrasshopperFixture collection")] + public class CreateAnalysisTaskTests_OBSOLETE { + + public static GH_OasysComponent ComponentMother() { + var comp = new CreateAnalysisTask_OBSOLETE(); + comp.CreateAttributes(); + + ComponentTestHelper.SetInput(comp, "my Task", 0); + var output = (GsaAnalysisCaseGoo)ComponentTestHelper.GetOutput( + CreateAnalysisCaseTests.ComponentMother()); + ComponentTestHelper.SetInput(comp, output, 1); + + return comp; + } + + [Fact] + public void CreateComponentTest() { + GH_OasysComponent comp = ComponentMother(); + + var output = (GsaAnalysisTaskGoo)ComponentTestHelper.GetOutput(comp); + + Assert.Equal("my Task", output.Value.ApiTask.Name); + Assert.Equal((int)AnalysisTaskType.Static, output.Value.ApiTask.Type); + Assert.Equal("my Case", output.Value.Cases[0].Name); + Assert.Equal("1.4L1 + 0.8L3", output.Value.Cases[0].Definition); + } + } +} diff --git a/GsaGHTests/4_CustomUIComponents/DropDownComponentTests.cs b/GsaGHTests/4_CustomUIComponents/DropDownComponentTests.cs index 792ea7eda..0e75df2b1 100644 --- a/GsaGHTests/4_CustomUIComponents/DropDownComponentTests.cs +++ b/GsaGHTests/4_CustomUIComponents/DropDownComponentTests.cs @@ -85,6 +85,7 @@ public class DropDownComponentTests { [InlineData(typeof(LoadDiagrams), true)] [InlineData(typeof(ReactionForceDiagrams))] [InlineData(typeof(ResultDiagrams))] + [InlineData(typeof(CreateAnalysisTask_OBSOLETE))] public void ToggleDropDownsTest(Type t, bool ignoreSpacerDescriptionCount = false) { var comp = (GH_OasysDropDownComponent)Activator.CreateInstance(t); OasysDropDownComponentTestHelper.ChangeDropDownTest(comp, ignoreSpacerDescriptionCount); diff --git a/GsaGHTests/Helpers/Assemble/AssembleModelTestsLoads.cs b/GsaGHTests/Helpers/Assemble/AssembleModelTestsLoads.cs index dc51fa754..863bb283b 100644 --- a/GsaGHTests/Helpers/Assemble/AssembleModelTestsLoads.cs +++ b/GsaGHTests/Helpers/Assemble/AssembleModelTestsLoads.cs @@ -2,6 +2,7 @@ using GsaGH.Parameters; using GsaGHTests.Helper; using GsaGHTests.Model; +using OasysGH.Components; using Xunit; using LoadCaseType = GsaGH.Parameters.LoadCaseType; @@ -216,7 +217,7 @@ public partial class AssembleModelTests { var steelExample = new GsaModel(); steelExample.ApiModel.Open(GsaFile.SteelDesignSimple); - OasysGH.Components.GH_OasysDropDownComponent assemblyComponent = CreateModelTest.CreateModelFromModels(new List() { + GH_OasysDropDownComponent assemblyComponent = CreateModelTest.CreateModelFromModels(new List() { new GsaModelGoo(steelExample), loadModelGoo, }); diff --git a/IntegrationTests/2_Parameters/4_Analysis/AnalysisTaskAndCaseTest.cs b/IntegrationTests/2_Parameters/4_Analysis/AnalysisTaskAndCaseTest.cs index 392509eae..d1af437c1 100644 --- a/IntegrationTests/2_Parameters/4_Analysis/AnalysisTaskAndCaseTest.cs +++ b/IntegrationTests/2_Parameters/4_Analysis/AnalysisTaskAndCaseTest.cs @@ -1,134 +1,128 @@ -using System.Diagnostics.CodeAnalysis; -using System.IO; +using System.IO; using System.Reflection; using Grasshopper.Kernel; using Grasshopper.Kernel.Types; -using GsaGH.Parameters; using Xunit; namespace IntegrationTests.Parameters { [Collection("GrasshopperFixture collection")] - public class GetCreateAnalysisTaskAndCaseTest { + public class AnalysisTaskAndCaseTest { public static GH_Document Document => document ?? (document = OpenDocument()); private static GH_Document document = null; [Fact] - public void NewCaseDescriptionsTest() { + public void AnalysisTaskNameTest() { IGH_Param param = TestHelper(MethodBase.GetCurrentMethod() .Name.Replace("Test", string.Empty)); - var output1 = (GH_String)param.VolatileData.get_Branch(0)[0]; - var output2 = (GH_String)param.VolatileData.get_Branch(0)[1]; + var output0 = (GH_String)param.VolatileData.get_Branch(0)[0]; - Assert.Equal("1.5L2", output1.Value); - Assert.Equal("0.9L1", output2.Value); + Assert.Equal("Task 1", output0.Value); } [Fact] - public void NewCaseIDsTest() { + public void AnalysisTaskDescriptionsTest() { IGH_Param param = TestHelper(MethodBase.GetCurrentMethod() .Name.Replace("Test", string.Empty)); - var output1 = (GH_Integer)param.VolatileData.get_Branch(0)[0]; - var output2 = (GH_Integer)param.VolatileData.get_Branch(0)[1]; + var output0 = (GH_String)param.VolatileData.get_Branch(0)[0]; + var output1 = (GH_String)param.VolatileData.get_Branch(0)[1]; - Assert.Equal(0, output1.Value); - Assert.Equal(0, output2.Value); + Assert.Equal("GSA AnalysisCase (ID:1 'DL' L1)", output0.Value); + Assert.Equal("GSA AnalysisCase (ID:2 'LL' L2)", output1.Value); } [Fact] - public void NewCaseNamesTest() { + public void AnalysisTaskTypeTest() { IGH_Param param = TestHelper(MethodBase.GetCurrentMethod() .Name.Replace("Test", string.Empty)); - var output1 = (GH_String)param.VolatileData.get_Branch(0)[0]; - var output2 = (GH_String)param.VolatileData.get_Branch(0)[1]; + var output0 = (GH_String)param.VolatileData.get_Branch(0)[0]; - Assert.Equal("acase1", output1.Value); - Assert.Equal("acase2", output2.Value); + Assert.Equal("Static", output0.Value); } [Fact] - public void NoRuntimeErrorTest() { - Helper.TestNoRuntimeMessagesInDocument(Document, GH_RuntimeMessageLevel.Error); - } - - [Fact] - public void OriginalCaseDescriptionsTest() { + public void AnalysisTaskIdTest() { IGH_Param param = TestHelper(MethodBase.GetCurrentMethod() .Name.Replace("Test", string.Empty)); - var output1 = (GH_String)param.VolatileData.get_Branch(0)[0]; - var output2 = (GH_String)param.VolatileData.get_Branch(0)[1]; + var output0 = (GH_Integer)param.VolatileData.get_Branch(0)[0]; + + Assert.Equal(1, output0.Value); + } - Assert.Equal("L1", output1.Value); - Assert.Equal("L2", output2.Value); + [Fact] + public void NoRuntimeErrorTest() { + Helper.TestNoRuntimeMessagesInDocument(Document, GH_RuntimeMessageLevel.Error); } [Fact] - public void OriginalCaseIDsTest() { + public void AnalysisCaseNameTest() { IGH_Param param = TestHelper(MethodBase.GetCurrentMethod() .Name.Replace("Test", string.Empty)); - var output1 = (GH_Integer)param.VolatileData.get_Branch(0)[0]; - var output2 = (GH_Integer)param.VolatileData.get_Branch(0)[1]; - - Assert.Equal(1, output1.Value); - Assert.Equal(2, output2.Value); + var output0 = (GH_String)param.VolatileData.get_Branch(0)[0]; + var output1 = (GH_String)param.VolatileData.get_Branch(0)[1]; + var output2 = (GH_String)param.VolatileData.get_Branch(0)[2]; + var output3 = (GH_String)param.VolatileData.get_Branch(0)[3]; + + Assert.Equal("DL", output0.Value); + Assert.Equal("LL", output1.Value); + Assert.Equal("DL", output2.Value); + Assert.Equal("LL", output3.Value); } [Fact] - public void OriginalCaseNamesTest() { + public void AnalysisCaseDescriptionTest() { IGH_Param param = TestHelper(MethodBase.GetCurrentMethod() .Name.Replace("Test", string.Empty)); - var output1 = (GH_String)param.VolatileData.get_Branch(0)[0]; - var output2 = (GH_String)param.VolatileData.get_Branch(0)[1]; - - Assert.Equal("DL", output1.Value); - Assert.Equal("LL", output2.Value); + var output0 = (GH_String)param.VolatileData.get_Branch(0)[0]; + var output1 = (GH_String)param.VolatileData.get_Branch(0)[1]; + var output2 = (GH_String)param.VolatileData.get_Branch(0)[2]; + var output3 = (GH_String)param.VolatileData.get_Branch(0)[3]; + + Assert.Equal("L1", output0.Value); + Assert.Equal("L2", output1.Value); + Assert.Equal("L1", output2.Value); + Assert.Equal("L2", output3.Value); } [Fact] - [SuppressMessage("ReSharper", "InconsistentNaming")] - public void OriginalTaskIDTest() { + public void AnalysisCaseIdTest() { IGH_Param param = TestHelper(MethodBase.GetCurrentMethod() .Name.Replace("Test", string.Empty)); - var output = (GH_Integer)param.VolatileData.get_Branch(0)[0]; - int gsaghobject = output.Value; - - Assert.Equal(1, gsaghobject); + var output0 = (GH_Integer)param.VolatileData.get_Branch(0)[0]; + var output1 = (GH_Integer)param.VolatileData.get_Branch(0)[1]; + var output2 = (GH_Integer)param.VolatileData.get_Branch(0)[2]; + var output3 = (GH_Integer)param.VolatileData.get_Branch(0)[3]; + + Assert.Equal(1, output0.Value); + Assert.Equal(2, output1.Value); + Assert.Equal(1, output2.Value); + Assert.Equal(2, output3.Value); } [Fact] - public void OriginalTaskNameTest() { + public void CombinationCaseIdTest() { IGH_Param param = TestHelper(MethodBase.GetCurrentMethod() .Name.Replace("Test", string.Empty)); - var output = (GH_String)param.VolatileData.get_Branch(0)[0]; - string gsaghobject = output.Value; + var output0 = (GH_Integer)param.VolatileData.get_Branch(0)[0]; - Assert.Equal("Task 1", gsaghobject); + Assert.Equal(1, output0.Value); } [Fact] - public void OriginalTaskTest() { + public void CombinationCaseNameTest() { IGH_Param param = TestHelper(MethodBase.GetCurrentMethod() .Name.Replace("Test", string.Empty)); - var output = (GsaAnalysisTaskGoo)param.VolatileData.get_Branch(0)[0]; - GsaAnalysisTask gsaghobject = output.Value; - - Assert.Equal("Task 1", gsaghobject.Name); - Assert.Equal(1, gsaghobject.Id); - Assert.Equal(2, gsaghobject.Cases.Count); - Assert.Equal("DL", gsaghobject.Cases[0].Name); - Assert.Equal("LL", gsaghobject.Cases[1].Name); - Assert.Equal("L1", gsaghobject.Cases[0].Definition); - Assert.Equal("L2", gsaghobject.Cases[1].Definition); - Assert.Equal(AnalysisTaskType.Static, gsaghobject.Type); + var output0 = (GH_String)param.VolatileData.get_Branch(0)[0]; + + Assert.Equal("ULS", output0.Value); } [Fact] - public void OriginalTaskTypeTest() { + public void CombinationCaseDescriptionTest() { IGH_Param param = TestHelper(MethodBase.GetCurrentMethod() .Name.Replace("Test", string.Empty)); - var output = (GH_String)param.VolatileData.get_Branch(0)[0]; - string gsaghobject = output.Value; + var output0 = (GH_String)param.VolatileData.get_Branch(0)[0]; - Assert.Equal("Static", gsaghobject); + Assert.Equal("1.4A1 + 1.6A2", output0.Value); } private static GH_Document OpenDocument() {