onroute-policy-engine 2.4.0 → 2.5.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.
@@ -8,5 +8,6 @@ export declare enum PolicyCheckId {
8
8
  MaxTireLoad = "max-tire-load",
9
9
  MinDriveAxleWeight = "minimum-drive-axle-weight",
10
10
  MinSteerAxleWeight = "minimum-steer-axle-weight",
11
+ NumberOfAxles = "number-of-axles",
11
12
  NumberOfWheelsPerAxle = "number-of-wheels"
12
13
  }
@@ -13,5 +13,6 @@ var PolicyCheckId;
13
13
  PolicyCheckId["MaxTireLoad"] = "max-tire-load";
14
14
  PolicyCheckId["MinDriveAxleWeight"] = "minimum-drive-axle-weight";
15
15
  PolicyCheckId["MinSteerAxleWeight"] = "minimum-steer-axle-weight";
16
+ PolicyCheckId["NumberOfAxles"] = "number-of-axles";
16
17
  PolicyCheckId["NumberOfWheelsPerAxle"] = "number-of-wheels";
17
18
  })(PolicyCheckId || (exports.PolicyCheckId = PolicyCheckId = {}));
@@ -14,6 +14,19 @@ import { Policy } from 'onroute-policy-engine';
14
14
  * @returns Array of PolicyCheckResult objects representing the outcomes of the policy check
15
15
  */
16
16
  type PolicyCheck = (policy: Policy, vehicleConfiguration: Array<string>, axleConfiguration: Array<AxleConfiguration>) => Array<PolicyCheckResult>;
17
+ /**
18
+ * Validates the number of axles in each axle unit.
19
+ *
20
+ * Axle unit counts must be whole numbers from 1 to 3. This check runs before
21
+ * the other axle policy checks because bridge and weight calculations assume a
22
+ * valid axle count.
23
+ *
24
+ * @param _policy - The policy instance (unused in this check, but required by PolicyCheck type)
25
+ * @param _vehicleConfiguration - Vehicle configuration (unused in this check, but required by PolicyCheck type)
26
+ * @param axleConfiguration - Array of axle configurations containing axle count information
27
+ * @returns Array of AxleUnitPolicyCheckResult objects, one for each axle unit tested
28
+ */
29
+ export declare function CheckNumberOfAxles(_policy: Policy, _vehicleConfiguration: Array<string>, axleConfiguration: Array<AxleConfiguration>): Array<PolicyCheckResult>;
17
30
  /**
18
31
  * Performs bridge formula calculations on axle groups and returns policy check results.
19
32
  *
@@ -223,6 +236,7 @@ export declare function CheckMaxTireLoad(_policy: Policy, _vehicleConfiguration:
223
236
  * - MaxTireLoad: Validates tire load capacity for each axle unit
224
237
  * - MinDriveAxleWeight: Validates minimum weight requirements for drive axles
225
238
  * - MinSteerAxleWeight: Validates minimum weight requirements for steer axles
239
+ * - NumberOfAxles: Validates axle count per axle unit
226
240
  * - NumberOfWheelsPerAxle: Validates tire count per axle unit
227
241
  *
228
242
  * @see PolicyCheck
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.policyCheckMap = void 0;
4
+ exports.CheckNumberOfAxles = CheckNumberOfAxles;
4
5
  exports.CheckBridgeFormula = CheckBridgeFormula;
5
6
  exports.CheckNumTiresPerAxle = CheckNumTiresPerAxle;
6
7
  exports.CheckPermittableWeight = CheckPermittableWeight;
@@ -8,6 +9,44 @@ exports.CheckMinSteerAxleWeight = CheckMinSteerAxleWeight;
8
9
  exports.CheckMinDriveAxleWeight = CheckMinDriveAxleWeight;
9
10
  exports.CheckMaxTireLoad = CheckMaxTireLoad;
10
11
  const enum_1 = require("../enum");
12
+ /**
13
+ * Validates the number of axles in each axle unit.
14
+ *
15
+ * Axle unit counts must be whole numbers from 1 to 3. This check runs before
16
+ * the other axle policy checks because bridge and weight calculations assume a
17
+ * valid axle count.
18
+ *
19
+ * @param _policy - The policy instance (unused in this check, but required by PolicyCheck type)
20
+ * @param _vehicleConfiguration - Vehicle configuration (unused in this check, but required by PolicyCheck type)
21
+ * @param axleConfiguration - Array of axle configurations containing axle count information
22
+ * @returns Array of AxleUnitPolicyCheckResult objects, one for each axle unit tested
23
+ */
24
+ function CheckNumberOfAxles(_policy, _vehicleConfiguration, axleConfiguration) {
25
+ const policyCheckResults = new Array();
26
+ const policyId = enum_1.PolicyCheckId.NumberOfAxles;
27
+ axleConfiguration.forEach((ac, i) => {
28
+ const axleUnit = i + 1;
29
+ const numberOfAxles = ac.numberOfAxles;
30
+ const validNumber = Number.isFinite(numberOfAxles) && Number.isInteger(numberOfAxles);
31
+ let result = enum_1.PolicyCheckResultType.Pass;
32
+ let message = `No. of Axles for Axle Unit ${axleUnit} is permittable.`;
33
+ if (!validNumber || numberOfAxles < 1) {
34
+ result = enum_1.PolicyCheckResultType.Fail;
35
+ message = `No. of Axles for Axle Unit ${axleUnit} cannot be 0.`;
36
+ }
37
+ else if (numberOfAxles > 3) {
38
+ result = enum_1.PolicyCheckResultType.Fail;
39
+ message = `No. of Axles for Axle Unit ${axleUnit} is not permittable.`;
40
+ }
41
+ policyCheckResults.push({
42
+ id: policyId,
43
+ message,
44
+ result,
45
+ axleUnit,
46
+ });
47
+ });
48
+ return policyCheckResults;
49
+ }
11
50
  /**
12
51
  * Performs bridge formula calculations on axle groups and returns policy check results.
13
52
  *
@@ -467,6 +506,7 @@ function CheckMaxTireLoad(_policy, _vehicleConfiguration, axleConfiguration) {
467
506
  * - MaxTireLoad: Validates tire load capacity for each axle unit
468
507
  * - MinDriveAxleWeight: Validates minimum weight requirements for drive axles
469
508
  * - MinSteerAxleWeight: Validates minimum weight requirements for steer axles
509
+ * - NumberOfAxles: Validates axle count per axle unit
470
510
  * - NumberOfWheelsPerAxle: Validates tire count per axle unit
471
511
  *
472
512
  * @see PolicyCheck
@@ -474,6 +514,7 @@ function CheckMaxTireLoad(_policy, _vehicleConfiguration, axleConfiguration) {
474
514
  * @see runAxleCalculation
475
515
  */
