From ff950f7259b567c5cc97e486d3a4177082c5c486 Mon Sep 17 00:00:00 2001 From: Paulo Meira <10246101+PMeira@users.noreply.github.com> Date: Fri, 16 Feb 2024 15:15:37 -0300 Subject: [PATCH] Alt_PCE: implement 2 missing functions; update changelog. --- docs/changelog.md | 10 ++++++++++ include/dss_capi.h | 2 ++ src/CAPI/CAPI_Alt.pas | 33 +++++++++++++++++++++++++++++++++ src/dss_capi.lpr | 2 ++ 4 files changed, 47 insertions(+) diff --git a/docs/changelog.md b/docs/changelog.md index 3a166141f..0723e1388 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -17,6 +17,16 @@ # Versions 0.14.x +## Version 0.14.1 (2024-02-16) + +Minor release to address issues found through AltDSS-Python. These shouldn't affect software that use only the classic API. + +- Alt_PCE: implement two missing functions +- DSSObj, LineGeometry: for the alternative API, add array shortcuts for Wire; use the array shortcuts more. +- `SetterFlags_AllowAllConductors`: + - Update value of `SetterFlags_AllowAllConductors` to `0x40000000` to avoid difficulties in Python. + - Propagate setting when using Obj/Batch APIs; adjust Line.Conductors. + ## Version 0.14.0 (2024-02-09) Starting on this version, we will call DSS C-API and related projects AltDSS, an alternative implementation of OpenDSS, to make it more clear that this is not supported by EPRI and many extra features are not present in the official OpenDSS. Watch the DSS-Extensions org on GitHub for more announcements soon, including some support for the official implementation (still Windows-only at the moment). The name change **does not** mean compatibility or other aspects are expected to change, the project will still follow the basic guidelines of compatibility that have been followed since 2018. diff --git a/include/dss_capi.h b/include/dss_capi.h index cc6e10a53..f0b952d82 100644 --- a/include/dss_capi.h +++ b/include/dss_capi.h @@ -7758,6 +7758,8 @@ extern "C" { DSS_CAPI_DLL void Alt_PCE_Get_VariableValues(double** resultPtr, int32_t *resultDims, void* pce); DSS_CAPI_DLL void Alt_PCE_Set_VariableValue(void* pce, int32_t varIdx, double value); DSS_CAPI_DLL double Alt_PCE_Get_VariableValue(void* pce, int32_t varIdx); + DSS_CAPI_DLL void Alt_PCE_Set_VariableSValue(void* pce, const char* varName, double value); + DSS_CAPI_DLL double Alt_PCE_Get_VariableSValue(void* pce, const char* varName); DSS_CAPI_DLL const char* Alt_PCE_Get_VariableName(void* pce, int32_t varIdx); DSS_CAPI_DLL void* Alt_PCE_Get_EnergyMeter(void* elem); DSS_CAPI_DLL const char* Alt_PCE_Get_EnergyMeterName(void* elem); diff --git a/src/CAPI/CAPI_Alt.pas b/src/CAPI/CAPI_Alt.pas index 5520e7655..710d2dfe7 100644 --- a/src/CAPI/CAPI_Alt.pas +++ b/src/CAPI/CAPI_Alt.pas @@ -84,6 +84,8 @@ procedure Alt_PCE_Get_VariableNames(var ResultPtr: PPAnsiChar; ResultCount: PAPI procedure Alt_PCE_Get_VariableValues(var ResultPtr: PDouble; ResultCount: PAPISize; elem: TPCElement); CDECL; procedure Alt_PCE_Set_VariableValue(elem: TPCElement; varIdx: Integer; value: Double); CDECL; function Alt_PCE_Get_VariableValue(elem: TPCElement; varIdx: Integer): Double; CDECL; +procedure Alt_PCE_Set_VariableSValue(elem: TPCElement; varName: PAnsiChar; value: Double); CDECL; +function Alt_PCE_Get_VariableSValue(elem: TPCElement; varName: PAnsiChar): Double; CDECL; function Alt_PCE_Get_VariableName(elem: TPCElement; varIdx: Integer): PAnsiChar; CDECL; function Alt_PCE_Get_EnergyMeter(elem: TPCElement): TDSSObject; CDECL; function Alt_PCE_Get_EnergyMeterName(elem: TPCElement): PAnsiChar; CDECL; @@ -1214,6 +1216,37 @@ procedure Alt_PCE_Set_VariableValue(elem: TPCElement; varIdx: Integer; value: Do elem.Variable[varIdx] := value; end; //------------------------------------------------------------------------------ +function Alt_PCE_Get_VariableSValue(elem: TPCElement; varName: PAnsiChar): Double; CDECL; +var + sname: String; + varIdx: Integer; +begin + Result := 0; + sname := varName; + varIdx := elem.LookupVariable(sname); + if (varIdx <= 0) or (varIdx > elem.NumVariables) then + begin + DoSimpleMsg(elem.DSS, 'Invalid variable name %s for "%s"', [sname, elem.FullName], 100002); + Exit; + end; + Result := elem.Variable[varIdx]; +end; +//------------------------------------------------------------------------------ +procedure Alt_PCE_Set_VariableSValue(elem: TPCElement; varName: PAnsiChar; value: Double); CDECL; +var + sname: String; + varIdx: Integer; +begin + sname := varName; + varIdx := elem.LookupVariable(sname); + if (varIdx <= 0) or (varIdx > elem.NumVariables) then + begin + DoSimpleMsg(elem.DSS, 'Invalid variable name %s for "%s"', [sname, elem.FullName], 100002); + Exit; + end; + elem.Variable[varIdx] := value; +end; +//------------------------------------------------------------------------------ function Alt_CE_Get_NumPhases(elem: TDSSCktElement): Integer; CDECL; begin Result := elem.NPhases diff --git a/src/dss_capi.lpr b/src/dss_capi.lpr index 723f4f008..0b7ec8c4c 100644 --- a/src/dss_capi.lpr +++ b/src/dss_capi.lpr @@ -2192,6 +2192,8 @@ Alt_PCE_Get_VariableName, Alt_PCE_Get_VariableValue, Alt_PCE_Set_VariableValue, + Alt_PCE_Get_VariableSValue, + Alt_PCE_Set_VariableSValue, Alt_PDE_Get_AccumulatedL, Alt_PDE_Get_EnergyMeter, Alt_PDE_Get_EnergyMeterName,