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.

FormTargetDescription
DEVICEMGRAll containersAdds · removes · moves · queries materials by container name — DEVICEMGR
CONTAINER["name"] 4.0+One containerA place where materials sit, such as a conveyor · picker · magazine · tray — see the CONTAINER section of DEVICEMGR
DEVICE["name", …]One materialThis chapter

DEVICE forms

FormMaterial 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 with DEVICEMGR.AddDevice before writing values.
  • Assigning HaveDevice actually 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

MethodDescription
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.

PropertyTypeDescription
HaveDeviceboolWhether a material is present. Assigning it creates (true) or removes (false) the material at that place
Id · PartId · LotIdstringMaterial ID · part ID · lot ID
IndexintIndex value
ResultintResult value
RankintRank — a value that classifies the material type. 1 for a newly created material
Bincode · BinintOther names for Rank — they read and write the same value
LevelintLevel value
Barcode1 ~ Barcode5stringBarcodes #1 ~ #5
Message · ErrorMessagestringMessage · error message
ErrorCodeintError code
EjectModeboolMarks a material to be ejected
PassModeboolMarks a material that passes through without work
AlignVisionDone · InspectionDone · TestDone · WorkDoneboolWhether align vision · inspection · test · work (printing, …) is done
IsGoodboolWhether the material is good
AlignResultX · AlignResultY · AlignResultThdoubleAlignment result X · Y · θ
SubDevicestringSub-device information (written as a string, e.g. "OXXOOOO")
Data · Data1 ~ Data5stringFree-use data
OrderNumber · OrderItemNumberstringOrder number · order item number
RecipestringOrder contents — free format (e.g. a comma-separated string)
MeasurestringWeighing result
IsReorderboolWhether it is a reorder

Notes

  • If the material does not exist, create it with DEVICEMGR.AddDevice before writing values — assignments to a missing material are ignored.
  • DEVICEMGR.MoveDevice moves the whole material data, so keep values that must travel with the material (order number · measurement, …) in DEVICE properties.
  • EjectMode is only a mark meaning "eject this material". DEVICEMGR.RemoveDevice is what actually removes it.
  • Writing Bincode · Bin changes Rank to the same value.
Subscribe