Index: DamTools/LayerOnSlopeTool/trunk/src/Deltares.LayerOnSlopeTool.StiFileCreator/DGSMStabDAMInterface.cs =================================================================== diff -u --- DamTools/LayerOnSlopeTool/trunk/src/Deltares.LayerOnSlopeTool.StiFileCreator/DGSMStabDAMInterface.cs (revision 0) +++ DamTools/LayerOnSlopeTool/trunk/src/Deltares.LayerOnSlopeTool.StiFileCreator/DGSMStabDAMInterface.cs (revision 3100) @@ -0,0 +1,115 @@ +// Copyright (C) Stichting Deltares 2020. All rights reserved. +// +// This file is part of the Dam Engine. +// +// The Dam Engine is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Runtime.InteropServices; +using System.Text; + +namespace Deltares.LayerOnSlopeTool.StiFileCreator +{ + public class DGSMStabDAMInterface : DgsStandardDllInterface + { + + private const string DllFileName = @"DGSMStabDAM.dll"; + + [DllImport(DllFileName)] + static extern int GetDamLicenseType(); + [DllImport(DllFileName)] + static extern int GetDamLiveLicenseType(); + [DllImport(DllFileName)] + static extern int DllGetVersion(out DllVersionInfoStructure dllVersionInfoStructure); + [DllImport(DllFileName)] + static extern string GetDescription(StringBuilder errorMessage, ref int bufferSize); + [DllImport(DllFileName)] + static extern int GetErrorMessage(StringBuilder errorMessage, ref int bufferSize); + [DllImport(DllFileName)] + static extern int CreateMStabProject(string inputXmlString); + [DllImport(DllFileName)] + static extern int ConvertGeometry2DTo1D(string inputXML, StringBuilder outputXML, ref int bufferSize); + [DllImport(DllFileName)] + static extern int CreateGeometry2DData(string inputXML, StringBuilder outputXML, ref int bufferSize); + + /// + /// Gets DllVersion + /// + /// version as string + public new string GetDllVersion() + { + DllVersionInfoStructure dllInfo; + DllGetVersion(out dllInfo); + return dllInfo.DwBuildNumber.ToString(); + } + + /// + /// Create ProjectFile for MStab + /// + /// Error number + public int CreateProjectFile(string inputXmlString) + { + return (CreateMStabProject(inputXmlString)); + } + + /// + /// returns ErrorMessage + /// + /// Error as string + public new string ErrorMessage() + { + const int maxErrorMessageLength = 50; + int errorMessageLength = maxErrorMessageLength; + var errorMessage = new StringBuilder(maxErrorMessageLength); + int returnCode = GetErrorMessage(errorMessage, ref errorMessageLength); + if (returnCode == DllErrorOutputBufferTooSmall) + { + errorMessage = new StringBuilder(errorMessageLength); + returnCode = GetErrorMessage(errorMessage, ref errorMessageLength); + } + if (returnCode == DllErrorNone) + { + return errorMessage.ToString(); + } + else + { + return "Unknow error"; + } + } + + /// converts 2D geometry to 1D + /// + /// + /// + /// Error as integer + public int Geometry2DTo1DConversion(string inputXml, StringBuilder outputXml, ref int bufferSize) + { + return (ConvertGeometry2DTo1D(inputXml, outputXml, ref bufferSize)); + } + + /// Creates the geometry2 d data from geometry2 d. + /// The input XML. + /// The output XML. + /// Size of the buffer. + /// + public int CreateGeometry2DDataFromGeometry2D(string inputXml, StringBuilder outputXml, ref int bufferSize) + { + return (CreateGeometry2DData(inputXml, outputXml, ref bufferSize)); + } + + } +} Index: DamTools/LayerOnSlopeTool/trunk/src/Deltares.LayerOnSlopeTool.StiFileCreator/DGSStandardDLLInterface.cs =================================================================== diff -u --- DamTools/LayerOnSlopeTool/trunk/src/Deltares.LayerOnSlopeTool.StiFileCreator/DGSStandardDLLInterface.cs (revision 0) +++ DamTools/LayerOnSlopeTool/trunk/src/Deltares.LayerOnSlopeTool.StiFileCreator/DGSStandardDLLInterface.cs (revision 3100) @@ -0,0 +1,132 @@ +// Copyright (C) Stichting Deltares 2020. All rights reserved. +// +// This file is part of the Dam Engine. +// +// The Dam Engine is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Runtime.InteropServices; + +namespace Deltares.LayerOnSlopeTool.StiFileCreator + +{ + /// + /// Structure for dll information + /// + [StructLayout(LayoutKind.Sequential, Pack = 1)] + public struct DllVersionInfoStructure + { + /// + /// Size of the structure, in bytes + /// + public uint CbSize; + + /// + /// Major version of the DLL + /// + public uint DwMajorVersion; + + /// + /// Minor version of the DLL + /// + public uint DwMinorVersion; + + /// + /// Build number of the DLL + /// + public uint DwBuildNumber; + + /// + /// Identifies the platform for which the DLL was built + /// + public uint DwPlatformID; + } + + /// + /// The standard DLL interface for DGS. + /// + public class DgsStandardDllInterface + { + /// + /// No Licence error + /// + public const int DllUErrorNoLicense = 1; + + /// + /// User has aborted error + /// + public const int DllErrorUserAborted = 2; + + /// + /// Non compliant xml error + /// + public const int DllErrorNonCompliantXml = 3; + + /// + /// Invalid input data error + /// + public const int DllErrorInvalidInputData = 4; + + /// + /// Handled fatal error + /// + public const int DllErrorHandledFatal = 5; + + /// + /// Unhandled fatal error + /// + public const int DllErrorUnhandledFatal = 6; + + /// + /// Invalid handle for dll error + /// + public const int DllErrorInvalidHandle = 7; + + /// + /// Output buffer too small error + /// + public const int DllErrorOutputBufferTooSmall = 8; + + /// + /// Error constants + /// + public static int DllErrorNone = 0; + + /// + /// Used to hold the last error encountered + /// + public static int DllErrorLastErrorCode = 0; + + /// + /// Example! (remove this wrapper if not needed) + /// + /// + public string GetDllVersion() + { + return "To be implemented"; + } + + /// + /// List of errormessages + /// + /// + public string ErrorMessage() + { + return "To be implemented"; + } + } +} \ No newline at end of file Index: DamTools/LayerOnSlopeTool/trunk/src/Deltares.LayerOnSlopeTool.StiFileCreator/Deltares.LayerOnSlopeTool.StiFileCreator.csproj =================================================================== diff -u -r3093 -r3100 --- DamTools/LayerOnSlopeTool/trunk/src/Deltares.LayerOnSlopeTool.StiFileCreator/Deltares.LayerOnSlopeTool.StiFileCreator.csproj (.../Deltares.LayerOnSlopeTool.StiFileCreator.csproj) (revision 3093) +++ DamTools/LayerOnSlopeTool/trunk/src/Deltares.LayerOnSlopeTool.StiFileCreator/Deltares.LayerOnSlopeTool.StiFileCreator.csproj (.../Deltares.LayerOnSlopeTool.StiFileCreator.csproj) (revision 3100) @@ -44,6 +44,8 @@ + +