XScript Manual · Chapter 22
DEVICE — material (device) data
DEVICE is the data of one material held in a container (ID · barcodes · rank · alignment result · order information, …).
Material handling in QMS has the three levels below; containers are defined in the Device Data Editor.
| Form | Target | Description |
|---|---|---|
DEVICEMGR | All containers | Adds · removes · moves · queries materials by container name — DEVICEMGR |
CONTAINER["name"] 4.0+ | One container | A place where materials sit, such as a conveyor · picker · magazine · tray — see the CONTAINER section of DEVICEMGR |
DEVICE["name", …] | One material | This chapter |
DEVICE forms
| Form | Material it refers to |
|---|---|
DEVICE["name"] | The representative material of the container — for Single · Queue the one that came in first, for Stack the one that came in last, for Array · Map the first one from the front |
DEVICE["name", index] | Slot index of an Array · Map container (from 0). For a Map the number runs row × column count + column |
DEVICE["name", col, row] | Cell (col, row) of a Map container (from 0) |
- When the form points to a slot without material, reading a property gives the default value (
false· 0 · empty string), and assigning a property does nothing (no error). Create the material first withDEVICEMGR.AddDevicebefore writing values. - Assigning
HaveDeviceactually creates (true— left as is if one already exists) or removes (false) the material at that place. - Use Single · Queue · Stack containers without an index, as
DEVICE["name"]. With an index the material is treated as missing.
Example
xscript
//===============================
// DEVICE check
if( DEVICE["INCV"].HaveDevice == true )
{
Log("ID = {0}, RANK = {1}", DEVICE["INCV"].Id, DEVICE["INCV"].Rank);
Log("Result X={0}, Y={1}, TH={2}", DEVICE["INCV"].AlignResultX,
DEVICE["INCV"].AlignResultY, DEVICE["INCV"].AlignResultTh);
}
else
{
// If the device is missing, add it first and then set the values
DEVICEMGR.AddDevice("INCV");
// Align result values ( example )
double rx = 0.12;
double ry = -0.05;
double rth = 0.3;
// Set ID and RANK
DEVICE["INCV"].Id = "INCV_ID";
DEVICE["INCV"].Rank = 1;
DEVICE["INCV"].AlignResultX = rx;
DEVICE["INCV"].AlignResultY = ry;
DEVICE["INCV"].AlignResultTh = rth;
}Real-world — carrying order information with the material
Values such as the order number and recipe that are stored on the material (DEVICE) travel with it when DEVICEMGR.MoveDevice moves the material.
DEVICE_NAME is assumed to be an Array container with one slot per unit.
xscript
string DEVICE_NAME = "UnitLine"; // Array container with one slot per unit
FUNCTION bool AddOrder(string orderNumber, string orderItemId, string recipe)
{
// Create a material at the input position ( slot 0 ) and store the order information
if( DEVICEMGR.AddDevice(DEVICE_NAME, 0) == false )
{
return false; // slot 0 already holds a material
}
DEVICE[DEVICE_NAME, 0].OrderNumber = orderNumber;
DEVICE[DEVICE_NAME, 0].OrderItemNumber = orderItemId;
DEVICE[DEVICE_NAME, 0].Recipe = recipe;
DEVICE[DEVICE_NAME, 0].Measure = "";
return true;
}
FUNCTION bool PassToNextUnit(int unitIndex)
{
// Move the whole material data to the next slot ( slot unitIndex - 1 → slot unitIndex )
if( DEVICEMGR.MoveDevice(DEVICE_NAME, unitIndex - 1, DEVICE_NAME, unitIndex) == false )
{
return false; // nothing to move, or the target slot already holds a material
}
Log("Order {0} -> unit {1}", DEVICE[DEVICE_NAME, unitIndex].OrderNumber, unitIndex);
return true;
}Methods
| Method | Description |
|---|---|
string ToString() | Returns the material object as a string. It returns only the object type name (XMachine.XDevice) and contains no material values, so read the properties directly to log the contents |
Properties
All properties can be read and written.
| Property | Type | Description |
|---|---|---|
HaveDevice | bool | Whether a material is present. Assigning it creates (true) or removes (false) the material at that place |
Id · PartId · LotId | string | Material ID · part ID · lot ID |
Index | int | Index value |
Result | int | Result value |
Rank | int | Rank — a value that classifies the material type. 1 for a newly created material |
Bincode · Bin | int | Other names for Rank — they read and write the same value |
Level | int | Level value |
Barcode1 ~ Barcode5 | string | Barcodes #1 ~ #5 |
Message · ErrorMessage | string | Message · error message |
ErrorCode | int | Error code |
EjectMode | bool | Marks a material to be ejected |
PassMode | bool | Marks a material that passes through without work |
AlignVisionDone · InspectionDone · TestDone · WorkDone | bool | Whether align vision · inspection · test · work (printing, …) is done |
IsGood | bool | Whether the material is good |
AlignResultX · AlignResultY · AlignResultTh | double | Alignment result X · Y · θ |
SubDevice | string | Sub-device information (written as a string, e.g. "OXXOOOO") |
Data · Data1 ~ Data5 | string | Free-use data |
OrderNumber · OrderItemNumber | string | Order number · order item number |
Recipe | string | Order contents — free format (e.g. a comma-separated string) |
Measure | string | Weighing result |
IsReorder | bool | Whether it is a reorder |
Notes
- If the material does not exist, create it with
DEVICEMGR.AddDevicebefore writing values — assignments to a missing material are ignored. DEVICEMGR.MoveDevicemoves the whole material data, so keep values that must travel with the material (order number · measurement, …) in DEVICE properties.EjectModeis only a mark meaning "eject this material".DEVICEMGR.RemoveDeviceis what actually removes it.- Writing
Bincode·BinchangesRankto the same value.