71 changed files with 32864 additions and 53 deletions
@ -0,0 +1,6 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project version="4"> |
|||
<component name="JavaScriptLibraryMappings"> |
|||
<file url="file://$PROJECT_DIR$" libraries="{index}" /> |
|||
</component> |
|||
</project> |
|||
@ -0,0 +1,10 @@ |
|||
package com.dreamchaser.depository_manage.EPSON.ENS; |
|||
|
|||
import com.sun.jna.Memory; |
|||
import com.sun.jna.Pointer; |
|||
|
|||
public class ENS { |
|||
|
|||
protected Pointer _ptrToStruct = new Memory(10); |
|||
private boolean _disposed = false; |
|||
} |
|||
@ -0,0 +1,341 @@ |
|||
package com.dreamchaser.depository_manage.EPSON.ENS; |
|||
|
|||
import sun.management.snmp.jvmmib.EnumJvmMemPoolThreshdSupport; |
|||
|
|||
/** |
|||
* 用于ENS相关的枚举类 |
|||
*/ |
|||
public class ENSEnumrations { |
|||
|
|||
|
|||
/** |
|||
* 用于ENS错误码的枚举 |
|||
*/ |
|||
public enum ENSErrorCode |
|||
{ |
|||
ERR_BASE (0), |
|||
ERR_PARAMETER (ERR_BASE.getI()- 1), //Values of necessary arguments have not been set.
|
|||
ERR_INITIALIZE (ERR_BASE.getI()- 2), //Failure in initialization of bi-directional communication module.
|
|||
//Or API has not been initialized.
|
|||
ERR_NOTSUPPORT (ERR_BASE.getI()- 3), //Error before the start of communication (i.e. a port specification error etc.).
|
|||
//Or other error occurred in bi-directional communication module.
|
|||
ERR_PRINTER (ERR_BASE.getI()- 4), //Printer has not been registered
|
|||
ERR_NOTFOUND (ERR_BASE.getI()- 5), //Communication cannot be opened.
|
|||
//Communication trouble. Or there is no device information which can be acquired.
|
|||
ERR_BUFFERSIZE (ERR_BASE.getI()- 6), //Specified buffer size value is too small.
|
|||
ERR_TEMPORARY (ERR_BASE.getI()- 7), //Temporary storage memory used in API cannot be secured.
|
|||
ERR_COMMUNICATION (ERR_BASE.getI()- 8), //Communication error occurred inside system of bi-directional communication module.
|
|||
ERR_INVALIDDATA (ERR_BASE.getI()- 9), //Data acquired by API contains invalid code, so data is not reliable.
|
|||
ERR_CHANNEL (ERR_BASE.getI()- 10), //No usable communication channel for packet transmission/reception.
|
|||
ERR_HANDLE (ERR_BASE.getI()- 11), //Handle of specified bi-directional communication module is invalid.
|
|||
ERR_BUSY (ERR_BASE.getI()- 12), //Port could not be opened while printer is printing (communicating).
|
|||
ERR_LOADDLL (ERR_BASE.getI()- 13), //Failure in loading bi-directional communication module.
|
|||
ERR_DEVICEID (ERR_BASE.getI()- 14), //Specified DeviceID information is invalid.
|
|||
ERR_PRNHANDLE (ERR_BASE.getI()- 15), //Specified printer handle is invalid.
|
|||
ERR_PORT (ERR_BASE.getI()- 16), //Unsupported printer path name was specified.
|
|||
ERR_TIMEOUT (ERR_BASE.getI()- 17), //Receive processing stopped due to a time out.
|
|||
ERR_JOB1 (ERR_BASE.getI()- 18), //Job management error No. 1.
|
|||
ERR_JOB2 (ERR_BASE.getI()- 19), //Job management error No. 2.
|
|||
ERR_JOB3 (ERR_BASE.getI()- 20), //Job management error No. 3.
|
|||
ERR_INVALIDHANDLE ( ERR_BASE.getI()- 21),//Specified discovery handle is invalid.
|
|||
ERR_USERCANCEL (ERR_BASE.getI()- 22), //Discovery was canceled by user.
|
|||
ERR_THREADSTART (ERR_BASE.getI()- 23), //Failed in starting thread.
|
|||
ERR_TRAPRESOURCE ( ERR_BASE.getI()- 24), //Insufficient trap resource.
|
|||
ERR_SERVICE ( ERR_BASE.getI()- 25), //Core service error.
|
|||
ERR_JOBNOTSUPPORT ( ERR_BASE.getI()- 26),//Job management function is not supported.
|
|||
ERR_TRAPNOTSUPPORT ( ERR_BASE.getI()- 27), //Trap function is not supported.
|
|||
ERR_SETTRAP ( ERR_BASE.getI()- 28), //Trap setting failure.
|
|||
ERR_NOTRAPDATA ( ERR_BASE.getI()- 29), //No Trap notification data.
|
|||
ERR_GSTNOTSUPPORT ( ERR_BASE.getI()- 30),//Unsupported general status.
|
|||
ERR_OTHER ( - 31); //Other error;
|
|||
|
|||
private int i; |
|||
ENSErrorCode(int i) { |
|||
this.i = i; |
|||
} |
|||
public int getI() { |
|||
return i; |
|||
} |
|||
|
|||
/** |
|||
* 用于获取对应的枚举值 |
|||
* @return |
|||
*/ |
|||
public static ENSErrorCode getENSErrorCode(int i){ |
|||
switch (i) { |
|||
case 0: |
|||
return ERR_PARAMETER; |
|||
case -1: |
|||
return ERR_PARAMETER; |
|||
case -2: |
|||
return ERR_INITIALIZE; |
|||
case -3: |
|||
return ERR_NOTSUPPORT; |
|||
case -4: |
|||
return ERR_PRINTER; |
|||
case -5: |
|||
return ERR_NOTFOUND; |
|||
case -6: |
|||
return ERR_BUFFERSIZE; |
|||
case -7: |
|||
return ERR_TEMPORARY; |
|||
case -8: |
|||
return ERR_COMMUNICATION; |
|||
case -9: |
|||
return ERR_INVALIDDATA; |
|||
case -10: |
|||
return ERR_CHANNEL; |
|||
case -11: |
|||
return ERR_HANDLE; |
|||
case -12: |
|||
return ERR_BUSY; |
|||
case -13: |
|||
return ERR_LOADDLL; |
|||
case -14: |
|||
return ERR_DEVICEID; |
|||
case -15: |
|||
return ERR_PRNHANDLE; |
|||
case -16: |
|||
return ERR_PORT; |
|||
case -17: |
|||
return ERR_TIMEOUT; |
|||
case -18: |
|||
return ERR_JOB1; |
|||
case -19: |
|||
return ERR_JOB2; |
|||
case -20: |
|||
return ERR_JOB3; |
|||
case -21: |
|||
return ERR_INVALIDHANDLE; |
|||
case -22: |
|||
return ERR_USERCANCEL; |
|||
case -23: |
|||
return ERR_THREADSTART; |
|||
case -24: |
|||
return ERR_TRAPRESOURCE; |
|||
case -25: |
|||
return ERR_SERVICE; |
|||
case -26: |
|||
return ERR_JOBNOTSUPPORT; |
|||
case -27: |
|||
return ERR_TRAPNOTSUPPORT; |
|||
case -28: |
|||
return ERR_SETTRAP; |
|||
case -29: |
|||
return ERR_NOTRAPDATA; |
|||
case -30: |
|||
return ERR_GSTNOTSUPPORT; |
|||
case -31: |
|||
return ERR_OTHER; |
|||
default: |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 用于ENS类型的枚举 |
|||
*/ |
|||
public enum ENSType //Printer path type
|
|||
{ |
|||
TYPE_PORT (0), //Port
|
|||
TYPE_PRINTER (1), //Printer registration name
|
|||
TYPE_IPX (2); //IPX
|
|||
|
|||
|
|||
private int i; |
|||
ENSType(int i) { |
|||
|
|||
this.i = i; |
|||
} |
|||
public int getI() { |
|||
return i; |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 用于ENS路径类型的枚举 |
|||
*/ |
|||
public enum ENSPathType |
|||
{ |
|||
TYPE_EJL (0), //Printer compatible with EJL commands (Page printer)
|
|||
TYPE_REMOTE (1), //Printer compatible with remote commands (INK/SIDM printer)
|
|||
TYPE_UNKNOWN (100); //Type cannot be determined.
|
|||
|
|||
private int i; |
|||
|
|||
ENSPathType(int i) { |
|||
this.i = i; |
|||
} |
|||
|
|||
public int getI() { |
|||
return i; |
|||
} |
|||
|
|||
/** |
|||
* 用于获取对应的枚举值 |
|||
* @param i |
|||
* @return |
|||
*/ |
|||
public static ENSPathType getENSPathType(int i){ |
|||
switch (i){ |
|||
case 0: |
|||
return TYPE_EJL; |
|||
case 1: |
|||
return TYPE_REMOTE; |
|||
case 100: |
|||
return TYPE_UNKNOWN; |
|||
default: |
|||
return null; |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
//------------------------------------
|
|||
//Definitions Printer StateCode for TM-C3400/TM-C3500/TM-C7500 (printer type).
|
|||
//Please add StatusCode which are not being defined.
|
|||
//Some value that is not being defined in enum by specification change of SDK may be returned.
|
|||
//Refer SDK specifications for the latest definition.
|
|||
//------------------------------------
|
|||
public enum StatusCode |
|||
{ |
|||
ST_Error (0x00 ), |
|||
ST_TestPrint (0x01 ), |
|||
ST_Busy (0x02 ), |
|||
ST_Wait (0x03 ), |
|||
ST_Idle (0x04 ), |
|||
ST_NotPrint (0x05 ), |
|||
ST_Inkdrying (0x06 ), |
|||
ST_Cleaning (0x07 ); |
|||
|
|||
private int i; |
|||
StatusCode(int i) { |
|||
this.i = i; |
|||
} |
|||
|
|||
public int getI() { |
|||
return i; |
|||
} |
|||
|
|||
/** |
|||
* 用于获取对应的枚举值 |
|||
* @param i |
|||
* @return |
|||
*/ |
|||
public static StatusCode getStatusCode(int i){ |
|||
switch (i){ |
|||
case 0x00: |
|||
return ST_Error; |
|||
case 0x01: |
|||
return ST_TestPrint; |
|||
case 0x02: |
|||
return ST_Busy; |
|||
case 0x03: |
|||
return ST_Wait; |
|||
case 0x04: |
|||
return ST_Idle; |
|||
case 0x05: |
|||
return ST_NotPrint; |
|||
case 0x06: |
|||
return ST_Inkdrying; |
|||
case 0x07: |
|||
return ST_Cleaning; |
|||
default: |
|||
return null; |
|||
} |
|||
} |
|||
} |
|||
|
|||
//------------------------------------
|
|||
//Definitions Printer ErrorCode for TM-C3400/TM-C3500/TM-C7500 (printer type).
|
|||
//Please add ErrorCode which are not being defined.
|
|||
//Some value that is not being defined in enum by specification change of SDK may be returned.
|
|||
//Refer SDK specifications for the latest definition.
|
|||
//------------------------------------
|
|||
public enum ErrorCode |
|||
{ |
|||
ERR_FatalError (0x00 ), |
|||
ERR_CoverOpen (0x02 ), |
|||
ERR_PaperJam (0x04 ), |
|||
ERR_Inkout (0x05 ), |
|||
ERR_Paperout (0x06 ); |
|||
|
|||
private int i; |
|||
ErrorCode(int i) { |
|||
this.i = i; |
|||
} |
|||
|
|||
public int getI() { |
|||
return i; |
|||
} |
|||
|
|||
/** |
|||
* 用于获取对应的枚举值 |
|||
* @param i |
|||
* @return |
|||
*/ |
|||
public static ErrorCode getErrorCode(int i){ |
|||
switch (i){ |
|||
case 0x00: |
|||
return ERR_FatalError; |
|||
case 0x02: |
|||
return ERR_CoverOpen; |
|||
case 0x04: |
|||
return ERR_PaperJam; |
|||
case 0x05: |
|||
return ERR_Inkout; |
|||
case 0x06: |
|||
return ERR_Paperout; |
|||
default: |
|||
return null; |
|||
} |
|||
} |
|||
} |
|||
|
|||
//------------------------------------
|
|||
//Definitions Printer WarningCode for TM-C3400/TM-C3500/TM-C7500 (printer type).
|
|||
//Please add WarningCode which are not being defined.
|
|||
//Some value that is not being defined in enum by specification change of SDK may be returned.
|
|||
//Refer SDK specifications for the latest definition.
|
|||
//------------------------------------
|
|||
public enum WarningCode |
|||
{ |
|||
WAR_InkLow_B (0x010 ), |
|||
WAR_InkLow_C (0x011 ), |
|||
WAR_InkLow_M (0x012 ), |
|||
WAR_InkLow_Y (0x013 ); |
|||
|
|||
private int i; |
|||
WarningCode(int i) { |
|||
this.i = i; |
|||
} |
|||
|
|||
public int getI() { |
|||
return i; |
|||
} |
|||
|
|||
/** |
|||
* 用于获取对应的枚举值 |
|||
* @param i |
|||
* @return |
|||
*/ |
|||
public static WarningCode getWarningCode(int i){ |
|||
switch (i){ |
|||
case 0x010: |
|||
return WAR_InkLow_B; |
|||
case 0x011: |
|||
return WAR_InkLow_C; |
|||
case 0x012: |
|||
return WAR_InkLow_M; |
|||
case 0x013: |
|||
return WAR_InkLow_Y; |
|||
|
|||
default: |
|||
return null; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,231 @@ |
|||
package com.dreamchaser.depository_manage.EPSON.ENS; |
|||
|
|||
import com.dreamchaser.depository_manage.config.EPSON.ENS.Global_MEDIA_ENS; |
|||
import com.dreamchaser.depository_manage.config.EPSON.EPDM.Global_MEDIA_EPDM; |
|||
import com.sun.jna.Memory; |
|||
import com.sun.jna.Structure; |
|||
|
|||
public class ENSStatus extends ENS{ |
|||
|
|||
public class STATUSVERSION extends Structure |
|||
{ |
|||
public short MajorVersion; |
|||
public short MinerVersion; |
|||
} |
|||
|
|||
public class PAPERPATHINFO extends Structure |
|||
{ |
|||
public byte Type; |
|||
public byte Path; |
|||
} |
|||
|
|||
public class CHARASTATUSINFO01 extends Structure |
|||
{ |
|||
public byte Version; |
|||
public int StartDate; |
|||
public int TotalPrintedLine; |
|||
public short TotalTime; |
|||
public short CSFBin1PaperSize; |
|||
public short CSFBin2PaperSize; |
|||
public short CSFBin3PaperSize; |
|||
public short SeriesPaperWidth; |
|||
} |
|||
|
|||
public class CHARASTATUSINFO02 extends Structure |
|||
{ |
|||
public byte Version; |
|||
public int StartDate; |
|||
public int TotalPrintedLine; |
|||
public short TotalTime; |
|||
public int ChangeRibonLine; |
|||
} |
|||
|
|||
public class CHARASTATUSINFO03 extends Structure |
|||
{ |
|||
public byte Version; |
|||
public short CSFBin1PaperSize; |
|||
public byte CSFBin1PaperType; |
|||
public byte CSFBin1PaperRest; |
|||
public short CSFBin2PaperSize; |
|||
public byte CSFBin2PaperType; |
|||
public byte CSFBin2PaperRest; |
|||
public byte SIMMVolume; |
|||
} |
|||
|
|||
|
|||
public class TRAYFIELDINFO extends Structure |
|||
{ |
|||
public byte FieldType; |
|||
public byte Position; |
|||
} |
|||
|
|||
public class PAPERTRAYINFO extends Structure |
|||
{ |
|||
public byte TrayType; |
|||
public byte TrayVolume; |
|||
public TRAYFIELDINFO TrayField; |
|||
} |
|||
|
|||
public class JOBNAMEINFO extends Structure |
|||
{ |
|||
public int JobID; |
|||
public char[] Jobname = new char[64]; |
|||
} |
|||
|
|||
public class CARTRIDGEANDINKINFO extends Structure |
|||
{ |
|||
public byte CartridgeType; |
|||
public int ColorType; |
|||
public byte InkRest; |
|||
public byte InkDimension; |
|||
} |
|||
|
|||
|
|||
public class HEATERTEMPERATUREINFO extends Structure |
|||
{ |
|||
public byte TemperatureUnit; |
|||
public byte TemperatureSetForPreHeater; |
|||
public byte PreHeaterTemperature; |
|||
public byte PreHeaterInfo; |
|||
public byte TemperatureSetForPlatenHeater; |
|||
public byte PlatenHeaterTemperature; |
|||
public byte PlatenHeaterInfo; |
|||
public byte TemperatureSetForAfterHeater; |
|||
public byte AfterHeaterTemperature; |
|||
public byte AfterHeaterInfo; |
|||
} |
|||
|
|||
public class ROMCODEINFO extends Structure |
|||
{ |
|||
public byte Size; |
|||
public byte[] Data = new byte[255]; |
|||
} |
|||
|
|||
public static class INKSIDMSTATUS_02 extends Structure |
|||
{ |
|||
public int StatusSize; |
|||
public STATUSVERSION Version; |
|||
public byte StatusCode; |
|||
public byte ErrorCode; |
|||
public byte SelfPrintCode; |
|||
|
|||
public int[] WarmingCode = new int[2]; |
|||
public byte[] RestCSFPaper = new byte[4]; |
|||
public byte[] ReserveRestCSFPaper = new byte[4]; |
|||
public PAPERPATHINFO PaperPath; |
|||
public short PaperSizeError; |
|||
public byte PaperTypeError; |
|||
public PAPERPATHINFO PaperPathError; |
|||
public CHARASTATUSINFO01 CharaStatus01; |
|||
public CHARASTATUSINFO02 CharaStatus02; |
|||
public CHARASTATUSINFO03 CharaStatus03; |
|||
public short CopyPrintNumber; |
|||
public byte InkColorNumber; |
|||
public byte MicroWeaveInfo; |
|||
public short CleaningTime; |
|||
public byte[] PaperSelectStatus = new byte[11]; |
|||
public byte[] ReservePaperSelectStatus = new byte[5]; |
|||
public CARTRIDGEANDINKINFO[] CartridgeInk = new CARTRIDGEANDINKINFO[16]; |
|||
public PAPERTRAYINFO[] PaperTray = new PAPERTRAYINFO[8]; |
|||
public byte PrintTec; |
|||
public int ReplaceCartridge; |
|||
public short RomCode; |
|||
public byte[] InkRemainInfo = new byte[3]; |
|||
public byte[] ReserveInkRemainInfo = new byte[5]; |
|||
public byte CancelCode; |
|||
public byte CutterInfo; |
|||
public byte PaperJamInfo; |
|||
public byte RouteChangeLeverInfo; |
|||
public JOBNAMEINFO JobNameInfo; |
|||
public int ColorimetricCalibrationIDSize; |
|||
public byte[] ColorimetricCalibrationID = new byte[260]; |
|||
public byte PaperRestUnit; |
|||
public int PaperRestValue; |
|||
public short PaperWidth; |
|||
public byte PaperInfoType; |
|||
public byte PaperInfoValue; |
|||
public byte InkSelect; |
|||
public HEATERTEMPERATUREINFO HeaterTemperature; |
|||
public byte AvailableWarningCode2; |
|||
public byte[] WarningCode2 = new byte[16]; |
|||
public byte PrinterMachineInfo2SetFlag; |
|||
public byte[] PrinterMachineInfo2 = new byte[4]; |
|||
public byte FatalErrorCodeSetFlag; |
|||
public byte FatalErrorCode; |
|||
public byte ReprintInfo; |
|||
public byte StatusReplyType; |
|||
public byte[] SerialNo = new byte[10]; |
|||
public byte[] InkMaintenanceLimit = new byte[16]; |
|||
public ROMCODEINFO RomCode2; |
|||
public byte[] Reserved = new byte[194]; |
|||
}; |
|||
|
|||
private boolean _disposed = false; |
|||
public INKSIDMSTATUS_02 _struct; |
|||
|
|||
public byte StatusCode; |
|||
|
|||
public byte getStatusCode() { |
|||
return _struct.StatusCode; |
|||
} |
|||
|
|||
public byte ErrorCode; |
|||
public byte getErrorCode() { |
|||
return _struct.ErrorCode; |
|||
} |
|||
|
|||
public byte[] WarningCode; |
|||
public byte[] getWarningCode() { |
|||
return _struct.WarningCode2; |
|||
} |
|||
public ENSStatus() |
|||
{ |
|||
|
|||
int Size = Integer.SIZE / 8 * 6 + 556 + Short.SIZE / 8 * 5; |
|||
|
|||
_ptrToStruct = new Memory(Size); |
|||
|
|||
_struct = new INKSIDMSTATUS_02(); |
|||
_struct.StatusSize = Size; |
|||
_struct.Version = new STATUSVERSION(); |
|||
_struct.StatusCode = 0; |
|||
_struct.ErrorCode = 0; |
|||
_struct.SelfPrintCode = 0; |
|||
_struct.PaperPath = new PAPERPATHINFO(); |
|||
_struct.PaperSizeError = 0; |
|||
_struct.PaperTypeError = 0; |
|||
_struct.PaperPathError = new PAPERPATHINFO(); |
|||
_struct.CharaStatus01 = new CHARASTATUSINFO01(); |
|||
_struct.CharaStatus02 = new CHARASTATUSINFO02(); |
|||
_struct.CharaStatus03 = new CHARASTATUSINFO03(); |
|||
_struct.CopyPrintNumber = 0; |
|||
_struct.InkColorNumber = 0; |
|||
_struct.MicroWeaveInfo = 0; |
|||
_struct.CleaningTime = 0; |
|||
_struct.PrintTec = 0; |
|||
_struct.ReplaceCartridge = 0; |
|||
_struct.RomCode = 0; |
|||
_struct.CancelCode = 0; |
|||
_struct.CutterInfo = 0; |
|||
_struct.PaperJamInfo = 0; |
|||
_struct.RouteChangeLeverInfo = 0; |
|||
_struct.JobNameInfo = new JOBNAMEINFO(); |
|||
_struct.ColorimetricCalibrationIDSize = 0; |
|||
_struct.PaperRestUnit = 0; |
|||
_struct.PaperRestValue = 0; |
|||
_struct.PaperWidth = 0; |
|||
_struct.PaperInfoType = 0; |
|||
_struct.PaperInfoValue = 0; |
|||
_struct.InkSelect = 0; |
|||
_struct.HeaterTemperature = new HEATERTEMPERATUREINFO(); |
|||
_struct.AvailableWarningCode2 = 0; |
|||
_struct.PrinterMachineInfo2SetFlag = 0; |
|||
_struct.FatalErrorCodeSetFlag = 0; |
|||
_struct.FatalErrorCode = 0; |
|||
|
|||
Global_MEDIA_ENS.integerINKSIDMSTATUS_02Map.put(_ptrToStruct.getInt(0),_struct); |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
package com.dreamchaser.depository_manage.EPSON.EPDM; |
|||
|
|||
import com.sun.jna.Memory; |
|||
import com.sun.jna.Native; |
|||
import com.sun.jna.Pointer; |
|||
|
|||
public abstract class EPDM { |
|||
|
|||
protected Pointer _ptrToStruct = new Memory(24); |
|||
private boolean _disposed = false; |
|||
|
|||
public Pointer StructurePointer; |
|||
|
|||
public Pointer getStructurePointer() { |
|||
StructureToPtr(); |
|||
return _ptrToStruct; |
|||
} |
|||
|
|||
public abstract void PtrToStructure(); |
|||
public abstract void StructureToPtr(); |
|||
} |
|||
@ -0,0 +1,426 @@ |
|||
package com.dreamchaser.depository_manage.EPSON.EPDM; |
|||
|
|||
|
|||
/** |
|||
* 用于EPDM相关的枚举类 |
|||
*/ |
|||
public class EPDMEnumrations { |
|||
|
|||
|
|||
/** |
|||
* 用于EPDM的错误码 |
|||
*/ |
|||
public enum EPDMErrorCode { |
|||
EPDM_ERR_NORMAL(0), // The function succeeds.
|
|||
EPDM_ERR_CMD(-1), // The command is not supported.
|
|||
EPDM_ERR_PARAM(-2), // The parameter error
|
|||
EPDM_ERR_NOTSUPPORT(-3), // The specified Printer Driver is not supported.
|
|||
EPDM_ERR_DLLNOTFOUND(-4), // Not found the printer specific DLL
|
|||
EPDM_ERR_NOMEM(-5), // Shortage of memory.
|
|||
EPDM_ERR_OPENPRT(-6), // Open fails
|
|||
EPDM_ERR_FAIL(-7), // Any error is occurred.
|
|||
EPDM_ERR_VERSION(-8), // Not Supprot this DLL version.
|
|||
EPDM_ERR_NOTVALID(-9), // The function can not reply valid value.
|
|||
EPDM_ERR_COMMUNICATION(-10), // A communication error.
|
|||
EPDM_ERR_FATAL(-11), // Fatal error.
|
|||
EPDM_ERR_NOTFOUND(-12), // Not found the input data.
|
|||
EPDM_ERR_FILEFORMAT(-13), // Import file format error.
|
|||
EPDM_ERR_READFILE(-14), // The export file is not read.
|
|||
EPDM_ERR_WRITEFILE(-15), // The export file is not write.
|
|||
EPDM_ERR_OVERWRITE(-16), // The export file name is exist(Do not overwrite).
|
|||
EPDM_ERR_LONGERNAME(-17), // The Add Name is longer.
|
|||
EPDM_ERR_MAXDATA(-18), // The Add Data is max.
|
|||
EPDM_ERR_FWVERSION(-19); // The F/W version is old.
|
|||
|
|||
|
|||
private int i; |
|||
|
|||
EPDMErrorCode(int i) { |
|||
this.i = i; |
|||
} |
|||
|
|||
public int getI() { |
|||
return i; |
|||
} |
|||
|
|||
/** |
|||
* 用于获取对应的枚举值 |
|||
* |
|||
* @param s 输入 |
|||
* @return |
|||
*/ |
|||
public static EPDMErrorCode getEPDMErrorCode(int s) { |
|||
switch (s) { |
|||
case 0: |
|||
return EPDM_ERR_NORMAL; |
|||
case -1: |
|||
return EPDM_ERR_CMD; |
|||
case -2: |
|||
return EPDM_ERR_PARAM; |
|||
case -3: |
|||
return EPDM_ERR_NOTSUPPORT; |
|||
case -4: |
|||
return EPDM_ERR_DLLNOTFOUND; |
|||
case -5: |
|||
return EPDM_ERR_NOMEM; |
|||
case -6: |
|||
return EPDM_ERR_OPENPRT; |
|||
case -7: |
|||
return EPDM_ERR_FAIL; |
|||
case -8: |
|||
return EPDM_ERR_VERSION; |
|||
case -9: |
|||
return EPDM_ERR_NOTVALID; |
|||
case -10: |
|||
return EPDM_ERR_COMMUNICATION; |
|||
case -11: |
|||
return EPDM_ERR_FATAL; |
|||
case -12: |
|||
return EPDM_ERR_NOTFOUND; |
|||
case -13: |
|||
return EPDM_ERR_FILEFORMAT; |
|||
case -14: |
|||
return EPDM_ERR_READFILE; |
|||
case -15: |
|||
return EPDM_ERR_WRITEFILE; |
|||
case -16: |
|||
return EPDM_ERR_OVERWRITE; |
|||
case -17: |
|||
return EPDM_ERR_LONGERNAME; |
|||
case -18: |
|||
return EPDM_ERR_MAXDATA; |
|||
case -19: |
|||
return EPDM_ERR_FWVERSION; |
|||
default: |
|||
return null; |
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 用于打开打印机类型的枚举 |
|||
*/ |
|||
public enum OpenType { |
|||
EPDM_OPENTYPE_CUR(0), // Open with the printer driver's current default DEVMODE data structure.
|
|||
EPDM_OPENTYPE_ORG(1), // Open with the DEVMODE data structure in factory reset.
|
|||
EPDM_OPENTYPE_IN(2); // Open with the DEVMODE data structure specified by the lpDM parameter.
|
|||
|
|||
private int i; |
|||
|
|||
OpenType(int i) { |
|||
this.i = i; |
|||
} |
|||
|
|||
public int getI() { |
|||
return i; |
|||
} |
|||
|
|||
/** |
|||
* 用于获取对应的枚举值 |
|||
* |
|||
* @param i 输入 |
|||
* @return |
|||
*/ |
|||
public static OpenType getEPDMOpenType(int i) { |
|||
switch (i) { |
|||
case 0: |
|||
return EPDM_OPENTYPE_CUR; |
|||
case 1: |
|||
return EPDM_OPENTYPE_ORG; |
|||
case 2: |
|||
return EPDM_OPENTYPE_IN; |
|||
default: |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
/** |
|||
* 用于控制类型的枚举 |
|||
*/ |
|||
public enum Command { |
|||
EPDM_CMD_MEDIA(60), // Media type
|
|||
EPDM_CMD_STRING(213), // String.
|
|||
EPDM_CMD_FAVORITE(500), // My favorite :Comment=STR
|
|||
EPDM_CMD_FAVORITEW(501), // My favorite :Comment=WSTR
|
|||
EPDM_CMD_MEDIALAYOUT(502), // Media layout :Comment=STR
|
|||
EPDM_CMD_MEDIALAYOUTW(503), // Media layout :Comment=WSTR
|
|||
EPDM_CMD_QUALITY(504), // Print qulity
|
|||
EPDM_CMD_AUTOCUT(505), // Media cut mode
|
|||
EPDM_CMD_AUTOCUTNUM(506), // Count of media cut
|
|||
EPDM_CMD_MEDIAPOSITION(507), // Search media position
|
|||
EPDM_CMD_DRIVERSETTINGS(600), // Driver settings :Comment=STR
|
|||
EPDM_CMD_DRIVERSETTINGSW(601), // Driver settings :Comment=WSTR
|
|||
EPDM_CMD_PRINTERSETTINGS(602), // Printer settings :Comment=STR
|
|||
EPDM_CMD_PRINTERSETTINGSW(603), // Printer settings :Comment=WSTR
|
|||
EPDM_CMD_STRINGW(1024); // UNICODE String.
|
|||
|
|||
private int i; |
|||
|
|||
Command(int i) { |
|||
this.i = i; |
|||
} |
|||
|
|||
public int getI() { |
|||
return i; |
|||
} |
|||
|
|||
/** |
|||
* 用于获取对应的枚举值 |
|||
* |
|||
* @param i 输入 |
|||
* @return |
|||
*/ |
|||
public static Command getCommand(int i) { |
|||
switch (i) { |
|||
case 60: |
|||
return EPDM_CMD_MEDIA; |
|||
case 213: |
|||
return EPDM_CMD_STRING; |
|||
case 500: |
|||
return EPDM_CMD_FAVORITE; |
|||
case 501: |
|||
return EPDM_CMD_FAVORITEW; |
|||
case 502: |
|||
return EPDM_CMD_MEDIALAYOUT; |
|||
case 503: |
|||
return EPDM_CMD_MEDIALAYOUTW; |
|||
case 504: |
|||
return EPDM_CMD_QUALITY; |
|||
case 505: |
|||
return EPDM_CMD_AUTOCUT; |
|||
case 506: |
|||
return EPDM_CMD_AUTOCUTNUM; |
|||
case 507: |
|||
return EPDM_CMD_MEDIAPOSITION; |
|||
case 600: |
|||
return EPDM_CMD_DRIVERSETTINGS; |
|||
case 601: |
|||
return EPDM_CMD_DRIVERSETTINGSW; |
|||
case 602: |
|||
return EPDM_CMD_PRINTERSETTINGS; |
|||
case 603: |
|||
return EPDM_CMD_PRINTERSETTINGSW; |
|||
case 1024: |
|||
return EPDM_CMD_STRINGW; |
|||
|
|||
default: |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
/** |
|||
* 用于结构类型的枚举 |
|||
*/ |
|||
public enum StructVersion { |
|||
EPDM_STVER_STRING_1(1), // Structure Version define for [EPDM_STRING_1]
|
|||
EPDM_STVER_STRINGW_1(1), // Structure Version define for [EPDM_STRINGW_1]
|
|||
EPDM_STVER_FAVORITEINF(1), // Structure Version define for [EPDM_FAVORITEINF]
|
|||
EPDM_STVER_FAVORITEINFW(1), // Structure Version define for [EPDM_FAVORITEINFW]
|
|||
EPDM_STVER_FAVORITERANGE(1), // Structure Version define for [EPDM_FAVORITERANGE]
|
|||
EPDM_STVER_MEDIALAYOUTINF(1), // Structure Version define for [EPDM_MEDIALAYOUTINF]
|
|||
EPDM_STVER_MEDIALAYOUTINF_2(2), // Structure Version define for [EPDM_MEDIALAYOUTINF_2]
|
|||
EPDM_STVER_MEDIATYPERANGE(1), // Structure Version define for [EPDM_MEDIATYPERANGE]
|
|||
EPDM_STVER_MEDIATYPERANGE_2(2), // Structure Version define for [EPDM_MEDIATYPERANGE_2]
|
|||
EPDM_STVER_MEDIALAYOUTRANGE(1), // Structure Version define for [EPDM_MEDIALAYOUTRANGE]
|
|||
EPDM_STVER_MEDIALAYOUTRANGE_2(2), // Structure Version define for [EPDM_MEDIALAYOUTRANGE_2]
|
|||
EPDM_STVER_MEDIALAYOUTADD(1), // Structure Version define for [EPDM_MEDIALAYOUTADD]
|
|||
EPDM_STVER_MEDIALAYOUTADD_2(2), // Structure Version define for [EPDM_MEDIALAYOUTADD_2]
|
|||
EPDM_STVER_MEDIALAYOUTADDW(1), // Structure Version define for [EPDM_MEDIALAYOUTADDW]
|
|||
EPDM_STVER_MEDIALAYOUTADDW_2(2), // Structure Version define for [EPDM_MEDIALAYOUTADDW_2]
|
|||
EPDM_STVER_PRINTERSETTINGS(1), // Structure Version define for [EPDM_PRINTERSETTINGS]
|
|||
EPDM_STVER_EXPORTDATA(1), // Structure Version define for [EPDM_EXPORTDATA]
|
|||
EPDM_STVER_EXPORTDATAW(1), // Structure Version define for [EPDM_EXPORTDATAW]
|
|||
EPDM_STVER_FAVORITEADD(1), // Structure Version define for [EPDM_FAVORITEADD]
|
|||
EPDM_STVER_FAVORITEADDW(1), // Structure Version define for [EPDM_FAVORITEADDW]
|
|||
EPDM_STVER_EXPORT_DRIVERSETTINGS(1), // Structure Version define for [EPDM_EXPORT_DRIVERSETTINGS]
|
|||
EPDM_STVER_EXPORT_DRIVERSETTINGSW(1), // Structure Version define for [EPDM_EXPORT_DRIVERSETTINGSW]
|
|||
EPDM_STVER_EXPORT_PRINTERSETTINGS(1), // Structure Version define for [EPDM_EXPORT_PRINTERSETTINGS]
|
|||
EPDM_STVER_EXPORT_PRINTERSETTINGSW(1); // Structure Version define for [EPDM_EXPORT_PRINTERSETTINGSW]
|
|||
|
|||
private int i; |
|||
|
|||
StructVersion(int i) { |
|||
this.i = i; |
|||
} |
|||
|
|||
public int getI() { |
|||
return i; |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
/** |
|||
* 用于名称的枚举 |
|||
*/ |
|||
public enum StringID |
|||
{ |
|||
EPDM_STRING_MEDIA (3), // Media Name.
|
|||
EPDM_STRING_FAVORITE (15), // Favorite Name
|
|||
EPDM_STRING_MEDIALAYOUT (16), // Media Layout Name
|
|||
EPDM_STRING_MEDIATYPE (17), // Media Type Name
|
|||
EPDM_STRING_AUTOCUT (18), // Autocut Action Type Name
|
|||
EPDM_STRING_MEDIAPOSITION (19); // Media Position Kind Name
|
|||
|
|||
private int i; |
|||
StringID(int i) { |
|||
this.i = i; |
|||
} |
|||
|
|||
public int getI() { |
|||
return i; |
|||
} |
|||
|
|||
public static StringID getStringID(int s) { |
|||
switch (s) { |
|||
case 3: |
|||
return EPDM_STRING_MEDIA; |
|||
case 15: |
|||
return EPDM_STRING_FAVORITE; |
|||
case 16: |
|||
return EPDM_STRING_MEDIALAYOUT; |
|||
case 17: |
|||
return EPDM_STRING_MEDIATYPE; |
|||
case 18: |
|||
return EPDM_STRING_AUTOCUT; |
|||
case 19: |
|||
return EPDM_STRING_MEDIAPOSITION; |
|||
default: |
|||
return null; |
|||
} |
|||
|
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 用于媒体类型的枚举 |
|||
*/ |
|||
public enum MediaTypeID |
|||
{ |
|||
EPDM_MEDIATYPE_DIECUT ((short) 0), // Die-cut Label(Gap)
|
|||
EPDM_MEDIATYPE_BMDIECUT ((short)1), // Die-cut Label(BM)
|
|||
EPDM_MEDIATYPE_BMDIECUTGAP ((short)2), // Black Mark Die-cut Label(Gap)
|
|||
EPDM_MEDIATYPE_ALLLABEL ((short)3), // Full-page Label
|
|||
EPDM_MEDIATYPE_BMALLLABEL ((short)4), // Black Mark Full-page Label
|
|||
EPDM_MEDIATYPE_RECEIPT ((short)5), // Continuous Paper
|
|||
EPDM_MEDIATYPE_BMRECEIPT ((short)6), // Black Mark Continuous Paper
|
|||
EPDM_MEDIATYPE_TPDIECUT ((short)7), // Transparent Die-cut Label
|
|||
EPDM_MEDIATYPE_TPALLLABEL ((short)8); // Transparent Full-page Label
|
|||
|
|||
private short i; |
|||
|
|||
|
|||
MediaTypeID(short i) { |
|||
this.i = i; |
|||
} |
|||
|
|||
public short getI() { |
|||
return i; |
|||
} |
|||
|
|||
public static MediaTypeID getMediaTypeID(short s) { |
|||
switch (s) { |
|||
case 0: |
|||
return EPDM_MEDIATYPE_DIECUT; |
|||
case 1: |
|||
return EPDM_MEDIATYPE_BMDIECUT; |
|||
case 2: |
|||
return EPDM_MEDIATYPE_BMDIECUTGAP; |
|||
case 3: |
|||
return EPDM_MEDIATYPE_ALLLABEL; |
|||
case 4: |
|||
return EPDM_MEDIATYPE_BMALLLABEL; |
|||
case 5: |
|||
return EPDM_MEDIATYPE_RECEIPT; |
|||
case 6: |
|||
return EPDM_MEDIATYPE_BMRECEIPT; |
|||
case 7: |
|||
return EPDM_MEDIATYPE_TPDIECUT; |
|||
case 8: |
|||
return EPDM_MEDIATYPE_TPALLLABEL; |
|||
default: |
|||
return null; |
|||
} |
|||
|
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 用于打印质量的枚举 |
|||
*/ |
|||
public enum PrintQualityID |
|||
{ |
|||
EPDM_QUALITY_360X180 (0), // Quality level (360dpi * 180dpi)
|
|||
EPDM_QUALITY_360X360 (1), // Quality level (360dpi * 360dpi)
|
|||
EPDM_QUALITY_720X360 (2); // Quality level (720dpi * 360dpi)
|
|||
|
|||
|
|||
private int i; |
|||
|
|||
PrintQualityID(int i) { |
|||
this.i = i; |
|||
} |
|||
|
|||
public int getI() { |
|||
return i; |
|||
} |
|||
|
|||
public static PrintQualityID getPrintQualityID(int s) { |
|||
switch (s) { |
|||
case 0: |
|||
return EPDM_QUALITY_360X180; |
|||
case 1: |
|||
return EPDM_QUALITY_360X360; |
|||
case 2: |
|||
return EPDM_QUALITY_720X360; |
|||
default: |
|||
return null; |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
/** |
|||
* 用于打印机状态的枚举 |
|||
*/ |
|||
public enum OverWriteID |
|||
{ |
|||
EPDM_OVERWRITE_OFF (0), // Disable over write
|
|||
EPDM_OVERWRITE_ON (1); // Enable over write
|
|||
|
|||
|
|||
private int i; |
|||
OverWriteID(int i) { |
|||
this.i = i; |
|||
} |
|||
|
|||
public int getI() { |
|||
return i; |
|||
} |
|||
|
|||
public static OverWriteID getOverWriteID(int s) { |
|||
switch (s) { |
|||
case 0: |
|||
return EPDM_OVERWRITE_OFF; |
|||
case 1: |
|||
return EPDM_OVERWRITE_ON; |
|||
default: |
|||
return null; |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,214 @@ |
|||
package com.dreamchaser.depository_manage.EPSON.EPDM; |
|||
|
|||
import com.dreamchaser.depository_manage.EPSON.epsonException.EPDMException; |
|||
import com.dreamchaser.depository_manage.config.EPSON.EPDM.Global_MEDIA_EPDM; |
|||
import com.dreamchaser.depository_manage.exception.MyException; |
|||
import com.sun.jna.Memory; |
|||
import com.sun.jna.Native; |
|||
import com.sun.jna.Pointer; |
|||
import com.sun.jna.Structure; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.Arrays; |
|||
import java.util.Collections; |
|||
import java.util.List; |
|||
|
|||
public class EPDMMediaLayoutRange extends EPDM{ |
|||
|
|||
|
|||
|
|||
|
|||
public class EPDM_MEDIALAYOUTRANGE extends Structure |
|||
{ |
|||
public int dwVersion; |
|||
public int dwSize; |
|||
public short iIDCount; |
|||
public short iMediaTypeCount; |
|||
public Pointer lpMediaLayoutID; |
|||
public Pointer lpMediaTypeRange; |
|||
public short iMaxString; |
|||
public short iMaxCount; |
|||
|
|||
|
|||
@Override |
|||
protected List<String> getFieldOrder() { |
|||
return new ArrayList<>(Arrays.asList("dwVersion", "dwSize", "iIDCount", "iMediaTypeCount", "lpMediaLayoutID", "lpMediaTypeRange", "iMaxString", "iMaxCount")); |
|||
} |
|||
|
|||
public EPDM_MEDIALAYOUTRANGE() { |
|||
|
|||
} |
|||
|
|||
public EPDM_MEDIALAYOUTRANGE(Pointer p) { |
|||
super(p); |
|||
} |
|||
|
|||
}; |
|||
|
|||
private boolean _disposed = false; |
|||
private EPDM_MEDIALAYOUTRANGE _struct; |
|||
|
|||
|
|||
|
|||
public EPDMEnumrations.StructVersion Version; |
|||
|
|||
|
|||
public short IDCount; |
|||
|
|||
public short getIDCount() { |
|||
return _struct.iIDCount; |
|||
} |
|||
|
|||
|
|||
public short[] MediaLayoutID; |
|||
|
|||
public short[] getMediaLayoutID() { |
|||
|
|||
try |
|||
{ |
|||
short[] arr = new short[_struct.iIDCount]; |
|||
|
|||
for (int i = 0; i < _struct.iIDCount; i++) |
|||
{ |
|||
Pointer current = new Memory(_struct.lpMediaLayoutID.getLong(0) + (2 * i)); |
|||
|
|||
arr[i] = Global_MEDIA_EPDM.epdm_mediaLayoutRange_short.get(current.getInt(0)); |
|||
} |
|||
return arr; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return null; |
|||
|
|||
} |
|||
|
|||
|
|||
public EPDMMediaTypeRange.EPDM_MEDIATYPERANGE[] MediaTypeRange; |
|||
|
|||
public EPDMMediaTypeRange.EPDM_MEDIATYPERANGE[] getMediaTypeRange() { |
|||
try |
|||
{ |
|||
EPDMMediaTypeRange.EPDM_MEDIATYPERANGE[] arr = new EPDMMediaTypeRange.EPDM_MEDIATYPERANGE[_struct.iMediaTypeCount]; |
|||
|
|||
int struct_size = 22 * Short.SIZE / 8 + 2 * Integer.SIZE / 8; |
|||
|
|||
for (int i = 0; i < _struct.iMediaTypeCount; i++) |
|||
{ |
|||
Pointer current = new Memory(_struct.lpMediaTypeRange.getInt(0) + (struct_size) * i); |
|||
arr[i] = Global_MEDIA_EPDM.epdm_mediatyperangeMap.get(current.getInt(0)); |
|||
} |
|||
return arr; |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
// Error handling.
|
|||
System.out.println(e.getMessage()); |
|||
} |
|||
return MediaTypeRange; |
|||
} |
|||
|
|||
public EPDMMediaLayoutRange() { |
|||
|
|||
int struct_size = 24; |
|||
_ptrToStruct = new Memory(struct_size); |
|||
_struct = new EPDM_MEDIALAYOUTRANGE(_ptrToStruct); |
|||
_struct.dwVersion = EPDMEnumrations.StructVersion.EPDM_STVER_MEDIALAYOUTRANGE.getI(); |
|||
_struct.dwSize = struct_size; |
|||
_struct.iIDCount = 0; |
|||
_struct.iMediaTypeCount = 0; |
|||
_struct.lpMediaLayoutID = new Memory(10); |
|||
_struct.lpMediaTypeRange = new Memory(10); |
|||
_struct.iMaxString = 0; |
|||
_struct.iMaxCount = 0; |
|||
|
|||
StructureToPtr(); |
|||
PtrToStructure(); |
|||
} |
|||
|
|||
@Override |
|||
public void PtrToStructure() { |
|||
_struct.read(); |
|||
_struct = Global_MEDIA_EPDM.epdm_medialayoutrangeMap.get(_ptrToStruct.getInt(0)); |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void StructureToPtr() { |
|||
_struct.write(); |
|||
Global_MEDIA_EPDM.epdm_medialayoutrangeMap.put(_ptrToStruct.getInt(0),_struct); |
|||
} |
|||
|
|||
public void Alloc() |
|||
{ |
|||
try |
|||
{ |
|||
// iIDCount、iMediaTypeCount = 0 is EPDM_ERR_FAIL.
|
|||
if (_struct.iIDCount == 0 || _struct.iMediaTypeCount == 0) |
|||
{ |
|||
throw new EPDMException(EPDMEnumrations.EPDMErrorCode.EPDM_ERR_FAIL); |
|||
} |
|||
|
|||
|
|||
|
|||
// Free the memory.
|
|||
Native.free(Pointer.nativeValue(_struct.lpMediaLayoutID)); |
|||
Native.free(Pointer.nativeValue(_struct.lpMediaTypeRange)); |
|||
|
|||
|
|||
_struct.lpMediaLayoutID = new Memory(_struct.iIDCount * Short.SIZE / 8); |
|||
|
|||
int sizeOfEPDM_MEDIATYPERANGE = (22 * Short.SIZE / 8 + 2 * Integer.SIZE / 8); |
|||
|
|||
_struct.lpMediaTypeRange = new Memory(_struct.iMediaTypeCount *sizeOfEPDM_MEDIATYPERANGE ).getPointer(0); |
|||
|
|||
EPDMMediaTypeRange.EPDM_MEDIATYPERANGE[] epdmMediaTypeRange = new EPDMMediaTypeRange.EPDM_MEDIATYPERANGE[_struct.iMediaTypeCount]; |
|||
for (int i = 0; i < _struct.iMediaTypeCount; i++) |
|||
{ |
|||
Pointer current = new Memory(_ptrToStruct.getLong(0) + (sizeOfEPDM_MEDIATYPERANGE * i)); |
|||
epdmMediaTypeRange[i] = Global_MEDIA_EPDM.epdm_mediatyperangeMap.get(current.getInt(0)); |
|||
|
|||
epdmMediaTypeRange[i].dwVersion = EPDMEnumrations.StructVersion.EPDM_STVER_MEDIATYPERANGE.getI(); |
|||
epdmMediaTypeRange[i].dwSize = (22 * Short.SIZE / 8 + 2 * Integer.SIZE / 8); |
|||
|
|||
Pointer current2 = new Memory(_struct.lpMediaTypeRange.getLong(0) + (sizeOfEPDM_MEDIATYPERANGE * i)); |
|||
Global_MEDIA_EPDM.epdm_mediatyperangeMap.put(current2.getInt(0),epdmMediaTypeRange[i]); |
|||
} |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
// Error handling.
|
|||
System.out.println(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
public int GetMediaTypeIndex(EPDMEnumrations.MediaTypeID mediaTypeID) |
|||
{ |
|||
try |
|||
{ |
|||
int i = -1; |
|||
|
|||
if (_struct.iMediaTypeCount <= 0) |
|||
{ |
|||
return i; |
|||
} |
|||
|
|||
for (i = 0; i < _struct.iMediaTypeCount; i++) |
|||
{ |
|||
short typeID = MediaTypeRange[i].iTypeID; |
|||
if (typeID == mediaTypeID.getI()) |
|||
{ |
|||
break; |
|||
} |
|||
} |
|||
return i; |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,125 @@ |
|||
package com.dreamchaser.depository_manage.EPSON.EPDM; |
|||
|
|||
import com.dreamchaser.depository_manage.config.EPSON.EPDM.Global_MEDIA_EPDM; |
|||
import com.sun.jna.Memory; |
|||
import com.sun.jna.Pointer; |
|||
import com.sun.jna.Structure; |
|||
import com.sun.xml.bind.v2.runtime.MarshallerImpl; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
|
|||
public class EPDMMediaTypeRange extends EPDM { |
|||
|
|||
@Override |
|||
public void PtrToStructure() { |
|||
_struct.read(); |
|||
_struct = Global_MEDIA_EPDM.epdm_mediatyperangeMap.get(_ptrToStruct.getInt(0)); |
|||
} |
|||
|
|||
@Override |
|||
public void StructureToPtr() { |
|||
_struct.write(); |
|||
Global_MEDIA_EPDM.epdm_mediatyperangeMap.put(_ptrToStruct.getInt(0),_struct); |
|||
} |
|||
|
|||
public class EPDM_MEDIATYPERANGE extends Structure |
|||
{ |
|||
public int dwVersion; |
|||
public int dwSize; |
|||
public short iMaxPaperWid; |
|||
public short iMaxPaperHig; |
|||
public short iMaxLabelWid; |
|||
public short iMaxLabelHig; |
|||
public short iMaxLabelGap; |
|||
public short iMaxBMGap; |
|||
public short iMaxPrintWid; |
|||
public short iMaxPrintHig; |
|||
public short iMaxPrintX; |
|||
public short iMaxPrintY; |
|||
public short iMinPaperWid; |
|||
public short iMinPaperHig; |
|||
public short iMinLabelWid; |
|||
public short iMinLabelHig; |
|||
public short iMinLabelGap; |
|||
public short iMinBMGap; |
|||
public short iMinPrintWid; |
|||
public short iMinPrintHig; |
|||
public short iMinPrintX; |
|||
public short iMinPrintY; |
|||
public short iTypeID; |
|||
public short iRsv; |
|||
|
|||
@Override |
|||
protected List<String> getFieldOrder() { |
|||
return new ArrayList<>(Arrays.asList("dwVersion", "dwSize", "iMaxPaperWid", "iMaxPaperHig", "iMaxLabelWid", "iMaxLabelHig", |
|||
"iMaxLabelGap", "iMaxBMGap","iMaxPrintWid","iMaxPrintHig","iMaxPrintX","iMaxPrintY","iMinPaperWid","iMinPaperHig", |
|||
"iMinLabelWid","iMinLabelHig","iMinLabelGap","iMinBMGap","iMinPrintWid","iMinPrintHig","iMinPrintX","iMinPrintY", |
|||
"iTypeID","iRsv")); |
|||
} |
|||
|
|||
public EPDM_MEDIATYPERANGE() { |
|||
|
|||
} |
|||
|
|||
public EPDM_MEDIATYPERANGE(Pointer p) { |
|||
super(p); |
|||
} |
|||
|
|||
}; |
|||
|
|||
private boolean _disposed = false; |
|||
public EPDM_MEDIATYPERANGE _struct; |
|||
|
|||
|
|||
public short MaxPaperWid; |
|||
|
|||
public short getMaxPaperWid() { |
|||
return _struct.iMaxPaperWid; |
|||
} |
|||
|
|||
public short MaxPaperHig; |
|||
|
|||
public short getMaxPaperHig() { |
|||
return _struct.iMaxPaperHig; |
|||
} |
|||
|
|||
public EPDMMediaTypeRange() |
|||
{ |
|||
|
|||
int struct_size = 22 * Short.SIZE / 8 + 2 * Integer.SIZE / 8; |
|||
|
|||
_ptrToStruct =new Memory(struct_size ); |
|||
_struct = new EPDM_MEDIATYPERANGE(_ptrToStruct); |
|||
_struct.dwVersion = EPDMEnumrations.StructVersion.EPDM_STVER_MEDIATYPERANGE.getI(); |
|||
_struct.dwSize = struct_size; |
|||
_struct.iMaxPaperWid = 0; |
|||
_struct.iMaxPaperHig = 0; |
|||
_struct.iMaxLabelWid = 0; |
|||
_struct.iMaxLabelHig = 0; |
|||
_struct.iMaxLabelGap = 0; |
|||
_struct.iMaxBMGap = 0; |
|||
_struct.iMaxPrintWid = 0; |
|||
_struct.iMaxPrintHig = 0; |
|||
_struct.iMaxPrintX = 0; |
|||
_struct.iMaxPrintY = 0; |
|||
_struct.iMinPaperWid = 0; |
|||
_struct.iMinPaperHig = 0; |
|||
_struct.iMinLabelWid = 0; |
|||
_struct.iMinLabelHig = 0; |
|||
_struct.iMinLabelGap = 0; |
|||
_struct.iMinBMGap = 0; |
|||
_struct.iMinPrintWid = 0; |
|||
_struct.iMinPrintHig = 0; |
|||
_struct.iMinPrintX = 0; |
|||
_struct.iMinPrintY = 0; |
|||
_struct.iTypeID = EPDMEnumrations.MediaTypeID.EPDM_MEDIATYPE_DIECUT.getI(); |
|||
_struct.iRsv = 0; |
|||
|
|||
StructureToPtr(); |
|||
PtrToStructure(); |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,151 @@ |
|||
package com.dreamchaser.depository_manage.EPSON.EPDM; |
|||
|
|||
import com.dreamchaser.depository_manage.EPSON.epsonException.EPDMException; |
|||
import com.dreamchaser.depository_manage.config.EPSON.EPDM.Global_MEDIA_EPDM; |
|||
import com.dreamchaser.depository_manage.exception.MyException; |
|||
import com.sun.jna.Memory; |
|||
import com.sun.jna.Native; |
|||
import com.sun.jna.Pointer; |
|||
import com.sun.jna.Structure; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
|
|||
public class EPDMSelectData extends EPDM{ |
|||
|
|||
@Override |
|||
public void PtrToStructure() { |
|||
_struct.read(); |
|||
_struct = Global_MEDIA_EPDM.epdm_selectdataMap.get(_ptrToStruct.getInt(0)); |
|||
} |
|||
|
|||
@Override |
|||
public void StructureToPtr() { |
|||
_struct.write(); |
|||
Global_MEDIA_EPDM.epdm_selectdataMap.put(_ptrToStruct.getInt(0),_struct); |
|||
} |
|||
|
|||
public static class EPDM_SELECTDATA extends Structure |
|||
{ |
|||
public short iCount; |
|||
public short iSize; |
|||
public Pointer lpData; |
|||
|
|||
@Override |
|||
protected List<String> getFieldOrder() { |
|||
return new ArrayList<>(Arrays.asList("iCount", "iSize", "lpData")); |
|||
} |
|||
|
|||
public EPDM_SELECTDATA(Pointer p) { |
|||
super(p); |
|||
} |
|||
|
|||
public EPDM_SELECTDATA() { |
|||
} |
|||
}; |
|||
|
|||
|
|||
private boolean _disposed = false; |
|||
private EPDM_SELECTDATA _struct; |
|||
|
|||
|
|||
public short Count; |
|||
|
|||
|
|||
public Long[] Data; |
|||
|
|||
|
|||
public short getCount() { |
|||
return _struct.iCount; |
|||
} |
|||
|
|||
public Long[] getData() { |
|||
try |
|||
{ |
|||
if (_struct.lpData == Pointer.NULL || _struct.iSize > Long.SIZE / 8) |
|||
{ |
|||
return null; |
|||
} |
|||
|
|||
Long[] arr = new Long[_struct.iCount]; |
|||
|
|||
for (int i = 0; i < _struct.iCount; i++) |
|||
{ |
|||
Pointer current = new Memory(_struct.lpData.getLong(0) + (_struct.iSize * i)); |
|||
arr[i] = GetSelectData(current); |
|||
} |
|||
return arr; |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
public EPDMSelectData() |
|||
{ |
|||
_ptrToStruct = new Memory(Short.SIZE / 8 * 2); |
|||
|
|||
_struct.iCount = 0; |
|||
_struct.iSize = 0; |
|||
_struct.lpData = new Memory(10); |
|||
|
|||
|
|||
StructureToPtr(); |
|||
PtrToStructure(); |
|||
} |
|||
|
|||
|
|||
private Long GetSelectData(Pointer p) |
|||
{ |
|||
try |
|||
{ |
|||
Long data = 0L; |
|||
switch (_struct.iSize) |
|||
{ |
|||
case 8: |
|||
data = Global_MEDIA_EPDM.epdm_select_data_int64.get(p.getInt(0)); |
|||
break; |
|||
case 4: |
|||
data = Long.valueOf(Global_MEDIA_EPDM.epdm_select_data_int32.get(p.getInt(0))); |
|||
break; |
|||
case 2: |
|||
default: |
|||
data = Long.valueOf(Global_MEDIA_EPDM.epdm_select_data_int16.get(p.getInt(0))); |
|||
break; |
|||
} |
|||
return data; |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
public void Alloc() |
|||
{ |
|||
try |
|||
{ |
|||
// iIDCount、iSize = 0 is EPDM_ERR_FAIL.
|
|||
if (_struct.iCount == 0 || _struct.iSize == 0) |
|||
{ |
|||
throw new EPDMException(EPDMEnumrations.EPDMErrorCode.EPDM_ERR_FAIL); |
|||
} |
|||
|
|||
// Free the memory.
|
|||
Native.free(Pointer.nativeValue(_struct.lpData)); |
|||
// Allocate the memory. - EPDMSelectData.lpData
|
|||
_struct.lpData =new Memory(_struct.iCount * _struct.iSize); |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,150 @@ |
|||
package com.dreamchaser.depository_manage.EPSON.EPDM; |
|||
|
|||
import com.dreamchaser.depository_manage.EPSON.epsonException.EPDMException; |
|||
import com.dreamchaser.depository_manage.config.EPSON.EPDM.Global_MEDIA_EPDM; |
|||
import com.dreamchaser.depository_manage.exception.MyException; |
|||
import com.sun.jna.Memory; |
|||
import com.sun.jna.Native; |
|||
import com.sun.jna.Pointer; |
|||
import com.sun.jna.Structure; |
|||
import com.sun.media.jfxmedia.track.Track; |
|||
import jdk.nashorn.internal.objects.Global; |
|||
|
|||
import java.io.UnsupportedEncodingException; |
|||
import java.util.ArrayList; |
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
import java.util.Locale; |
|||
|
|||
public class EPDMString extends EPDM { |
|||
|
|||
public class EPDM_STRING_1 extends Structure |
|||
{ |
|||
public int dwVersion; |
|||
public int dwSize; |
|||
public int dwStrSize; |
|||
public int dwCommand; |
|||
public int dwID; |
|||
public Pointer lpString; |
|||
|
|||
|
|||
@Override |
|||
protected List<String> getFieldOrder() { |
|||
return new ArrayList<>(Arrays.asList("dwVersion", "dwSize", "dwStrSize", "dwCommand", "dwID", "lpString")); |
|||
} |
|||
|
|||
public EPDM_STRING_1() { |
|||
} |
|||
|
|||
public EPDM_STRING_1(Pointer p) { |
|||
super(p); |
|||
} |
|||
}; |
|||
|
|||
private boolean _disposed = false; |
|||
private EPDM_STRING_1 _struct; |
|||
|
|||
public int Command; |
|||
|
|||
public int getCommand() { |
|||
return _struct.dwCommand; |
|||
} |
|||
|
|||
public void setCommand(int command) { |
|||
_struct.dwCommand = command; |
|||
} |
|||
|
|||
public int ID; |
|||
|
|||
public int getID() { |
|||
return _struct.dwID; |
|||
} |
|||
|
|||
public void setID(int ID) { |
|||
_struct.dwID = ID; |
|||
} |
|||
|
|||
|
|||
|
|||
public String string; |
|||
|
|||
public String getString() { |
|||
byte[] StringData = new byte[_struct.dwStrSize]; |
|||
|
|||
// Deploy the memory to array.
|
|||
int i = 0; |
|||
for (i = 0; i < _struct.dwStrSize; i++) |
|||
{ |
|||
Pointer current = new Memory(_struct.lpString.getLong(0) + i); |
|||
// StringData[i]= current.getByte(0);
|
|||
StringData[i] = Global_MEDIA_EPDM.epdm_epdmString_byte.get(current.getInt(0)); |
|||
if (StringData[i] == 0) |
|||
{ |
|||
break; |
|||
} |
|||
} |
|||
try { |
|||
return new String(StringData,"gbk"); |
|||
} catch (UnsupportedEncodingException e) { |
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
public EPDMString() |
|||
{ |
|||
|
|||
|
|||
int structSize = 5 * Integer.SIZE / 8; |
|||
_ptrToStruct = new Memory( structSize ); |
|||
|
|||
_struct = new EPDM_STRING_1(_ptrToStruct); |
|||
_struct.dwVersion = EPDMEnumrations.StructVersion.EPDM_STVER_STRING_1.getI(); |
|||
_struct.dwSize = structSize; |
|||
_struct.dwStrSize = 0; |
|||
_struct.dwCommand = 0; |
|||
_struct.dwID = 0; |
|||
_struct.lpString = new Memory(10); |
|||
StructureToPtr(); |
|||
PtrToStructure(); |
|||
} |
|||
|
|||
|
|||
@Override |
|||
public void PtrToStructure() { |
|||
_struct.read(); |
|||
_struct = Global_MEDIA_EPDM.epdm_string_1Map.get(_ptrToStruct.getInt(0)); |
|||
} |
|||
|
|||
@Override |
|||
public void StructureToPtr() { |
|||
_struct.write(); |
|||
Global_MEDIA_EPDM.epdm_string_1Map.put(_ptrToStruct.getInt(0),_struct); |
|||
} |
|||
|
|||
|
|||
public void Alloc() |
|||
{ |
|||
try |
|||
{ |
|||
// m_Struct.dwStrSize == 0 is EPDM_ERR_FAIL.
|
|||
if (_struct.dwStrSize == 0) |
|||
{ |
|||
throw new EPDMException(EPDMEnumrations.EPDMErrorCode.EPDM_ERR_FAIL); |
|||
} |
|||
|
|||
// Free the memory.
|
|||
Native.free(Pointer.nativeValue(_struct.lpString)); |
|||
|
|||
// Allocate the memory. - EPDMString.lpString
|
|||
_struct.lpString =new Memory((int)_struct.dwStrSize); |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,301 @@ |
|||
package com.dreamchaser.depository_manage.EPSON.Other; |
|||
|
|||
import com.dreamchaser.depository_manage.EPSON.ENS.ENSEnumrations; |
|||
import com.dreamchaser.depository_manage.EPSON.ENS.ENSEnumrations.StatusCode; |
|||
import com.dreamchaser.depository_manage.EPSON.EPDM.EPDMEnumrations; |
|||
import com.dreamchaser.depository_manage.exception.MyException; |
|||
import com.dreamchaser.depository_manage.service.impl.EPSON.ENS.ENSWrapperImpl; |
|||
|
|||
|
|||
public class MessageString { |
|||
public static final int STATE_ENS_ERROR = 1; |
|||
public static final int STATE_MEDIA_LAYOUT_ERROR = 2; |
|||
public static final int STATE_MEDIA_POSITION_ERROR = 3; |
|||
public static final int STATE_PRINT_SETTING_ERROR = 4; |
|||
public static final int STATE_EPDI_DLL_NOT_FOUND = 5; |
|||
public static final int STATE_ENS_DLL_NOT_FOUND = 6; |
|||
public static final int STATE_DRIVER_NOT_FOUND = 7; |
|||
public static final int STATE_SYSTEM_PARAM_ERROR = 8; |
|||
public static final int STATE_DRAWIMAGE_ERROR = 9; |
|||
|
|||
public static final String STR_ENS_ERROR = "Can't get the printer status.\n\nEpsonNet SDK error code : "; |
|||
public static final String STR_MEDIA_LAYOUT_ERROR = "Fail to add the media layout.\r\n\r\nEPDI error code : "; |
|||
public static final String STR_MEDIA_POSITION_ERROR = "Fail to change the media position detection setting.\r\n\r\nEPDI error code : "; |
|||
public static final String STR_PRINT_SETTING_ERROR = "Fail to change the print settings.\r\n\r\nEPDI error code : "; |
|||
public static final String STR_STATUS_BUSY = "Printer is busy.\r\nStop the printing..."; |
|||
public static final String STR_STATUS_PRINTING = "Printer is printing now.\r\nStop the printing..."; |
|||
public static final String STR_STATUS_CLEANING = "Printer is cleaning the print head.\r\nStop the printing..."; |
|||
public static final String STR_STATUS_OTHER = "Printer is busy.\r\nStop the printing..."; |
|||
public static final String STR_ERROR_PAPERJAM = "Paper jam error.\r\nStop the printing..."; |
|||
public static final String STR_ERROR_PAPEROUT = "Paper out error.\r\nStop the printing..."; |
|||
public static final String STR_ERROR_INKEND = "Ink cartridge error.\r\nStop the printing..."; |
|||
public static final String STR_ERROR_OTHER = "Other error.\r\nStop the printing..."; |
|||
public static final String STR_WARNING_INKLOW = "Ink is low.\r\n"; |
|||
public static final String STR_WARNING_OTHER = "Other warning.\r\n"; |
|||
public static final String STR_EPDI_DLL_NOT_FOUND = "doesn't support this function.\r\nOr check if program architecture(x86/x64) and OS architecture are correct."; |
|||
public static final String STR_ENS_DLL_NOT_FOUND = "EpsonNet SDK isn't installed in this PC.\r\nPerfoming the printing without printer status check."; |
|||
public static final String STR_DRIVER_NOT_FOUND = "Epson printer doesn't exist. \r\n\r\nPlease install the printer driver before starting the sample program."; |
|||
public static final String STR_SYSTEM_PARAM_ERROR = "Specified value is out of range."; |
|||
public static final String STR_DRAWIMAGE_ERROR = "Failed to print image."; |
|||
|
|||
|
|||
public static boolean GetSDKError(int i, int state) { |
|||
boolean err = true; |
|||
String strMessage = ""; |
|||
String strSDKErrorCode; |
|||
|
|||
try { |
|||
if (i != ENSEnumrations.ENSErrorCode.ERR_BASE.getI()) { |
|||
strMessage = STR_ENS_ERROR; |
|||
err = false; |
|||
ENSEnumrations.ENSErrorCode ensErrorCode = ENSEnumrations.ENSErrorCode.getENSErrorCode(i); |
|||
if (ensErrorCode != null) { |
|||
strSDKErrorCode = ensErrorCode.toString(); |
|||
} |
|||
|
|||
} |
|||
} catch (Exception e) { |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
return err; |
|||
} |
|||
|
|||
|
|||
public static boolean GetEPDMError(int i, int state) |
|||
{ |
|||
boolean err = true; |
|||
String strMessage = ""; |
|||
String strEPDMErrorCode; |
|||
|
|||
try |
|||
{ |
|||
if (i != EPDMEnumrations.EPDMErrorCode.EPDM_ERR_NORMAL.getI()) |
|||
{ |
|||
switch(state) |
|||
{ |
|||
case (STATE_MEDIA_LAYOUT_ERROR): |
|||
{ |
|||
strMessage = STR_MEDIA_LAYOUT_ERROR; |
|||
err = false; |
|||
break; |
|||
} |
|||
case (STATE_MEDIA_POSITION_ERROR): |
|||
{ |
|||
strMessage = STR_MEDIA_POSITION_ERROR; |
|||
err = false; |
|||
break; |
|||
} |
|||
case (STATE_PRINT_SETTING_ERROR): |
|||
{ |
|||
strMessage = STR_PRINT_SETTING_ERROR; |
|||
err = false; |
|||
break; |
|||
} |
|||
default: |
|||
{ |
|||
strMessage = ""; |
|||
err = false; |
|||
break; |
|||
} |
|||
} |
|||
if (strMessage.length() > 0) |
|||
{ |
|||
strEPDMErrorCode = EPDMEnumrations.EPDMErrorCode.valueOf(strMessage).toString(); |
|||
} |
|||
} |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
// Error handling.
|
|||
} |
|||
return err; |
|||
} |
|||
|
|||
|
|||
public static boolean GetPrinterStatusError(ENSEnumrations.StatusCode sc, ENSEnumrations.ErrorCode ec, ENSWrapperImpl.WARNING_INFO wc) |
|||
{ |
|||
boolean err = true; |
|||
String strMessage = ""; |
|||
|
|||
try |
|||
{ |
|||
switch (sc) |
|||
{ |
|||
case ST_Busy: |
|||
{ |
|||
strMessage = STR_STATUS_BUSY; |
|||
err = false; |
|||
break; |
|||
} |
|||
case ST_Wait: |
|||
{ |
|||
strMessage = STR_STATUS_PRINTING; |
|||
err = false; |
|||
break; |
|||
} |
|||
case ST_Cleaning: |
|||
{ |
|||
strMessage = STR_STATUS_CLEANING; |
|||
err = false; |
|||
break; |
|||
} |
|||
case ST_Error: |
|||
{ |
|||
switch (ec) |
|||
{ |
|||
case ERR_PaperJam: |
|||
{ |
|||
strMessage = STR_ERROR_PAPERJAM; |
|||
err = false; |
|||
break; |
|||
} |
|||
case ERR_Paperout: |
|||
{ |
|||
strMessage = STR_ERROR_PAPEROUT; |
|||
err = false; |
|||
break; |
|||
} |
|||
case ERR_Inkout: |
|||
{ |
|||
strMessage = STR_ERROR_INKEND; |
|||
err = false; |
|||
break; |
|||
} |
|||
default: |
|||
{ |
|||
strMessage = STR_ERROR_OTHER; |
|||
err = false; |
|||
break; |
|||
} |
|||
} |
|||
break; |
|||
} |
|||
case ST_Idle: |
|||
{ |
|||
if (wc.InkLowWarning ) |
|||
{ |
|||
strMessage += STR_WARNING_INKLOW; |
|||
err = true; |
|||
} |
|||
if (wc.OtherWarning) |
|||
{ |
|||
strMessage += STR_WARNING_OTHER; |
|||
err = true; |
|||
} |
|||
break; |
|||
} |
|||
default: |
|||
{ |
|||
strMessage = STR_STATUS_OTHER; |
|||
err = false; |
|||
break; |
|||
} |
|||
} |
|||
if (strMessage.length() > 0) |
|||
{ |
|||
// MessageBox.Show((strMessage), "", MessageBoxButtons.OK);
|
|||
// 弹出一个消息框,并返回结构
|
|||
} |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
// Error handling.
|
|||
} |
|||
return err; |
|||
} |
|||
|
|||
|
|||
public static boolean GetSystemError(int state, String devName) |
|||
{ |
|||
boolean err = true; |
|||
String strMessage = ""; |
|||
|
|||
if ( devName == null) |
|||
{ |
|||
devName = ""; |
|||
} |
|||
try |
|||
{ |
|||
switch (state) |
|||
{ |
|||
case (STATE_EPDI_DLL_NOT_FOUND): |
|||
{ |
|||
strMessage = String.format("%s %s",devName, STR_EPDI_DLL_NOT_FOUND); |
|||
err = false; |
|||
break; |
|||
} |
|||
default: |
|||
{ |
|||
strMessage = ""; |
|||
err = false; |
|||
break; |
|||
} |
|||
} |
|||
if (strMessage.length() > 0) |
|||
{ |
|||
// MessageBox.Show((strMessage), "", MessageBoxButtons.OK);
|
|||
// 弹出一个文本信息框
|
|||
} |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
// Error handling.
|
|||
} |
|||
return err; |
|||
} |
|||
|
|||
public static boolean GetSystemError(int state) |
|||
{ |
|||
boolean err = true; |
|||
String strMessage = ""; |
|||
|
|||
try |
|||
{ |
|||
switch (state) |
|||
{ |
|||
case (STATE_ENS_DLL_NOT_FOUND): |
|||
{ |
|||
strMessage = STR_ENS_DLL_NOT_FOUND; |
|||
err = false; |
|||
break; |
|||
} |
|||
case (STATE_DRIVER_NOT_FOUND): |
|||
{ |
|||
strMessage = STR_DRIVER_NOT_FOUND; |
|||
err = false; |
|||
break; |
|||
} |
|||
case (STATE_SYSTEM_PARAM_ERROR): |
|||
{ |
|||
strMessage = STR_SYSTEM_PARAM_ERROR; |
|||
err = false; |
|||
break; |
|||
} |
|||
case (STATE_DRAWIMAGE_ERROR): |
|||
{ |
|||
strMessage = STR_DRAWIMAGE_ERROR; |
|||
err = false; |
|||
break; |
|||
} |
|||
default: |
|||
{ |
|||
strMessage = ""; |
|||
err = false; |
|||
break; |
|||
} |
|||
} |
|||
if (strMessage.length() > 0) |
|||
{ |
|||
// MessageBox.Show((strMessage), "", MessageBoxButtons.OK);
|
|||
// 弹出一个文本信息框
|
|||
} |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
// Error handling.
|
|||
} |
|||
return err; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,125 @@ |
|||
package com.dreamchaser.depository_manage.EPSON.Other; |
|||
|
|||
import com.dreamchaser.depository_manage.exception.MyException; |
|||
|
|||
import javax.print.PrintService; |
|||
import java.awt.*; |
|||
import java.awt.geom.Rectangle2D; |
|||
import java.awt.print.*; |
|||
|
|||
public class Print { |
|||
private int _pageNumber = 0; |
|||
private int _totalPrintPage = 0; |
|||
private boolean _exceptionFlag = false; |
|||
|
|||
private PrinterJob _pdPrint; |
|||
|
|||
|
|||
private void PD_PrintPage() |
|||
{ |
|||
try |
|||
{ |
|||
PD_PrintPage_DrawBarcode(); |
|||
PD_PrintPage_Close(); |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
// Error handling.
|
|||
_exceptionFlag = true; |
|||
} |
|||
} |
|||
|
|||
|
|||
public Print(String devName, String portName, int totalPrintPage) |
|||
{ |
|||
try |
|||
{ |
|||
// Create the PrintDocumentObject.
|
|||
_pdPrint = PrinterJob.getPrinterJob(); |
|||
// Add the PrintPageEventHandler.
|
|||
// _pdPrint.PrintPage += new PrintPageEventHandler(PD_PrintPage);
|
|||
|
|||
// Set the using Printer.
|
|||
PrintService[] printServices = PrinterJob.lookupPrintServices(); |
|||
for (PrintService printService:printServices |
|||
) { |
|||
String name = printService.getName(); |
|||
if(name.contains(devName)){ |
|||
_pdPrint.setPrintService(printService); |
|||
break; |
|||
} |
|||
} |
|||
_pdPrint.setJobName("Test Print"); |
|||
|
|||
|
|||
_totalPrintPage = totalPrintPage; |
|||
|
|||
return; |
|||
} |
|||
catch(Exception e) |
|||
{ |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
public void DoPrinting() |
|||
{ |
|||
try |
|||
{ |
|||
// Start the print.
|
|||
_pdPrint.print(); |
|||
|
|||
if(_exceptionFlag) |
|||
{ |
|||
throw new Exception(); |
|||
} |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
private void PD_PrintPage_DrawBarcode() |
|||
{ |
|||
try |
|||
{ |
|||
// 调用预设二维码打印类
|
|||
_pdPrint.setPrintable(new PrintBarCode()); |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
private void PD_PrintPage_Close() |
|||
{ |
|||
try |
|||
{ |
|||
// Check final page.
|
|||
if (_pageNumber < _totalPrintPage) |
|||
{ |
|||
_pdPrint.cancel(); |
|||
} |
|||
|
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,57 @@ |
|||
package com.dreamchaser.depository_manage.EPSON.Other; |
|||
|
|||
import java.awt.*; |
|||
import java.awt.print.PageFormat; |
|||
import java.awt.print.Printable; |
|||
import java.awt.print.PrinterException; |
|||
|
|||
public class PrintBarCode implements Printable { |
|||
|
|||
/** |
|||
|
|||
* @param graphics 指明打印的图形环境 |
|||
|
|||
* @param pageFormat 指明打印页格式(页面大小以点为计量单位,1点为1英才的1/72,1英寸为25.4毫米。A4纸大致为595×842点) |
|||
|
|||
* @param pageIndex 指明页号 |
|||
|
|||
**/ |
|||
|
|||
// 设置用于打印的编码
|
|||
public String code; |
|||
|
|||
|
|||
public void setCode(String code) { |
|||
this.code = code; |
|||
} |
|||
|
|||
@Override |
|||
public int print(Graphics g, PageFormat pf, int pageIndex) throws PrinterException { |
|||
|
|||
|
|||
//print string
|
|||
String str = code; |
|||
|
|||
//转换成Graphics2D
|
|||
Graphics2D g2 = (Graphics2D) g; |
|||
|
|||
//设置打印颜色为黑色
|
|||
g2.setColor(Color.black); |
|||
|
|||
//打印起点坐标
|
|||
double x = pf.getImageableX(); |
|||
double y = pf.getImageableY(); |
|||
|
|||
if (pageIndex == 0) {//设置打印字体(字体名称、样式和点大小)(字体名称可以是物理或者逻辑名称)
|
|||
|
|||
//Java平台所定义的五种字体系列:Serif、SansSerif、Monospaced、Dialog 和 DialogInput
|
|||
Font font = new Font("Courier New", Font.PLAIN, 9); |
|||
g2.setFont(font);//设置字体
|
|||
|
|||
g2.drawString(code,20,100); |
|||
|
|||
return PAGE_EXISTS; |
|||
} |
|||
return NO_SUCH_PAGE; |
|||
} |
|||
} |
|||
@ -0,0 +1,57 @@ |
|||
package com.dreamchaser.depository_manage.EPSON.Other; |
|||
|
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.profesorfalken.wmi4java.WMI4Java; |
|||
import org.apache.catalina.Manager; |
|||
|
|||
import javax.print.PrintService; |
|||
import javax.print.attribute.PrintServiceAttributeSet; |
|||
import java.awt.*; |
|||
import java.awt.print.PrinterJob; |
|||
import java.io.PrintStream; |
|||
import java.net.InetAddress; |
|||
import java.net.Socket; |
|||
import java.util.ArrayList; |
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 用于实现打印机选择的类 |
|||
*/ |
|||
public class SelectPrinterInfo { |
|||
|
|||
public static List<PRINTER_INFO> GetPrinterInfoList() { |
|||
|
|||
//定义打印机信息列表
|
|||
List<PRINTER_INFO> printerInfoList = new ArrayList<PRINTER_INFO>(); |
|||
PRINTER_INFO printerInfo; |
|||
try { |
|||
// 获取本地所有打印机
|
|||
List<Map<String, String>> wmiObjectListProperties = WMI4Java.get().getWMIObjectList("Win32_PRINTER"); |
|||
for (Map<String,String> printer:wmiObjectListProperties |
|||
) { |
|||
|
|||
printerInfo = new PRINTER_INFO(); |
|||
// 获取设备名称
|
|||
printerInfo.devName = printer.get("Name"); |
|||
// 获取端口名称
|
|||
printerInfo.portName =printer.get("PortName") ; |
|||
|
|||
if (printerInfo.devName.contains("EPSON")){ |
|||
printerInfoList.add(printerInfo); |
|||
} |
|||
|
|||
} |
|||
return printerInfoList; |
|||
} catch (Exception e) { |
|||
System.out.println(e.getMessage()); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
public static class PRINTER_INFO { |
|||
public String devName; |
|||
public String portName; |
|||
} |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
package com.dreamchaser.depository_manage.EPSON.epsonException; |
|||
|
|||
import com.dreamchaser.depository_manage.EPSON.ENS.ENSEnumrations; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
/** |
|||
* 用于ENS的错误类 |
|||
*/ |
|||
@EqualsAndHashCode(callSuper = true) |
|||
@Data |
|||
public class ENSException extends Exception{ |
|||
|
|||
private static final long serialVersionUID = -2429062150745133718L; |
|||
|
|||
/** |
|||
* 错误类型 |
|||
*/ |
|||
public ENSEnumrations.ENSErrorCode ensErrorCode; |
|||
|
|||
|
|||
public ENSEnumrations.ENSErrorCode getEnsErrorCode() { |
|||
return ensErrorCode; |
|||
} |
|||
|
|||
public void setEnsErrorCode(ENSEnumrations.ENSErrorCode ensErrorCode) { |
|||
this.ensErrorCode = ensErrorCode; |
|||
} |
|||
|
|||
public ENSException(ENSEnumrations.ENSErrorCode e) |
|||
{ |
|||
ensErrorCode = e; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
package com.dreamchaser.depository_manage.EPSON.epsonException; |
|||
|
|||
import com.dreamchaser.depository_manage.EPSON.EPDM.EPDMEnumrations; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
/** |
|||
* 用于EPDM的错误类 |
|||
*/ |
|||
@EqualsAndHashCode(callSuper = true) |
|||
@Data |
|||
public class EPDMException extends Exception { |
|||
|
|||
private static final long serialVersionUID = 6037874212969710082L; |
|||
|
|||
/** |
|||
* 错误类型 |
|||
*/ |
|||
public EPDMEnumrations.EPDMErrorCode epdmErrorCode; |
|||
|
|||
public EPDMException(EPDMEnumrations.EPDMErrorCode e) |
|||
{ |
|||
epdmErrorCode = e; |
|||
} |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
package com.dreamchaser.depository_manage.config.EPSON.ENS; |
|||
|
|||
import com.dreamchaser.depository_manage.EPSON.ENS.ENSStatus; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public class Global_MEDIA_ENS { |
|||
|
|||
/** |
|||
* 用于全局INKSIDMSTATUS_02中的实现 |
|||
*/ |
|||
public static Map<Integer, ENSStatus.INKSIDMSTATUS_02> integerINKSIDMSTATUS_02Map = new HashMap<>(); |
|||
|
|||
|
|||
/** |
|||
* 用于存储ENS中出现要进行暂存的字符串 |
|||
*/ |
|||
public static Map<Integer,String> ENS_STRUCTURE_Str = new HashMap<>(); |
|||
} |
|||
@ -0,0 +1,77 @@ |
|||
package com.dreamchaser.depository_manage.config.EPSON.EPDM; |
|||
|
|||
|
|||
import com.dreamchaser.depository_manage.EPSON.EPDM.EPDMMediaLayoutRange; |
|||
import com.dreamchaser.depository_manage.EPSON.EPDM.EPDMMediaTypeRange; |
|||
import com.dreamchaser.depository_manage.EPSON.EPDM.EPDMSelectData; |
|||
import com.dreamchaser.depository_manage.EPSON.EPDM.EPDMString; |
|||
import com.dreamchaser.depository_manage.entity.EPSON.EPDM.EPDMMediaLayoutInf; |
|||
import com.dreamchaser.depository_manage.entity.EPSON.EPDM.MEDIA_LAYOUT_RANGE; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public class Global_MEDIA_EPDM { |
|||
/** |
|||
* 用于全局MEDIA_LAYOUT_RANGE中的实现 |
|||
*/ |
|||
public static Map<Integer,MEDIA_LAYOUT_RANGE> media_layout_rangeMap = new HashMap<>(); |
|||
|
|||
/** |
|||
* 用于全局EPDMMediaLayoutRange的实现 |
|||
*/ |
|||
public static Map<Integer,EPDMMediaLayoutRange> epdmMediaLayoutRangeMap = new HashMap<>(); |
|||
|
|||
|
|||
/** |
|||
* 用于全局EPDM_MEDIALAYOUTRANGE的实现 |
|||
*/ |
|||
public static Map<Integer, EPDMMediaLayoutRange.EPDM_MEDIALAYOUTRANGE> epdm_medialayoutrangeMap = new HashMap<>(); |
|||
|
|||
|
|||
/** |
|||
* |
|||
* 用于全局EPDM_MEDIATYPERANGE的实现 |
|||
*/ |
|||
public static Map<Integer, EPDMMediaTypeRange.EPDM_MEDIATYPERANGE> epdm_mediatyperangeMap = new HashMap<>(); |
|||
|
|||
|
|||
/** |
|||
* 用于全局EPDM_SELECTDATA的实现 |
|||
*/ |
|||
public static Map<Integer, EPDMSelectData.EPDM_SELECTDATA> epdm_selectdataMap = new HashMap<>(); |
|||
|
|||
/** |
|||
* 用于EPDMMediaLayoutRange中的PtrToStructure转short |
|||
*/ |
|||
public static Map<Integer,Short> epdm_mediaLayoutRange_short = new HashMap<>(); |
|||
|
|||
/** |
|||
* 用于全局EPDM_STRING_1的实现 |
|||
*/ |
|||
public static Map<Integer, EPDMString.EPDM_STRING_1> epdm_string_1Map = new HashMap<>(); |
|||
|
|||
|
|||
/** |
|||
* 用于EPDMSelectData中的使用 |
|||
*/ |
|||
public static List<Long> epdm_select_data_int64 = new ArrayList<>(); |
|||
public static List<Integer> epdm_select_data_int32 = new ArrayList<>(); |
|||
public static List<Short> epdm_select_data_int16 = new ArrayList<>(); |
|||
|
|||
|
|||
/** |
|||
* 用于EPDMString中使用的byte |
|||
*/ |
|||
public static Map<Integer,Byte> epdm_epdmString_byte = new HashMap<>(); |
|||
|
|||
|
|||
/** |
|||
* 用于全局EPDM_MEDIALAYOUTINF的实现 |
|||
*/ |
|||
public static Map<Integer, EPDMMediaLayoutInf.EPDM_MEDIALAYOUTINF> epdm_medialayoutinfMap = new HashMap<>(); |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,102 @@ |
|||
package com.dreamchaser.depository_manage.controller.EPSON; |
|||
|
|||
import com.dreamchaser.depository_manage.EPSON.Other.MessageString; |
|||
import com.dreamchaser.depository_manage.EPSON.epsonException.EPDMException; |
|||
import com.dreamchaser.depository_manage.entity.EPSON.EPDM.MEDIA_LAYOUT_RANGE; |
|||
import com.dreamchaser.depository_manage.exception.MyException; |
|||
import com.dreamchaser.depository_manage.service.impl.EPSON.EPDM.EPDMWrapperImpl; |
|||
|
|||
public class AddMediaLayoutDlg { |
|||
|
|||
private String _devName; |
|||
private String _portName; |
|||
private boolean _isEPDMOpen = true; |
|||
|
|||
public AddMediaLayoutDlg(String devName, String portName) |
|||
{ |
|||
|
|||
_devName = devName; |
|||
_portName = portName; |
|||
} |
|||
|
|||
public void AddMediaLayoutDlg_Load() |
|||
{ |
|||
try |
|||
{ |
|||
EPDMWrapperImpl.GetInstance().Open(_devName, _portName); |
|||
UpdateMediaLayoutRangeString(); |
|||
} catch (Exception e) |
|||
{ |
|||
// Error handling.
|
|||
ExceptionClose(); |
|||
} |
|||
} |
|||
/** |
|||
* 这是更新媒体布局范围字符串的方法。 |
|||
*/ |
|||
private void UpdateMediaLayoutRangeString() { |
|||
MEDIA_LAYOUT_RANGE obj = EPDMWrapperImpl.GetInstance().GetMediaLayoutRangeValue(); |
|||
GetMediaLayoutRangeString(MediaLayoutRangeToString(obj.MinPaperWid), MediaLayoutRangeToString(obj.MaxPaperWid)); |
|||
GetMediaLayoutRangeString(MediaLayoutRangeToString(obj.MinLabelWid), MediaLayoutRangeToString(obj.MaxLabelWid)); |
|||
GetMediaLayoutRangeString(MediaLayoutRangeToString(obj.MinLabelHig), MediaLayoutRangeToString(obj.MaxLabelHig)); |
|||
GetMediaLayoutRangeString(MediaLayoutRangeToString(obj.MinLabelGap), MediaLayoutRangeToString(obj.MaxLabelGap)); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 这是获取媒体布局范围字符串的方法。 |
|||
* @param minRangeString 最小范围字符串。 |
|||
* @param maxRangeString 最大范围字符串。 |
|||
* @return |
|||
*/ |
|||
private String GetMediaLayoutRangeString(String minRangeString, String maxRangeString) { |
|||
try { |
|||
String rangeString = ""; |
|||
|
|||
if (minRangeString.length() > 0 && maxRangeString.length() > 0) { |
|||
rangeString = "( " + minRangeString + " - " + maxRangeString + " )"; |
|||
} |
|||
return rangeString; |
|||
} catch (Exception e) { |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 这是将媒体布局范围值更改为字符串的方法。 |
|||
* |
|||
* @param size 介质布局范围值(0.1mm单位) |
|||
* @return |
|||
*/ |
|||
private String MediaLayoutRangeToString(double size) { |
|||
try { |
|||
// Changed the size. (0.1mm to mm)
|
|||
double d = size / 10; |
|||
|
|||
return String.format("%01f", d); |
|||
} catch (Exception e) { |
|||
// Error handling.
|
|||
ExceptionClose(); |
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 这是关闭应用的方法。 |
|||
*/ |
|||
private void ExceptionClose() { |
|||
EPDMClose(); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 这是用于关闭的方法 |
|||
*/ |
|||
private void EPDMClose() { |
|||
if (_isEPDMOpen) { |
|||
EPDMWrapperImpl.GetInstance().Close(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,80 @@ |
|||
package com.dreamchaser.depository_manage.controller.EPSON; |
|||
|
|||
import com.dreamchaser.depository_manage.EPSON.ENS.ENSEnumrations; |
|||
import com.dreamchaser.depository_manage.EPSON.Other.MessageString; |
|||
import com.dreamchaser.depository_manage.EPSON.Other.Print; |
|||
import com.dreamchaser.depository_manage.EPSON.epsonException.ENSException; |
|||
import com.dreamchaser.depository_manage.exception.MyException; |
|||
import com.dreamchaser.depository_manage.service.impl.EPSON.ENS.ENSWrapper; |
|||
import com.dreamchaser.depository_manage.service.impl.EPSON.ENS.ENSWrapperImpl; |
|||
|
|||
public class PrintDlg { |
|||
private String _devName; |
|||
private String _portName; |
|||
private boolean _isENSInitialize = true; |
|||
|
|||
|
|||
/** |
|||
* 这是PrintDlg的构造函数 |
|||
* |
|||
* @param devName 选中的打印机的设备名称 |
|||
* @param portName 选中的打印机的端口名称 |
|||
*/ |
|||
public PrintDlg(String devName, String portName) { |
|||
|
|||
_devName = devName; |
|||
_portName = portName; |
|||
} |
|||
|
|||
/** |
|||
* 获取打印机状态和打印动作。 |
|||
*/ |
|||
private void PrintButton_Click() { |
|||
ENSWrapperImpl obj = ENSWrapperImpl.GetInstance(); |
|||
// 获取打印数量
|
|||
int printPage = 1; |
|||
try { |
|||
try { |
|||
obj.Initialize(_devName, _portName); |
|||
} catch (Exception e) { |
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
if (_isENSInitialize) { |
|||
ENSEnumrations.StatusCode sc = obj.GetStatusInformation(); |
|||
ENSEnumrations.ErrorCode ec = obj.GetErrorInformation(); |
|||
ENSWrapperImpl.WARNING_INFO wc = obj.GetWarningInformation(); |
|||
if (!MessageString.GetPrinterStatusError(sc, ec, wc)) { |
|||
return; |
|||
} |
|||
} |
|||
|
|||
Print print = new Print(_devName, _portName, printPage); |
|||
print.DoPrinting(); |
|||
} catch (Exception e) { |
|||
// Error handling.
|
|||
ExceptionClose(); |
|||
} finally { |
|||
ENSClose(); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
private void ENSClose() { |
|||
if (_isENSInitialize) { |
|||
try { |
|||
ENSWrapperImpl.GetInstance().Release(); |
|||
} catch (Exception e) { |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// This is the method that close application.
|
|||
/// </summary>
|
|||
private void ExceptionClose() { |
|||
ENSClose(); |
|||
} |
|||
} |
|||
@ -0,0 +1,279 @@ |
|||
package com.dreamchaser.depository_manage.controller.EPSON; |
|||
|
|||
import com.dreamchaser.depository_manage.EPSON.Other.MessageString; |
|||
import com.dreamchaser.depository_manage.EPSON.epsonException.EPDMException; |
|||
import com.dreamchaser.depository_manage.entity.EPSON.EPDM.MEDIA_LAYOUT; |
|||
import com.dreamchaser.depository_manage.entity.EPSON.EPDM.MEDIA_TYPE; |
|||
import com.dreamchaser.depository_manage.entity.EPSON.EPDM.PRINT_QUALITY; |
|||
import com.dreamchaser.depository_manage.exception.MyException; |
|||
import com.dreamchaser.depository_manage.service.impl.EPSON.EPDM.EPDMWrapper; |
|||
import com.dreamchaser.depository_manage.service.impl.EPSON.EPDM.EPDMWrapperImpl; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
|
|||
public class PrintSettingsDlg { |
|||
private List<MEDIA_LAYOUT> _mediaLayoutList; |
|||
private List<MEDIA_TYPE> _mediaTypeList; |
|||
private List<PRINT_QUALITY> _printQualityList; |
|||
private String _devName; |
|||
private String _portName; |
|||
private boolean _isEPDMOpen = true; |
|||
|
|||
/** |
|||
* 这是PrintSettingsDlg的构造函数。 |
|||
* @param devName |
|||
* @param portName |
|||
*/ |
|||
public PrintSettingsDlg(String devName, String portName) |
|||
{ |
|||
|
|||
_devName = devName; |
|||
_portName = portName; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 初始化加载方法 |
|||
*/ |
|||
public Map<String,List<String>> PrintSettings_Load() |
|||
{ |
|||
try |
|||
{ |
|||
EPDMWrapperImpl.GetInstance().Open(_devName, _portName); |
|||
List<String> StrMediaLayoutList = UpdateMediaLayoutComboBox(); |
|||
List<String> StrMediaTypeList = UpdateMediaTypeComboBox(); |
|||
List<String> StrPrintQualityList = UpdatePrintQualityComboBox(); |
|||
Map<String,List<String>> listMap = new HashMap<>(); |
|||
listMap.put("StrMediaLayoutList",StrMediaLayoutList); |
|||
listMap.put("StrMediaTypeList",StrMediaTypeList); |
|||
listMap.put("StrPrintQualityList",StrPrintQualityList); |
|||
return listMap; |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
// Error handling.
|
|||
ExceptionClose(); |
|||
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 这是在MediaTypeComboBox更改操作上实现更新打印质量列表的事件处理程序。 |
|||
*/ |
|||
private void MediaTypeComboBox_SelectedIndexChanged() |
|||
{ |
|||
try |
|||
{ |
|||
EPDMWrapperImpl obj = EPDMWrapperImpl.GetInstance(); |
|||
// int index = MediaTypeComboBox.SelectedIndex;
|
|||
int index = 1; // 获取选中的数据的下标
|
|||
|
|||
obj.SetMediaType(_mediaTypeList.get(index).getMediaTypeID()); |
|||
|
|||
// 同时获取输出index
|
|||
_printQualityList = obj.GetPrintQualityList(index); |
|||
if (_printQualityList == null) |
|||
{ |
|||
return; |
|||
} |
|||
List<String> StrPrintQualityList = new ArrayList<>(); |
|||
|
|||
// PrintQualityComboBox.Items.Clear();
|
|||
|
|||
for (PRINT_QUALITY printQuality : _printQualityList) |
|||
{ |
|||
StrPrintQualityList.add(printQuality.getStrPrintQuality()); |
|||
// PrintQualityComboBox.Items.Add(printQuality.StrPrintQuality);
|
|||
// this.Controls.Add(PrintQualityComboBox);
|
|||
} |
|||
// 设置选中的下标
|
|||
// PrintQualityComboBox.SelectedIndex = index;
|
|||
} catch (Exception ep) |
|||
{ |
|||
// Error handling.
|
|||
ExceptionClose(); |
|||
} |
|||
} |
|||
|
|||
|
|||
private void ApplyButton_Click() |
|||
{ |
|||
EPDMWrapperImpl obj = EPDMWrapperImpl.GetInstance(); |
|||
try |
|||
{ |
|||
int index = 0; |
|||
|
|||
// index为选中的媒体布局下标
|
|||
// index = MediaLayoutComboBox.SelectedIndex;
|
|||
obj.SetMediaLayout(_mediaLayoutList.get(index).getMediaLayoutID()); |
|||
|
|||
// index为选中的媒体类型下标
|
|||
// index = MediaTypeComboBox.SelectedIndex;
|
|||
obj.SetMediaType(_mediaTypeList.get(index).getMediaTypeID()); |
|||
//
|
|||
// index为选中的打印质量下标
|
|||
// index = PrintQualityComboBox.SelectedIndex;
|
|||
if (index >= 0) |
|||
{ |
|||
// 如果选中的大于0
|
|||
obj.SetPrintQuality(_printQualityList.get(index).getPrintQualityID()); |
|||
} |
|||
else |
|||
{ |
|||
// 否则设置为将打印质量设置为不可用
|
|||
// PrintQualityComboBox.Enabled = false;
|
|||
} |
|||
obj.UpdateDevMode(); |
|||
} catch (Exception e) |
|||
{ |
|||
// Error handling.
|
|||
ExceptionClose(); |
|||
} |
|||
finally |
|||
{ |
|||
EPDMClose(); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
/** |
|||
* 这是更新打印质量组合框列表的方法。 |
|||
*/ |
|||
private List<String> UpdatePrintQualityComboBox() |
|||
{ |
|||
// 用于保存当前打印质量
|
|||
List<String> StrPrintQualityList = new ArrayList<>(); |
|||
try |
|||
{ |
|||
Integer index = 0; |
|||
|
|||
_printQualityList = EPDMWrapperImpl.GetInstance().GetPrintQualityList( index); |
|||
if (_printQualityList == null) |
|||
{ |
|||
return null; |
|||
} |
|||
|
|||
for (PRINT_QUALITY printQuality : _printQualityList) |
|||
{ |
|||
StrPrintQualityList.add(printQuality.getStrPrintQuality()); |
|||
} |
|||
return StrPrintQualityList; |
|||
// index 是选中的打印质量
|
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 这是更新媒体类型组合框列表的方法。 |
|||
*/ |
|||
private List<String> UpdateMediaTypeComboBox() |
|||
{ |
|||
try |
|||
{ |
|||
int index = 0; |
|||
|
|||
_mediaTypeList = EPDMWrapperImpl.GetInstance().GetMediaTypeList(index); |
|||
if (_mediaTypeList == null) |
|||
{ |
|||
return null; |
|||
} |
|||
List<String> StrMediaTypeList = new ArrayList<>(); |
|||
|
|||
|
|||
for (MEDIA_TYPE mediaType : _mediaTypeList) |
|||
{ |
|||
// MediaTypeComboBox.Items.Add(mediaType.StrMediaType);
|
|||
// this.Controls.Add(MediaTypeComboBox);
|
|||
StrMediaTypeList.add(mediaType.getStrMediaType()); |
|||
} |
|||
|
|||
return StrMediaTypeList; |
|||
// MediaTypeComboBox.SelectedIndex = index;
|
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 这是更新媒体布局组合框列表的方法。 |
|||
*/ |
|||
private List<String> UpdateMediaLayoutComboBox() |
|||
{ |
|||
try |
|||
{ |
|||
int index = 0; |
|||
|
|||
_mediaLayoutList = EPDMWrapperImpl.GetInstance().GetMediaLayoutList(index); |
|||
if (_mediaLayoutList == null) |
|||
{ |
|||
return null; |
|||
} |
|||
|
|||
List<String> StrMediaLayoutList = new ArrayList<>(); |
|||
|
|||
|
|||
for (MEDIA_LAYOUT mediaLayout : _mediaLayoutList) |
|||
{ |
|||
StrMediaLayoutList.add(mediaLayout.getStrMediaLayout()); |
|||
} |
|||
// index是选中的下标
|
|||
return StrMediaLayoutList; |
|||
|
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 这是关闭PrintSettingsDlg的方法。 |
|||
*/ |
|||
private void EPDMClose() |
|||
{ |
|||
if (_isEPDMOpen) |
|||
{ |
|||
try |
|||
{ |
|||
EPDMWrapperImpl.GetInstance().Close(); |
|||
} catch (Exception e) |
|||
{ |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
/** |
|||
* 这是关闭对话的方法 |
|||
*/ |
|||
private void ExceptionClose() |
|||
{ |
|||
EPDMClose(); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,80 @@ |
|||
package com.dreamchaser.depository_manage.controller.EPSON; |
|||
|
|||
import com.dreamchaser.depository_manage.EPSON.Other.MessageString; |
|||
import com.dreamchaser.depository_manage.EPSON.Other.SelectPrinterInfo; |
|||
import com.dreamchaser.depository_manage.exception.MyException; |
|||
import com.dreamchaser.depository_manage.pojo.RestResponse; |
|||
import com.dreamchaser.depository_manage.utils.CrudUtil; |
|||
import com.dreamchaser.depository_manage.utils.ObjectFormatUtil; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.io.*; |
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
@RestController |
|||
@RequestMapping("/Epson") |
|||
public class PrinterIndexDlg { |
|||
|
|||
private List<SelectPrinterInfo.PRINTER_INFO> _printerInfoList; |
|||
|
|||
private PrintSettingsDlg printSettingsDlg; |
|||
|
|||
/** |
|||
* 用于获取当前电脑的爱普生打印机列表 |
|||
* @return |
|||
*/ |
|||
@PostMapping("/GetPrinterInfoList") |
|||
public RestResponse GetPrinterInfoList(){ |
|||
try { |
|||
List<String> list = new ArrayList<>(); |
|||
_printerInfoList = SelectPrinterInfo.GetPrinterInfoList(); |
|||
if (_printerInfoList.size() == 0) { |
|||
MessageString.GetSystemError(MessageString.STATE_DRIVER_NOT_FOUND); |
|||
return new RestResponse(null); |
|||
} else { |
|||
for (SelectPrinterInfo.PRINTER_INFO printerInfo : _printerInfoList) |
|||
{ |
|||
list.add(printerInfo.devName); |
|||
} |
|||
} |
|||
return new RestResponse(list); |
|||
}catch (Exception e){ |
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 用于初始化打印机设置页面 |
|||
* @param map 选中的打印机 |
|||
* @return |
|||
*/ |
|||
@PostMapping("/PrintSettingLoad") |
|||
public RestResponse PrintSettingLoad(@RequestBody Map<String,Object> map){ |
|||
if(map.containsKey("index")){ |
|||
Integer index = ObjectFormatUtil.toInteger(map.get("index")); |
|||
printSettingsDlg = new PrintSettingsDlg(_printerInfoList.get(index).devName,_printerInfoList.get(index).portName); |
|||
return new RestResponse(200); |
|||
}else{ |
|||
throw new MyException("缺少必要参数"); |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
/** |
|||
* 用于初始化打印机设置页面中的列表 |
|||
* @return |
|||
*/ |
|||
@PostMapping("/updatePrintSettingPage") |
|||
public RestResponse updatePrintSettingPage(){ |
|||
Map<String, List<String>> listMap = printSettingsDlg.PrintSettings_Load(); |
|||
return new RestResponse(listMap); |
|||
} |
|||
} |
|||
@ -0,0 +1,99 @@ |
|||
package com.dreamchaser.depository_manage.controller.EPSON; |
|||
|
|||
import com.dreamchaser.depository_manage.EPSON.Other.MessageString; |
|||
import com.dreamchaser.depository_manage.EPSON.epsonException.EPDMException; |
|||
import com.dreamchaser.depository_manage.entity.EPSON.EPDM.MEDIA_POSITION; |
|||
import com.dreamchaser.depository_manage.exception.MyException; |
|||
import com.dreamchaser.depository_manage.service.impl.EPSON.EPDM.EPDMWrapperImpl; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
public class SetRollPaperDlg { |
|||
private List<MEDIA_POSITION> _mediaPositionList; |
|||
private String _devName; |
|||
private String _portName; |
|||
private boolean _isEPDMOpen = true; |
|||
|
|||
public SetRollPaperDlg(String _devName, String _portName) { |
|||
this._devName = _devName; |
|||
this._portName = _portName; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 这是加载时的方法 |
|||
*/ |
|||
private void SetRollPaperDlg_Load(){ |
|||
try |
|||
{ |
|||
EPDMWrapperImpl.GetInstance().Open(_devName, _portName); |
|||
UpdateMediaPositionComboBox(); |
|||
} catch (Exception e) |
|||
{ |
|||
// Error handling.
|
|||
ExceptionClose(); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 这是更新媒体位置组合框列表的方法 |
|||
*/ |
|||
private void UpdateMediaPositionComboBox(){ |
|||
List<String> strMediaPositionList = new ArrayList<>(); |
|||
try |
|||
{ |
|||
Integer index = 0; |
|||
|
|||
_mediaPositionList = EPDMWrapperImpl.GetInstance().GetMediaPositionList(index); |
|||
if (_mediaPositionList == null) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
|
|||
for (MEDIA_POSITION mediaPosition : _mediaPositionList) |
|||
{ |
|||
strMediaPositionList.add(mediaPosition.StrMediaPosition); |
|||
} |
|||
// 最终选中
|
|||
// MediaPositionComboBox.SelectedIndex = index;
|
|||
|
|||
} catch (Exception e) |
|||
{ |
|||
// Error handling.
|
|||
ExceptionClose(); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 这是用于关闭EPDM的方法 |
|||
*/ |
|||
private void EPDMClose() |
|||
{ |
|||
if (_isEPDMOpen) |
|||
{ |
|||
try |
|||
{ |
|||
EPDMWrapperImpl.GetInstance().Close(); |
|||
} catch (Exception e) |
|||
{ |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 这是用于关闭的的方法。 |
|||
*/ |
|||
private void ExceptionClose() |
|||
{ |
|||
EPDMClose(); |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,149 @@ |
|||
package com.dreamchaser.depository_manage.entity.EPSON.EPDM; |
|||
|
|||
import com.dreamchaser.depository_manage.EPSON.EPDM.EPDM; |
|||
import com.dreamchaser.depository_manage.EPSON.EPDM.EPDMEnumrations; |
|||
import com.dreamchaser.depository_manage.config.EPSON.EPDM.Global_MEDIA_EPDM; |
|||
import com.sun.jna.Memory; |
|||
import com.sun.jna.Pointer; |
|||
import com.sun.jna.Structure; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
|
|||
public class EPDMMediaLayoutInf extends EPDM { |
|||
|
|||
|
|||
public class EPDM_MEDIALAYOUTINF extends Structure |
|||
{ |
|||
public int dwVersion; |
|||
public int dwSize; |
|||
public short iPaperWid; |
|||
public short iPaperHig; |
|||
public short iLabelWid; |
|||
public short iLabelHig; |
|||
public short iLabelGap; |
|||
public short iBMGap; |
|||
public short iPrintWid; |
|||
public short iPrintHig; |
|||
public short iPrintX; |
|||
public short iPrintY; |
|||
public short iMediaTypeID; |
|||
public short iMediaLayoutID; |
|||
|
|||
|
|||
@Override |
|||
protected List<String> getFieldOrder() { |
|||
return new ArrayList<>(Arrays.asList("dwVersion","dwSize","iPaperWid","iPaperHig","iLabelWid","iLabelHig","iLabelGap","iBMGap" |
|||
,"iPrintWid","iPrintHig","iPrintX","iPrintY","iMediaTypeID","iMediaLayoutID")); |
|||
} |
|||
|
|||
public EPDM_MEDIALAYOUTINF() { |
|||
} |
|||
|
|||
public EPDM_MEDIALAYOUTINF(Pointer p) { |
|||
super(p); |
|||
} |
|||
|
|||
}; |
|||
|
|||
public short PaperWid; |
|||
|
|||
public short getPaperWid() { |
|||
return _struct.iPaperWid; |
|||
} |
|||
|
|||
public void setPaperWid(short paperWid) { |
|||
_struct.iPaperWid = paperWid; |
|||
} |
|||
|
|||
public short LabelWid; |
|||
|
|||
public short getLabelWid() { |
|||
return _struct.iLabelWid; |
|||
} |
|||
|
|||
public void setLabelWid(short labelWid) { |
|||
_struct.iLabelWid = labelWid; |
|||
} |
|||
public short LabelHig; |
|||
|
|||
public short getLabelHig() { |
|||
return _struct.iLabelHig; |
|||
} |
|||
|
|||
public void setLabelHig(short labelHig) { |
|||
_struct.iLabelHig = labelHig; |
|||
} |
|||
|
|||
public short LabelGap; |
|||
|
|||
public short getLabelGap() { |
|||
return _struct.iLabelGap; |
|||
} |
|||
|
|||
public void setLabelGap(short labelGap) { |
|||
_struct.iLabelGap = labelGap; |
|||
} |
|||
|
|||
public short MediaTypeID; |
|||
|
|||
public short getMediaTypeID() { |
|||
return _struct.iMediaTypeID; |
|||
} |
|||
|
|||
public void setMediaTypeID(short mediaTypeID) { |
|||
_struct.iMediaTypeID = mediaTypeID; |
|||
} |
|||
public short MediaLayoutID; |
|||
|
|||
public short getMediaLayoutID() { |
|||
return _struct.iMediaLayoutID; |
|||
} |
|||
|
|||
public void setMediaLayoutID(short mediaLayoutID) { |
|||
_struct.iMediaLayoutID = mediaLayoutID; |
|||
} |
|||
|
|||
|
|||
|
|||
private boolean _disposed = false; |
|||
public EPDM_MEDIALAYOUTINF _struct; |
|||
|
|||
|
|||
public EPDMMediaLayoutInf() |
|||
{ |
|||
int structSize = 12 * Short.SIZE / 8 + Integer.SIZE / 8 * 2; |
|||
_ptrToStruct = new Memory(structSize); |
|||
|
|||
_struct = new EPDM_MEDIALAYOUTINF(_ptrToStruct); |
|||
_struct.dwVersion = EPDMEnumrations.StructVersion.EPDM_STVER_MEDIALAYOUTINF.getI(); |
|||
_struct.dwSize = structSize; |
|||
_struct.iPaperWid = 0; |
|||
_struct.iPaperHig = 0; |
|||
_struct.iLabelWid = 0; |
|||
_struct.iLabelHig = 0; |
|||
_struct.iLabelGap = 0; |
|||
_struct.iBMGap = 0; |
|||
_struct.iPrintWid = 0; |
|||
_struct.iPrintHig = 0; |
|||
_struct.iPrintX = 0; |
|||
_struct.iPrintY = 0; |
|||
_struct.iMediaTypeID = 0; |
|||
_struct.iMediaLayoutID = 0; |
|||
StructureToPtr(); |
|||
PtrToStructure(); |
|||
} |
|||
|
|||
@Override |
|||
public void PtrToStructure() { |
|||
_struct.read(); |
|||
_struct = Global_MEDIA_EPDM.epdm_medialayoutinfMap.get(_ptrToStruct.getInt(0)); |
|||
} |
|||
|
|||
@Override |
|||
public void StructureToPtr() { |
|||
_struct.write(); |
|||
Global_MEDIA_EPDM.epdm_medialayoutinfMap.put(_ptrToStruct.getInt(0),_struct); |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
package com.dreamchaser.depository_manage.entity.EPSON.EPDM; |
|||
|
|||
import lombok.Data; |
|||
|
|||
/** |
|||
*这是定义媒体布局信息的类。 |
|||
*/ |
|||
@Data |
|||
public class MEDIA_LAYOUT { |
|||
public String StrMediaLayout; |
|||
public int MediaLayoutID; |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
package com.dreamchaser.depository_manage.entity.EPSON.EPDM; |
|||
|
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* 这是定义介质分布范围值的类 |
|||
*/ |
|||
@Data |
|||
public class MEDIA_LAYOUT_RANGE { |
|||
public short MinPaperWid; |
|||
public short MaxPaperWid; |
|||
public short MinLabelWid; |
|||
public short MaxLabelWid; |
|||
public short MinLabelHig; |
|||
public short MaxLabelHig; |
|||
public short MinLabelGap; |
|||
public short MaxLabelGap; |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
package com.dreamchaser.depository_manage.entity.EPSON.EPDM; |
|||
|
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* 这是定义媒体位置信息的类 |
|||
*/ |
|||
@Data |
|||
public class MEDIA_POSITION { |
|||
public String StrMediaPosition; |
|||
public int MediaPositionID; |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
package com.dreamchaser.depository_manage.entity.EPSON.EPDM; |
|||
|
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* 这是定义媒体类型信息的类 |
|||
*/ |
|||
@Data |
|||
public class MEDIA_TYPE { |
|||
public String StrMediaType; |
|||
public int MediaTypeID; |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
package com.dreamchaser.depository_manage.entity.EPSON.EPDM; |
|||
|
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* 这是定义打印质量信息的类。 |
|||
*/ |
|||
@Data |
|||
public class PRINT_QUALITY { |
|||
public String StrPrintQuality; |
|||
public int PrintQualityID; |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
package com.dreamchaser.depository_manage.service.impl.EPSON.ENS; |
|||
|
|||
import com.dreamchaser.depository_manage.service.impl.EPSON.EPDM.EPDMWrapper; |
|||
import com.sun.jna.Library; |
|||
import com.sun.jna.Native; |
|||
import com.sun.jna.Pointer; |
|||
import com.sun.jna.ptr.IntByReference; |
|||
|
|||
public interface ENSWrapper extends Library { |
|||
|
|||
String strLibrary = "C:/Program Files (x86)/EpsonNet/EpsonNetSDK/EpsonNetSDK"; |
|||
// String strLibrary = "C://Program Files//EpsonNet//EpsonNetSDK//EpsonNetSDK.dll";
|
|||
ENSWrapper instance = Native.load(strLibrary, ENSWrapper.class); |
|||
|
|||
int ENSInitialize(); |
|||
|
|||
|
|||
int ENSRelease(); |
|||
|
|||
int ENSGetDeviceID |
|||
(int PathType, String PrnPath, |
|||
Pointer IdBuff, int BuffLen, |
|||
int StructVersion); |
|||
|
|||
int ENSOpenCommunication |
|||
(int PathType, String PrnPath, |
|||
Pointer IdBuff, Pointer PtrHandle); |
|||
|
|||
int ENSCloseCommunication |
|||
(Pointer PtrHandle); |
|||
|
|||
int ENSGetInformation |
|||
(Pointer PtrHandle, String Command, |
|||
Pointer GetParm, Pointer GetBuff, |
|||
int BuffLen); |
|||
} |
|||
@ -0,0 +1,253 @@ |
|||
package com.dreamchaser.depository_manage.service.impl.EPSON.ENS; |
|||
|
|||
import com.dreamchaser.depository_manage.EPSON.ENS.ENSEnumrations; |
|||
import com.dreamchaser.depository_manage.EPSON.ENS.ENSStatus; |
|||
import com.dreamchaser.depository_manage.EPSON.epsonException.ENSException; |
|||
import com.dreamchaser.depository_manage.config.EPSON.ENS.Global_MEDIA_ENS; |
|||
import com.dreamchaser.depository_manage.exception.MyException; |
|||
import com.sun.jna.Memory; |
|||
import com.sun.jna.Native; |
|||
import com.sun.jna.Pointer; |
|||
|
|||
public class ENSWrapperImpl { |
|||
|
|||
/** |
|||
* 这是定义警告代码标志的类。 |
|||
*/ |
|||
public class WARNING_INFO |
|||
{ |
|||
public boolean InkLowWarning = false; |
|||
public boolean OtherWarning = false; |
|||
} |
|||
|
|||
private static ENSWrapperImpl _singleton = new ENSWrapperImpl(); |
|||
private String _devName, _portName; |
|||
private Pointer _ptrHandle; |
|||
|
|||
private static final String INFO_COMMAND = "STATUS"; |
|||
|
|||
private ENSWrapperImpl() |
|||
{ |
|||
} |
|||
|
|||
public static ENSWrapperImpl GetInstance() |
|||
{ |
|||
return _singleton; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 这个方法用于实现ENSInitialize. |
|||
* @param devName 所选打印机的设备名称 |
|||
* @param portName 所选打印机的端口名称 |
|||
*/ |
|||
public void Initialize(String devName, String portName) |
|||
{ |
|||
try |
|||
{ |
|||
_devName = devName; |
|||
_portName = portName; |
|||
|
|||
ENSEnumrations.ENSErrorCode errCode = ENSEnumrations.ENSErrorCode.getENSErrorCode(ENSWrapper.instance.ENSInitialize()); |
|||
if (errCode != ENSEnumrations.ENSErrorCode.ERR_BASE) |
|||
{ |
|||
throw new ENSException(errCode); |
|||
} |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 这个方法用于获取选中的打印机的状态 |
|||
* @param structINKSIDM INKSIDMSTATUS_02 对象 |
|||
*/ |
|||
public void GetPrinterStatus(ENSStatus.INKSIDMSTATUS_02 structINKSIDM) { |
|||
Pointer ptrInt = Pointer.NULL; |
|||
Pointer ptrTemp = Pointer.NULL; |
|||
Pointer ptrGetBuff = Pointer.NULL; |
|||
try |
|||
{ |
|||
// Handling of to call ENSGetDeviceID.
|
|||
int buffLen = 0; |
|||
|
|||
// ENSGetDeviceID 1st call. Get the required buffLen.
|
|||
ENSEnumrations.ENSErrorCode errCode = ENSEnumrations.ENSErrorCode.getENSErrorCode(ENSWrapper.instance.ENSGetDeviceID(ENSEnumrations.ENSType.TYPE_PRINTER.getI(), _devName, Pointer.NULL, buffLen, 0x1)); |
|||
if (errCode != ENSEnumrations.ENSErrorCode.ERR_BUFFERSIZE) |
|||
{ |
|||
throw new ENSException(errCode); |
|||
} |
|||
|
|||
ptrTemp = new Memory(buffLen); |
|||
|
|||
// ENSGetDeviceID 2nd call.
|
|||
errCode = ENSEnumrations.ENSErrorCode.getENSErrorCode(ENSWrapper.instance.ENSGetDeviceID( ENSEnumrations.ENSType.TYPE_PRINTER.getI(), _devName, ptrTemp, buffLen, 0x1)); |
|||
if (errCode != ENSEnumrations.ENSErrorCode.ERR_BASE) |
|||
{ |
|||
throw new ENSException(errCode); |
|||
} |
|||
|
|||
// Handling of to call ENSOpenCommunication.
|
|||
errCode = ENSEnumrations.ENSErrorCode.getENSErrorCode(ENSWrapper.instance.ENSOpenCommunication( ENSEnumrations.ENSType.TYPE_PRINTER.getI(), _devName, ptrTemp, _ptrHandle)); |
|||
if (errCode != ENSEnumrations.ENSErrorCode.ERR_BASE) |
|||
{ |
|||
throw new ENSException(errCode); |
|||
} |
|||
|
|||
// Get printer status information.
|
|||
structINKSIDM = new ENSStatus.INKSIDMSTATUS_02(); |
|||
String str = "STRUCTURE=INKSIDMSTATUS_02"; |
|||
int random = (int) Math.random(); |
|||
ptrInt = new Memory(random); |
|||
Global_MEDIA_ENS.ENS_STRUCTURE_Str.put(random,str); |
|||
|
|||
// Handling of to call ENSGetInformation.
|
|||
buffLen = 0; |
|||
|
|||
// ENSGetInformation 1st call. Get the required buffLen.
|
|||
errCode = ENSEnumrations.ENSErrorCode.getENSErrorCode(ENSWrapper.instance.ENSGetInformation(_ptrHandle, INFO_COMMAND, ptrInt, Pointer.NULL, buffLen)); |
|||
if (errCode != ENSEnumrations.ENSErrorCode.ERR_BUFFERSIZE) |
|||
{ |
|||
throw new ENSException(errCode); |
|||
} |
|||
|
|||
ptrGetBuff = new Memory(buffLen); |
|||
|
|||
// ENSGetInformation 2nd call.
|
|||
errCode = ENSEnumrations.ENSErrorCode.getENSErrorCode(ENSWrapper.instance.ENSGetInformation(_ptrHandle, INFO_COMMAND, ptrInt, ptrGetBuff, buffLen)); |
|||
if (errCode != ENSEnumrations.ENSErrorCode.ERR_BASE) |
|||
{ |
|||
throw new ENSException(errCode); |
|||
} |
|||
|
|||
// Get INKSIDMSTATUS_02 structure object.
|
|||
// structINKSIDM = (ENSStatus.INKSIDMSTATUS_02)Marshal.PtrToStructure(ptrGetBuff, typeof(ENSStatus.INKSIDMSTATUS_02));
|
|||
structINKSIDM = Global_MEDIA_ENS.integerINKSIDMSTATUS_02Map.get(ptrGetBuff.getInt(0)); |
|||
//
|
|||
// Handling of to call ENSCloseCommunication.
|
|||
errCode = ENSEnumrations.ENSErrorCode.getENSErrorCode(ENSWrapper.instance.ENSCloseCommunication(_ptrHandle)); |
|||
if (errCode != ENSEnumrations.ENSErrorCode.ERR_BASE) |
|||
{ |
|||
throw new ENSException(errCode); |
|||
} |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
finally |
|||
{ |
|||
Native.free(Pointer.nativeValue(ptrTemp)); |
|||
Native.free(Pointer.nativeValue(ptrInt)); |
|||
Native.free(Pointer.nativeValue(ptrGetBuff)); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 这个方法用于获取状态信息 |
|||
* @return |
|||
*/ |
|||
public ENSEnumrations.StatusCode GetStatusInformation() |
|||
{ |
|||
try |
|||
{ |
|||
ENSStatus.INKSIDMSTATUS_02 structINKSIDM = new ENSStatus.INKSIDMSTATUS_02(); |
|||
GetPrinterStatus(structINKSIDM); |
|||
return ENSEnumrations.StatusCode.getStatusCode(structINKSIDM.StatusCode); |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 这个方法用于获取ErrorCode |
|||
* @return |
|||
*/ |
|||
public ENSEnumrations.ErrorCode GetErrorInformation() |
|||
{ |
|||
try |
|||
{ |
|||
ENSStatus.INKSIDMSTATUS_02 structINKSIDM = new ENSStatus.INKSIDMSTATUS_02(); |
|||
GetPrinterStatus( structINKSIDM); |
|||
return ENSEnumrations.ErrorCode.getErrorCode(structINKSIDM.ErrorCode); |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 这是获取WarningCode的方法。 |
|||
* 判断是否出现警告。 |
|||
* @return |
|||
*/ |
|||
public WARNING_INFO GetWarningInformation() |
|||
{ |
|||
try |
|||
{ |
|||
ENSStatus.INKSIDMSTATUS_02 structINKSIDM = new ENSStatus.INKSIDMSTATUS_02(); |
|||
GetPrinterStatus( structINKSIDM); |
|||
|
|||
int awc = structINKSIDM.AvailableWarningCode2; |
|||
WARNING_INFO warningInfo = new WARNING_INFO(); |
|||
|
|||
if (awc != 0) |
|||
{ |
|||
for (int i = 0; i < awc; i++) |
|||
{ |
|||
if ((structINKSIDM.WarningCode2[i] == ENSEnumrations.WarningCode.WAR_InkLow_B.getI()) || |
|||
(structINKSIDM.WarningCode2[i] == ENSEnumrations.WarningCode.WAR_InkLow_C.getI()) || |
|||
(structINKSIDM.WarningCode2[i] == ENSEnumrations.WarningCode.WAR_InkLow_M.getI()) || |
|||
(structINKSIDM.WarningCode2[i] == ENSEnumrations.WarningCode.WAR_InkLow_Y.getI())) |
|||
{ |
|||
warningInfo.InkLowWarning = true; |
|||
} |
|||
else |
|||
{ |
|||
warningInfo.OtherWarning = true; |
|||
} |
|||
} |
|||
} |
|||
return warningInfo; |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 这是实现ENSRelease的方法 |
|||
*/ |
|||
public void Release() |
|||
{ |
|||
try |
|||
{ |
|||
ENSEnumrations.ENSErrorCode errCode = ENSEnumrations.ENSErrorCode.getENSErrorCode(ENSWrapper.instance.ENSRelease()); |
|||
if (errCode != ENSEnumrations.ENSErrorCode.ERR_BASE) |
|||
{ |
|||
throw new ENSException(errCode); |
|||
} |
|||
} |
|||
|
|||
catch (Exception e) |
|||
{ |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
package com.dreamchaser.depository_manage.service.impl.EPSON.EPDM; |
|||
|
|||
import com.sun.jna.Library; |
|||
import com.sun.jna.Native; |
|||
import com.sun.jna.Pointer; |
|||
import com.sun.jna.ptr.IntByReference; |
|||
|
|||
|
|||
public interface EPDMWrapper extends Library { |
|||
|
|||
|
|||
String strLibrary = "C:/Windows/System32/spool/drivers/x64/3/E_BEPSET32"; |
|||
// String strLibrary = "3/E_BEPSET32";
|
|||
// String strLibrary = "\\3\\E_BEPSET32";
|
|||
// String strLibrary = "C:/Windows/System32/spool/drivers/W32X86/3/E_BEPSET32.DLL";
|
|||
EPDMWrapper instance = Native.load(strLibrary, EPDMWrapper.class); |
|||
IntByReference number = new IntByReference(0); |
|||
|
|||
|
|||
int EPDM_Open(String DevName, String PortName, int Type, Pointer DMAdd, Pointer PrnHandleAdd); |
|||
|
|||
int EPDM_GetRange(Pointer PrnHandle, int Command, Pointer Param); |
|||
|
|||
int EPDM_GetData(Pointer PrnHandle, int Command, Pointer Param); |
|||
|
|||
int EPDM_SetData(Pointer PrnHandle, int Command, int Param); |
|||
|
|||
int EPDM_AddData(Pointer PrnHandle, int Command, Pointer Param); |
|||
|
|||
int EPDM_ImportData(Pointer PrnHandle, int Command, Pointer Param); |
|||
|
|||
boolean EPDM_UpdateDevMode(Pointer PrnHandle); |
|||
|
|||
boolean EPDM_Close(Pointer PrnHandle); |
|||
} |
|||
@ -0,0 +1,622 @@ |
|||
package com.dreamchaser.depository_manage.service.impl.EPSON.EPDM; |
|||
|
|||
import com.dreamchaser.depository_manage.EPSON.EPDM.EPDMEnumrations; |
|||
import com.dreamchaser.depository_manage.EPSON.EPDM.EPDMMediaLayoutRange; |
|||
import com.dreamchaser.depository_manage.EPSON.EPDM.EPDMSelectData; |
|||
import com.dreamchaser.depository_manage.EPSON.EPDM.EPDMString; |
|||
import com.dreamchaser.depository_manage.EPSON.epsonException.EPDMException; |
|||
import com.dreamchaser.depository_manage.config.EPSON.ENS.Global_MEDIA_ENS; |
|||
import com.dreamchaser.depository_manage.config.EPSON.EPDM.Global_MEDIA_EPDM; |
|||
import com.dreamchaser.depository_manage.entity.EPSON.EPDM.*; |
|||
import com.dreamchaser.depository_manage.exception.MyException; |
|||
import com.sun.jna.Memory; |
|||
import com.sun.jna.Native; |
|||
import com.sun.jna.Pointer; |
|||
import org.apache.commons.collections4.Get; |
|||
import org.apache.commons.math3.analysis.function.Add; |
|||
|
|||
import java.lang.reflect.Array; |
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 用于实现EPDMWrapper的方法 |
|||
*/ |
|||
public class EPDMWrapperImpl { |
|||
|
|||
|
|||
private static EPDMWrapperImpl _singleton = new EPDMWrapperImpl(); |
|||
/*打印质量*/ |
|||
private static String STR_PRINTQUALITY_360X180 = "360x180dpi"; |
|||
private static String STR_PRINTQUALITY_360X360 = "360x360dpi"; |
|||
private static String STR_PRINTQUALITY_720X360 = "720x360dpi"; |
|||
|
|||
private Pointer _ptrGetParm = new Memory(24); |
|||
|
|||
public static EPDMWrapperImpl GetInstance() { |
|||
return _singleton; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 这是实现EpDMOpen的方法 |
|||
* |
|||
* @param devName 所选打印机的设备名称。 |
|||
* @param portName 所选打印机的端口名称。 |
|||
*/ |
|||
public void Open(String devName, String portName) { |
|||
|
|||
|
|||
try { |
|||
EPDMEnumrations.EPDMErrorCode errCode = EPDMEnumrations.EPDMErrorCode.getEPDMErrorCode(EPDMWrapper.instance.EPDM_Open(devName, portName, 0, Pointer.NULL, _ptrGetParm)); |
|||
if (errCode != EPDMEnumrations.EPDMErrorCode.EPDM_ERR_NORMAL) { |
|||
throw new EPDMException(errCode); |
|||
} |
|||
} catch (Exception e) { |
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 这是获取MediaLayoutRange的最小值和最大值的方法。 |
|||
* |
|||
* @return 包含获取值的类 |
|||
*/ |
|||
public MEDIA_LAYOUT_RANGE GetMediaLayoutRangeValue() { |
|||
try { |
|||
EPDMMediaLayoutRange epdmMediaLayoutRange = GetMediaLayoutRange(); |
|||
// Get the MediaLayoutRange value.
|
|||
int index = epdmMediaLayoutRange.GetMediaTypeIndex(EPDMEnumrations.MediaTypeID.EPDM_MEDIATYPE_DIECUT); |
|||
|
|||
MEDIA_LAYOUT_RANGE mediaLayoutRange = new MEDIA_LAYOUT_RANGE(); |
|||
mediaLayoutRange.MinPaperWid = epdmMediaLayoutRange.MediaTypeRange[index].iMinPaperWid; |
|||
mediaLayoutRange.MaxPaperWid = epdmMediaLayoutRange.MediaTypeRange[index].iMaxPaperWid; |
|||
|
|||
mediaLayoutRange.MinLabelWid = epdmMediaLayoutRange.MediaTypeRange[index].iMinLabelWid; |
|||
mediaLayoutRange.MaxLabelWid = epdmMediaLayoutRange.MediaTypeRange[index].iMaxLabelWid; |
|||
|
|||
mediaLayoutRange.MinLabelHig = epdmMediaLayoutRange.MediaTypeRange[index].iMinLabelHig; |
|||
mediaLayoutRange.MaxLabelHig = epdmMediaLayoutRange.MediaTypeRange[index].iMaxLabelHig; |
|||
|
|||
mediaLayoutRange.MinLabelGap = epdmMediaLayoutRange.MediaTypeRange[index].iMinLabelGap; |
|||
mediaLayoutRange.MaxLabelGap = epdmMediaLayoutRange.MediaTypeRange[index].iMaxLabelGap; |
|||
return mediaLayoutRange; |
|||
} catch (Exception e) { |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 这是用于实现EPDM_GetRange的方法 |
|||
* |
|||
* @return EPDM_MEDIALAYOUTRANGE结构体 |
|||
*/ |
|||
public EPDMMediaLayoutRange GetMediaLayoutRange() { |
|||
try { |
|||
EPDMMediaLayoutRange epdmMediaLayoutRange = new EPDMMediaLayoutRange(); |
|||
// EPDM_GetRange第一次调用。获取所需的内存大小。
|
|||
EPDMEnumrations.EPDMErrorCode errCode = EPDMEnumrations.EPDMErrorCode.getEPDMErrorCode(EPDMWrapper.instance.EPDM_GetRange(_ptrGetParm, EPDMEnumrations.Command.EPDM_CMD_MEDIALAYOUT.getI(), epdmMediaLayoutRange.getStructurePointer())); |
|||
if (errCode != EPDMEnumrations.EPDMErrorCode.EPDM_ERR_NORMAL) { |
|||
System.out.println(errCode); |
|||
throw new EPDMException(errCode); |
|||
} |
|||
|
|||
epdmMediaLayoutRange.PtrToStructure(); |
|||
|
|||
epdmMediaLayoutRange.Alloc(); |
|||
|
|||
Global_MEDIA_EPDM.epdmMediaLayoutRangeMap.put(_ptrGetParm.getInt(0), epdmMediaLayoutRange); |
|||
// 第二次调用EPDM_GetRange
|
|||
|
|||
errCode = EPDMEnumrations.EPDMErrorCode.getEPDMErrorCode(EPDMWrapper.instance.EPDM_GetRange(_ptrGetParm, EPDMEnumrations.Command.EPDM_CMD_MEDIALAYOUT.getI(), epdmMediaLayoutRange.getStructurePointer())); |
|||
if (errCode != EPDMEnumrations.EPDMErrorCode.EPDM_ERR_NORMAL) { |
|||
throw new EPDMException(errCode); |
|||
} |
|||
Global_MEDIA_EPDM.epdmMediaLayoutRangeMap.put(_ptrGetParm.getInt(0), epdmMediaLayoutRange); |
|||
return epdmMediaLayoutRange; |
|||
|
|||
} catch (Exception e) { |
|||
System.out.println(e.getMessage()); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 这是实现EPDM_Close的方法 |
|||
*/ |
|||
public void Close() { |
|||
try { |
|||
if (!EPDMWrapper.instance.EPDM_Close(_ptrGetParm)) { |
|||
throw new EPDMException(EPDMEnumrations.EPDMErrorCode.EPDM_ERR_FAIL); |
|||
} |
|||
} catch (Exception e) { |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 这是创建媒体位置组合框列表的方法。 |
|||
* |
|||
* @param index 所选组合框序列的个数。 |
|||
* @return >媒体职位列表。 |
|||
*/ |
|||
public List<MEDIA_POSITION> GetMediaPositionList(Integer index) { |
|||
try { |
|||
List<MEDIA_POSITION> mediaPositionList = new ArrayList<MEDIA_POSITION>(); |
|||
MEDIA_POSITION mediaPosition; |
|||
|
|||
// GetRange EPDM_CMD_MEDIAPOSITION
|
|||
EPDMSelectData epdmSelectData = GetMediaPositionRange(); |
|||
|
|||
// GetData EPDM_CMD_MEDIAPOSITION & Get combo box index.
|
|||
index = ArrayIndexOf(epdmSelectData.Data, GetMediaPositionID()); |
|||
|
|||
// GetData EPDM_CMD_STRING
|
|||
for (int i = 0; i < epdmSelectData.Count; i++) { |
|||
String strData = GetString(EPDMEnumrations.StringID.EPDM_STRING_MEDIAPOSITION.getI(), epdmSelectData.Data[i].intValue()); |
|||
|
|||
// Add the mediapositionlist
|
|||
mediaPosition = new MEDIA_POSITION(); |
|||
mediaPosition.StrMediaPosition = strData; |
|||
mediaPosition.MediaPositionID = epdmSelectData.Data[i].intValue(); |
|||
mediaPositionList.add(mediaPosition); |
|||
} |
|||
return mediaPositionList; |
|||
|
|||
} catch (Exception e) { |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 这是创建媒体布局组合框列表的方法。 |
|||
* |
|||
* @param index 所选组合框序列的数目。 |
|||
* @return 媒体布局列表。 |
|||
*/ |
|||
public List<MEDIA_LAYOUT> GetMediaLayoutList(Integer index) { |
|||
try { |
|||
List<MEDIA_LAYOUT> mediaLayoutList = new ArrayList<MEDIA_LAYOUT>(); |
|||
MEDIA_LAYOUT mediaLayout; |
|||
|
|||
// GetRange EPDM_CMD_MEDIALAYOUT
|
|||
EPDMMediaLayoutRange epdmMediaLayoutRange = GetMediaLayoutRange(); |
|||
// GetData EPDM_CMD_MEDIALAYOUT & Get combo box index.
|
|||
index = ArrayIndexOfForShort(epdmMediaLayoutRange.MediaLayoutID, GetMediaLayoutID()); |
|||
|
|||
// GetData EPDM_CMD_STRING
|
|||
for (int i = 0; i < epdmMediaLayoutRange.IDCount; i++) { |
|||
String strData = GetString(EPDMEnumrations.StringID.EPDM_STRING_MEDIALAYOUT.getI(), epdmMediaLayoutRange.MediaLayoutID[i]); |
|||
|
|||
// Add the mediaLayoutlist
|
|||
mediaLayout = new MEDIA_LAYOUT(); |
|||
mediaLayout.StrMediaLayout = strData; |
|||
mediaLayout.MediaLayoutID = (int) epdmMediaLayoutRange.MediaLayoutID[i]; |
|||
mediaLayoutList.add(mediaLayout); |
|||
} |
|||
return mediaLayoutList; |
|||
|
|||
} catch (Exception e) { |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 这是获取当前媒体布局ID的方法。 |
|||
* |
|||
* @return 媒体布局id |
|||
*/ |
|||
public short GetMediaLayoutID() { |
|||
try { |
|||
EPDMMediaLayoutInf epdmMeiaLayoutInf = new EPDMMediaLayoutInf(); |
|||
|
|||
// GetData EPDM_CMD_mediaLayout
|
|||
EPDMEnumrations.EPDMErrorCode errCode = EPDMEnumrations.EPDMErrorCode.getEPDMErrorCode(EPDMWrapper.instance.EPDM_GetData(_ptrGetParm, EPDMEnumrations.Command.EPDM_CMD_MEDIALAYOUT.getI(), epdmMeiaLayoutInf.StructurePointer)); |
|||
if (errCode != EPDMEnumrations.EPDMErrorCode.EPDM_ERR_NORMAL) { |
|||
throw new EPDMException(errCode); |
|||
} |
|||
epdmMeiaLayoutInf.PtrToStructure(); |
|||
|
|||
short mediaLayoutID = epdmMeiaLayoutInf.MediaLayoutID; |
|||
|
|||
return mediaLayoutID; |
|||
|
|||
} catch (Exception e) { |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 这是获取媒体位置范围的方法。 |
|||
* |
|||
* @return EPDM_CMD_MEDIAPOSITION的数据结构对象EPDM_SelectData |
|||
*/ |
|||
public EPDMSelectData GetMediaPositionRange() { |
|||
try { |
|||
return GetSelectDataRange(EPDMEnumrations.Command.EPDM_CMD_MEDIAPOSITION); |
|||
} catch (Exception e) { |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 这是获取当前媒体位置检测设置ID的方法。 |
|||
* |
|||
* @return >媒体位置检测设置ID |
|||
*/ |
|||
public short GetMediaPositionID() { |
|||
try { |
|||
return GetShortData(EPDMEnumrations.Command.EPDM_CMD_MEDIAPOSITION); |
|||
} catch (Exception e) { |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 这是设置媒体布局的方法。 |
|||
* @param mediaLayoutID 所选媒体布局ID |
|||
*/ |
|||
public void SetMediaLayout(int mediaLayoutID) |
|||
{ |
|||
try |
|||
{ |
|||
SetData(EPDMEnumrations.Command.EPDM_CMD_MEDIALAYOUT.getI(), mediaLayoutID); |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 这是创建媒体类型组合框列表的方法。 |
|||
* @param index 所选组合框序列的个数 |
|||
* @return 媒体类型列表 |
|||
*/ |
|||
public List<MEDIA_TYPE> GetMediaTypeList(Integer index) { |
|||
try { |
|||
List<MEDIA_TYPE> mediaTypeList = new ArrayList<MEDIA_TYPE>(); |
|||
MEDIA_TYPE mediaType; |
|||
|
|||
// GetRange EPDM_CMD_MEDIA
|
|||
EPDMSelectData epdmSelectData = GetMediaTypeRange(); |
|||
|
|||
// GetData EPDM_CMD_MEDIA
|
|||
short mediaTypeID = GetMediaTypeID(); |
|||
|
|||
// Get combo box index.
|
|||
index = ArrayIndexOf(epdmSelectData.Data, mediaTypeID); |
|||
|
|||
// GetData EPDM_CMD_STRING
|
|||
for (int i = 0; i < epdmSelectData.Count; i++) { |
|||
String strData = GetString( EPDMEnumrations.StringID.EPDM_STRING_MEDIA.getI(), epdmSelectData.Data[i].intValue()); |
|||
|
|||
// Add the mediatypelist
|
|||
mediaType = new MEDIA_TYPE(); |
|||
mediaType.StrMediaType = strData; |
|||
mediaType.MediaTypeID = epdmSelectData.Data[i].intValue(); |
|||
mediaTypeList.add(mediaType); |
|||
} |
|||
return mediaTypeList; |
|||
|
|||
} catch (Exception e) { |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 这是获取媒体类型范围的方法。 |
|||
* |
|||
* @return epdm_select的数据结构对象。 |
|||
*/ |
|||
public EPDMSelectData GetMediaTypeRange() { |
|||
try { |
|||
return GetSelectDataRange(EPDMEnumrations.Command.EPDM_CMD_MEDIA); |
|||
} catch (Exception e) { |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 这是获取当前媒体类型ID的方法。 |
|||
* @return 媒体类型ID。 |
|||
*/ |
|||
public short GetMediaTypeID() |
|||
{ |
|||
try |
|||
{ |
|||
return GetShortData(EPDMEnumrations.Command.EPDM_CMD_MEDIA); |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 这是实现EPDMSelectData结构的EPDM GetRange的方法。 |
|||
* |
|||
* @param cmd 命令获取设置的范围 |
|||
* @return EPDMSelectData结构对象。 |
|||
*/ |
|||
public EPDMSelectData GetSelectDataRange(EPDMEnumrations.Command cmd) { |
|||
try { |
|||
EPDMSelectData epdmSelectData = new EPDMSelectData(); |
|||
EPDMEnumrations.EPDMErrorCode errCode = EPDMEnumrations.EPDMErrorCode.getEPDMErrorCode(EPDMWrapper.instance.EPDM_GetRange(_ptrGetParm, cmd.getI(), epdmSelectData.StructurePointer)); |
|||
if (errCode != EPDMEnumrations.EPDMErrorCode.EPDM_ERR_NORMAL) { |
|||
|
|||
throw new EPDMException(errCode); |
|||
|
|||
} |
|||
epdmSelectData.PtrToStructure(); |
|||
|
|||
// Allocate the memory. - EPDMSelectData.Data
|
|||
epdmSelectData.Alloc(); |
|||
|
|||
// EPDM_GetRange 2nd call.
|
|||
errCode = EPDMEnumrations.EPDMErrorCode.getEPDMErrorCode(EPDMWrapper.instance.EPDM_GetRange(_ptrGetParm, cmd.getI(), epdmSelectData.StructurePointer)); |
|||
if (errCode != EPDMEnumrations.EPDMErrorCode.EPDM_ERR_NORMAL) { |
|||
throw new EPDMException(errCode); |
|||
} |
|||
epdmSelectData.PtrToStructure(); |
|||
|
|||
return epdmSelectData; |
|||
} catch (EPDMException e) { |
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 这是用于实现EPDM_GetData的方法 |
|||
* |
|||
* @param cmd 命令获取数据 |
|||
* @return |
|||
*/ |
|||
public short GetShortData(EPDMEnumrations.Command cmd) { |
|||
Pointer ptrPosition = Pointer.NULL; |
|||
try { |
|||
ptrPosition = new Memory(Short.SIZE / 8); |
|||
|
|||
EPDMEnumrations.EPDMErrorCode errCode = EPDMEnumrations.EPDMErrorCode.getEPDMErrorCode(EPDMWrapper.instance.EPDM_GetData(_ptrGetParm, cmd.getI(), ptrPosition)); |
|||
if (errCode != EPDMEnumrations.EPDMErrorCode.EPDM_ERR_NORMAL) { |
|||
throw new EPDMException(errCode); |
|||
} |
|||
|
|||
return _ptrGetParm.getShort(0); |
|||
} catch (Exception e) { |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} finally { |
|||
Native.free(Pointer.nativeValue(ptrPosition)); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 这是实现EPDM_sTRiNG_1结构的EPDM_GetData的方法 |
|||
* |
|||
* @param stringParam 要获取的字符串的命令。 |
|||
* @param id 要获取的字符串的ID |
|||
* @return |
|||
*/ |
|||
public String GetString(int stringParam, int id) { |
|||
try { |
|||
EPDMString epdmString = new EPDMString(); |
|||
|
|||
epdmString.Command = stringParam; |
|||
epdmString.ID = id; |
|||
|
|||
EPDMEnumrations.EPDMErrorCode errCode = EPDMEnumrations.EPDMErrorCode.getEPDMErrorCode(EPDMWrapper.instance.EPDM_GetData(_ptrGetParm, EPDMEnumrations.Command.EPDM_CMD_STRING.getI(), epdmString.StructurePointer)); |
|||
if (errCode != EPDMEnumrations.EPDMErrorCode.EPDM_ERR_NORMAL) { |
|||
throw new EPDMException(errCode); |
|||
} |
|||
|
|||
epdmString.PtrToStructure(); |
|||
|
|||
// Allocate the memory. - EPDMString.String
|
|||
epdmString.Alloc(); |
|||
|
|||
errCode = EPDMEnumrations.EPDMErrorCode.getEPDMErrorCode(EPDMWrapper.instance.EPDM_GetData(_ptrGetParm, EPDMEnumrations.Command.EPDM_CMD_STRING.getI(), epdmString.StructurePointer)); |
|||
if (errCode != EPDMEnumrations.EPDMErrorCode.EPDM_ERR_NORMAL) { |
|||
throw new EPDMException(errCode); |
|||
} |
|||
|
|||
epdmString.PtrToStructure(); |
|||
|
|||
return epdmString.getString(); |
|||
} catch (Exception e) { |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 这是用于实现EPDM_SetData的方法 |
|||
* |
|||
* @param cmd 要获取的命令号。 |
|||
* @param param 数据参数 |
|||
*/ |
|||
public void SetData(int cmd, int param) { |
|||
try { |
|||
EPDMEnumrations.EPDMErrorCode errCode = EPDMEnumrations.EPDMErrorCode.getEPDMErrorCode(EPDMWrapper.instance.EPDM_SetData(_ptrGetParm, cmd, param)); |
|||
|
|||
if (errCode != EPDMEnumrations.EPDMErrorCode.EPDM_ERR_NORMAL) { |
|||
throw new EPDMException(errCode); |
|||
} |
|||
} catch (Exception e) { |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 这是实现EPDM_UpdateDevMode的方法 |
|||
*/ |
|||
public void UpdateDevMode() { |
|||
try { |
|||
if (!EPDMWrapper.instance.EPDM_UpdateDevMode(_ptrGetParm)) { |
|||
throw new EPDMException(EPDMEnumrations.EPDMErrorCode.EPDM_ERR_FAIL); |
|||
} |
|||
} catch (Exception e) { |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 这是设置媒体类型的方法。 |
|||
* @param mediaTypeID 所选媒体类型ID。 |
|||
*/ |
|||
public void SetMediaType(int mediaTypeID) |
|||
{ |
|||
try |
|||
{ |
|||
SetData(EPDMEnumrations.Command.EPDM_CMD_MEDIA.getI(), mediaTypeID); |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 这是创建打印质量组合框列表的方法。 |
|||
* |
|||
* @param index 所选组合框序列的个数(输出),当没有可选择的打印质量时,-1返回索引。 |
|||
* @return 印刷质量的清单 |
|||
*/ |
|||
public List<PRINT_QUALITY> GetPrintQualityList(Integer index) { |
|||
try { |
|||
List<PRINT_QUALITY> printQualityList = new ArrayList<PRINT_QUALITY>(); |
|||
PRINT_QUALITY printQuality; |
|||
|
|||
// GetData EPDM_CMD_MEDIA
|
|||
EPDMSelectData epdmSelectData = GetPrintQualityRange(); |
|||
if (epdmSelectData == null) { |
|||
index = -1; |
|||
return null; |
|||
} |
|||
|
|||
// GetData EPDM_CMD_MEDIA & Get combo box index.
|
|||
index = ArrayIndexOf(epdmSelectData.Data, GetPrintQualityID()); |
|||
|
|||
// GetPrintQualityString
|
|||
String strData = ""; |
|||
for (int i = 0; i < epdmSelectData.Count; i++) { |
|||
int ID = epdmSelectData.Data[i].intValue(); |
|||
if (ID == EPDMEnumrations.PrintQualityID.EPDM_QUALITY_360X180.getI()) { |
|||
strData = STR_PRINTQUALITY_360X180; |
|||
} else if (ID == EPDMEnumrations.PrintQualityID.EPDM_QUALITY_360X360.getI()) { |
|||
strData = STR_PRINTQUALITY_360X360; |
|||
} else if (ID == EPDMEnumrations.PrintQualityID.EPDM_QUALITY_720X360.getI()) { |
|||
strData = STR_PRINTQUALITY_720X360; |
|||
} |
|||
|
|||
// Add the mediapositionlist
|
|||
printQuality = new PRINT_QUALITY(); |
|||
printQuality.StrPrintQuality = strData; |
|||
printQuality.PrintQualityID = ID; |
|||
printQualityList.add(printQuality); |
|||
} |
|||
return printQualityList; |
|||
} catch (Exception e) { |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 这是得到打印质量范围的方法。 |
|||
* |
|||
* @return |
|||
*/ |
|||
public EPDMSelectData GetPrintQualityRange() { |
|||
try { |
|||
return GetSelectDataRange(EPDMEnumrations.Command.EPDM_CMD_QUALITY); |
|||
} catch (Exception e) { |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 这是获得目前印刷质量的方法之一。 |
|||
* |
|||
* @return 打印质量ID |
|||
*/ |
|||
public short GetPrintQualityID() { |
|||
try { |
|||
return GetShortData(EPDMEnumrations.Command.EPDM_CMD_QUALITY); |
|||
} catch (Exception e) { |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 这是设置打印质量的方法。 |
|||
* |
|||
* @param printQualityID 选定打印质量ID。 |
|||
*/ |
|||
public void SetPrintQuality(int printQualityID) { |
|||
try { |
|||
SetData(EPDMEnumrations.Command.EPDM_CMD_QUALITY.getI(), printQualityID); |
|||
} catch (Exception e) { |
|||
// Error handling.
|
|||
throw new MyException(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
public Integer ArrayIndexOf(Object[] objects, Object object) { |
|||
int num = 0; |
|||
for (int i = 0; i < objects.length; i++) { |
|||
Object obj = objects[i]; |
|||
if (obj.toString().equals(object.toString())) { |
|||
num = i; |
|||
} |
|||
} |
|||
return num; |
|||
} |
|||
|
|||
|
|||
public Integer ArrayIndexOfForShort(short[] objects, short object) { |
|||
int num = 0; |
|||
for (int i = 0; i < objects.length; i++) { |
|||
short obj = objects[i]; |
|||
if (obj == object) { |
|||
num = i; |
|||
} |
|||
} |
|||
return num; |
|||
} |
|||
|
|||
} |
|||
File diff suppressed because it is too large
Binary file not shown.
Binary file not shown.
@ -0,0 +1,217 @@ |
|||
body { |
|||
margin: 0; |
|||
padding: 0; |
|||
width: 100%; |
|||
height: 100%; |
|||
background-color: #fff; |
|||
} |
|||
|
|||
.container { |
|||
width: 900px; |
|||
height: auto; |
|||
margin: 0 auto; |
|||
} |
|||
|
|||
.header { |
|||
display: flex; |
|||
align-items: center; |
|||
width: 100%; |
|||
height: 100px; |
|||
margin: 10px 0; |
|||
border: 1px solid gray; |
|||
} |
|||
.printer { |
|||
display: flex; |
|||
align-items: center; |
|||
margin-left: 10px; |
|||
} |
|||
.printer span { |
|||
display: block; |
|||
width: 120px; |
|||
} |
|||
.printer select { |
|||
width: 520px; |
|||
height: 26px; |
|||
} |
|||
.printer .reset { |
|||
width: 120px; |
|||
height: 24px; |
|||
margin-left: 10px; |
|||
line-height: 24px; |
|||
text-align: center; |
|||
border: 1px solid #a9a9a9; |
|||
} |
|||
|
|||
.main { |
|||
display: flex; |
|||
align-items: center; |
|||
justify-content: space-between; |
|||
width: 100%; |
|||
} |
|||
|
|||
.main-left { |
|||
width: 60%; |
|||
} |
|||
.send1{ |
|||
|
|||
width: 90%; |
|||
height: 30px; |
|||
margin: 10px ; |
|||
line-height: 30px; |
|||
text-align: center; |
|||
font-size: 16px; |
|||
/* border: 1px solid gray; */ |
|||
/* border-radius: 5px; */ |
|||
/* margin: 10px 10px; */ |
|||
|
|||
} |
|||
|
|||
.flex-rows { |
|||
padding: 10px 0 10px 10px; |
|||
margin-bottom: 20px; |
|||
border: 1px solid gray; |
|||
} |
|||
|
|||
.flex-rows p { |
|||
font-size: 16px; |
|||
} |
|||
.flex-rows .ex2 { |
|||
display: flex; |
|||
align-items: center; |
|||
height: 40px; |
|||
} |
|||
|
|||
.function .ex2 span, |
|||
.upgrade .ex2 span { |
|||
display: block; |
|||
width: 120px; |
|||
font-size: 14px; |
|||
} |
|||
.parameter .ex2 span { |
|||
display: block; |
|||
width: 160px; |
|||
font-size: 14px; |
|||
} |
|||
|
|||
.ex2 .right { |
|||
width: 500px; |
|||
} |
|||
.ex2 .diy-span-class{ |
|||
display: flex; |
|||
justify-content: flex-start; |
|||
align-items: center; |
|||
} |
|||
|
|||
.ex2 .diy-span-class span { |
|||
display: block; |
|||
width: 30px ; |
|||
margin-left: 6px; |
|||
font-size: 14px; |
|||
} |
|||
.ex2 .diy-span-class span:nth-child(1) { |
|||
margin-left: 0; |
|||
} |
|||
|
|||
.headselect{ |
|||
width: 500px; |
|||
} |
|||
|
|||
.ex2 .right input[type='text'] { |
|||
width: 200px; |
|||
height: 24px; |
|||
} |
|||
|
|||
.ex2 .right input[type='button'], |
|||
.ex2 .right input[type='number'], |
|||
.ex2 .right input[type='reset'], |
|||
.ex2 .right select { |
|||
width: 120px; |
|||
height: 24px; |
|||
} |
|||
|
|||
.ex2 .diy-span-class input[type='number'] { |
|||
width: 60px; |
|||
height: 24px; |
|||
} |
|||
|
|||
|
|||
.ex2 .right input[type='number'] { |
|||
height: 22px; |
|||
} |
|||
|
|||
.ex2 .right select, |
|||
.ex2 .right input[type='button'] { |
|||
height: 28px; |
|||
} |
|||
|
|||
.ex2 .crc input[type='text'] { |
|||
width: 120px; |
|||
height: 24px; |
|||
} |
|||
.file-input { |
|||
display: flex; |
|||
align-items: center; |
|||
} |
|||
.select-file { |
|||
position: relative; |
|||
width: 120px; |
|||
height: 28px; |
|||
margin-left: 6px; |
|||
border: 1px solid #a9a9a9; |
|||
} |
|||
|
|||
.select-file span { |
|||
width: 100%; |
|||
height: 100%; |
|||
line-height: 28px; |
|||
text-align: center; |
|||
background-color: #fff; |
|||
} |
|||
.select-file input { |
|||
opacity: 0; |
|||
position: absolute; |
|||
width: 100%; |
|||
height: 100%; |
|||
top: 0; |
|||
left: 0; |
|||
overflow: hidden; |
|||
} |
|||
|
|||
.main-right { |
|||
width: 36%; |
|||
height: 860px; |
|||
margin-top: -20px; |
|||
border: 1px solid gray; |
|||
} |
|||
.main-right p { |
|||
padding-left: 5%; |
|||
} |
|||
|
|||
.overflowTest { |
|||
width: 90%; |
|||
height: 320px; |
|||
margin: 0 auto; |
|||
padding: 4px; |
|||
border: 1px solid gray; |
|||
background-color: #fff; |
|||
overflow: scroll; |
|||
} |
|||
#overflowTest1 { |
|||
width: 90%; |
|||
height: 320px; |
|||
margin: 0 auto; |
|||
padding: 4px; |
|||
border: 1px solid gray; |
|||
background-color: #fff; |
|||
overflow: scroll; |
|||
} |
|||
.clear-all { |
|||
width: 90%; |
|||
height: 30px; |
|||
margin: 10px auto 0; |
|||
line-height: 30px; |
|||
text-align: center; |
|||
font-size: 16px; |
|||
border: 1px solid gray; |
|||
border-radius: 5px; |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
|
|||
|
|||
var DrawLableBarCodeParam = { |
|||
"x": 20.0, |
|||
"y": 10.0, |
|||
"height": 10, |
|||
"width": 50, |
|||
"value": '12345678', |
|||
"codeType": 20, |
|||
"rotate": 0, |
|||
"fontSize": 4.0, |
|||
"textHeight": 0, |
|||
"textPosition": 0, |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
var DrawLableGraphParam = { |
|||
"x": 2.0, |
|||
"y": 5.0, |
|||
"height": 30, |
|||
"width": 40, |
|||
"rotate": 0, |
|||
"graphType": 3, |
|||
"cornerRadius": 0, |
|||
"lineWidth": 4, |
|||
"lineType":2, |
|||
"dashwidth": [1,1], |
|||
} |
|||
File diff suppressed because one or more lines are too long
@ -0,0 +1,9 @@ |
|||
var DrawLableLineParam = { |
|||
"x": 2.0, |
|||
"y": 2.0, |
|||
"height": 2, |
|||
"width": 50, |
|||
"rotate": 0, |
|||
"lineType": 2, |
|||
"dashwidth": [1,1], |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
var DrawLableQrCodeParam = { |
|||
"x": 20.0, |
|||
"y": 10.0, |
|||
"height": 10, |
|||
"width": 10, |
|||
"value": "精臣SDK", |
|||
"rotate": 0, |
|||
"codeType": 31, |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
|
|||
var DrawLableTextParam = { |
|||
"x": 20.0, |
|||
"y": 10.0, |
|||
"height": 10, |
|||
"width": 50, |
|||
"value": "精臣SDK", |
|||
"fontFamily": "宋体", |
|||
"rotate": 0, |
|||
"fontSize": 4.0, |
|||
"textAlignHorizonral": 0, |
|||
"textAlignVertical": 0, |
|||
"letterSpacing": 1.0, |
|||
"lineSpacing": 1.0, |
|||
"lineMode":0, |
|||
"fontStyle": [false, false, false,false], |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
|
|||
var InitDrawingBoardParam={ |
|||
"width":70, |
|||
"height":50, |
|||
"rotate":0, |
|||
"path":"ZT001.ttf", |
|||
"verticalShift":0, |
|||
"HorizontalShift":0}; |
|||
@ -0,0 +1,3 @@ |
|||
var generateImagePreviewImageParam = { |
|||
"displayScale":8 |
|||
} |
|||
@ -0,0 +1,4 @@ |
|||
var initSdkParam = { |
|||
"fontDir":"", |
|||
|
|||
} |
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,518 @@ |
|||
document.write( |
|||
"<script src='/static/js/JcPrinter/jquery.js'></script>" |
|||
); |
|||
|
|||
document.write( |
|||
"<script src='/static/js/JcPrinter/layer/layer.js' ></script>" |
|||
); |
|||
|
|||
|
|||
document.write( |
|||
"<script src='/static/js/JcPrinter/jcPrinterSdk_api_third.js'></script>" |
|||
); |
|||
|
|||
document.write( |
|||
"<script src='/static/js/JcPrinter/drawParameter/InitDrawingBoard.js'></script>" |
|||
); |
|||
|
|||
document.write( |
|||
"<script src='/static/js/JcPrinter/drawParameter/initSdk.js'></script>" |
|||
); |
|||
|
|||
document.write( |
|||
"<script src='/static/js/JcPrinter/drawParameter/DrawLableText.js'></script>" |
|||
); |
|||
|
|||
document.write( |
|||
"<script src='/static/js/JcPrinter/drawParameter/DrawLableQrCode.js'></script>" |
|||
); |
|||
|
|||
document.write( |
|||
"<script src='/static/js/JcPrinter/drawParameter/DrawLableLine.js'></script>" |
|||
); |
|||
|
|||
document.write( |
|||
"<script src='/static/js/JcPrinter/drawParameter/DrawLableImage.js'></script>" |
|||
); |
|||
|
|||
document.write( |
|||
"<script src='/static/js/JcPrinter/drawParameter/DrawLableGraph.js'></script>" |
|||
); |
|||
|
|||
document.write( |
|||
"<script src='/static/js/JcPrinter/drawParameter/DrawLableBarCode.js'></script>" |
|||
); |
|||
|
|||
document.write( |
|||
"<script src='/static/js/JcPrinter/drawParameter/generateImagePreviewImage.js'></script>" |
|||
); |
|||
|
|||
document.write( |
|||
"<script src='/static/js/JcPrinter/drawParameter/picturePrint.js'></script>" |
|||
); |
|||
|
|||
|
|||
var bCanclePrint = false; |
|||
var base64Data = ""; |
|||
var readerPrintData = new FileReader(); |
|||
var readerPrinterInfo = new FileReader(); |
|||
var strPrintData; |
|||
var strPrinterInfo; |
|||
var allPrinters; |
|||
var pageIndex = 1; |
|||
|
|||
|
|||
var app = new Vue({ |
|||
el: '#app', |
|||
data: { |
|||
form: { |
|||
paperType: '1', |
|||
density: '3', |
|||
pageCount: '1', |
|||
quantityCount: '2', |
|||
printMode: '1' |
|||
}, |
|||
formLabelWidth: "120px", |
|||
options: [], |
|||
tags: [], |
|||
isInit: false, |
|||
isInitApi: false, |
|||
isDraw: false, |
|||
isEditTag: false, |
|||
editIndex: 0, |
|||
dialogInitDrawingBoardParam: false, |
|||
dialogDrawLableTextParam: false, |
|||
dialogDrawLableBarCodeParam: false, |
|||
dialogDrawLableQrCodeParam: false, |
|||
dialogDrawLableLineParam: false, |
|||
dialogDrawLableGraphParam: false, |
|||
dialogDrawLableImageParam: false, |
|||
value: '', |
|||
imgSrc: '', |
|||
initSdkParam: {//初始化数据
|
|||
"fontDir": "", |
|||
}, |
|||
InitDrawingBoardParam: { |
|||
"width": 50, |
|||
"height": 30, |
|||
"rotate": 0, |
|||
"path": "ZT001.ttf", |
|||
"verticalShift": 0, |
|||
"HorizontalShift": 0 |
|||
}, |
|||
DrawLableTextParam: { |
|||
"x": 1.0, |
|||
"y": 1.0, |
|||
"height": 10, |
|||
"width": 50, |
|||
"value": "", |
|||
"fontFamily": "宋体", |
|||
"rotate": 0, |
|||
"fontSize": 4.0, |
|||
"textAlignHorizonral": 0, |
|||
"textAlignVertical": 0, |
|||
"letterSpacing": 1.0, |
|||
"lineSpacing": 1.0, |
|||
"lineMode": 0, |
|||
"fontStyle": [false, false, false, false], |
|||
}, |
|||
DrawLableBarCodeParam: { |
|||
"x": 20.0, |
|||
"y": 10.0, |
|||
"height": 10, |
|||
"width": 50, |
|||
"value": document.getElementById("materialQrCode").value, |
|||
"codeType": 20, |
|||
"rotate": 0, |
|||
"fontSize": 4.0, |
|||
"textHeight": 0, |
|||
"textPosition": 0, |
|||
}, |
|||
DrawLableQrCodeParam: { |
|||
"x": 20.0, |
|||
"y": 10.0, |
|||
"height": 10, |
|||
"width": 10, |
|||
"value": document.getElementById("materialQrCode").value, |
|||
"rotate": 0, |
|||
"codeType": 31, |
|||
}, |
|||
DrawLableLineParam: { |
|||
"x": 2.0, |
|||
"y": 2.0, |
|||
"height": 2, |
|||
"width": 50, |
|||
"rotate": 0, |
|||
"lineType": 2, |
|||
"dashwidth": [1, 1], |
|||
}, |
|||
DrawLableGraphParam: { |
|||
"x": 2.0, |
|||
"y": 5.0, |
|||
"height": 30, |
|||
"width": 40, |
|||
"rotate": 0, |
|||
"graphType": 3, |
|||
"cornerRadius": 0, |
|||
"lineWidth": 4, |
|||
"lineType": 2, |
|||
"dashwidth": [1, 1], |
|||
}, |
|||
DrawLableImageParam: { |
|||
"x": 2.0, |
|||
"y": 2.0, |
|||
"height": 10, |
|||
"width": 50, |
|||
"rotate": 0, |
|||
"imageProcessingType": 0, |
|||
"imageProcessingValue": 127, |
|||
"imageData": "", |
|||
"imgSrc": '' |
|||
}, |
|||
DrawLableGraphParamDemo: { |
|||
"x": 2.0, |
|||
"y": 2.0, |
|||
"width": 46, |
|||
"height": 26, |
|||
"rotate": 0, |
|||
"graphType": 3, |
|||
"cornerRadius": 0, |
|||
"lineWidth": 0.5, |
|||
"lineType": 1, |
|||
"dashwidth": [1, 1], |
|||
}, |
|||
|
|||
}, |
|||
mounted() { |
|||
// 初始化打印服务
|
|||
getInstance(); |
|||
}, |
|||
methods: { |
|||
// 初始化
|
|||
initSdkApi() { |
|||
initSdk(this.initSdkParam); |
|||
this.isInitApi = true |
|||
}, |
|||
// 选择打印机
|
|||
selectPrinterApi() { |
|||
let printerName = ''; |
|||
for (let index = 0; index < this.options.length; index++) { |
|||
if (this.value === this.options[index].value) printerName = this.options[index].label |
|||
} |
|||
selectPrinter(printerName, parseInt(this.value), (data => { |
|||
var arrParse = JSON.parse(JSON.stringify(data)); |
|||
if (!arrParse.resultAck.result) { |
|||
return; |
|||
} else if (isJSON(arrParse.resultAck.info)) { |
|||
//选择成功,打印机连接成功
|
|||
console.log(data) |
|||
} |
|||
|
|||
})); |
|||
}, |
|||
// 重新获取打印机
|
|||
refreshPrinters() { |
|||
getAllPrinters(data => { |
|||
let arrParse = JSON.parse(JSON.stringify(data)); |
|||
if (isJSON(arrParse.resultAck.info)) { |
|||
allPrinters = JSON.parse(arrParse.resultAck.info); |
|||
let allPrintersName = Object.keys(allPrinters); |
|||
let allPrintersValue = Object.values(allPrinters); |
|||
this.options = []; |
|||
for (i = 0; i < allPrintersName.length; i++) { |
|||
let newopt = {}; |
|||
newopt.label = allPrintersName[i]; |
|||
newopt.value = allPrintersValue[i]; |
|||
this.options.push(newopt) |
|||
} |
|||
} |
|||
}); |
|||
}, |
|||
// 初始化画板
|
|||
InitDrawingBoardApi() { |
|||
this.dialogInitDrawingBoardParam = true; |
|||
this.isDraw = false; |
|||
this.imgSrc = ""; |
|||
}, |
|||
handleClose(index) { |
|||
this.tags.splice(index, 1); |
|||
}, |
|||
clickTag(tag, index) { |
|||
this.isEditTag = true; |
|||
this.editIndex = index; |
|||
switch (tag.name) { |
|||
case "文本": |
|||
this.DrawLableTextParam = {...tag}; |
|||
this.dialogDrawLableTextParam = true; |
|||
break; |
|||
case "一维码": |
|||
this.DrawLableBarCodeParam = {...tag}; |
|||
this.dialogDrawLableBarCodeParam = true; |
|||
break; |
|||
case "二维码": |
|||
this.DrawLableQrCodeParam = {...tag}; |
|||
this.dialogDrawLableQrCodeParam = true; |
|||
break; |
|||
case "线条": |
|||
this.DrawLableLineParam = {...tag}; |
|||
this.dialogDrawLableLineParam = true; |
|||
break; |
|||
case "形状": |
|||
this.DrawLableGraphParam = {...tag}; |
|||
this.dialogDrawLableGraphParam = true; |
|||
break; |
|||
case "图片": |
|||
this.DrawLableImageParam = {...tag}; |
|||
this.dialogDrawLableImageParam = true; |
|||
break; |
|||
} |
|||
}, |
|||
// 初始化画布
|
|||
InitDrawingBoardPar(callbackFunction) { |
|||
if (!this.InitDrawingBoardParam.width || !this.InitDrawingBoardParam.height) { |
|||
this.$message({ |
|||
message: '请选填写画板宽高', |
|||
type: 'warning' |
|||
}); |
|||
return |
|||
} |
|||
this.InitDrawingBoardParam.width = Number(this.InitDrawingBoardParam.width); |
|||
this.InitDrawingBoardParam.height = Number(this.InitDrawingBoardParam.height); |
|||
// 创建画板
|
|||
/** |
|||
* 1.绘制元素前,必须先初始化画板,否则会引起崩溃! |
|||
2.初始化画板时会清空画板上次绘制的内容! |
|||
*/ |
|||
InitDrawingBoard(this.InitDrawingBoardParam, callbackFunction); |
|||
this.dialogInitDrawingBoardParam = false; |
|||
this.isInit = true |
|||
}, |
|||
// 一维码
|
|||
DrawLableBarCodeApi() { |
|||
this.DrawLableBarCodeParam.width = Number(this.DrawLableBarCodeParam.width); |
|||
this.DrawLableBarCodeParam.height = Number(this.DrawLableBarCodeParam.height); |
|||
this.DrawLableBarCodeParam.x = Number(this.DrawLableBarCodeParam.x); |
|||
this.DrawLableBarCodeParam.y = Number(this.DrawLableBarCodeParam.y); |
|||
this.DrawLableBarCodeParam.name = "条形码"; |
|||
DrawLableBarCode(this.DrawLableBarCodeParam); |
|||
if (this.isEditTag) { |
|||
this.$set(this.tags, this.editIndex, this.DrawLableBarCodeParam); |
|||
} else { |
|||
this.tags.push(this.DrawLableBarCodeParam) |
|||
} |
|||
this.dialogDrawLableBarCodeParam = false; |
|||
this.isDraw = true |
|||
}, |
|||
// 二维码
|
|||
DrawLableQrCodeApi() { |
|||
|
|||
this.DrawLableQrCodeParam.width = Number(this.DrawLableQrCodeParam.width); |
|||
this.DrawLableQrCodeParam.height = Number(this.DrawLableQrCodeParam.width); |
|||
this.DrawLableQrCodeParam.x = Number(this.DrawLableQrCodeParam.x); |
|||
this.DrawLableQrCodeParam.y = Number(this.DrawLableQrCodeParam.y); |
|||
this.DrawLableQrCodeParam.name = "二维码"; |
|||
//DrawLableQrCode(this.DrawLableQrCodeParam);
|
|||
if (this.isEditTag) { |
|||
this.$set(this.tags, this.editIndex, this.DrawLableQrCodeParam); |
|||
} else { |
|||
this.tags.push(this.DrawLableQrCodeParam) |
|||
} |
|||
this.dialogDrawLableQrCodeParam = false; |
|||
this.isDraw = true |
|||
}, |
|||
DragList(List) { |
|||
List.forEach(res => { |
|||
|
|||
}) |
|||
}, |
|||
// 预览时进行绘制
|
|||
generateImagePreviewImagepi() { |
|||
let List = [...this.tags]; |
|||
// 创建画布
|
|||
InitDrawingBoard(this.InitDrawingBoardParam, (data => { |
|||
List.forEach(res => { |
|||
switch (res.name) { |
|||
case "文本": |
|||
DrawLableText(res); |
|||
break; |
|||
case "条形码": |
|||
DrawLableBarCode(res); |
|||
break; |
|||
case "二维码": |
|||
DrawLableQrCode(res); |
|||
break; |
|||
case "线条": |
|||
DrawLableLine(res); |
|||
break; |
|||
case "形状": |
|||
DrawLableGraph(res); |
|||
break; |
|||
case "图片": |
|||
DrawLableImage(res); |
|||
break; |
|||
} |
|||
}); |
|||
// 标签预览
|
|||
generateImagePreviewImage(generateImagePreviewImageParam['displayScale'], |
|||
(data => { |
|||
var arrParse = JSON.parse(JSON.stringify(data)); |
|||
//var Epc = document.getElementById('searchRfidBox');
|
|||
var base64Data = arrParse.resultAck.info; |
|||
var obj = JSON.parse(base64Data); |
|||
var data = obj.ImageData; |
|||
var imgDisplay = document.getElementById('base64image'); |
|||
var errorCode = obj.errorCode; |
|||
|
|||
this.imgSrc = "data:image/jpeg;base64," + data; |
|||
// self.isInit = false
|
|||
})) |
|||
})); |
|||
}, |
|||
//清空
|
|||
emptyImagePreviewImage() { |
|||
this.imgSrc = ""; |
|||
this.tags = []; |
|||
this.isDraw = false |
|||
}, |
|||
DrawLableTextApiDemo(DrawLableTextParamDemo, callbackFunction) { |
|||
DrawLableText(DrawLableTextParamDemo, callbackFunction); |
|||
}, |
|||
DrawLableGraphApiDemo(callbackFunction) { |
|||
DrawLableGraph(this.DrawLableGraphParamDemo, callbackFunction); |
|||
}, |
|||
|
|||
DrawLableLineApiDemo(DrawLableLineParamDemo, callbackFunction) { |
|||
DrawLableLine(DrawLableLineParamDemo, callbackFunction); |
|||
}, |
|||
DrawLableBarCodeApiDemo(drawLableBarCodeParamDemo, callableFunction) { |
|||
DrawLableBarCode(drawLableBarCodeParamDemo, callableFunction) |
|||
}, |
|||
|
|||
/** |
|||
* 开始打印任务 |
|||
* @param {*} pageCount 页数 |
|||
* @param {*} quantityCount 份数 |
|||
* @param {*} density 浓度 |
|||
* @param {*} paperType 纸张类型 |
|||
* @param {*} paperType 材质 |
|||
* @param {*} paperType 打印模式 |
|||
*/ |
|||
startPrintJob(index) { |
|||
let { |
|||
pageCount = "1", |
|||
quantityCount = "1", |
|||
density = "3", |
|||
paperType = "1", |
|||
printMode = "1" |
|||
} = this.form; |
|||
const self = this; |
|||
switch (index) { |
|||
case 1: |
|||
quantityCount = 1; |
|||
break; |
|||
case 2: |
|||
quantityCount = 1; |
|||
pageCount = 2; |
|||
break; |
|||
case 4: |
|||
pageCount = 2; |
|||
break; |
|||
} |
|||
if (this.value === "") { |
|||
self.$message({ |
|||
message: '请选择连接打印机', |
|||
type: 'warning' |
|||
}); |
|||
return; |
|||
} |
|||
if (!this.form.quantityCount && (index === 3 || index === 4)) { |
|||
self.$message({ |
|||
message: '请选填写打印份数', |
|||
type: 'warning' |
|||
}); |
|||
return; |
|||
} |
|||
// 初始化画板
|
|||
InitDrawingBoard(this.InitDrawingBoardParam, (data1 => { |
|||
// 添加文字
|
|||
this.DrawLableBarCodeApiDemo(this.DrawLableBarCodeParam, (data => { |
|||
// 提交数据
|
|||
var totalCount = parseInt(pageCount) * parseInt(quantityCount); |
|||
startJob(parseInt(density), parseInt(paperType), parseInt(printMode), totalCount, function (data) { |
|||
bCanclePrint = false; |
|||
var arrParse = JSON.parse(JSON.stringify(data)); |
|||
if (arrParse.resultAck.result !== 0) { |
|||
self.$message({ |
|||
message: '打印失败!', |
|||
type: 'warning' |
|||
}); |
|||
return; |
|||
} |
|||
var intPageCount = parseInt(pageCount); |
|||
var intQuantityCount = parseInt(quantityCount); |
|||
self.sendCommitJob(self.DrawLableTextParamDemo, pageIndex, intPageCount, intQuantityCount); |
|||
}); |
|||
})) |
|||
})) |
|||
|
|||
|
|||
}, |
|||
/** |
|||
* 提交打印数据 |
|||
* @param {string} printData 打印数据 |
|||
* @param {string} printerInfo 打印机信息 |
|||
* @param {number} pageIndex 页序号 |
|||
* @param {number} pageCount 页数 |
|||
* @param {number} quantityCount 单页的份数 |
|||
*/ |
|||
sendCommitJob(printData, pageIndex, pageCount, quantityCount) { |
|||
if (bCanclePrint) { |
|||
return; |
|||
} |
|||
const self = this; |
|||
var jsonObj = {"printerImageProcessingInfo": {"printQuantity": quantityCount}}; |
|||
commitJob(null, JSON.stringify(jsonObj), function (data) { |
|||
var arrParse = JSON.parse(JSON.stringify(data)); |
|||
var resultInfo = "commitJob ok"; |
|||
if (arrParse.resultAck.printQuantity === pageCount && arrParse.resultAck.onPrintPageCompleted === quantityCount) { |
|||
//所有⻚数据的所有份数打印完成
|
|||
endJob(function (data) { |
|||
// 停止打印
|
|||
var arrParse = JSON.parse(JSON.stringify(data)); |
|||
if (String(arrParse.resultAck.info).indexOf("endJob ok") > -1) { |
|||
// document.getElementById("printId").disabled = false;
|
|||
} |
|||
}); |
|||
return; |
|||
} |
|||
|
|||
//异常导致打印取消
|
|||
if (arrParse.resultAck.errorCode !== 0 && (arrParse.resultAck.cacheStatus === "cancel")) { |
|||
// document.getElementById("printId").disabled = false;
|
|||
return; |
|||
} |
|||
|
|||
//异常导致打印暂停
|
|||
if (arrParse.resultAck.errorCode !== 0 && (arrParse.resultAck.cacheStatus === "pause")) { |
|||
cancleJobApi(); |
|||
return; |
|||
} |
|||
|
|||
//当前⻚所有份数打印完成,但是未打印完所有⻚数据,继续发送下⼀⻚数据
|
|||
if (String(arrParse.resultAck.info).indexOf(resultInfo) > -1 && pageIndex !== pageCount) { |
|||
pageIndex++; |
|||
setTimeout(function () { |
|||
// 初始化画板
|
|||
InitDrawingBoard(self.InitDrawingBoardParam, (data1 => { |
|||
// 添加文字
|
|||
self.DrawLableBarCodeApiDemo(self.DrawLableBarCodeParam, (data => { |
|||
self.sendCommitJob(self.DrawLableTextParamDemo, pageIndex, pageCount, quantityCount); |
|||
})) |
|||
|
|||
}))// 提交数据
|
|||
}, 500); |
|||
} |
|||
}); |
|||
} |
|||
}, |
|||
}); |
|||
@ -0,0 +1,662 @@ |
|||
//websocket
|
|||
var g_websocket; |
|||
|
|||
/* //响应数据 */ |
|||
var ackJsonData; |
|||
|
|||
/** websocket(打印服务)连接状态*/ |
|||
var websocketConnectStatus = false; |
|||
/**SDK初始化状态 */ |
|||
var initSdkStatus = false; |
|||
/**设备状态 */ |
|||
var deviceStatus = false; |
|||
/**消息列表 */ |
|||
var MessageList = {}; |
|||
|
|||
/**通过websocket发送消息 */ |
|||
function sendMsg(msg, callback) { |
|||
console.log('sendMsg', msg.apiName); |
|||
MessageList[msg.apiName] = callback; |
|||
var data = JSON.stringify(msg); |
|||
var tryTimes = 10; |
|||
for (var i = 0; i < tryTimes; i++) { |
|||
if (g_websocket.readyState === 1) { |
|||
g_websocket.send(data); |
|||
return; |
|||
} |
|||
} |
|||
} |
|||
|
|||
//初始化打印服务
|
|||
//1.1 获取接口实例JCAPI.getInstance(单例模式)
|
|||
function getInstance() { |
|||
if ('WebSocket' in window) { |
|||
g_websocket = websocketLifePeriod(); |
|||
} else { |
|||
console.log('unsupported websocket'); |
|||
//return false;
|
|||
g_websocket = null; |
|||
return false; |
|||
} |
|||
|
|||
//保持在线
|
|||
setInterval(function () { |
|||
if (g_websocket.readyState === 2 || g_websocket.readyState === 3) { |
|||
getInstance(); |
|||
} |
|||
}, 3000); |
|||
|
|||
return true; |
|||
} |
|||
|
|||
//1.1.1 打开链接及回调
|
|||
function websocketLifePeriod() { |
|||
|
|||
let websocket; |
|||
websocket = new WebSocket('ws://127.0.0.1:37989'); |
|||
//websocket.binaryType = 'arraybuffer';
|
|||
websocket.onerror = function (evt) {//since there is an error, sockets will close so...
|
|||
sok.onclose = function (e) { |
|||
console.log("WebSocket Error: ", e); |
|||
} |
|||
}; |
|||
|
|||
websocket.proxy_read_timeout = 10000; |
|||
websocket.binaryType = "arraybuffer"; |
|||
|
|||
websocket.onopen = connectCallback; |
|||
|
|||
websocket.onclose = closeCallback; |
|||
|
|||
websocket.onmessage = readCallback; |
|||
|
|||
websocket.onerror = errorCallback; |
|||
|
|||
console.log(websocket); |
|||
|
|||
return websocket; |
|||
} |
|||
|
|||
//1.1.2 websocket连接回调
|
|||
function connectCallback(e) { |
|||
ackJsonData = ''; |
|||
console.log('websocket connect success'); |
|||
websocketConnectStatus = true; |
|||
init(); |
|||
} |
|||
|
|||
//1.1.3 关闭连接回调
|
|||
function closeCallback(e) { |
|||
websocketConnectStatus = false; |
|||
console.log( |
|||
'websocket closed: ' + e.code + ' ' + e.reason + ' ' + e.wasClean |
|||
); |
|||
// globalwebsocket = websocket;
|
|||
g_websocket.close(); |
|||
//websocketLifePeriod();
|
|||
if (e.code === 1005) { |
|||
// globalwebsocket = websocket;
|
|||
} |
|||
console.log('closed'); |
|||
ackJsonData = ''; |
|||
} |
|||
|
|||
|
|||
//1.1.4 读回调
|
|||
function readCallback(e) { |
|||
var callBackInfo = e.data; |
|||
console.log('readCallback', callBackInfo); |
|||
ackJsonData = callBackInfo; |
|||
|
|||
var callbackName; |
|||
|
|||
if (isJSON(ackJsonData)) { |
|||
var arrParse = JSON.parse(ackJsonData); |
|||
|
|||
//接口回调
|
|||
if (!!MessageList[arrParse.apiName]) { |
|||
|
|||
MessageList[arrParse.apiName](arrParse); |
|||
} |
|||
|
|||
//回调分发
|
|||
if (arrParse.apiName === 'printStatus') { |
|||
if (arrParse['resultAck']['online'] === 'online') { |
|||
deviceStatus = true; |
|||
} else { |
|||
deviceStatus = false; |
|||
} |
|||
} else { |
|||
if (arrParse['resultAck']['callback'] !== undefined) { |
|||
callbackName = arrParse['resultAck']['callback']['name']; |
|||
|
|||
if (callbackName === 'onConnectSuccess') { |
|||
var printerName = arrParse['resultAck']['callback']['printerName']; |
|||
onConnectSuccess(printerName); |
|||
} else if (callbackName === 'onDisConnect') { |
|||
var printerName = arrParse['resultAck']['callback']['printerName']; |
|||
onDisConnect(printerName); |
|||
} else if (callbackName === 'onCoverStatusChange') { |
|||
var coverStatus = arrParse['resultAck']['callback']['coverStatus']; |
|||
onCoverStatusChange(coverStatus); |
|||
} else if (callbackName === 'onElectricityChange') { |
|||
var powerLever = arrParse['resultAck']['callback']['powerLever']; |
|||
onElectricityChange(powerLever); |
|||
} else if (callbackName === 'onPaperStatusChange') { |
|||
var paperStatus = arrParse['resultAck']['callback']['paperStatus']; |
|||
onPaperStatusChange(paperStatus); |
|||
} else if (callbackName === 'onPrintPageCompleted') { |
|||
onPrintPageCompleted(); |
|||
} else if (callbackName === 'onPrintProgress') { |
|||
onPrintProgress(); |
|||
} else if (callbackName === 'onAbnormalResponse') { |
|||
onAbnormalResponse(); |
|||
} else { |
|||
console.log('unknow callback api!'); |
|||
} |
|||
} |
|||
} |
|||
|
|||
ackJsonData = ''; |
|||
} |
|||
} |
|||
|
|||
//1.1.5 错误回调
|
|||
function errorCallback(e) { |
|||
//如果出现连接、处理、接收、发送数据失败的时候触发onerror事件
|
|||
console.log(e.data); |
|||
} |
|||
|
|||
//封装初始化SDK/获取打印机列表/选择打印机
|
|||
function init() { |
|||
initSdk(this.initSdkParam, function (data) { |
|||
var arrParse = JSON.parse(JSON.stringify(data)); |
|||
if (arrParse.resultAck.result !== 0) { |
|||
// 如果初始化失败
|
|||
this.$message.error("初始化打印服务失败,请重试"); |
|||
setTimeout(function () { |
|||
var index = parent.layer.getFrameIndex(window.name); |
|||
parent.layer.close(index); |
|||
}, 500); |
|||
return; |
|||
} |
|||
|
|||
getAllPrinters((data) => { |
|||
let arrParse = JSON.parse(JSON.stringify(data)); |
|||
|
|||
if (!arrParse.resultAck.result) { |
|||
this.$message.error("打印机获取失败,请重试"); |
|||
setTimeout(function () { |
|||
var index = parent.layer.getFrameIndex(window.name); |
|||
parent.layer.close(index); |
|||
}, 500); |
|||
return; |
|||
} else if (isJSON(arrParse.resultAck.info)) { |
|||
allPrinters = JSON.parse(arrParse.resultAck.info); |
|||
let allPrintersName = Object.keys(allPrinters); |
|||
let allPrintersValue = Object.values(allPrinters); |
|||
this.options = []; |
|||
// 将其保存到数据中供前端展示
|
|||
for (i = 0; i < allPrintersName.length; i++) { |
|||
let newopt = {}; |
|||
newopt.label = allPrintersName[i]; |
|||
newopt.value = allPrintersValue[i]; |
|||
this.options.push(newopt) |
|||
} |
|||
// 选中打印机
|
|||
selectPrinter(allPrintersName[0], parseInt(allPrintersValue[0]), (data => { |
|||
initSdkStatus = true; |
|||
var arrParse = JSON.parse(JSON.stringify(data)); |
|||
if (!arrParse.resultAck.result) { |
|||
return; |
|||
} else if (isJSON(arrParse.resultAck.info)) { |
|||
//选择成功,打印机连接成功
|
|||
console.log(data) |
|||
} |
|||
})) |
|||
} |
|||
}) |
|||
|
|||
}) |
|||
} |
|||
|
|||
//1.2 断开websocket连接
|
|||
function unInitPrintInstance() { |
|||
g_websocket.close(); |
|||
} |
|||
|
|||
//2.1 打印机连接成功回调onConnectSuccess
|
|||
function onConnectSuccess(printerName) { |
|||
console.log('打印机连接成功!'); |
|||
initSdkStatus = true; |
|||
deviceStatus = true; |
|||
} |
|||
|
|||
//2.2 打印机断开回调onDisConnect
|
|||
function onDisConnect(printerName) { |
|||
console.log('打印机断开!'); |
|||
initSdkStatus = false; |
|||
} |
|||
|
|||
//2.3 打印机上盖变化回调onCoverStatusChange
|
|||
function onCoverStatusChange(coverStatus) { |
|||
console.log('打印机盒盖有变化!'); |
|||
} |
|||
|
|||
//2.4 打印机电量变化回调onElectricityChange()
|
|||
function onElectricityChange(powerLever) { |
|||
console.log('打印机电量有变化!'); |
|||
} |
|||
|
|||
//2.5 打印机纸张状态变化回调onPaperStatusChange
|
|||
function onPaperStatusChange(paperStatus) { |
|||
console.log('打印机纸张状态有变化!'); |
|||
} |
|||
|
|||
//3.1 页打印成功回调onPrintPageCompleted
|
|||
function onPrintPageCompleted() { |
|||
console.log('页打印状态有变化!'); |
|||
} |
|||
|
|||
//3.2 打印进度回调onPrintProgress
|
|||
function onPrintProgress() { |
|||
console.log('打印进度有变化!'); |
|||
} |
|||
|
|||
//3.3 打印异常回调onAbnormalResponse
|
|||
function onAbnormalResponse() { |
|||
console.log('打印异常!'); |
|||
} |
|||
|
|||
//获取所有当前PC上连接的精臣打印机
|
|||
//4.1 获取打印机列表getAllPrinters()
|
|||
function getAllPrinters(callbackFunction) { |
|||
//刷新设备时,关闭设备
|
|||
//closePrinter();
|
|||
var jsonObj = {apiName: 'getAllPrinters'}; |
|||
var allDevice = {}; |
|||
|
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//5. 图片打印
|
|||
/*base64Data--图片base64数据 |
|||
nPrintCount--打印数量 |
|||
bDenoise--降噪*/ |
|||
function picturePrint(base64Data, nPrintCount, bDenoise, callbackFunction) { |
|||
var jsonObj = { |
|||
apiName: 'picturePrint', |
|||
parameter: { |
|||
data: base64Data, |
|||
nPrintCount: nPrintCount, |
|||
bDenoise: bDenoise |
|||
} |
|||
}; |
|||
|
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//6.选择并打开需要使用的打印机名称,及端口号
|
|||
function selectPrinter(printerName, port, callbackFunction) { |
|||
var jsonObj = { |
|||
apiName: 'selectPrinter', |
|||
parameter: {printerName: printerName, port: port} |
|||
}; |
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//7.停止打印
|
|||
function stopPrint(callbackFunction) { |
|||
var jsonObj = {apiName: 'stopPrint'}; |
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//8.关闭打印端口
|
|||
function closePrinter(callbackFunction) { |
|||
var jsonObj = {apiName: 'closePrinter'}; |
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//9.设置打印浓度
|
|||
//nDensity--范围为getDensityScopeApi查询范围
|
|||
function setPrintDensity(nDensity, callbackFunction) { |
|||
var jsonObj = { |
|||
apiName: 'setPrintDensity', |
|||
parameter: {nDensity: nDensity} |
|||
}; |
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//10.设置打印速度
|
|||
//nSpeed--范围为getSpeedScopeApi查询的范围
|
|||
function setPrintSpeed(nSpeed, callbackFunction) { |
|||
var jsonObj = {apiName: 'setPrintSpeed', parameter: {nSpeed: nSpeed}}; |
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//11.设置打印标贴类型
|
|||
//nType--间隙:01,黑标:02,连续纸:03,定位孔:04,透明纸:05,随机打印:06
|
|||
function setPrintLabelType(nType, callbackFunction) { |
|||
var jsonObj = {apiName: 'setPrintLabelType', parameter: {nType: nType}}; |
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
|
|||
//12.设置关机时间
|
|||
//nType--1:15分钟,2:30分钟,3:60分钟,4:never
|
|||
function setPrinterAutoShutDownTime(nType, callbackFunction) { |
|||
var jsonObj = { |
|||
apiName: 'setPrinterAutoShutDownTime', |
|||
parameter: {nType: nType} |
|||
}; |
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//13.复位打印机
|
|||
function setPrinterReset(callbackFunction) { |
|||
var jsonObj = {apiName: 'setPrinterReset'}; |
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//14. 纸张标定
|
|||
function setPrintPaperPos(nType, callbackFunction) { |
|||
var jsonObj = { |
|||
apiName: 'setPrintPaper', |
|||
parameter: {nType: nType} |
|||
}; |
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//15.获取打印速度
|
|||
function getPrintSpeed(callbackFunction) { |
|||
var jsonObj = {apiName: 'getPrintSpeed'}; |
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//15.获取打印机电量
|
|||
function getPower(callbackFunction) { |
|||
var jsonObj = {apiName: 'getPower'}; |
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//16.获取标贴类型
|
|||
function getPrintLabelType(callbackFunction) { |
|||
var jsonObj = {apiName: 'getPrintLabelType'}; |
|||
|
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//17.获取打印浓度
|
|||
function getPrintDensity(callbackFunction) { |
|||
var jsonObj = {apiName: 'getPrintDensity'}; |
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//18.获取打印机语言
|
|||
function getPrinterLanguageType(callbackFunction) { |
|||
var jsonObj = {apiName: 'getPrinterLanguageType'}; |
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//19.查询关机时间
|
|||
function getPrinterAutoShutDownTime(callbackFunction) { |
|||
var jsonObj = {apiName: 'getPrinterAutoShutDownTime'}; |
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//20.获取打印机序列号
|
|||
function getPrinterSn(callbackFunction) { |
|||
var jsonObj = {apiName: 'getPrinterSn'}; |
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//21.获取硬件版本
|
|||
function getPrinterHardwareVersion(callbackFunction) { |
|||
var jsonObj = {apiName: 'getPrinterHardwareVersion'}; |
|||
var responseData = {}; |
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//22.获取软件版本
|
|||
function getPrinterSoftwareVersion(callbackFunction) { |
|||
var jsonObj = {apiName: 'getPrinterSoftwareVersion'}; |
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//23. 获取打印机语言
|
|||
function setPrinterLanguageType(nType, callbackFunction) { |
|||
var jsonObj = { |
|||
apiName: 'setPrinterLanguageType', |
|||
parameter: {nType: nType} |
|||
}; |
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//24.获取打速度印范围
|
|||
function getSpeedScope(callbackFunction) { |
|||
var jsonObj = {apiName: 'getSpeedScope'}; |
|||
sendMsg(jsonObj, callbackFunction); |
|||
return getResult(5, 'getSpeedScope', 'set printer language timeout!'); |
|||
} |
|||
|
|||
//25. 获取已开启的打印机
|
|||
function getConnectPrinter(callbackFunction) { |
|||
var jsonObj = {apiName: 'getConnectPrinter'}; |
|||
sendMsg(jsonObj, callbackFunction); |
|||
return getResult(5, 'getConnectPrinter', 'get connect printer timeout!'); |
|||
} |
|||
|
|||
//26.获取打印机型号
|
|||
function getPrinterType(callbackFunction) { |
|||
var jsonObj = {apiName: 'getPrinterType'}; |
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//27.获取浓度范围
|
|||
function getDensityScope(callbackFunction) { |
|||
var jsonObj = {apiName: 'getDensityScope'}; |
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//28. 获取打印模式 1-热敏 2-热转印
|
|||
function getPrinterMode(callbackFunction) { |
|||
var jsonObj = {apiName: 'getPrintMode'}; |
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//29.获取打印机mac地址
|
|||
function getMacAddress(callbackFunction) { |
|||
var jsonObj = {apiName: 'getMacAddress'}; |
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//30.设置打印模式
|
|||
//nType-1热敏,2碳带
|
|||
function setPrintMode(nType, callbackFunction) { |
|||
var jsonObj = {apiName: 'setPrintMode', parameter: {nType: nType}}; |
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
/** |
|||
* 31.开始打印任务 |
|||
* @param {number} printDensity 打印浓度 |
|||
* @param {number} printLabelType 纸张类型 |
|||
* @param {number} printMaterial 材质 |
|||
* @param {number} printMode 打印模式 |
|||
* @param {number} count 总打印张数 |
|||
* @param {*} callbackFunction 回调函数 |
|||
*/ |
|||
function startJob(printDensity, printLabelType, printMode, count, callbackFunction) { |
|||
var jsonObj = { |
|||
apiName: 'startJob', |
|||
parameter: { |
|||
printDensity: printDensity, |
|||
printLabelType: printLabelType, |
|||
printMode: printMode, |
|||
count: count |
|||
} |
|||
}; |
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//32.提交打印任务commitJob
|
|||
function commitJob(printData, printerImageProcessingInfo, callbackFunction) { |
|||
var printDataJson = eval('(' + printData + ')'); |
|||
var printerImageProcessingInfoJson = eval('(' + printerImageProcessingInfo + ')'); |
|||
var jsonObj = { |
|||
apiName: 'commitJob', |
|||
parameter: { |
|||
printData: printDataJson, |
|||
printerImageProcessingInfo: printerImageProcessingInfoJson['printerImageProcessingInfo'], |
|||
} |
|||
}; |
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//33.结束打印任务endJob
|
|||
function endJob(callbackFunction) { |
|||
var jsonObj = {apiName: 'endJob'}; |
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//33.取消打印任务cancleJob
|
|||
function cancleJob(callbackFunction) { |
|||
var jsonObj = {apiName: 'stopPrint'}; |
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//34.1 创建画板
|
|||
function InitDrawingBoard(json, callbackFunction) { |
|||
var jsonObj = { |
|||
apiName: 'InitDrawingBoard', |
|||
parameter: json |
|||
}; |
|||
console.log("画布宽度:" + json.width); |
|||
console.log("画布高度:" + json.height); |
|||
console.log("画布旋转角度:" + json.rotate); |
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//34.2 绘制文本
|
|||
function DrawLableText(json, callbackFunction) { |
|||
var jsonObj = { |
|||
apiName: 'DrawLableText', |
|||
parameter: json |
|||
}; |
|||
|
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//34.3 绘制一维码
|
|||
function DrawLableBarCode(json, callbackFunction) { |
|||
var jsonObj = { |
|||
apiName: 'DrawLableBarCode', |
|||
parameter: json |
|||
}; |
|||
|
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//34.4 绘制二维码
|
|||
function DrawLableQrCode(json, callbackFunction) { |
|||
var jsonObj = { |
|||
apiName: 'DrawLableQrCode', |
|||
parameter: json |
|||
}; |
|||
|
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//34.5 绘制线条
|
|||
function DrawLableLine(json, callbackFunction) { |
|||
var jsonObj = { |
|||
apiName: 'DrawLableLine', |
|||
parameter: json |
|||
}; |
|||
|
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//34.6 绘制图形
|
|||
function DrawLableGraph(json, callbackFunction) { |
|||
var jsonObj = { |
|||
apiName: 'DrawLableGraph', |
|||
parameter: json |
|||
}; |
|||
|
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//34.7 绘制图像
|
|||
function DrawLableImage(json, callbackFunction) { |
|||
var jsonObj = { |
|||
apiName: 'DrawLableImage', |
|||
parameter: json |
|||
}; |
|||
|
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//34.8 生成预览图
|
|||
function generateImagePreviewImage(displayScale, callbackFunction) { |
|||
var jsonObj = { |
|||
apiName: 'generateImagePreviewImage', |
|||
displayScale: displayScale |
|||
}; |
|||
|
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
//35. 初始化SDK
|
|||
function initSdk(json, callbackFunction) { |
|||
var jsonObj = { |
|||
apiName: 'initSdk', |
|||
parameter: json |
|||
}; |
|||
sendMsg(jsonObj, callbackFunction); |
|||
} |
|||
|
|||
|
|||
//36. 获取调用结果
|
|||
function getResult(tryTime, apiName, errInfo) { |
|||
tryTimes = tryTime; |
|||
|
|||
let result = {}; |
|||
while (tryTimes--) { |
|||
if (!isJSON(ackJsonData)) continue; |
|||
|
|||
var arrParse = JSON.parse(ackJsonData); |
|||
if (arrParse['apiName'] === apiName) { |
|||
result = arrParse['resultAck']; |
|||
break; |
|||
} |
|||
} |
|||
|
|||
if (tryTimes <= 0) { |
|||
result['result'] = false; |
|||
result['errorCode'] = 0x12; |
|||
result['info'] = errInfo; |
|||
} |
|||
return result; |
|||
} |
|||
|
|||
//37. 判断字符串是否为JSON
|
|||
function isJSON(str) { |
|||
if (typeof str == 'string') { |
|||
try { |
|||
var obj = JSON.parse(str); |
|||
if (typeof obj == 'object' && obj) { |
|||
return true; |
|||
} else { |
|||
return false; |
|||
} |
|||
|
|||
} catch (e) { |
|||
//console.log('error:'+str+'!!!'+e);
|
|||
return false; |
|||
} |
|||
|
|||
} |
|||
|
|||
console.log('It is not a string!'); |
|||
} |
|||
File diff suppressed because it is too large
File diff suppressed because one or more lines are too long
@ -0,0 +1,2 @@ |
|||
/*! layer mobile-v2.0.0 Web 通用弹出层组件 MIT License */ |
|||
;!function(e){"use strict";var t=document,n="querySelectorAll",i="getElementsByClassName",a=function(e){return t[n](e)},s={type:0,shade:!0,shadeClose:!0,fixed:!0,anim:"scale"},l={extend:function(e){var t=JSON.parse(JSON.stringify(s));for(var n in e)t[n]=e[n];return t},timer:{},end:{}};l.touch=function(e,t){e.addEventListener("click",function(e){t.call(this,e)},!1)};var r=0,o=["layui-m-layer"],c=function(e){var t=this;t.config=l.extend(e),t.view()};c.prototype.view=function(){var e=this,n=e.config,s=t.createElement("div");e.id=s.id=o[0]+r,s.setAttribute("class",o[0]+" "+o[0]+(n.type||0)),s.setAttribute("index",r);var l=function(){var e="object"==typeof n.title;return n.title?'<h3 style="'+(e?n.title[1]:"")+'">'+(e?n.title[0]:n.title)+"</h3>":""}(),c=function(){"string"==typeof n.btn&&(n.btn=[n.btn]);var e,t=(n.btn||[]).length;return 0!==t&&n.btn?(e='<span yes type="1">'+n.btn[0]+"</span>",2===t&&(e='<span no type="0">'+n.btn[1]+"</span>"+e),'<div class="layui-m-layerbtn">'+e+"</div>"):""}();if(n.fixed||(n.top=n.hasOwnProperty("top")?n.top:100,n.style=n.style||"",n.style+=" top:"+(t.body.scrollTop+n.top)+"px"),2===n.type&&(n.content='<i></i><i class="layui-m-layerload"></i><i></i><p>'+(n.content||"")+"</p>"),n.skin&&(n.anim="up"),"msg"===n.skin&&(n.shade=!1),s.innerHTML=(n.shade?"<div "+("string"==typeof n.shade?'style="'+n.shade+'"':"")+' class="layui-m-layershade"></div>':"")+'<div class="layui-m-layermain" '+(n.fixed?"":'style="position:static;"')+'><div class="layui-m-layersection"><div class="layui-m-layerchild '+(n.skin?"layui-m-layer-"+n.skin+" ":"")+(n.className?n.className:"")+" "+(n.anim?"layui-m-anim-"+n.anim:"")+'" '+(n.style?'style="'+n.style+'"':"")+">"+l+'<div class="layui-m-layercont">'+n.content+"</div>"+c+"</div></div></div>",!n.type||2===n.type){var d=t[i](o[0]+n.type),y=d.length;y>=1&&layer.close(d[0].getAttribute("index"))}document.body.appendChild(s);var u=e.elem=a("#"+e.id)[0];n.success&&n.success(u),e.index=r++,e.action(n,u)},c.prototype.action=function(e,t){var n=this;e.time&&(l.timer[n.index]=setTimeout(function(){layer.close(n.index)},1e3*e.time));var a=function(){var t=this.getAttribute("type");0==t?(e.no&&e.no(),layer.close(n.index)):e.yes?e.yes(n.index):layer.close(n.index)};if(e.btn)for(var s=t[i]("layui-m-layerbtn")[0].children,r=s.length,o=0;o<r;o++)l.touch(s[o],a);if(e.shade&&e.shadeClose){var c=t[i]("layui-m-layershade")[0];l.touch(c,function(){layer.close(n.index,e.end)})}e.end&&(l.end[n.index]=e.end)},e.layer={v:"2.0",index:r,open:function(e){var t=new c(e||{});return t.index},close:function(e){var n=a("#"+o[0]+e)[0];n&&(n.innerHTML="",t.body.removeChild(n),clearTimeout(l.timer[e]),delete l.timer[e],"function"==typeof l.end[e]&&l.end[e](),delete l.end[e])},closeAll:function(){for(var e=t[i](o[0]),n=0,a=e.length;n<a;n++)layer.close(0|e[0].getAttribute("index"))}},"function"==typeof define?define(function(){return layer}):function(){var e=document.scripts,n=e[e.length-1],i=n.src,a=i.substring(0,i.lastIndexOf("/")+1);n.getAttribute("merge")||document.head.appendChild(function(){var e=t.createElement("link");return e.href=a+"need/layer.css?2.0",e.type="text/css",e.rel="styleSheet",e.id="layermcss",e}())}()}(window); |
|||
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 5.8 KiB |
|
After Width: | Height: | Size: 11 KiB |
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 5.7 KiB |
|
After Width: | Height: | Size: 701 B |
|
After Width: | Height: | Size: 1.7 KiB |
@ -0,0 +1,93 @@ |
|||
<!DOCTYPE html> |
|||
<html lang="en" xmlns:th="http://www.thymeleaf.org"> |
|||
<head> |
|||
<meta charset="UTF-8"> |
|||
<title>打印设置</title> |
|||
<meta name="renderer" content="webkit"> |
|||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
|||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> |
|||
<link rel="stylesheet" href="/static/lib/layui-v2.6.3/css/layui.css" media="all"> |
|||
<link rel="stylesheet" href="/static/css/public.css" media="all"> |
|||
</head> |
|||
<body> |
|||
<div class="layuimini-container"> |
|||
<div class="layuimini-main"> |
|||
<fieldset class="table-search-fieldset"> |
|||
<legend>打印设置</legend> |
|||
<input id="index" style="display: none" th:value="${index}"> |
|||
<form class="layui-form layui-form-pane" |
|||
style="margin: 0 auto;max-width: 700px;padding-top: 5px; padding-bottom: 50px" lay-filter="form1"> |
|||
<div class="layui-form-item"> |
|||
<div class="layui-inline"> |
|||
<label class="layui-form-label">媒体布局:</label> |
|||
<div class="layui-input-inline"> |
|||
<select name="media_layout" id="media_layout"> |
|||
</select> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<div class="layui-inline"> |
|||
<label class="layui-form-label">媒体类型:</label> |
|||
<div class="layui-input-inline"> |
|||
<select name="media_type" id="media_type"> |
|||
</select> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="layui-form-item"> |
|||
<div class="layui-inline"> |
|||
<label class="layui-form-label">打印质量:</label> |
|||
<div class="layui-input-inline"> |
|||
<select name="print_quality" id="print_quality"> |
|||
</select> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
|
|||
</form> |
|||
</fieldset> |
|||
</div> |
|||
</div> |
|||
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script> |
|||
<script> |
|||
layui.use(['form', 'dropdown'], function () { |
|||
var $ = layui.jquery, |
|||
form = layui.form, |
|||
dropdown = layui.dropdown; |
|||
let index = $("#index").val() |
|||
layui.$(function () { |
|||
let req = {}; |
|||
req.index = index; |
|||
$.ajax({ |
|||
url: "/Epson/PrintSettingLoad", |
|||
type: "post", |
|||
dataType: "json", |
|||
data:JSON.stringify(req), |
|||
contentType: "application/json;charset=utf-8", |
|||
beforeSend: function () { |
|||
this.layerIndex = layer.load(0, {shade: [0.5, '#393D49']}); |
|||
}, |
|||
success: function (data) { |
|||
if (data.status === 200) { |
|||
$.ajax({ |
|||
url: "/Epson/updatePrintSettingPage", |
|||
type: "post", |
|||
dataType: "json", |
|||
contentType: "application/json;charset=utf-8", |
|||
success: function (result) { |
|||
layer.close(this.layerIndex); |
|||
console.log(result) |
|||
} |
|||
}) |
|||
} |
|||
} |
|||
}) |
|||
}) |
|||
|
|||
|
|||
}); |
|||
</script> |
|||
</body> |
|||
</html> |
|||
@ -0,0 +1,103 @@ |
|||
<!DOCTYPE html> |
|||
<html lang="en" xmlns:th="http://www.thymeleaf.org"> |
|||
<head> |
|||
<meta charset="utf-8"> |
|||
<title>打印初始页面</title> |
|||
<meta name="renderer" content="webkit"> |
|||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
|||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> |
|||
<link rel="stylesheet" href="/static/lib/layui-v2.6.3/css/layui.css" media="all"> |
|||
<link rel="stylesheet" href="/static/css/public.css" media="all"> |
|||
</head> |
|||
<body> |
|||
<div class="layuimini-container"> |
|||
<div class="layuimini-main"> |
|||
<fieldset class="table-search-fieldset"> |
|||
<legend>打印</legend> |
|||
<form class="layui-form layui-form-pane" |
|||
style="margin: 0 auto;max-width: 700px;padding-top: 5px; padding-bottom: 50px" lay-filter="form1"> |
|||
<div class="layui-form-item"> |
|||
<div class="layui-inline"> |
|||
<label class="layui-form-label">打印机:</label> |
|||
<div class="layui-input-inline"> |
|||
<select name="printer" id="printer"> |
|||
</select> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
|
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label">打印设置:</label> |
|||
<div class="layui-input-inline"> |
|||
<input type="button" class="layui-btn layui-btn-primary" onclick="print_setting()" value="设置" style="width: 100%"> |
|||
</div> |
|||
</div> |
|||
|
|||
</form> |
|||
</fieldset> |
|||
</div> |
|||
</div> |
|||
|
|||
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script> |
|||
<script> |
|||
function print_setting(){ |
|||
|
|||
} |
|||
|
|||
layui.use(['form','dropdown'],function () { |
|||
var $ = layui.jquery, |
|||
form = layui.form, |
|||
dropdown = layui.dropdown; |
|||
layui.$(function () { |
|||
$.ajax({ |
|||
url:"/Epson/GetPrinterInfoList", |
|||
type:"post", |
|||
dataType:"json", |
|||
contentType: "application/json;charset=utf-8", |
|||
beforeSend: function () { |
|||
this.layerIndex = layer.load(0, {shade: [0.5, '#393D49']}); |
|||
}, |
|||
success:function (data) { |
|||
layer.close(this.layerIndex); |
|||
data = data.data; |
|||
if(data === null){ |
|||
layer.msg("暂未查询到爱普生打印机,请确认",{ |
|||
icon:0, |
|||
time:1000 |
|||
},function () { |
|||
var index = parent.layer.getFrameIndex(window.name); |
|||
parent.layer.close(index);//关闭当前页 |
|||
}) |
|||
}else{ |
|||
let printer_list = $("#printer"); |
|||
printer_list.empty(); |
|||
$.each(data,function (index,item) { |
|||
printer_list.append(new Option(item,index)) |
|||
}); |
|||
form.render(); |
|||
} |
|||
} |
|||
}) |
|||
}); |
|||
|
|||
|
|||
print_setting = function () { |
|||
layer.open({ |
|||
type: 2, |
|||
title: '打印设置', |
|||
skin: 'layui-layer-rim', |
|||
maxmin: true, |
|||
shadeClose: true, //点击遮罩关闭层 |
|||
area: ['100%', '100%'], |
|||
move: '.layui-layer-title', |
|||
fixed: false, |
|||
content: '/printSetting?index='+$("#printer").val(), |
|||
}) |
|||
} |
|||
|
|||
|
|||
}); |
|||
</script> |
|||
</body> |
|||
</html> |
|||
@ -0,0 +1,220 @@ |
|||
<!DOCTYPE html> |
|||
<html lang="en" xmlns:th="http://www.thymeleaf.org"> |
|||
<!-- 引入样式 --> |
|||
<link rel="stylesheet" href="/static/css/JcPrinter/chalk_index.css"> |
|||
<head> |
|||
<meta charset="utf-8" /> |
|||
<title>精臣SDK</title> |
|||
</head> |
|||
<body> |
|||
<div id="app" class="container"> |
|||
<input style="display:none;" id="materialQrCode" th:value="${qrCode}"> |
|||
<div class="link"> |
|||
<H2>打印设备</H2> |
|||
<el-row> |
|||
<el-col :span="5"> |
|||
<el-select @change="selectPrinterApi()" v-model="value" placeholder="请选择"> |
|||
<el-option |
|||
v-for="item in options" |
|||
:key="item.value" |
|||
:label="item.label" |
|||
:value="item.value"> |
|||
</el-option> |
|||
</el-select> |
|||
</el-col> |
|||
<el-col :span="12"><el-button @click="refreshPrinters()" type="primary">重新获取</el-button></el-col> |
|||
</el-row> |
|||
</div> |
|||
<br> |
|||
<br> |
|||
<div> |
|||
<el-row> |
|||
<el-col :span="5"> |
|||
<div style="margin-bottom:20px;"> |
|||
<el-button @click="InitDrawingBoardApi()" type="primary">初始化画布</el-button> |
|||
</div> |
|||
<div v-show="isInit"> |
|||
<div style="margin-bottom:20px;"> |
|||
<el-button @click="dialogDrawLableBarCodeParam=true;isEditTag=false" type="primary">绘制条形码</el-button> |
|||
</div> |
|||
<div style="margin-bottom:20px;"> |
|||
<el-button @click="dialogDrawLableQrCodeParam=true;isEditTag=false" type="primary">绘制二维码</el-button> |
|||
</div> |
|||
</div> |
|||
</el-col> |
|||
<el-col :span="10"> |
|||
<div style="margin-bottom:20px"> |
|||
<el-tag v-show="isInit" @click="InitDrawingBoardApi()">画布</el-tag> |
|||
<el-tag |
|||
style="margin: 10px 10px 10px 0;" |
|||
v-for="(tag,index) in tags" |
|||
:key="tag.name" |
|||
closable |
|||
@click="clickTag(tag,index)" |
|||
@close="handleClose(index)" |
|||
>{{tag.name}} |
|||
</el-tag> |
|||
</div> |
|||
<div class="img"> |
|||
<img v-if="imgSrc" :src="imgSrc" alt=""> |
|||
<el-empty v-else description="预览位置"></el-empty> |
|||
</div> |
|||
<div v-show="isDraw" style="margin-top: 20px;"> |
|||
<el-button @click="generateImagePreviewImagepi()">预览</el-button> |
|||
<el-button @click="emptyImagePreviewImage()">清空</el-button> |
|||
</div> |
|||
</el-col> |
|||
</el-row> |
|||
</div> |
|||
<div> |
|||
<h2>打印相关</h2> |
|||
<el-row> |
|||
<el-col :span="7"> |
|||
<el-form :model="form" label-width="80px"> |
|||
<el-form-item label="打印浓度"> |
|||
<el-input v-model="form.density"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="打印纸张"> |
|||
<el-select v-model="form.paperType" placeholder="请选择打印纸张"> |
|||
<el-option label="间隙纸" value="1"></el-option> |
|||
<el-option label="黑标纸" value="2"></el-option> |
|||
<el-option label="连续纸" value="3"></el-option> |
|||
<el-option label="定孔纸" value="4"></el-option> |
|||
<el-option label="透明纸" value="5"></el-option> |
|||
<el-option label="标牌" value="6"></el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item label="打印份数"> |
|||
<el-input v-model="form.quantityCount" type="number" placeholder="建议填写2-100,单份打印时无效"></el-input> |
|||
</el-form-item> |
|||
</el-form> |
|||
</el-col> |
|||
<el-col :span="14"> |
|||
<div> |
|||
<el-button style="margin: 0 20px 40px 40px;" @click="startPrintJob(1)" type="primary">单页单份打印</el-button> |
|||
<el-button style="margin: 0 0 40px 0;" @click="startPrintJob(2)" type="primary">多页单份打印</el-button> |
|||
</div> |
|||
<div> |
|||
<el-button style="margin: 0 20px 20px 40px;" @click="startPrintJob(3)" type="primary">单页多份打印</el-button> |
|||
<el-button style="margin: 0 0 20px 0;" @click="startPrintJob(4)"type="primary">多页多份打印</el-button> |
|||
</div> |
|||
</el-col> |
|||
</el-row> |
|||
</div> |
|||
<el-dialog title="画布初始化" :visible.sync="dialogInitDrawingBoardParam"> |
|||
<el-form :model="form"> |
|||
<el-form-item label="画布宽度" :label-width="formLabelWidth"> |
|||
<el-input type="number" v-model="InitDrawingBoardParam.width" ></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="画布高度" :label-width="formLabelWidth"> |
|||
<el-input type="number" v-model="InitDrawingBoardParam.height" ></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="旋转角度" :label-width="formLabelWidth"> |
|||
<el-select v-model="InitDrawingBoardParam.rotate" placeholder="请选择活动区域"> |
|||
<el-option label="旋转0度" :value="0"></el-option> |
|||
<el-option label="旋转90度" :value="90"></el-option> |
|||
<el-option label="旋转180度" :value="180"></el-option> |
|||
<el-option label="旋转270度" :value="270"></el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
</el-form> |
|||
<div slot="footer" class="dialog-footer"> |
|||
<el-button @click="dialogInitDrawingBoardParam = false">取 消</el-button> |
|||
<el-button type="primary" @click="InitDrawingBoardPar()">确 定</el-button> |
|||
</div> |
|||
</el-dialog> |
|||
<el-dialog title="绘制一维码" :visible.sync="dialogDrawLableBarCodeParam"> |
|||
<el-form :model="form"> |
|||
<el-form-item label="一维码内容" :label-width="formLabelWidth"> |
|||
<el-input v-model="DrawLableBarCodeParam.value" readonly></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="宽度" :label-width="formLabelWidth"> |
|||
<el-input type="number" v-model="DrawLableBarCodeParam.width" ></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="高度" :label-width="formLabelWidth"> |
|||
<el-input type="number" v-model="DrawLableBarCodeParam.height" ></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="旋转角度" :label-width="formLabelWidth"> |
|||
<el-select v-model="DrawLableBarCodeParam.rotate" placeholder="请选择旋转角度"> |
|||
<el-option label="旋转0度" :value="0"></el-option> |
|||
<el-option label="旋转90度" :value="90"></el-option> |
|||
<el-option label="旋转180度" :value="180"></el-option> |
|||
<el-option label="旋转270度" :value="270"></el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item label="文本位置" :label-width="formLabelWidth"> |
|||
<el-select v-model="DrawLableBarCodeParam.textPosition" placeholder="请选择文本位置"> |
|||
<el-option label="下方显示" :value="0"></el-option> |
|||
<el-option label="上方显示" :value="1"></el-option> |
|||
<el-option label="不显示" :value="2"></el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
</el-form> |
|||
|
|||
<div slot="footer" class="dialog-footer"> |
|||
<el-button @click="dialogDrawLableBarCodeParam = false">取 消</el-button> |
|||
<el-button type="primary" @click="DrawLableBarCodeApi()">确 定</el-button> |
|||
</div> |
|||
</el-dialog> |
|||
<el-dialog title="绘制二维码" :visible.sync="dialogDrawLableQrCodeParam"> |
|||
<el-form :model="form"> |
|||
<el-form-item label="二维码内容" :label-width="formLabelWidth"> |
|||
<el-input v-model="DrawLableQrCodeParam.value" readonly ></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="宽高" :label-width="formLabelWidth"> |
|||
<el-input type="number" v-model="DrawLableQrCodeParam.width" ></el-input> |
|||
</el-form-item> |
|||
<span style="color:red; padding-left:120px">此处不依据二维码类型校验二维码内容,可百度相关的条码类型输入符合要求的条码类型</span> |
|||
<el-form-item label="一维码类型" :label-width="formLabelWidth"> |
|||
<el-select v-model="DrawLableQrCodeParam.codeType" placeholder="请选择一维码类型"> |
|||
<el-option label="QR_CODE" :value="31"></el-option> |
|||
<el-option label="PDF417" :value="32"></el-option> |
|||
<el-option label="DATA_MATRIX" :value="33"></el-option> |
|||
<el-option label="AZTEC" :value="34"></el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item label="旋转角度" :label-width="formLabelWidth"> |
|||
<el-select v-model="DrawLableQrCodeParam.rotate" placeholder="请选择旋转角度"> |
|||
<el-option label="旋转0度" :value="0"></el-option> |
|||
<el-option label="旋转90度" :value="90"></el-option> |
|||
<el-option label="旋转180度" :value="180"></el-option> |
|||
<el-option label="旋转270度" :value="270"></el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
</el-form> |
|||
|
|||
<div slot="footer" class="dialog-footer"> |
|||
<el-button @click="dialogDrawLableQrCodeParam = false">取 消</el-button> |
|||
<el-button type="primary" @click="DrawLableQrCodeApi()">确 定</el-button> |
|||
</div> |
|||
</el-dialog> |
|||
</div> |
|||
|
|||
<script src="/static/js/vue/vue.js"></script> |
|||
|
|||
<!-- 引入组件库 --> |
|||
<script src="/static/js/JcPrinter/element-ui_lib_index.js"></script> |
|||
<script src='/static/js/JcPrinter/jcPrinterSdk_api_third.js'></script> |
|||
<script src='/static/js/JcPrinter/index_Demo.js'></script> |
|||
</body> |
|||
|
|||
</html> |
|||
|
|||
<style> |
|||
body{ |
|||
margin: 0; |
|||
} |
|||
.container{ |
|||
width: 1200px; |
|||
margin: 0 auto; |
|||
} |
|||
.img{ |
|||
width: 400px; |
|||
min-height: 300px; |
|||
border: solid 1px #67C23A; |
|||
} |
|||
.img img{ |
|||
width: 400px; |
|||
min-height: 300px; |
|||
} |
|||
</style> |
|||
Loading…
Reference in new issue