Skip to content

Commit

Permalink
Alt_PCE: implement 2 missing functions; update changelog.
Browse files Browse the repository at this point in the history
  • Loading branch information
PMeira committed Feb 17, 2024
1 parent 60eba80 commit 8b3da5b
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Since 2019-03-05, the `dss_capi` repository contains all the Pascal code used to

See [the changelog](https://github.com/dss-extensions/dss_capi/blob/master/docs/changelog.md) for a detailed list.

- 2024-02-16 / version 0.14.1: Incremental updates and fixes, especially in the alternative API.
- 2024-02-09 / version 0.14.0: Lots of changes and bugfixes, see the changelog.
- 2023-06-27 / version 0.13.4: Bugfix release (CapControl), incremental improvements. See the changelog or release page for details.
- 2023-06-11 / version 0.13.3: Bugfix release for some components (notably Capacitor, Reactor, UPFC).
Expand Down
10 changes: 10 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions include/dss_capi.h
Original file line number Diff line number Diff line change
Expand Up @@ -7744,6 +7744,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);
Expand Down
33 changes: 33 additions & 0 deletions src/CAPI/CAPI_Alt.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/dss_capi.lpr
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 8b3da5b

Please sign in to comment.