Skip to content

Commit 65fe268

Browse files
committed
Obj: Expose the internal DSSObjectFlags
1 parent f6d9611 commit 65fe268

File tree

6 files changed

+59
-4
lines changed

6 files changed

+59
-4
lines changed

docs/changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
Minor release, relevant changes only in the Alt API, i.e. no need to upgrade if you don't use it.
2323

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

include/dss_capi.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,28 @@ extern "C" {
514514
*/
515515
};
516516

517+
/*!
518+
Object flags are bit flags used by various of the internal processes of the DSS engine.
519+
520+
Most are internal state, but advanced/expert users can manipulate them for some interesting uses.
521+
*/
522+
enum DSSObjectFlags {
523+
DSSObjectFlags_Editing = 0x0001,
524+
DSSObjectFlags_HasBeenSaved = 0x0002,
525+
DSSObjectFlags_DefaultAndUnedited = 0x0004,
526+
DSSObjectFlags_Checked = 0x0008,
527+
DSSObjectFlags_Flag = 0x0010, ///< General purpose flag for each object
528+
DSSObjectFlags_HasEnergyMeter = 0x0020,
529+
DSSObjectFlags_HasSensorObj = 0x0040,
530+
DSSObjectFlags_IsIsolated = 0x0080,
531+
DSSObjectFlags_HasControl = 0x0100,
532+
DSSObjectFlags_IsMonitored = 0x0200, ///< Indicates some control is monitoring this element
533+
DSSObjectFlags_HasOCPDevice = 0x0400, ///< Fuse, Relay, or Recloser
534+
DSSObjectFlags_HasAutoOCPDevice = 0x0800, ///< Relay or Recloser only
535+
DSSObjectFlags_NeedsRecalc = 0x1000, ///< Used for Edit command loops
536+
DSSObjectFlags_NeedsYPrim = 0x2000 ///< Used for Edit command loops + setter flags
537+
};
538+
517539
/*!
518540
Setter flags customize down how the update of DSS properties are handled by the
519541
engine and parts of the API. Use especially in the `Obj` and `Batch` APIs
@@ -7734,6 +7756,16 @@ extern "C" {
77347756
*/
77357757
DSS_CAPI_DLL int32_t* Obj_GetPropSeqPtr(void *obj);
77367758

7759+
/*!
7760+
Copy of the internal flags (bitset from DSSObjectFlags) of a DSS object -- for expert users
7761+
*/
7762+
DSS_CAPI_DLL uint32_t Obj_GetFlags(void *obj);
7763+
7764+
/*!
7765+
Replace the internal flags of a DSS object -- for expert users
7766+
*/
7767+
DSS_CAPI_DLL void Obj_SetFlags(void *obj, uint32_t flags);
7768+
77377769
DSS_CAPI_DLL double Obj_GetFloat64(void *obj, int32_t Index);
77387770
DSS_CAPI_DLL int32_t Obj_GetInt32(void *obj, int32_t Index);
77397771
DSS_CAPI_DLL void* Obj_GetObject(void *obj, int32_t Index);

include/dss_capi_ctx.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7152,6 +7152,14 @@ extern "C" {
71527152
(API Extension)
71537153
*/
71547154

7155+
/*!
7156+
Copy of the internal flags (bitset from DSSObjectFlags) of a DSS object -- for expert users
7157+
*/
7158+
7159+
/*!
7160+
Replace the internal flags of a DSS object -- for expert users
7161+
*/
7162+
71557163

71567164

71577165

src/CAPI/CAPI_Obj.pas

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ procedure Obj_BeginEdit(obj: TDSSObject); CDECL;
8787
procedure Obj_EndEdit(obj: TDSSObject; NumChanges: Integer); CDECL;
8888
procedure Obj_Activate(obj: TDSSObject; AllLists: TAltAPIBoolean); CDECL;
8989
function Obj_GetPropSeqPtr(obj: TDSSObject): PInteger; CDECL;
90+
function Obj_GetFlags(obj: TDSSObject): TDSSObjectFlags; CDECL;
91+
procedure Obj_SetFlags(obj: TDSSObject; flags: TDSSObjectFlags) CDECL;
9092

9193
function Obj_GetFloat64(obj: TDSSObject; Index: Integer): Double; CDECL;
9294
function Obj_GetInt32(obj: TDSSObject; Index: Integer): Integer; CDECL;
@@ -413,6 +415,16 @@ function Obj_GetPropSeqPtr(obj: TDSSObject): PInteger; CDECL;
413415
Result := PInteger(obj.PrpSequence);
414416
end;
415417

418+
function Obj_GetFlags(obj: TDSSObject): TDSSObjectFlags; CDECL;
419+
begin
420+
Result := obj.Flags;
421+
end;
422+
423+
procedure Obj_SetFlags(obj: TDSSObject; flags: TDSSObjectFlags) CDECL;
424+
begin
425+
obj.Flags := flags;
426+
end;
427+
416428
function Obj_GetName(obj: TDSSObject): PAnsiChar; CDECL;
417429
begin
418430
Result := PAnsiChar(obj.Name);

src/Common/DSSClass.pas

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,13 @@ interface
143143
IsIsolated,
144144
HasControl,
145145
IsMonitored, // indicates some control is monitoring this element
146-
// IsPartofFeeder, -- UNUSED
147-
// Drawn, // Flag used in tree searches etc -- UNUSED
148146
HasOCPDevice, // Fuse, Relay, or Recloser
149147
HasAutoOCPDevice, // Relay or Recloser only
150-
// HasSwtControl // Has a remotely-controlled Switch -- UNUSED
151148
NeedsRecalc, // Used for Edit command loops
152-
NeedsYprim // Used for Edit command loops + setter flags
149+
NeedsYPrim // Used for Edit command loops + setter flags
150+
// IsPartofFeeder, -- UNUSED
151+
// Drawn, // Flag used in tree searches etc -- UNUSED
152+
// HasSwtControl // Has a remotely-controlled Switch -- UNUSED
153153
);
154154
TDSSObjectFlags = set of TDSSObjectFlag;
155155
Flg = TDSSObjectFlag;

src/dss_capi.lpr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2020,6 +2020,8 @@
20202020
Obj_PropertySideEffects,
20212021
Obj_BeginEdit,
20222022
Obj_EndEdit,
2023+
Obj_GetFlags,
2024+
Obj_SetFlags,
20232025
Obj_Activate,
20242026
Obj_GetPropSeqPtr,
20252027
Obj_GetFloat64,

0 commit comments

Comments
 (0)