Add Force DTOs
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
{
|
||||
public enum CalcTerms
|
||||
{
|
||||
ShortTerm,
|
||||
LongTerm,
|
||||
ShortTerm = 1,
|
||||
LongTerm = 2,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -9,11 +10,22 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
{
|
||||
public class CheckConvertLogic<T, V> : ICheckLogic
|
||||
where T : ISaveable
|
||||
public class CheckConvertLogic<T, V> : ICheckConvertLogic<T, V> where T : ISaveable
|
||||
where V : ISaveable
|
||||
{
|
||||
private string checkResult;
|
||||
|
||||
public CheckConvertLogic(IConvertStrategy<T, V> source)
|
||||
{
|
||||
ConvertStrategy = source;
|
||||
TraceLogger = source.TraceLogger;
|
||||
}
|
||||
|
||||
public CheckConvertLogic()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public IConvertStrategy<T, V> ConvertStrategy { get; set; }
|
||||
|
||||
public string CheckResult => checkResult;
|
||||
|
||||
@@ -18,9 +18,20 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
public IConvertStrategy<T,V> ConvertStrategy { get; set; }
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
|
||||
public DictionaryConvertStrategy(IBaseConvertStrategy baseConvertStrategy, IConvertStrategy<T, V> convertStrategy)
|
||||
{
|
||||
ReferenceDictionary = baseConvertStrategy.ReferenceDictionary;
|
||||
TraceLogger = baseConvertStrategy.TraceLogger;
|
||||
ConvertStrategy = convertStrategy;
|
||||
}
|
||||
public DictionaryConvertStrategy()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public T Convert(V source)
|
||||
{
|
||||
ICheckInputData();
|
||||
CheckInputData();
|
||||
T val;
|
||||
var key = (source.Id, typeof(T));
|
||||
if (ReferenceDictionary.ContainsKey(key))
|
||||
@@ -38,7 +49,7 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
}
|
||||
return val;
|
||||
}
|
||||
private void ICheckInputData()
|
||||
private void CheckInputData()
|
||||
{
|
||||
if(ReferenceDictionary is null)
|
||||
{
|
||||
@@ -47,6 +58,6 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
throw new StructureHelperException(errorString);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
using StructureHelperCommon.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
{
|
||||
public interface IBaseConvertStrategy
|
||||
{
|
||||
Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
IShiftTraceLogger TraceLogger { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using StructureHelperCommon.Models;
|
||||
|
||||
namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
{
|
||||
public interface ICheckConvertLogic<T, V> : ICheckLogic
|
||||
where T : ISaveable
|
||||
where V : ISaveable
|
||||
{
|
||||
IConvertStrategy<T, V> ConvertStrategy { get; set; }
|
||||
IShiftTraceLogger? TraceLogger { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -7,12 +7,10 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
{
|
||||
public interface IConvertStrategy<T,V>
|
||||
public interface IConvertStrategy<T,V> : IBaseConvertStrategy
|
||||
where T :ISaveable
|
||||
where V :ISaveable
|
||||
{
|
||||
Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
IShiftTraceLogger TraceLogger { get; set; }
|
||||
T Convert(V source);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,33 @@
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces.Logics;
|
||||
using System;
|
||||
|
||||
namespace StructureHelperCommon.Models.Forces
|
||||
{
|
||||
public class DesignForceTuple : IDesignForceTuple
|
||||
{
|
||||
private IUpdateStrategy<IDesignForceTuple> updateStrategy = new DesignForceTupleUpdateStrategy();
|
||||
public Guid Id { get; }
|
||||
|
||||
|
||||
public LimitStates LimitState { get; set; }
|
||||
public CalcTerms CalcTerm { get; set; }
|
||||
public IForceTuple ForceTuple { get; set; }
|
||||
public IForceTuple ForceTuple { get; set; } = new ForceTuple();
|
||||
|
||||
public DesignForceTuple(LimitStates limitState, CalcTerms calcTerm) : this()
|
||||
public DesignForceTuple(Guid id)
|
||||
{
|
||||
LimitState = limitState;
|
||||
CalcTerm = calcTerm;
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public DesignForceTuple()
|
||||
public DesignForceTuple() : this (Guid.NewGuid())
|
||||
{
|
||||
ForceTuple = new ForceTuple();
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
var newTuple = new DesignForceTuple(this.LimitState, this.CalcTerm);
|
||||
newTuple.ForceTuple = this.ForceTuple.Clone() as ForceTuple;
|
||||
var newTuple = new DesignForceTuple();
|
||||
updateStrategy.Update(newTuple, this);
|
||||
return newTuple;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,11 +15,11 @@ namespace StructureHelperCommon.Models.Forces
|
||||
{
|
||||
if (forceType == ForceType.Force_zero)
|
||||
{
|
||||
return new DesignForceTuple(limitState, calcTerm);
|
||||
return new DesignForceTuple() { LimitState = limitState, CalcTerm = calcTerm };
|
||||
}
|
||||
else if (forceType == ForceType.Force_Mx50My50Nz100)
|
||||
{
|
||||
var tuple = new DesignForceTuple(limitState, calcTerm);
|
||||
var tuple = new DesignForceTuple() { LimitState = limitState, CalcTerm = calcTerm };
|
||||
var forceTuple = tuple.ForceTuple;
|
||||
forceTuple.Mx = -50e3d;
|
||||
forceTuple.My = -50e3d;
|
||||
|
||||
@@ -32,10 +32,26 @@ namespace StructureHelperCommon.Models.Forces
|
||||
ForcePoint = new Point2D() { X = 0, Y = 0 };
|
||||
DesignForces = new List<IDesignForceTuple>
|
||||
{
|
||||
new DesignForceTuple(LimitStates.ULS, CalcTerms.ShortTerm),
|
||||
new DesignForceTuple(LimitStates.ULS, CalcTerms.LongTerm),
|
||||
new DesignForceTuple(LimitStates.SLS, CalcTerms.ShortTerm),
|
||||
new DesignForceTuple(LimitStates.SLS, CalcTerms.LongTerm)
|
||||
new DesignForceTuple()
|
||||
{
|
||||
LimitState = LimitStates.ULS,
|
||||
CalcTerm = CalcTerms.ShortTerm
|
||||
},
|
||||
new DesignForceTuple()
|
||||
{
|
||||
LimitState = LimitStates.ULS,
|
||||
CalcTerm = CalcTerms.LongTerm
|
||||
},
|
||||
new DesignForceTuple()
|
||||
{
|
||||
LimitState = LimitStates.SLS,
|
||||
CalcTerm = CalcTerms.ShortTerm
|
||||
},
|
||||
new DesignForceTuple()
|
||||
{
|
||||
LimitState = LimitStates.SLS,
|
||||
CalcTerm = CalcTerms.LongTerm
|
||||
}
|
||||
};
|
||||
}
|
||||
public ForceCombinationList() : this (Guid.NewGuid()) { }
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services.Forces;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace StructureHelperCommon.Models.Forces
|
||||
@@ -9,6 +10,8 @@ namespace StructureHelperCommon.Models.Forces
|
||||
{
|
||||
private readonly IUpdateStrategy<IForceTuple> updateStrategy = new ForceTupleUpdateStrategy();
|
||||
/// <inheritdoc/>
|
||||
public Guid Id { get; }
|
||||
/// <inheritdoc/>
|
||||
public double Mx { get; set; }
|
||||
/// <inheritdoc/>
|
||||
public double My { get; set; }
|
||||
@@ -21,6 +24,16 @@ namespace StructureHelperCommon.Models.Forces
|
||||
/// <inheritdoc/>
|
||||
public double Mz { get; set; }
|
||||
|
||||
public ForceTuple(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public ForceTuple() : this (Guid.NewGuid())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
Mx = 0d;
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
using System;
|
||||
using System.CodeDom;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
|
||||
namespace StructureHelperCommon.Models.Forces
|
||||
{
|
||||
public interface IDesignForceTuple : ICloneable
|
||||
public interface IDesignForceTuple : ISaveable, ICloneable
|
||||
{
|
||||
LimitStates LimitState { get; set; }
|
||||
CalcTerms CalcTerm { get; set; }
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
using System;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using System;
|
||||
|
||||
namespace StructureHelperCommon.Models.Forces
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface for generic force for beams
|
||||
/// </summary>
|
||||
public interface IForceTuple : ICloneable
|
||||
public interface IForceTuple : ISaveable, ICloneable
|
||||
{
|
||||
/// <summary>
|
||||
/// Bending moment round about x-axis
|
||||
|
||||
@@ -14,9 +14,9 @@ namespace StructureHelperCommon.Models.Forces
|
||||
readonly IUpdateStrategy<IForceAction> forceUpdateStrategy = new ForceActionUpdateStrategy();
|
||||
public void Update(IAction targetObject, IAction sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(targetObject);
|
||||
CheckObject.IsNull(sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
|
||||
CheckObject.CompareTypes(targetObject, sourceObject);
|
||||
targetObject.Name = sourceObject.Name;
|
||||
if (targetObject is IForceAction forceAction)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Forces.Logics
|
||||
{
|
||||
public class DesignForceTupleUpdateStrategy : IUpdateStrategy<IDesignForceTuple>
|
||||
{
|
||||
private IUpdateStrategy<IForceTuple> forceTupleUpdateStrategy;
|
||||
|
||||
public DesignForceTupleUpdateStrategy(IUpdateStrategy<IForceTuple> forceTupleUpdateStrategy)
|
||||
{
|
||||
this.forceTupleUpdateStrategy = forceTupleUpdateStrategy;
|
||||
}
|
||||
|
||||
public DesignForceTupleUpdateStrategy() : this (new ForceTupleUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Update(IDesignForceTuple targetObject, IDesignForceTuple sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(targetObject);
|
||||
CheckObject.IsNull(sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
targetObject.LimitState = sourceObject.LimitState;
|
||||
targetObject.CalcTerm = sourceObject.CalcTerm;
|
||||
if (sourceObject.ForceTuple is not null)
|
||||
{
|
||||
forceTupleUpdateStrategy.Update(targetObject.ForceTuple, sourceObject.ForceTuple);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Forces.Logics
|
||||
{
|
||||
public class ForceActionBaseUpdateStrategy : IUpdateStrategy<IForceAction>
|
||||
{
|
||||
private readonly IUpdateStrategy<IPoint2D> pointStrategy;
|
||||
|
||||
public ForceActionBaseUpdateStrategy(IUpdateStrategy<IPoint2D> pointStrategy)
|
||||
{
|
||||
this.pointStrategy = pointStrategy;
|
||||
}
|
||||
|
||||
public ForceActionBaseUpdateStrategy() : this(new Point2DUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Update(IForceAction targetObject, IForceAction sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(targetObject);
|
||||
CheckObject.IsNull(sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
targetObject.Name = sourceObject.Name;
|
||||
targetObject.SetInGravityCenter = sourceObject.SetInGravityCenter;
|
||||
pointStrategy.Update(targetObject.ForcePoint, sourceObject.ForcePoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,21 +8,45 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Models.Forces.Logics;
|
||||
|
||||
namespace StructureHelperCommon.Models.Forces
|
||||
{
|
||||
public class ForceActionUpdateStrategy : IUpdateStrategy<IForceAction>
|
||||
{
|
||||
private readonly IUpdateStrategy<IPoint2D> pointStrategy = new Point2DUpdateStrategy();
|
||||
private readonly IUpdateStrategy<IDesignForcePair> forcePairUpdateStrategy = new ForcePairUpdateStrategy();
|
||||
private readonly IUpdateStrategy<IForceCombinationByFactor> factorUpdateStrategy = new FactorCombinationUpdateStrategy();
|
||||
private readonly IUpdateStrategy<IForceCombinationList> forceListUpdateStrategy = new ForceCombinationListUpdateStrategy();
|
||||
private readonly IUpdateStrategy<IForceAction> forceActionUpdateStrategy;
|
||||
private readonly IUpdateStrategy<IDesignForcePair> forcePairUpdateStrategy;
|
||||
private readonly IUpdateStrategy<IForceCombinationByFactor> factorUpdateStrategy;
|
||||
private readonly IUpdateStrategy<IForceCombinationList> forceListUpdateStrategy;
|
||||
|
||||
public ForceActionUpdateStrategy(
|
||||
IUpdateStrategy<IForceAction> forceActionUpdateStrategy,
|
||||
IUpdateStrategy<IDesignForcePair> forcePairUpdateStrategy,
|
||||
IUpdateStrategy<IForceCombinationByFactor> factorUpdateStrategy,
|
||||
IUpdateStrategy<IForceCombinationList> forceListUpdateStrategy)
|
||||
{
|
||||
this.forceActionUpdateStrategy = forceActionUpdateStrategy;
|
||||
this.forcePairUpdateStrategy = forcePairUpdateStrategy;
|
||||
this.factorUpdateStrategy = factorUpdateStrategy;
|
||||
this.forceListUpdateStrategy = forceListUpdateStrategy;
|
||||
}
|
||||
|
||||
public ForceActionUpdateStrategy() : this(
|
||||
new ForceActionBaseUpdateStrategy(),
|
||||
new ForcePairUpdateStrategy(),
|
||||
new ForceCombinationByFactorUpdateStrategy(),
|
||||
new ForceCombinationListUpdateStrategy()
|
||||
)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Update(IForceAction targetObject, IForceAction sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(targetObject);
|
||||
CheckObject.IsNull(sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
CheckObject.CompareTypes(targetObject, sourceObject);
|
||||
targetObject.SetInGravityCenter = sourceObject.SetInGravityCenter;
|
||||
pointStrategy.Update(targetObject.ForcePoint, sourceObject.ForcePoint);
|
||||
forceActionUpdateStrategy.Update(targetObject, sourceObject);
|
||||
UpdateChildProperties(targetObject, sourceObject);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,20 +8,21 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Forces
|
||||
{
|
||||
public class FactorCombinationUpdateStrategy : IUpdateStrategy<IForceCombinationByFactor>
|
||||
public class ForceCombinationByFactorUpdateStrategy : IUpdateStrategy<IForceCombinationByFactor>
|
||||
{
|
||||
private IUpdateStrategy<IForceTuple> tupleUpdateStrategy;
|
||||
public FactorCombinationUpdateStrategy(IUpdateStrategy<IForceTuple> tupleUpdateStrategy)
|
||||
public ForceCombinationByFactorUpdateStrategy(IUpdateStrategy<IForceTuple> tupleUpdateStrategy)
|
||||
{
|
||||
this.tupleUpdateStrategy = tupleUpdateStrategy;
|
||||
}
|
||||
public FactorCombinationUpdateStrategy() : this(new ForceTupleUpdateStrategy())
|
||||
public ForceCombinationByFactorUpdateStrategy() : this(new ForceTupleUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
public void Update(IForceCombinationByFactor targetObject, IForceCombinationByFactor sourceObject)
|
||||
{
|
||||
CheckObject.CompareTypes(targetObject, sourceObject);
|
||||
CheckObject.IsNull(targetObject);
|
||||
CheckObject.IsNull(sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
tupleUpdateStrategy.Update(targetObject.FullSLSForces, sourceObject.FullSLSForces);
|
||||
targetObject.ULSFactor = sourceObject.ULSFactor;
|
||||
@@ -1,4 +1,5 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces.Logics;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -10,10 +11,22 @@ namespace StructureHelperCommon.Models.Forces
|
||||
{
|
||||
public class ForceCombinationListUpdateStrategy : IUpdateStrategy<IForceCombinationList>
|
||||
{
|
||||
private IUpdateStrategy<IDesignForceTuple> designForceTupleUpdateStrategy;
|
||||
|
||||
public ForceCombinationListUpdateStrategy(IUpdateStrategy<IDesignForceTuple> designForceTupleUpdateStrategy)
|
||||
{
|
||||
this.designForceTupleUpdateStrategy = designForceTupleUpdateStrategy;
|
||||
}
|
||||
|
||||
public ForceCombinationListUpdateStrategy() : this (new DesignForceTupleUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Update(IForceCombinationList targetObject, IForceCombinationList sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(targetObject, sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
CheckObject.CompareTypes(targetObject, sourceObject);
|
||||
targetObject.DesignForces.Clear();
|
||||
foreach (var item in sourceObject.DesignForces)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services.Forces;
|
||||
using System;
|
||||
|
||||
namespace StructureHelperCommon.Models.Forces
|
||||
{
|
||||
@@ -8,6 +9,8 @@ namespace StructureHelperCommon.Models.Forces
|
||||
{
|
||||
private readonly IUpdateStrategy<IForceTuple> updateStrategy = new ForceTupleUpdateStrategy();
|
||||
/// <inheritdoc/>
|
||||
public Guid Id { get; }
|
||||
/// <inheritdoc/>
|
||||
public double Mx { get; set; }
|
||||
/// <inheritdoc/>
|
||||
public double My { get; set; }
|
||||
@@ -20,6 +23,16 @@ namespace StructureHelperCommon.Models.Forces
|
||||
/// <inheritdoc/>
|
||||
public double Mz { get; set; }
|
||||
|
||||
public StrainTuple(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public StrainTuple() : this (Guid.NewGuid())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
Mx = 0d;
|
||||
|
||||
Reference in New Issue
Block a user