using System;
using System.Diagnostics;
using System.Runtime.Serialization;
namespace Deltares.MStab.IO.Classic
{
[Serializable]
public class ClassicSoilException : Exception
{
//
// For guidelines regarding the creation of new exception types, see
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconerrorraisinghandlingguidelines.asp
// and
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp07192001.asp
//
public ClassicSoilException() {}
public ClassicSoilException(string message) : base(message) {}
public ClassicSoilException(string message, Exception inner) : base(message, inner) {}
protected ClassicSoilException(
SerializationInfo info,
StreamingContext context)
: base(info, context) {}
}
///
/// Access parameters from Classic Input files with help of DGSSerializer.dll
///
internal class GetClassicSoil
{
public static void GetClassicSoilList(int handle, ref ClassicSoilFunctionDefinitions.SoilNameList aSoilNameList)
{
var lBuffer = new char[1024];
try
{
if (aSoilNameList == null)
{
aSoilNameList = new ClassicSoilFunctionDefinitions.SoilNameList();
aSoilNameList.soilName = new string[ClassicSoilFunctionDefinitions.SoilConstants.maxSoilGroups];
for (int index = 0; index < ClassicSoilFunctionDefinitions.SoilConstants.maxSoilGroups; index++)
{
aSoilNameList.soilName[index] = new String(lBuffer);
}
}
// Todo in DLL : list with soils are not realy ok as "double" used soils are realy doubled which is not supposed to happen.
if (!ClassicSoilFunctionDefinitions.ClassicGetSoilNameList(handle, ref aSoilNameList))
{
throw new ClassicSoilException("Could not get object from ClassicMStab");
}
}
catch (ClassicSoilException e)
{
Debug.Assert(false, e.ToString());
}
}
public static void GetClassicSoilParamValueDouble(int handle, string SoilName, string SoilParam, ref double SoilValue)
{
var lBuffer = new char[1024];
try
{
if (!ClassicSoilFunctionDefinitions.ClassicGetSoilItemByName(handle, SoilName, SoilParam, ref SoilValue))
{
throw new ClassicSoilException("Could not get object from ClassicMStab");
}
}
catch (ClassicSoilException e)
{
Debug.Assert(false, e.ToString());
}
}
public static void GetClassicMStabSigmaTau(int handle, ref ClassicMStabFunctionDefinitions.MStabSigmaTauCurves aSigmaTauCurves)
{
try
{
var lBuffer = new char[1024];
if (aSigmaTauCurves == null)
{
aSigmaTauCurves = new ClassicMStabFunctionDefinitions.MStabSigmaTauCurves();
aSigmaTauCurves.curves = new ClassicMStabFunctionDefinitions.Curves[ClassicMStabFunctionDefinitions.MStabConstants.maxStressTables];
for (int index = 0; index < ClassicMStabFunctionDefinitions.MStabConstants.maxStressTables; index++)
{
aSigmaTauCurves.curves[index].itemName = new string(lBuffer);
}
}
ClassicMStabFunctionDefinitions.ClassicGetSigmaTauCurves(handle, ref aSigmaTauCurves);
}
catch (ClassicSoilException e)
{
Debug.Assert(false, e.ToString());
}
}
///
/// get bond stress diagrams
///
///
///
public static void GetClassicMStabBondStresses(int handle, ref ClassicMStabFunctionDefinitions.MStabBondStressDiagrams bondStressDiagrams)
{
try
{
var lBuffer = new char[1024];
if (bondStressDiagrams == null)
{
bondStressDiagrams = new ClassicMStabFunctionDefinitions.MStabBondStressDiagrams();
bondStressDiagrams.curves = new ClassicMStabFunctionDefinitions.Curves[ClassicMStabFunctionDefinitions.MStabConstants.maxStressTables];
for (int index = 0; index < ClassicMStabFunctionDefinitions.MStabConstants.maxStressTables; index++)
{
bondStressDiagrams.curves[index].itemName = new string(lBuffer);
}
}
ClassicMStabFunctionDefinitions.ClassicGetBondStressDiagrams(handle, ref bondStressDiagrams);
}
catch (ClassicSoilException e)
{
Debug.Assert(false, e.ToString());
}
}
public static void GetClassicSoilResistance(int handle, ref ClassicMStabFunctionDefinitions.MStabSoilResistance soilResistance)
{
ClassicMStabFunctionDefinitions.ClassicGetSoilResistance(handle, ref soilResistance);
}
public static void GetClassicSoilItemString(int handle, string aSoilName, ref ClassicSoilFunctionDefinitions.SoilParamListString aStressNames)
{
try
{
var lBuffer = new char[1024];
if (aStressNames == null)
{
aStressNames = new ClassicSoilFunctionDefinitions.SoilParamListString();
}
aStressNames.StressTableName = new string(lBuffer);
aStressNames.SoilBondStressTableName = new string(lBuffer);
ClassicSoilFunctionDefinitions.ClassicGetSoilItemString(handle, aSoilName, ref aStressNames);
}
catch (ClassicSoilException e)
{
Debug.Assert(false, e.ToString());
}
}
}
}