Unit Utilities

Classes, Interfaces, Objects and Records
Variables

Description

 

Uses

Overview

Functions and Procedures

function StrTOrF(const b: Boolean): String; inline;
function StrYOrN(const b: Boolean): String; inline;
function CompareTextShortest(const S1, S2: String): Integer;
procedure FireOffEditor(DSS: TDSSContext; FileNm: String);
procedure DoDOSCmd(DSS: TDSSContext; CmdString: String);
function StripExtension(const S: String): String;
function StripClassName(const S: String): String;
function GetNodeString(const Busname: String): String;
function Pad(const S: String; Width: Integer): String;
function PadDots(const S: String; Width: Integer): String;
function PadTrunc(const S: String; Width: Integer): String;
function IntArrayToString(iarray: pIntegerArray; count: Integer): String;
function DblArrayToString(dblarray: pDoubleArray; count: Integer): String;
function CmplxArrayToString(cpxarray: pComplexArray; count: Integer): String;
function StringListToString(lst: TStringList): String;
function EncloseQuotes(const s: String): String;
procedure ShowMessageBeep(DSS: TDSSContext; const s: String);
procedure ParseObjectClassandName(DSS: TDSSContext; const FullObjName: String; var ClassName, ObjName: String);
procedure ParseIntArray(DSS: TDSSContext; var iarray: pIntegerArray; var count: Integer; const s: String);
function InterpretYesNo(const s: String): Boolean;
procedure InitDblArray(NumValues: Integer; Xarray: pDoubleArray; Value: Double);
function InterpretDblArray(DSS: TDSSContext; const s: String; MaxValues: Integer; ResultArray: pDoubleArray): Integer;
function InterpretIntArray(DSS: TDSSContext; const s: String; MaxValues: Integer; ResultArray: pIntegerArray): Integer;
procedure InterpretTStringListArray(DSS: TDSSContext; const s: String; var ResultList: TStringList);
function InterpretTimeStepSize(DSS: TDSSContext; const s: String): Double;
function InterpretColorName(DSS: TDSSContext; const s: String): Integer;
function ConstructElemName(DSS: TDSSContext; const Param: String): String;
function GetDSSArray_Real(n: Integer; dbls: pDoubleArray; scale: Double = 1.0): String;
function GetDSSArray_Single(n: Integer; sngs: pSingleArray): String;
function GetDSSArray_Integer(n: Integer; ints: pIntegerArray): String;
function GetOCPDeviceType(pElem: TDSSCktElement): Integer;
function GetOCPDeviceTypeString(icode: Integer): String;
function InterpretDblArrayMMF(DSS: TDSSContext; mmPtr: pByte; FileType: TLSFileType; Column, INDEX, DataSize: Integer): double;
function DoExecutiveCommand(DSS: TDSSContext; const s: String): Integer;
function GetCktElementIndex(DSS: TDSSContext; const FullObjName: String): Integer;
function IsShuntElement(const Elem: TDSSCktElement): Boolean;
function IsLineElement(const Elem: TDSSCktElement): Boolean;
function IsTransformerElement(const Elem: TDSSCktElement): Boolean;
function CheckParallel(const Line1, Line2: TDSSCktElement): Boolean;
function AllTerminalsClosed(ThisElement: TDSSCktElement): Boolean;
function Str_Real(const Value: Double; NumDecimals: Integer): String;
procedure DumpAllDSSCommands(DSS: TDSSContext; var Filename: String);
procedure DumpAllocationFactors(DSS: TDSSContext; var Filename: String);
procedure DumpComplexMatrix(DSS: TDSSContext; F: TFileStream; AMatrix: TcMatrix);
function NearestBasekV(DSS: TDSSContext; kV: Double): Double;
function DoResetFaults(DSS: TDSSContext): Integer;
function DoResetControls(DSS: TDSSContext): Integer;
procedure DoResetKeepList(DSS: TDSSContext);
function GetNodeNum(DSS: TDSSContext; NodeRef: Integer): Integer;
function MaxdblArrayValue(npts: Integer; dbls: pDoubleArray): Double;
function iMaxAbsdblArrayValue(npts: Integer; dbls: pDoubleArray): Integer;
function iMaxAbssngArrayValue(npts: Integer; sngs: pSingleArray): Integer;
function QuadSolver(const a, b, c: Double): Double;
function WriteClassFile(DSS: TDSSContext; const DSS_Class: TDSSClass; FileName: String; IsCktElement: Boolean): Boolean;
function WriteVsourceClassFile(DSS: TDSSContext; const DSS_Class: TDSSClass; IsCktElement: Boolean): Boolean;
procedure WriteActiveDSSObject(DSS: TDSSContext; F: TFileStream; const NeworEdit: String);
function checkforblanks(const S: String): String;
function RewriteAlignedFile(DSS: TDSSContext; const Filename: String): Boolean;
procedure ClearEventLog(DSS: TDSSContext);
procedure AppendToEventLog(DSS: TDSSContext; const opdev: String; const action: String);
procedure LogThisEvent(DSS: TDSSContext; const EventName: String);
procedure ClearErrorLog(DSS: TDSSContext);
procedure RotatePhasorDeg(var Phasor: Complex; const h, AngleDeg: Double);
procedure RotatePhasorRad(var Phasor: Complex; const h, AngleRad: Double);
procedure ConvertComplexArrayToPolar(const Buffer: pComplexArray; N: Integer);
procedure ConvertComplexArrayToPowerandPF(const Buffer: pComplexArray; N: Integer);
function Residual(p: Pointer; Nph: Integer): Complex;
function ResidualPolar(p: Pointer; Nph: Integer): Complex;
function Powerfactor(const S: Complex): Double;
procedure CmulArray(pc: pcomplexarray; Multiplier: Double; size: Integer);
procedure CalcInitialMachineStates(DSS: TDSSContext);
procedure InvalidateAllPCELEMENTS(DSS: TDSSContext);
function InitializeForHarmonics(DSS: TDSSContext): Boolean;
function SavePresentVoltages(DSS: TDSSContext): Boolean;
function RetrieveSavedVoltages(DSS: TDSSContext): Boolean;
function GetMaxPUVoltage(DSS: TDSSContext): Double;
function GetMinPUVoltage(DSS: TDSSContext; IgnoreNeutrals: Boolean): Double;
function GetTotalPowerFromSources(DSS: TDSSContext): Complex;
function GetMaxCktElementSize(DSS: TDSSContext): Integer;
function GetUniqueNodeNumber(DSS: TDSSContext; const sBusName: String; StartNode: Integer): Integer;
function IsPathBetween(FromLine, ToLine: TPDElement): Boolean;
procedure TraceAndEdit(DSS: TDSSContext; FromLine, ToLine: TPDElement; NPhases: Integer; EditStr: String);
procedure GoForwardAndRephase(DSS: TDSSContext; FromLine: TPDElement; const PhaseString, EditStr, ScriptFileName: String; TransStop: Boolean);
procedure MakeDistributedGenerators(DSS: TDSSContext; kW, PF: Double; How: String; Skip: Integer; Fname: String; DoGenerators: Boolean);
procedure Obfuscate(DSS: TDSSContext);
function AdjustInputFilePath(DSS: TDSSContext; param: String): String;
procedure FSWriteLn(F: TFileStream; Ss: Array of String); inline; overload;
procedure FSWriteLn(F: TFileStream; S: String = ''); inline; overload;
procedure FSWriteLn(F: TFileStream; S: String; S2: String); inline; overload;
procedure FSWriteLn(F: TFileStream; S: String; S2: String; S3: String); inline; overload;
procedure FSWrite(F: TFileStream; S: String); inline; overload;
procedure FSWrite(F: TFileStream; S: String; S2: String); inline; overload;
procedure FSWrite(F: TFileStream; S: String; S2: String; S3: String); inline; overload;
procedure FSReadln(F: TStream; out S: String);
procedure FSFlush(F: TFileStream);
function SliceProps(props: pStringArray; count: Integer): ArrayOfString;
procedure DoSngFile(DSS: TDSSContext; var pA, pB: PDoubleArray; var NumPoints: Integer; OnlyLoadB: Boolean; const FileName: String; const ClassName: String; RoundA: Boolean = False);
procedure DoDblFile(DSS: TDSSContext; var pA, pB: PDoubleArray; var NumPoints: Integer; OnlyLoadB: Boolean; const FileName: String; const ClassName: String; RoundA: Boolean = False);
procedure DoCSVFile(DSS: TDSSContext; var pA, pB: PDoubleArray; var NumPoints: Integer; OnlyLoadB: Boolean; const FileName: String; const ClassName: String; RoundA: Boolean = False);
procedure DelFilesFromDir(Directory: String; FileMask: String = '*'; DelSubDirs: Boolean = True);

