UniPRT SDK  v1.0.0.0
JSON 与印表机的资料交换

以下部分描述了用于读取/写入印表机设定的 JSON(JavaScript 物件标记法)资料交换语法。

请注意,SettingsReadWrite 类别提供了读取/写入设定的支援,并使用下方定义的 JSON 命令结构与印表机进行通讯。这提供给希望使用印表机支援的 JSON 介面直接与印表机通讯的使用者作为参考资料。

通用 JSON 命令语法 - 管理端口

以下是印表机 JSON 命令的一般语法。

请注意, ToFrom 键是可选的,如果应用程式不需要,可以省略这些参数。这些参数只会交换并从印表机回传。

印表机会使用相同TrackNo回应命令,呼叫者/发送者可以使用此编号选择对应的回应,特别是当多个命令发送给印表机时。如果印表机回传数据,数据会包含在**Content**栏位中。

完整命令:

{ "Command": <command>,
"From": <optional>,
"To": <optional>,
"TrackNo": <AnyTrackingString>,
"Content": { <content> }
}

最小命令:不包含 ToFrom 选用键。

{ "Command": <command>,
"TrackNo": <AnyTrackingString>,
"Content": { <content> }
}

支援的 JSON 命令

以下是发送给印表机的 "Command" 键支援的值。

"Cfg.Item" 读取/写入键及对应的值 使用 null 作为值读取键项。 读取单一键。
("Content":)

{ "MyKeyOfInterest" : null }
  • Read Multiple Keys.
    ("Content":)
    { "MyKey1" : null, "MyKey2" : null, .., "MyKeyN" : null }

请注意,如果使用分支名称,可以读取多个键。
例如,使用 "branchX.subBranch" 作为键会回传 "item1" 和 "item2",如果 branchX.subBranch.item1 和 branchX.subBranch.item2 存在。
("Content":):

{ "branchX.subBranch" : null }
  • 使用与特定键相关联的任何支持值来编写键值。。
    ("Content":):
    {"DecimalKey" : 3.5}
  • "Cfg.Prop" 读取与键或分支相关的属性
  • 属性:
    属性 描述
    "Type" "Dec" - Decimal, "Enum" - Enumeration, "Bool" - Boolean, "Exe" - Executable
    "Perm" Permision: Read (R), Write (W), Execute (X)
    "Value" The current value associated with key
    "Min" Minimum value
    "Max" Maximum value
    "Inc" Increment
    "Options" The allowed values. Note for Bool only true or false allowed.
  • 键 "Type" 回传的属性:
    "Dec" "Enum" "Bool" "Exe"
    "Type" x x x x
    "Perm" x x x x
    "Value" x x x
    "Min" x
    "Max" x
    "Inc" x
    "Options" x

支援的 JSON 键

支持的键及对应的值:

Examples

Example 1 - Read "Image.Width-in" key

{ "Command": "Cfg.Item",
"TrackNo": "Ex-1",
"Content": {
"Image.Width-in" : null
}
}

Example 2 - Write "Image.Width-in" key

{ "Command": "Cfg.Item",
"TrackNo": "Ex-2",
"Content": {
"Image.Width-in" : 3.5
}
}

Example 3 - Read Properties for multiple keys

Below shows how to read multiple "branch" items ("Speed" and "ODV.Symbol") in order to read all keys associated with each branch as well as an individual item "Label.Sensor".

Command Sent To Printer:

{ "Command": "Cfg.Prop",
"From": "Originator",
"To": "Receiver101",
"TrackNo": "Ex-3",
"Content": {
"Speed" : null,
"ODV.Symbol" : null,
"Label.Sensor":null
}
}

Printer Response:

{
"Command": "Success",
"From": "P-408106",
"To": "Originator",
"TrackNo": "Ex-3",
"Content": {
"Speed.Print-ips": {
"Type": "Dec",
"Perm": "RW",
"Value": 6,
"Min": 1,
"Max": 8,
"Inc": 1
},
"Speed.Print-mmps": {
"Type": "Enum",
"Perm": "RW",
"Value": "e152.4",
"Options": ["e25.4", "e50.8", "e76.2", "e101.6", "e127.0", "e152.4", "e177.8", "e203.2"]
},
"Speed.Rev-ips": {
"Type": "Dec",
"Perm": "RW",
"Value": 2,
"Min": 1,
"Max": 6,
"Inc": 1
},
"Speed.Rev-mmps": {
"Type": "Enum",
"Perm": "RW",
"Value": "e50.8",
"Options": ["e25.4", "e50.8", "e76.2", "e101.6", "e127.0", "e152.4"]
},
"Speed.Slew-ips": {
"Type": "Dec",
"Perm": "RW",
"Value": 6,
"Min": 1,
"Max": 8,
"Inc": 1
},
"Speed.Slew-mmps": {
"Type": "Enum",
"Perm": "RW",
"Value": "e152.4",
"Options": ["e25.4", "e50.8", "e76.2", "e101.6", "e127.0", "e152.4", "e177.8", "e203.2"]
},
"Speed.SlewControl": {
"Type": "Enum",
"Perm": "RW",
"Value": "eAutomatic",
"Options": ["eAutomatic", "eManual"]
},
"ODV.Symbol.Codabar-b": {
"Type": "Bool",
"Perm": "RW",
"Value": true
},
"ODV.Symbol.Code128-b": {
"Type": "Bool",
"Perm": "RW",
"Value": true
},
"ODV.Symbol.Code39-b": {
"Type": "Bool",
"Perm": "RW",
"Value": true
},
"ODV.Symbol.Code93-b": {
"Type": "Bool",
"Perm": "RW",
"Value": true
},
"ODV.Symbol.DataMatrix-b": {
"Type": "Bool",
"Perm": "RW",
"Value": true
},
"ODV.Symbol.Graphics-b": {
"Type": "Bool",
"Perm": "RW",
"Value": true
},
"ODV.Symbol.Int25-b": {
"Type": "Bool",
"Perm": "RW",
"Value": true
},
"ODV.Symbol.Orient": {
"Type": "Enum",
"Perm": "RW",
"Value": "eAll",
"Options": ["eAll", "ePicket", "eLadder"]
},
"ODV.Symbol.PDF417-b": {
"Type": "Bool",
"Perm": "RW",
"Value": true
},
"ODV.Symbol.QR-b": {
"Type": "Bool",
"Perm": "RW",
"Value": true
},
"ODV.Symbol.UPCEAN-b": {
"Type": "Bool",
"Perm": "RW",
"Value": true
},
"Label.Sensor": {
"Type": "Enum",
"Perm": "RW",
"Value": "eGap",
"Options": ["eDisable", "eMark", "eGap"]
}
}