onroute-policy-engine 2.2.1 → 2.3.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.
@@ -5,6 +5,7 @@ export declare enum PolicyCheckResultType {
5
5
  export declare enum PolicyCheckId {
6
6
  BridgeFormula = "bridge-formula",
7
7
  CheckPermittableWeight = "check-permittable-weight",
8
+ MaxTireLoad = "max-tire-load",
8
9
  MinDriveAxleWeight = "minimum-drive-axle-weight",
9
10
  MinSteerAxleWeight = "minimum-steer-axle-weight",
10
11
  NumberOfWheelsPerAxle = "number-of-wheels"
@@ -10,6 +10,7 @@ var PolicyCheckId;
10
10
  (function (PolicyCheckId) {
11
11
  PolicyCheckId["BridgeFormula"] = "bridge-formula";
12
12
  PolicyCheckId["CheckPermittableWeight"] = "check-permittable-weight";
13
+ PolicyCheckId["MaxTireLoad"] = "max-tire-load";
13
14
  PolicyCheckId["MinDriveAxleWeight"] = "minimum-drive-axle-weight";
14
15
  PolicyCheckId["MinSteerAxleWeight"] = "minimum-steer-axle-weight";
15
16
  PolicyCheckId["NumberOfWheelsPerAxle"] = "number-of-wheels";
@@ -143,7 +143,9 @@ function addRuntimeFacts(engine, policy) {
143
143
  const vehicleConfiguration = await almanac.factValue(enum_1.PolicyFacts.VehicleConfiguration);
144
144
  // Retrieve the axle configuration from permit data
145
145
  const axleConfiguration = await almanac.factValue(enum_1.PermitAppInfo.PermitData, {}, enum_1.PermitAppInfo.AxleConfiguration);
146
- const results = policy.runAxleCalculation(vehicleConfiguration, axleConfiguration);
146
+ // Retrieve licensed GVW from permit data
147
+ const vehicleDetails = await almanac.factValue(enum_1.PermitAppInfo.PermitData, {}, enum_1.PermitAppInfo.VehicleDetails);
148
+ const results = policy.runAxleCalculation(vehicleConfiguration, axleConfiguration, vehicleDetails.licensedGVW || 0);
147
149
  const violations = results.results.filter((r) => r.result === enum_1.PolicyCheckResultType.Fail);
148
150
  return violations.map((v) => v.message);
149
151
  });
@@ -163,6 +163,52 @@ export declare function CheckMinSteerAxleWeight(_policy: Policy, _vehicleConfigu
163
163
  * @see AxleGroupPolicyCheckResult
164
164
  */
165
165
  export declare function CheckMinDriveAxleWeight(_policy: Policy, _vehicleConfiguration: Array<string>, axleConfiguration: Array<AxleConfiguration>): Array<PolicyCheckResult>;
166
+ /**
167
+ * Validates maximum tire load capacity for each axle unit based on tire size and count.
168
+ *
169
+ * This function performs tire load validation for all axle units in a vehicle configuration.
170
+ * It checks that the weight on each axle unit does not exceed the maximum load capacity
171
+ * of the tires based on their size and quantity. The validation uses different rules for
172
+ * steer axles versus non-steer axles.
173
+ *
174
+ * For steer axles:
175
+ * - Tire size must not exceed 455mm
176
+ * - For tires ≥445mm: Maximum weight is 9,100kg
177
+ * - For tires <445mm: Maximum weight is calculated as (number of tires × tire size × 10)
178
+ *
179
+ * For non-steer axles:
180
+ * - For tires ≥445mm: Maximum weight is (number of tires × 3,850kg)
181
+ * - For tires >300mm and <445mm: Maximum weight is (number of tires × 3,000kg)
182
+ * - For tires ≤300mm: Maximum weight is (number of tires × tire size × 10)
183
+ *
184
+ * @param _policy - The policy instance (unused in this check, but required by PolicyCheck type)
185
+ * @param _vehicleConfiguration - Vehicle configuration (unused in this check, but required by PolicyCheck type)
186
+ * @param axleConfiguration - Array of axle configurations containing tire size, tire count, and weight information
187
+ * @returns Array of PolicyCheckResult objects, with individual axle unit results for failures
188
+ * or a single group result for successful validation
189
+ *
190
+ * @example
191
+ * // For a vehicle with valid tire loads
192
+ * const results = CheckMaxTireLoad(policy, ['TRKTRAC'], [
193
+ * { tireSize: 445, numberOfTires: 2, axleUnitWeight: 8000 }, // Steer axle: 8000kg ≤ 9100kg (pass)
194
+ * { tireSize: 445, numberOfTires: 8, axleUnitWeight: 30000 } // Drive axle: 30000kg ≤ 30800kg (pass)
195
+ * ]);
196
+ * // Returns single pass result for all axle units
197
+ *
198
+ * @example
199
+ * // For a vehicle with invalid tire loads
200
+ * const results = CheckMaxTireLoad(policy, ['TRKTRAC'], [
201
+ * { tireSize: 460, numberOfTires: 2, axleUnitWeight: 8000 }, // Steer axle: tire size > 455mm (fail)
202
+ * { tireSize: 445, numberOfTires: 8, axleUnitWeight: 32000 } // Drive axle: 32000kg > 30800kg (fail)
203
+ * ]);
204
+ * // Returns individual fail results for each axle unit
205
+ *
206
+ * @see PolicyCheck
207
+ * @see AxleUnitPolicyCheckResult
208
+ * @see AxleGroupPolicyCheckResult
209
+ * @see AxleConfiguration
210
+ */
211
+ export declare function CheckMaxTireLoad(_policy: Policy, _vehicleConfiguration: Array<string>, axleConfiguration: Array<AxleConfiguration>): Array<PolicyCheckResult>;
166
212
  /**
167
213
  * Map of policy check functions keyed by their corresponding PolicyCheckId.
168
214
  *
@@ -173,6 +219,10 @@ export declare function CheckMinDriveAxleWeight(_policy: Policy, _vehicleConfigu
173
219
  *
174
220
  * Currently includes:
175
221
  * - BridgeFormula: Validates axle groups against bridge formula requirements
222
+ * - CheckPermittableWeight: Validates total vehicle weight against permit limits
223
+ * - MaxTireLoad: Validates tire load capacity for each axle unit
224
+ * - MinDriveAxleWeight: Validates minimum weight requirements for drive axles
225
+ * - MinSteerAxleWeight: Validates minimum weight requirements for steer axles
176
226
  * - NumberOfWheelsPerAxle: Validates tire count per axle unit
177
227
  *
178
228
  * @see PolicyCheck
@@ -6,6 +6,7 @@ exports.CheckNumTiresPerAxle = CheckNumTiresPerAxle;
6
6
  exports.CheckPermittableWeight = CheckPermittableWeight;
7
7
  exports.CheckMinSteerAxleWeight = CheckMinSteerAxleWeight;
8
8
  exports.CheckMinDriveAxleWeight = CheckMinDriveAxleWeight;
9
+ exports.CheckMaxTireLoad = CheckMaxTireLoad;
9
10
  const enum_1 = require("../enum");
10
11
  /**
11
12
  * Performs bridge formula calculations on axle groups and returns policy check results.
@@ -312,6 +313,145 @@ function CheckMinDriveAxleWeight(_policy, _vehicleConfiguration, axleConfigurati
312
313
  });
313
314
  return policyCheckResults;
314
315
  }
316
+ /**
317
+ * Validates maximum tire load capacity for each axle unit based on tire size and count.
318
+ *
319
+ * This function performs tire load validation for all axle units in a vehicle configuration.
320
+ * It checks that the weight on each axle unit does not exceed the maximum load capacity
321
+ * of the tires based on their size and quantity. The validation uses different rules for
322
+ * steer axles versus non-steer axles.
323
+ *
324
+ * For steer axles:
325
+ * - Tire size must not exceed 455mm
326
+ * - For tires ≥445mm: Maximum weight is 9,100kg
327
+ * - For tires <445mm: Maximum weight is calculated as (number of tires × tire size × 10)
328
+ *
329
+ * For non-steer axles:
330
+ * - For tires ≥445mm: Maximum weight is (number of tires × 3,850kg)
331
+ * - For tires >300mm and <445mm: Maximum weight is (number of tires × 3,000kg)
332
+ * - For tires ≤300mm: Maximum weight is (number of tires × tire size × 10)
333
+ *
334
+ * @param _policy - The policy instance (unused in this check, but required by PolicyCheck type)
335
+ * @param _vehicleConfiguration - Vehicle configuration (unused in this check, but required by PolicyCheck type)
336
+ * @param axleConfiguration - Array of axle configurations containing tire size, tire count, and weight information
337
+ * @returns Array of PolicyCheckResult objects, with individual axle unit results for failures
338
+ * or a single group result for successful validation
339
+ *
340
+ * @example
341
+ * // For a vehicle with valid tire loads
342
+ * const results = CheckMaxTireLoad(policy, ['TRKTRAC'], [
343
+ * { tireSize: 445, numberOfTires: 2, axleUnitWeight: 8000 }, // Steer axle: 8000kg ≤ 9100kg (pass)
344
+ * { tireSize: 445, numberOfTires: 8, axleUnitWeight: 30000 } // Drive axle: 30000kg ≤ 30800kg (pass)
345
+ * ]);
346
+ * // Returns single pass result for all axle units
347
+ *
348
+ * @example
349
+ * // For a vehicle with invalid tire loads
350
+ * const results = CheckMaxTireLoad(policy, ['TRKTRAC'], [
351
+ * { tireSize: 460, numberOfTires: 2, axleUnitWeight: 8000 }, // Steer axle: tire size > 455mm (fail)
352
+ * { tireSize: 445, numberOfTires: 8, axleUnitWeight: 32000 } // Drive axle: 32000kg > 30800kg (fail)
353
+ * ]);
354
+ * // Returns individual fail results for each axle unit
355
+ *
356
+ * @see PolicyCheck
357
+ * @see AxleUnitPolicyCheckResult
358
+ * @see AxleGroupPolicyCheckResult
359
+ * @see AxleConfiguration
360
+ */
361
+ function CheckMaxTireLoad(_policy, _vehicleConfiguration, axleConfiguration) {
362
+ const policyCheckResults = new Array();
363
+ const policyId = enum_1.PolicyCheckId.MaxTireLoad;
364
+ // Steer axle tire load check
365
+ const steerTireSize = axleConfiguration[0].tireSize;
366
+ if (!steerTireSize) {
367
+ policyCheckResults.push({
368
+ id: policyId,
369
+ result: enum_1.PolicyCheckResultType.Fail,
370
+ message: `Steer axle tire size is invalid`,
371
+ axleUnit: 1,
372
+ });
373
+ }
374
+ else if (steerTireSize > 455) {
375
+ policyCheckResults.push({
376
+ id: policyId,
377
+ result: enum_1.PolicyCheckResultType.Fail,
378
+ message: `Steer axle tire size must not exceed 455mm`,
379
+ axleUnit: 1,
380
+ });
381
+ }
382
+ else if (steerTireSize >= 445) {
383
+ if (axleConfiguration[0].axleUnitWeight > 9100) {
384
+ policyCheckResults.push({
385
+ id: policyId,
386
+ result: enum_1.PolicyCheckResultType.Fail,
387
+ message: `Steer axle weight exceeds maximum of 9100kg for ${steerTireSize}mm tire size`,
388
+ axleUnit: 1,
389
+ });
390
+ }
391
+ }
392
+ else {
393
+ const maxWeightOnSteerAxle = (axleConfiguration[0].numberOfTires || 0) * (steerTireSize * 10);
394
+ if (axleConfiguration[0].axleUnitWeight > maxWeightOnSteerAxle) {
395
+ policyCheckResults.push({
396
+ id: policyId,
397
+ result: enum_1.PolicyCheckResultType.Fail,
398
+ message: `Steer axle weight exceeds maximum of ${maxWeightOnSteerAxle}kg for ${steerTireSize}mm tire size`,
399
+ axleUnit: 1,
400
+ });
401
+ }
402
+ }
403
+ // Non-steer axle tire load checks
404
+ axleConfiguration.slice(1).forEach((a, i) => {
405
+ const tireSize = a.tireSize;
406
+ const numberOfTires = a.numberOfTires;
407
+ let maxWeight = 0;
408
+ if (!tireSize) {
409
+ policyCheckResults.push({
410
+ id: policyId,
411
+ result: enum_1.PolicyCheckResultType.Fail,
412
+ message: `Axle unit ${i + 1} tire size is invalid`,
413
+ axleUnit: i + 1,
414
+ });
415
+ }
416
+ else if (!numberOfTires) {
417
+ policyCheckResults.push({
418
+ id: policyId,
419
+ result: enum_1.PolicyCheckResultType.Fail,
420
+ message: `Axle unit ${i + 1} number of wheels is invalid`,
421
+ axleUnit: i + 1,
422
+ });
423
+ }
424
+ else {
425
+ if (tireSize >= 445) {
426
+ maxWeight = numberOfTires * 3850;
427
+ }
428
+ else if (tireSize > 300) {
429
+ maxWeight = numberOfTires * 3000;
430
+ }
431
+ else {
432
+ maxWeight = numberOfTires * tireSize * 10;
433
+ }
434
+ if (a.axleUnitWeight > maxWeight) {
435
+ policyCheckResults.push({
436
+ id: policyId,
437
+ result: enum_1.PolicyCheckResultType.Fail,
438
+ message: `Axle unit ${i + 1} weight exceeds maximum of ${maxWeight}kg for ${numberOfTires} ${steerTireSize}mm tires`,
439
+ axleUnit: 1,
440
+ });
441
+ }
442
+ }
443
+ });
444
+ if (policyCheckResults.length === 0) {
445
+ policyCheckResults.push({
446
+ id: policyId,
447
+ result: enum_1.PolicyCheckResultType.Pass,
448
+ message: 'Max tire load check passed for all axle units',
449
+ startAxleUnit: 1,
450
+ endAxleUnit: axleConfiguration.length,
451
+ });
452
+ }
453
+ return policyCheckResults;
454
+ }
315
455
  /**
316
456
  * Map of policy check functions keyed by their corresponding PolicyCheckId.
317
457
  *
@@ -322,6 +462,10 @@ function CheckMinDriveAxleWeight(_policy, _vehicleConfiguration, axleConfigurati
322
462
  *
323
463
  * Currently includes:
324
464
  * - BridgeFormula: Validates axle groups against bridge formula requirements
465
+ * - CheckPermittableWeight: Validates total vehicle weight against permit limits
466
+ * - MaxTireLoad: Validates tire load capacity for each axle unit
467
+ * - MinDriveAxleWeight: Validates minimum weight requirements for drive axles
468
+ * - MinSteerAxleWeight: Validates minimum weight requirements for steer axles
325
469
  * - NumberOfWheelsPerAxle: Validates tire count per axle unit
326
470
  *
327
471
  * @see PolicyCheck
@@ -331,6 +475,7 @@ function CheckMinDriveAxleWeight(_policy, _vehicleConfiguration, axleConfigurati
331
475
  exports.policyCheckMap = new Map([
332
476
  [enum_1.PolicyCheckId.BridgeFormula, CheckBridgeFormula],
333
477
  [enum_1.PolicyCheckId.CheckPermittableWeight, CheckPermittableWeight],
478
+ [enum_1.PolicyCheckId.MaxTireLoad, CheckMaxTireLoad],
334
479
  [enum_1.PolicyCheckId.MinDriveAxleWeight, CheckMinDriveAxleWeight],
335
480
  [enum_1.PolicyCheckId.MinSteerAxleWeight, CheckMinSteerAxleWeight],
336
481
  [enum_1.PolicyCheckId.NumberOfWheelsPerAxle, CheckNumTiresPerAxle],
@@ -201,6 +201,7 @@ export declare class Policy {
201
201
  * Each axle configuration contains details like number of axles, spacing, tire count, etc.
202
202
  * The length should match the vehicleConfiguration array plus one (since the first
203
203
  * vehicle in the configuration is a power unit with two axle units).
204
+ * @param licensedGVW Licensed GVW of the vehicle being permitted.
204
205
  * @returns AxleCalcResults object containing:
205
206
  * - results: Array of PolicyCheckResult objects, each representing the outcome of a specific policy check
206
207
  * - totalOverload: Numeric value representing the total overload across all axle calculations
@@ -221,7 +222,7 @@ export declare class Policy {
221
222
  * @see PolicyCheckResult
222
223
  * @see AxleConfiguration
223
224
  */
224
- runAxleCalculation(vehicleConfiguration: Array<string>, axleConfiguration: Array<AxleConfiguration>): AxleCalcResults;
225
+ runAxleCalculation(vehicleConfiguration: Array<string>, axleConfiguration: Array<AxleConfiguration>, licensedGVW: number): AxleCalcResults;
225
226
  /**
226
227
  * Gets the list of allowed vehicles separated into two maps, one
227
228
  * for trailers and one for power units. This will filter out LCV
@@ -673,6 +673,7 @@ class Policy {
673
673
  * Each axle configuration contains details like number of axles, spacing, tire count, etc.
674
674
  * The length should match the vehicleConfiguration array plus one (since the first
675
675
  * vehicle in the configuration is a power unit with two axle units).
676
+ * @param licensedGVW Licensed GVW of the vehicle being permitted.
676
677
  * @returns AxleCalcResults object containing:
677
678
  * - results: Array of PolicyCheckResult objects, each representing the outcome of a specific policy check
678
679
  * - totalOverload: Numeric value representing the total overload across all axle calculations
@@ -693,11 +694,13 @@ class Policy {
693
694
  * @see PolicyCheckResult
694
695
  * @see AxleConfiguration
695
696
  */
696
- runAxleCalculation(vehicleConfiguration, axleConfiguration) {
697
+ runAxleCalculation(vehicleConfiguration, axleConfiguration, licensedGVW) {
697
698
  const axleCalcResults = { results: [], totalOverload: 0 };
698
699
  for (const [, func] of policy_check_helper_1.policyCheckMap) {
699
700
  axleCalcResults.results.push(...func(this, vehicleConfiguration, axleConfiguration));
700
701
  }
702
+ const gvcw = axleConfiguration.reduce((w, curr) => w + curr.axleUnitWeight, 0);
703
+ axleCalcResults.totalOverload = Math.max(axleCalcResults.totalOverload, gvcw - licensedGVW);
701
704
  return axleCalcResults;
702
705
  }
703
706
  /**
@@ -15,6 +15,6 @@ export type AxleConfiguration = {
15
15
  axleUnitWeight: number;
16
16
  /** Number of tires on this axle unit */
17
17
  numberOfTires?: number;
18
- /** Tire size in inches */
18
+ /** Tire size in centimetres */
19
19
  tireSize?: number;
20
20
  };
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "v2.2.1";
1
+ export declare const version = "v2.3.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.2.1';
5
+ exports.version = 'v2.3.0';
package/package.json CHANGED
@@ -91,5 +91,5 @@
91
91
  ],
92
92
  "testEnvironment": "node"
93
93
  },
94
- "version": "v2.2.1"
94
+ "version": "v2.3.0"
95
95
  }