Types

TLSFileType = (...);

Constants

sCRLF: String = sLineBreak;
clAqua: Integer = $FFFF00;
clBlack: Integer = $000000;
clBlue: Integer = $FF0000;
clDkGray: Integer = $808080;
clFuchsia: Integer = $FF00FF;
clGray: Integer = $808080;
clGreen: Integer = $008000;
clLime: Integer = $00FF00;
clLtGray: Integer = $C0C0C0;
clMaroon: Integer = $000080;
clNavy: Integer = $800000;
clOlive: Integer = $008080;
clPurple: Integer = $800080;
clRed: Integer = $0000FF;
clSilver: Integer = $C0C0C0;
clTeal: Integer = $808000;
clWhite: Integer = $FFFFFF;
clYellow: Integer = $00FFFF;

Description

Functions and Procedures

function StrTOrF(const b: Boolean): String; inline;
 
function StrYOrN(const b: Boolean): String; inline;
 
function CompareTextShortest(const S1, S2: String): Integer;
 
procedure FireOffEditor(DSS: TDSSContext; FileNm: String);
 
procedure DoDOSCmd(DSS: TDSSContext; CmdString: String);
 
function StripExtension(const S: String): String;
 
function StripClassName(const S: String): String;
 
function GetNodeString(const Busname: String): String;

