-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComponentMounting.java
More file actions
163 lines (147 loc) · 5.54 KB
/
ComponentMounting.java
File metadata and controls
163 lines (147 loc) · 5.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*
* Copyright (C) 2025 Tony Luken <tonyluken62+gerberfilereader.gmail.com>
*
* This file is part of GerberFileReader.
*
* GerberFileReader is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* GerberFileReader is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with GerberFileReader. If
* not, see <http://www.gnu.org/licenses/>.
*/
package standardAttributes;
import gerberFileReader.GerberLayerFormatException;
/**
* A class to represent the Gerber Standard Attribute {@value #GERBER_STANDARD_ATTRIBUTE_NAME}
*/
public class ComponentMounting extends StandardAttribute {
/**
* The string used in Gerber files as the name for Component Mounting Standard Attributes:
* {@value #GERBER_STANDARD_ATTRIBUTE_NAME}
*/
public static final String GERBER_STANDARD_ATTRIBUTE_NAME = ".CMnt";
/**
* Constructs an empty Component Mounting Standard Attribute, call
* {@link StandardAttribute#initialize(Attribute)} to initialize the contents of this Component
* Mounting Standard Attribute.
*/
public ComponentMounting() {
super();
}
/**
* Constructs a Component Mounting Standard Attribute from a Gerber TO extended command.
*
* @param cmd the Gerber command
* @throws GerberLayerFormatException if the command does not properly define a Component
* Mounting Standard Attribute
*/
public ComponentMounting(String cmd) throws GerberLayerFormatException {
super(cmd);
}
/**
* An enumeration of possible mounting types: {@link #ThroughHole}, {@link #SurfaceMountDevice},
* {@link #PressFit}, {@link #Other}, and {@link #Unknown}
*/
public enum MountingType {
/**
* The component leads are inserted into plated holes and are soldered to make electrical
* contact with the plated holes
*/
ThroughHole,
/**
* The component leads rest on the surface of copper pads and are soldered to make
* electrical contact with the copper pads
*/
SurfaceMountDevice,
/**
* The component leads are mechanically pressed into properly sized plated holes to make
* electrical contact with the plated holes
*/
PressFit,
/**
* The component is mounted in some other way
*/
Other,
/**
* This value is only used to indicate the Gerber file contains an invalid or unknown type
*/
Unknown;
public static MountingType fromAttributeValue(String attributeValue) {
switch (attributeValue) {
case "TH" :
return ThroughHole;
case "SMD" :
return SurfaceMountDevice;
case "Pressfit" :
return PressFit;
case "Other" :
return Other;
default :
return Unknown;
}
}
}
/**
* Gets the component's mounting type associated with the object to which this attribute
* is attached.
*
* @return the component's mounting type
*/
public MountingType getMountingType() {
return MountingType.fromAttributeValue(getValues().get(0));
}
/**
* Checks if the component associated with the object to which this attribute is attached
* is a through hole component.
*
* @return true if the component is a through hole component
*/
public boolean isThroughHole() {
return getMountingType() == MountingType.ThroughHole;
}
/**
* Checks if the component associated with the object to which this attribute is attached
* is a surface mount component.
*
* @return true if the component is a surface mount component
*/
public boolean isSurfaceMountDevice() {
return getMountingType() == MountingType.SurfaceMountDevice;
}
/**
* Checks if the component associated with the object to which this attribute is attached
* is a press fit component, i.e., its leads are pressed into properly sized plated holes to
* realize electrical contact.
*
* @return true if the component is press fit
*/
public boolean isPressFit() {
return getMountingType() == MountingType.PressFit;
}
/**
* Checks if the component associated with the object to which this attribute is attached
* is something other than a through hole, surface mount, or press fit component.
*
* @return true if the component is something other than a through hole, surface mount, or press
* fit component
*/
public boolean isOther() {
return getMountingType() == MountingType.Other;
}
@Override
public String getGerberStandardAttributeName() {
return GERBER_STANDARD_ATTRIBUTE_NAME;
}
@Override
public void validate() throws GerberLayerFormatException {
verifyValueCount(1);
if (getMountingType() == MountingType.Unknown) {
throw new GerberLayerFormatException("Invalid component mounting type: " + toString());
}
}
}