-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTypes.fs
183 lines (168 loc) · 4.13 KB
/
Types.fs
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
namespace Fabra
/// Barcode orientation
type Orientation =
/// Normal
| N
/// Rotated 90 degrees (clockwise)
| R
/// Inverted 180 degrees
| I
/// Read from bottom up, 270 degrees
| B
override x.ToString() =
match x with
| N -> "N"
| R -> "R"
| I -> "I"
| B -> "B"
/// Barcode mode
type Mode =
/// No selected mode
| N
/// UCC Case Mode
| U
/// Automatic Mode
| A
/// UCC/EAN Mode
| D
override x.ToString() =
match x with
| N -> "N"
| U -> "U"
| A -> "A"
| D -> "D"
/// Generic Yes or No value for when a ZPL command requires a Y or N argument
type YesNo =
/// Yes
| Y
/// No
| N
override x.ToString() =
match x with
| Y -> "Y"
| N -> "N"
/// Justification
type Justification =
/// Left
| Left
/// Right
| Right
/// Justified
| Justified
override x.ToString() =
match x with
| Left -> "0"
| Right -> "1"
| Justified -> "2"
/// Line Colour
type LineColour =
/// Black
| B
/// White
| W
override x.ToString() =
match x with
| B -> "B"
| W -> "W"
/// Field Data (^FD)
type FieldData =
| FieldData of string
override x.ToString() =
let (FieldData str) = x
$"^FD{str}^FS"
/// Scalable/Bitmapped Font (^A)
type Text =
{ Orientation: Orientation
Height: int
Width: int
Data: FieldData }
override x.ToString() =
$"^A0{x.Orientation},{x.Height},{x.Width}{x.Data}"
/// Code 128 Bar Code, Subsets A, B, and C (^BC)
type Barcode =
{ Orientation: Orientation
Height: int
PrintInterpretationLine: YesNo
PrintInterpretationLineAboveCode: YesNo
UCC_CheckDigit: YesNo
Mode: Mode
Data: FieldData }
override x.ToString() =
$"^BC{x.Orientation},{x.Height},{x.PrintInterpretationLine},{x.PrintInterpretationLineAboveCode},{x.UCC_CheckDigit}{x.Data}"
/// Data Matrix Quality Level
type DataMatrixQualityLevel=
| QL0
| QL50
| QL80
| QL100
| QL140
| QL200
override x.ToString() =
match x with
| QL0 -> "0"
| QL50 -> "50"
| QL80 -> "80"
| QL100 -> "100"
| QL140 -> "140"
| QL200 -> "200"
/// Data Matrix Aspect Ratio
type DataMatrixAspectRatio=
| Square
| Rectangular
override x.ToString() =
match x with
| Square -> "1"
| Rectangular -> "2"
/// Data Matrix Bar Code (^BX)
type DataMatrixBarcode =
{ Orientation: Orientation
DimensionalHeight: int
QualityLevel: DataMatrixQualityLevel
ColumnsToEncode: int option
RowsToEncode: int option
FormatId: int option
EscapeSequenceControlCharacter: string option
AspectRatio: DataMatrixAspectRatio option
Data: FieldData }
override x.ToString() =
let inline (+.) s1 s2 =
match s2 with
| Some x -> s1 + $",{x}"
| None -> s1 + ","
$"^BX{x.Orientation},{x.DimensionalHeight},{x.QualityLevel}" +. x.ColumnsToEncode +. x.RowsToEncode +. x.FormatId +. x.EscapeSequenceControlCharacter +. x.AspectRatio + $"{x.Data}"
/// Field Origin (^FO)
type FieldOrigin =
{ X_Axis: int
Y_Axis: int
Z: Justification }
override x.ToString() = $"^FO{x.X_Axis},{x.Y_Axis},{x.Z}"
/// Graphic Box (^GB)
type GraphicBox =
{ Width: int
Height: int
Thickness: int
LineColour: LineColour
Rounding: int }
override x.ToString() =
$"^GB{x.Width},{x.Height},{x.Thickness},{x.LineColour},{x.Rounding}^FS"
/// Bar Code Field Default (^BY)
type BarcodeFieldDefault =
{
// Module width
Width: int
// Wide bar to narrow bar width ratio
Ratio: float
//Barcode height
Height: int }
override x.ToString() = $"^BY{x.Width},{x.Ratio},{x.Height}"
/// A label element/command.
/// Used for containing all label commands within a single collection/label.
type LabelElement =
| FieldData of FieldData
| Text of Text
| Barcode of Barcode
| DataMatrixBarcode of DataMatrixBarcode
| FieldOrigin of FieldOrigin
| GraphicBox of GraphicBox
| BarcodeFieldDefault of BarcodeFieldDefault
| Collection of LabelElement list