DEVICEMGR is the object that handles every container of the project by name. It takes the container name as the first argument to add · remove · move materials (devices) and to query material counts and positions.
From 4.0 a container itself can also be accessed directly with CONTAINER["name"] (see the CONTAINER section below).
For the data of one material see DEVICE; containers are defined in the Device Data Editor.
Array · Map place a material only in an empty slot. AddDevice on a slot that already holds a material does not overwrite it and returns false. To replace one on purpose, use SetDevice.
AddDevice of Single · Queue · Stack accepts up to twice the capacity, to allow the momentary overlap while materials are handed over. If the over-capacity state lasts longer than 1 second, an error is logged.
The 3.x row-search functions GetDeviceRow · GetDeviceRankRow · GetEmptyRow were removed in 4.0 and replaced by the Get…Pos functions, which find (col, row) over the whole map at once.
Because the search happens in one call, the row and column cannot get out of step when the material state changes between two calls.
xscript
int col = 0;int row = 0;if( DEVICEMGR.GetDevicePos("Tray", /*frontToRear*/false, /*leftToRight*/true, /*ref*/col, /*ref*/row) == true ){ Log($"pick ( col={col}, row={row} )");}
// Move the order material to the next unitDEVICEMGR.MoveDevice(DEVICE_NAME, unitIndex - 1, DEVICE_NAME, unitIndex);// Remove the material that left the last unitDEVICEMGR.RemoveDevice(DEVICE_NAME, unitIndex);// Check the material count of all containersif( DEVICEMGR.GetDeviceCountAll() > 0 ){ // materials are still on the line}
CONTAINER["name"] is the container object itself. It behaves like the DEVICEMGR function of the same name, without the container name argument
(e.g. DEVICEMGR.MakeFull("Tray", 1) is the same as CONTAINER["Tray"].MakeFull(1)). For an unknown container name, properties return default values (0 · false) and functions do nothing.
xscript
// If the tray has an empty slot, put a Rank 2 material in the first empty slotif( CONTAINER["Tray"].IsFull == false ){ int col = 0; int row = 0; if( DEVICEMGR.GetEmptyPos("Tray", /*frontToRear*/false, /*leftToRight*/true, /*ref*/col, /*ref*/row) == true ) { CONTAINER["Tray"].AddDevice(col, row); DEVICE["Tray", col, row].Rank = 2; }}Log("Tray : {0} / {1}, empty = {2}", CONTAINER["Tray"].Count, CONTAINER["Tray"].Capacity, CONTAINER["Tray"].EmptyCount);
Property
Type
Description
Name
string
Container name
SensorName
string
Name of the sensor IO that detects whether material is present
Count
int
Number of materials held (read only)
Capacity
int
Number of materials it can hold — columns × rows for a Map. To change it, use DEVICEMGR.SetCapacity · SetMapSize
EmptyCount
int
Number of empty places (read only). 0 when over capacity
IsFull · IsEmpty
bool
Whether it is full (material count at or above capacity) · empty (read only)
HaveDevice
bool
Whether it holds at least one material (read only)
The first argument of a DEVICEMGR function is the container name. If no container has that name, the function logs an error and returns false (count · size functions return 0, column searches return -1).
Removes the materials of every container and removes all container registrations too. The project's containers are registered again when the project is reopened, but if the project is saved before that, the container definitions are dropped from the project
Adds a Single container (capacity 1). sensorName is the sensor IO name for that position, log sets whether to log. Returns false if the name already exists
bool Contains(string name)
Checks whether a container with the given name exists
bool SetCapacity(string containerName, int capacity)4.0+
Changes the capacity (1 or more). For a Map use SetMapSize. Shrinking an Array that still holds materials also removes the materials in the rear slots
bool SetMapSize(string containerName, int col, int row)4.0+
Changes the column · row count of a Map container (1 or more each). If materials remain, their positions may shift
Adds one material to a Single · Queue · Stack. Returns false for an Array · Map
bool AddDevice(string containerName, int index)
Places one material in empty slot index of an Array · Map
bool AddDevice(string containerName, int colIndex, int rowIndex)
Places one material in empty cell (colIndex, rowIndex) of a Map
bool SetDevice(string containerName, int index) · bool SetDevice(string containerName, int colIndex, int rowIndex)
Places a new material in a slot of an Array · Map. Unlike AddDevice it replaces a material that is already there (the existing data of that slot is lost)
bool RemoveDevice(string containerName, int index=-1)
Removes one material — the one that came in first for Single · Queue, the last one for Stack, slot index for Array · Map (-1 means the first material from the front)
bool RemoveDeviceMap(string containerName, int colIndex, int rowIndex)
Removes the material in cell (colIndex, rowIndex) of a Map
bool RemoveContainerDevice(string containerName)
Removes just one material (the same as RemoveDevice(name)). Returns true whenever the container exists, even if it is empty
bool ClearContainerDevice(string containerName)
Removes all materials of the container
bool MakeEmpty(string containerName)
The same as ClearContainerDevice
bool MakeFull(string containerName, int rank)
Fills every slot of an Array · Map with materials of rank rank (existing materials are replaced). Same as CONTAINER["name"].MakeFull(rank)
bool ClearAllDevice(void)
Removes the materials of every container. The containers remain
Moves a material from container name1 to container name2. The whole material data moves.
If the receiving side has no room (for Array · Map, the slot already holds a material) or there is no material to send, nothing is moved, false is returned and the material stays where it was.
For Array · Map containers, always give the position.
Method
Description
bool MoveDevice(string name1, string name2)
Moves the representative material, container to container
bool MoveDevice(string name1, int index1, string name2)
From a position in name1 to name2
bool MoveDevice(string name1, string name2, int index2)
From name1 to a position in name2
bool MoveDevice(string name1, int index1, string name2, int index2)
Both positions given
bool MoveDevice(string name1, int col1, int row1, string name2)
From a column/row in name1 to name2
bool MoveDevice(string name1, string name2, int col2, int row2)
From name1 to a column/row in name2
bool MoveDevice(string name1, int col1, int row1, string name2, int index2)
Column/row → index
bool MoveDevice(string name1, int index1, string name2, int col2, int row2)
Index → column/row
bool MoveDevice(string name1, int col1, int row1, string name2, int col2, int row2)
Both as column/row
bool MoveDeviceAll(string name1, string name2)
Moves all materials from name1 to name2. Both containers must be of the same type; an Array · Map also needs the same capacity and an empty receiving side. Not available for Stack
Parameter
Description
string name1
The container to move from
string name2
The container to move to
int index1 / col1 / row1
The material position in the source container
int index2 / col2 / row2
The material position in the destination container
frontToRear is the row search direction (false : from row 0 / true : from the last row), and leftToRight is the column search direction (true : from column 0 / false : from the last column).
On a container that is not a Map, nothing is found (false, column searches return -1).
Method
Description
bool GetDevicePos(string containerName, bool frontToRear, bool leftToRight, ref int col, ref int row)4.0+
Finds the first position that holds a material. Returns false when there is none, and col · row are -1
bool GetDeviceRankPos(string containerName, int rank, bool frontToRear, bool leftToRight, ref int col, ref int row)4.0+
Finds the first position of a material with rank rank
bool GetEmptyPos(string containerName, bool frontToRear, bool leftToRight, ref int col, ref int row)4.0+
Finds the first empty position (for putting down)
int GetDeviceCol(string containerName, int row, bool leftToRight)
Returns the column holding a material within the given row (-1 when none)
int GetDeviceRankCol(string containerName, int row, int rank, bool leftToRight)
Returns the column of a material with rank rank within the given row (-1 when none)
int GetEmptyCol(string containerName, int row, bool leftToRight)
Returns an empty column within the given row (-1 when none)
Compares material presence with the sensor state in every container that has a sensor. Returns false if any of them differs or a sensor IO name is wrong. Containers without a sensor are not compared
string GetDeviceDataSensorCompareResult(void)
Returns a string with one line for each container that does not match (an empty string when all match)
bool AddLogDeviceInfo(string info)
Writes name(material count/capacity) of each container as one debug log line. info is a label added to that line (can be turned off with SYS.SetDebugLog(false))
void AddLogContainerDevice(string containerName)
Logs every slot of the container as ● (material) · ○ (empty). A Map is logged one line per row
Get the size with GetColumnCount · GetRowCount for a Map and GetCapacity for an Array, then visit the slots in a loop.
Remove materials that left the line with RemoveDevice. When initializing the machine, clear all material information with ClearAllDevice (the containers remain).
ClearContainerAll also removes the container registrations, so do not use it during operation.
The 3.x functions GetDeviceRow · GetDeviceRankRow · GetEmptyRow were removed in 4.0 — replace them with GetDevicePos · GetDeviceRankPos · GetEmptyPos.