add Function Docs and some Cleanups ...
This commit is contained in:
@@ -37,8 +37,8 @@ class XCX121SMCXINDSignalDetector : public XCBase
|
|||||||
bool useGuards;
|
bool useGuards;
|
||||||
double rfRewar;
|
double rfRewar;
|
||||||
XBoxZone mWaitingBoxes[];
|
XBoxZone mWaitingBoxes[];
|
||||||
XBoxZone mActivatedBoxes[];
|
|
||||||
XBoxZone mBreakedBoxes[];
|
XBoxZone mBreakedBoxes[];
|
||||||
|
XBoxZone mActivatedBoxes[];
|
||||||
XBoxZone mUnAvailableBoxes[];
|
XBoxZone mUnAvailableBoxes[];
|
||||||
X121SMCStrategyXINDSignalConditions mConditions;
|
X121SMCStrategyXINDSignalConditions mConditions;
|
||||||
X121SMCStrategyXINDSignalConditions mConditionsCollection[];
|
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(
|
bool DetectSignalSetup(
|
||||||
//
|
|
||||||
X121SMCStrategySignalProviderData &provider,
|
X121SMCStrategySignalProviderData &provider,
|
||||||
//
|
double maxAllowedSLDistanceInPoint = 300 //
|
||||||
double maxAllowedSLDistanceInPoint = 300
|
|
||||||
//
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -105,6 +108,11 @@ class XCX121SMCXINDSignalDetector : public XCBase
|
|||||||
//
|
//
|
||||||
int loopback = 10;
|
int loopback = 10;
|
||||||
|
|
||||||
|
//
|
||||||
|
int idx = -1;
|
||||||
|
int count = 0;
|
||||||
|
bool has = false;
|
||||||
|
|
||||||
//
|
//
|
||||||
mConditions.symbol = symbol;
|
mConditions.symbol = symbol;
|
||||||
mConditions.period = period;
|
mConditions.period = period;
|
||||||
@@ -224,6 +232,9 @@ class XCX121SMCXINDSignalDetector : public XCBase
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
hasSignalBox = HasXPVConditions(
|
hasSignalBox = HasXPVConditions(
|
||||||
|
mWaitingBoxes,
|
||||||
|
mActivatedBoxes,
|
||||||
|
mBreakedBoxes,
|
||||||
X_CYCLE_DECISION,
|
X_CYCLE_DECISION,
|
||||||
signalBox,
|
signalBox,
|
||||||
signalBoxDir,
|
signalBoxDir,
|
||||||
@@ -232,7 +243,11 @@ class XCX121SMCXINDSignalDetector : public XCBase
|
|||||||
);
|
);
|
||||||
if (hasSignalBox)
|
if (hasSignalBox)
|
||||||
{
|
{
|
||||||
|
//
|
||||||
signalProvider = X121SMC_XIND_PROVIDER_XSTR;
|
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 ...
|
// Cleanup Signal if UnApproved ...
|
||||||
if (!hasSignalBox)
|
if (!hasSignalBox)
|
||||||
@@ -422,17 +433,19 @@ class XCX121SMCXINDSignalDetector : public XCBase
|
|||||||
return result;
|
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(
|
bool DetectSignalTrigger(
|
||||||
//
|
|
||||||
X121SMCStrategyXINDSignalConditions &conditions,
|
X121SMCStrategyXINDSignalConditions &conditions,
|
||||||
//
|
|
||||||
X121SMCStrategySignalProviderData &provider,
|
X121SMCStrategySignalProviderData &provider,
|
||||||
//
|
int maxAllowedSetupAge = 60)
|
||||||
int maxAllowedSetupAge = 60
|
|
||||||
//
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
bool result = false;
|
bool result = false;
|
||||||
@@ -524,16 +537,19 @@ class XCX121SMCXINDSignalDetector : public XCBase
|
|||||||
return result;
|
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(
|
bool DetectGuards(
|
||||||
//
|
|
||||||
X121SMCGuard &guards[],
|
X121SMCGuard &guards[],
|
||||||
const XPosition &positions[],
|
const XPosition &positions[],
|
||||||
//
|
X121SMCStrategySignalProviderData &provider)
|
||||||
X121SMCStrategySignalProviderData &provider
|
|
||||||
//
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
bool result = false;
|
bool result = false;
|
||||||
@@ -1069,8 +1085,14 @@ class XCX121SMCXINDSignalDetector : public XCBase
|
|||||||
return result;
|
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(
|
int UpdateWaitingBoxes(
|
||||||
ENUM_X_CYCLES cycle,
|
ENUM_X_CYCLES cycle,
|
||||||
X121SMCStrategySignalProviderData &provider //
|
X121SMCStrategySignalProviderData &provider //
|
||||||
@@ -1416,7 +1438,138 @@ class XCX121SMCXINDSignalDetector : public XCBase
|
|||||||
return result;
|
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)
|
bool IsBoxExists(XBoxZone &box)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -1507,8 +1660,13 @@ class XCX121SMCXINDSignalDetector : public XCBase
|
|||||||
return result;
|
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 AddConditionsIfNotExists(
|
||||||
int maxAllowed = 10 //
|
int maxAllowed = 10 //
|
||||||
)
|
)
|
||||||
@@ -1586,9 +1744,13 @@ class XCX121SMCXINDSignalDetector : public XCBase
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Draw Functions ...
|
// Draw Functions ...
|
||||||
//
|
|
||||||
|
|
||||||
//
|
/**
|
||||||
|
* Draw Specified Bar on Chart ...
|
||||||
|
*
|
||||||
|
* @param bar: XOHCL instance Reference, Specified Bar ...
|
||||||
|
* @param forceClean: force Clean Drawn Objects ...
|
||||||
|
*/
|
||||||
void DrawBar(
|
void DrawBar(
|
||||||
XOHCL &bar,
|
XOHCL &bar,
|
||||||
XCPOIDrawer *drawer,
|
XCPOIDrawer *drawer,
|
||||||
@@ -1649,7 +1811,11 @@ class XCX121SMCXINDSignalDetector : public XCBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
/**
|
||||||
|
* Draw Boxes of Signallings on Chart ...
|
||||||
|
*
|
||||||
|
* @param forceClean: force Clean Drawn Objects ...
|
||||||
|
*/
|
||||||
void DrawBoxes(
|
void DrawBoxes(
|
||||||
XCPOIDrawer *drawer,
|
XCPOIDrawer *drawer,
|
||||||
bool forceClean = false //
|
bool forceClean = false //
|
||||||
@@ -1758,19 +1924,6 @@ class XCX121SMCXINDSignalDetector : public XCBase
|
|||||||
mBarObjects.Clear();
|
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 ...
|
// Detect Signals Based On XPV Indicator Golden Zones ...
|
||||||
//
|
|
||||||
bool HasXPVConditions(
|
bool HasXPVConditions(
|
||||||
|
XBoxZone &waitingBoxes[],
|
||||||
|
XBoxZone &ctivtedBoxes[],
|
||||||
|
XBoxZone &breakedBoxes[],
|
||||||
ENUM_X_CYCLES cycle,
|
ENUM_X_CYCLES cycle,
|
||||||
XBoxZone &box,
|
XBoxZone &box,
|
||||||
ENUM_X_DIRECTION &dir,
|
ENUM_X_DIRECTION &dir,
|
||||||
|
|||||||
Reference in New Issue
Block a user