Return only element name sans class.

function Pad(const S: String; Width: Integer): String;
 
function PadDots(const S: String; Width: Integer): String;
 
function PadTrunc(const S: String; Width: Integer): String;
 
function IntArrayToString(iarray: pIntegerArray; count: Integer): String;
 
function DblArrayToString(dblarray: pDoubleArray; count: Integer): String;
 
function CmplxArrayToString(cpxarray: pComplexArray; count: Integer): String;
 
function StringListToString(lst: TStringList): String;
 
function EncloseQuotes(const s: String): String;
 
procedure ShowMessageBeep(DSS: TDSSContext; const s: String);
 
procedure ParseObjectClassandName(DSS: TDSSContext; const FullObjName: String; var ClassName, ObjName: String);

Parsing Utilities

procedure ParseIntArray(DSS: TDSSContext; var iarray: pIntegerArray; var count: Integer; const s: String);
 
function InterpretYesNo(const s: String): Boolean;
 
procedure InitDblArray(NumValues: Integer; Xarray: pDoubleArray; Value: Double);
 
function InterpretDblArray(DSS: TDSSContext; const s: String; MaxValues: Integer; ResultArray: pDoubleArray): Integer;
 
function InterpretIntArray(DSS: TDSSContext; const s: String; MaxValues: Integer; ResultArray: pIntegerArray): Integer;
 
procedure InterpretTStringListArray(DSS: TDSSContext; const s: String; var ResultList: TStringList);
 
function InterpretTimeStepSize(DSS: TDSSContext; const s: String): Double;
 
function InterpretColorName(DSS: TDSSContext; const s: String): Integer;
 
function ConstructElemName(DSS: TDSSContext; const Param: String): String;
 
function GetDSSArray_Real(n: Integer; dbls: pDoubleArray; scale: Double = 1.0): String;
 
function GetDSSArray_Single(n: Integer; sngs: pSingleArray): String;
 
function GetDSSArray_Integer(n: Integer; ints: pIntegerArray): String;
 
