|
|
@ -2,6 +2,8 @@ package a8k.app.factory; |
|
|
|
|
|
|
|
import a8k.app.constant.AppConstant; |
|
|
|
import a8k.app.dao.type.db.ReactionRecord; |
|
|
|
import a8k.app.iflytophald.type.protocol.A8kEcode; |
|
|
|
import a8k.app.type.exception.AppException; |
|
|
|
import a8k.app.type.lisprotocol.BiLisDoubleTrackFrame; |
|
|
|
import a8k.app.type.lisprotocol.BiLisDoubleTrackFrameBuildContext; |
|
|
|
import a8k.app.type.lisprotocol.BiLisFrameParseErrorCode; |
|
|
@ -19,7 +21,7 @@ import java.lang.reflect.Field; |
|
|
|
@Slf4j |
|
|
|
public class BiLisDoubleTrackFrameFactory { |
|
|
|
// |
|
|
|
static public BiLisDoubleTrackFrameBuildContext createRFrame(ReactionRecord reactionRecord, Integer subProjIndex) { |
|
|
|
static public BiLisDoubleTrackFrameBuildContext createRFrame(ReactionRecord reactionRecord, Integer subProjIndex) throws AppException { |
|
|
|
//R|A10|123456789|^PCT/CRP^CRP^#|46|mg/L|0.5-200||L_1^_03|F||||20141201144906||0|<CR> |
|
|
|
|
|
|
|
BiLisDoubleTrackFrameBuildContext buildContext = new BiLisDoubleTrackFrameBuildContext(); |
|
|
@ -80,7 +82,7 @@ public class BiLisDoubleTrackFrameFactory { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static public BiLisDoubleTrackFrameBuildContext createQFrameBytes(String deviceName, String barcode) { |
|
|
|
static public BiLisDoubleTrackFrameBuildContext createQFrameBytes(String deviceName, String barcode) throws AppException { |
|
|
|
BiLisDoubleTrackFrameBuildContext context = new BiLisDoubleTrackFrameBuildContext(); |
|
|
|
|
|
|
|
BiLisDoubleTrackFrame frame = new BiLisDoubleTrackFrame(); |
|
|
@ -144,7 +146,7 @@ public class BiLisDoubleTrackFrameFactory { |
|
|
|
|
|
|
|
char[] checkcode = computeChecksum(cmdContent); |
|
|
|
|
|
|
|
if (!isCheckcodeEq(c1,c2,checkcode)) { |
|
|
|
if (!isCheckcodeEq(c1, c2, checkcode)) { |
|
|
|
log.warn("Received frame has invalid checksum: {}, {} !={} {}", c1, c2, checkcode[0], checkcode[1]); |
|
|
|
throw new BiLisFrameParseException(BiLisFrameParseErrorCode.ChecksumError, "rx checksum error: " + c1 + ", " + c2); |
|
|
|
} |
|
|
@ -183,14 +185,14 @@ public class BiLisDoubleTrackFrameFactory { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static public void serialize(BiLisDoubleTrackFrameBuildContext buildContext, BiLisDoubleTrackFrame frame) { |
|
|
|
static public void serialize(BiLisDoubleTrackFrameBuildContext buildContext, BiLisDoubleTrackFrame frame) throws AppException { |
|
|
|
/* |
|
|
|
* Frame Structure: |
|
|
|
* STX,FN,Content,ETX,C1,C2,CR,LF |
|
|
|
*/ |
|
|
|
if (frame.frameType != BiLisDoubleTrackFrame.STX) { |
|
|
|
log.warn("Frame type is not STX, cannot serialize: {}", frame.frameType); |
|
|
|
buildContext.buildSuccess = false; |
|
|
|
throw AppException.of(A8kEcode.CODEERROR, "Frame type is not STX, cannot serialize: %s", frame.frameType); |
|
|
|
} |
|
|
|
|
|
|
|
if ((frame.frameContent instanceof QFrame |
|
|
@ -201,7 +203,7 @@ public class BiLisDoubleTrackFrameFactory { |
|
|
|
createBiLisDoubleTrackFrame(buildContext, content); |
|
|
|
} else { |
|
|
|
log.warn("Unsupported frame content type: {}", frame.frameContent.getClass().getSimpleName()); |
|
|
|
buildContext.buildSuccess = false; |
|
|
|
throw AppException.of(A8kEcode.CODEERROR, "Unsupported frame content type: %s", frame.frameContent.getClass().getSimpleName()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|