onroute-policy-engine 2.30.1 → 2.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants/axle-spread-legal-limits.d.ts +4 -0
- package/dist/constants/axle-spread-legal-limits.js +4 -0
- package/dist/enum/facts.d.ts +1 -0
- package/dist/enum/facts.js +1 -0
- package/dist/helper/axle-spread.helper.d.ts +1 -1
- package/dist/helper/axle-spread.helper.js +14 -2
- package/dist/helper/bridge-calculation.helper.d.ts +2 -2
- package/dist/helper/bridge-calculation.helper.js +52 -21
- package/dist/helper/dimensions.helper.d.ts +5 -0
- package/dist/helper/dimensions.helper.js +10 -0
- package/dist/helper/facts.helper.js +11 -0
- package/dist/helper/interaxle-spacing.helper.d.ts +1 -3
- package/dist/helper/interaxle-spacing.helper.js +17 -13
- package/dist/helper/policy-check.helper.d.ts +2 -2
- package/dist/helper/policy-check.helper.js +8 -16
- package/dist/policy-engine.d.ts +2 -2
- package/dist/policy-engine.js +3 -3
- package/dist/types/axle-unit-type.d.ts +1 -0
- package/dist/types/axle-unit-type.js +10 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/enum/facts.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare enum CostFacts {
|
|
|
17
17
|
CostPerKilometre = "costPerKilometre",
|
|
18
18
|
CostPerMonth = "costPerMonth",
|
|
19
19
|
FixedCost = "fixedCost",
|
|
20
|
+
OverloadAxleCost = "overloadAxleCost",
|
|
20
21
|
OverloadGvwCost = "overloadGvwCost",
|
|
21
22
|
OverloadWeightCost = "overloadWeightCost",
|
|
22
23
|
RangeMatrixCostLookup = "rangeMatrixCostLookup"
|
package/dist/enum/facts.js
CHANGED
|
@@ -22,6 +22,7 @@ var CostFacts;
|
|
|
22
22
|
CostFacts["CostPerKilometre"] = "costPerKilometre";
|
|
23
23
|
CostFacts["CostPerMonth"] = "costPerMonth";
|
|
24
24
|
CostFacts["FixedCost"] = "fixedCost";
|
|
25
|
+
CostFacts["OverloadAxleCost"] = "overloadAxleCost";
|
|
25
26
|
CostFacts["OverloadGvwCost"] = "overloadGvwCost";
|
|
26
27
|
CostFacts["OverloadWeightCost"] = "overloadWeightCost";
|
|
27
28
|
CostFacts["RangeMatrixCostLookup"] = "rangeMatrixCostLookup";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxleConfiguration } from '../types/axle-configuration';
|
|
2
|
-
export declare function getTandemAxleSpreadThreshold(vehicleConfiguration: Array<string>, vehicleIndex: number): {
|
|
2
|
+
export declare function getTandemAxleSpreadThreshold(vehicleConfiguration: Array<string>, vehicleIndex: number, axleConfiguration: Array<AxleConfiguration>, axleIndex: number): {
|
|
3
3
|
minCm: number;
|
|
4
4
|
maxCm: number;
|
|
5
5
|
};
|
|
@@ -7,15 +7,27 @@ const axle_spread_legal_limits_1 = require("../constants/axle-spread-legal-limit
|
|
|
7
7
|
const power_unit_codes_1 = require("../constants/power-unit-codes");
|
|
8
8
|
const semi_trailer_codes_1 = require("../constants/semi-trailer-codes");
|
|
9
9
|
const trailer_codes_1 = require("../constants/trailer-codes");
|
|
10
|
-
function getTandemAxleSpreadThreshold(vehicleConfiguration, vehicleIndex) {
|
|
10
|
+
function getTandemAxleSpreadThreshold(vehicleConfiguration, vehicleIndex, axleConfiguration, axleIndex) {
|
|
11
11
|
const vehicleType = vehicleConfiguration[vehicleIndex];
|
|
12
12
|
const isSpreadTandemSemiTrailer = vehicleType === trailer_codes_1.TRAILER_CODES.SEMI_TRAILERS_SPREAD_TANDEMS;
|
|
13
|
+
const isDriveAxle = axleIndex === 1;
|
|
14
|
+
const hasSingleAxleJeep = vehicleConfiguration[1] === trailer_codes_1.TRAILER_CODES.JEEPS &&
|
|
15
|
+
axleConfiguration[2].numberOfAxles === 1;
|
|
13
16
|
if (isSpreadTandemSemiTrailer) {
|
|
14
17
|
return {
|
|
15
18
|
minCm: axle_spread_legal_limits_1.AXLE_SPREAD_LEGAL_LIMITS.TANDEM.SPREAD_TANDEM_SEMI_TRAILER.MINIMUM,
|
|
16
19
|
maxCm: axle_spread_legal_limits_1.AXLE_SPREAD_LEGAL_LIMITS.TANDEM.SPREAD_TANDEM_SEMI_TRAILER.MAXIMUM,
|
|
17
20
|
};
|
|
18
21
|
}
|
|
22
|
+
// Tandem Drive with Single Axle Jeep Bridge Formula Exception
|
|
23
|
+
if (isDriveAxle && hasSingleAxleJeep) {
|
|
24
|
+
return {
|
|
25
|
+
minCm: axle_spread_legal_limits_1.AXLE_SPREAD_LEGAL_LIMITS.TANDEM.DRIVE_AXLE_WITH_SINGLE_AXLE_JEEP
|
|
26
|
+
.MINIMUM,
|
|
27
|
+
maxCm: axle_spread_legal_limits_1.AXLE_SPREAD_LEGAL_LIMITS.TANDEM.DRIVE_AXLE_WITH_SINGLE_AXLE_JEEP
|
|
28
|
+
.MAXIMUM,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
19
31
|
return {
|
|
20
32
|
minCm: axle_spread_legal_limits_1.AXLE_SPREAD_LEGAL_LIMITS.TANDEM.MINIMUM,
|
|
21
33
|
maxCm: axle_spread_legal_limits_1.AXLE_SPREAD_LEGAL_LIMITS.TANDEM.MAXIMUM,
|
|
@@ -76,7 +88,7 @@ function getAxleSpreadThreshold(vehicleConfiguration, axleUnitVehicleIndexes, ax
|
|
|
76
88
|
};
|
|
77
89
|
}
|
|
78
90
|
if (isTandemAxle) {
|
|
79
|
-
return getTandemAxleSpreadThreshold(vehicleConfiguration, vehicleIndex);
|
|
91
|
+
return getTandemAxleSpreadThreshold(vehicleConfiguration, vehicleIndex, axleConfiguration, axleIndex);
|
|
80
92
|
}
|
|
81
93
|
if (isTridemAxle) {
|
|
82
94
|
return getTridemAxleSpreadThreshold(vehicleConfiguration, vehicleIndex, axleConfiguration, axleIndex);
|
|
@@ -5,9 +5,9 @@ import { Policy } from 'onroute-policy-engine';
|
|
|
5
5
|
* Evaluates the weight against all possible axle group combinations and returns
|
|
6
6
|
* the result of each group comparison, with an indicator of whether or not the
|
|
7
7
|
* axle group failed the bridge calculation.
|
|
8
|
-
* @param
|
|
8
|
+
* @param axleConfiguration Vehicle dimensions and weights per axle
|
|
9
9
|
* @param policy Policy Enging object initialized with policy config
|
|
10
10
|
* @returns Array of BridgeCalculationResult objects, one for each
|
|
11
11
|
* axle group in the vehicle configuration
|
|
12
12
|
*/
|
|
13
|
-
export declare function runBridgeFormula(
|
|
13
|
+
export declare function runBridgeFormula(policy: Policy, axleConfiguration: Array<AxleConfiguration>, vehicleConfiguration: Array<string>): Array<BridgeCalculationResult>;
|
|
@@ -1,42 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runBridgeFormula = runBridgeFormula;
|
|
4
|
+
const trailer_codes_1 = require("../constants/trailer-codes");
|
|
5
|
+
const axle_unit_type_1 = require("../types/axle-unit-type");
|
|
4
6
|
/**
|
|
5
7
|
* Runs the bridge formula against the supplied vehicle axle configuration.
|
|
6
8
|
* Evaluates the weight against all possible axle group combinations and returns
|
|
7
9
|
* the result of each group comparison, with an indicator of whether or not the
|
|
8
10
|
* axle group failed the bridge calculation.
|
|
9
|
-
* @param
|
|
11
|
+
* @param axleConfiguration Vehicle dimensions and weights per axle
|
|
10
12
|
* @param policy Policy Enging object initialized with policy config
|
|
11
13
|
* @returns Array of BridgeCalculationResult objects, one for each
|
|
12
14
|
* axle group in the vehicle configuration
|
|
13
15
|
*/
|
|
14
|
-
function runBridgeFormula(
|
|
16
|
+
function runBridgeFormula(policy, axleConfiguration, vehicleConfiguration) {
|
|
15
17
|
const BRIDGE_MULTIPLIER = policy.policyDefinition.bridgeCalculationConstants.multiplier;
|
|
16
18
|
const BRIDGE_MIN_WEIGHT = policy.policyDefinition.bridgeCalculationConstants.minWeight;
|
|
17
19
|
const results = [];
|
|
18
20
|
let index = 0;
|
|
19
|
-
if (!
|
|
21
|
+
if (!axleConfiguration || axleConfiguration.length < 2) {
|
|
20
22
|
throw new Error('Invalid axle configuration, bridge formula requires a minimum of two axle units');
|
|
21
23
|
}
|
|
22
24
|
// Loop through each axle unit in the configuration, and
|
|
23
25
|
// calculate the bridge formula for each other axle unit. The
|
|
24
26
|
// number of axle groups calculated will be the Nth triangular
|
|
25
27
|
// number, where N = (number of axle units) - 1.
|
|
26
|
-
|
|
28
|
+
axleConfiguration.forEach((axle) => {
|
|
27
29
|
var _a;
|
|
28
30
|
// Do not process once we reach the last axle unit
|
|
29
31
|
// in the configuration, as they have all been calculated
|
|
30
32
|
// by then.
|
|
31
|
-
if (index <=
|
|
33
|
+
if (index <= axleConfiguration.length) {
|
|
32
34
|
// Initialize the variables for our start axle
|
|
33
|
-
const
|
|
34
|
-
let
|
|
35
|
+
const currentAxleIdex = index + 1;
|
|
36
|
+
let nextAxleIndex = currentAxleIdex + 1;
|
|
35
37
|
if (!axle.numberOfAxles || axle.numberOfAxles < 0) {
|
|
36
|
-
throw new Error(`Invalid or missing number of axles for axle unit number ${
|
|
38
|
+
throw new Error(`Invalid or missing number of axles for axle unit number ${currentAxleIdex}`);
|
|
37
39
|
}
|
|
38
40
|
if (!axle.axleUnitWeight || axle.axleUnitWeight < 0) {
|
|
39
|
-
throw new Error(`Invalid or missing weight for axle unit number ${
|
|
41
|
+
throw new Error(`Invalid or missing weight for axle unit number ${currentAxleIdex}`);
|
|
40
42
|
}
|
|
41
43
|
let totalWeight = axle.axleUnitWeight;
|
|
42
44
|
// Spread may be zero or undefined if the axle unit
|
|
@@ -45,7 +47,7 @@ function runBridgeFormula(axleConfig, policy) {
|
|
|
45
47
|
// since it describes the spacing from the previous axle
|
|
46
48
|
// unit in the configuration.
|
|
47
49
|
if (axle.numberOfAxles > 1 && (!axle.axleSpread || axle.axleSpread < 0)) {
|
|
48
|
-
throw new Error(`Invalid or missing axle spread for axle unit number ${
|
|
50
|
+
throw new Error(`Invalid or missing axle spread for axle unit number ${currentAxleIdex}`);
|
|
49
51
|
}
|
|
50
52
|
if (axle.numberOfAxles == 1 && axle.axleSpread && axle.axleSpread < 0) {
|
|
51
53
|
throw new Error(`Invalid axle spread for single axle unit, cannot be a negative number`);
|
|
@@ -53,32 +55,61 @@ function runBridgeFormula(axleConfig, policy) {
|
|
|
53
55
|
let wheelbase = (_a = axle.axleSpread) !== null && _a !== void 0 ? _a : 0;
|
|
54
56
|
// Now loop through all of the next axles, building up a group
|
|
55
57
|
// for each.
|
|
56
|
-
|
|
57
|
-
var _a;
|
|
58
|
+
axleConfiguration.slice(currentAxleIdex).forEach((axleN) => {
|
|
59
|
+
var _a, _b, _c, _d;
|
|
60
|
+
var _e, _f, _g;
|
|
58
61
|
if (!axleN.axleUnitWeight || axleN.axleUnitWeight < 0) {
|
|
59
|
-
throw new Error(`Invalid or missing weight for axle unit number ${
|
|
62
|
+
throw new Error(`Invalid or missing weight for axle unit number ${nextAxleIndex}`);
|
|
60
63
|
}
|
|
61
64
|
totalWeight += axleN.axleUnitWeight;
|
|
62
65
|
if (axleN.numberOfAxles > 1 &&
|
|
63
66
|
(!axleN.axleSpread || axleN.axleSpread < 0)) {
|
|
64
|
-
throw new Error(`Invalid or missing axle spread for axle unit number ${
|
|
67
|
+
throw new Error(`Invalid or missing axle spread for axle unit number ${nextAxleIndex}`);
|
|
65
68
|
}
|
|
66
69
|
if (!axleN.interaxleSpacing || axleN.interaxleSpacing < 0) {
|
|
67
|
-
throw new Error(`Invalid or missing axle spacing between axle units ${
|
|
70
|
+
throw new Error(`Invalid or missing axle spacing between axle units ${currentAxleIdex} and ${nextAxleIndex}`);
|
|
71
|
+
}
|
|
72
|
+
wheelbase += ((_e = axleN.axleSpread) !== null && _e !== void 0 ? _e : 0) + axleN.interaxleSpacing;
|
|
73
|
+
// Tandem Drive with Single Axle Jeep Bridge Formula Exception
|
|
74
|
+
const hasSingleAxleJeep = vehicleConfiguration[1] === trailer_codes_1.TRAILER_CODES.JEEPS &&
|
|
75
|
+
(0, axle_unit_type_1.getAxleUnitType)((_a = axleConfiguration[2]) === null || _a === void 0 ? void 0 : _a.numberOfAxles) === 'SINGLE';
|
|
76
|
+
const hasTandemDrive = (0, axle_unit_type_1.getAxleUnitType)((_b = axleConfiguration[1]) === null || _b === void 0 ? void 0 : _b.numberOfAxles) === 'TANDEM';
|
|
77
|
+
const driveAxleSpread = (_f = (_c = axleConfiguration[1]) === null || _c === void 0 ? void 0 : _c.axleSpread) !== null && _f !== void 0 ? _f : 0;
|
|
78
|
+
const isDriveAxle = currentAxleIdex === 1;
|
|
79
|
+
const isJeepAxle = hasSingleAxleJeep && currentAxleIdex === 2;
|
|
80
|
+
const firstTrailerInteraxleSpacing = (_g = (_d = axleConfiguration[2]) === null || _d === void 0 ? void 0 : _d.interaxleSpacing) !== null && _g !== void 0 ? _g : 0;
|
|
81
|
+
const isTandemDriveSingleAxleJeepException = (isDriveAxle || isJeepAxle) && hasTandemDrive && hasSingleAxleJeep;
|
|
82
|
+
const isLowerTandemDriveSingleAxleJeepException = isTandemDriveSingleAxleJeepException &&
|
|
83
|
+
driveAxleSpread >= 240 &&
|
|
84
|
+
driveAxleSpread <= 300 &&
|
|
85
|
+
firstTrailerInteraxleSpacing >= 120 &&
|
|
86
|
+
firstTrailerInteraxleSpacing <= 300;
|
|
87
|
+
const isUpperTandemDriveSingleAxleJeepException = isTandemDriveSingleAxleJeepException &&
|
|
88
|
+
driveAxleSpread > 300 &&
|
|
89
|
+
driveAxleSpread <= 370 &&
|
|
90
|
+
firstTrailerInteraxleSpacing > 300 &&
|
|
91
|
+
firstTrailerInteraxleSpacing <= 350;
|
|
92
|
+
// Calculate standard bridge formula result
|
|
93
|
+
const formulaMaxBridge = BRIDGE_MULTIPLIER * wheelbase + BRIDGE_MIN_WEIGHT;
|
|
94
|
+
// Apply the Tandem Drive + Single Axle Jeep policy exception only when
|
|
95
|
+
// it increases the permitted weight (i.e. it's an allowance override).
|
|
96
|
+
let maxBridge = formulaMaxBridge;
|
|
97
|
+
if (isLowerTandemDriveSingleAxleJeepException) {
|
|
98
|
+
maxBridge = Math.max(formulaMaxBridge, 28000);
|
|
99
|
+
}
|
|
100
|
+
else if (isUpperTandemDriveSingleAxleJeepException) {
|
|
101
|
+
maxBridge = Math.max(formulaMaxBridge, 29000);
|
|
68
102
|
}
|
|
69
|
-
wheelbase += ((_a = axleN.axleSpread) !== null && _a !== void 0 ? _a : 0) + axleN.interaxleSpacing;
|
|
70
|
-
// The magic is in the next line
|
|
71
|
-
const maxBridge = BRIDGE_MULTIPLIER * wheelbase + BRIDGE_MIN_WEIGHT;
|
|
72
103
|
// Push the axle group result to the results array, including
|
|
73
104
|
// a convenience success indicator.
|
|
74
105
|
results.push({
|
|
75
|
-
startAxleUnit:
|
|
76
|
-
endAxleUnit:
|
|
106
|
+
startAxleUnit: currentAxleIdex,
|
|
107
|
+
endAxleUnit: nextAxleIndex,
|
|
77
108
|
maxBridge: maxBridge,
|
|
78
109
|
actualWeight: totalWeight,
|
|
79
110
|
success: totalWeight <= maxBridge,
|
|
80
111
|
});
|
|
81
|
-
|
|
112
|
+
nextAxleIndex++;
|
|
82
113
|
});
|
|
83
114
|
}
|
|
84
115
|
index++;
|
|
@@ -114,3 +114,8 @@ export declare function getVehicleRelatives(policy: Policy, configuration: Array
|
|
|
114
114
|
* // Returns [0, 0, 1, 1]
|
|
115
115
|
*/
|
|
116
116
|
export declare function getAxleUnitVehicleIndexes(policy: Policy, configuration: Array<string>, axleConfiguration: Array<AxleConfiguration>): Array<number>;
|
|
117
|
+
/**
|
|
118
|
+
* Returns an array of vehicle indexes for each axle unit.
|
|
119
|
+
* Each entry maps an axle unit to the vehicle in vehicleConfiguration that it belongs to.
|
|
120
|
+
*/
|
|
121
|
+
export declare function getAxleUnitVehicleIndexLookup(policy: Policy, vehicleConfiguration: Array<string>, axleConfiguration: Array<AxleConfiguration>): Array<number>;
|
|
@@ -7,6 +7,7 @@ exports.getDefaultTrailerWeightHelper = getDefaultTrailerWeightHelper;
|
|
|
7
7
|
exports.selectCorrectWeightDimensionHelper = selectCorrectWeightDimensionHelper;
|
|
8
8
|
exports.getVehicleRelatives = getVehicleRelatives;
|
|
9
9
|
exports.getAxleUnitVehicleIndexes = getAxleUnitVehicleIndexes;
|
|
10
|
+
exports.getAxleUnitVehicleIndexLookup = getAxleUnitVehicleIndexLookup;
|
|
10
11
|
const enum_1 = require("onroute-policy-engine/enum");
|
|
11
12
|
/**
|
|
12
13
|
* Gets the maximum size dimensions for a given permit type, commodity,
|
|
@@ -554,6 +555,15 @@ function getAxleUnitVehicleIndexes(policy, configuration, axleConfiguration) {
|
|
|
554
555
|
}
|
|
555
556
|
return axleUnitVehicleIndexes;
|
|
556
557
|
}
|
|
558
|
+
/**
|
|
559
|
+
* Returns an array of vehicle indexes for each axle unit.
|
|
560
|
+
* Each entry maps an axle unit to the vehicle in vehicleConfiguration that it belongs to.
|
|
561
|
+
*/
|
|
562
|
+
function getAxleUnitVehicleIndexLookup(policy, vehicleConfiguration, axleConfiguration) {
|
|
563
|
+
return axleConfiguration.some((axleUnit) => axleUnit.vehicleIndex !== undefined)
|
|
564
|
+
? getAxleUnitVehicleIndexes(policy, vehicleConfiguration, axleConfiguration)
|
|
565
|
+
: axleConfiguration.map((_, axleIndex) => axleIndex < 2 ? 0 : axleIndex - 1);
|
|
566
|
+
}
|
|
557
567
|
/**
|
|
558
568
|
* Walks along the vehicle configuration from the start index
|
|
559
569
|
* in the direction indicated by increment, which will typically
|
|
@@ -339,6 +339,17 @@ function addRuntimeFacts(engine, policy) {
|
|
|
339
339
|
}
|
|
340
340
|
return getOverloadCost(overloadKg, distance);
|
|
341
341
|
});
|
|
342
|
+
/**
|
|
343
|
+
* Calculate the STOW fee from the same selected overload used by OCD.
|
|
344
|
+
*/
|
|
345
|
+
engine.addFact(enum_1.CostFacts.OverloadAxleCost.toString(), async function (params, almanac) {
|
|
346
|
+
const axleResults = await almanac.factValue(stgvwi_1.AXLE_CALC_RESULTS_FACT);
|
|
347
|
+
const totalDistance = await almanac.factValue(enum_1.PermitAppInfo.PermitData, {}, enum_1.PermitAppInfo.TotalDistance);
|
|
348
|
+
if (!totalDistance) {
|
|
349
|
+
return 0;
|
|
350
|
+
}
|
|
351
|
+
return getOverloadCost(axleResults.overload, totalDistance);
|
|
352
|
+
});
|
|
342
353
|
/**
|
|
343
354
|
* Add runtime fact to calculate the overload fee for STWSE permits
|
|
344
355
|
* based on the Weight over 27.5m and Total Distance.
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { INTERAXLE_SPACING_LEGAL_MINIMUMS } from '../constants/interaxle-spacing-legal-minimums';
|
|
2
1
|
import { AxleConfiguration } from '../types/axle-configuration';
|
|
3
2
|
import { InteraxleSpacingRequirement } from '../types/interaxle-spacing-requirement';
|
|
4
|
-
export declare function getAxleUnitType(numberOfAxles: number): keyof typeof INTERAXLE_SPACING_LEGAL_MINIMUMS;
|
|
5
3
|
export declare function getFailedInteraxleSpacingMessage(requirement: InteraxleSpacingRequirement, previousAxleUnitNumber: number, currentAxleUnitNumber: number): string;
|
|
6
|
-
export declare function getInteraxleSpacingRequirement(axleConfiguration: Array<AxleConfiguration>, axleIndex: number): InteraxleSpacingRequirement | undefined;
|
|
4
|
+
export declare function getInteraxleSpacingRequirement(axleConfiguration: Array<AxleConfiguration>, axleIndex: number, vehicleConfiguration: Array<string>, axleUnitVehicleIndexes: Array<number>): InteraxleSpacingRequirement | undefined;
|
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAxleUnitType = getAxleUnitType;
|
|
4
3
|
exports.getFailedInteraxleSpacingMessage = getFailedInteraxleSpacingMessage;
|
|
5
4
|
exports.getInteraxleSpacingRequirement = getInteraxleSpacingRequirement;
|
|
6
5
|
const interaxle_spacing_legal_minimums_1 = require("../constants/interaxle-spacing-legal-minimums");
|
|
6
|
+
const trailer_codes_1 = require("../constants/trailer-codes");
|
|
7
|
+
const axle_unit_type_1 = require("../types/axle-unit-type");
|
|
7
8
|
const format_meters_helper_1 = require("./format-meters.helper");
|
|
8
|
-
function getAxleUnitType(numberOfAxles) {
|
|
9
|
-
if (numberOfAxles === 1) {
|
|
10
|
-
return 'SINGLE';
|
|
11
|
-
}
|
|
12
|
-
if (numberOfAxles === 2) {
|
|
13
|
-
return 'TANDEM';
|
|
14
|
-
}
|
|
15
|
-
return 'TRIDEM';
|
|
16
|
-
}
|
|
17
9
|
function getFailedInteraxleSpacingMessage(requirement, previousAxleUnitNumber, currentAxleUnitNumber) {
|
|
18
10
|
if (requirement.groupLabel) {
|
|
19
11
|
if (requirement.min && requirement.max) {
|
|
@@ -31,7 +23,7 @@ function getFailedInteraxleSpacingMessage(requirement, previousAxleUnitNumber, c
|
|
|
31
23
|
}
|
|
32
24
|
return '';
|
|
33
25
|
}
|
|
34
|
-
function getInteraxleSpacingRequirement(axleConfiguration, axleIndex) {
|
|
26
|
+
function getInteraxleSpacingRequirement(axleConfiguration, axleIndex, vehicleConfiguration, axleUnitVehicleIndexes) {
|
|
35
27
|
// the first axle unit will never have an interaxle spacing value or previous axle unit to compare against
|
|
36
28
|
if (axleIndex === 0) {
|
|
37
29
|
return undefined;
|
|
@@ -42,8 +34,20 @@ function getInteraxleSpacingRequirement(axleConfiguration, axleIndex) {
|
|
|
42
34
|
!Number.isFinite(previousAxleUnit.numberOfAxles)) {
|
|
43
35
|
return undefined;
|
|
44
36
|
}
|
|
45
|
-
const previousAxleUnitType = getAxleUnitType(previousAxleUnit.numberOfAxles);
|
|
46
|
-
const currentAxleUnitType = getAxleUnitType(axleUnit.numberOfAxles);
|
|
37
|
+
const previousAxleUnitType = (0, axle_unit_type_1.getAxleUnitType)(previousAxleUnit.numberOfAxles);
|
|
38
|
+
const currentAxleUnitType = (0, axle_unit_type_1.getAxleUnitType)(axleUnit.numberOfAxles);
|
|
39
|
+
const vehicleIndex = axleUnitVehicleIndexes[axleIndex];
|
|
40
|
+
const vehicleType = vehicleConfiguration[vehicleIndex];
|
|
41
|
+
const isSingleAxleJeep = vehicleType === trailer_codes_1.TRAILER_CODES.JEEPS &&
|
|
42
|
+
(0, axle_unit_type_1.getAxleUnitType)(axleConfiguration[2].numberOfAxles) === 'SINGLE';
|
|
43
|
+
const isTandemDrive = (0, axle_unit_type_1.getAxleUnitType)(axleConfiguration[1].numberOfAxles) === 'TANDEM';
|
|
44
|
+
// Tandem Drive with Single Axle Jeep Bridge Formula Exception
|
|
45
|
+
if (isSingleAxleJeep && isTandemDrive) {
|
|
46
|
+
return {
|
|
47
|
+
min: 120,
|
|
48
|
+
max: 350,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
47
51
|
return {
|
|
48
52
|
min: interaxle_spacing_legal_minimums_1.INTERAXLE_SPACING_LEGAL_MINIMUMS[previousAxleUnitType][currentAxleUnitType],
|
|
49
53
|
};
|
|
@@ -68,7 +68,7 @@ export declare function CheckNumberOfAxles(_policy: Policy, _vehicleConfiguratio
|
|
|
68
68
|
* @see AxleGroupPolicyCheckResult
|
|
69
69
|
* @see BridgeCalculationResult
|
|
70
70
|
*/
|
|
71
|
-
export declare function CheckBridgeFormula(policy: Policy,
|
|
71
|
+
export declare function CheckBridgeFormula(policy: Policy, vehicleConfiguration: Array<string>, axleConfiguration: Array<AxleConfiguration>): Array<PolicyCheckResult>;
|
|
72
72
|
/**
|
|
73
73
|
* Validates the number of tires per axle unit against regulatory requirements.
|
|
74
74
|
*
|
|
@@ -302,7 +302,7 @@ export declare function CheckDriveJeepLoadEqualization(_policy: Policy, vehicleC
|
|
|
302
302
|
* Validates each axle unit against the minimum interaxle spacing for its
|
|
303
303
|
* current axle unit and the next axle unit, per Table II.
|
|
304
304
|
*/
|
|
305
|
-
export declare function CheckLegalInteraxleSpacing(
|
|
305
|
+
export declare function CheckLegalInteraxleSpacing(policy: Policy, vehicleConfiguration: Array<string>, axleConfiguration: Array<AxleConfiguration>): Array<PolicyCheckResult>;
|
|
306
306
|
/**
|
|
307
307
|
* Validates each axle unit against its legal axle spread maximum.
|
|
308
308
|
*/
|
|
@@ -53,15 +53,6 @@ function getApplicableLegalWeightThreshold(policy, vehicleConfiguration, axleCon
|
|
|
53
53
|
}
|
|
54
54
|
return (_a = policy.selectCorrectWeightDimension(weights, vehicleConfiguration, axleConfiguration, axleIndex)) === null || _a === void 0 ? void 0 : _a.legal;
|
|
55
55
|
}
|
|
56
|
-
/**
|
|
57
|
-
* Returns an array of vehicle indexes for each axle unit.
|
|
58
|
-
* Each entry maps an axle unit to the vehicle in vehicleConfiguration that it belongs to.
|
|
59
|
-
*/
|
|
60
|
-
function getAxleUnitVehicleIndexLookup(policy, vehicleConfiguration, axleConfiguration) {
|
|
61
|
-
return axleConfiguration.some((axleUnit) => axleUnit.vehicleIndex !== undefined)
|
|
62
|
-
? (0, dimensions_helper_1.getAxleUnitVehicleIndexes)(policy, vehicleConfiguration, axleConfiguration)
|
|
63
|
-
: axleConfiguration.map((_, axleIndex) => axleIndex < 2 ? 0 : axleIndex - 1);
|
|
64
|
-
}
|
|
65
56
|
function getConfiguredAxleUnitWeightThreshold(policy, vehicleConfiguration, axleConfiguration, axleUnitVehicleIndexes, axleIndex, threshold) {
|
|
66
57
|
var _a;
|
|
67
58
|
var _b;
|
|
@@ -131,7 +122,7 @@ function getFeatureLegalPowerUnitWeightThreshold(vehicleType, axleConfiguration,
|
|
|
131
122
|
function CheckLegalWeight(policy, vehicleConfiguration, axleConfiguration) {
|
|
132
123
|
const policyId = enum_1.PolicyCheckId.LegalWeight;
|
|
133
124
|
const powerUnitType = vehicleConfiguration[0];
|
|
134
|
-
const axleUnitVehicleIndexes = getAxleUnitVehicleIndexLookup(policy, vehicleConfiguration, axleConfiguration);
|
|
125
|
+
const axleUnitVehicleIndexes = (0, dimensions_helper_1.getAxleUnitVehicleIndexLookup)(policy, vehicleConfiguration, axleConfiguration);
|
|
135
126
|
return axleConfiguration.map((axleUnit, axleIndex) => {
|
|
136
127
|
const featureThreshold = axleUnitVehicleIndexes[axleIndex] === 0 &&
|
|
137
128
|
isFeatureLegalWeightPowerUnit(powerUnitType)
|
|
@@ -342,14 +333,14 @@ function getBridgeFormulaInputFailure(axleConfiguration) {
|
|
|
342
333
|
* @see AxleGroupPolicyCheckResult
|
|
343
334
|
* @see BridgeCalculationResult
|
|
344
335
|
*/
|
|
345
|
-
function CheckBridgeFormula(policy,
|
|
336
|
+
function CheckBridgeFormula(policy, vehicleConfiguration, axleConfiguration) {
|
|
346
337
|
const policyCheckResults = new Array();
|
|
347
338
|
const policyId = enum_1.PolicyCheckId.BridgeFormula;
|
|
348
339
|
const inputFailure = getBridgeFormulaInputFailure(axleConfiguration);
|
|
349
340
|
if (inputFailure) {
|
|
350
341
|
return [inputFailure];
|
|
351
342
|
}
|
|
352
|
-
const bridgeCalcResults = policy.calculateBridge(axleConfiguration);
|
|
343
|
+
const bridgeCalcResults = policy.calculateBridge(axleConfiguration, vehicleConfiguration);
|
|
353
344
|
bridgeCalcResults.forEach((br) => {
|
|
354
345
|
const message = `Axle group ${br.startAxleUnit} to ${br.endAxleUnit} ${br.success ? 'passes' : 'does not pass'} bridge formula.`;
|
|
355
346
|
policyCheckResults.push({
|
|
@@ -487,7 +478,7 @@ function CheckNumTiresPerAxle(_policy, _vehicleConfiguration, axleConfiguration)
|
|
|
487
478
|
*/
|
|
488
479
|
function CheckPermittableWeight(policy, vehicleConfiguration, axleConfiguration) {
|
|
489
480
|
const policyId = enum_1.PolicyCheckId.PermittableWeight;
|
|
490
|
-
const axleUnitVehicleIndexes = getAxleUnitVehicleIndexLookup(policy, vehicleConfiguration, axleConfiguration);
|
|
481
|
+
const axleUnitVehicleIndexes = (0, dimensions_helper_1.getAxleUnitVehicleIndexLookup)(policy, vehicleConfiguration, axleConfiguration);
|
|
491
482
|
const QUALIFYING_TRIDEM_SPREAD_CM = {
|
|
492
483
|
MINIMUM: 240,
|
|
493
484
|
MAXIMUM: 370,
|
|
@@ -1227,10 +1218,11 @@ function CheckDriveJeepLoadEqualization(_policy, vehicleConfiguration, axleConfi
|
|
|
1227
1218
|
* Validates each axle unit against the minimum interaxle spacing for its
|
|
1228
1219
|
* current axle unit and the next axle unit, per Table II.
|
|
1229
1220
|
*/
|
|
1230
|
-
function CheckLegalInteraxleSpacing(
|
|
1221
|
+
function CheckLegalInteraxleSpacing(policy, vehicleConfiguration, axleConfiguration) {
|
|
1231
1222
|
const policyId = enum_1.PolicyCheckId.LegalInteraxleSpacing;
|
|
1223
|
+
const axleUnitVehicleIndexes = (0, dimensions_helper_1.getAxleUnitVehicleIndexLookup)(policy, vehicleConfiguration, axleConfiguration);
|
|
1232
1224
|
return axleConfiguration.map((axleUnit, axleIndex) => {
|
|
1233
|
-
const requirement = (0, interaxle_spacing_helper_1.getInteraxleSpacingRequirement)(axleConfiguration, axleIndex);
|
|
1225
|
+
const requirement = (0, interaxle_spacing_helper_1.getInteraxleSpacingRequirement)(axleConfiguration, axleIndex, vehicleConfiguration, axleUnitVehicleIndexes);
|
|
1234
1226
|
// Pass when no requirement exists, interaxle spacing is missing, or interaxle spacing falls within the requirement's min/max bounds.
|
|
1235
1227
|
const shouldPass = !requirement ||
|
|
1236
1228
|
!axleUnit.interaxleSpacing ||
|
|
@@ -1256,7 +1248,7 @@ function CheckLegalInteraxleSpacing(_policy, _vehicleConfiguration, axleConfigur
|
|
|
1256
1248
|
*/
|
|
1257
1249
|
function CheckLegalAxleSpread(policy, vehicleConfiguration, axleConfiguration) {
|
|
1258
1250
|
const policyId = enum_1.PolicyCheckId.LegalAxleSpread;
|
|
1259
|
-
const axleUnitVehicleIndexes = getAxleUnitVehicleIndexLookup(policy, vehicleConfiguration, axleConfiguration);
|
|
1251
|
+
const axleUnitVehicleIndexes = (0, dimensions_helper_1.getAxleUnitVehicleIndexLookup)(policy, vehicleConfiguration, axleConfiguration);
|
|
1260
1252
|
return axleConfiguration.flatMap((axleUnit, axleIndex) => {
|
|
1261
1253
|
const threshold = (0, axle_spread_helper_1.getAxleSpreadThreshold)(vehicleConfiguration, axleUnitVehicleIndexes, axleConfiguration, axleIndex);
|
|
1262
1254
|
if (!axleUnit.axleSpread ||
|
package/dist/policy-engine.d.ts
CHANGED
|
@@ -181,11 +181,11 @@ export declare class Policy {
|
|
|
181
181
|
/**
|
|
182
182
|
* Convenience method of policy that delegates the bridge calculation
|
|
183
183
|
* to the helper method.
|
|
184
|
-
* @param
|
|
184
|
+
* @param axleConfiguration Vehicle dimensions and weights per axle
|
|
185
185
|
* @returns Array of BridgeCalculationResult objects, one for each
|
|
186
186
|
* axle group in the vehicle configuration
|
|
187
187
|
*/
|
|
188
|
-
calculateBridge(
|
|
188
|
+
calculateBridge(axleConfiguration: Array<AxleConfiguration>, vehicleConfiguration: Array<string>): Array<BridgeCalculationResult>;
|
|
189
189
|
/**
|
|
190
190
|
* Runs all configured axle calculation policy checks against a vehicle configuration.
|
|
191
191
|
*
|
package/dist/policy-engine.js
CHANGED
|
@@ -667,14 +667,14 @@ class Policy {
|
|
|
667
667
|
/**
|
|
668
668
|
* Convenience method of policy that delegates the bridge calculation
|
|
669
669
|
* to the helper method.
|
|
670
|
-
* @param
|
|
670
|
+
* @param axleConfiguration Vehicle dimensions and weights per axle
|
|
671
671
|
* @returns Array of BridgeCalculationResult objects, one for each
|
|
672
672
|
* axle group in the vehicle configuration
|
|
673
673
|
*/
|
|
674
|
-
calculateBridge(
|
|
674
|
+
calculateBridge(axleConfiguration, vehicleConfiguration) {
|
|
675
675
|
let bridgeResults;
|
|
676
676
|
try {
|
|
677
|
-
bridgeResults = (0, bridge_calculation_helper_1.runBridgeFormula)(
|
|
677
|
+
bridgeResults = (0, bridge_calculation_helper_1.runBridgeFormula)(this, axleConfiguration, vehicleConfiguration);
|
|
678
678
|
}
|
|
679
679
|
catch (e) {
|
|
680
680
|
console.log(`Error calculating bridge formula: ${e.message}`);
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AXLE_UNIT_TYPES = void 0;
|
|
4
|
+
exports.getAxleUnitType = getAxleUnitType;
|
|
4
5
|
exports.AXLE_UNIT_TYPES = {
|
|
5
6
|
SINGLE: 'SINGLE',
|
|
6
7
|
TANDEM: 'TANDEM',
|
|
7
8
|
TRIDEM: 'TRIDEM',
|
|
8
9
|
};
|
|
10
|
+
function getAxleUnitType(numberOfAxles) {
|
|
11
|
+
if (numberOfAxles === 1) {
|
|
12
|
+
return 'SINGLE';
|
|
13
|
+
}
|
|
14
|
+
if (numberOfAxles === 2) {
|
|
15
|
+
return 'TANDEM';
|
|
16
|
+
}
|
|
17
|
+
return 'TRIDEM';
|
|
18
|
+
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "v2.
|
|
1
|
+
export declare const version = "v2.32.0";
|
package/dist/version.js
CHANGED
package/package.json
CHANGED