function GetOCPDeviceType(pElem: TDSSCktElement): Integer;
 
function GetOCPDeviceTypeString(icode: Integer): String;
 
function InterpretDblArrayMMF(DSS: TDSSContext; mmPtr: pByte; FileType: TLSFileType; Column, INDEX, DataSize: Integer): double;

Addition to deal with Memory mapped data

function DoExecutiveCommand(DSS: TDSSContext; const s: String): Integer;

misc functions

function GetCktElementIndex(DSS: TDSSContext; const FullObjName: String): Integer;
 
function IsShuntElement(const Elem: TDSSCktElement): Boolean;
 
function IsLineElement(const Elem: TDSSCktElement): Boolean;
 
function IsTransformerElement(const Elem: TDSSCktElement): Boolean;
 
function CheckParallel(const Line1, Line2: TDSSCktElement): Boolean;
 
function AllTerminalsClosed(ThisElement: TDSSCktElement): Boolean;
 
function Str_Real(const Value: Double; NumDecimals: Integer): String;
 
procedure DumpAllDSSCommands(DSS: TDSSContext; var Filename: String);
 
procedure DumpAllocationFactors(DSS: TDSSContext; var Filename: String);
 
procedure DumpComplexMatrix(DSS: TDSSContext; F: TFileStream; AMatrix: TcMatrix);
 
function NearestBasekV(DSS: TDSSContext; kV: Double): Double;
 
function DoResetFaults(DSS: TDSSContext): Integer;
 
function DoResetControls(DSS: TDSSContext): Integer;
 
procedure DoResetKeepList(DSS: TDSSContext);
 
function GetNodeNum(DSS: TDSSContext; NodeRef: Integer): Integer;
 
function MaxdblArrayValue(npts: Integer; dbls: pDoubleArray): Double;
 
function iMaxAbsdblArrayValue(npts: Integer; dbls: pDoubleArray): Integer;
 
function iMaxAbssngArrayValue(npts: Integer; sngs: pSingleArray): Integer;
 
function QuadSolver(const a, b, c: Double): Double;
 
function WriteClassFile(DSS: TDSSContext; const DSS_Class: TDSSClass; FileName: String; IsCktElement: Boolean): Boolean;

returns largest of two answers Save Function Helper

function WriteVsourceClassFile(DSS: TDSSContext; const DSS_Class: TDSSClass; IsCktElement: Boolean): Boolean;
 
procedure WriteActiveDSSObject(DSS: TDSSContext; F: TFileStream; const NeworEdit: String);
 
function checkforblanks(const S: String): String;
 
function RewriteAlignedFile(DSS: TDSSContext; const Filename: String): Boolean;
 
procedure ClearEventLog(DSS: TDSSContext);

Event Log

procedure AppendToEventLog(DSS: TDSSContext; const opdev: String; const action: String);
 
procedure LogThisEvent(DSS: TDSSContext; const EventName: String);
 
procedure ClearErrorLog(DSS: TDSSContext);
 
procedure RotatePhasorDeg(var Phasor: Complex; const h, AngleDeg: Double);

Routines for doing common things to complex numbers

procedure RotatePhasorRad(var Phasor: Complex; const h, AngleRad: Double);
 
procedure ConvertComplexArrayToPolar(const Buffer: pComplexArray; N: Integer);
 
procedure ConvertComplexArrayToPowerandPF(const Buffer: pComplexArray; N: Integer);
 
function Residual(p: Pointer; Nph: Integer): Complex;
 
function ResidualPolar(p: Pointer; Nph: Integer): Complex;
 
function Powerfactor(const S: Complex): Double;
 
procedure CmulArray(pc: pcomplexarray; Multiplier: Double; size: Integer);
 
procedure CalcInitialMachineStates(DSS: TDSSContext);

Multiply a complex array times a double Support for going in and out of Dynamics Mode and Harmonics Mode

procedure InvalidateAllPCELEMENTS(DSS: TDSSContext);
 
function InitializeForHarmonics(DSS: TDSSContext): Boolean;
 
