XScript 手册 · Chapter 23

DEVICEMGR — 设备管理器

DEVICEMGR 是管理整个容器(产线节点)的全局对象。如同托盘/弹匣那样 多个位置存在多个设备的情况下,以 Row × Col 映射进行管理, 并对设备的添加/删除/移动/查询进行统一处理。

基本示例

xscript
int trayRowCount = DEVICEMGR.GetRowCount("Tray");
int trayColCount = DEVICEMGR.GetColumnCount("Tray");
 
// 将整个托盘填充为 Rank 1
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);

实战示例 — 单元间移动

xscript
// 将订单移动至下一个单元
DEVICEMGR.MoveDevice(DEVICE_NAME, unitIndex - 1, DEVICE_NAME, unitIndex);
 
// 在最后一个单元排出
DEVICEMGR.RemoveDevice(DEVICE_NAME, unitIndex);
 
// 确认总计数
if (DEVICEMGR.GetDeviceCountAll() > 0)
{
    // 产线上仍残留物体
}

方法

容器管理

签名说明
bool ClearContainerAll(void)全部初始化
bool AddContainer(string name, string sensorName = "", bool log = true)添加容器

设备添加/删除

签名说明
bool AddDevice(string container) / AddDevice(string container, int index)添加设备
bool RemoveDevice(string container) / RemoveDevice(string container, int index)移除设备
bool RemoveDeviceMap(string container, int col, int row)按映射坐标移除
bool ClearAllDevice(void)全部移除

移动 · 复制

签名说明
bool MoveDevice(string name1, int index1, string name2, int index2)移动设备

查询

签名说明
int GetRowCount(string container)行数
int GetColumnCount(string container)列数
int GetDeviceCount(string container)该容器的设备数
int GetDeviceCountAll(void)全部容器的设备数
bool IsFull(string container)是否已满
bool IsEmpty(string container)是否为空

填充映射

签名说明
bool MakeFull(string container, int rank)以指定 Rank 填充
bool MakeEmpty(string container)全部清空

技巧

  • Tray/Cassette 这类阵列型容器,先用 GetRowCount/GetColumnCount 查询尺寸后再以二重 for 遍历。
  • 单一索引容器(产线节点)用 AddDevice(name, index) 指定位置。
  • 为防止漏排,务必在最后一个单元调用 RemoveDevice,或用 ClearAllDevice 初始化。