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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
//! Attributes.

use chrono::{DateTime, UTC};
use uuid::Uuid;

#[derive(Debug)]
pub enum FileAttribute {
    Part(Part),
    FileFunction(FileFunction),
    FilePolarity(FilePolarity),
    GenerationSoftware(GenerationSoftware),
    CreationDate(DateTime<UTC>),
    ProjectId {
        id: String,
        guid: Uuid,
        revision: String,
    },
    Md5(String),
    UserDefined { name: String, value: Vec<String> },
}

#[derive(Debug)]
pub enum ApertureAttribute {
    ApertureFunction(ApertureFunction),
    DrillTolerance {
        plus: f64,
        minus: f64,
    },
}

#[derive(Debug)]
pub enum Part {
    /// Single PCB
    Single,
    /// A.k.a. customer panel, assembly panel, shipping panel, biscuit
    Array,
    /// A.k.a. working panel, production panel
    FabricationPanel,
    /// A test coupon
    Coupon,
    /// None of the above
    Other(String),
}

#[derive(Debug)]
pub enum Position {
    Top,
    Bottom,
}

#[derive(Debug)]
pub enum ExtendedPosition {
    Top,
    Inner,
    Bottom,
}

#[derive(Debug)]
pub enum CopperType {
    Plane,
    Signal,
    Mixed,
    Hatched,
}

#[derive(Debug)]
pub enum Drill {
    ThroughHole,
    Blind,
    Buried,
}

#[derive(Debug)]
pub enum DrillRouteType {
    Drill,
    Route,
    Mixed,
}

#[derive(Debug)]
pub enum Profile {
    Plated,
    NonPlated,
}

#[derive(Debug)]
pub enum FileFunction {
    Copper { layer: i32, pos: ExtendedPosition, copper_type: Option<CopperType> },
    Soldermask { pos: Position, index: Option<i32> },
    Legend { pos: Position, index: Option<i32> },
    Goldmask { pos: Position, index: Option<i32> },
    Silvermask { pos: Position, index: Option<i32> },
    Tinmask { pos: Position, index: Option<i32> },
    Carbonmask { pos: Position, index: Option<i32> },
    Peelablesoldermask { pos: Position, index: Option<i32> },
    Glue { pos: Position, index: Option<i32> },
    Viatenting(Position),
    Viafill,
    Heatsink(Position),
    Paste(Position),
    KeepOut(Position),
    Pads(Position),
    Scoring(Position),
    Plated { from_layer: i32, to_layer: i32, drill: Drill, label: Option<DrillRouteType> },
    NonPlated { from_layer: i32, to_layer: i32, drill: Drill, label: Option<DrillRouteType> },
    Profile(Profile),
    Drillmap,
    FabricationDrawing,
    ArrayDrawing,
    AssemblyDrawing(Position),
    Drawing(String),
    Other(String),
}

#[derive(Debug)]
pub enum FilePolarity {
    Positive,
    Negative,
}

#[derive(Debug)]
pub struct GenerationSoftware {
    pub vendor: String,
    pub application: String,
    pub version: Option<String>,
}

impl GenerationSoftware {
    pub fn new<S: Into<String>>(vendor: S, application: S, version: Option<S>) -> Self {
        GenerationSoftware {
            vendor: vendor.into(),
            application: application.into(),
            version: version.map(|s| s.into()),
        }
    }
}

#[derive(Debug)]
pub enum ApertureFunction {
    // Only valid for layers with file function plated or non-plated
    ViaDrill,
    BackDrill,
    ComponentDrill {
        press_fit: Option<bool>, // TODO is this bool?
    },
    CastellatedDrill,
    MechanicalDrill {
        function: Option<DrillFunction>,
    },
    Slot,
    CutOut,
    Cavity,
    OtherDrill(String),

    // Only valid for layers with file function copper
    ComponentPad {
        press_fit: Option<bool>, // TODO is this bool?
    },
    SmdPad(SmdPadType),
    BgaPad(SmdPadType),
    ConnectorPad,
    HeatsinkPad,
    ViaPad,
    TestPad,
    CastellatedPad,
    FiducialPad(FiducialScope),
    ThermalReliefPad,
    WasherPad,
    AntiPad,
    OtherPad(String),
    Conductor,
    NonConductor,
    CopperBalancing,
    Border,
    OtherCopper(String),

    // All layers
    Profile,
    NonMaterial,
    Material,
    Other(String),
}

#[derive(Debug)]
pub enum DrillFunction {
    BreakOut,
    Tooling,
    Other,
}

#[derive(Debug)]
pub enum SmdPadType {
    CopperDefined,
    SoldermaskDefined,
}

#[derive(Debug)]
pub enum FiducialScope{
    Global,
    Local,
}