Skip to content

Commit 8b3da5b

Browse files
committed
Alt_PCE: implement 2 missing functions; update changelog.
1 parent 60eba80 commit 8b3da5b

File tree

5 files changed

+48
-0
lines changed

5 files changed

+48
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Since 2019-03-05, the `dss_capi` repository contains all the Pascal code used to
4646

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

49+
- 2024-02-16 / version 0.14.1: Incremental updates and fixes, especially in the alternative API.
4950
- 2024-02-09 / version 0.14.0: Lots of changes and bugfixes, see the changelog.
5051
- 2023-06-27 / version 0.13.4: Bugfix release (CapControl), incremental improvements. See the changelog or release page for details.
5152
- 2023-06-11 / version 0.13.3: Bugfix release for some components (notably Capacitor, Reactor, UPFC).

docs/changelog.md

+10
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@
1717

1818
# Versions 0.14.x
1919

20+
## Version 0.14.1 (2024-02-16)
21+
22+
Minor release to address issues found through AltDSS-Python. These shouldn't affect software that use only the classic API.
23+
24+
- Alt_PCE: implement two missing functions
25+
- DSSObj, LineGeometry: for the alternative API, add array shortcuts for Wire; use the array shortcuts more.
26+
- `SetterFlags_AllowAllConductors`:
27+
- Update value of `SetterFlags_AllowAllConductors` to `0x40000000` to avoid difficulties in Python.
28+
- Propagate setting when using Obj/Batch APIs; adjust Line.Conductors.
29+
2030
## Version 0.14.0 (2024-02-09)
2131

2232
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.

include/dss_capi.h

+2
Original file line numberDiff line numberDiff line change
@@ -7744,6 +7744,8 @@ extern "C" {
77447744
DSS_CAPI_DLL void Alt_PCE_Get_VariableValues(double** resultPtr, int32_t *resultDims, void* pce);
77457745
DSS_CAPI_DLL void Alt_PCE_Set_VariableValue(void* pce, int32_t varIdx, double value);
77467746
DSS_CAPI_DLL double Alt_PCE_Get_VariableValue(void* pce, int32_t varIdx);
7747+
DSS_CAPI_DLL void Alt_PCE_Set_VariableSValue(void* pce, const char* varName, double value);
7748+
DSS_CAPI_DLL double Alt_PCE_Get_VariableSValue(void* pce, const char* varName);
77477749
DSS_CAPI_DLL const char* Alt_PCE_Get_VariableName(void* pce, int32_t varIdx);
77487750
DSS_CAPI_DLL void* Alt_PCE_Get_EnergyMeter(void* elem);
77497751
DSS_CAPI_DLL const char* Alt_PCE_Get_EnergyMeterName(void* elem);

src/CAPI/CAPI_Alt.pas

+33
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ procedure Alt_PCE_Get_VariableNames(var ResultPtr: PPAnsiChar; ResultCount: PAPI
8484
procedure Alt_PCE_Get_VariableValues(var ResultPtr: PDouble; ResultCount: PAPISize; elem: TPCElement); CDECL;
8585
procedure Alt_PCE_Set_VariableValue(elem: TPCElement; varIdx: Integer; value: Double); CDECL;
8686
function Alt_PCE_Get_VariableValue(elem: TPCElement; varIdx: Integer): Double; CDECL;
87+
procedure Alt_PCE_Set_VariableSValue(elem: TPCElement; varName: PAnsiChar; value: Double); CDECL;
88+
function Alt_PCE_Get_VariableSValue(elem: TPCElement; varName: PAnsiChar): Double; CDECL;
8789
function Alt_PCE_Get_VariableName(elem: TPCElement; varIdx: Integer): PAnsiChar; CDECL;
8890
function Alt_PCE_Get_EnergyMeter(elem: TPCElement): TDSSObject; CDECL;
8991
function Alt_PCE_Get_EnergyMeterName(elem: TPCElement): PAnsiChar; CDECL;
@@ -1214,6 +1216,37 @@ procedure Alt_PCE_Set_VariableValue(elem: TPCElement; varIdx: Integer; value: Do
12141216
elem.Variable[varIdx] := value;
12151217
end;
12161218
//------------------------------------------------------------------------------
1219+
function Alt_PCE_Get_VariableSValue(elem: TPCElement; varName: PAnsiChar): Double; CDECL;
1220+
var
1221+
sname: String;
1222+
varIdx: Integer;
1223+
begin
1224+
Result := 0;
1225+
sname := varName;
1226+
varIdx := elem.LookupVariable(sname);
1227+
if (varIdx <= 0) or (varIdx > elem.NumVariables) then
1228+
begin
1229+
DoSimpleMsg(elem.DSS, 'Invalid variable name %s for "%s"', [sname, elem.FullName], 100002);
1230+
Exit;
1231+
end;
1232+
Result := elem.Variable[varIdx];
1233+
end;
1234+
//------------------------------------------------------------------------------
1235+
procedure Alt_PCE_Set_VariableSValue(elem: TPCElement; varName: PAnsiChar; value: Double); CDECL;
1236+
var
1237+
sname: String;
1238+
varIdx: Integer;
1239+
begin
1240+
sname := varName;
1241+
varIdx := elem.LookupVariable(sname);
1242+
if (varIdx <= 0) or (varIdx > elem.NumVariables) then
1243+
begin
1244+
DoSimpleMsg(elem.DSS, 'Invalid variable name %s for "%s"', [sname, elem.FullName], 100002);
1245+
Exit;
1246+
end;
1247+
elem.Variable[varIdx] := value;
1248+
end;
1249+
//------------------------------------------------------------------------------
12171250
function Alt_CE_Get_NumPhases(elem: TDSSCktElement): Integer; CDECL;
12181251
begin
12191252
Result := elem.NPhases

src/dss_capi.lpr

+2
Original file line numberDiff line numberDiff line change
@@ -2192,6 +2192,8 @@
21922192
Alt_PCE_Get_VariableName,
21932193
Alt_PCE_Get_VariableValue,
21942194
Alt_PCE_Set_VariableValue,
2195+
Alt_PCE_Get_VariableSValue,
2196+
Alt_PCE_Set_VariableSValue,
21952197
Alt_PDE_Get_AccumulatedL,
21962198
Alt_PDE_Get_EnergyMeter,
21972199
Alt_PDE_Get_EnergyMeterName,

0 commit comments

Comments
 (0)