476
516
  exports.policyCheckMap = new Map([
517
+ [enum_1.PolicyCheckId.NumberOfAxles, CheckNumberOfAxles],
477
518
  [enum_1.PolicyCheckId.BridgeFormula, CheckBridgeFormula],
478
519
  [enum_1.PolicyCheckId.CheckPermittableWeight, CheckPermittableWeight],
479
520
  [enum_1.PolicyCheckId.MaxTireLoad, CheckMaxTireLoad],
@@ -696,11 +696,19 @@ class Policy {
696
696
  */
697
697
  runAxleCalculation(vehicleConfiguration, axleConfiguration, licensedGVW) {
698
698
  const axleCalcResults = { results: [], totalOverload: 0 };
699
- for (const [, func] of policy_check_helper_1.policyCheckMap) {
700
- axleCalcResults.results.push(...func(this, vehicleConfiguration, axleConfiguration));
701
- }
702
699
  const gvcw = axleConfiguration.reduce((w, curr) => w + curr.axleUnitWeight, 0);
703
700
  axleCalcResults.totalOverload = Math.max(axleCalcResults.totalOverload, gvcw - licensedGVW);
701
+ const axleCountResults = (0, policy_check_helper_1.CheckNumberOfAxles)(this, vehicleConfiguration, axleConfiguration);
702
+ axleCalcResults.results.push(...axleCountResults);
703
+ if (axleCountResults.some((r) => r.result === enum_1.PolicyCheckResultType.Fail)) {
704
+ return axleCalcResults;
705
+ }
706
+ for (const [policyCheckId, policyCheck] of policy_check_helper_1.policyCheckMap) {
707
+ if (policyCheckId === enum_1.PolicyCheckId.NumberOfAxles) {
708
+ continue;
709
+ }
710
+ axleCalcResults.results.push(...policyCheck(this, vehicleConfiguration, axleConfiguration));
711
+ }
704
712
  return axleCalcResults;
705
713
  }
706
714
  /**
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "v2.4.0";
1
+ export declare const version = "v2.5.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.4.0';
5
+ exports.version = 'v2.5.0';
package/package.json CHANGED
@@ -91,5 +91,5 @@
91
91
  ],
92
92
  "testEnvironment": "node"
93
93
  },
94
- "version": "v2.4.0"
94
+ "version": "v2.5.0"
95
95
  }