Skip to content

Commit

Permalink
Obj: Expose the internal DSSObjectFlags
Browse files Browse the repository at this point in the history
  • Loading branch information
PMeira committed Mar 19, 2024
1 parent f6d9611 commit 65fe268
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
Minor release, relevant changes only in the Alt API, i.e. no need to upgrade if you don't use it.

- Alt/Obj, Batch: adjust checks for new elements. Refactored some other internal code to simplify this kind of check.
- Obj: expose internal object flags.
- ReduceAlgs: Very minor code clean-up.
- Header: Where possible, use uint32_t for bit sets (flags, options).

Expand Down
32 changes: 32 additions & 0 deletions include/dss_capi.h
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,28 @@ extern "C" {
*/
};

/*!
Object flags are bit flags used by various of the internal processes of the DSS engine.
Most are internal state, but advanced/expert users can manipulate them for some interesting uses.
*/
enum DSSObjectFlags {
DSSObjectFlags_Editing = 0x0001,
DSSObjectFlags_HasBeenSaved = 0x0002,
DSSObjectFlags_DefaultAndUnedited = 0x0004,
DSSObjectFlags_Checked = 0x0008,
DSSObjectFlags_Flag = 0x0010, ///< General purpose flag for each object
DSSObjectFlags_HasEnergyMeter = 0x0020,
DSSObjectFlags_HasSensorObj = 0x0040,
DSSObjectFlags_IsIsolated = 0x0080,
DSSObjectFlags_HasControl = 0x0100,
DSSObjectFlags_IsMonitored = 0x0200, ///< Indicates some control is monitoring this element
DSSObjectFlags_HasOCPDevice = 0x0400, ///< Fuse, Relay, or Recloser
DSSObjectFlags_HasAutoOCPDevice = 0x0800, ///< Relay or Recloser only
DSSObjectFlags_NeedsRecalc = 0x1000, ///< Used for Edit command loops
DSSObjectFlags_NeedsYPrim = 0x2000 ///< Used for Edit command loops + setter flags
};

/*!
Setter flags customize down how the update of DSS properties are handled by the
engine and parts of the API. Use especially in the `Obj` and `Batch` APIs
Expand Down Expand Up @@ -7734,6 +7756,16 @@ extern "C" {
*/
DSS_CAPI_DLL int32_t* Obj_GetPropSeqPtr(void *obj);

/*!
Copy of the internal flags (bitset from DSSObjectFlags) of a DSS object -- for expert users
*/
DSS_CAPI_DLL uint32_t Obj_GetFlags(void *obj);

/*!
Replace the internal flags of a DSS object -- for expert users
*/
DSS_CAPI_DLL void Obj_SetFlags(void *obj, uint32_t flags);

DSS_CAPI_DLL double Obj_GetFloat64(void *obj, int32_t Index);
DSS_CAPI_DLL int32_t Obj_GetInt32(void *obj, int32_t Index);
DSS_CAPI_DLL void* Obj_GetObject(void *obj, int32_t Index);
Expand Down
8 changes: 8 additions & 0 deletions include/dss_capi_ctx.h
Original file line number Diff line number Diff line change
Expand Up @@ -7152,6 +7152,14 @@ extern "C" {
(API Extension)
*/

/*!
Copy of the internal flags (bitset from DSSObjectFlags) of a DSS object -- for expert users
*/

/*!
Replace the internal flags of a DSS object -- for expert users
*/




Expand Down
12 changes: 12 additions & 0 deletions src/CAPI/CAPI_Obj.pas
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ procedure Obj_BeginEdit(obj: TDSSObject); CDECL;
procedure Obj_EndEdit(obj: TDSSObject; NumChanges: Integer); CDECL;
procedure Obj_Activate(obj: TDSSObject; AllLists: TAltAPIBoolean); CDECL;
function Obj_GetPropSeqPtr(obj: TDSSObject): PInteger; CDECL;
function Obj_GetFlags(obj: TDSSObject): TDSSObjectFlags; CDECL;
procedure Obj_SetFlags(obj: TDSSObject; flags: TDSSObjectFlags) CDECL;

function Obj_GetFloat64(obj: TDSSObject; Index: Integer): Double; CDECL;
function Obj_GetInt32(obj: TDSSObject; Index: Integer): Integer; CDECL;
Expand Down Expand Up @@ -413,6 +415,16 @@ function Obj_GetPropSeqPtr(obj: TDSSObject): PInteger; CDECL;
Result := PInteger(obj.PrpSequence);
end;

function Obj_GetFlags(obj: TDSSObject): TDSSObjectFlags; CDECL;
begin
Result := obj.Flags;
end;

procedure Obj_SetFlags(obj: TDSSObject; flags: TDSSObjectFlags) CDECL;
begin
obj.Flags := flags;
end;

function Obj_GetName(obj: TDSSObject): PAnsiChar; CDECL;
begin
Result := PAnsiChar(obj.Name);
Expand Down
8 changes: 4 additions & 4 deletions src/Common/DSSClass.pas
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ interface
IsIsolated,
HasControl,
IsMonitored, // indicates some control is monitoring this element
// IsPartofFeeder, -- UNUSED
// Drawn, // Flag used in tree searches etc -- UNUSED
HasOCPDevice, // Fuse, Relay, or Recloser
HasAutoOCPDevice, // Relay or Recloser only
// HasSwtControl // Has a remotely-controlled Switch -- UNUSED
NeedsRecalc, // Used for Edit command loops
NeedsYprim // Used for Edit command loops + setter flags
NeedsYPrim // Used for Edit command loops + setter flags
// IsPartofFeeder, -- UNUSED
// Drawn, // Flag used in tree searches etc -- UNUSED
// HasSwtControl // Has a remotely-controlled Switch -- UNUSED
);
TDSSObjectFlags = set of TDSSObjectFlag;
Flg = TDSSObjectFlag;
Expand Down
2 changes: 2 additions & 0 deletions src/dss_capi.lpr
Original file line number Diff line number Diff line change
Expand Up @@ -2020,6 +2020,8 @@
Obj_PropertySideEffects,
Obj_BeginEdit,
Obj_EndEdit,
Obj_GetFlags,
Obj_SetFlags,
Obj_Activate,
Obj_GetPropSeqPtr,
Obj_GetFloat64,
Expand Down

0 comments on commit 65fe268

Please sign in to comment.