Skip to content

Commit

Permalink
Merge pull request #78 from arup-group/COMPSGH-150-com-design-sometim…
Browse files Browse the repository at this point in the history
…es-returns

COMPSGH-150-com-design-sometimes-returns
  • Loading branch information
tlmnrnhrdt authored Aug 19, 2022
2 parents 6201ff6 + 6c2b4bf commit 1f76e07
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 37 deletions.
2 changes: 2 additions & 0 deletions Compos/0_File/ComposFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public short CodeSatisfied(string memberName)
/// </returns>
internal short Design()
{
this.Initialise();
short status = 0;
foreach (Member member in this.Members)
{
Expand All @@ -137,6 +138,7 @@ internal short Design()
/// </returns>
public short Design(string memberName)
{
this.Initialise();
return ComposFile.ComposCOM.Design(memberName);
}

Expand Down
1 change: 1 addition & 0 deletions Compos/5_Member/IMember.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public interface IMember

short Analyse();
short CodeSatisfied();
string GetCodeSatisfiedMessage();
float MaxResult(string option, short position);
short MaxResultPosition(string option, short position);
float MinResult(string option, short position);
Expand Down
19 changes: 19 additions & 0 deletions Compos/5_Member/Member.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,25 @@ public short CodeSatisfied()
return FileRegister[this.FileGuid].CodeSatisfied(this.Name);
}

public string GetCodeSatisfiedMessage()
{
int status = this.CodeSatisfied();
switch (status)
{
case 0:
return "all code requirements are met";
case 1:
return "except the natural frequency is lower than that required, other code requirements are met";
case 2:
return "one or more code requirements are not met";
case 3:
return "the given member name is not valid";
case 4:
default:
return "there is no results for the given named member";
}
}

public float MaxResult(string option, short position)
{
return FileRegister[this.FileGuid].MaxResult(this.Name, option, position);
Expand Down
2 changes: 1 addition & 1 deletion ComposGH/Components/2_Studs/1_Primary/CreateStud.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ protected override void SolveInstance(IGH_DataAccess DA)
}

#region Custom UI
private StudSpacingType SpacingType = StudSpacingType.Automatic;
private StudSpacingType SpacingType = StudSpacingType.Min_Num_of_Studs;

internal override void InitialiseDropdowns()
{
Expand Down
22 changes: 3 additions & 19 deletions ComposGH/Components/7_Results/CodeSatisfied.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,10 @@ protected override void SolveInstance(IGH_DataAccess DA)
}
if (member != null)
{
Status = member.CodeSatisfied();
switch (Status)
{
case 0:
this.Message = "all code requirements are met";
break;
case 1:
this.Message = "except the natural frequency is lower than that required, other code requirements are met";
this.Message = member.GetCodeSatisfiedMessage();
this.Status = member.CodeSatisfied();
if(this.Status == 1)
AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "The natural frequency is lower than that required");
break;
case 2:
this.Message = "one or more code requirements are not met";
break;
case 3:
this.Message = "the given member name is not valid";
break;
case 4:
this.Message = "there is no results for the given named member";
break;
}
DA.SetData(0, new GH_Number(Status));
}
}
Expand Down
17 changes: 12 additions & 5 deletions ComposGH/Components/8_Design/1_Primary/DesignMember.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,29 @@ protected override void RegisterOutputParams(GH_OutputParamManager pManager)

protected override void SolveInstance(IGH_DataAccess DA)
{
MemberGoo memGoo = (MemberGoo)GetInput.GenericGoo<MemberGoo>(this, DA, 0);
MemberGoo memGoo = (MemberGoo)GetInput.GenericGoo<MemberGoo>(this, DA, 0);
DesignCriteriaGoo critGoo = (DesignCriteriaGoo)GetInput.GenericGoo<DesignCriteriaGoo>(this, DA, 1);
Message = "";
this.Message = "";
if (memGoo.Value != null)
{
Member designedMember = (Member)memGoo.Value.Duplicate();
designedMember.DesignCriteria = critGoo.Value;
this.Message = designedMember.GetCodeSatisfiedMessage();
if (!designedMember.Design())
{
AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Failed to design member");
return;
}
string[] oldProfile = memGoo.Value.Beam.Sections[0].SectionDescription.Split(' ');
string[] newProfile = designedMember.Beam.Sections[0].SectionDescription.Split(' ');
if (newProfile[2] == oldProfile[2])
{
AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Failed to design member");
return;
}
string[] profile = designedMember.Beam.Sections[0].SectionDescription.Split(' ');
Message = profile[2];
this.Message = newProfile[2];
DA.SetData(0, new MemberGoo(designedMember));
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ public static GH_OasysDropDownComponent CreateStudMother()
public void CreateComponentTest()
{
var comp = CreateStudMother();
comp.SetSelected(0, 0); // change the dropdown to Automatic

StudGoo output = (StudGoo)ComponentTestHelper.GetOutput(comp);

Assert.Equal(StudSpacingType.Automatic, output.Value.StudSpacingType);
Assert.Equal(StudSpacingType.Min_Num_of_Studs, output.Value.StudSpacingType);

StudDimensionsGoo input1 = (StudDimensionsGoo)ComponentTestHelper.GetOutput(CreateStandardStudDimsComponentTests.CreateStandardStudDimsMother());
ComponentTestHelper.SetInput(comp, input1, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,16 @@ public void CreateComponent()

MemberGoo output = (MemberGoo)ComponentTestHelper.GetOutput(comp);

Assert.Single(comp.RuntimeMessages(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error));
//"Failed to design member"
Assert.StartsWith("CAT HE HE220.A", output.Value.Beam.Sections[0].SectionDescription);

//MemberGoo input1 = (MemberGoo)ComponentTestHelper.GetOutput(CreateMemberComponentTests.CreateMemberMother());

//ComposFile composFile = new ComposFile(new List<IMember>() { input1.Value });
MemberGoo input1 = (MemberGoo)ComponentTestHelper.GetOutput(CreateMemberComponentTests.CreateMemberMother());
ComposFile composFile = new ComposFile(new List<IMember>() { input1.Value, output.Value });

//string path = Path.Combine(Environment.CurrentDirectory, "GH-Test-Files");
//Directory.CreateDirectory(path);
//Type myType = comp.GetType();
//string pathFileName = Path.Combine(path, myType.Name) + ".cob";
//composFile.SaveAs(pathFileName);
string path = Path.Combine(Environment.CurrentDirectory, "GH-Test-Files");
Directory.CreateDirectory(path);
Type myType = comp.GetType();
string pathFileName = Path.Combine(path, myType.Name);
Assert.Equal(0, composFile.SaveAs(pathFileName));
}
}
}

0 comments on commit 1f76e07

Please sign in to comment.