UniPRT SDK  v1.0.0.0
JsonStringBuilder类 参考

支持构建发送到印表机的 JSON 讯息 更多...

静态 Public 成员函数

static String CreateMsgFrame (String fromId, String trackId, String command, String content, String toId)
 Create JSON object message that can be sent to printer. 更多...
 
static String CreateMsgFrame_Json (String fromId, String trackId, String command)
 
static String CreateMsgFrame_Json (String fromId, String trackId, String command, String content)
 
static String CreateMsgFrame_Json (String fromId, String trackId, String command, String content, String toId)
 
static String CreateMsgFrame_Json (String fromId, String trackId, String command, String content, String toId, boolean usingDataPort)
 Create JSON object message that can be sent to printer. 更多...
 
static String GetRandomId_Json ()
 Returns random integer simply used to make sure each msg has unique ID. Use this to identify any msgs that will be sent infrequent 更多...
 
static String GetRandomObjectId_Json ()
 Returns random integer in case want to use a dedicated object ID that can also be used to send/receive json messages with that ID as "TrackNo" 更多...
 

静态 Public 属性

static final String DataPortPrefix = "!PTR_SETUP\nUPMC\n"
 
static final String DataPortSuffix = "PTR_END\n"
 
static final int MAX_RAND_MSG_ID = 4_000_000
 调用 GetRandomId() 时将随机生成的最大 ID,可用于发送请求讯息的 ID。
 
static final int MAX_RAND_OBJ_ID = 6_000_000
 调用 GetRandomObjectId() 时将随机生成的最大 ID。
适用于想要使用“对象 ID”发送请求讯息的类/对象。
 
static final int MIN_RAND_MSG_ID = 1
 调用 GetRandomId() 时将随机生成的最小 ID,可用于发送请求讯息的 ID。
 
static final int MIN_RAND_OBJ_ID = 4_000_001
 调用 GetRandomObjectId() 时将随机生成的最小 ID。
适用于想要使用“对象 ID”发送请求讯息的类/对象。
 

详细描述

支持构建发送到印表机的 JSON 讯息

成员函数说明

◆ CreateMsgFrame()

static String CreateMsgFrame ( String  fromId,
String  trackId,
String  command,
String  content,
String  toId 
)
static

Create JSON object message that can be sent to printer.

fromId:必填,发送者的标识符。请注意,这是用于路由响应的,应该对每个发送讯息的类/对象唯一。
trackId:必填,可用于跟踪讯息的标识符。
command:必填,命令值。
content:选填,内容值。可以是 JSON 对象。请注意,未检查是否为正确的 JSON 格式。
请注意,由于 content 可以是 JSON 对象或字符串,发送字符串时由调用者负责添加引号。 toId:选填,用于区分目标接收者的标识符。

◆ CreateMsgFrame_Json()

static String CreateMsgFrame_Json ( String  fromId,
String  trackId,
String  command,
String  content,
String  toId,
boolean  usingDataPort 
)
static

Create JSON object message that can be sent to printer.

fromId:必填,发送者的标识符。请注意,这是用于路由响应的,应该对每个发送讯息的类/对象唯一。
trackId:必填,可用于跟踪讯息的标识符。
command:必填,命令值。
content:选填,内容值。可以是 JSON 对象。请注意,未检查是否为正确的 JSON 格式。
请注意,由于 content 可以是 JSON 对象或字符串,发送字符串时由调用者负责添加引号。 toId:选填,用于区分目标接收者的标识符。

◆ GetRandomId_Json()

static String GetRandomId_Json ( )
static

Returns random integer simply used to make sure each msg has unique ID. Use this to identify any msgs that will be sent infrequent

随机值在 MIN_RAND_MSG_ID 和 MAX_RAND_MSG_ID 之间返回

◆ GetRandomObjectId_Json()

static String GetRandomObjectId_Json ( )
static

Returns random integer in case want to use a dedicated object ID that can also be used to send/receive json messages with that ID as "TrackNo"

随机值在 MIN_RAND_OBJ_ID 和 MAX_RAND_OBJ_ID 之间返回。
如果希望为对象分配讯息 ID 以发送/接收讯息时,使用此选项。例如:对象向/从印表机发送/接收 ODV 或 RFID 讯息。