function SavePresentVoltages(DSS: TDSSContext): Boolean;
 
function RetrieveSavedVoltages(DSS: TDSSContext): Boolean;
 
function GetMaxPUVoltage(DSS: TDSSContext): Double;
 
function GetMinPUVoltage(DSS: TDSSContext; IgnoreNeutrals: Boolean): Double;
 
function GetTotalPowerFromSources(DSS: TDSSContext): Complex;
 
function GetMaxCktElementSize(DSS: TDSSContext): Integer;
 
function GetUniqueNodeNumber(DSS: TDSSContext; const sBusName: String; StartNode: Integer): Integer;
 
function IsPathBetween(FromLine, ToLine: TPDElement): Boolean;

TraceBack Functions

procedure TraceAndEdit(DSS: TDSSContext; FromLine, ToLine: TPDElement; NPhases: Integer; EditStr: String);
 
procedure GoForwardAndRephase(DSS: TDSSContext; FromLine: TPDElement; const PhaseString, EditStr, ScriptFileName: String; TransStop: Boolean);
 
procedure MakeDistributedGenerators(DSS: TDSSContext; kW, PF: Double; How: String; Skip: Integer; Fname: String; DoGenerators: Boolean);
 
procedure Obfuscate(DSS: TDSSContext);
 
function AdjustInputFilePath(DSS: TDSSContext; param: String): String;
 
procedure FSWriteLn(F: TFileStream; Ss: Array of String); inline; overload;
 
procedure FSWriteLn(F: TFileStream; S: String = ''); inline; overload;
 
procedure FSWriteLn(F: TFileStream; S: String; S2: String); inline; overload;
 
procedure FSWriteLn(F: TFileStream; S: String; S2: String; S3: String); inline; overload;
 
procedure FSWrite(F: TFileStream; S: String); inline; overload;
 
procedure FSWrite(F: TFileStream; S: String; S2: String); inline; overload;
 
procedure FSWrite(F: TFileStream; S: String; S2: String; S3: String); inline; overload;
 
procedure FSReadln(F: TStream; out S: String);
 
procedure FSFlush(F: TFileStream);
 
function SliceProps(props: pStringArray; count: Integer): ArrayOfString;
 
procedure DoSngFile(DSS: TDSSContext; var pA, pB: PDoubleArray; var NumPoints: Integer; OnlyLoadB: Boolean; const FileName: String; const ClassName: String; RoundA: Boolean = False);

The built-in Slice was causing issues on ARM64

procedure DoDblFile(DSS: TDSSContext; var pA, pB: PDoubleArray; var NumPoints: Integer; OnlyLoadB: Boolean; const FileName: String; const ClassName: String; RoundA: Boolean = False);
 
procedure DoCSVFile(DSS: TDSSContext; var pA, pB: PDoubleArray; var NumPoints: Integer; OnlyLoadB: Boolean; const FileName: String; const ClassName: String; RoundA: Boolean = False);
 
procedure DelFilesFromDir(Directory: String; FileMask: String = '*'; DelSubDirs: Boolean = True);
 

Types

TLSFileType = (...);
 
Values
  • PlainText = 0
  • Float64 = 1
  • Float32 = 2

Constants

sCRLF: String = sLineBreak;
 
clAqua: Integer = $FFFF00;
 
clBlack: Integer = $000000;
 
clBlue: Integer = $FF0000;
 
clDkGray: Integer = $808080;
 
clFuchsia: Integer = $FF00FF;
 
clGray: Integer = $808080;
 
clGreen: Integer = $008000;
 
clLime: Integer = $00FF00;
 
clLtGray: Integer = $C0C0C0;
 
clMaroon: Integer = $000080;
 
clNavy: Integer = $800000;
 
clOlive: Integer = $008080;
 
clPurple: Integer = $800080;
 
clRed: Integer = $0000FF;
 
clSilver: Integer = $C0C0C0;
 
clTeal: Integer = $808000;
 
clWhite: Integer = $FFFFFF;
 
clYellow: Integer = $00FFFF;
 

Generated by PasDoc 0.16.0.