以下部分描述了用於讀取/寫入印表機設定的 JSON(JavaScript 物件標記法)資料交換語法。
請注意,SettingsReadWrite 類別提供了讀取/寫入設定的支援,並使用下方定義的 JSON 命令結構與印表機進行通訊。這提供給希望使用印表機支援的 JSON 介面直接與印表機通訊的使用者作為參考資料。
通用 JSON 命令語法 - 管理端口
以下是印表機 JSON 命令的一般語法。
請注意, To 和 From 鍵是可選的,如果應用程式不需要,可以省略這些參數。這些參數會被交換並從印表機回傳。
印表機會使用相同TrackNo回應命令,呼叫者/發送者可以使用此編號選擇對應的回應,特別是當多個命令發送給印表機時。如果印表機回傳數據,數據會包含在**Content**欄位中。
完整命令:
{ "Command": <command>,
"From": <optional>,
"To": <optional>,
"TrackNo": <AnyTrackingString>,
"Content": { <content> }
}
最小命令:不包含 To 或 From 選用鍵。
{ "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":):
- "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"]
}
}