add Function Docs and some Cleanups ...

This commit is contained in:
2025-04-04 22:03:57 +03:30
parent 9a67c4bc39
commit ffcf43067e
2 changed files with 203 additions and 48 deletions
+199 -46
View File
@@ -37,8 +37,8 @@ class XCX121SMCXINDSignalDetector : public XCBase
bool useGuards;
double rfRewar;
XBoxZone mWaitingBoxes[];
XBoxZone mActivatedBoxes[];
XBoxZone mBreakedBoxes[];
XBoxZone mActivatedBoxes[];
XBoxZone mUnAvailableBoxes[];
X121SMCStrategyXINDSignalConditions mConditions;
X121SMCStrategyXINDSignalConditions mConditionsCollection[];
@@ -67,14 +67,17 @@ class XCX121SMCXINDSignalDetector : public XCBase
//
//
//
// Detect Setup Conditions ...
/**
* Detect Setup Conditions based on Signalling ...
*
* @param provider: X121SMCStrategySignalProviderData instance Reference, Specified Data for Cycles ...
* @param maxAllowedSLDistanceInPoint: int, Max Allowed SL Distance in Points (if Bigger thn Zero Provided) ...
*
* @return ( bool )
*/
bool DetectSignalSetup(
//
X121SMCStrategySignalProviderData &provider,
//
double maxAllowedSLDistanceInPoint = 300
//
double maxAllowedSLDistanceInPoint = 300 //
)
{
//
@@ -105,6 +108,11 @@ class XCX121SMCXINDSignalDetector : public XCBase
//
int loopback = 10;
//
int idx = -1;
int count = 0;
bool has = false;
//
mConditions.symbol = symbol;
mConditions.period = period;
@@ -224,6 +232,9 @@ class XCX121SMCXINDSignalDetector : public XCBase
{
//
hasSignalBox = HasXPVConditions(
mWaitingBoxes,
mActivatedBoxes,
mBreakedBoxes,
X_CYCLE_DECISION,
signalBox,
signalBoxDir,
@@ -232,7 +243,11 @@ class XCX121SMCXINDSignalDetector : public XCBase
);
if (hasSignalBox)
{
//
signalProvider = X121SMC_XIND_PROVIDER_XSTR;
//
MakeSignalBoxUnAvailable(signalBox);
}
}
@@ -240,10 +255,6 @@ class XCX121SMCXINDSignalDetector : public XCBase
//
//
// //
// // Update Models To Time ...
// UpdateTo(cTime);
//
// Cleanup Signal if UnApproved ...
if (!hasSignalBox)
@@ -422,17 +433,19 @@ class XCX121SMCXINDSignalDetector : public XCBase
return result;
}
//
// Detect Trigger Conditions ...
/**
* Detect Trigger Conditions for Specified Signal ...
*
* @param conditions: X121SMCStrategyXINDSignalConditions instance Reference, Specified Signal Conditions ...
* @param provider: X121SMCStrategySignalProviderData instance Reference, Specified Data for Cycles ...
* @param maxAllowedSetupAge: specified Setup Age for Expiration (if bigger than Zero) ...
*
* @return ( bool )
*/
bool DetectSignalTrigger(
//
X121SMCStrategyXINDSignalConditions &conditions,
//
X121SMCStrategySignalProviderData &provider,
//
int maxAllowedSetupAge = 60
//
)
int maxAllowedSetupAge = 60)
{
//
bool result = false;
@@ -524,16 +537,19 @@ class XCX121SMCXINDSignalDetector : public XCBase
return result;
}
//
// Detect Guards ...
/**
* Detect Guards bsed on Signalling Class ...
*
* @param guards: X121SMCGuard instance Collection, Holds Provided Guards ...
* @param positions: XPosition instance Collection, Provides Signalling Based Positions for Apply Guards on them ...
* @param provider: X121SMCStrategySignalProviderData instance Reference, Specified Data for Cycles ...
*
* @return ( bool )
*/
bool DetectGuards(
//
X121SMCGuard &guards[],
const XPosition &positions[],
//
X121SMCStrategySignalProviderData &provider
//
)
X121SMCStrategySignalProviderData &provider)
{
//
bool result = false;
@@ -1069,8 +1085,14 @@ class XCX121SMCXINDSignalDetector : public XCBase
return result;
}
//
// Waiting Boxes ...
/**
* Detect and Manage Important Zones and Categorized them for Signalling Clss ...
*
* @param cycle: ENUM_X_CYCLES member, Specified Source Cycle for Detecting ...
* @param provider: X121SMCStrategySignalProviderData instance Reference, Specified Data for Cycles ...
*
* @return ( int )
*/
int UpdateWaitingBoxes(
ENUM_X_CYCLES cycle,
X121SMCStrategySignalProviderData &provider //
@@ -1416,7 +1438,138 @@ class XCX121SMCXINDSignalDetector : public XCBase
return result;
}
/**
* Make a Detected Signal Box UnAvailable for Prevent of Double Executing ...
*
* @param box: XBoxZone instance Reference, Specified Signal Box ...
*/
void MakeSignalBoxUnAvailable(
XBoxZone &box //
)
{
//
int idx = -1;
int count = 0;
bool has = false;
//
// Validate Box ...
has = box.IsValid();
if (!has)
{
return;
}
//
// Check Waiting Boxes ...
count = ArraySize(mWaitingBoxes);
has = IsValidSize(count);
if (has)
{
//
has = FindBoxIndex(
idx,
box,
mWaitingBoxes //
);
if (has)
{
//
// Remove Signal Box From Collection ...
ArrayRemove(
mWaitingBoxes,
idx,
1 //
);
//
// Add Signal Box to UnAvailable Boxes ...
AddRef(
box,
mUnAvailableBoxes //
);
//
return;
}
}
//
// Check Activated Boxes ...
count = ArraySize(mActivatedBoxes);
has = IsValidSize(count);
if (has)
{
//
has = FindBoxIndex(
idx,
box,
mActivatedBoxes //
);
if (has)
{
//
// Remove Signal Box From Collection ...
ArrayRemove(
mActivatedBoxes,
idx,
1 //
);
//
// Add Signal Box to UnAvailable Boxes ...
AddRef(
box,
mUnAvailableBoxes //
);
//
return;
}
}
//
// Check Breaked Boxes ...
count = ArraySize(mBreakedBoxes);
has = IsValidSize(count);
if (has)
{
//
has = FindBoxIndex(
idx,
box,
mBreakedBoxes //
);
if (has)
{
//
// Remove Signal Box From Collection ...
ArrayRemove(
mBreakedBoxes,
idx,
1 //
);
//
// Add Signal Box to UnAvailable Boxes ...
AddRef(
box,
mUnAvailableBoxes //
);
//
return;
}
}
}
/**
* Check a Box is Exists in Box Collections of Signalling Collections ...
*
* @param box: XBoxZone instance Reference, Specified Box to Check ...
*
* @return ( bool )
*/
bool IsBoxExists(XBoxZone &box)
{
//
@@ -1507,8 +1660,13 @@ class XCX121SMCXINDSignalDetector : public XCBase
return result;
}
//
// Add Conditions to Conditions Collection ...
/**
* Add Conditions to Conditions Collection if not Exists ...
*
* @param maxAllowed: int, Specified Max Allowed Holding Conditions ...
*
* @return ( int )
*/
int AddConditionsIfNotExists(
int maxAllowed = 10 //
)
@@ -1586,9 +1744,13 @@ class XCX121SMCXINDSignalDetector : public XCBase
//
// Draw Functions ...
//
//
/**
* Draw Specified Bar on Chart ...
*
* @param bar: XOHCL instance Reference, Specified Bar ...
* @param forceClean: force Clean Drawn Objects ...
*/
void DrawBar(
XOHCL &bar,
XCPOIDrawer *drawer,
@@ -1649,7 +1811,11 @@ class XCX121SMCXINDSignalDetector : public XCBase
}
}
//
/**
* Draw Boxes of Signallings on Chart ...
*
* @param forceClean: force Clean Drawn Objects ...
*/
void DrawBoxes(
XCPOIDrawer *drawer,
bool forceClean = false //
@@ -1758,19 +1924,6 @@ class XCX121SMCXINDSignalDetector : public XCBase
mBarObjects.Clear();
}
// /**
// * Update To Time of Exists Components ...
// *
// * @param value: updated time ...
// */
// void UpdateTo(
// datetime value = NULL //
// )
// {
// //
// value = NormalizeTime(value);
// }
//
};
@@ -228,8 +228,10 @@ struct X121SMCStrategyXINDSignalConditions
//
// Detect Signals Based On XPV Indicator Golden Zones ...
//
bool HasXPVConditions(
XBoxZone &waitingBoxes[],
XBoxZone &ctivtedBoxes[],
XBoxZone &breakedBoxes[],
ENUM_X_CYCLES cycle,
XBoxZone &box,
ENUM_X_DIRECTION &dir,