XScript Manual · Chapter 23

title: "DEVICEMGR — device manager" chapter: 23

DEVICEMGR — device manager

DEVICEMGR is the global object that manages all containers and their devices. For tray/magazine-style containers it maintains a Row × Col map; for line nodes, a single index. Handles add / remove / move / query in one place.

Basic example

int trayRowCount = DEVICEMGR.GetRowCount("Tray");
int trayColCount = DEVICEMGR.GetColCount("Tray");
 
DEVICEMGR.MakeFull("Tray", 1);
 
if (DEVICEMGR.IsFull("Tray") == true)
{
    Log("Tray Is Full. Col = {0}, Row = {1}", trayColCount, trayRowCount);
}
else
{
    Log("Tray Is Not Full. Col = {0}, Row = {1}", trayColCount, trayRowCount);
}
 
int devCount = DEVICEMGR.GetDeviceCount("Tray");
Log("Before Remove, Device Count = {0}", devCount);
 
DEVICEMGR.RemoveDeviceMap("Tray", 0, 0);
 
devCount = DEVICEMGR.GetDeviceCount("Tray");
Log("After Remove, Device Count = {0}", devCount);

Real-world — unit-to-unit handoff

DEVICEMGR.MoveDevice(DEVICE_NAME, unitIndex - 1, DEVICE_NAME, unitIndex);
 
// Eject in the last unit
DEVICEMGR.RemoveDevice(DEVICE_NAME, unitIndex);
 
if (DEVICEMGR.GetDeviceCountAll() > 0)
{
    // Line still has items
}

Methods

Containers

SignatureDescription
bool ClearContainerAll(void)Clear everything
bool AddContainer(string name, string sensorName = "", bool log = true)Add container
int GetContainerCount(void)Container count

Add / remove

SignatureDescription
bool AddDevice(string container) / AddDevice(string container, int index)Add
bool RemoveDevice(string container) / RemoveDevice(string container, int index)Remove
bool RemoveDeviceMap(string container, int col, int row)Remove by map coord
bool ClearAllDevice(void)Remove all

Move / copy

SignatureDescription
bool MoveDevice(string name1, int index1, string name2, int index2)Move
bool CopyDevice(...)Copy

Query

SignatureDescription
int GetRowCount(string container)Rows
int GetColCount(string container)Columns
int GetDeviceCount(string container)Per-container count
int GetDeviceCountAll(void)Total count
bool IsFull(string container)Full
bool IsEmpty(string container)Empty

Fill

SignatureDescription
bool MakeFull(string container, int rank)Fill all slots with rank
bool MakeEmpty(string container)Clear all slots

Tips

  • Array-style containers (trays/cassettes): read GetRowCount/GetColCount and iterate with nested for.
  • Linear line nodes: use indexed AddDevice(name, index).
  • Always call RemoveDevice in the last unit — or ClearAllDevice on reset — to prevent phantom occupancy on restart.