From bcb60bf0e37592ca0dfd810a297f579fe9577967 Mon Sep 17 00:00:00 2001 From: Paulo Meira <10246101+PMeira@users.noreply.github.com> Date: Fri, 31 Mar 2023 01:56:23 -0300 Subject: [PATCH] dss_capi_lib.cs: Expose the new DSS C-API functions --- src/dss_capi_lib.cs | 60 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 4 deletions(-) diff --git a/src/dss_capi_lib.cs b/src/dss_capi_lib.cs index 6811737..dda9922 100644 --- a/src/dss_capi_lib.cs +++ b/src/dss_capi_lib.cs @@ -1,7 +1,7 @@ // dss_sharp: A compatibility layer for DSS C-API that mimics the official OpenDSS COM interface. -// Copyright (c) 2016-2022 Paulo Meira -// Copyright (c) 2018-2022 DSS Extensions contributors +// Copyright (c) 2016-2023 Paulo Meira +// Copyright (c) 2018-2023 DSS Extensions contributors // // See LICENSE for more information. // @@ -18,8 +18,12 @@ namespace native { /// /// The DSS_CAPI static class exposes DSS C-API functions to C#. - /// Some functions are not exposed through the traditional API classes, - /// but advanced users are free to use them. + /// DSS C-API is the library from DSS Extensions that implements the + /// (customized, not supported by EPRI, etc.) OpenDSS engine and wraps + /// it in easily consumable C-compatible functions. + /// + /// Some functions in this class are not exposed through the traditional + /// API classes, but advanced users are free to use them. /// public static class DSS_CAPI { @@ -1119,6 +1123,15 @@ public static void ctx_Capacitors_Set_IsDelta(IntPtr /* void */ ctx, bool Value) public static extern double ctx_CktElement_Get_Variable(IntPtr /* void */ ctx, [param: MarshalAs(UnmanagedType.LPStr)] string MyVarName, ref int Code); #endif + [DllImport("dss_capi", CallingConvention = CallingConvention.Cdecl)] + public static extern int ctx_CktElement_Get_VariableIdx(IntPtr /* void */ ctx); + + [DllImport("dss_capi", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr ctx_CktElement_Get_VariableName(IntPtr /* void */ ctx); + + [DllImport("dss_capi", CallingConvention = CallingConvention.Cdecl)] + public static extern double ctx_CktElement_Get_VariableValue(IntPtr /* void */ ctx); + [DllImport("dss_capi", CallingConvention = CallingConvention.Cdecl)] public static extern double ctx_CktElement_Get_Variablei(IntPtr /* void */ ctx, int Idx, ref int Code); @@ -1184,6 +1197,20 @@ public static void ctx_CktElement_Set_Enabled(IntPtr /* void */ ctx, bool Value) public static extern void ctx_CktElement_Set_Variable(IntPtr /* void */ ctx, [param: MarshalAs(UnmanagedType.LPStr)] string MyVarName, ref int Code, double Value); #endif + [DllImport("dss_capi", CallingConvention = CallingConvention.Cdecl)] + public static extern void ctx_CktElement_Set_VariableIdx(IntPtr /* void */ ctx, int Value); + + #if NETSTANDARD2_1_OR_GREATER + [DllImport("dss_capi", CallingConvention = CallingConvention.Cdecl)] + public static extern void ctx_CktElement_Set_VariableName(IntPtr /* void */ ctx, [param: MarshalAs(UnmanagedType.LPUTF8Str)] string Value); + #else + [DllImport("dss_capi", CallingConvention = CallingConvention.Cdecl)] + public static extern void ctx_CktElement_Set_VariableName(IntPtr /* void */ ctx, [param: MarshalAs(UnmanagedType.LPStr)] string Value); + #endif + + [DllImport("dss_capi", CallingConvention = CallingConvention.Cdecl)] + public static extern void ctx_CktElement_Set_VariableValue(IntPtr /* void */ ctx, double Value); + [DllImport("dss_capi", CallingConvention = CallingConvention.Cdecl)] public static extern void ctx_CktElement_Set_Variablei(IntPtr /* void */ ctx, int Idx, ref int Code, double Value); @@ -1355,12 +1382,18 @@ public static void ctx_CktElement_Set_Enabled(IntPtr /* void */ ctx, bool Value) [DllImport("dss_capi", CallingConvention = CallingConvention.Cdecl)] public static extern void ctx_DSS_Get_Classes_GR(IntPtr /* void */ ctx); + [DllImport("dss_capi", CallingConvention = CallingConvention.Cdecl)] + public static extern uint ctx_DSS_Get_CompatFlags(IntPtr /* void */ ctx); + [DllImport("dss_capi", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr ctx_DSS_Get_DataPath(IntPtr /* void */ ctx); [DllImport("dss_capi", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr ctx_DSS_Get_DefaultEditor(IntPtr /* void */ ctx); + [DllImport("dss_capi", CallingConvention = CallingConvention.Cdecl)] + public static extern ushort ctx_DSS_Get_EnableArrayDimensions(IntPtr /* void */ ctx); + [DllImport("dss_capi", CallingConvention = CallingConvention.Cdecl)] public static extern ushort ctx_DSS_Get_LegacyModels(IntPtr /* void */ ctx); @@ -1444,6 +1477,9 @@ public static void ctx_DSS_Set_COMErrorResults(IntPtr /* void */ ctx, bool Value ctx_DSS_Set_COMErrorResults(ctx, (ushort) (Value ? 1u : 0u)); } + [DllImport("dss_capi", CallingConvention = CallingConvention.Cdecl)] + public static extern void ctx_DSS_Set_CompatFlags(IntPtr /* void */ ctx, uint Value); + #if NETSTANDARD2_1_OR_GREATER [DllImport("dss_capi", CallingConvention = CallingConvention.Cdecl)] public static extern void ctx_DSS_Set_DataPath(IntPtr /* void */ ctx, [param: MarshalAs(UnmanagedType.LPUTF8Str)] string Value); @@ -1452,6 +1488,14 @@ public static void ctx_DSS_Set_COMErrorResults(IntPtr /* void */ ctx, bool Value public static extern void ctx_DSS_Set_DataPath(IntPtr /* void */ ctx, [param: MarshalAs(UnmanagedType.LPStr)] string Value); #endif + [DllImport("dss_capi", CallingConvention = CallingConvention.Cdecl)] + public static extern void ctx_DSS_Set_EnableArrayDimensions(IntPtr /* void */ ctx, ushort Value); + + public static void ctx_DSS_Set_EnableArrayDimensions(IntPtr /* void */ ctx, bool Value) + { + ctx_DSS_Set_EnableArrayDimensions(ctx, (ushort) (Value ? 1u : 0u)); + } + [DllImport("dss_capi", CallingConvention = CallingConvention.Cdecl)] public static extern void ctx_DSS_Set_LegacyModels(IntPtr /* void */ ctx, ushort Value); @@ -1493,6 +1537,14 @@ public static void ctx_DSS_Set_LegacyModels(IntPtr /* void */ ctx, bool Value) [DllImport("dss_capi", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr ctx_Error_Get_NumberPtr(IntPtr /* void */ ctx); + #if NETSTANDARD2_1_OR_GREATER + [DllImport("dss_capi", CallingConvention = CallingConvention.Cdecl)] + public static extern void ctx_Error_Set_Description(IntPtr /* void */ ctx, [param: MarshalAs(UnmanagedType.LPUTF8Str)] string Value); + #else + [DllImport("dss_capi", CallingConvention = CallingConvention.Cdecl)] + public static extern void ctx_Error_Set_Description(IntPtr /* void */ ctx, [param: MarshalAs(UnmanagedType.LPStr)] string Value); + #endif + [DllImport("dss_capi", CallingConvention = CallingConvention.Cdecl)] public static extern void ctx_Error_Set_EarlyAbort(IntPtr /* void */ ctx, ushort Value);