Skip to content

Commit

Permalink
[+] Added log messages for directIO commands to write TLV data
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaly Kravtsov committed Jan 28, 2022
1 parent 6150ec7 commit c23be57
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
package com.shtrih.jpos.fiscalprinter.directIO;

import com.shtrih.jpos.fiscalprinter.FiscalPrinterImpl;
import com.shtrih.util.CompositeLogger;
import com.shtrih.util.Hex;

public class DIOFSWriteOperationTLV extends DIOItem {

private static CompositeLogger logger = CompositeLogger.getLogger(DIOFSWriteOperationTLV.class);

public DIOFSWriteOperationTLV(FiscalPrinterImpl service) {
super(service);
}

public void execute(int[] data, Object object) throws Exception
{
byte[] tlv = (byte[]) object;
boolean print = true;
if (data != null) {
print = (data[0] == 1);
}
service.fsWriteOperationTLV((byte[]) object, print);
logger.debug("directIO(SMFPTR_DIO_FS_WRITE_OPERATION_TLV, " + Hex.toHex(tlv) + ")");
service.fsWriteOperationTLV(tlv, print);
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
package com.shtrih.jpos.fiscalprinter.directIO;

import com.shtrih.jpos.fiscalprinter.FiscalPrinterImpl;
import com.shtrih.util.CompositeLogger;
import com.shtrih.util.Hex;

public class DIOFSWriteTLV extends DIOItem {

private static CompositeLogger logger = CompositeLogger.getLogger(DIOFSWriteTLV.class);

public DIOFSWriteTLV(FiscalPrinterImpl service) {
super(service);
}

public void execute(int[] data, Object object) throws Exception {
byte[] tlv = (byte[])object;
boolean print = true;
if (data != null) {
print = (data[0] == 1);
}
service.fsWriteTLV((byte[]) object, print);
logger.debug("directIO(SMFPTR_DIO_FS_WRITE_TLV, " + Hex.toHex(tlv) + ")");
service.fsWriteTLV(tlv, print);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@
import com.shtrih.fiscalprinter.command.TLVList;
import com.shtrih.jpos.DIOUtils;
import com.shtrih.jpos.fiscalprinter.FiscalPrinterImpl;
import com.shtrih.util.CompositeLogger;
import com.shtrih.util.Hex;

public class DIOFSWriteTag extends DIOItem {

private static CompositeLogger logger = CompositeLogger.getLogger(DIOFSWriteTag.class);

public DIOFSWriteTag(FiscalPrinterImpl service) {
super(service);
}
Expand All @@ -28,6 +32,8 @@ public void execute(int[] data, Object object) throws Exception {
print = data[1] == 1;
}
String tagValue = (String) object;
logger.debug(String.format("directIO(SMFPTR_DIO_FS_WRITE_TAG, Tag: %s, Valus: %s)", tagId, tagValue));

byte[] tlv = getPrinter().getTLVData(tagId, tagValue);
service.fsWriteTLV(tlv, print);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.shtrih.util;

public class ServiceVersion {
public static final String VERSION = "638";
public static final String VERSION = "639";
}
Binary file modified Source/FiscalPrinterTest/Res/Logo.bmp
Binary file not shown.
Binary file removed Source/FiscalPrinterTest/Res/Logo.gif
Binary file not shown.
Binary file removed Source/FiscalPrinterTest/Res/Logo.png
Binary file not shown.
Binary file removed Source/FiscalPrinterTest/Res/Logo2.bmp
Binary file not shown.
4 changes: 2 additions & 2 deletions Source/FiscalPrinterTest/Res/jpos.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<!-- <prop name="portName" type="String" value="COM8"/> -->
<!--Baudrate 2400;4800;9600;19200;38400;57600;115200;230400;460800 -->
<!--<prop name="portName" type="String" value="192.168.137.111:7778"/>-->
<prop name="portName" type="String" value="COM3"/>
<prop name="portName" type="String" value="COM8"/>
<prop name="baudRate" type="String" value="115200"/>
<!--Default department-->
<prop name="department" type="String" value="0"/>
Expand Down Expand Up @@ -165,7 +165,7 @@
<!-- Table mode, 0 - auto, 1 - disabled -->
<prop name="tableMode" type="String" value="0"/>
<!-- Logo mode, 0 - feed paper, 1 - split image -->
<prop name="logoMode" type="String" value="1"/>
<prop name="logoMode" type="String" value="0"/>
<!-- SearchMode, 0 - none, 1 - search on error -->
<prop name="searchMode" type="String" value="0"/>
<!-- stringEncoding -->
Expand Down
Binary file removed Source/FiscalPrinterTest/Res/printer.bmp
Binary file not shown.
Binary file removed Source/FiscalPrinterTest/Res/qrcode_110.bmp
Binary file not shown.
32 changes: 31 additions & 1 deletion Source/FiscalPrinterTest/src/PrinterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ public void printFiscalReceipt() {
//printCorrectionReceipts();
//testCommandTimeout();

printSalesReceiptZeroPrice();
printFiscalReceiptLogoBeforeHeader();

} catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -4542,4 +4542,34 @@ private void printSalesReceiptZeroPrice() {
e.printStackTrace();
}
}

public void printFiscalReceiptLogoBeforeHeader() {
try {
printer.resetPrinter();

printer.clearLogo();
printer.clearImages();
printer.loadLogo(SmFptrConst.SMFPTR_LOGO_BEFORE_HEADER, "logo.bmp");
int numHeaderLines = printer.getNumHeaderLines();
for (int i = 1; i <= numHeaderLines; i++) {
printer.setHeaderLine(i, "Header line " + i, false);
}

long payment = 0;
printer.resetPrinter();
printer.setFiscalReceiptType(jpos.FiscalPrinterConst.FPTR_RT_SALES);
printer.beginFiscalReceipt(false);
printer.printRecItem("Item 1", 0, 1000000, 4, 100, "");
printer.printRecTotal(100, 100, "1");
printer.printRecMessage("printRecMessage 1");
printer.printRecMessage("printRecMessage 2");
printer.printRecMessage("printRecMessage 3");
printer.endFiscalReceipt(false);

} catch (Exception e) {
e.printStackTrace();
}
}


}

0 comments on commit c23be57

Please sign in to comment.