onroute-policy-engine 2.12.1 → 2.14.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.
@@ -58,9 +58,9 @@ export declare function CheckBridgeFormula(policy: Policy, _vehicleConfiguration
58
58
  * Validates the number of tires per axle unit against regulatory requirements.
59
59
  *
60
60
  * This function checks that each axle unit has a valid number of tires based on
61
- * the number of axles in that unit. The validation allows for 2, 4, or 8 tires
62
- * per axle (2, 4, or 8 * number of axles). This ensures compliance with tire
63
- * count regulations for commercial vehicles.
61
+ * the number of axles in that unit and the axle unit position. Axle unit 1 is
62
+ * the steer axle unit, axle unit 2 is the drive axle unit, and axle units 3+
63
+ * use the generic axle unit allowance.
64
64
  *
65
65
  * @param _policy - The policy instance (unused in this check, but required by PolicyCheck type)
66
66
  * @param _vehicleConfiguration - Vehicle configuration (unused in this check, but required by PolicyCheck type)
@@ -70,15 +70,15 @@ export declare function CheckBridgeFormula(policy: Policy, _vehicleConfiguration
70
70
  * @example
71
71
  * // For a vehicle with 2 axle units
72
72
  * const results = CheckNumTiresPerAxle(policy, ['TRKTRAC'], [
73
- * { numberOfAxles: 2, numberOfTires: 4 }, // 2 axles × 2 tires = 4 (valid)
74
- * { numberOfAxles: 3, numberOfTires: 12 } // 3 axles × 4 tires = 12 (valid)
73
+ * { numberOfAxles: 2, numberOfTires: 4 }, // tandem steer: 4 (valid)
74
+ * { numberOfAxles: 3, numberOfTires: 12 } // tridem drive: 12 (valid)
75
75
  * ]);
76
76
  * // Returns pass results for both axle units
77
77
  *
78
78
  * @example
79
79
  * // Invalid tire count example
80
80
  * const results = CheckNumTiresPerAxle(policy, ['TRKTRAC'], [
81
- * { numberOfAxles: 2, numberOfTires: 6 } // 2 axles × 3 tires = 6 (invalid - not 2, 4, or 8 per axle)
81
+ * { numberOfAxles: 1, numberOfTires: 8 } // single drive: 8 (invalid)
82
82
  * ]);
83
83
  * // Returns fail result for the axle unit
84
84
  *
@@ -235,7 +235,7 @@ export declare function CheckMinDriveAxleWeight(_policy: Policy, _vehicleConfigu
235
235
  * @see AxleGroupPolicyCheckResult
236
236
  * @see AxleConfiguration
237
237
  */
238
- export declare function CheckMaxTireLoad(_policy: Policy, _vehicleConfiguration: Array<string>, axleConfiguration: Array<AxleConfiguration>): Array<PolicyCheckResult>;
238
+ export declare function CheckMaxTireLoad(_policy: Policy, _vehicleConfiguration: string[], axleConfiguration: AxleConfiguration[]): PolicyCheckResult[];
239
239
  /**
240
240
  * Validates that each booster has no more axles than the trailer it follows.
241
241
  *
@@ -100,9 +100,9 @@ function CheckBridgeFormula(policy, _vehicleConfiguration, axleConfiguration) {
100
100
  * Validates the number of tires per axle unit against regulatory requirements.
101
101
  *
102
102
  * This function checks that each axle unit has a valid number of tires based on
103
- * the number of axles in that unit. The validation allows for 2, 4, or 8 tires
104
- * per axle (2, 4, or 8 * number of axles). This ensures compliance with tire
105
- * count regulations for commercial vehicles.
103
+ * the number of axles in that unit and the axle unit position. Axle unit 1 is
104
+ * the steer axle unit, axle unit 2 is the drive axle unit, and axle units 3+
105
+ * use the generic axle unit allowance.
106
106
  *
107
107
  * @param _policy - The policy instance (unused in this check, but required by PolicyCheck type)
108
108
  * @param _vehicleConfiguration - Vehicle configuration (unused in this check, but required by PolicyCheck type)
@@ -112,15 +112,15 @@ function CheckBridgeFormula(policy, _vehicleConfiguration, axleConfiguration) {
112
112
  * @example
113
113
  * // For a vehicle with 2 axle units
114
114
  * const results = CheckNumTiresPerAxle(policy, ['TRKTRAC'], [
115
- * { numberOfAxles: 2, numberOfTires: 4 }, // 2 axles × 2 tires = 4 (valid)
116
- * { numberOfAxles: 3, numberOfTires: 12 } // 3 axles × 4 tires = 12 (valid)
115
+ * { numberOfAxles: 2, numberOfTires: 4 }, // tandem steer: 4 (valid)
116
+ * { numberOfAxles: 3, numberOfTires: 12 } // tridem drive: 12 (valid)
117
117
  * ]);
118
118
  * // Returns pass results for both axle units
119
119
  *
120
120
  * @example
121
121
  * // Invalid tire count example
122
122
  * const results = CheckNumTiresPerAxle(policy, ['TRKTRAC'], [
123
- * { numberOfAxles: 2, numberOfTires: 6 } // 2 axles × 3 tires = 6 (invalid - not 2, 4, or 8 per axle)
123
+ * { numberOfAxles: 1, numberOfTires: 8 } // single drive: 8 (invalid)
124
124
  * ]);
125
125
  * // Returns fail result for the axle unit
126
126
  *
@@ -143,7 +143,10 @@ function CheckNumTiresPerAxle(_policy, _vehicleConfiguration, axleConfiguration)
143
143
  message = `Number of axles for axle unit ${axleNum} is not permittable.`;
144
144
  }
145
145
  else {
146
- const checkResult = [numAxles * 2, numAxles * 4, numAxles * 8].includes(numTires);
146
+ const multipliers = axleNum === 1 ? [2] : axleNum === 2 ? [2, 4] : [2, 4, 8];
147
+ const checkResult = multipliers
148
+ .map((multiplier) => numAxles * multiplier)
149
+ .includes(numTires);
147
150
  message = checkResult
148
151
  ? `No. of Wheels for Axle Unit ${axleNum} is permittable.`
149
152
  : `No. of Wheels for Axle Unit ${axleNum} is not permittable.`;
@@ -449,85 +452,137 @@ function CheckMinDriveAxleWeight(_policy, _vehicleConfiguration, axleConfigurati
449
452
  function CheckMaxTireLoad(_policy, _vehicleConfiguration, axleConfiguration) {
450
453
  const policyCheckResults = new Array();
451
454
  const policyId = enum_1.PolicyCheckId.MaxTireLoad;
452
- // Steer axle tire load check
453
- const steerTireSize = axleConfiguration[0].tireSize;
454
- if (!steerTireSize) {
455
+ const powerUnitType = _vehicleConfiguration[0];
456
+ const isRubberTiredLoader = powerUnitType === 'RBTRLDR';
457
+ const isAllTerrainCrane = powerUnitType === 'CRANEAT';
458
+ const isMobileCrane = powerUnitType === 'CRANEMB';
459
+ const addFailResult = (axleUnit) => {
455
460
  policyCheckResults.push({
456
461
  id: policyId,
457
462
  result: enum_1.PolicyCheckResultType.Fail,
458
- message: `Steer axle tire size is invalid`,
459
- axleUnit: 1,
463
+ message: `Tire Size for Axle Unit ${axleUnit} exceeds its load capacity.`,
464
+ axleUnit,
460
465
  });
461
- }
462
- else if (steerTireSize > 455) {
463
- policyCheckResults.push({
464
- id: policyId,
465
- result: enum_1.PolicyCheckResultType.Fail,
466
- message: `Steer axle tire size must not exceed 455mm`,
467
- axleUnit: 1,
468
- });
469
- }
470
- else if (steerTireSize >= 445) {
471
- if (axleConfiguration[0].axleUnitWeight > 9100) {
472
- policyCheckResults.push({
473
- id: policyId,
474
- result: enum_1.PolicyCheckResultType.Fail,
475
- message: `Steer axle weight exceeds maximum of 9100kg for ${steerTireSize}mm tire size`,
476
- axleUnit: 1,
477
- });
478
- }
479
- }
480
- else {
481
- const maxWeightOnSteerAxle = (axleConfiguration[0].numberOfTires || 0) * (steerTireSize * 10);
482
- if (axleConfiguration[0].axleUnitWeight > maxWeightOnSteerAxle) {
483
- policyCheckResults.push({
484
- id: policyId,
485
- result: enum_1.PolicyCheckResultType.Fail,
486
- message: `Steer axle weight exceeds maximum of ${maxWeightOnSteerAxle}kg for ${steerTireSize}mm tire size`,
487
- axleUnit: 1,
488
- });
489
- }
490
- }
491
- // Non-steer axle tire load checks
492
- axleConfiguration.slice(1).forEach((a, i) => {
493
- const tireSize = a.tireSize;
494
- const numberOfTires = a.numberOfTires;
495
- const axleUnitNum = i + 2;
496
- let maxWeight = 0;
466
+ };
467
+ /**
468
+ * Both the kg/cm rate and the explicit axle cap apply for all axle types.
469
+ * The lower of the two is the binding limit:
470
+ * maxAllowedWeight = min((tireSize / 10) * rateKgPerCm * numberOfTires, capWeight)
471
+ *
472
+ * When capWeight is omitted, only the rate applies.
473
+ */
474
+ const exceedsRateOrCapLimit = (axleWeight, tireSize, numberOfTires, rateKgPerCm, capWeight) => {
475
+ const rateLimitWeight = (tireSize / 10) * rateKgPerCm * numberOfTires;
476
+ const maxAllowedWeight = capWeight !== undefined
477
+ ? Math.min(rateLimitWeight, capWeight)
478
+ : rateLimitWeight;
479
+ return axleWeight > maxAllowedWeight;
480
+ };
481
+ axleConfiguration.forEach((ac, index) => {
482
+ var _a, _b;
483
+ const axleUnit = index + 1;
484
+ const tireSize = ac.tireSize;
485
+ const numberOfTires = (_a = ac.numberOfTires) !== null && _a !== void 0 ? _a : 0;
486
+ const axleWeight = (_b = ac.axleUnitWeight) !== null && _b !== void 0 ? _b : 0;
497
487
  if (!tireSize) {
498
- policyCheckResults.push({
499
- id: policyId,
500
- result: enum_1.PolicyCheckResultType.Fail,
501
- message: `Axle unit ${axleUnitNum} tire size is invalid`,
502
- axleUnit: axleUnitNum,
503
- });
488
+ addFailResult(axleUnit);
489
+ return;
504
490
  }
505
- else if (!numberOfTires) {
506
- policyCheckResults.push({
507
- id: policyId,
508
- result: enum_1.PolicyCheckResultType.Fail,
509
- message: `Axle unit ${axleUnitNum} number of wheels is invalid`,
510
- axleUnit: axleUnitNum,
511
- });
491
+ if (!numberOfTires) {
492
+ addFailResult(axleUnit);
493
+ return;
512
494
  }
513
- else {
514
- if (tireSize >= 445) {
515
- maxWeight = numberOfTires * 3850;
495
+ const isSteeringAxle = index === 0;
496
+ /**
497
+ * Rubber Tired Loader
498
+ *
499
+ * All axle units — rate 110 kg/cm; lower of rate or cap is binding:
500
+ * >=600 mm => min(110 kg/cm rate, 12,000 kg/axle)
501
+ * >=520 mm => min(110 kg/cm rate, 11,000 kg/axle)
502
+ *
503
+ * For RTL the 110 kg/cm rate always yields more than the cap at these
504
+ * tire sizes (e.g. 520mm * 110 * 2 = 11,440 > 11,000), so the cap
505
+ * will always be the binding constraint in practice.
506
+ */
507
+ if (isRubberTiredLoader) {
508
+ if (tireSize >= 600) {
509
+ if (exceedsRateOrCapLimit(axleWeight, tireSize, numberOfTires, 110, 12000)) {
510
+ addFailResult(axleUnit);
511
+ }
516
512
  }
517
- else if (tireSize > 300) {
518
- maxWeight = numberOfTires * 3000;
513
+ else if (tireSize >= 520) {
514
+ if (exceedsRateOrCapLimit(axleWeight, tireSize, numberOfTires, 110, 11000)) {
515
+ addFailResult(axleUnit);
516
+ }
519
517
  }
520
- else {
521
- maxWeight = numberOfTires * tireSize * 10;
518
+ return;
519
+ }
520
+ /**
521
+ * Crane - All Terrain
522
+ *
523
+ * All axle units — rate 100 kg/cm; lower of rate or cap is binding:
524
+ * >=520 mm => min(100 kg/cm rate, 11,000 kg/axle)
525
+ *
526
+ * For tires where the rate yields less than the cap
527
+ * (e.g. 520mm * 100 * 2 = 10,400 < 11,000), the rate is binding.
528
+ * For tires where the rate yields more than the cap
529
+ * (e.g. 609mm * 100 * 2 = 12,180 > 11,000), the cap is binding.
530
+ */
531
+ if (isAllTerrainCrane) {
532
+ if (tireSize >= 520) {
533
+ if (exceedsRateOrCapLimit(axleWeight, tireSize, numberOfTires, 100, 11000)) {
534
+ addFailResult(axleUnit);
535
+ }
522
536
  }
523
- if (a.axleUnitWeight > maxWeight) {
524
- policyCheckResults.push({
525
- id: policyId,
526
- result: enum_1.PolicyCheckResultType.Fail,
527
- message: `Axle unit ${axleUnitNum} weight exceeds maximum of ${maxWeight}kg for ${numberOfTires} ${tireSize}mm tires`,
528
- axleUnit: axleUnitNum,
529
- });
537
+ return;
538
+ }
539
+ /**
540
+ * Mobile Crane
541
+ *
542
+ * Non-steering axle units only — rate 100 kg/cm; lower of rate or cap is binding:
543
+ * >=520 mm => min(100 kg/cm rate, 11,000 kg/axle)
544
+ *
545
+ * Same rate/cap interaction as Crane - All Terrain above.
546
+ * Steering axle falls through to the standard steer axle rules below.
547
+ */
548
+ if (isMobileCrane && !isSteeringAxle) {
549
+ if (tireSize >= 520) {
550
+ if (exceedsRateOrCapLimit(axleWeight, tireSize, numberOfTires, 100, 11000)) {
551
+ addFailResult(axleUnit);
552
+ }
530
553
  }
554
+ return;
555
+ }
556
+ /**
557
+ * Steer axle — all vehicles except Crane - All Terrain, Mobile Crane
558
+ * (steering), Rubber Tired Loader
559
+ *
560
+ * Rate 100 kg/cm; lower of rate or cap is binding:
561
+ * <445 mm => rate only (no cap)
562
+ * >=445 mm => min(100 kg/cm rate, 9,100 kg/axle)
563
+ *
564
+ * e.g. 445mm * 2 tires => min(8,900, 9,100) = 8,900 kg <- rate binding
565
+ * e.g. 457mm * 2 tires => min(9,140, 9,100) = 9,100 kg <- cap binding
566
+ */
567
+ if (isSteeringAxle) {
568
+ const capWeight = tireSize >= 445 ? 9100 : undefined;
569
+ if (exceedsRateOrCapLimit(axleWeight, tireSize, numberOfTires, 100, capWeight)) {
570
+ addFailResult(axleUnit);
571
+ }
572
+ return;
573
+ }
574
+ /**
575
+ * Standard non-steering axle — all vehicles except Crane - All Terrain,
576
+ * Mobile Crane (non-steering), Rubber Tired Loader
577
+ *
578
+ * Rate 100 kg/cm; lower of rate or per-tire cap is binding:
579
+ * >=445 mm => min(100 kg/cm rate, 4,550 kg/tire * numberOfTires)
580
+ * <=444 mm => min(100 kg/cm rate, 3,000 kg/tire * numberOfTires)
581
+ */
582
+ const perTireCap = tireSize >= 445 ? 4550 : 3000;
583
+ const axleCap = perTireCap * numberOfTires;
584
+ if (exceedsRateOrCapLimit(axleWeight, tireSize, numberOfTires, 100, axleCap)) {
585
+ addFailResult(axleUnit);
531
586
  }
532
587
  });
533
588
  if (policyCheckResults.length === 0) {
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "v2.12.1";
1
+ export declare const version = "v2.14.0";
package/dist/version.js CHANGED
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
4
  // Generated by genversion.
5
- exports.version = 'v2.12.1';
5
+ exports.version = 'v2.14.0';
package/package.json CHANGED
@@ -91,5 +91,5 @@
91
91
  ],
92
92
  "testEnvironment": "node"
93
93
  },
94
- "version": "v2.12.1"
94
+ "version": "v2.14.0"
95
95
  }