-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathErrorState.cs
More file actions
224 lines (194 loc) · 10.1 KB
/
ErrorState.cs
File metadata and controls
224 lines (194 loc) · 10.1 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
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ICLPrinterServer
{
public class ErrorState
{
public const string SyntaxError = "SyntaxError";
public const string InvalidOperationCode = "InvalidOperationCode";
public const string ClockNotSet = "ClockNotSet";
public const string DateNotSet = "DateNotSet";
public const string ClockHardwareError = "ClockHardwareError";
public const string PrintHeadFault = "PrintHeadFault";
public const string PrintHeadOverheat = "PrintHeadOverheat";
public const string GeneralError = "GeneralError";
public const string SumOverflow = "SumOverflow";
public const string CmdNotAllowed = "CmdNotAllowed";
public const string RAM_IsReset = "RAM_IsReset";
public const string RAM_Corrupted = "RAM_Corrupted";
public const string LidOpen = "LidOpen";
public const string NoPaper = "NoPaper";
public const string NoPaperNoReprint = "NoPaperNoReprint";
public const string LittlePaper = "LittlePaper";
public const string EKL_NoPaper = "EKL_NoPaper";
public const string FiscalCheckOpen = "FiscalCheckOpen";
public const string EKL_LittlePaper = "EKL_LittlePaper";
public const string EKL_MemoryLow = "EKL_MemoryLow";
public const string EKL_Overflow = "EKL_Overflow";
public const string EKL_CompactFormat = "EKL_CompactFormat";
public const string EKL_DetailedFormat = "EKL_DetailedFormat";
public const string EKL_Error = "EKL_Error";
public const string NonFiscalCheckOpen = "NonFiscalCheckOpen";
public const string RotatedNonFiscalCheckOpen = "RotatedNonFiscalCheckOpen";
public const string AnnulCheckOpen = "AnnulCheckOpen";
public const string Switch1IsOn = "Switch1IsOn";
public const string Switch2IsOn = "Switch2IsOn";
public const string Switch3IsOn = "Switch3IsOn";
public const string Switch4IsOn = "Switch4IsOn";
public const string Switch5IsOn = "Switch5IsOn";
public const string Switch6IsOn = "Switch6IsOn";
public const string Switch7IsOn = "Switch7IsOn";
public const string Switch8IsOn = "Switch8IsOn";
public const string FiscalMemReadError = "FiscalMemReadError";
public const string FiscalMemWriteError = "FiscalMemWriteError";
public const string NoFiscalMemInstalled = "NoFiscalMemInstalled";
public const string FiscalMemLowSpace = "FiscalMemLowSpace";
public const string FiscalMemFull = "FiscalMemFull";
public const string FiscalMemGeneralError = "FiscalMemGeneralError";
public const string FiscalMemIsReadOnly = "FiscalMemIsReadOnly";
public const string FiscalMemIsFormatted = "FiscalMemIsFormatted";
public const string FiscalMode = "FiscalMode";
public const string TaxValuesAreSet = "TaxValuesAreSet";
public const string SerialNumbersAreSet = "SerialNumbersAreSet";
public const string Report24HRequired = "Report24HRequired";
public const string WaitingPaperReplaceConfirmation = "WaitingPaperReplaceConfirmation";
public const string IllegalTaxGroup = "IllegalTaxGroup";
public const string NoValidTaxGroup = "NoValidTaxGroup";
public const string LoginFailed3Times = "LoginFailed3Times";
public const string BadPrinterStatusReceived = "BadPrinterStatusReceived";
public const string BadSerialPort = "BadSerialPort";
public const string BadConnectionParameters = "BadCommunicationParameters";
public const string NotEnoughCashInTheRegister = "NotEnoughCashInTheRegister";
public const string FiscalPrinterOverflow = "FiscalPrinterOverflow";
public const string FiscalPrinterNotReady = "FiscalPrinterNotReady";
public const string TooManyTransactionsInReceipt = "TooManyTransactionsInReceipt";
public const string VATGroupsMismatch = "VATGroupsMismatch";
public const string InvalidInputData = "InvalidInputData";
public const string FreePriceLimitation = "EvalPriceLimitation";
public const string FreeQttyLimitation = "EvalQttyLimitation";
public const string FreeItemsLimitation = "EvalItemsLimitation";
public const string FreeLimitation = "EvalLimitation";
public const string CommandNotAcknoledged = "CommandNotAcknoledged";
public const string CommandNotSupported = "CommandNotSupported";
public const string PowerInterruption = "PowerInterruption";
public const string DailyReportNotEmpty = "DailyReportNotEmpty";
public const string ItemsReportNotEmpty = "ItemsReportNotEmpty";
public const string OperatorsReportNotEmpty = "OperatorsReportNotEmpty";
public const string ReportsOverflow = "ReportsOverflow";
public const string DuplicateNotPrinted = "DuplicateNotPrinted";
public const string RegularReceipt = "RegularReceipt";
public const string PrintVATInReceipt = "PrintVATInReceipt";
public const string ReceiptIsInvoice = "ReceiptIsInvoice";
public const string UsingNonIntegerNumbers = "UsingNonIntegerNumbers";
public const string UsingIntegerNumbers = "UsingIntegerNumbers";
public const string AutoCutPaper = "AutoCutPaper";
public const string TransparentDisplay = "TransparentDisplay";
public const string CommunicationSpeed9600 = "CommunicationSpeed9600";
public const string CommunicationSpeed19200 = "CommunicationSpeed19200";
public const string AutoOpenSafe = "AutoOpenSafe";
public const string PrintLogoOnReceipts = "PrintLogoOnReceipts";
public const string PrintTotalInForeignCurrency = "PrintTotalInForeignCurrency";
public const string BadPassword = "BadPassword";
public const string BadLogicalAddress = "BadLogicalAddress";
public const string TaxTerminalError = "TaxTerminalError";
public const string IncorrectItemInformation = "IncorrectItemInformation";
public const string OldProtocolUsed = "OldProtocolUsed";
public const string NewProtocolUsed = "NewProtocolUsed";
public const string NRAConnectionError = "NRAConnectionError";
public const string ModemConnectionError = "ModemConnectionError";
public const string SIMCardError = "SIMCardError";
public const string BatteryLow = "BatteryLow";
public const string KitchenPrinterError = "KitchenPrinterError";
public const string KitchenPrinterNoPaper = "KitchenPrinterNoPaper";
public const string CashReceiptPrinterDisconnected = "CashReceiptPrinterDisconnected";
public const string CashDrawerDisconnected = "CashDrawerDisconnected";
public const string FiscalPrinterBusy = "FiscalPrinterBusy";
public const string NonFiscalPrinterDisconnected = "NonFiscalPrinterDisconnected";
public const string ExternalDisplayDisconnected = "ExternalDisplayDisconnected";
public const string KitchenPrinterDisconnected = "KitchenPrinterDisconnected";
public const string CardReaderDisconnected = "CardReaderDisconnected";
public const string ElectronicScaleDisconnected = "ElectronicScaleDisconnected";
public const string ElectronicScaleNotEnabled = "ElectronicScaleNotEnabled";
public const string SalesDataControllerDisconnected = "SalesDataControllerDisconnected";
public const string BarcodeScannerDisconnected = "BarcodeScannerDisconnected";
public const string AccessControllerDisconnected = "AccessControllerDisconnected";
public const string DriverNotFound = "DriverNotFound";
public const string CertificateNotFound = "CertificateNotFound";
public const string IncorrectWorkflowManager = "IncorrectWorkflowManager";
public const string UnableToCreateUniqueSaleNumber = "UnableToCreateUniqueSaleNumber";
public const string ErrorHandled = "ErrorHandled";
public static readonly string [] AllLicenseLimitations = { FreeLimitation, FreeItemsLimitation, FreePriceLimitation, FreeQttyLimitation };
private readonly HashSet<string> informations = new HashSet<string> ();
public HashSet<string> Informations
{
get { return informations; }
}
private string command;
public string Command
{
get { return command; }
set { command = value; }
}
public ErrorState ()
{
informations.Add (FiscalMemIsFormatted);
informations.Add (FiscalMode);
informations.Add (NewProtocolUsed);
}
public ErrorState (string error)
: this ()
{
Set (error);
}
public ErrorState Set (string error)
{
informations.Add (error);
return this;
}
public ErrorState SetInformation (string error)
{
informations.Add (error);
return this;
}
public bool Check (params string [] errorCodes)
{
return errorCodes.Any (ec => informations.Contains (ec));
}
public bool Unset (string error)
{
if (informations.Contains (error)) {
informations.Remove (error);
return true;
}
return false;
}
public void Clear ()
{
informations.Clear ();
command = null;
}
public void Load (ErrorState state)
{
Clear ();
if (state == null)
return;
foreach (var item in state.informations)
informations.Add (item);
command = state.command;
}
public override string ToString ()
{
var ret = new StringBuilder ();
if (command != null)
ret.Append ("Command: " + command);
var info = string.Join (", ", informations);
if (info.Length > 0) {
if (ret.Length > 0)
ret.Append ("\n");
ret.Append ($"Information: {info}");
}
return ret.ToString ();
}
}
}