UniPRT SDK  v1.0.0.0
JsonStringBuilder 類別 參考文件

支援建立發送到打印機的 JSON 訊息 更多...

靜態公開方法(Static Public Methods)

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". 更多...
 

靜態公開屬性

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 訊息。