Add train weight, power, and max TE tracerestrict conditionals.

Minor refactorings.
This commit is contained in:
Jonathan G Rennison
2016-06-29 22:08:05 +01:00
parent a091780843
commit b5531975da
5 changed files with 215 additions and 13 deletions

View File

@@ -113,6 +113,7 @@ enum TraceRestrictItemType {
TRIT_COND_ENTRY_DIRECTION = 16, ///< Test which side of signal/signal tile is being entered from
TRIT_COND_PBS_ENTRY_SIGNAL = 17, ///< Test tile and PBS-state of previous signal
TRIT_COND_TRAIN_GROUP = 18, ///< Test train group membership
TRIT_COND_PHYS_PROP = 19, ///< Test train physical property
//TRIT_COND_TRAIN_OWNER = 24, ///< Test train owner: reserved for future use
/* space up to 31 */
};
@@ -172,6 +173,16 @@ enum TraceRestrictOrderCondAuxField {
/* space up to 3 */
};
/**
* TraceRestrictItem auxiliary type field, for physical property type conditionals
*/
enum TraceRestrictPhysPropCondAuxField {
TRPPCAF_WEIGHT = 0, ///< value field is a weight
TRPPCAF_POWER = 1, ///< value field is a power
TRPPCAF_MAX_TE = 2, ///< value field is a tractive effort
/* space up to 3 */
};
/**
* TraceRestrictItem auxiliary type field, for order type conditionals
*/
@@ -414,6 +425,9 @@ enum TraceRestrictValueType {
TRVT_RESERVE_THROUGH = 10,///< takes a value 0 = reserve through, 1 = cancel previous reserve through
TRVT_LONG_RESERVE = 11,///< takes a value 0 = long reserve, 1 = cancel previous long reserve
TRVT_GROUP_INDEX = 12,///< takes a GroupID
TRVT_WEIGHT = 13,///< takes a weight
TRVT_POWER = 14,///< takes a power
TRVT_FORCE = 15,///< takes a force
};
/**
@@ -425,7 +439,7 @@ struct TraceRestrictTypePropertySet {
};
void SetTraceRestrictValueDefault(TraceRestrictItem &item, TraceRestrictValueType value_type);
void SetTraceRestrictTypeAndNormalise(TraceRestrictItem &item, TraceRestrictItemType type);
void SetTraceRestrictTypeAndNormalise(TraceRestrictItem &item, TraceRestrictItemType type, uint8 aux_data = 0);
/**
* Get TraceRestrictTypePropertySet for a given instruction, only looks at value field
@@ -480,6 +494,26 @@ static inline TraceRestrictTypePropertySet GetTraceRestrictTypeProperties(TraceR
out.cond_type = TRCOT_BINARY;
break;
case TRIT_COND_PHYS_PROP:
switch (static_cast<TraceRestrictPhysPropCondAuxField>(GetTraceRestrictAuxField(item))) {
case TRPPCAF_WEIGHT:
out.value_type = TRVT_WEIGHT;
break;
case TRPPCAF_POWER:
out.value_type = TRVT_POWER;
break;
case TRPPCAF_MAX_TE:
out.value_type = TRVT_FORCE;
break;
default:
NOT_REACHED();
break;
}
break;
default:
NOT_REACHED();
break;