Example
Here is a machining optionality module for the operation branch node Edge Treatments in the template for the GCD type Edge. This node stands for operations such as deburring, rounding, and chamfering. This module checks to see if any such operations are required for the current GCD.
Plant variables control whether aPriori should automatically determine whether deburring is necessary. The cost model assumes that deburring is necessary for sharp edges that were not created either by turning or (for hole edges) by a sheet metal operation.
Other kinds of edge treatment for hole edges are assumed to be necessary for round edges that are part of non-flanged holes and for chamfers that are part of holes that have not been previously countersunk.
The code divides edge treatment operations into the following categories:
Non-hole edge deburring: This is required if and only if all the following are true of the edge:
o External edge and the plant variable autoSelectExternalEdgesForDebur is set to true or is an internal edge and plant variable autoSelectInernalEdgesForDebur is set to true.
o Sharp.
o Not a child GCD of a simple hole.
o Has no coincident turning axis (and so is not created by turning operation).
Hole edge deburring: This is required if and only if all the following are true of the edge:
o Sharp.
o Not created by a sheet metal operation.
o Child GCD of a simple hole.
o Plant variable autoDeburSharpHoleEdges is set to true.
o Has no coincident turning axis (and so is not created by turning operation).
Hole edge machining: This is required if and only if either of the following is true of the edge:
o Round and non-flanged.
o Chamfer and not previously countersunk.
 
import libSetups.csl
 
Rule IsEdgeTreatmentsRequired: _
IsEdgeDeburringRequired or IsHoleEdgeDeburringRequired or _
IsHoleEdgeMachiningRequired
Message IsEdgeTreatmentsRequired: OLT + _
'Edge treatments, e.g., rounding, chamfering, countersinking, ‘ _
‘edge turning or deburring, are not required'
 
IsEdgeDeburringRequired = _
{true if ( _
( _
(plant.autoSelectExternalEdgesForDebur == true and _
gcd.internal == false)_
or _
(plant.autoSelectInternalEdgesForDebur == true and _
gcd.internal == true) _
)
and _
gcd.edgeTypeName == 'SHARP' _
and _
hasNoParentGcd _
and _
GetCoincidentTurningAxis(gcd) == null
) _
false otherwise}
 
IsHoleEdgeDeburringRequired = _
{true if _
gcd.edgeTypeName == 'SHARP' and _
part.processGroupName != 'Sheet Metal' and _
hasParentGcd and plant.autoDeburrSharpHoleEdges ==true and _
GetCoincidentTurningAxis(gcd.parentArtifact) == null _
false otherwise}
 
IsHoleEdgeMachiningRequired = _
{true if ( _
(gcd.edgeTypeName == 'ROUND' and not(isFlangedHoleEdge))) or _
(gcd.edgeTypeName == 'CHAMFER' and not(previousCounterSunkEdge)
) _
false otherwise}
 
previousCounterSunkEdge =
{hasNodeInTree(op.parentArtifactResult, 'PreviouslyCountersunk') _
if ( _
op.parentArtifactResult != null and _
op.parentArtifactResult.artifactTypeName == 'SimpleHole' and _
gcd.parentArtifact.isCountersunk == true _
) _
false otherwise _
}
 
isFlangedHoleEdge = _
{true if _
gcd.parentArtifact != null and _
gcd.parentArtifact.artifactTypeName == 'SimpleHole' and _
gcd.parentArtifact.isFlanged == true
false otherwise _
}
 
hasNoParentGcd = _
{false if gcd.parentArtifact.artifactTypeName == 'SimpleHole' true otherwise}
 
hasParentGcd = _
{true if gcd.parentArtifact.artifactTypeName == 'SimpleHole' false otherwise}
 
The rule in this module refers to three boolean-valued formulas, corresponding to the three categories described above:
IsEdgeDeburringRequired
IsHoleEdgeDeburringRequired
IsHoleEdgeMachiningRequired
IsEdgeDeburringRequired refers to the formula hasNoParentGCD. The formula, defined later in the module, is true if and only if the current GCD is not part of a simple hole.
IsHoleEdgeDeburringRequired refers to the formula hasParentGCD. The formula, defined later in the module, is true if and only if the current GCD is part of a simple hole.
IsHoleEdgeMachiningRequired refers to the following formulas:
previousCountersunkEdge: true if the current edge is part of a previously countersunk simple hole; false otherwise.
isFlangedHoleEdge: true if the current edge is a part of a flanged, simple hole; false otherwise.
The formulas use the following CSL standard inputs:
gcd: current GCD. has one field for each attribute of the current GCD. This code uses the following attributes:
o artifactTypeName: names the specified GCD’s type; string valued. Used here to determine if the edge’s parent is a simple hole.
o edgeTypeName: is used to determine if the specified GCD is a sharp edge, round, or chamfer; string valued.
o internal: indicates whether the specified GCD is an internal or external edge; boolean valued.
o isFlanged: true if the specified GCD is flanged; false otherwise.
o isCountersunk: true if the specified GCD is countersunk; false otherwise.
o parentAtrifact: parent of the specified GCD in the GCD hierarchy.
op: Current operation. fields include the following:
o parentArtifactResult: parent of the current node in the process-operation hierarchy.
part: Current part. fields include the following:
o processGroupName: names the current primary process group; string valued.
plant: has one field for each plant variable. This code accesses the fields for the following plant variables:
o autoDeburSharpHoleEdges
o autoSelectExternalEdgesForDebur
o autoSelectInernalEdgesForDebur
The formulas also use the following functions:
GetCoincidentTurningAxis, defined in the imported library file libSetups.csl. The function returns null if and only if there is no turning axis that is coincident with the argument’s axis.
hasNodeInTree: CSL predefined function. Returns true if the specified node or one of its descendents has a node attribute named by the specified string.