Skip to content

Commit

Permalink
Increment version to 0.9.3, based on OpenDSS revision 2136 and includ…
Browse files Browse the repository at this point in the history
…e PM patchset.
  • Loading branch information
PMeira committed Feb 16, 2018
1 parent e406a11 commit 5cc6711
Show file tree
Hide file tree
Showing 18 changed files with 5,134 additions and 81 deletions.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dss_capi: An unofficial C API for EPRI's OpenDSS

If you are looking for the Python bindings, see [dss_python](http://github.com/PMeira/dss_python/).

Version 0.9.2, based on [OpenDSS revision 2134](https://sourceforge.net/p/electricdss/code/2134/tree/).
Version 0.9.3, based on [OpenDSS revision 2136](https://sourceforge.net/p/electricdss/code/2136/tree/).

This is a work-in-progress but it's deemed stable enough to be made public.
*Note that, while the interface with OpenDSS is stable (classic version), the OpenDSS-PM (actor-based parallel machine version) interface was integrated recently and is experimental.*
Expand All @@ -20,10 +20,13 @@ Instead of using extra numeric parameters as in the official DDLL interface, eac

Besides low-level details such as memory management, most of the COM documentation can be used as-is.

A custom patchset to build OpenDSS-PM with FreePascal (as well as port recent features of the Classic version) is maintained in the folder `src/patchset`.

Recent changes
==============
- 2018-02-08: First public release (OpenDSS revision 2123)
- 2018-02-10: Experimental support for OpenDSS-PM (at the moment, a custom patch is provided for FreePascal support) and port COM interface fixes (OpenDSS revision 2134)
- 2018-02-08 / version 0.9.1: First public release (OpenDSS revision 2123)
- 2018-02-12 / version 0.9.2: Experimental support for OpenDSS-PM (at the moment, a custom patch is provided for FreePascal support) and port COM interface fixes (OpenDSS revision 2134)
- 2018-02-16 / version 0.9.3: Integrate COM interface fixes from revision 2136 (`First` `Next` iteration)

Missing features and limitations
================================
Expand All @@ -44,7 +47,7 @@ To build the DLL yourself:

- Get the official OpenDSS source code [for the target revision](https://sourceforge.net/p/electricdss/code/2123/tree/) in the same root folder:
```
svn checkout https://svn.code.sf.net/p/electricdss/code/trunk electricdss -r2134
svn checkout https://svn.code.sf.net/p/electricdss/code/trunk electricdss -r2136
```

- Install the [FreePascal compiler](https://freepascal.org/). If you have the Lazarus IDE installed, you most likely already have the compiler too. Add the folder containing the compiler (`fpc.exe`) to your PATH environment variable.
Expand All @@ -54,10 +57,10 @@ To build the DLL yourself:
git clone https://github.com/PMeira/dss_capi.git
```

- For the OpenDSS revision 2134, apply the patch on `src/r2134.patch` if you're building the OpenDSS-PM version.
- For the OpenDSS revision 2136, apply the patch on `src/r2136.patch` if you're building the OpenDSS-PM version.
```
cd electricdss
svn patch ../dss_capi/src/r2134.patch
svn patch ../dss_capi/src/r2136.patch
```

On Windows
Expand Down
Binary file modified README.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion include/dsspm_capi.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef DSSPM_CAPI_DLL_H
#define DSSPM_CAPI_DLL_H
#define DSSPM_CAPI_VERSION "0.9.2"
#define DSSPM_CAPI_VERSION "0.9.3"
#ifndef DSSPM_CAPI_DLL
//#define DSSPM_CAPI_DLL __declspec(dllimport)
#define DSSPM_CAPI_DLL
Expand Down
4 changes: 2 additions & 2 deletions src/main/CAPI_Reclosers.pas
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ function Reclosers_Get_First():Integer;cdecl;
Repeat
If pElem.Enabled Then Begin
ActiveCircuit.ActiveCktElement := pElem;
Result := 1;
Result := RecloserClass.ElementList.ActiveIndex;
End
Else pElem := RecloserClass.ElementList.Next;
Until (Result = 1) or (pElem = nil);
Until (Result >0) or (pElem = nil);
End;
end;
//------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
From 9b3174d692c9a2f87ad4ff19e2c58d1f7f6857ea Mon Sep 17 00:00:00 2001
From: Paulo Meira <10246101+PMeira@users.noreply.github.com>
Date: Fri, 16 Feb 2018 16:06:38 -0200
Subject: [PATCH] PM to Classic: Add NumTerminals to Capacitor

---
Source/PDElements/Capacitor.pas | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/Source/PDElements/Capacitor.pas b/Source/PDElements/Capacitor.pas
index 5ba88ae..af01111 100644
--- a/Source/PDElements/Capacitor.pas
+++ b/Source/PDElements/Capacitor.pas
@@ -85,6 +85,7 @@ TYPE
Bus2Defined :Boolean;

SpecType :Integer;
+ NumTerm : Integer; // Flag used to indicate The number of terminals

function get_States(Idx: Integer): Integer;
procedure set_States(Idx: Integer; const Value: Integer);
@@ -123,6 +124,8 @@ TYPE
Property NomKV:Double Read kvrating;
Property LastStepInService:Integer Read FLastStepInService Write set_LastStepInService;

+ Property NumTerminals:Integer Read NumTerm; // Property to know if the capacitor has 2 terminals
+
end;

VAR
@@ -341,7 +344,10 @@ BEGIN
CASE ParamPointer OF
0: DoSimpleMsg('Unknown parameter "'+ParamName+'" for Object "Capacitor.'+Name+'"', 450);
1: CapSetbus1(param);
- 2: Setbus(2, param);
+ 2: Begin
+ Setbus(2, param);
+ NumTerm := 2; // Specifies that the capacitor is not connected to ground
+ End;
3:{ Numphases := Parser.IntValue}; // see below
4: InterpretDblArray (Param, FNumSteps, FkvarRating);
5: kvRating := Parser.Dblvalue;
@@ -526,6 +532,7 @@ BEGIN
Bus2Defined := FALSE;

RecalcElementData;
+ NumTerm := 1;

InitPropertyValues(0);
END;
--
2.10.0.windows.1

48 changes: 48 additions & 0 deletions src/patchset/0002-PM-to-Classic-Port-some-memory-checks.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
From 15d2a477a4dcf5024759a1a3101bc2282baf52fb Mon Sep 17 00:00:00 2001
From: Paulo Meira <10246101+PMeira@users.noreply.github.com>
Date: Fri, 16 Feb 2018 16:09:12 -0200
Subject: [PATCH] PM to Classic: Port some memory checks

---
Source/Meters/EnergyMeter.pas | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/Source/Meters/EnergyMeter.pas b/Source/Meters/EnergyMeter.pas
index 12cc190..fd28c88 100644
--- a/Source/Meters/EnergyMeter.pas
+++ b/Source/Meters/EnergyMeter.pas
@@ -2842,6 +2842,7 @@ begin
If (EnergyMeterClass.DI_Verbose) Then Begin

This_Meter_DIFileIsOpen := TRUE;
+ if DI_MHandle <> nil then DI_MHandle.free;
DI_MHandle := Create_Meter_Space('"Hour"');
For i := 1 to NumEMRegisters Do WriteintoMemStr(DI_MHandle,', "' + RegisterNames[i] + '"');
WriteintoMemStr(DI_MHandle, Char(10));
@@ -3200,6 +3201,7 @@ begin
Try
IF This_Meter_DIFileIsOpen Then SDI_MHandle.Free;
This_Meter_DIFileIsOpen := TRUE;
+ if SDI_MHandle <> nil then SDI_MHandle.free;
SDI_MHandle := Create_Meter_Space('"Hour", ');
WriteintoMemStr(SDI_MHandle, 'kWh, kvarh, "Peak kW", "peak kVA", "Losses kWh", "Losses kvarh", "Peak Losses kW"' + Char(10));

@@ -3590,6 +3592,7 @@ begin
Try
IF OverloadFileIsOpen Then OV_MHandle.Free;
OverloadFileIsOpen := TRUE;
+ if OV_MHandle <> nil then OV_MHandle.free;
OV_MHandle := Create_Meter_Space('"Hour", "Element", "Normal Amps", "Emerg Amps", "% Normal", "% Emerg", "kVBase"' + Char(10));
Except
On E:Exception Do DosimpleMsg('Error creating memory space (Overload report) for writing.'+CRLF+E.Message, 541);
@@ -3602,6 +3605,7 @@ begin
Try
IF VoltageFileIsOpen Then VR_MHandle.Free;
VoltageFileIsOpen := TRUE;
+ if VR_MHandle <> nil then VR_MHandle.free;
VR_MHandle := Create_Meter_Space('"Hour", "Undervoltages", "Min Voltage", "Overvoltage", "Max Voltage", "Min Bus", "Max Bus"');
WriteintoMemStr(VR_MHandle,', "LV Undervoltages", "Min LV Voltage", "LV Overvoltage", "Max LV Voltage", "Min LV Bus", "Max LV Bus"' + Char(10));
Except
--
2.10.0.windows.1

Loading

0 comments on commit 5cc6711

Please sign in to comment.