react-native-esc-pos-printer
Version:
An unofficial React Native library for printing on an EPSON TM printer with the Epson ePOS SDK for iOS and Epson ePOS SDK for Android
278 lines (264 loc) • 12.9 kB
text/typescript
import {
PrinterErrorResult,
PrinterErrorCodeResult,
GetPrinterSettingsPaperWidthValues,
GetPrinterSettingsDensityValues,
GetPrinterSettingsPrintSpeedValues,
PrinterPaperStatus,
PrinterPanelSwitchStatus,
PrinterDrawerStatus,
PrinterErrorStatus,
PrinterAutoRecoverErrorStatus,
PrinterBatteryLevelStatus,
PrinterRemovalWaitingStatus,
PrinterPaperTakenSensorStatus,
PrinterUnrecoverErrorStatus,
CommonParams,
} from './enums';
import type { PrinterStatusProperties } from '../types';
export const InitPrinterErrorMessageMapping = {
[]: 'An invalid parameter was passed.',
[]:
'Memory necessary for processing could not be allocated.',
[]:
'A model name or language not supported was specified.',
[]: 'An unknown error occurred.',
} as const;
export const ConnectPrinterErrorMessageMapping = {
[]: 'An invalid parameter was passed.',
[]: 'Failed to open the device.',
[]:
'Failed to communicate with the devices within the specified time.',
[]:
'Tried to start communication with a printer with which communication had been already established. Tried to start communication with a printer during reconnection process.',
[]:
'Memory necessary for processing could not be allocated.',
[]: 'An unknown error occurred.',
[]: 'Could not run the process.',
[]: 'The device could not be found.',
[]: 'The device was in use.',
[]: 'The device type is different.',
[]: 'Failed to recover the printer.',
} as const;
export const DisconnectPrinterErrorMessageMapping = {
[]:
'Tried to end communication where it had not been established.',
[]: 'Necessary memory could not be allocated.',
[]: 'An unknown error occurred.',
[]: 'Could not run the process.',
[]:
'Failed to disconnect the device.T ried to terminate communication with a printer during reconnection process.',
[]:
'Printer is not initialized. Please call init() first.',
} as const;
export const CommonOperationErrorMessageMapping = {
[]: 'An invalid parameter was passed.',
[]:
'Memory necessary for processing could not be allocated.',
[]: 'An unknown error occurred.',
[]:
'Printer is not initialized. Please call init() first.',
} as const;
export const SendDataPrinterErrorMessageMapping = {
[]: 'An invalid parameter was passed.',
[]:
'Memory necessary for processing could not be allocated.',
[]: 'An unknown error occurred.',
[]: 'Could not run the process.',
[]:
'The control commands have not been buffered. This API was called while no communication had been started.',
[]:
'Printer is not initialized. Please call init() first.',
} as const;
export const PrintErrorCodeMessageMapping = {
[]:
'Automatic recovery error occurred.',
[]: 'Cover open error occurred.',
[]: 'Auto cutter error occurred.',
[]: 'Mechanical error occurred.',
[]:
'No paper is left in the roll paper end detector.',
[]:
'Unrecoverable error occurred.',
[]:
'Error exists in the requested document syntax.',
[]:
'Printer specified by the device ID does not exist.',
[]:
'Error occurred with the printing system.',
[]:
'Error was detected with the communication port.',
[]: 'Print timeout occurred.',
[]:
'Specified print job ID does not exist.',
[]: 'Print queue is full.',
[]: 'Battery has run out.',
[]:
'The number of print jobs sent to the printer has exceeded the allowable limit.',
[]:
'The size of the print job data exceeds the capacity of the printer.',
[]:
'Print command sent while waiting for paper removal.',
[]: 'Printing.',
[]:
'Sufficient memory required for processing could not be allocated.',
[]: 'Could not run the process.',
[]:
'This API was called while no communication had been started.',
[]:
'Could not run the process because the printer is operating.',
};
export const GetPrinterSettingsPaperWidthValuesMapping = {
[]: 58,
[]: 60,
[]: 70,
[]: 76,
[]: 80,
};
export const GetPrinterSettingsPrintDencityValuesMapping = {
[]: 0,
[]: 70,
[]: 75,
[]: 80,
[]: 85,
[]: 90,
[]: 95,
[]: 100,
[]: 105,
[]: 110,
[]: 115,
[]: 120,
[]: 125,
[]: 130,
};
export const GetPrinterSettingsPrintSpeendValuesMapping = {
[]: 1,
[]: 2,
[]: 3,
[]: 4,
[]: 5,
[]: 6,
[]: 7,
[]: 8,
[]: 9,
[]: 10,
[]: 11,
[]: 12,
[]: 13,
[]: 14,
[]: 15,
[]: 16,
[]: 17,
};
export const GetPrinterStatusMessageMapping: Record<
PrinterStatusProperties,
Record<string, string>
> = {
connection: {
[]: 'Connected',
[]: 'Status is unknown.',
},
online: {
[]: 'Online',
[]: 'Offline',
[]: 'Status is unknown.',
},
coverOpen: {
[]: 'Cover is open.',
[]: 'Cover is closed.',
[]: 'Status is unknown.',
},
paper: {
[]: 'Paper remains.',
[]: 'Paper is running out.',
[]: 'Paper has run out.',
[]: 'Status is unknown.',
},
paperFeed: {
[]: 'Paper feed in progress',
[]: 'Stopped',
[]: 'Status is unknown.',
},
panelSwitch: {
[]: 'Pressed',
[]: 'Not pressed',
[]: 'Status is unknown.',
},
drawer: {
[]: 'High',
[]: 'Low',
[]: 'Status is unknown.',
},
errorStatus: {
[]: 'Normal',
[]: 'Mechanical error occurred.',
[]: 'Auto cutter error occurred.',
[]: 'Unrecoverable error occurred.',
[]: 'Automatic recovery error occurred.',
[]: 'Status is unknown.',
},
autoRecoverError: {
[]: 'Head overheat error',
[]:
'Motor driver IC overheat error',
[]: 'Battery overheat error',
[]: 'Paper error',
[]: 'Cover is open.',
[]: 'Status is unknown.',
},
buzzer: {
[]: 'Sounding',
[]: 'Stopped',
[]: 'Status is unknown.',
},
adapter: {
[]: 'Connected',
[]: 'Disconnected',
[]: 'Status is unknown.',
},
batteryLevel: {
[]:
'Remaining battery capacity 6',
[]:
'Remaining battery capacity 5',
[]:
'Remaining battery capacity 4',
[]:
'Remaining battery capacity 3',
[]:
'Remaining battery capacity 2',
[]:
'Remaining battery capacity 1',
[]:
'Remaining battery capacity 0',
[]: 'Status is unknown.',
},
removalWaiting: {
[]:
'Waiting for paper removal',
[]: 'Not waiting for removal.',
[]: 'Status is unknown.',
},
paperTakenSensor: {
[]:
'The paper removal sensor is detecting paper',
[]:
'The paper removal sensor is not detecting paper.',
[]:
'A state that is not detectable by the paper removal sensor',
[]: 'Status is unknown.',
},
unrecoverError: {
[]: 'High voltage error',
[]: 'Low voltage error',
[]: 'Status is unknown.',
},
};
export type PrinterErrorMessageMapping =
| typeof InitPrinterErrorMessageMapping
| typeof ConnectPrinterErrorMessageMapping
| typeof DisconnectPrinterErrorMessageMapping
| typeof CommonOperationErrorMessageMapping
| typeof SendDataPrinterErrorMessageMapping
| typeof PrintErrorCodeMessageMapping
| typeof GetPrinterSettingsPaperWidthValuesMapping;